Belle II Software  release-05-02-19
FullSimModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2014 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Andreas Moll, Guofu Cao, Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <simulation/modules/fullsim/FullSimModule.h>
12 #include <simulation/kernel/RunManager.h>
13 #include <simulation/kernel/DetectorConstruction.h>
14 //- #include <simulation/kernel/PhysicsList.h>
15 #include <simulation/physicslist/Belle2PhysicsList.h>
16 #include <simulation/kernel/ExtPhysicsConstructor.h>
17 #include <simulation/kernel/MagneticField.h>
18 #include <simulation/kernel/PrimaryGeneratorAction.h>
19 #include <simulation/kernel/EventAction.h>
20 #include <simulation/kernel/TrackingAction.h>
21 #include <simulation/kernel/SteppingAction.h>
22 #include <simulation/kernel/StackingAction.h>
23 
24 #include <mdst/dataobjects/MCParticle.h>
25 #include <framework/datastore/StoreObjPtr.h>
26 #include <framework/datastore/StoreArray.h>
27 #include <framework/dataobjects/EventMetaData.h>
28 #include <framework/gearbox/Unit.h>
29 
30 #include <CLHEP/Units/SystemOfUnits.h>
31 
32 #include <simulation/monopoles/G4MonopolePhysics.h>
33 #include <simulation/longlivedneutral/G4LongLivedNeutralPhysics.h>
34 
35 #include <G4TransportationManager.hh>
36 #include <G4Transportation.hh>
37 #include <G4PhysListFactory.hh>
38 #include <G4ProcessVector.hh>
39 #include <G4OpticalPhysics.hh>
40 #include <G4ParticleDefinition.hh>
41 #include <G4ParticleTable.hh>
42 #include <G4EventManager.hh>
43 #include <G4RunManager.hh>
44 #include <G4UImanager.hh>
45 #include <G4VisExecutive.hh>
46 #include <G4StepLimiter.hh>
47 #include <G4EmParameters.hh>
48 #include <G4HadronicProcessStore.hh>
49 #include <G4InuclParticleNames.hh>
50 
51 #include <G4Mag_UsualEqRhs.hh>
52 #include <G4NystromRK4.hh>
53 #include <G4HelixExplicitEuler.hh>
54 #include <G4HelixSimpleRunge.hh>
55 #include <G4CachedMagneticField.hh>
56 
57 using namespace std;
58 using namespace Belle2;
59 using namespace Belle2::Simulation;
60 using namespace Belle2::Monopoles;
61 using namespace G4InuclParticleNames;
62 
63 //-----------------------------------------------------------------
64 // Register the Module
65 //-----------------------------------------------------------------
66 REG_MODULE(FullSim)
67 
68 //-----------------------------------------------------------------
69 // Implementation
70 //-----------------------------------------------------------------
71 
72 FullSimModule::FullSimModule() : Module(), m_useNativeGeant4(true)
73 {
74  //Set module properties and the description
75  setDescription("Performs the full Geant4 detector simulation. Requires a valid geometry in memory.");
76  setPropertyFlags(c_ParallelProcessingCertified | c_TerminateInAllProcesses);
77 
78  //Parameter definition
79  addParam("InputMCParticleCollection", m_mcParticleInputColName, "The name of the input MCParticle collection.", string(""));
80  addParam("ThresholdImportantEnergy", m_thresholdImportantEnergy,
81  "[GeV] A particle which got 'stuck' and has less than this energy will be killed after 'ThresholdTrials' trials.", 0.250);
82  addParam("ThresholdTrials", m_thresholdTrials,
83  "Geant4 will try 'ThresholdTrials' times to move a particle which got 'stuck' and has an energy less than 'ThresholdImportantEnergy'.",
84  10);
85  addParam("RunEventVerbosity", m_runEventVerbosity, "Geant4 run/event verbosity: 0=silent; 1=info level; 2=debug level", 0);
86  addParam("TrackingVerbosity", m_trackingVerbosity,
87  "Tracking verbosity: 0=Silent; 1=Min info per step; 2=sec particles; 3=pre/post step info; 4=like 3 but more info; 5=proposed step length info.",
88  0);
89  addParam("HadronProcessVerbosity", m_hadronProcessVerbosity, "Hadron Process verbosity: 0=Silent; 1=info level; 2=debug level", 0);
90  addParam("EmProcessVerbosity", m_emProcessVerbosity, "Em Process verbosity: 0=Silent; 1=info level; 2=debug level", 0);
91  addParam("PhysicsList", m_physicsList, "The name of the physics list which is used for the simulation.", string("Belle2"));
92  addParam("StandardEM", m_standardEM, "If true, replaces fast EM physics with standard EM physics.", false);
93  addParam("RegisterOptics", m_optics, "If true, G4OpticalPhysics is registered in Geant4 PhysicsList.", true);
94  addParam("UseHighPrecisionNeutrons", m_HPneutrons, "If true, high precision neutron models used below 20 MeV.", false);
95  addParam("RegisterMonopoles", m_monopoles, "If set to true, G4MonopolePhysics is registered in Geant4 PhysicsList.", false);
96  addParam("MonopoleMagCharge", m_monopoleMagneticCharge, "The value of monopole magnetic charge in units of e+.", 1.0);
97  addParam("ProductionCut", m_productionCut,
98  "[cm] Apply continuous energy loss to primary particle which has no longer enough energy to produce secondaries which travel at least the specified productionCut distance.",
99  0.07);
100  addParam("PXDProductionCut", m_pxdProductionCut, "[cm] Secondary production threshold in PXD envelope.", 0.0);
101  addParam("SVDProductionCut", m_svdProductionCut, "[cm] Secondary production threshold in SVD envelope.", 0.0);
102  addParam("CDCProductionCut", m_cdcProductionCut, "[cm] Secondary production threshold in CDC envelope.", 0.0);
103  addParam("ARICHTOPProductionCut", m_arichtopProductionCut, "[cm] Secondary production threshold in ARICH and TOP envelopes.", 0.0);
104  addParam("ECLProductionCut", m_eclProductionCut, "[cm] Secondary production threshold in ECL envelope.", 0.0);
105  addParam("KLMProductionCut", m_klmProductionCut, "[cm] Secondary production threshold in BKLM and EKLM envelopes.", 0.0);
106  addParam("MaxNumberSteps", m_maxNumberSteps,
107  "The maximum number of steps before the track transportation is stopped and the track is killed.", 100000);
108  addParam("PhotonFraction", m_photonFraction, "The fraction of Cerenkov photons which will be kept and propagated.", 0.5);
109  addParam("EnableVisualization", m_EnableVisualization, "If set to True, the Geant4 visualization support is enabled.", false);
110 
111  addParam("StoreOpticalPhotons", m_storeOpticalPhotons, "If set to True, optical photons are stored in MCParticles.", false);
112  addParam("StoreAllSecondaries", m_storeSecondaries,
113  "If set to True, all secondaries produced by Geant4 over a kinetic energy cut are stored in MCParticles. Otherwise do not store them.",
114  false);
115  addParam("SecondariesEnergyCut", m_secondariesEnergyCut, "[MeV] Kinetic energy cut for storing secondaries", 1.0);
116  addParam("StoreBremsstrahlungPhotons", m_storeBremsstrahlungPhotons,
117  "If set to True, store BremsstrahlungPhotons over a kinetic energy cut in MCParticles. Otherwise do not store them.", false);
118  addParam("BremsstrahlungPhotonsEnergyCut", m_bremsstrahlungPhotonsEnergyCut,
119  "[MeV] Kinetic energy cut for storing bremsstrahlung photons", 10.0);
120  addParam("StorePairConversions", m_storePairConversions,
121  "If set to True, store e+ or e- from pair conversions over a kinetic energy cut in MCParticles. Otherwise do not store them.",
122  false);
123  addParam("PairConversionsEnergyCut", m_pairConversionsEnergyCut,
124  "[MeV] Kinetic energy cut for storing e+ or e- from pair conversions", 10.0);
125 
126  addParam("magneticField", m_magneticFieldName,
127  "Chooses the magnetic field stepper used by Geant4. Possible values are: default, nystrom, expliciteuler, simplerunge",
128  string("default"));
129  addParam("magneticCacheDistance", m_magneticCacheDistance,
130  "Minimum distance for BField lookup in cm. If the next requested point is closer than this distance than return the flast BField value. 0 means no caching",
131  0.0);
132  addParam("deltaChordInMagneticField", m_deltaChordInMagneticField,
133  "[mm] The maximum miss-distance between the trajectory curve and its linear cord(s) approximation", 0.25);
134  vector<string> defaultCommandsAtPreInit;
135  addParam("UICommandsAtPreInit", m_uiCommandsAtPreInit,
136  "A list of Geant4 UI commands that should be applied at PreInit state, before the simulation starts.",
137  defaultCommandsAtPreInit);
138  vector<string> defaultCommandsAtIdle;
139  addParam("UICommandsAtIdle", m_uiCommandsAtIdle,
140  "A list of Geant4 UI commands that should be applied at Idle state, before the simulation starts.",
141  defaultCommandsAtIdle);
142  addParam("trajectoryStore", m_trajectoryStore,
143  "If non-zero save the full trajectory of 1=primary, 2=non-optical or 3=all particles", 0);
144  addParam("trajectoryDistanceTolerance", m_trajectoryDistanceTolerance,
145  "Maximum deviation from the real trajectory points when merging "
146  "segments (in cm)", 5e-4);
147  vector<float> defaultAbsorbers;
148  addParam("AbsorbersRadii", m_absorbers,
149  "Radii (in cm) of absorbers across which tracks will be destroyed.", defaultAbsorbers);
150 
151  //Make sure the instance of the run manager is created now to initialize some stuff we need for geometry
152  RunManager::Instance();
153  m_magneticField = NULL;
154  m_uncachedField = NULL;
155  m_magFldEquation = NULL;
156  m_stepper = NULL;
157  m_chordFinder = NULL;
158  m_visManager = NULL;
159  m_stepLimiter = NULL;
160 }
161 
162 
163 FullSimModule::~FullSimModule()
164 {
165 
166 }
167 
168 
169 void FullSimModule::initialize()
170 {
171  // MCParticles input and output collections can be different.
172  // Output collection is always the default one.
173  // In case we simulate only beam background events using BG mixing or BG overlay
174  // there is no input collection.
175 
176  if (m_mcParticleInputColName.empty()) {
177  // input and output collections are the same
178  // register in datastore because the input collection may not exist (case: only BG)
179  StoreArray<MCParticle>().registerInDataStore();
180  } else {
181  // input and output collections are different
182  StoreArray<MCParticle>().isRequired(m_mcParticleInputColName); // input collection
183  StoreArray<MCParticle>().registerInDataStore(); // output collection
184  }
185 
186  //Make sure the EventMetaData already exists.
187  StoreObjPtr<EventMetaData>().isRequired();
188 
189  //Get the instance of the run manager.
190  RunManager& runManager = RunManager::Instance();
191 
192  //Add Geometry
193  runManager.SetUserInitialization(new DetectorConstruction());
194 
195  //Create the Physics list
196  //- PhysicsList* physicsList = new PhysicsList(m_physicsList);
197  //- physicsList->setProductionCutValue(m_productionCut);
198  //- if (m_optics) physicsList->registerOpticalPhysicsList();
199  //- runManager.SetUserInitialization(physicsList);
200 
201  if (m_physicsList == "Belle2") {
202  // Use Belle2PhysicsList
203  Belle2PhysicsList* physicsList = new Belle2PhysicsList(m_physicsList);
204  physicsList->SetVerbosity(m_runEventVerbosity);
205  physicsList->UseStandardEMPhysics(m_standardEM);
206  physicsList->UseOpticalPhysics(m_optics);
207  physicsList->UseHighPrecisionNeutrons(m_HPneutrons);
208  physicsList->SetProductionCutValue(m_productionCut);
209  physicsList->SetPXDProductionCutValue(m_pxdProductionCut);
210  physicsList->SetSVDProductionCutValue(m_svdProductionCut);
211  physicsList->SetCDCProductionCutValue(m_cdcProductionCut);
212  physicsList->SetARICHTOPProductionCutValue(m_arichtopProductionCut);
213  physicsList->SetECLProductionCutValue(m_eclProductionCut);
214  physicsList->SetKLMProductionCutValue(m_klmProductionCut);
215  physicsList->UseLongLivedNeutralParticles();
216 
217  //Apply the Geant4 UI commands in PreInit State - before initialization
218  if (m_uiCommandsAtPreInit.size() > 0) {
219  G4UImanager* uiManager = G4UImanager::GetUIpointer();
220  for (vector<string>::iterator iter = m_uiCommandsAtPreInit.begin(); iter != m_uiCommandsAtPreInit.end(); ++iter) {
221  uiManager->ApplyCommand(*iter);
222  }
223  }
224 
225  runManager.SetUserInitialization(physicsList);
226 
227  } else {
228  G4PhysListFactory physListFactory;
229  physListFactory.SetVerbose(m_runEventVerbosity);
230  G4VModularPhysicsList* physicsList = NULL;
231  if (physListFactory.IsReferencePhysList(m_physicsList)) physicsList = physListFactory.GetReferencePhysList(m_physicsList);
232  if (physicsList == NULL) B2FATAL("Could not load the physics list " << m_physicsList);
233  physicsList->RegisterPhysics(new ExtPhysicsConstructor);
234  if (m_optics) physicsList->RegisterPhysics(new G4OpticalPhysics);
235  if (m_monopoles) {
236  physicsList->RegisterPhysics(new G4MonopolePhysics(m_monopoleMagneticCharge));
237  }
238 
239  physicsList->RegisterPhysics(new G4LongLivedNeutralPhysics());
240 
241  physicsList->SetDefaultCutValue((m_productionCut / Unit::mm) * CLHEP::mm); // default is 0.7 mm
242 
243  //Apply the Geant4 UI commands in PreInit State - before initialization
244  if (m_uiCommandsAtPreInit.size() > 0) {
245  G4UImanager* uiManager = G4UImanager::GetUIpointer();
246  for (vector<string>::iterator iter = m_uiCommandsAtPreInit.begin(); iter != m_uiCommandsAtPreInit.end(); ++iter) {
247  uiManager->ApplyCommand(*iter);
248  }
249  }
250 
251  // LEP: For geant4e-specific particles, set a big step so that AlongStep computes
252  // all the energy (as is done in G4ErrorPhysicsList)
253  G4ParticleTable::G4PTblDicIterator* myParticleIterator = G4ParticleTable::GetParticleTable()->GetIterator();
254  myParticleIterator->reset();
255  while ((*myParticleIterator)()) {
256  G4ParticleDefinition* particle = myParticleIterator->value();
257  if (particle->GetParticleName().compare(0, 4, "g4e_") == 0) {
258  physicsList->SetParticleCuts(1.0E+9 * CLHEP::cm, particle);
259  }
260  }
261  runManager.SetUserInitialization(physicsList);
262  }
263 
264  //Create the magnetic field for the Geant4 simulation
265  if (m_magneticFieldName != "none") {
266  m_magneticField = new Belle2::Simulation::MagneticField();
267  if (m_magneticCacheDistance > 0) {
268  m_uncachedField = m_magneticField;
269  m_magneticField = new G4CachedMagneticField(m_uncachedField, m_magneticCacheDistance);
270  }
271  G4FieldManager* fieldManager = G4TransportationManager::GetTransportationManager()->GetFieldManager();
272  fieldManager->SetDetectorField(m_magneticField);
273  if (m_magneticFieldName != "default") {
274 
275  //We only use Magnetic field so let's try the specialized steppers
276  m_magFldEquation = new G4Mag_UsualEqRhs(m_magneticField);
277  if (m_magneticFieldName == "nystrom") {
278  m_stepper = new G4NystromRK4(m_magFldEquation);
279  } else if (m_magneticFieldName == "expliciteuler") {
280  m_stepper = new G4HelixExplicitEuler(m_magFldEquation);
281  } else if (m_magneticFieldName == "simplerunge") {
282  m_stepper = new G4HelixSimpleRunge(m_magFldEquation);
283  } else {
284  B2FATAL("Unknown magnetic field option: " << m_magneticFieldName);
285  }
286 
287  //Set a minimum stepsize (stepMinimum): The chordfinder should not attempt to limit
288  //the stepsize to something less than 10µm (which is the default value of Geant4).
289  m_chordFinder = new G4ChordFinder(m_magneticField, 1e-2 * CLHEP::mm, m_stepper);
290  fieldManager->SetChordFinder(m_chordFinder);
291  } else {
292  fieldManager->CreateChordFinder(m_magneticField);
293  }
294 
295  //Change DeltaCord (the max. miss-distance between the trajectory curve and its linear chord(s) approximation, if asked.
296  G4ChordFinder* chordFinder = fieldManager->GetChordFinder();
297  B2DEBUG(1, "Geant4 default deltaChord = " << chordFinder->GetDeltaChord());
298  chordFinder->SetDeltaChord(m_deltaChordInMagneticField * CLHEP::mm);
299  B2DEBUG(1, "DeltaChord after reset = " << chordFinder->GetDeltaChord());
300 
301  //This might be a good place to optimize the Integration parameters (DeltaOneStep, DeltaIntersection, MinEpsilon, MaxEpsilon)
302  }
303 
304  //Create the generator action which takes the MCParticle list and converts it to Geant4 primary vertices.
305  G4VUserPrimaryGeneratorAction* generatorAction = new PrimaryGeneratorAction(m_mcParticleInputColName, m_mcParticleGraph);
306  runManager.SetUserAction(generatorAction);
307 
308  //Add the event action which creates the final MCParticle list and the Relation list.
309  //The output collection name will be always "MCParticles".
310  EventAction* eventAction = new EventAction("", m_mcParticleGraph);
311  runManager.SetUserAction(eventAction);
312 
313  //Add the tracking action which handles the secondary particles created by Geant4.
314  TrackingAction* trackingAction = new TrackingAction(m_mcParticleGraph);
315  trackingAction->setIgnoreOpticalPhotons(!m_storeOpticalPhotons);
316  trackingAction->setIgnoreSecondaries(!m_storeSecondaries);
317  trackingAction->setSecondariesEnergyCut(m_secondariesEnergyCut);
318  trackingAction->setIgnoreBremsstrahlungPhotons(!m_storeBremsstrahlungPhotons);
319  trackingAction->setBremsstrahlungPhotonsEnergyCut(m_bremsstrahlungPhotonsEnergyCut);
320  trackingAction->setIgnorePairConversions(!m_storePairConversions);
321  trackingAction->setPairConversionsEnergyCut(m_pairConversionsEnergyCut);
322 
323  runManager.SetUserAction(trackingAction);
324 
325  //Add the stepping action which provides additional security checks
326  SteppingAction* steppingAction = new SteppingAction();
327  steppingAction->setMaxNumberSteps(m_maxNumberSteps);
328  steppingAction->setAbsorbersR(m_absorbers);
329  for (auto& rAbsorber : m_absorbers) {
330  B2INFO("An absorber found at R = " << rAbsorber << " cm");
331  }
332  runManager.SetUserAction(steppingAction);
333 
334  //Add the stacking action which provides performance speed ups for the handling of optical photons
335  StackingAction* stackingAction = new StackingAction();
336  stackingAction->setPropagatedPhotonFraction(m_photonFraction);
337  runManager.SetUserAction(stackingAction);
338 
339  //Initialize G4 kernel
340  runManager.Initialize();
341 
342  //Set the parameters for the G4Transportation system.
343  //To make sure we really change all G4Transportation classes, we loop over all particles
344  //even if the pointer to the G4Transportation object seems to be the same for all particles.
345  //Only one instance of G4StepLimiter is needed: see G4StepLimiterBuilder(), for example.
346  m_stepLimiter = new G4StepLimiter();
347  G4ParticleTable::G4PTblDicIterator* partIter = G4ParticleTable::GetParticleTable()->GetIterator();
348  partIter->reset();
349  while ((*partIter)()) {
350  G4ParticleDefinition* currParticle = partIter->value();
351  G4ProcessVector& currProcList = *currParticle->GetProcessManager()->GetProcessList();
352  assert(currProcList.size() < INT_MAX);
353  for (int iProcess = 0; iProcess < static_cast<int>(currProcList.size()); ++iProcess) {
354  G4Transportation* transport = dynamic_cast<G4Transportation*>(currProcList[iProcess]);
355  if (transport != nullptr) {
356  //Geant4 energy unit is MeV
357  transport->SetThresholdImportantEnergy(m_thresholdImportantEnergy / Unit::MeV * CLHEP::MeV);
358  transport->SetThresholdTrials(m_thresholdTrials);
359  break;
360  }
361  }
362  // Add StepLimiter process for charged tracks.
363  double zeroChargeTol = 0.01 * Unit::e;
364  if (fabs(currParticle->GetPDGCharge()) > zeroChargeTol) {
365  currParticle->GetProcessManager()->AddDiscreteProcess(m_stepLimiter);
366  B2DEBUG(100, "Added StepLimiter process for " << currParticle->GetParticleName());
367  }
368  }
369 
370  // Inactivate all secondary-generating processes for g4e particles. This comprises
371  // Cerenkov and Scintillation that were inserted by G4OpticalPhysics and the
372  // CaptureAtRest process for g4e anti-deuteron.
373  partIter->reset();
374  while ((*partIter)()) {
375  G4ParticleDefinition* currParticle = partIter->value();
376  if (currParticle->GetParticleName().compare(0, 4, "g4e_") == 0) {
377  G4ProcessManager* processManager = currParticle->GetProcessManager();
378  if (processManager) {
379  G4ProcessVector* processList = processManager->GetProcessList();
380  assert(processList->size() < INT_MAX);
381  for (int i = 0; i < static_cast<int>(processList->size()); ++i) {
382  if (((*processList)[i]->GetProcessName() == "Cerenkov") ||
383  ((*processList)[i]->GetProcessName() == "Scintillation") ||
384  ((*processList)[i]->GetProcessName() == "hFritiofCaptureAtRest")) {
385  processManager->SetProcessActivation(i, false);
386  }
387  }
388  }
389  }
390  }
391 
392  //Set the verbosity level of Geant4 according to the logging settings of the module
393  //int g4VerboseLevel = 0;
394  //switch (LogSystem::Instance().getCurrentLogLevel()) {
395  // case LogConfig::c_Debug : g4VerboseLevel = 2;
396  // break;
397  // case LogConfig::c_Info : g4VerboseLevel = 1;
398  // break;
399  // default: g4VerboseLevel = 0;
400  //}
401  //G4EventManager::GetEventManager()->SetVerboseLevel(g4VerboseLevel);
402  //G4RunManager::GetRunManager()->SetVerboseLevel(g4VerboseLevel);
403  G4EventManager::GetEventManager()->SetVerboseLevel(m_runEventVerbosity);
404  G4RunManager::GetRunManager()->SetVerboseLevel(m_runEventVerbosity);
405  G4EventManager::GetEventManager()->GetTrackingManager()->SetVerboseLevel(
406  m_trackingVerbosity); //turned out to be more useful as a parameter.
407  G4HadronicProcessStore::Instance()->SetVerbose(m_hadronProcessVerbosity);
408  G4EmParameters::Instance()->SetVerbose(m_emProcessVerbosity);
409 
410 
411  if (m_EnableVisualization) {
412  m_visManager = new G4VisExecutive;
413  m_visManager->Initialize();
414  }
415 
416  //Apply the Geant4 UI commands at Idle state - after initilization
417  if (m_uiCommandsAtIdle.size() > 0) {
418  G4UImanager* uiManager = G4UImanager::GetUIpointer();
419  for (vector<string>::iterator iter = m_uiCommandsAtIdle.begin(); iter != m_uiCommandsAtIdle.end(); ++iter) {
420  uiManager->ApplyCommand(*iter);
421  }
422  }
423 
424  //Store Trajectories?
425  if (m_trajectoryStore) {
426  trackingAction->setStoreTrajectories(m_trajectoryStore, m_trajectoryDistanceTolerance);
427  steppingAction->setStoreTrajectories(true);
428  }
429 
430  //Physics tables are build in run initialization. We have run independent
431  //geometry at the moment so there is no need to do this in begin run. Instead
432  //we use one Geant4 run for all Belle2 runs we might encounter. So let's do
433  //run initialization now to save memory when doing parallel processing
434  B2INFO("Perform Geant4 final initialization: Geometry optimization, PhysicsList calculations...");
435  RunManager::Instance().beginRun(0);
436  B2INFO("done, Geant4 ready");
437  //Otherwise we could use a fake run to do this and move RunManager::beginRun
438  //back to beginRun()
439  //runManager.BeamOn(0);
440 }
441 
442 
443 void FullSimModule::beginRun()
444 {
445  //Nothing to do: geometry and physics are run independent
446 }
447 
448 
449 void FullSimModule::event()
450 {
451  //Get the event meta data
452  StoreObjPtr<EventMetaData> eventMetaDataPtr;
453 
454  //Process the event
455  RunManager::Instance().processEvent(eventMetaDataPtr->getEvent());
456 }
457 
458 
459 void FullSimModule::endRun()
460 {
461  //Nothing to do: geometry and physics are run independent
462 }
463 
464 void FullSimModule::terminate()
465 {
466  //We used one Geant4 run for all Belle2 runs so end the geant4 run here
467  RunManager::Instance().endRun();
468  //And clean up the run manager
469  if (m_visManager != nullptr) delete m_visManager;
470  RunManager::Instance().destroy();
471  // Delete the step limiter process
472  delete m_stepLimiter;
473  // Delete the objects associated with transport in magnetic field
474  if (m_chordFinder) delete m_chordFinder;
475  if (m_stepper) delete m_stepper;
476  if (m_magFldEquation) delete m_magFldEquation;
477  if (m_uncachedField) delete m_uncachedField;
478  if (m_magneticField) delete m_magneticField;
479 }
Belle2::Simulation::SteppingAction::setMaxNumberSteps
void setMaxNumberSteps(int maxSteps)
Sets the maximum number of steps before a track is stopped and killed.
Definition: SteppingAction.h:56
Belle2::Simulation::StackingAction::setPropagatedPhotonFraction
void setPropagatedPhotonFraction(double fraction)
Set fraction of Cerenkov photons that are actually propagated.
Definition: StackingAction.h:56
Belle2::Simulation::ExtPhysicsConstructor
Define geant4e-specific physics.
Definition: ExtPhysicsConstructor.h:41
Belle2::Simulation::SteppingAction
The Class for the stepping action.
Definition: SteppingAction.h:39
Belle2::Simulation::Belle2PhysicsList::SetKLMProductionCutValue
void SetKLMProductionCutValue(G4double)
Set cut value for BKLM and EKLM envelopes.
Definition: Belle2PhysicsList.cc:323
Belle2::Simulation::Belle2PhysicsList::SetECLProductionCutValue
void SetECLProductionCutValue(G4double)
Set cut value for ECL barrel, forward and backward envelopes.
Definition: Belle2PhysicsList.cc:317
Belle2::Simulation::TrackingAction::setStoreTrajectories
void setStoreTrajectories(int store, double distanceTolerance)
Sets the trajectory option to enable storing of the simulated particle trajectories.
Definition: TrackingAction.cc:44
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Simulation::SteppingAction::setStoreTrajectories
void setStoreTrajectories(bool store)
Sets the trajectory option to enable storing of the simulated particle trajectories.
Definition: SteppingAction.h:59
Belle2::Simulation::TrackingAction::setIgnoreSecondaries
void setIgnoreSecondaries(bool ignore=true)
Set ignore flag for low energy Geant-produced secondary particles if set to true, secondaries with ki...
Definition: TrackingAction.h:82
Belle2::Simulation::TrackingAction::setBremsstrahlungPhotonsEnergyCut
void setBremsstrahlungPhotonsEnergyCut(double cut_MeV)
Set kinetic energy cut for bremsstrahlung photons.
Definition: TrackingAction.h:102
Belle2::Simulation::Belle2PhysicsList::UseHighPrecisionNeutrons
void UseHighPrecisionNeutrons(G4bool)
Use high precision neutron models below 20 MeV.
Definition: Belle2PhysicsList.cc:345
Belle2::Simulation::RunManager::Initialize
void Initialize()
Initialize the Kernel.
Definition: RunManager.cc:37
Belle2::Simulation::Belle2PhysicsList::SetProductionCutValue
void SetProductionCutValue(G4double)
Use parameter to set global cut value.
Definition: Belle2PhysicsList.cc:287
Belle2::Simulation::TrackingAction::setPairConversionsEnergyCut
void setPairConversionsEnergyCut(double cut_MeV)
Set kinetic energy cut for e+ e- pair conversions.
Definition: TrackingAction.h:116
Belle2::Simulation::RunManager
The run manager controls the flow of the Geant4 program and manages the event loop(s) within a run.
Definition: RunManager.h:40
Belle2::Simulation::Belle2PhysicsList::UseStandardEMPhysics
void UseStandardEMPhysics(G4bool)
Use standard EM physics instead of EM option1.
Definition: Belle2PhysicsList.cc:329
Belle2::DetectorConstruction
Class responsible to connect to geometry to simulation.
Definition: DetectorConstruction.h:38
Belle2::Simulation::Belle2PhysicsList::UseOpticalPhysics
void UseOpticalPhysics(G4bool)
Add optical photon physics.
Definition: Belle2PhysicsList.cc:339
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::Simulation::TrackingAction::setIgnorePairConversions
void setIgnorePairConversions(bool ignore=true)
Set ignore flag for e+ or e- coming from gamma conversions into a pair if set to true,...
Definition: TrackingAction.h:110
Belle2::Simulation::TrackingAction
The Tracking Action class.
Definition: TrackingAction.h:40
Belle2::Simulation::MagneticField
The Class for the Belle2 magnetic field implementation for Geant4.
Definition: MagneticField.h:38
Belle2::Simulation::StackingAction
The basf2 stacking action.
Definition: StackingAction.h:36
Belle2::Simulation::PrimaryGeneratorAction
The PrimaryGeneratorAction class inherits from G4VuserPrimaryGeneratorAction and specifies how a prim...
Definition: PrimaryGeneratorAction.h:36
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::Simulation::TrackingAction::setIgnoreOpticalPhotons
void setIgnoreOpticalPhotons(bool ignore=true)
Set ignore flag for optical photons if set to true, optical photons will not be stored in MCParticles...
Definition: TrackingAction.h:75
Belle2::Simulation::SteppingAction::setAbsorbersR
void setAbsorbersR(const std::vector< float > &vec)
Sets the radii of absorbers for killing tracks across them.
Definition: SteppingAction.h:65
Belle2::FullSimModule
The full Geant4 simulation module.
Definition: FullSimModule.h:44
Belle2::Simulation::Belle2PhysicsList::SetARICHTOPProductionCutValue
void SetARICHTOPProductionCutValue(G4double)
Set cut value for ARICH and TOP envelopes.
Definition: Belle2PhysicsList.cc:311
Belle2::Simulation::Belle2PhysicsList::UseLongLivedNeutralParticles
void UseLongLivedNeutralParticles()
Simulate neutral long-lived particles with given pdg and mass value.
Definition: Belle2PhysicsList.cc:350
Belle2::Simulation::TrackingAction::setIgnoreBremsstrahlungPhotons
void setIgnoreBremsstrahlungPhotons(bool ignore=true)
Set ignore flag for low energy breamsstrahlung photons if set to true, breamsstrahlung photons with k...
Definition: TrackingAction.h:96
Belle2::Simulation::Belle2PhysicsList::SetVerbosity
void SetVerbosity(G4int verb)
Run/event verbosity level.
Definition: Belle2PhysicsList.cc:281
Belle2::Simulation::Belle2PhysicsList::SetPXDProductionCutValue
void SetPXDProductionCutValue(G4double)
Set cut value for PXD envelope.
Definition: Belle2PhysicsList.cc:293
Belle2::Simulation::TrackingAction::setSecondariesEnergyCut
void setSecondariesEnergyCut(double cut_MeV)
Set kinetic energy cut for secondaries.
Definition: TrackingAction.h:88
Belle2::Simulation::Belle2PhysicsList::SetCDCProductionCutValue
void SetCDCProductionCutValue(G4double)
Set cut value for CDC envelope.
Definition: Belle2PhysicsList.cc:305
Belle2::StoreArray< MCParticle >
Belle2::Simulation::Belle2PhysicsList
Custom Geant4 physics list for Belle II with options to add optical physics, standard EM physics and ...
Definition: Belle2PhysicsList.h:37
Belle2::G4LongLivedNeutralPhysics
LongLivedNeutral physics Class – to be registered in the physics list.
Definition: G4LongLivedNeutralPhysics.h:37
Belle2::Monopoles::G4MonopolePhysics
Monopole physics class to register on the physics list.
Definition: G4MonopolePhysics.h:43
Belle2::Simulation::EventAction
The Event Action class.
Definition: EventAction.h:33
Belle2::Simulation::Belle2PhysicsList::SetSVDProductionCutValue
void SetSVDProductionCutValue(G4double)
Set cut value for SVD envelope.
Definition: Belle2PhysicsList.cc:299