Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
@@ -0,0 +1,64 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(gflash3)
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available UI and Vis drivers by default
# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR})
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(ExGflash3 ExGflash3.cc ${sources} ${headers})
target_link_libraries(ExGflash3 ${Geant4_LIBRARIES} )
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build gflash. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(gflash_SCRIPTS
test.mac vis.mac
)
foreach(_script ${gflash_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Add program to the project targets
# (this avoids the need of typing the program name after make)
#
add_custom_target(gflash3 DEPENDS ExGflash3)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS ExGflash3 DESTINATION bin)
@@ -0,0 +1,161 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflash3.cc
/// \brief Main program of the parameterisations/gflash/gflash3 example
//
// Created by Joanna Weng 26.11.2004
// G4 includes
#include "G4Types.hh"
#include "G4ios.hh"
#include "G4Timer.hh"
#include "G4UImanager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#else
#include "G4RunManager.hh"
#endif
// my project
#include "ExGflash3DetectorConstruction.hh"
#include "ExGflash3ParallelWorld.hh"
#include "ExGflashActionInitialization.hh"
#include "FTFP_BERT.hh"
#include "G4FastSimulationPhysics.hh"
#include "G4ParallelWorldPhysics.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc,char** argv)
{
// Instantiate G4UIExecutive if interactive mode
G4UIExecutive* ui = nullptr;
if ( argc == 1 ) {
ui = new G4UIExecutive(argc, argv);
}
// timer to see GFlash performance
G4Timer timer;
timer.Start();
G4cout<<"+-------------------------------------------------------+"<<G4endl;
G4cout<<"| |"<<G4endl;
G4cout<<"| This is an example of Shower |"<<G4endl;
G4cout<<"| Parameterization with GFLASH |"<<G4endl;
G4cout<<"+-------------------------------------------------------+"<<G4endl;
#ifdef G4MULTITHREADED
G4MTRunManager * runManager = new G4MTRunManager;
runManager->SetNumberOfThreads(1);
G4cout<<"+-------------------------------------------------------+"<<G4endl;
G4cout<<"| Constructing MT run manager |"<<G4endl;
G4cout<<"+-------------------------------------------------------+"<<G4endl;
#else
G4RunManager * runManager = new G4RunManager;
G4cout<<"+-------------------------------------------------------+"<<G4endl;
G4cout<<"| Constructing sequential run manager |"<<G4endl;
G4cout<<"+-------------------------------------------------------+"<<G4endl;
#endif
// UserInitialization classes (mandatory)
G4cout<<"# GFlash Example: Detector Construction"<<G4endl;
auto detector = new ExGflash3DetectorConstruction();
detector->RegisterParallelWorld(new ExGflash3ParallelWorld("parallelWorld"));
runManager->SetUserInitialization(detector);
// G4cout<<"# GFlash Example: Physics "<<G4endl;
// -- Select a physics list:
G4VModularPhysicsList* physicsList = new FTFP_BERT();
// -- Create a fast simulation physics constructor, used to augment
// -- the above physics list to allow for fast simulation:
G4FastSimulationPhysics* fastSimulationPhysics = new G4FastSimulationPhysics();
// -- We now configure the fastSimulationPhysics object.
// -- The gflash model (GFlashShowerModel, see ExGflashDetectorConstruction.cc)
// -- is applicable to e+ and e- : we augment the physics list for these
// -- particles (by adding a G4FastSimulationManagerProcess with below's
// -- calls), this will make the fast simulation to be activated:
fastSimulationPhysics->ActivateFastSimulation("e-");
fastSimulationPhysics->ActivateFastSimulation("e+");
// -- Register this fastSimulationPhysics to the physicsList,
// -- when the physics list will be called by the run manager
// -- (will happen at initialization of the run manager)
// -- for physics process construction, the fast simulation
// -- configuration will be applied as well.
physicsList->RegisterPhysics( new G4ParallelWorldPhysics("parallelWorld") );
physicsList->RegisterPhysics( fastSimulationPhysics );
runManager->SetUserInitialization(physicsList);
// Action initialization:
runManager->SetUserInitialization(new ExGflashActionInitialization);
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
UImanager->ApplyCommand("/run/verbose 0");
runManager->Initialize();
UImanager->ApplyCommand("/Step/Verbose 0");
if (ui) // Define UI terminal for interactive mode
{
UImanager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
}
else // Batch mode
{
G4String s=*(argv+1);
UImanager->ApplyCommand("/control/execute "+s);
}
delete visManager;
delete runManager;
timer.Stop();
G4cout << G4endl;
G4cout << "******************************************";
G4cout << G4endl;
G4cout << "Total Real Elapsed Time is: "<< timer.GetRealElapsed();
G4cout << G4endl;
G4cout << "Total System Elapsed Time: " << timer.GetSystemElapsed();
G4cout << G4endl;
G4cout << "Total GetUserElapsed Time: " << timer.GetUserElapsed();
G4cout << G4endl;
G4cout << "******************************************";
G4cout << G4endl;
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,18 @@
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := ExGflash3
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../../../..
endif
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/binmake.gmk
@@ -0,0 +1,84 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflash3DetectorConstruction.hh
/// \brief Definition of the ExGflash3DetectorConstruction class
//
#ifndef ExGflash3DetectorConstruction_h
#define ExGflash3DetectorConstruction_h 1
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
class G4LogicalVolume;
class G4VPhysicalVolume;
class G4Region;
class GFlashHomoShowerParameterisation;
class GFlashShowerModel;
class GFlashHitMaker;
class GFlashParticleBounds;
class ExGflash3DetectorConstruction : public G4VUserDetectorConstruction
{
public:
ExGflash3DetectorConstruction();
~ExGflash3DetectorConstruction();
virtual G4VPhysicalVolume* Construct();
virtual void ConstructSDandField();
private:
G4Region* fRegion;
static G4ThreadLocal GFlashShowerModel* fFastShowerModel;
static G4ThreadLocal GFlashHomoShowerParameterisation* fParameterisation;
static G4ThreadLocal GFlashParticleBounds* fParticleBounds;
static G4ThreadLocal GFlashHitMaker* fHitMaker;
};
#endif
@@ -0,0 +1,54 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
#ifndef ExGflash3ParallelWorld_h
#define ExGflash3ParallelWorld_h 1
#include "G4VUserParallelWorld.hh"
#include "globals.hh"
class G4LogicalVolume;
class G4VPhysicalVolume;
class ExGflash3ParallelWorld : public G4VUserParallelWorld
{
public:
ExGflash3ParallelWorld(G4String aWorldName);
~ExGflash3ParallelWorld();
virtual void Construct() final;
virtual void ConstructSD() final;
const G4VPhysicalVolume* GetCristal(int aNumCrystal)
{return fCrystalPhys[aNumCrystal];};
private:
G4LogicalVolume* fCrystalLog;
G4VPhysicalVolume* fCrystalPhys[100];
};
#endif
@@ -0,0 +1,62 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflash3SensitiveDetector.hh
/// \brief Definition of the ExGflash3SensitiveDetector class
//
#ifndef EX1GFLASHSENSITIVEDETECTOR_H
#define EX1GFLASHSENSITIVEDETECTOR_H
#include "G4VSensitiveDetector.hh"
#include "G4VGFlashSensitiveDetector.hh"
#include "ExGflashHitsCollection.hh"
#include "globals.hh"
class G4GFlashSpot;
class ExGflash3ParallelWorld;
class G4Step;
class G4HCofThisEvent;
class G4TouchableHistory;
class ExGflash3SensitiveDetector: public G4VSensitiveDetector,
public G4VGFlashSensitiveDetector {
public:
ExGflash3SensitiveDetector(G4String, ExGflash3ParallelWorld* det);
~ExGflash3SensitiveDetector();
virtual void Initialize(G4HCofThisEvent*);
virtual G4bool ProcessHits(G4Step*,G4TouchableHistory*);
virtual G4bool ProcessHits(G4GFlashSpot*aSpot,G4TouchableHistory*);
virtual void EndOfEvent(G4HCofThisEvent*);
private:
ExGflashHitsCollection* fCaloHitsCollection;
ExGflash3ParallelWorld* fDetector;
G4int fHCID;
};
#endif
@@ -0,0 +1,50 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashActionInitialization.hh
/// \brief Definition of the ExGflashActionInitialization class
#ifndef ExGflashActionInitialization_h
#define ExGflashActionInitialization_h 1
#include "G4VUserActionInitialization.hh"
/// Action initialization class.
///
class ExGflashActionInitialization : public G4VUserActionInitialization
{
public:
ExGflashActionInitialization();
virtual ~ExGflashActionInitialization();
virtual void BuildForMaster() const;
virtual void Build() const;
};
#endif
@@ -0,0 +1,51 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashEventAction.hh
/// \brief Definition of the ExGflashEventAction class
//
#ifndef ExGflashEventAction_h
#define ExGflashEventAction_h
#include "G4UserEventAction.hh"
#include "G4Timer.hh"
#include "globals.hh"
class ExGflashEventAction: public G4UserEventAction {
public:
ExGflashEventAction();
~ExGflashEventAction();
virtual void BeginOfEventAction(const G4Event*);
virtual void EndOfEventAction(const G4Event*);
private:
G4int fNevent;
G4double fDtime;
G4int fCalorimeterCollectionId;
G4Timer fTimerIntern;
};
#endif
@@ -0,0 +1,118 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashHit.hh
/// \brief Definition of the ExGflashHit class
//
#ifndef ExGflashHit_h
#define ExGflashHit_h 1
#include "G4VHit.hh"
#include "G4THitsCollection.hh"
#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
class G4LogicalVolume;
class ExGflashHit : public G4VHit
{
public:
ExGflashHit();
ExGflashHit(G4LogicalVolume* logVol);
~ExGflashHit();
ExGflashHit(const ExGflashHit &right);
const ExGflashHit& operator=(const ExGflashHit &right);
G4bool operator==(const ExGflashHit &right) const;
inline void *operator new(size_t);
inline void operator delete(void *aHit);
void *operator new(size_t,void*p){return p;}
#ifndef G4NOT_ISO_DELETES
void operator delete(void *,void*){}
#endif
virtual void Draw();
virtual void Print();
private:
G4double fEdep;
G4ThreeVector fPos;
G4int fCrystalNumber;
G4ThreeVector fStart;
G4RotationMatrix fRot;
const G4LogicalVolume* fLogV;
public:
inline void SetEdep(G4double de)
{ fEdep = de; };
inline void AddEdep(G4double de)
{ fEdep += de; };
inline G4double GetEdep()
{ return fEdep; };
inline void SetPos(G4ThreeVector xyz)
{ fPos = xyz; };
inline G4int GetCrystalNum()
{ return fCrystalNumber; };
inline void SetCrystalNum(G4int num)
{ fCrystalNumber=num; };
inline G4ThreeVector GetPos()
{ return fPos; };
inline void SetStart(G4ThreeVector xyz)
{ fStart = xyz; };
inline G4ThreeVector GetStart()
{ return fStart; };
inline void SetRot(G4RotationMatrix rmat)
{ fRot = rmat; };
inline G4RotationMatrix GetRot()
{ return fRot; };
inline const G4LogicalVolume * GetLogV()
{ return fLogV; };
};
typedef G4THitsCollection<ExGflashHit> ExGflashHitsCollection;
extern G4ThreadLocal G4Allocator<ExGflashHit>* ExGflashHitAllocator;
inline void* ExGflashHit::operator new(size_t)
{
if(!ExGflashHitAllocator) ExGflashHitAllocator = new G4Allocator<ExGflashHit>;
return (void *) ExGflashHitAllocator->MallocSingle();
}
inline void ExGflashHit::operator delete(void *aHit)
{
ExGflashHitAllocator->FreeSingle((ExGflashHit*) aHit);
}
#endif
@@ -0,0 +1,35 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashHitsCollection.hh
/// \brief Definition of the ExGflashHitsCollection class
//
#ifndef ExGflashHitsCollection_h
#define ExGflashHitsCollection_h
#include "G4THitsCollection.hh"
class ExGflashHit;
typedef G4THitsCollection<ExGflashHit> ExGflashHitsCollection;
#endif
@@ -0,0 +1,52 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashPrimaryGeneratorAction.hh
/// \brief Definition of the ExGflashPrimaryGeneratorAction class
//
#ifndef ExGflashPrimaryGeneratorAction_h
#define ExGflashPrimaryGeneratorAction_h
#include "G4VUserPrimaryGeneratorAction.hh"
class G4Event;
class G4GeneralParticleSource;
class ExGflashPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
ExGflashPrimaryGeneratorAction();
~ExGflashPrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event* anEvent);
private:
G4GeneralParticleSource* fParticleGun;
};
#endif
@@ -0,0 +1,51 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashRunAction.hh
/// \brief Definition of the ExGflashRunAction class
//
#ifndef ExGflashRunAction_h
#define ExGflashRunAction_h
#include "G4UserRunAction.hh"
#include "globals.hh"
class G4Run;
class ExGflashRunAction : public G4UserRunAction
{
public:
ExGflashRunAction();
~ExGflashRunAction();
virtual void BeginOfRunAction(const G4Run* aRun);
virtual void EndOfRunAction(const G4Run* aRun);
private:
G4int fRunID;
};
#endif
@@ -0,0 +1,214 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflash3DetectorConstruction.cc
/// \brief Implementation of the ExGflash3DetectorConstruction class
//
// Created by Joanna Weng 26.11.2004
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// User Classes
#include "ExGflash3DetectorConstruction.hh"
// G4 Classes
#include "G4NistManager.hh"
#include "G4Material.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4Box.hh"
#include "G4SDManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4SystemOfUnits.hh"
#include "G4AutoDelete.hh"
#include "globals.hh"
//fast simulation
#include "GFlashHomoShowerParameterisation.hh"
#include "G4FastSimulationManager.hh"
#include "GFlashShowerModel.hh"
#include "GFlashHitMaker.hh"
#include "GFlashParticleBounds.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal GFlashShowerModel* ExGflash3DetectorConstruction::fFastShowerModel = 0;
G4ThreadLocal
GFlashHomoShowerParameterisation* ExGflash3DetectorConstruction::fParameterisation = 0;
G4ThreadLocal GFlashParticleBounds* ExGflash3DetectorConstruction::fParticleBounds = 0;
G4ThreadLocal GFlashHitMaker* ExGflash3DetectorConstruction::fHitMaker = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflash3DetectorConstruction::ExGflash3DetectorConstruction()
:G4VUserDetectorConstruction(), fRegion(nullptr)
{
G4cout<<"ExGflash3DetectorConstruction::Detector constructor"<<G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflash3DetectorConstruction::~ExGflash3DetectorConstruction()
{
delete fFastShowerModel;
delete fParameterisation;
delete fParticleBounds;
delete fHitMaker;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* ExGflash3DetectorConstruction::Construct()
{
//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
G4cout << "Defining the materials" << G4endl;
// Get nist material manager
G4NistManager* nistManager = G4NistManager::Instance();
// Build materials
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4");
/*******************************
* The Experimental Hall *
*******************************/
G4double experimentalHall_x=1000.*cm;
G4double experimentalHall_y=1000.*cm;
G4double experimentalHall_z=1000.*cm;
G4VSolid* experimentalHall_box
= new G4Box("expHall_box", // World Volume
experimentalHall_x, // x size
experimentalHall_y, // y size
experimentalHall_z); // z size
G4LogicalVolume* experimentalHallLog
= new G4LogicalVolume(experimentalHall_box,
air,
"expHallLog",
0, //opt: fieldManager
0, //opt: SensitiveDetector
0); //opt: UserLimits
G4VPhysicalVolume* experimentalHall_phys
= new G4PVPlacement(0,
G4ThreeVector(), //at (0,0,0)
"expHall",
experimentalHallLog,
0,
false,
0);
//------------------------------
// Calorimeter segments
//------------------------------
// Simplified `CMS-like` PbWO4 crystal calorimeter
G4int nbOfCrystals = 10; // this are the crystals PER ROW in this example
// cube of 10 x 10 crystals
// don't change it @the moment, since
// the readout in event action assumes this
// dimensions and is not automatically adapted
// in this version of the example :-(
// Simplified `CMS-like` PbWO4 crystal calorimeter
G4double calo_xside = 31*cm;
G4double calo_yside = 31*cm;
G4double calo_zside = 24*cm;
G4double crystalWidth = 3*cm;
G4double crystalLength = 24*cm;
calo_xside = (crystalWidth*nbOfCrystals)+1*cm;
calo_yside = (crystalWidth*nbOfCrystals)+1*cm;
calo_zside = crystalLength;
G4Box* calo_box= new G4Box("CMS calorimeter", // its name
calo_xside/2., // size
calo_yside/2.,
calo_zside/2.);
G4LogicalVolume* caloLog
= new G4LogicalVolume(calo_box, // its solid
pbWO4, // its material
"calo log", // its name
0, // opt: fieldManager
0, // opt: SensitiveDetector
0); // opt: UserLimit
G4double xpos = 0.0;
G4double ypos = 0.0;
G4double zpos = 100.0*cm;
new G4PVPlacement(0,
G4ThreeVector(xpos, ypos, zpos),
caloLog,
"calorimeter",
experimentalHallLog,
false,
1);
// Individual crystals are created as part of the readout geometry in the parallel world
experimentalHallLog->SetVisAttributes(G4VisAttributes::GetInvisible());
G4VisAttributes* caloVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
caloLog->SetVisAttributes(caloVisAtt);
// define the fParameterisation region
fRegion = new G4Region("crystals");
caloLog->SetRegion(fRegion);
fRegion->AddRootLogicalVolume(caloLog);
return experimentalHall_phys;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflash3DetectorConstruction::ConstructSDandField()
{
// SD moved to parallel world
// -- fast simulation models:
// **********************************************
// * Initializing shower modell
// ***********************************************
G4cout << "Creating shower parameterization models" << G4endl;
fFastShowerModel = new GFlashShowerModel("fFastShowerModel", fRegion);
fParameterisation = new GFlashHomoShowerParameterisation(fRegion->GetMaterialIterator()[0]);
fFastShowerModel->SetParameterisation(*fParameterisation);
// Energy Cuts to kill particles:
fParticleBounds = new GFlashParticleBounds();
fFastShowerModel->SetParticleBounds(*fParticleBounds);
// Makes the EnergieSpots
fHitMaker = new GFlashHitMaker();
// Important: use SD defined in different geometry
fHitMaker->SetNameOfWorldWithSD("parallelWorld");
fFastShowerModel->SetHitMaker(*fHitMaker);
G4cout<<"end shower parameterization."<<G4endl;
// **********************************************
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,172 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// User Classes
#include "ExGflash3ParallelWorld.hh"
#include "ExGflash3SensitiveDetector.hh"
// G4 Classes
#include "G4NistManager.hh"
#include "G4Material.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4Box.hh"
#include "G4SDManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4SystemOfUnits.hh"
#include "G4AutoDelete.hh"
#include "globals.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflash3ParallelWorld::ExGflash3ParallelWorld(G4String aWorldName)
:G4VUserParallelWorld(aWorldName), fCrystalLog(nullptr), fCrystalPhys{}
{
G4cout<<"ExGflash3ParallelWorld::Parralel world constructor"<<G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflash3ParallelWorld::~ExGflash3ParallelWorld() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflash3ParallelWorld::Construct()
{
// In parallel world material does not matter
G4Material* dummy = nullptr;
// Build parallel/ghost geometry:
auto ghostLogicalVolume = GetWorld()->GetLogicalVolume();
// Use part of the Ex1GflashDetectorConstruction (without individual crystals)
G4int nbOfCrystals = 10; // this are the crystals PER ROW in this example
// cube of 10 x 10 crystals
// don't change it @the moment, since
// the readout in event action assumes this
// dimensions and is not automatically adapted
// in this version of the example :-(
// Simplified `CMS-like` PbWO4 crystal calorimeter
G4double calo_xside = 31*cm;
G4double calo_yside = 31*cm;
G4double calo_zside = 24*cm;
G4double crystalWidth = 3*cm;
G4double crystalLength = 24*cm;
calo_xside = (crystalWidth*nbOfCrystals)+1*cm;
calo_yside = (crystalWidth*nbOfCrystals)+1*cm;
calo_zside = crystalLength;
G4Box* calo_box= new G4Box("CMS calorimeter", // its name
calo_xside/2., // size
calo_yside/2.,
calo_zside/2.);
G4LogicalVolume* caloLog
= new G4LogicalVolume(calo_box, // its solid
dummy, // its material
"calo log", // its name
0, // opt: fieldManager
0, // opt: SensitiveDetector
0); // opt: UserLimit
G4double xpos = 0.0;
G4double ypos = 0.0;
G4double zpos = 100.0*cm;
new G4PVPlacement(0,
G4ThreeVector(xpos, ypos, zpos),
caloLog,
"calorimeter",
ghostLogicalVolume,
false,
1);
// Crystals
G4VSolid* crystal_box
= new G4Box("Crystal", // its name
crystalWidth/2,
crystalWidth/2,
crystalLength/2);
// size
fCrystalLog
= new G4LogicalVolume(crystal_box, // its solid
dummy, // its material
"CrystalLog"); // its name
for (G4int i=0; i<nbOfCrystals; i++)
{
for (G4int j=0; j<nbOfCrystals; j++)
{
G4int n = i*10+j;
G4ThreeVector crystalPos((i*crystalWidth)-135,
(j*crystalWidth)-135,0 );
fCrystalPhys[n]
= new G4PVPlacement(0, // no rotation
crystalPos, // translation
fCrystalLog,
"crystal", // its name
caloLog,
false,
i);
}
}
G4cout << "There are " << nbOfCrystals <<
" crystals per row in the calorimeter, so in total "<<
nbOfCrystals*nbOfCrystals << " crystals" << G4endl;
G4cout << "They have width of " << crystalWidth /cm <<
" cm and a length of " << crystalLength /cm
<<" cm. " << G4endl;
G4VisAttributes* caloVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
G4VisAttributes* crystalVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
caloLog->SetVisAttributes(caloVisAtt);
fCrystalLog->SetVisAttributes(crystalVisAtt);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflash3ParallelWorld::ConstructSD()
{
// -- sensitive detectors:
G4SDManager* SDman = G4SDManager::GetSDMpointer();
ExGflash3SensitiveDetector* CaloSD
= new ExGflash3SensitiveDetector("Calorimeter",this);
SDman->AddNewDetector(CaloSD);
fCrystalLog->SetSensitiveDetector(CaloSD);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,130 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflash3SensitiveDetector.cc
/// \brief Implementation of the ExGflash3SensitiveDetector class
//
// Created by Joanna Weng 26.11.2004
#include "ExGflash3SensitiveDetector.hh"
#include "ExGflashHit.hh"
#include "G4GFlashSpot.hh"
#include "ExGflash3DetectorConstruction.hh"
#include "ExGflash3ParallelWorld.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Step.hh"
#include "G4VTouchable.hh"
#include "G4TouchableHistory.hh"
//WARNING : You have to use also G4VGFlashSensitiveDetector() as base class
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflash3SensitiveDetector::ExGflash3SensitiveDetector(G4String name,
ExGflash3ParallelWorld* det)
: G4VSensitiveDetector(name), G4VGFlashSensitiveDetector(), fDetector(det), fHCID(-1)
{
G4String caloname="ExGflashCollection";
collectionName.insert(caloname);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflash3SensitiveDetector::~ExGflash3SensitiveDetector()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflash3SensitiveDetector::Initialize(G4HCofThisEvent* HCE)
{
if(fHCID<0){ fHCID = GetCollectionID(0); }
fCaloHitsCollection=new
ExGflashHitsCollection(SensitiveDetectorName,collectionName[0]); // first collection
HCE->AddHitsCollection( fHCID, fCaloHitsCollection );
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflash3SensitiveDetector::EndOfEvent(G4HCofThisEvent*)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool ExGflash3SensitiveDetector::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhist)
{
G4double e=aStep->GetTotalEnergyDeposit();
if(e<=0.)return false;
G4TouchableHistory* theTouchable
= (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
// enrgy deposited -> make Hit
//const G4VPhysicalVolume* physVol= aStep->GetPreStepPoint()->GetPhysicalVolume();
//G4TouchableHistory* theTouchable =
// (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
ExGflashHit* caloHit=new ExGflashHit();
caloHit->SetEdep(e);
caloHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
fCaloHitsCollection->insert(caloHit);
if (ROhist){;}
G4VPhysicalVolume* physVol = theTouchable->GetVolume();
G4int crystalnum=0;
for(int i=0;i<100;i++) //@@@@@@@ ExGflash3SensitiveDetector:vorsichty
{
if(physVol == fDetector->GetCristal(i)) crystalnum= i;
}
caloHit->SetCrystalNum(crystalnum);
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Separate GFLASH interface
G4bool ExGflash3SensitiveDetector::ProcessHits(G4GFlashSpot*aSpot ,G4TouchableHistory* ROhist)
{ //cout<<"This is ProcessHits GFLASH"<<endl;
G4double e=aSpot->GetEnergySpot()->GetEnergy();
if(e<=0.)return false;
G4VPhysicalVolume* pCurrentVolume = aSpot->GetTouchableHandle()->GetVolume();
ExGflashHit* caloHit=new ExGflashHit();
caloHit->SetEdep(e);
caloHit->SetPos(aSpot->GetEnergySpot()->GetPosition());
fCaloHitsCollection->insert(caloHit);
if (ROhist){;}
//cout <<pCurrentVolume->GetName() << endl;
G4int crystalnum=0;
for(int i=0;i<100;i++) //@@@@@@@ ExGflash3SensitiveDetector:vorsichty
{
if(pCurrentVolume == fDetector->GetCristal(i)) crystalnum= i;
}
caloHit->SetCrystalNum(crystalnum);
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,64 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashActionInitialization.cc
/// \brief Implementation of the ExGflashActionInitialization class
#include "ExGflashActionInitialization.hh"
#include "ExGflashPrimaryGeneratorAction.hh"
#include "ExGflashRunAction.hh"
#include "ExGflashEventAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashActionInitialization::ExGflashActionInitialization()
: G4VUserActionInitialization()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashActionInitialization::~ExGflashActionInitialization()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashActionInitialization::BuildForMaster() const
{
// SetUserAction(new ExGflashRunAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashActionInitialization::Build() const
{
SetUserAction(new ExGflashPrimaryGeneratorAction);
SetUserAction(new ExGflashRunAction);
SetUserAction(new ExGflashEventAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,219 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashEventAction.cc
/// \brief Implementation of the ExGflashEventAction class
//
// Created by Joanna Weng 26.11.2004
#include "ExGflashEventAction.hh"
#include "ExGflashHit.hh"
#include "G4EventManager.hh"
#include "G4SDManager.hh"
#include "G4UImanager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Event.hh"
#include "G4SystemOfUnits.hh"
//std
#include <iostream>
#include <algorithm>
//Gflash
using namespace std;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashEventAction::ExGflashEventAction()
: G4UserEventAction(),
fNevent(0),fDtime(0.0),fCalorimeterCollectionId(-1)
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashEventAction::~ExGflashEventAction()
{
if ( fNevent > 0 ) {
G4cout << "Internal Real Elapsed Time /event is: "<< fDtime /fNevent<< G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashEventAction::BeginOfEventAction(const G4Event *evt)
{
fTimerIntern.Start();
G4cout<<" ------ Start ExGflashEventAction ----- "<<G4endl;
fNevent=evt->GetEventID();
G4cout<<" Start generating event Nr "<<fNevent<<G4endl<<G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashEventAction::EndOfEventAction(const G4Event *evt)
{
fTimerIntern.Stop();
G4cout << G4endl;
G4cout << "******************************************";
G4cout << G4endl;
G4cout << "Internal Real Elapsed Time is: "<< fTimerIntern.GetRealElapsed();
G4cout << G4endl;
G4cout << "Internal System Elapsed Time: " << fTimerIntern.GetSystemElapsed();
G4cout << G4endl;
G4cout << "Internal GetUserElapsed Time: " << fTimerIntern.GetUserElapsed();
G4cout << G4endl;
G4cout << "******************************************"<< G4endl;
fDtime+=fTimerIntern.GetRealElapsed();
G4cout<<" ------ ExGflashEventAction::End of event nr. "<<fNevent<<" -----"<< G4endl;
G4SDManager * SDman = G4SDManager::GetSDMpointer();
G4String colNam;
fCalorimeterCollectionId=SDman->GetCollectionID(colNam="ExGflashCollection");
if (fCalorimeterCollectionId<0) return;
G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
ExGflashHitsCollection* THC = 0;
G4double totE = 0;
// Read out of the crysta ECAL
THC=(ExGflashHitsCollection *)(HCE->GetHC(fCalorimeterCollectionId));
if (THC)
{
/// Hits in sensitive Detector
int n_hit = THC->entries();
G4cout<<" " << n_hit<< " hits are stored in ExGflashHitsCollection "<<G4endl;
G4PrimaryVertex* pvertex=evt->GetPrimaryVertex();
///Computing (x,y,z) of vertex of initial particles
G4ThreeVector vtx=pvertex->GetPosition();
G4PrimaryParticle* pparticle=pvertex->GetPrimary();
// direction of the Shower
G4ThreeVector mom=pparticle->GetMomentum()/pparticle->GetMomentum().mag();
//@@@ ExGflashEventAction: Magicnumber
G4double energyincrystal[100];
G4int hitsincrystal[100];
for (int i=0;i<100;i++) energyincrystal[i]=0.;
for (int i=0;i<100;i++) hitsincrystal[i]=0.;
//@@@ ExGflashEventAction: Magicnumber
/// For all Hits in sensitive detector
for (int i=0;i<n_hit;i++)
{
G4double estep = (*THC)[i]->GetEdep()/GeV;
if (estep >0.0)
{
totE += (*THC)[i]->GetEdep()/GeV;
G4int num=(*THC)[i]->GetCrystalNum();
energyincrystal[num]+=(*THC)[i]->GetEdep()/GeV;
hitsincrystal[num]++;
//G4cout << num << G4endl;
// G4cout << " Crystal Nummer " << (*THC)[i]->GetCrystalNum() << G4endl;
// G4cout << (*THC)[i]->GetCrystalNum() /10 <<
// " "<<(*THC)[i]->GetCrystalNum()%10 << G4endl;
G4ThreeVector hitpos=(*THC)[i]->GetPos();
G4ThreeVector l (hitpos.x(), hitpos.y(), hitpos.z());
// distance from shower start
l = l - vtx;
// projection on shower axis = longitudinal profile
G4ThreeVector longitudinal = l;
// shower profiles (Radial)
G4ThreeVector radial = vtx.cross(l);
}
}
G4double max = 0;
G4int index = 0;
//Find crystal with maximum energy
for (int i=0;i<100;i++)
{
//G4cout << i <<" " << energyincrystal[i] << G4endl;
if (max <energyincrystal[i])
{
max=energyincrystal[i];
index = i;
}
}
//G4cout << index <<" NMAX " << index << G4endl;
// 3x3 matrix of crystals around the crystal with the maximum energy deposit
G4double e3x3 =
energyincrystal[index]+energyincrystal[index+1]+energyincrystal[index-1]+
energyincrystal[index-10]+energyincrystal[index-9]+energyincrystal[index-11]+
energyincrystal[index+10]+energyincrystal[index+11]+energyincrystal[index+9];
// 5x5 matrix of crystals around the crystal with the maximum energy deposit
G4double e5x5 =
energyincrystal[index]+energyincrystal[index+1]+energyincrystal[index-1]+
energyincrystal[index+2]+energyincrystal[index-2]+
energyincrystal[index-10]+energyincrystal[index-9]+energyincrystal[index-11]+
energyincrystal[index-8]+energyincrystal[index-12]+
energyincrystal[index+10]+energyincrystal[index+11]+energyincrystal[index+9]+
energyincrystal[index+12]+energyincrystal[index+8];
// 3x3 matrix of crystals around the crystal with the maximum energy deposit
G4int num3x3 =
hitsincrystal[index]+hitsincrystal[index+1]+hitsincrystal[index-1]+
hitsincrystal[index-10]+hitsincrystal[index-9]+hitsincrystal[index-11]+
hitsincrystal[index+10]+hitsincrystal[index+11]+hitsincrystal[index+9];
// 5x5 matrix of crystals around the crystal with the maximum energy deposit
G4int num5x5 =
hitsincrystal[index]+hitsincrystal[index+1]+hitsincrystal[index-1]+
hitsincrystal[index+2]+hitsincrystal[index-2]+
hitsincrystal[index-10]+hitsincrystal[index-9]+hitsincrystal[index-11]+
hitsincrystal[index-8]+hitsincrystal[index-12]+
hitsincrystal[index+10]+hitsincrystal[index+11]+hitsincrystal[index+9]+
hitsincrystal[index+12]+hitsincrystal[index+8];
G4cout << " e1 " << energyincrystal[index]
<< " e3x3 " << e3x3<< " GeV e5x5 " <<e5x5 <<G4endl;
G4cout << " num1 " << hitsincrystal[index]
<< " num3x3 " << num3x3<< " num5x5 " <<num5x5 <<G4endl;
}
G4cout << " Total energy deposited in the calorimeter: " << totE << " (GeV)" << G4endl;
G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
G4int n_trajectories = 0;
if(trajectoryContainer){ n_trajectories = trajectoryContainer->entries(); }
G4cout << " " << n_trajectories << " trajectories stored in this event." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,131 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashHit.cc
/// \brief Implementation of the ExGflashHit class
//
#include "ExGflashHit.hh"
#include "G4VVisManager.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4LogicalVolume.hh"
#include "G4Transform3D.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal G4Allocator<ExGflashHit>* ExGflashHitAllocator=0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashHit::ExGflashHit()
: G4VHit(), fLogV(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashHit::ExGflashHit(G4LogicalVolume* logVol)
: G4VHit(), fLogV(logVol)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashHit::~ExGflashHit()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashHit::ExGflashHit(const ExGflashHit &right)
: G4VHit(right)
//@@@ ExGflashHit:Is it right with the init?
{
fEdep = right.fEdep;
fPos = right.fPos;
fStart =right.fStart;
fRot = right.fRot;
fLogV = right.fLogV;
fCrystalNumber = right.fCrystalNumber;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const ExGflashHit & ExGflashHit::operator=(const ExGflashHit &right)
{
G4VHit::operator=(right);
fEdep = right.fEdep;
fStart =right.fStart;
fPos = right.fPos;
fRot = right.fRot;
fLogV = right.fLogV;
fCrystalNumber = right.fCrystalNumber;
fCrystalNumber = right.fCrystalNumber;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool ExGflashHit::operator==(const ExGflashHit &right) const
{
// @@@@ return false;
if ((fPos==right.fPos) && (fEdep == right.fEdep)) return true;
else return false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager)
{
G4Transform3D trans(fRot,fPos);
G4VisAttributes attribs;
const G4VisAttributes* pVA = fLogV->GetVisAttributes();
if(pVA) attribs = *pVA;
G4Colour colour(1.,0.,0.);
attribs.SetColour(colour);
attribs.SetForceWireframe(false);
attribs.SetForceSolid(true);
pVVisManager->Draw(*fLogV,attribs,trans);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashHit::Print()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,57 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashPrimaryGeneratorAction.cc
/// \brief Implementation of the ExGflashPrimaryGeneratorAction class
//
#include "ExGflashPrimaryGeneratorAction.hh"
#include "G4GeneralParticleSource.hh"
#include "G4Event.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashPrimaryGeneratorAction::ExGflashPrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction(), fParticleGun(0)
{
fParticleGun=new G4GeneralParticleSource;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashPrimaryGeneratorAction::~ExGflashPrimaryGeneratorAction()
{
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,73 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file ExGflashRunAction.cc
/// \brief Implementation of the ExGflashRunAction class
//
#include "ExGflashRunAction.hh"
#include "G4Run.hh"
#include "G4ios.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashRunAction::ExGflashRunAction()
: G4UserRunAction(), fRunID(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExGflashRunAction::~ExGflashRunAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashRunAction::BeginOfRunAction(const G4Run* aRun)
{
((G4Run *)(aRun))->SetRunID(fRunID++);
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExGflashRunAction::EndOfRunAction(const G4Run* aRun)
{
G4cout << "number of event = " << aRun->GetNumberOfEvent() << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,16 @@
#
# Macro file for the non-interactive mode
# Runs GFlash simulation and prints out the output
#
/gps/pos/centre 0 0 0
/gps/particle e-
/gps/energy 50 GeV
/gps/direction 0. 0. 1.0
# Paramatrisation on
/GFlash/flag 1
/tracking/verbose 0
/run/beamOn 10
@@ -0,0 +1,84 @@
#
# Macro file for the initialization phase of gflash example
# when runing in interactive mode
#
# Sets some default verbose
/gps/position 0 0 0
/gps/particle e+
/gps/energy 2.0 GeV
/gps/direction 0. 0. 1.0
#
# Use this open statement to create an OpenGL view:
/vis/open OGL 600x600-0+0
#
# Use this open statement to create a .prim file suitable for
# viewing in DAWN:
#/vis/open DAWNFILE
#
# Use this open statement to create a .heprep file suitable for
# viewing in HepRApp:
#/vis/open HepRepFile
#
# Use this open statement to create a .wrl file suitable for
# viewing in a VRML viewer:
#/vis/open VRML2FILE
#
# Disable auto refresh and quieten vis messages whilst scene and
# trajectories are established:
/vis/viewer/set/autoRefresh false
/vis/verbose errors
#
# Draw geometry:
/vis/drawVolume
#
# Specify view point vector:
/vis/viewer/set/viewpointVector 1 1 1
#
# Specify zoom value:
/vis/viewer/zoom 0.5
#
# Specify style (surface or wireframe):
#/vis/viewer/set/style wireframe
#
# Draw coordinate axes:
#/vis/scene/add/axes 0 0 0 1 m
#
# Draw smooth trajectories at end of event, showing trajectory points
# as markers 2 pixels wide:
/vis/scene/add/trajectories smooth
/vis/modeling/trajectories/create/drawByCharge
/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true
/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2
# (if too many tracks cause core dump => /tracking/storeTrajectory 0)
#
# Draw hits at end of event:
#/vis/scene/add/hits
#
# To draw only gammas:
#/vis/filtering/trajectories/create/particleFilter
#/vis/filtering/trajectories/particleFilter-0/add gamma
#
# To invert the above, drawing all particles except gammas,
# keep the above two lines but also add:
#/vis/filtering/trajectories/particleFilter-0/invert true
#
# Many other options are available with /vis/modeling and /vis/filtering.
# For example, to select colour by particle ID:
#/vis/modeling/trajectories/create/drawByParticleID
#/vis/modeling/trajectories/drawByParticleID-0/set e- blue
#
# To superimpose all of the events from a given run:
/vis/scene/endOfEventAction accumulate
#
# Re-establish auto refreshing and verbosity:
/vis/viewer/set/autoRefresh true
/vis/verbose warnings
#
# For file-based drivers, use this to create an empty detector view:
#/vis/viewer/flush
#
/tracking/verbose 0
/GFlash/flag 1
/run/beamOn 2