DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4SensDetAction.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDG4_GEANT4SENSDETACTION_H
14 #define DDG4_GEANT4SENSDETACTION_H
15 
16 // Framework include files
17 #include <DD4hep/Detector.h>
18 #include <DDG4/Geant4Action.h>
20 
21 // Geant4 include files
22 #include <G4ThreeVector.hh>
23 #include <G4VTouchable.hh>
24 
25 // C/C++ include files
26 #include <vector>
27 
28 // Forward declarations
29 class G4HCofThisEvent;
30 class G4Step;
31 class G4Event;
32 class G4TouchableHistory;
33 class G4VHitsCollection;
34 class G4VReadOutGeometry;
35 
37 namespace dd4hep {
38 
39  // Forward declarations
40  class Detector;
41  class DetElement;
42  class SensitiveDetector;
43 
45  namespace sim {
46 
47  // Forward declarations
48  class Geant4Sensitive;
49  class Geant4FastSimSpot;
50  class Geant4StepHandler;
51  class Geant4HitCollection;
52  class Geant4SensDetActionSequence;
53  class Geant4SensDetSequences;
54 
56 
61  class Geant4ActionSD: virtual public Geant4Action {
62  protected:
66  Geant4ActionSD(const std::string& name);
68  virtual ~Geant4ActionSD();
69  public:
71  virtual std::size_t defineCollection(const std::string& name) = 0;
73  virtual G4VReadOutGeometry* readoutGeometry() const = 0;
75  virtual G4int GetCollectionID(G4int i) = 0;
77  virtual bool isActive() const = 0;
79  virtual SensitiveDetector sensitiveDetector() const = 0;
81  virtual std::string path() const = 0;
83  virtual std::string fullPath() const = 0;
85  virtual const std::string& sensitiveType() const = 0;
86  };
87 
89 
94  class Geant4Filter: public Geant4Action {
95  protected:
98 
99  public:
101  Geant4Filter(Geant4Context* context, const std::string& name);
103  virtual ~Geant4Filter();
104 
106  virtual bool operator()(const G4Step* step) const;
107 
109 
112  virtual bool operator()(const Geant4FastSimSpot* spot) const;
113  };
114 
116 
122  public:
125  MEDIUM_MODE = 1<<0,
126  DETAILED_MODE = 1<<1
127  };
128 
129  private:
134 
135  protected:
138 #if defined(G__ROOT) || defined(__CLING__) || defined(__ROOTCLING__)
139  Detector* m_detDesc { nullptr };
141 #else
144 #endif
155 
158 
159  public:
161  Geant4Sensitive(Geant4Context* context, const std::string& name, DetElement det, Detector& description);
162 
164  virtual ~Geant4Sensitive();
165 
167  Geant4ActionSD& detector() const;
168 
170  void setDetector(Geant4ActionSD* sens_det);
171 
173  int hitCreationMode() const {
174  return m_hitCreationMode;
175  }
176 
178  std::string detectorName() const {
179  return detector().name();
180  }
181 
183  std::string path() const {
184  return detector().path();
185  }
186 
188  std::string fullPath() const {
189  return detector().fullPath();
190  }
191 
193  bool isActive() const {
194  return detector().isActive();
195  }
196 
199  return m_sensitive;
200  }
201 
203  G4VReadOutGeometry* readoutGeometry() const {
204  return detector().readoutGeometry();
205  }
206 
208  Detector& detectorDescription() const;
209 
211  void mark(const G4Track* track) const;
212 
214  void mark(const G4Step* step) const;
215 
218 
220  void adopt(Geant4Filter* filter);
221 
223  void adopt_front(Geant4Filter* filter);
224 
226  void adoptFilter(Geant4Action* filter);
227 
229  void adoptFilter_front(Geant4Action* filter);
230 
232 
234  bool accept(const G4Step* step) const;
235 
237 
239  bool accept(const Geant4FastSimSpot* step) const;
240 
242  template <typename TYPE> std::size_t defineCollection(const std::string& coll_name);
243 
245  const std::string& hitCollectionName(std::size_t which) const;
246 
248  Geant4HitCollection* collection(std::size_t which);
249 
251  Geant4HitCollection* collectionByID(std::size_t id);
252 
254  virtual void defineCollections();
255 
257 
260  virtual void begin(G4HCofThisEvent* hce);
261 
263  virtual void end(G4HCofThisEvent* hce);
264 
266 
271  virtual void clear(G4HCofThisEvent* hce);
272 
274 
277  long long int volumeID(const G4Step* step);
278 
280 
283  long long int volumeID(const G4VTouchable* touchable);
284 
286 
290  long long int cellID(const G4Step* step);
291 
293 
297  long long int cellID(const G4VTouchable* touchable, const G4ThreeVector& global);
298 
300  virtual bool process(const G4Step* step, G4TouchableHistory* history);
301 
303 
306  virtual bool processFastSim(const Geant4FastSimSpot* spot, G4TouchableHistory* history);
307  };
308 
310 
318  public:
319  typedef Geant4HitCollection* (*create_t)(const std::string&, const std::string&, Geant4Sensitive*);
320  typedef std::pair<std::string, std::pair<Geant4Sensitive*,create_t> > HitCollection;
321  typedef std::vector<HitCollection> HitCollections;
322 
323  protected:
325  G4HCofThisEvent* m_hce = 0;
335  Actors<Geant4Sensitive> m_actors;
337  Actors<Geant4Filter> m_filters;
338 
346  std::string m_sensitiveType;
348  template <typename TYPE> static
349  Geant4HitCollection* _create(const std::string& det, const std::string& coll, Geant4Sensitive* sd) {
350  return new Geant4HitCollection(det, coll, sd, (TYPE*) 0);
351  }
352 
353  protected:
356 
357  public:
360 
363 
365  virtual const std::string& sensitiveType() const {
366  return m_sensitiveType;
367  }
368 
370  virtual void updateContext(Geant4Context* ctxt) override;
371 
373  std::size_t defineCollections(Geant4ActionSD* sens_det);
374 
376  std::size_t defineCollection(Geant4Sensitive* owner, const std::string& name, create_t func);
377 
379  template <typename TYPE> std::size_t defineCollection(Geant4Sensitive* owner, const std::string& coll_name) {
380  return defineCollection(owner, coll_name, Geant4SensDetActionSequence::_create<TYPE>);
381  }
382 
384  const std::string& hitCollectionName(std::size_t which) const;
385 
387  Geant4HitCollection* collection(std::size_t which) const;
388 
390  Geant4HitCollection* collectionByID(std::size_t id) const;
391 
393  template <typename T> void callAtBegin(T* p, void (T::*f)(G4HCofThisEvent*)) {
394  m_begin.add(p, f);
395  }
396 
398  template <typename T> void callAtEnd(T* p, void (T::*f)(G4HCofThisEvent*)) {
399  m_end.add(p, f);
400  }
401 
403  template <typename T> void callAtProcess(T* p, void (T::*f)(G4Step*, G4TouchableHistory*)) {
404  m_process.add(p, f);
405  }
406 
408  template <typename T> void callAtClear(T* p, void (T::*f)(G4HCofThisEvent*)) {
409  m_clear.add(p, f);
410  }
411 
413  void adopt(Geant4Sensitive* sensitive);
414 
416  void adopt(Geant4Filter* filter);
417 
419  void adoptFilter(Geant4Action* filter);
420 
422  bool accept(const G4Step* step) const;
423 
425  bool accept(const Geant4FastSimSpot* step) const;
426 
428 
431  virtual void begin(G4HCofThisEvent* hce);
432 
434 
435  virtual void end(G4HCofThisEvent* hce);
437 
442  virtual void clear();
443 
445  virtual bool process(const G4Step* step, G4TouchableHistory* history);
446 
448  virtual bool processFastSim(const Geant4FastSimSpot* spot, G4TouchableHistory* history);
449  };
450 
452 
465  public:
466  friend class Geant4ActionContainer;
468  typedef std::map<std::string, Geant4SensDetActionSequence*> Members;
469  private:
472  void insert(const std::string& name, Geant4SensDetActionSequence* seq);
473 
474  public:
478  virtual ~Geant4SensDetSequences();
480  Geant4SensDetActionSequence* operator[](const std::string& name) const;
482  Geant4SensDetActionSequence* find(const std::string& name) const;
485  return m_sequences;
486  }
488  const Members& sequences() const {
489  return m_sequences;
490  }
492  void clear();
493  };
494 
496  template <typename TYPE> inline std::size_t Geant4Sensitive::defineCollection(const std::string& coll_name) {
497  return sequence().defineCollection<TYPE>(this, coll_name);
498  }
499 
501 
514  template <typename T> class Geant4SensitiveAction : public Geant4Sensitive {
515  public:
516  typedef T UserData;
517  protected:
519  std::string m_collectionName { };
521  std::string m_readoutName { };
522 
524  std::size_t m_collectionID { 0 };
527 
528  protected:
531 
532  public:
535  const std::string& name,
536  DetElement det,
537  Detector& description);
538 
541 
544 
546  virtual void defineCollections();
547 
550 
552 
562  template <typename HIT> std::size_t declareReadoutFilteredCollection();
563 
565  template <typename HIT>
566  std::size_t defineReadoutCollection(const std::string collection_name);
567 
569  virtual void initialize() final;
571  virtual void finalize() final;
572 
574  virtual void begin(G4HCofThisEvent* hce) final;
576  virtual void end(G4HCofThisEvent* hce) final;
578  virtual void clear(G4HCofThisEvent* hce) final;
579 
581  virtual bool process(const G4Step* step,G4TouchableHistory* history) final;
582 
584  virtual bool processFastSim(const Geant4FastSimSpot* spot, G4TouchableHistory* history) final;
585  };
586 
587  } // End namespace sim
588 } // End namespace dd4hep
589 #endif // DDG4_GEANT4SENSDETACTION_H
dd4hep::sim::Geant4SensitiveAction::begin
virtual void begin(G4HCofThisEvent *hce) final
G4VSensitiveDetector interface: Method invoked at the begining of each event.
dd4hep::sim::Geant4Sensitive::m_sequence
Geant4SensDetActionSequence * m_sequence
Reference to the containing action sequence.
Definition: Geant4SensDetAction.h:133
dd4hep::sim::Geant4SensDetActionSequence::m_sensitive
SensitiveDetector m_sensitive
Reference to the sensitive detector element.
Definition: Geant4SensDetAction.h:342
dd4hep::sim::Geant4Sensitive::fullPath
std::string fullPath() const
G4VSensitiveDetector internals: Access to the detector path name.
Definition: Geant4SensDetAction.h:188
dd4hep::sim::Geant4SensDetActionSequence::_create
static Geant4HitCollection * _create(const std::string &det, const std::string &coll, Geant4Sensitive *sd)
Create a new typed hit collection.
Definition: Geant4SensDetAction.h:349
dd4hep::sim::Geant4Sensitive::HitCreationFlags
HitCreationFlags
Definition: Geant4SensDetAction.h:123
dd4hep::sim::Geant4ActionSD::path
virtual std::string path() const =0
G4VSensitiveDetector internals: Access to the detector path name.
dd4hep::sim::Geant4SensitiveAction::defineCollections
virtual void defineCollections()
Define collections created by this sensitivie action object.
dd4hep::sim::Geant4SensDetActionSequence::callAtProcess
void callAtProcess(T *p, void(T::*f)(G4Step *, G4TouchableHistory *))
Register process-hit callback.
Definition: Geant4SensDetAction.h:403
dd4hep::sim::Geant4Sensitive::adopt
void adopt(Geant4Filter *filter)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4SensDetAction.cpp:126
dd4hep::sim::Geant4Sensitive::defineCollections
virtual void defineCollections()
Define collections created by this sensitivie action object.
Definition: Geant4SensDetAction.cpp:206
dd4hep::sim::Geant4SensDetActionSequence::callAtBegin
void callAtBegin(T *p, void(T::*f)(G4HCofThisEvent *))
Register begin-of-event callback.
Definition: Geant4SensDetAction.h:393
Geant4HitCollection.h
dd4hep::sim::Geant4Filter::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4Filter)
Define standard assignments and constructors.
dd4hep::sim::Geant4Sensitive::readoutGeometry
G4VReadOutGeometry * readoutGeometry() const
Access to the readout geometry of the sensitive detector.
Definition: Geant4SensDetAction.h:203
dd4hep::sim::Geant4SensDetSequences::insert
void insert(const std::string &name, Geant4SensDetActionSequence *seq)
Insert sequence member.
Definition: Geant4SensDetAction.cpp:521
dd4hep::sim::Geant4Sensitive::isActive
bool isActive() const
G4VSensitiveDetector internals: Is the detector active?
Definition: Geant4SensDetAction.h:193
dd4hep::sim::Geant4SensDetActionSequence::m_end
CallbackSequence m_end
Callback sequence for event finalization action.
Definition: Geant4SensDetAction.h:329
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:44
dd4hep::sim::Geant4SensDetActionSequence::processFastSim
virtual bool processFastSim(const Geant4FastSimSpot *spot, G4TouchableHistory *history)
GFLASH/FastSim interface: Method for generating hit(s) using the information of the fast simulation s...
Definition: Geant4SensDetAction.cpp:451
dd4hep::sim::Geant4ActionSD::isActive
virtual bool isActive() const =0
Is the detector active?
dd4hep::sim::Geant4SensitiveAction::m_collectionID
std::size_t m_collectionID
Collection identifier.
Definition: Geant4SensDetAction.h:524
Detector.h
dd4hep::sim::Geant4SensDetActionSequence::m_actors
Actors< Geant4Sensitive > m_actors
The list of sensitive detector objects.
Definition: Geant4SensDetAction.h:335
dd4hep::sim::Geant4ActionSD::~Geant4ActionSD
virtual ~Geant4ActionSD()
Default destructor.
Definition: Geant4SensDetAction.cpp:71
dd4hep::sim::Geant4ActionSD::fullPath
virtual std::string fullPath() const =0
G4VSensitiveDetector internals: Access to the detector path name.
dd4hep::sim::Geant4Sensitive::m_filters
Actors< Geant4Filter > m_filters
The list of sensitive detector filter objects.
Definition: Geant4SensDetAction.h:154
dd4hep::sim::Geant4Sensitive::detector
Geant4ActionSD & detector() const
Access to the sensitive detector object.
Definition: Geant4SensDetAction.cpp:171
dd4hep::sim::Geant4Sensitive::clear
virtual void clear(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked if the event was aborted.
Definition: Geant4SensDetAction.cpp:229
dd4hep::sim::Geant4SensDetActionSequence::clear
virtual void clear()
G4VSensitiveDetector interface: Method invoked if the event was aborted.
Definition: Geant4SensDetAction.cpp:490
dd4hep::sim::Geant4SensDetSequences::m_sequences
Members m_sequences
Definition: Geant4SensDetAction.h:470
dd4hep::sim::Geant4SensDetSequences::clear
void clear()
Clear the sequence list.
Definition: Geant4SensDetAction.cpp:532
dd4hep::sim::Geant4SensitiveAction::initialize
virtual void initialize() final
Initialization overload for specialization.
dd4hep::sim::Geant4HitCollection
Generic hit container class using Geant4HitWrapper objects.
Definition: Geant4HitCollection.h:201
dd4hep::sim::Geant4SensDetActionSequence::sensitiveType
virtual const std::string & sensitiveType() const
Access to the sensitive type of the detector.
Definition: Geant4SensDetAction.h:365
dd4hep::sim::Geant4Sensitive::process
virtual bool process(const G4Step *step, G4TouchableHistory *history)
G4VSensitiveDetector interface: Method for generating hit(s) using the information of G4Step object.
Definition: Geant4SensDetAction.cpp:218
dd4hep::sim::Geant4Sensitive::Geant4Sensitive
Geant4Sensitive(Geant4Context *context, const std::string &name, DetElement det, Detector &description)
Constructor. The sensitive detector element is identified by the detector name.
Definition: Geant4SensDetAction.cpp:98
dd4hep::sim::Geant4SensDetActionSequence::defineCollection
std::size_t defineCollection(Geant4Sensitive *owner, const std::string &coll_name)
Define a named collection containing hist of a specified type.
Definition: Geant4SensDetAction.h:379
dd4hep::CallbackSequence::add
void add(const Callback &cb, Location where)
Generically Add a new callback to the sequence depending on the location arguments.
Definition: Callback.h:367
G4VHitsCollection
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:47
dd4hep::sim::Geant4SensDetActionSequence::adopt
void adopt(Geant4Sensitive *sensitive)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4SensDetAction.cpp:355
dd4hep::sim::Geant4Filter::~Geant4Filter
virtual ~Geant4Filter()
Standard destructor.
Definition: Geant4SensDetAction.cpp:82
dd4hep::sim::Geant4SensitiveAction::m_collectionName
std::string m_collectionName
Property: collection name. If not set default is readout name!
Definition: Geant4SensDetAction.h:519
dd4hep::sim::Geant4SensDetActionSequence::defineCollections
std::size_t defineCollections(Geant4ActionSD *sens_det)
Called at construction time of the sensitive detector to declare all hit collections.
dd4hep::sim::Geant4FastSimSpot
Spot definition for fast simulation and GFlash.
Definition: Geant4FastSimSpot.h:71
dd4hep::sim::Geant4SensDetSequences::Members
std::map< std::string, Geant4SensDetActionSequence * > Members
Definition: Geant4SensDetAction.h:468
dd4hep::sim::Geant4Sensitive::volumeID
long long int volumeID(const G4Step *step)
Returns the volumeID of the sensitive volume corresponding to the step.
Definition: Geant4SensDetAction.cpp:245
dd4hep::sim::Geant4SensDetActionSequence::HitCollections
std::vector< HitCollection > HitCollections
Definition: Geant4SensDetAction.h:321
dd4hep::sim::Geant4SensitiveAction::end
virtual void end(G4HCofThisEvent *hce) final
G4VSensitiveDetector interface: Method invoked at the end of each event.
dd4hep::sim::Geant4Sensitive::collection
Geant4HitCollection * collection(std::size_t which)
Retrieve the hits collection associated with this detector by its serial number.
Definition: Geant4SensDetAction.cpp:196
dd4hep::sim::Geant4Sensitive::~Geant4Sensitive
virtual ~Geant4Sensitive()
Standard destructor.
Definition: Geant4SensDetAction.cpp:113
dd4hep::sim::Geant4SensitiveAction::process
virtual bool process(const G4Step *step, G4TouchableHistory *history) final
G4VSensitiveDetector interface: Method for generating hit(s) using the G4Step object.
dd4hep::sim::Geant4SensDetActionSequence::m_begin
CallbackSequence m_begin
Callback sequence for event initialization action.
Definition: Geant4SensDetAction.h:327
dd4hep::sim::Geant4Sensitive::DETAILED_MODE
@ DETAILED_MODE
Definition: Geant4SensDetAction.h:126
dd4hep::sim::Geant4ActionSD::readoutGeometry
virtual G4VReadOutGeometry * readoutGeometry() const =0
Access to the readout geometry of the sensitive detector.
dd4hep::sim::Geant4SensitiveAction::finalize
virtual void finalize() final
Finalization overload for specialization.
dd4hep::sim::Geant4SensitiveAction::clear
virtual void clear(G4HCofThisEvent *hce) final
G4VSensitiveDetector interface: Method invoked if the event was aborted.
dd4hep::sim::Geant4SensitiveAction::defineReadoutCollection
std::size_t defineReadoutCollection(const std::string collection_name)
Define readout specific hit collection. matching name must be present in readout structure.
dd4hep::CallbackSequence
Definition of an actor on sequences of callbacks.
Definition: Callback.h:339
dd4hep::sim::Geant4Sensitive::SIMPLE_MODE
@ SIMPLE_MODE
Definition: Geant4SensDetAction.h:124
dd4hep::sim::Geant4SensDetActionSequence::Geant4SensDetActionSequence
Geant4SensDetActionSequence(Geant4Context *context, const std::string &name)
Standard constructor.
Definition: Geant4SensDetAction.cpp:321
dd4hep::sim::Geant4Sensitive::adoptFilter_front
void adoptFilter_front(Geant4Action *filter)
Add an actor responding to all callbacks to the sequence front. Sequence takes ownership.
Definition: Geant4SensDetAction.cpp:136
dd4hep::sim::Geant4SensDetActionSequence::m_process
CallbackSequence m_process
Callback sequence for step processing.
Definition: Geant4SensDetAction.h:331
dd4hep::sim::Geant4SensDetSequences::~Geant4SensDetSequences
virtual ~Geant4SensDetSequences()
Default destructor.
Definition: Geant4SensDetAction.cpp:496
dd4hep::sim::Geant4SensDetActionSequence::m_filters
Actors< Geant4Filter > m_filters
The list of sensitive detector filter objects.
Definition: Geant4SensDetAction.h:337
dd4hep::sim::Geant4SensDetSequences::find
Geant4SensDetActionSequence * find(const std::string &name) const
Access sequence member by name.
Definition: Geant4SensDetAction.cpp:512
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::sim::Geant4Sensitive::mark
void mark(const G4Track *track) const
Mark the track to be kept for MC truth propagation during hit processing.
Definition: Geant4SensDetAction.cpp:233
dd4hep::sim::Geant4ActionSD::GetCollectionID
virtual G4int GetCollectionID(G4int i)=0
This is a utility method which returns the hits collection ID.
dd4hep::sim::Geant4SensitiveAction::m_userData
UserData m_userData
User data block.
Definition: Geant4SensDetAction.h:526
dd4hep::sim::Geant4Sensitive::defineCollection
std::size_t defineCollection(const std::string &coll_name)
Initialize the usage of a single hit collection. Returns the collection ID.
Definition: Geant4SensDetAction.h:496
dd4hep::sim::Geant4Sensitive::m_readout
Readout m_readout
Reference to the readout structure.
Definition: Geant4SensDetAction.h:150
dd4hep::sim::Geant4Sensitive::setDetector
void setDetector(Geant4ActionSD *sens_det)
Access to the sensitive detector object.
Definition: Geant4SensDetAction.cpp:166
dd4hep::sim::Geant4Sensitive::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4Sensitive)
Define standard assignments and constructors.
dd4hep::sim::Geant4SensDetActionSequence::m_hce
G4HCofThisEvent * m_hce
Geant4 hit collection context.
Definition: Geant4SensDetAction.h:325
dd4hep::sim::Geant4SensDetActionSequence::callAtEnd
void callAtEnd(T *p, void(T::*f)(G4HCofThisEvent *))
Register end-of-event callback.
Definition: Geant4SensDetAction.h:398
dd4hep::sim::Geant4Sensitive::m_detDesc
Detector & m_detDesc
Reference to the detector description object.
Definition: Geant4SensDetAction.h:143
dd4hep::sim::Geant4Sensitive::accept
bool accept(const G4Step *step) const
Callback before hit processing starts. Invoke all filters.
Definition: Geant4SensDetAction.cpp:152
dd4hep::sim::Geant4SensDetActionSequence::end
virtual void end(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked at the end of each event.
Definition: Geant4SensDetAction.cpp:478
dd4hep::sim::Geant4Sensitive::sensitiveDetector
SensitiveDetector sensitiveDetector() const
Access the dd4hep sensitive detector.
Definition: Geant4SensDetAction.h:198
dd4hep::sim::Geant4Sensitive::MEDIUM_MODE
@ MEDIUM_MODE
Definition: Geant4SensDetAction.h:125
dd4hep::sim::Geant4SensitiveAction::Geant4SensitiveAction
Geant4SensitiveAction(Geant4Context *context, const std::string &name, DetElement det, Detector &description)
Standard , initializing constructor.
dd4hep::sim::Geant4SensDetActionSequence::m_detector
Geant4ActionSD * m_detector
Reference to G4 sensitive detector.
Definition: Geant4SensDetAction.h:344
dd4hep::sim::Geant4SensDetActionSequence::collection
Geant4HitCollection * collection(std::size_t which) const
Retrieve the hits collection associated with this detector by its serial number.
Definition: Geant4SensDetAction.cpp:404
dd4hep::sim::Geant4ActionSD::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4ActionSD)
Define standard assignments and constructors.
dd4hep::sim::Geant4Sensitive::m_hitCreationMode
int m_hitCreationMode
Property: Hit creation mode. Maybe one of the enum HitCreationFlags.
Definition: Geant4SensDetAction.h:137
dd4hep::sim::Geant4SensDetSequences
Geant4SensDetSequences: class to access groups of sensitive actions.
Definition: Geant4SensDetAction.h:464
dd4hep::sim::Geant4Sensitive::begin
virtual void begin(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked at the begining of each event.
Definition: Geant4SensDetAction.cpp:210
dd4hep::sim::Geant4SensDetActionSequence::accept
bool accept(const G4Step *step) const
Callback before hit processing starts. Invoke all filters.
Definition: Geant4SensDetAction.cpp:426
dd4hep::sim::Geant4ActionSD::sensitiveType
virtual const std::string & sensitiveType() const =0
Access to the sensitive type of the detector.
dd4hep::sim::Geant4SensDetActionSequence::callAtClear
void callAtClear(T *p, void(T::*f)(G4HCofThisEvent *))
Register clear callback.
Definition: Geant4SensDetAction.h:408
dd4hep::sim::Geant4SensitiveAction
Template class to ease the construction of sensitive detectors using particle template specialization...
Definition: Geant4SensDetAction.h:514
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::Geant4SensDetActionSequence::create_t
Geant4HitCollection *(* create_t)(const std::string &, const std::string &, Geant4Sensitive *)
Definition: Geant4SensDetAction.h:319
dd4hep::sim::Geant4SensDetActionSequence::~Geant4SensDetActionSequence
virtual ~Geant4SensDetActionSequence()
Default destructor.
Definition: Geant4SensDetAction.cpp:333
dd4hep::sim::Geant4Sensitive::detectorName
std::string detectorName() const
G4VSensitiveDetector internals: Access to the detector name.
Definition: Geant4SensDetAction.h:178
dd4hep::sim::Geant4SensitiveAction::readout
Readout readout()
Access the readout object. Note: if m_readoutName is set, the m_readout != m_sensitive....
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4SensDetActionSequence::updateContext
virtual void updateContext(Geant4Context *ctxt) override
Set or update client context.
Definition: Geant4SensDetAction.cpp:342
dd4hep::sim::Geant4SensitiveAction::UserData
T UserData
Definition: Geant4SensDetAction.h:516
dd4hep::sim::Geant4SensDetActionSequence::m_sensitiveType
std::string m_sensitiveType
The true sensitive type of the detector.
Definition: Geant4SensDetAction.h:346
dd4hep::sim::Geant4Filter::Geant4Filter
Geant4Filter(Geant4Context *context, const std::string &name)
Standard constructor.
Definition: Geant4SensDetAction.cpp:76
dd4hep::sim::Geant4SensDetActionSequence::m_collections
HitCollections m_collections
Hit collection creators.
Definition: Geant4SensDetAction.h:340
dd4hep::sim::Geant4ActionSD
Interface class to access properties of the underlying Geant4 sensitive detector structure.
Definition: Geant4SensDetAction.h:61
dd4hep::sim::Geant4SensDetActionSequence::hitCollectionName
const std::string & hitCollectionName(std::size_t which) const
Access HitCollection container names.
Definition: Geant4SensDetAction.cpp:394
dd4hep::sim::Geant4Sensitive::m_sensitive
SensitiveDetector m_sensitive
Reference to the sensitive detector element.
Definition: Geant4SensDetAction.h:148
dd4hep::sim::Geant4SensitiveAction::declareReadoutFilteredCollection
std::size_t declareReadoutFilteredCollection()
Define readout specific hit collection with volume ID filtering.
dd4hep::sim::Geant4SensDetActionSequence::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4SensDetActionSequence)
Define standard assignments and constructors.
dd4hep::sim::Geant4SensitiveAction::declareOptionalProperties
void declareOptionalProperties()
Declare optional properties from embedded structure.
dd4hep::sim::Geant4SensDetActionSequence::collectionByID
Geant4HitCollection * collectionByID(std::size_t id) const
Retrieve the hits collection associated with this detector by its collection identifier.
Definition: Geant4SensDetAction.cpp:417
dd4hep::sim::Geant4SensDetActionSequence::HitCollection
std::pair< std::string, std::pair< Geant4Sensitive *, create_t > > HitCollection
Definition: Geant4SensDetAction.h:320
dd4hep::sim::Geant4SensDetActionSequence
The sequencer to host Geant4 sensitive actions called if particles interact with sensitive elements.
Definition: Geant4SensDetAction.h:317
dd4hep::sim::Geant4SensDetSequences::sequences
Members & sequences()
Access to the members.
Definition: Geant4SensDetAction.h:484
dd4hep::sim::Geant4ActionContainer
Class, which allows all Geant4Action to be stored.
Definition: Geant4ActionContainer.h:60
dd4hep::sim::Geant4Sensitive::cellID
long long int cellID(const G4Step *step)
Returns the cellID of the sensitive volume corresponding to the step.
Definition: Geant4SensDetAction.cpp:260
dd4hep::sim::Geant4Sensitive::m_detector
DetElement m_detector
Reference to the detector element describing this sensitive element.
Definition: Geant4SensDetAction.h:146
dd4hep::sim::Geant4SensDetActionSequence::adoptFilter
void adoptFilter(Geant4Action *filter)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4SensDetAction.cpp:349
dd4hep::sim::Geant4Sensitive::adoptFilter
void adoptFilter(Geant4Action *filter)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4SensDetAction.cpp:120
dd4hep::sim::Geant4Sensitive::hitCreationMode
int hitCreationMode() const
Property access to the hit creation mode.
Definition: Geant4SensDetAction.h:173
dd4hep::sim::Geant4SensDetSequences::sequences
const Members & sequences() const
Access to the members CONST.
Definition: Geant4SensDetAction.h:488
dd4hep::sim::Geant4SensitiveAction::~Geant4SensitiveAction
virtual ~Geant4SensitiveAction()
Default destructor.
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4Sensitive::processFastSim
virtual bool processFastSim(const Geant4FastSimSpot *spot, G4TouchableHistory *history)
GFLASH/FastSim interface: Method for generating hit(s) using the information of the fast simulation s...
Definition: Geant4SensDetAction.cpp:223
det
DetElement::Object * det
Definition: AlignmentsCalculator.cpp:66
dd4hep::sim::Geant4Sensitive::hitCollectionName
const std::string & hitCollectionName(std::size_t which) const
Access HitCollection container names.
Definition: Geant4SensDetAction.cpp:191
dd4hep::sim::Geant4SensDetSequences::Geant4SensDetSequences
Geant4SensDetSequences()=default
Default constructor.
dd4hep::sim::Geant4SensDetActionSequence::defineCollection
std::size_t defineCollection(Geant4Sensitive *owner, const std::string &name, create_t func)
Initialize the usage of a hit collection. Returns the collection identifier.
Definition: Geant4SensDetAction.cpp:375
dd4hep::sim::Geant4ActionSD::sensitiveDetector
virtual SensitiveDetector sensitiveDetector() const =0
Access to the Detector sensitive detector handle.
dd4hep::sim::Geant4Filter
Base class to construct filters for Geant4 sensitive detectors.
Definition: Geant4SensDetAction.h:94
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::sim::Geant4Action::Actors
Actor class to manipulate action groups.
Definition: Geant4Action.h:168
dd4hep::Readout
Handle to the implementation of the readout structure of a subdetector.
Definition: Readout.h:38
dd4hep::Segmentation
Handle class supporting generic Segmentations of sensitive detectors.
Definition: Segmentations.h:41
dd4hep::sim::Geant4Sensitive
The base class for Geant4 sensitive detector actions implemented by users.
Definition: Geant4SensDetAction.h:121
dd4hep::sim::Geant4Sensitive::adopt_front
void adopt_front(Geant4Filter *filter)
Add an actor responding to all callbacks to the sequence front. Sequence takes ownership.
Definition: Geant4SensDetAction.cpp:142
dd4hep::sim::Geant4SensDetActionSequence::begin
virtual void begin(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked at the begining of each event.
Definition: Geant4SensDetAction.cpp:465
dd4hep::sim::Geant4Sensitive::m_segmentation
Segmentation m_segmentation
Reference to segmentation.
Definition: Geant4SensDetAction.h:152
dd4hep::sim::Geant4SensDetSequences::operator[]
Geant4SensDetActionSequence * operator[](const std::string &name) const
Access sequence member by name.
Definition: Geant4SensDetAction.cpp:502
dd4hep::sim::Geant4ActionSD::Geant4ActionSD
Geant4ActionSD(const std::string &name)
Standard action constructor.
Definition: Geant4SensDetAction.cpp:65
dd4hep::sim::Geant4SensitiveAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4SensitiveAction)
Define standard assignments and constructors.
dd4hep::sim::Geant4Sensitive::m_sensitiveDetector
Geant4ActionSD * m_sensitiveDetector
Reference to G4 sensitive detector.
Definition: Geant4SensDetAction.h:131
dd4hep::sim::Geant4SensitiveAction::processFastSim
virtual bool processFastSim(const Geant4FastSimSpot *spot, G4TouchableHistory *history) final
GFLASH/FastSim interface: Method for generating hit(s) using the information of the fast simulation s...
dd4hep::sim::Geant4Sensitive::collectionByID
Geant4HitCollection * collectionByID(std::size_t id)
Retrieve the hits collection associated with this detector by its collection identifier.
Definition: Geant4SensDetAction.cpp:201
Geant4Action.h
dd4hep::sim::Geant4Sensitive::end
virtual void end(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked at the end of each event.
Definition: Geant4SensDetAction.cpp:214
dd4hep::sim::Geant4Sensitive::sequence
Geant4SensDetActionSequence & sequence() const
Access to the hosting sequence.
Definition: Geant4SensDetAction.cpp:181
dd4hep::sim::Geant4Sensitive::path
std::string path() const
G4VSensitiveDetector internals: Access to the detector path name.
Definition: Geant4SensDetAction.h:183
dd4hep::sim::Geant4SensDetActionSequence::m_clear
CallbackSequence m_clear
Callback sequence to invoke the event deletion.
Definition: Geant4SensDetAction.h:333
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4SensDetActionSequence::process
virtual bool process(const G4Step *step, G4TouchableHistory *history)
G4VSensitiveDetector interface: Method for generating hit(s) using the information of G4Step object.
Definition: Geant4SensDetAction.cpp:440
dd4hep::sim::Geant4ActionSD::defineCollection
virtual std::size_t defineCollection(const std::string &name)=0
Initialize the usage of a hit collection. Returns the collection identifier.
dd4hep::sim::Geant4Action::context
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:270
dd4hep::sim::Geant4Filter::operator()
virtual bool operator()(const G4Step *step) const
Filter action. Return true if hits should be processed. Default returns true.
Definition: Geant4SensDetAction.cpp:87
dd4hep::sim::Geant4Sensitive::detectorDescription
Detector & detectorDescription() const
Access the detector desciption object.
Definition: Geant4SensDetAction.cpp:186
dd4hep::sim::Geant4SensitiveAction::m_readoutName
std::string m_readoutName
Property: segmentation name for parallel readouts. If not set readout segmentation is used!
Definition: Geant4SensDetAction.h:521