DD4hep  1.34.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:
137  int m_hitCreationMode { 0 };
139  bool m_useVolumeManager { true };
140 
141 #if defined(G__ROOT) || defined(__CLING__) || defined(__ROOTCLING__)
142  Detector* m_detDesc { nullptr };
144 #else
147 #endif
158 
161 
162  public:
164  Geant4Sensitive(Geant4Context* context, const std::string& name, DetElement det, Detector& description);
165 
167  virtual ~Geant4Sensitive();
168 
170  int id() const;
171 
173  Geant4ActionSD& detector() const;
174 
176  void setDetector(Geant4ActionSD* sens_det);
177 
179  bool useVolumeManager() const {
180  return m_useVolumeManager;
181  }
182 
184  int hitCreationMode() const {
185  return m_hitCreationMode;
186  }
187 
189  std::string detectorName() const {
190  return detector().name();
191  }
192 
194  std::string path() const {
195  return detector().path();
196  }
197 
199  std::string fullPath() const {
200  return detector().fullPath();
201  }
202 
204  bool isActive() const {
205  return detector().isActive();
206  }
207 
210  return m_sensitive;
211  }
212 
214  G4VReadOutGeometry* readoutGeometry() const {
215  return detector().readoutGeometry();
216  }
217 
219  Detector& detectorDescription() const;
220 
222  void mark(const G4Track* track) const;
223 
225  void mark(const G4Step* step) const;
226 
229 
231  void adopt(Geant4Filter* filter);
232 
234  void adopt_front(Geant4Filter* filter);
235 
237  void adoptFilter(Geant4Action* filter);
238 
240  void adoptFilter_front(Geant4Action* filter);
241 
243 
245  bool accept(const G4Step* step) const;
246 
248 
250  bool accept(const Geant4FastSimSpot* step) const;
251 
253  template <typename TYPE> std::size_t defineCollection(const std::string& coll_name);
254 
256  const std::string& hitCollectionName(std::size_t which) const;
257 
259  Geant4HitCollection* collection(std::size_t which);
260 
262  Geant4HitCollection* collectionByID(std::size_t id);
263 
265  virtual void defineCollections();
266 
268 
271  virtual void begin(G4HCofThisEvent* hce);
272 
274  virtual void end(G4HCofThisEvent* hce);
275 
277 
282  virtual void clear(G4HCofThisEvent* hce);
283 
285 
288  long long int volumeID(const G4Step* step);
289 
291 
294  long long int volumeID(const G4VTouchable* touchable);
295 
297 
301  long long int cellID(const G4Step* step);
302 
304 
308  long long int cellID(const G4VTouchable* touchable, const G4ThreeVector& global);
309 
311  virtual bool process(const G4Step* step, G4TouchableHistory* history);
312 
314 
317  virtual bool processFastSim(const Geant4FastSimSpot* spot, G4TouchableHistory* history);
318  };
319 
321 
329  public:
330  typedef Geant4HitCollection* (*create_t)(const std::string&, const std::string&, Geant4Sensitive*);
331  typedef std::pair<std::string, std::pair<Geant4Sensitive*,create_t> > HitCollection;
332  typedef std::vector<HitCollection> HitCollections;
333 
334  protected:
336  G4HCofThisEvent* m_hce { nullptr };
346  Actors<Geant4Sensitive> m_actors;
348  Actors<Geant4Filter> m_filters;
349 
357  std::string m_sensitiveType;
359  template <typename TYPE> static
360  Geant4HitCollection* _create(const std::string& det, const std::string& coll, Geant4Sensitive* sd) {
361  return new Geant4HitCollection(det, coll, sd, (TYPE*) 0);
362  }
363 
364  protected:
367 
368  public:
371 
374 
376  virtual const std::string& sensitiveType() const {
377  return m_sensitiveType;
378  }
379 
381  virtual void updateContext(Geant4Context* ctxt) override;
382 
384  std::size_t defineCollections(Geant4ActionSD* sens_det);
385 
387  std::size_t defineCollection(Geant4Sensitive* owner, const std::string& name, create_t func);
388 
390  template <typename TYPE> std::size_t defineCollection(Geant4Sensitive* owner, const std::string& coll_name) {
391  return defineCollection(owner, coll_name, Geant4SensDetActionSequence::_create<TYPE>);
392  }
393 
395  const std::string& hitCollectionName(std::size_t which) const;
396 
398  Geant4HitCollection* collection(std::size_t which) const;
399 
401  Geant4HitCollection* collectionByID(std::size_t id) const;
402 
404  template <typename T> void callAtBegin(T* p, void (T::*f)(G4HCofThisEvent*)) {
405  m_begin.add(p, f);
406  }
407 
409  template <typename T> void callAtEnd(T* p, void (T::*f)(G4HCofThisEvent*)) {
410  m_end.add(p, f);
411  }
412 
414  template <typename T> void callAtProcess(T* p, void (T::*f)(G4Step*, G4TouchableHistory*)) {
415  m_process.add(p, f);
416  }
417 
419  template <typename T> void callAtClear(T* p, void (T::*f)(G4HCofThisEvent*)) {
420  m_clear.add(p, f);
421  }
422 
424  void adopt(Geant4Sensitive* sensitive);
425 
427  void adopt(Geant4Filter* filter);
428 
430  void adoptFilter(Geant4Action* filter);
431 
433  bool accept(const G4Step* step) const;
434 
436  bool accept(const Geant4FastSimSpot* step) const;
437 
439 
442  virtual void begin(G4HCofThisEvent* hce);
443 
445 
446  virtual void end(G4HCofThisEvent* hce);
448 
453  virtual void clear();
454 
456  virtual bool process(const G4Step* step, G4TouchableHistory* history);
457 
459  virtual bool processFastSim(const Geant4FastSimSpot* spot, G4TouchableHistory* history);
460  };
461 
463 
476  public:
477  friend class Geant4ActionContainer;
479  typedef std::map<std::string, Geant4SensDetActionSequence*> Members;
480  private:
483  void insert(const std::string& name, Geant4SensDetActionSequence* seq);
484 
485  public:
489  virtual ~Geant4SensDetSequences();
491  Geant4SensDetActionSequence* operator[](const std::string& name) const;
493  Geant4SensDetActionSequence* find(const std::string& name) const;
496  return m_sequences;
497  }
499  const Members& sequences() const {
500  return m_sequences;
501  }
503  void clear();
504  };
505 
507  template <typename TYPE> inline std::size_t Geant4Sensitive::defineCollection(const std::string& coll_name) {
508  return sequence().defineCollection<TYPE>(this, coll_name);
509  }
510 
512 
525  template <typename T> class Geant4SensitiveAction : public Geant4Sensitive {
526  public:
527  typedef T UserData;
528  protected:
530  std::string m_collectionName { };
532  std::string m_readoutName { };
533 
535  std::size_t m_collectionID { 0 };
538 
539  protected:
542 
543  public:
546  const std::string& name,
547  DetElement det,
548  Detector& description);
549 
552 
555 
557  virtual void defineCollections();
558 
561 
563 
573  template <typename HIT> std::size_t declareReadoutFilteredCollection();
574 
576  template <typename HIT>
577  std::size_t defineReadoutCollection(const std::string collection_name);
578 
580  virtual void initialize() final;
582  virtual void finalize() final;
583 
585  virtual void begin(G4HCofThisEvent* hce) final;
587  virtual void end(G4HCofThisEvent* hce) final;
589  virtual void clear(G4HCofThisEvent* hce) final;
590 
592  virtual bool process(const G4Step* step,G4TouchableHistory* history) final;
593 
595  virtual bool processFastSim(const Geant4FastSimSpot* spot, G4TouchableHistory* history) final;
596  };
597 
598  } // End namespace sim
599 } // End namespace dd4hep
600 #endif // DDG4_GEANT4SENSDETACTION_H
dd4hep::sim::Geant4SensitiveAction::begin
virtual void begin(G4HCofThisEvent *hce) final
G4VSensitiveDetector interface: Method invoked at the beginning 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:353
dd4hep::sim::Geant4Sensitive::fullPath
std::string fullPath() const
G4VSensitiveDetector internals: Access to the detector path name.
Definition: Geant4SensDetAction.h:199
dd4hep::sim::Geant4Sensitive::m_useVolumeManager
bool m_useVolumeManager
Property: Use the volume manager to access CellID and VolumeID.
Definition: Geant4SensDetAction.h:139
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:360
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:414
dd4hep::sim::Geant4Sensitive::adopt
void adopt(Geant4Filter *filter)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4SensDetAction.cpp:135
dd4hep::sim::Geant4Sensitive::defineCollections
virtual void defineCollections()
Define collections created by this sensitivie action object.
Definition: Geant4SensDetAction.cpp:215
dd4hep::sim::Geant4SensDetActionSequence::callAtBegin
void callAtBegin(T *p, void(T::*f)(G4HCofThisEvent *))
Register begin-of-event callback.
Definition: Geant4SensDetAction.h:404
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:214
dd4hep::sim::Geant4SensDetSequences::insert
void insert(const std::string &name, Geant4SensDetActionSequence *seq)
Insert sequence member.
Definition: Geant4SensDetAction.cpp:548
dd4hep::sim::Geant4Sensitive::isActive
bool isActive() const
G4VSensitiveDetector internals: Is the detector active?
Definition: Geant4SensDetAction.h:204
dd4hep::sim::Geant4SensDetActionSequence::m_end
CallbackSequence m_end
Callback sequence for event finalization action.
Definition: Geant4SensDetAction.h:340
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:43
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:478
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:535
Detector.h
dd4hep::sim::Geant4SensDetActionSequence::m_actors
Actors< Geant4Sensitive > m_actors
The list of sensitive detector objects.
Definition: Geant4SensDetAction.h:346
dd4hep::sim::Geant4ActionSD::~Geant4ActionSD
virtual ~Geant4ActionSD()
Default destructor.
Definition: Geant4SensDetAction.cpp:74
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:157
dd4hep::sim::Geant4Sensitive::detector
Geant4ActionSD & detector() const
Access to the sensitive detector object.
Definition: Geant4SensDetAction.cpp:180
dd4hep::sim::Geant4Sensitive::clear
virtual void clear(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked if the event was aborted.
Definition: Geant4SensDetAction.cpp:238
dd4hep::sim::Geant4SensDetActionSequence::clear
virtual void clear()
G4VSensitiveDetector interface: Method invoked if the event was aborted.
Definition: Geant4SensDetAction.cpp:517
dd4hep::sim::Geant4SensDetSequences::m_sequences
Members m_sequences
Definition: Geant4SensDetAction.h:481
dd4hep::sim::Geant4SensDetSequences::clear
void clear()
Clear the sequence list.
Definition: Geant4SensDetAction.cpp:559
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:376
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:227
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:101
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:390
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:366
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:382
dd4hep::sim::Geant4Filter::~Geant4Filter
virtual ~Geant4Filter()
Standard destructor.
Definition: Geant4SensDetAction.cpp:85
dd4hep::sim::Geant4SensitiveAction::m_collectionName
std::string m_collectionName
Property: collection name. If not set default is readout name!
Definition: Geant4SensDetAction.h:530
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:479
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:254
dd4hep::sim::Geant4SensDetActionSequence::HitCollections
std::vector< HitCollection > HitCollections
Definition: Geant4SensDetAction.h:332
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:205
dd4hep::sim::Geant4Sensitive::~Geant4Sensitive
virtual ~Geant4Sensitive()
Standard destructor.
Definition: Geant4SensDetAction.cpp:117
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:338
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:338
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:348
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:145
dd4hep::sim::Geant4SensDetActionSequence::m_process
CallbackSequence m_process
Callback sequence for step processing.
Definition: Geant4SensDetAction.h:342
dd4hep::sim::Geant4SensDetSequences::~Geant4SensDetSequences
virtual ~Geant4SensDetSequences()
Default destructor.
Definition: Geant4SensDetAction.cpp:523
dd4hep::sim::Geant4SensDetActionSequence::m_filters
Actors< Geant4Filter > m_filters
The list of sensitive detector filter objects.
Definition: Geant4SensDetAction.h:348
dd4hep::sim::Geant4SensDetSequences::find
Geant4SensDetActionSequence * find(const std::string &name) const
Access sequence member by name.
Definition: Geant4SensDetAction.cpp:539
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:187
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:242
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:537
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:507
dd4hep::sim::Geant4Sensitive::m_readout
Readout m_readout
Reference to the readout structure.
Definition: Geant4SensDetAction.h:153
dd4hep::sim::Geant4Sensitive::setDetector
void setDetector(Geant4ActionSD *sens_det)
Access to the sensitive detector object.
Definition: Geant4SensDetAction.cpp:175
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:336
dd4hep::sim::Geant4SensDetActionSequence::callAtEnd
void callAtEnd(T *p, void(T::*f)(G4HCofThisEvent *))
Register end-of-event callback.
Definition: Geant4SensDetAction.h:409
dd4hep::sim::Geant4Sensitive::m_detDesc
Detector & m_detDesc
Reference to the detector description object.
Definition: Geant4SensDetAction.h:146
dd4hep::sim::Geant4Sensitive::accept
bool accept(const G4Step *step) const
Callback before hit processing starts. Invoke all filters.
Definition: Geant4SensDetAction.cpp:161
dd4hep::sim::Geant4SensDetActionSequence::end
virtual void end(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked at the end of each event.
Definition: Geant4SensDetAction.cpp:505
dd4hep::sim::Geant4Sensitive::sensitiveDetector
SensitiveDetector sensitiveDetector() const
Access the dd4hep sensitive detector.
Definition: Geant4SensDetAction.h:209
dd4hep::sim::Geant4Sensitive::MEDIUM_MODE
@ MEDIUM_MODE
Definition: Geant4SensDetAction.h:125
dd4hep::sim::Geant4Sensitive::id
int id() const
Get the detector identifier (DetElement::id())
Definition: Geant4SensDetAction.cpp:124
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:355
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:431
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:475
dd4hep::sim::Geant4Sensitive::begin
virtual void begin(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked at the beginning of each event.
Definition: Geant4SensDetAction.cpp:219
dd4hep::sim::Geant4SensDetActionSequence::accept
bool accept(const G4Step *step) const
Callback before hit processing starts. Invoke all filters.
Definition: Geant4SensDetAction.cpp:453
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:419
dd4hep::sim::Geant4SensitiveAction
Template class to ease the construction of sensitive detectors using particle template specialization...
Definition: Geant4SensDetAction.h:525
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:330
dd4hep::sim::Geant4SensDetActionSequence::~Geant4SensDetActionSequence
virtual ~Geant4SensDetActionSequence()
Default destructor.
Definition: Geant4SensDetAction.cpp:360
dd4hep::sim::Geant4Sensitive::detectorName
std::string detectorName() const
G4VSensitiveDetector internals: Access to the detector name.
Definition: Geant4SensDetAction.h:189
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:369
dd4hep::sim::Geant4SensitiveAction::UserData
T UserData
Definition: Geant4SensDetAction.h:527
dd4hep::sim::Geant4SensDetActionSequence::m_sensitiveType
std::string m_sensitiveType
The true sensitive type of the detector.
Definition: Geant4SensDetAction.h:357
dd4hep::sim::Geant4Filter::Geant4Filter
Geant4Filter(Geant4Context *context, const std::string &name)
Standard constructor.
Definition: Geant4SensDetAction.cpp:79
dd4hep::sim::Geant4SensDetActionSequence::m_collections
HitCollections m_collections
Hit collection creators.
Definition: Geant4SensDetAction.h:351
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:421
dd4hep::sim::Geant4Sensitive::m_sensitive
SensitiveDetector m_sensitive
Reference to the sensitive detector element.
Definition: Geant4SensDetAction.h:151
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:444
dd4hep::sim::Geant4SensDetActionSequence::HitCollection
std::pair< std::string, std::pair< Geant4Sensitive *, create_t > > HitCollection
Definition: Geant4SensDetAction.h:331
dd4hep::sim::Geant4Sensitive::useVolumeManager
bool useVolumeManager() const
Access volume manager usage flag. This is a subdetector specific flag.
Definition: Geant4SensDetAction.h:179
dd4hep::sim::Geant4SensDetActionSequence
The sequencer to host Geant4 sensitive actions called if particles interact with sensitive elements.
Definition: Geant4SensDetAction.h:328
dd4hep::sim::Geant4SensDetSequences::sequences
Members & sequences()
Access to the members.
Definition: Geant4SensDetAction.h:495
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:275
dd4hep::sim::Geant4Sensitive::m_detector
DetElement m_detector
Reference to the detector element describing this sensitive element.
Definition: Geant4SensDetAction.h:149
dd4hep::sim::Geant4SensDetActionSequence::adoptFilter
void adoptFilter(Geant4Action *filter)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4SensDetAction.cpp:376
dd4hep::sim::Geant4Sensitive::adoptFilter
void adoptFilter(Geant4Action *filter)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4SensDetAction.cpp:129
dd4hep::sim::Geant4Sensitive::hitCreationMode
int hitCreationMode() const
Property access to the hit creation mode.
Definition: Geant4SensDetAction.h:184
dd4hep::sim::Geant4SensDetSequences::sequences
const Members & sequences() const
Access to the members CONST.
Definition: Geant4SensDetAction.h:499
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:232
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:200
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:402
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:151
dd4hep::sim::Geant4SensDetActionSequence::begin
virtual void begin(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked at the beginning of each event.
Definition: Geant4SensDetAction.cpp:492
dd4hep::sim::Geant4Sensitive::m_segmentation
Segmentation m_segmentation
Reference to segmentation.
Definition: Geant4SensDetAction.h:155
dd4hep::sim::Geant4SensDetSequences::operator[]
Geant4SensDetActionSequence * operator[](const std::string &name) const
Access sequence member by name.
Definition: Geant4SensDetAction.cpp:529
dd4hep::sim::Geant4ActionSD::Geant4ActionSD
Geant4ActionSD(const std::string &name)
Standard action constructor.
Definition: Geant4SensDetAction.cpp:68
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:210
Geant4Action.h
dd4hep::sim::Geant4Sensitive::end
virtual void end(G4HCofThisEvent *hce)
G4VSensitiveDetector interface: Method invoked at the end of each event.
Definition: Geant4SensDetAction.cpp:223
dd4hep::sim::Geant4Sensitive::sequence
Geant4SensDetActionSequence & sequence() const
Access to the hosting sequence.
Definition: Geant4SensDetAction.cpp:190
dd4hep::sim::Geant4Sensitive::path
std::string path() const
G4VSensitiveDetector internals: Access to the detector path name.
Definition: Geant4SensDetAction.h:194
dd4hep::sim::Geant4SensDetActionSequence::m_clear
CallbackSequence m_clear
Callback sequence to invoke the event deletion.
Definition: Geant4SensDetAction.h:344
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:467
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:90
dd4hep::sim::Geant4Sensitive::detectorDescription
Detector & detectorDescription() const
Access the detector description object.
Definition: Geant4SensDetAction.cpp:195
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:532