DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4Exec.cpp
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "DD4hep/Printout.h"
17 #include "DD4hep/Primitives.h"
18 #include "DD4hep/InstanceCount.h"
19 #include "DD4hep/Handle.h"
20 #include "DDG4/Geant4RunAction.h"
21 #include "DDG4/Geant4EventAction.h"
28 #include "DDG4/Geant4PhysicsList.h"
29 #include "DDG4/Geant4UIManager.h"
30 #include "DDG4/Geant4Kernel.h"
31 #include "DDG4/Geant4Random.h"
32 
33 // Geant4 include files
34 #include "G4Version.hh"
35 #include "G4UserRunAction.hh"
36 #include "G4UserEventAction.hh"
37 #include "G4UserTrackingAction.hh"
38 #include "G4UserStackingAction.hh"
39 #include "G4UserSteppingAction.hh"
40 #include "G4VUserPhysicsList.hh"
41 #include "G4VModularPhysicsList.hh"
42 #include "G4VUserPrimaryGeneratorAction.hh"
43 #include "G4VUserActionInitialization.hh"
44 #include "G4VUserDetectorConstruction.hh"
45 
46 // C/C++ include files
47 #include <memory>
48 #include <stdexcept>
49 
50 namespace {
51  G4Mutex action_mutex=G4MUTEX_INITIALIZER;
52 }
53 
55 namespace DD4hep {
56 
58  namespace Simulation {
59 
61  template <typename T> class SequenceHdl {
62  public:
68  : m_sequence(0), m_activeContext(0) {
69  }
71  _aquire(seq);
72  }
73  virtual ~SequenceHdl() {
74  _release();
75  }
76  void _aquire(T* s) {
78  m_sequence = s;
79  if ( m_sequence ) m_sequence->addRef();
80  }
82  m_activeContext = ctxt;
83  if ( m_sequence ) {
84  m_sequence->updateContext(ctxt);
85  }
86  }
87  void _release() {
90  }
91  Geant4Context* context() const {
92  return m_activeContext;
93  }
94  Geant4Kernel& kernel() const {
95  return context()->kernel();
96  }
98  if ( m_sequence ) {
99  m_sequence->configureFiber(ctxt);
100  }
101  }
102  void createClientContext(const G4Run* run) {
103  Geant4Run* r = new Geant4Run(run);
105  }
106  void destroyClientContext(const G4Run*) {
108  if ( r ) {
110  deletePtr(r);
111  }
112  }
113  void createClientContext(const G4Event* evt) {
116  }
117  void destroyClientContext(const G4Event*) {
119  if ( e ) {
121  deletePtr(e);
122  }
123  }
124  };
125 
126  class Geant4UserRunAction;
127  class Geant4UserEventAction;
128 
130 
136  public G4UserRunAction,
137  public SequenceHdl<Geant4RunActionSequence>
138  {
139  public:
143  : Base(ctxt, seq), eventAction(0) {
144  updateContext(ctxt);
145  configureFiber(ctxt);
146  }
149  }
151  virtual void BeginOfRunAction(const G4Run* run);
153  virtual void EndOfRunAction(const G4Run* run);
154  };
155 
157 
163  public G4UserEventAction,
164  public SequenceHdl<Geant4EventActionSequence>
165  {
166  public:
170  : Base(ctxt, seq), runAction(0) {
171  updateContext(ctxt);
172  configureFiber(ctxt);
173  }
176  }
178  virtual void BeginOfEventAction(const G4Event* evt);
180  virtual void EndOfEventAction(const G4Event* evt);
181  };
182 
184 
190  public G4UserTrackingAction,
191  public SequenceHdl<Geant4TrackingActionSequence>
192  {
193  public:
196  : Base(ctxt, seq) {
197  updateContext(ctxt);
198  configureFiber(ctxt);
199  }
202  }
204  virtual void PreUserTrackingAction(const G4Track* trk) {
205  m_sequence->context()->kernel().setTrackMgr(fpTrackingManager);
206  m_sequence->begin(trk);
207  }
209  virtual void PostUserTrackingAction(const G4Track* trk) {
210  m_sequence->end(trk);
212  }
213  };
214 
216 
222  public G4UserStackingAction,
223  public SequenceHdl<Geant4StackingActionSequence>
224  {
225  public:
228  : Base(ctxt, seq) {
229  updateContext(ctxt);
230  configureFiber(ctxt);
231  }
234  }
236  virtual void NewStage() {
237  m_sequence->newStage();
238  }
240  virtual void PrepareNewEvent() {
241  m_sequence->prepare();
242  }
243  };
244 
245 
247 
254  public SequenceHdl<Geant4GeneratorActionSequence>
255  {
256  public:
259  : G4VUserPrimaryGeneratorAction(), Base(ctxt, seq) {
260  updateContext(ctxt);
261  configureFiber(ctxt);
262  }
265  }
267  virtual void GeneratePrimaries(G4Event* event);
268  };
269 
271 
277  public G4UserSteppingAction,
278  public SequenceHdl<Geant4SteppingActionSequence>
279  {
280  public:
283  : Base(ctxt, seq) {
284  updateContext(ctxt);
285  configureFiber(ctxt);
286  }
289  }
291  virtual void UserSteppingAction(const G4Step* s) {
292  (*m_sequence)(s, fpSteppingManager);
293  }
294  };
295 
297 
304  public SequenceHdl<Geant4DetectorConstructionSequence>
305  {
306  protected:
308  public:
311  : G4VUserDetectorConstruction(), Base(ctxt, seq),
312  m_ctxt(ctxt->kernel().lcdd(), this)
313  {
314  }
317  }
319  virtual void ConstructSDandField();
321  virtual G4VPhysicalVolume* Construct();
322  };
323 
325 
332  public SequenceHdl<Geant4UserInitializationSequence>
333  {
334  public:
337  : G4VUserActionInitialization(), Base(ctxt, seq) {
338  }
341  }
343  virtual void Build() const;
345  virtual void BuildForMaster() const;
346  };
347 
349  void Geant4UserRunAction::BeginOfRunAction(const G4Run* run) {
350  createClientContext(run);
351  kernel().executePhase("begin-run",(const void**)&run);
352  if ( m_sequence ) m_sequence->begin(run); // Action not mandatory
353  }
354 
356  void Geant4UserRunAction::EndOfRunAction(const G4Run* run) {
357  if ( m_sequence ) m_sequence->end(run); // Action not mandatory
358  kernel().executePhase("end-run",(const void**)&run);
360  }
361 
363  void Geant4UserEventAction::BeginOfEventAction(const G4Event* evt) {
364  kernel().executePhase("begin-event",(const void**)&evt);
365  if ( m_sequence ) m_sequence->begin(evt); // Action not mandatory
366  }
367 
369  void Geant4UserEventAction::EndOfEventAction(const G4Event* evt) {
370  if ( m_sequence ) m_sequence->end(evt); // Action not mandatory
371  kernel().executePhase("end-event",(const void**)&evt);
373  }
374 
377  createClientContext(event);
378  if ( m_sequence ) {
379  (*m_sequence)(event);
380  return;
381  }
382  throw std::runtime_error("GeneratePrimaries: Panic! No action sequencer defined. "
383  "No primary particles can be produced.");
384  }
385 
388  G4AutoLock protection_lock(&action_mutex);
389  Geant4Context* ctx = m_sequence->context();
394  updateContext(ctx);
395  }
396 
399  // The G4TransportationManager is thread-local.
400  // Thus, regardless of whether the field class object is global or local
401  // to a certain volume, a field object must be assigned to G4FieldManager.
402  G4AutoLock protection_lock(&action_mutex);
405  if ( 0 == m_ctxt.world ) {
406  m_sequence->except("+++ Executing G4 detector construction did not result in a valid world volume!");
407  }
408  return m_ctxt.world;
409  }
410 
413  G4AutoLock protection_lock(&action_mutex);
415  Geant4Context* ctx = krnl.workerContext();
416 
417  if ( m_sequence ) {
418  Geant4Context* old = m_sequence->context();
419  m_sequence->info("+++ Executing Geant4UserActionInitialization::Build. "
420  "Context:%p Kernel:%p [%ld]", (void*)ctx, (void*)&krnl, krnl.id());
421 
423  m_sequence->build();
425  }
426  // Set user generator action sequence. Not optional, since event context is defined inside
427  Geant4UserGeneratorAction* gen_action = new Geant4UserGeneratorAction(ctx,krnl.generatorAction(false));
428  SetUserAction(gen_action);
429 
430  // Set the run action sequence. Not optional, since run context is defined/destroyed inside
431  Geant4UserRunAction* run_action = new Geant4UserRunAction(ctx,krnl.runAction(false));
432  SetUserAction(run_action);
433 
434  // Set the event action sequence. Not optional, since event context is destroyed inside
435  Geant4UserEventAction* evt_action = new Geant4UserEventAction(ctx,krnl.eventAction(false));
436  run_action->eventAction = evt_action;
437  evt_action->runAction = run_action;
438  SetUserAction(evt_action);
439 
440  // Set the tracking action sequence
441  Geant4TrackingActionSequence* trk_action = krnl.trackingAction(false);
442  if ( trk_action ) {
443  Geant4UserTrackingAction* action = new Geant4UserTrackingAction(ctx, trk_action);
444  SetUserAction(action);
445  }
446  // Set the stepping action sequence
447  Geant4SteppingActionSequence* stp_action = krnl.steppingAction(false);
448  if ( stp_action ) {
449  Geant4UserSteppingAction* action = new Geant4UserSteppingAction(ctx, stp_action);
450  SetUserAction(action);
451  }
452  // Set the stacking action sequence
453  Geant4StackingActionSequence* stk_action = krnl.stackingAction(false);
454  if ( stk_action ) {
455  Geant4UserStackingAction* action = new Geant4UserStackingAction(ctx, stk_action);
456  SetUserAction(action);
457  }
458 
459  }
460 
463  if ( m_sequence ) {
464  m_sequence->info("+++ Executing Geant4UserActionInitialization::BuildForMaster....");
466  }
467  }
468  }
469 }
470 
471 #include "DD4hep/LCDD.h"
472 #include "DD4hep/Plugins.h"
474 #include "DDG4/Geant4Kernel.h"
475 
476 using namespace std;
477 using namespace DD4hep;
478 using namespace DD4hep::Simulation;
479 
480 // Geant4 include files
481 #include "G4RunManager.hh"
482 #include "G4PhysListFactory.hh"
483 
485 public:
487  Geant4DetectorConstructionSequence* buildDefaultDetectorConstruction(Geant4Kernel& kernel);
488 };
490  Geant4Action* cr;
492  Geant4Context* ctx = kernel.workerContext();
494  printout(WARNING, "Geant4Exec", "+++ Building default Geant4DetectorConstruction for single threaded compatibility.");
495 
496  // Attach first the geometry converter from DD4hep to Geant4
497  cr = PluginService::Create<Geant4Action*>("Geant4DetectorGeometryConstruction",ctx,string("ConstructGeometry"));
498  det_cr = dynamic_cast<Geant4DetectorConstruction*>(cr);
499  if ( det_cr )
500  seq->adopt(det_cr);
501  else
502  throw runtime_error("Panic! Failed to build Geant4DetectorGeometryConstruction.");
503  // Attach the sensitive detector manipulator:
504  cr = PluginService::Create<Geant4Action*>("Geant4DetectorSensitivesConstruction",ctx,string("ConstructSensitives"));
505  det_cr = dynamic_cast<Geant4DetectorConstruction*>(cr);
506  if ( det_cr )
507  seq->adopt(det_cr);
508  else
509  throw runtime_error("Panic! Failed to build Geant4DetectorSensitivesConstruction.");
510  return seq;
511 }
512 
514 int Geant4Exec::configure(Geant4Kernel& kernel) {
515  Geometry::LCDD& lcdd = kernel.lcdd();
516  Geant4Context* ctx = kernel.workerContext();
517  Geant4Random* rndm = Geant4Random::instance(false);
518 
519  if ( !rndm ) {
520  rndm = new Geant4Random(ctx, "Geant4Random");
522  rndm->initialize();
523  }
524  Geant4Random::setMainInstance(rndm);
525  kernel.executePhase("configure",0);
526 
527  // Construct the default run manager
528  G4RunManager& runManager = kernel.runManager();
529 
530  // Check if the geometry was loaded
531  if (lcdd.sensitiveDetectors().size() <= 1) {
532  printout(WARNING, "Geant4Exec", "+++ Only %d subdetectors present. "
533  "You sure you loaded the geometry properly?",
534  int(lcdd.sensitiveDetectors().size()));
535  }
536 
537  // Get the detector constructed
539  if ( 0 == user_det && kernel.isMultiThreaded() ) {
540  throw runtime_error("Panic! No valid detector construction sequencer present. [Mandatory MT]");
541  }
542  if ( 0 == user_det && !kernel.isMultiThreaded() ) {
544  }
546  runManager.SetUserInitialization(det_seq);
547 
548  // Get the physics list constructed
549  Geant4PhysicsListActionSequence* phys_seq = kernel.physicsList(false);
550  if ( 0 == phys_seq ) {
551  string phys_model = "QGSP_BERT";
552  phys_seq = kernel.physicsList(true);
553  phys_seq->property("extends").set(phys_model);
554  }
555  G4VUserPhysicsList* physics = phys_seq->extensionList();
556  if (0 == physics) {
557  throw runtime_error("Panic! No valid user physics list present!");
558  }
559 #if 0
560  printout(INFO, "Geant4Exec", "+++ PhysicsList RangeCut: %f", phys_seq->m_rangecut );
562  physics->SetDefaultCutValue(phys_seq->m_rangecut);
563  physics->SetCuts();
564  if( DEBUG == printLevel() ) physics->DumpCutValuesTable();
565 #endif
566  runManager.SetUserInitialization(physics);
567 
568  // Construct the remaining user initialization in multi-threaded mode
569  Geant4UserInitializationSequence* user_init = kernel.userInitialization(false);
570  if ( 0 == user_init && kernel.isMultiThreaded() ) {
571  throw runtime_error("Panic! No valid user initialization sequencer present. [Mandatory MT]");
572  }
573  else if ( 0 == user_init && !kernel.isMultiThreaded() ) {
574  // Use default actions registered to the default kernel. Will do the right thing...
575  user_init = kernel.userInitialization(true);
576  }
578  runManager.SetUserInitialization(init);
579  return 1;
580 }
581 
583 int Geant4Exec::initialize(Geant4Kernel& kernel) {
584  // Construct the default run manager
585  G4RunManager& runManager = kernel.runManager();
586  //
587  // Initialize G4 engine
588  //
589  kernel.executePhase("initialize",0);
590  runManager.Initialize();
591  return 1;
592 }
593 
595 int Geant4Exec::run(Geant4Kernel& kernel) {
596  Property& p = kernel.property("UI");
597  string value = p.value<string>();
598 
599  kernel.executePhase("start",0);
600  if ( !value.empty() ) {
601  Geant4Action* ui = kernel.globalAction(value);
602  if ( ui ) {
603  Geant4Call* c = dynamic_cast<Geant4Call*>(ui);
604  if ( c ) {
605  (*c)(0);
606  kernel.executePhase("stop",0);
607  return 1;
608  }
609  ui->except("++ Geant4Exec: Failed to start UI interface.");
610  }
611  throw runtime_error(format("Geant4Exec","++ Failed to locate UI interface %s.",value.c_str()));
612  }
613  long nevt = kernel.property("NumEvents").value<long>();
614  kernel.runManager().BeamOn(nevt);
615  kernel.executePhase("stop",0);
616  return 1;
617 }
618 
620 int Geant4Exec::terminate(Geant4Kernel& kernel) {
621  kernel.executePhase("terminate",0);
622  return 1;
623 }
Geant4UserInitializationSequence * userInitialization(bool create)
Access to the user initialization object.
virtual ~Geant4UserDetectorConstruction()
Default destructor.
Definition: Geant4Exec.cpp:316
void setTrackMgr(G4TrackingManager *mgr)
Access the tracking manager.
Definition: Geant4Kernel.h:157
The property class to assign options to actions.
Concrete implementation of the Geant4 stepping action sequence.
Concrete implementation of the Geant4 user initialization action sequence.
Definition: Geant4Exec.cpp:330
Geant4Kernel & worker(unsigned long thread_identifier, bool create_if=false)
Access worker instance by it's identifier.
static unsigned long int thread_self()
Access thread identifier.
User event context for DDG4.
virtual const HandleMap & sensitiveDetectors() const =0
Accessor to the map of sub-detectors.
Geant4UserActionInitialization(Geant4Context *ctxt, Geant4UserInitializationSequence *seq)
Standard constructor.
Definition: Geant4Exec.cpp:336
Class to orchestrate a modular initializion of a multi- or single threaded Geant4 application...
double m_rangecut
global range cut for secondary productions
virtual void constructGeo(Geant4DetectorConstructionContext *ctxt)
Geometry construction callback. Called at "Construct()".
void deletePtr(T *&p)
Helper to delete objects from heap and reset the pointer. Saves many many lines of code...
Definition: Primitives.h:234
Geant4Kernel & kernel() const
Access to the kernel object.
G4VPhysicalVolume * world
Reference to the world after construction.
Geant4SteppingActionSequence * steppingAction(bool create)
Access stepping action sequence.
virtual void UserSteppingAction(const G4Step *s)
User stepping callback.
Definition: Geant4Exec.cpp:291
virtual void EndOfEventAction(const G4Event *evt)
End-of-event callback.
Definition: Geant4Exec.cpp:369
virtual void BeginOfRunAction(const G4Run *run)
Begin-of-run callback.
Definition: Geant4Exec.cpp:349
SequenceHdl(Geant4Context *ctxt, T *seq)
Definition: Geant4Exec.cpp:70
Concrete implementation of the Geant4 generator action.
Definition: Geant4Exec.cpp:252
virtual ~Geant4UserGeneratorAction()
Default destructor.
Definition: Geant4Exec.cpp:264
void destroyClientContext(const G4Run *)
Definition: Geant4Exec.cpp:106
Geant4TrackingActionSequence * trackingAction(bool create)
Access tracking action sequence.
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:24
virtual void end(const G4Run *run)
End-of-run callback.
static void decrement(T *)
Decrement count according to type information.
Concrete basic implementation of the Geant4 detector construction sequencer.
Geant4Context * context() const
Definition: Geant4Exec.cpp:91
void createClientContext(const G4Run *run)
Definition: Geant4Exec.cpp:102
void adopt(Geant4DetectorConstruction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Geant4StackingActionSequence * stackingAction(bool create)
Access stacking action sequence.
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:32
virtual ~Geant4UserSteppingAction()
Default destructor.
Definition: Geant4Exec.cpp:288
virtual void end(const G4Track *track)
Post-tracking action callback.
virtual void NewStage()
New-stage callback.
Definition: Geant4Exec.cpp:236
TGeoShape * s
Definition: Volumes.cpp:294
Concrete implementation of the Geant4 run action.
Definition: Geant4Exec.cpp:135
LCDD & lcdd() const
Access to detector description.
Definition: Geant4Kernel.h:153
return e
Definition: Volumes.cpp:297
Sequence handler implementing common actions to all sequences.
Definition: Geant4Exec.cpp:61
Concrete implementation of the Geant4 event action sequence.
void createClientContext(const G4Event *evt)
Definition: Geant4Exec.cpp:113
PrintLevel printLevel()
Access the current printer level.
Definition: Printout.cpp:323
void build(Q *p, void(T::*f)())
Register callback to setup worker. Types Q and T must be polymorph!
virtual void BuildForMaster() const
Build the action sequences for the master thread.
Definition: Geant4Exec.cpp:462
virtual ~Geant4UserActionInitialization()
Default destructor.
Definition: Geant4Exec.cpp:340
Property & property(const std::string &name)
Access single property.
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:261
Concrete implementation of the Geant4 tracking action sequence.
virtual void constructSensitives(Geant4DetectorConstructionContext *ctxt)
Sensitive detector construction callback. Called at "ConstructSDandField()".
void destroyClientContext(const G4Event *)
Definition: Geant4Exec.cpp:117
Geant4UserEventAction(Geant4Context *ctxt, Geant4EventActionSequence *seq)
Standard constructor.
Definition: Geant4Exec.cpp:169
Geant4Kernel & kernel() const
Definition: Geant4Exec.cpp:94
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
std::string format(const std::string &src, const std::string &fmt,...)
Build formatted string.
Definition: Printout.cpp:267
void releasePtr(T &p)
Helper to delete objects from heap and reset the pointer. Saves many many lines of code...
Definition: Primitives.h:316
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:16
void initialize()
Initialize the instance.
Concrete implementation of the Geant4 stacking action sequence.
static Geant4Random * instance(bool throw_exception=true)
Access the main Geant4 random generator instance. Must be created before used!
virtual G4VPhysicalVolume * Construct()
Call the actions to construct the detector geometry.
Definition: Geant4Exec.cpp:398
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:52
Class, which allows all Geant4Action derivatives to access the DDG4 kernel structures.
Definition: Geant4Kernel.h:43
virtual ~Geant4UserTrackingAction()
Default destructor.
Definition: Geant4Exec.cpp:201
Geant4DetectorConstructionSequence * buildDefaultDetectorConstruction(Geant4Kernel &kernel)
Definition: Geant4Exec.cpp:489
virtual void EndOfRunAction(const G4Run *run)
End-of-run callback.
Definition: Geant4Exec.cpp:356
Geant4PhysicsListActionSequence * physicsList(bool create)
Access to the physics list.
Geant4UserDetectorConstruction(Geant4Context *ctxt, Geant4DetectorConstructionSequence *seq)
Standard constructor.
Definition: Geant4Exec.cpp:310
Geant4EventActionSequence * eventAction(bool create)
Access run action sequence.
Property & property(const std::string &name)
Access single property.
virtual void GeneratePrimaries(G4Event *event)
Generate primary particles.
Definition: Geant4Exec.cpp:376
virtual void PrepareNewEvent()
Preparation callback.
Definition: Geant4Exec.cpp:240
The implementation of the single Geant4 physics list action sequence.
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:28
virtual ~Geant4UserRunAction()
Default destructor.
Definition: Geant4Exec.cpp:148
virtual void end(const G4Event *event)
End-of-event callback.
User run context for DDG4.
Definition: Geant4Context.h:71
Concrete implementation of the Geant4 user detector construction action sequence. ...
Definition: Geant4Exec.cpp:302
virtual void Build() const
Build the actions for the worker thread.
Definition: Geant4Exec.cpp:412
Geant4GeneratorActionSequence * generatorAction(bool create)
Access generator action sequence.
Concrete implementation of the Geant4 generator action sequence.
Concrete basic implementation of the Geant4 run action sequencer.
virtual ~Geant4UserStackingAction()
Default destructor.
Definition: Geant4Exec.cpp:233
Geant4Context * workerContext()
Thread's Geant4 execution context.
Geant4UserSteppingAction(Geant4Context *ctxt, Geant4SteppingActionSequence *seq)
Standard constructor.
Definition: Geant4Exec.cpp:282
Geant4UserRunAction(Geant4Context *ctxt, Geant4RunActionSequence *seq)
Standard constructor.
Definition: Geant4Exec.cpp:142
virtual void updateContext(Geant4Context *ctxt)
Set client context.
void updateContext(Geant4Context *ctxt)
Definition: Geant4Exec.cpp:81
TYPE value() const
Retrieve value.
Geant4DetectorConstructionSequence * detectorConstruction(bool create)
Access detector construcion action sequence (geometry+sensitives+field)
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
virtual bool executePhase(const std::string &name, const void **args) const
Execute phase action if it exists.
void setEvent(Geant4Event *new_event)
Set the geant4 event reference.
virtual void PostUserTrackingAction(const G4Track *trk)
Post-track action callback.
Definition: Geant4Exec.cpp:209
virtual void ConstructSDandField()
Call the actions for the construction of the sensitive detectors and the field.
Definition: Geant4Exec.cpp:387
Geant4UserGeneratorAction(Geant4Context *ctxt, Geant4GeneratorActionSequence *seq)
Standard constructor.
Definition: Geant4Exec.cpp:258
void setRun(Geant4Run *new_run)
Set the geant4 run reference.
virtual void BeginOfEventAction(const G4Event *evt)
Begin-of-event callback.
Definition: Geant4Exec.cpp:363
G4RunManager & runManager()
Access to the Geant4 run manager.
Concrete implementation of the Geant4 stacking action sequence.
Definition: Geant4Exec.cpp:221
Geant4Event * eventPtr() const
Access the geant4 event by ptr. Must be checked by clients!
Concrete implementation of the Geant4 event action.
Definition: Geant4Exec.cpp:162
#define DEBUG
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:20
Generic context to extend user, run and event information.
void buildMaster(Q *p, void(T::*f)())
Register callback to setup master. Types Q and T must be polymorph!
Geant4DetectorConstructionContext m_ctxt
Definition: Geant4Exec.cpp:307
Basic implementation of the Geant4 detector construction action.
Geant4UserEventAction * eventAction
Definition: Geant4Exec.cpp:140
The main interface to the DD4hep detector description package.
Definition: LCDD.h:82
Concrete implementation of the Geant4 stepping action.
Definition: Geant4Exec.cpp:276
Mini interface to THE random generator of the application.
Definition: Geant4Random.h:60
G4VUserPhysicsList * extensionList()
Extend physics list from factory:
unsigned long id() const
Access worker identifier.
Definition: Geant4Kernel.h:161
void info(const char *fmt,...) const
Support of info messages.
Concrete implementation of the Geant4 tracking action.
Definition: Geant4Exec.cpp:189
virtual void PreUserTrackingAction(const G4Track *trk)
Pre-track action callback.
Definition: Geant4Exec.cpp:204
virtual ~Geant4UserEventAction()
Default destructor.
Definition: Geant4Exec.cpp:175
Callback interface class with argument.
Definition: Geant4Call.h:30
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
Definition: Printout.cpp:111
Geant4UserTrackingAction(Geant4Context *ctxt, Geant4TrackingActionSequence *seq)
Standard constructor.
Definition: Geant4Exec.cpp:195
void set(const TYPE &value)
Set value of this property.
SequenceHdl()
Default constructor.
Definition: Geant4Exec.cpp:67
Geant4Action * globalAction(const std::string &action_name, bool throw_if_not_present=true)
Retrieve action from repository.
virtual void constructField(Geant4DetectorConstructionContext *ctxt)
Electromagnetic field construction callback. Called at "ConstructSDandField()".
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:91
virtual void begin(const G4Event *event)
Begin-of-event callback.
void configureFiber(Geant4Context *ctxt)
Definition: Geant4Exec.cpp:97
Geant4 detector construction context definition.
virtual void begin(const G4Track *track)
Pre-tracking action callback.
Geant4Run * runPtr() const
Access the geant4 run by ptr. Must be checked by clients!
Geant4RunActionSequence * runAction(bool create)
Access run action sequence.
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:56
Geant4UserStackingAction(Geant4Context *ctxt, Geant4StackingActionSequence *seq)
Standard constructor.
Definition: Geant4Exec.cpp:227
virtual void begin(const G4Run *run)
Begin-of-run callback.