18 #include <G4RunManager.hh>
19 #include <G4UImanager.hh>
20 #include <G4VisManager.hh>
22 #include <fwk/CentralConfig.h>
23 #include <fwk/RandomEngineRegistry.h>
25 #include <det/Detector.h>
27 #include <evt/Event.h>
28 #include <evt/ShowerSimData.h>
30 #include <sdet/SDetector.h>
31 #include <sdet/Station.h>
34 #include <sevt/PMTSimData.h>
35 #include <sevt/SEvent.h>
36 #include <sevt/Station.h>
37 #include <sevt/StationSimData.h>
39 #include <utl/ErrorLogger.h>
40 #include <utl/Reader.h>
41 #include <utl/Particle.h>
42 #include <utl/ShowerParticleIterator.h>
43 #include <utl/TimeDistribution.h>
44 #include <utl/TimeDistributionAlgorithm.h>
50 #include <CLHEP/Random/Random.h>
52 #include <tls/Geant4Manager.h>
61 using namespace G4TankSimulatorASCII;
63 G4TankPMT* G4TankSimulator::fgPMTAction = 0;
64 const sdet::Station* G4TankSimulator::fCurrentDetectorStation = 0;
68 bool G4TankSimulator::fgMuCapture;
71 G4TankSimulator::G4TankSimulator() :
77 fUseGlobalPhysicsList(false),
78 fDetectorConstructed(0),
98 CentralConfig::GetInstance()->
GetTopBranch(
"G4TankSimulatorASCII");
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(
"G4TankSimulatorASCII");
242 SEvent& sEvent =
event.GetSEvent();
245 const SDetector& sDetector = Detector::GetInstance().GetSDetector();
251 ERROR(
"The detector hasn't been initialized when looping over stations");
255 if (sIt->HasSimData()) {
262 const int stationId = sIt->GetId();
264 const unsigned long numParticles =
268 G4cerr << stationId <<
':' << numParticles <<
' ' << flush;
296 SEvent& sEvent =
event.GetSEvent();
297 const SDetector& sDetector = Detector::GetInstance().GetSDetector();
305 INFO(
"No stations with SimData found.");
322 if (!sIt->HasSimData())
continue;
328 const unsigned long numParticles =
331 const int stationId = sIt->GetId();
334 G4cerr << stationId <<
':' << numParticles <<
' ' << flush;
371 tls::Geant4Manager::GetInstance().NotifyDelete();
395 if (!pmtIt->HasSimData()) {
396 pmtIt->MakeSimData();
397 pmtIt->GetSimData().MakePETimeDistribution();
void SetRunAction(G4UserRunAction *const action)
static sevt::SEvent::StationIterator fCurrentEventStationIt
fwk::VModule::ResultFlag Run(evt::Event &theEvent)
Run: invoked once per event.
Branch GetTopBranch() const
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
static G4TankPMT * fgPMTAction
G4TankConstruction * fgTankConstruction
Station Level Simulated Data
StationIterator StationsEnd()
End of all stations.
friend class G4TankPhysicsList
G4TankStackingAction * fStackingAction
void SetPrimaryGenerator(G4VUserPrimaryGeneratorAction *const action)
Detector description interface for Station-related data.
Report success to RunController.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
int GetNumberOfStations() const
Get total number of stations in the event.
Geant4 Stepping user action class.
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...
bool fDetectorConstructed
void SetStackingAction(G4UserStackingAction *const action)
#define INFO(message)
Macro for logging informational messages.
G4VisManager * fVisManager
static sevt::StationSimData::ParticleIterator fCurrentParticleIt
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.
void SetCurrentTank(const sevt::SEvent::StationIterator sIt)
StationIterator AllStationsBegin() const
Beginning of the collection of pointers to all stations in the history of the array.
ParticleVector::iterator ParticleIterator
Class representing a document branch.
void ConstructTraces(sevt::Station &station) const
class to hold data at Station level
void SetEventAction(G4UserEventAction *const action)
static const sdet::Station * fCurrentDetectorStation
fwk::VModule::ResultFlag RunFull(evt::Event &theEvent)
PMTIterator PMTsEnd(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
end PMT iterator for read/write
virtual ~G4TankSimulator()
fwk::VModule::ResultFlag RunFast(evt::Event &theEvent)
Geant4 Event user action class.
Data structure to hold the different Geant4 global objects required to run a single module...
bool fUseGlobalPhysicsList
void GetData(bool &b) const
Overloads of the GetData member template function.
ParticleIterator ParticlesBegin()
Beginning of simulated particles entering the station.
void SetTrackingAction(G4UserTrackingAction *const action)
Geant4 Stacking user action class.
ResultFlag
Flag returned by module methods to the RunController.
Geant4 Run user action class.
StationIterator StationsBegin()
Beginning of all stations.
void SetParticle(const utl::Particle &particle)
Detector description interface for SDetector-related data.
Report failure to RunController, causing RunController to terminate execution.
Geant4 Tracking user action class.
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
sevt::StationSimData & GetSimData()
Get simulated data at station level.
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
friend class G4TankConstruction
implementation of G4 visualization manager
const Station & GetStation(const int stationId) const
Get station by Station Id.
static void GetDataFromConstruction()
void SetStation(const sdet::Station *const station)
boost::indirect_iterator< InternalConstStationIterator, const Station & > ConstStationIterator
#define ERROR(message)
Macro for logging error messages.
ParticleIterator ParticlesEnd()
End of simulated particles entering the station.
void SetSteppingAction(G4UserSteppingAction *const action)
G4RunManager * fRunManager
allow customization of the standard global PhysicsList that are handled by the Geant4Manager ...