15 #include <G4RunManager.hh>
16 #include <G4UImanager.hh>
17 #include <G4VisManager.hh>
19 #include <fwk/CentralConfig.h>
20 #include <fwk/RandomEngineRegistry.h>
22 #include <det/Detector.h>
24 #include <evt/Event.h>
25 #include <evt/ShowerSimData.h>
27 #include <sdet/SDetector.h>
28 #include <sdet/Station.h>
31 #include <sevt/PMTSimData.h>
32 #include <sevt/SEvent.h>
33 #include <sevt/Station.h>
34 #include <sevt/StationSimData.h>
36 #include <utl/ErrorLogger.h>
37 #include <utl/Reader.h>
38 #include <utl/Particle.h>
39 #include <utl/ParticleCases.h>
40 #include <utl/ShowerParticleIterator.h>
41 #include <utl/TimeDistribution.h>
42 #include <utl/TimeDistributionAlgorithm.h>
48 #include <CLHEP/Random/Random.h>
50 #include <tls/Geant4Manager.h>
59 using namespace G4TankSimulatorOG;
62 const sdet::Station* G4TankSimulator::fCurrentDetectorStation = 0;
66 bool G4TankSimulator::fgMuCapture;
69 G4TankSimulator::G4TankSimulator() :
75 fUseGlobalPhysicsList(false),
77 fDetectorConstructed(0),
91 CentralConfig::GetInstance()->
GetTopBranch(
"G4TankSimulator");
108 if (sepMode ==
"Standard")
110 else if (sepMode ==
"Universality")
118 fRunManager = tls::Geant4Manager::GetInstance().GetRunManager();
129 INFO(
"using global PhysicsList from Geant4Manager");
130 tls::Geant4Manager::GetInstance().AddVisManager(
fVisManager);
135 INFO(
"Constructing G4Tank");
136 const SDetector& sDetector = Detector::GetInstance().GetSDetector();
150 tls::Geant4Manager::GetInstance().AddCustomization(custom);
153 INFO(
"using PhysicsList from G4TankPhysicsList");
167 fUImanager->ApplyCommand(
"/tracking/verbose 0");
180 ERROR(
"SEvent does not exist.");
184 CLHEP::HepRandom::setTheEngine(&RandomEngineRegistry::GetInstance().
185 Get(RandomEngineRegistry::eDetector).
188 SEvent& sEvent =
event.GetSEvent();
193 INFO(
"Constructing G4Tank");
197 ERROR(
"No stations!");
201 const SDetector& sDetector = Detector::GetInstance().GetSDetector();
214 fUImanager->ApplyCommand(
"/vis/open VRML2FILE");
215 fUImanager->ApplyCommand(
"/vis/scene/create");
216 fUImanager->ApplyCommand(
"/vis/sceneHandler/attach");
217 fUImanager->ApplyCommand(
"/vis/scene/add/volume");
218 fUImanager->ApplyCommand(
"/vis/viewero/set/style/wireframe");
220 fUImanager->ApplyCommand(
"/vis/scene/notifyHandlers");
221 fUImanager->ApplyCommand(
"/vis/viewer/update");
224 fUImanager->ApplyCommand(
"/tracking/storeTrajectory 1");
225 fUImanager->ApplyCommand(
"/vis/scene/add/trajectories");
231 tls::Geant4Manager::GetInstance().Customize(
"G4TankSimulator");
241 SEvent& sEvent =
event.GetSEvent();
244 const SDetector& sDetector = Detector::GetInstance().GetSDetector();
250 ERROR(
"The detector hasn't been initialized when looping over stations");
254 if (sIt->HasSimData()) {
261 const int stationId = sIt->GetId();
263 const unsigned long numParticles =
267 G4cerr << stationId <<
':' << numParticles <<
' ' << flush;
278 if (!nParticlesAlreadySimulated)
307 SEvent& sEvent =
event.GetSEvent();
308 const SDetector& sDetector = Detector::GetInstance().GetSDetector();
316 INFO(
"No stations with SimData found.");
332 if (!sIt->HasSimData())
339 const unsigned long numParticles =
342 const int stationId = sIt->GetId();
345 G4cerr << stationId <<
':' << numParticles <<
' ' << flush;
356 if (!nParticlesAlreadySimulated)
390 tls::Geant4Manager::GetInstance().NotifyDelete();
410 pmtIt != station.
PMTsEnd(); ++pmtIt)
411 if (!pmtIt->HasSimData())
412 pmtIt->MakeSimData();
448 cerr <<
"Unknown particle type" << endl;
477 cerr <<
"Unknown particle type" << endl;
void SetRunAction(G4UserRunAction *const action)
Branch GetTopBranch() const
friend class G4TankConstruction
allow customization of the standard global PhysicsList that are handled by the Geant4Manager ...
Geant4 Stepping user action class.
Station Level Simulated Data
StationIterator StationsEnd()
End of all stations.
virtual ~G4TankSimulator()
void SetPrimaryGenerator(G4VUserPrimaryGeneratorAction *const action)
Geant4 Tracking user action class.
Detector description interface for Station-related data.
Report success to RunController.
total (shower and background)
static void GetDataFromConstruction()
static const sdet::Station * fCurrentDetectorStation
int GetNumberOfStations() const
Get total number of stations in the event.
void AddPhoton(const int nPMT, const double peTime) const
Interface class to access to the SD part of an event.
PMTIterator PMTsBegin(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
begin PMT iterator for read/write
Skip remaining modules in the current loop and continue with next iteration of the loop...
void SetStackingAction(G4UserStackingAction *const action)
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
void ConstructTraces(sevt::Station &station) const
#define INFO(message)
Macro for logging informational messages.
electrons produced by hadrons close to the detector
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
boost::filter_iterator< PMTFilter, InternalPMTIterator > PMTIterator
Iterator over station for read/write.
void SetSimulatorSignature(const std::string &name)
Set name of the tank simulator module used to simulate this station.
G4TankConstruction * fgTankConstruction
bool HasPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if a PE release time distribution exists (optionally for a given source)
StationIterator AllStationsBegin() const
Beginning of the collection of pointers to all stations in the history of the array.
ParticleVector::iterator ParticleIterator
electrons and positrons from shower
G4RunManager * fRunManager
Class representing a document branch.
class to hold data at Station level
void SetEventAction(G4UserEventAction *const action)
static sevt::SEvent::StationIterator fCurrentEventStationIt
PMTIterator PMTsEnd(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
end PMT iterator for read/write
implementation of G4 visualization manager
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Data structure to hold the different Geant4 global objects required to run a single module...
void GetData(bool &b) const
Overloads of the GetData member template function.
G4VisManager * fVisManager
G4TankStackingAction * fStackingAction
Geant4 Run user action class.
photons from muon decay in shower
ParticleIterator ParticlesBegin()
Beginning of simulated particles entering the station.
fwk::VModule::ResultFlag RunFull(evt::Event &theEvent)
void SetTrackingAction(G4UserTrackingAction *const action)
ResultFlag
Flag returned by module methods to the RunController.
unsigned int GetTotalSimParticleCount() const
Get the total number of particles that were actually simulated (after thinning)
void SetTotalSimParticleCount(const unsigned int n)
StationIterator StationsBegin()
Beginning of all stations.
Geant4 Stacking user action class.
Class to hold simulated data at PMT level.
friend class G4TankPhysicsList
SignalSeparationMode fSignalSeparationMode
Detector description interface for SDetector-related data.
bool fDetectorConstructed
Report failure to RunController, causing RunController to terminate execution.
static sevt::StationSimData::ParticleIterator fCurrentParticleIt
#define OFFLINE_ELECTRONS
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
sevt::StationSimData & GetSimData()
Get simulated data at station level.
void SetStation(const sdet::Station *const station)
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
utl::TimeDistributionI & GetPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Simulated photoelectron time distribution.
fwk::VModule::ResultFlag RunFast(evt::Event &theEvent)
const Station & GetStation(const int stationId) const
Get station by Station Id.
fwk::VModule::ResultFlag Run(evt::Event &theEvent)
Run: invoked once per event.
boost::indirect_iterator< InternalConstStationIterator, const Station & > ConstStationIterator
#define ERROR(message)
Macro for logging error messages.
ParticleIterator ParticlesEnd()
End of simulated particles entering the station.
Geant4 Event user action class.
void AddTime(const double time, const T weight=T(1))
Add an entry (optionally weighted) for the given time. Slot will be computed.
mu+ and mu- (including signal from mu decay electrons) from shower
void SetSteppingAction(G4UserSteppingAction *const action)
electrons from muon decay in shower
bool fUseGlobalPhysicsList
void MakePETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Create a PE release time distribution (optionally for given source)