DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4TrackerWeightedSD.cpp
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 
14 // Framework include files
15 #include <DD4hep/DD4hepUnits.h>
16 #include <DDG4/Geant4SensDetAction.inl>
19 #include <DDG4/Geant4EventAction.h>
20 #include <G4Event.hh>
21 #include <G4VSolid.hh>
22 
23 #include <map>
24 #include <limits>
25 #include <sstream>
26 
28 namespace dd4hep {
29 
31  namespace sim {
32 
33  using namespace detail;
34 
55 
64  struct TrackerWeighted {
65 
67  enum {
68  POSITION_WEIGHTED = 1, // Use energy weights to define the position of the energy deposit
69  POSITION_MIDDLE = 2, // Set the hit position between the step pre and post point
70  POSITION_PREPOINT = 3, // Set the hit position to the position of the step pre point
71  POSITION_POSTPOINT = 4 // Set the hit position to the position of the step post point
72  };
73 
76  Geant4Sensitive* sensitive = 0;
77  G4VSensitiveDetector* thisSD = 0;
78  G4VPhysicalVolume* thisPV = 0;
79  double distance_to_inside = 0.0;
80  double distance_to_outside = 0.0;
81  double mean_time = 0.0;
82  double step_length = 0.0;
83  double e_cut = 0.0;
84  int current = -1;
85  int parent = 0;
86  int combined = 0;
87  int hit_position_type = POSITION_MIDDLE;
88  int hit_flag = 0;
89  int g4ID = 0;
90  EInside last_inside = kOutside;
91  long long int cell = 0;
92  bool single_deposit_mode = false;
93 
95  TrackerWeighted() = default;
96 
99  mean_pos.SetXYZ(0,0,0);
100  distance_to_inside = 0;
101  distance_to_outside = 0;
102  mean_time = 0;
103  step_length = 0;
104  thisPV = nullptr;
105  post.clear();
106  pre.clear();
107  current = -1;
108  parent = -1;
109  combined = 0;
110  cell = 0;
111  hit_flag = 0;
112  g4ID = 0;
113  last_inside = kOutside;
114  return *this;
115  }
116 
118  TrackerWeighted& start(const G4Step* step, const G4StepPoint* point) {
119  if( DEBUG == printLevel() ) {
120  std::cout<<" DEBUG: Geant4TrackerWeightedSD::start(const G4Step* step, const G4StepPoint* point) ...."<<std::endl;
121  Geant4StepHandler h(step);
122  dumpStep( h, step);
123  }
124 
125  clear();
126  pre.storePoint(step,point);
127  pre.truth.deposit = 0.0;
128  post.truth.deposit = 0.0;
129  current = pre.truth.trackID;
130  sensitive->mark(step->GetTrack());
131  post.copyFrom(pre);
132  parent = step->GetTrack()->GetParentID();
133  g4ID = step->GetTrack()->GetTrackID();
134 
135  Geant4StepHandler startVolume(step);
136  thisPV = startVolume.preVolume();
137 
138  return *this;
139  }
140 
142  TrackerWeighted& update(const G4Step* step) {
143  if( DEBUG == printLevel() ) {
144  std::cout<<" DEBUG: Geant4TrackerWeightedSD::update(const G4Step* step) ...."<<std::endl;
145  Geant4StepHandler h(step);
146  dumpStep( h, step);
147  }
148 
149  post.storePoint(step,step->GetPostStepPoint());
150  Position mean = (post.position+pre.position)*0.5;
151  double mean_tm = (post.truth.time+pre.truth.time)*0.5;
152  pre.truth.deposit += post.truth.deposit;
153  mean_pos.SetX(mean_pos.x()+mean.x()*post.truth.deposit);
154  mean_pos.SetY(mean_pos.y()+mean.y()*post.truth.deposit);
155  mean_pos.SetZ(mean_pos.z()+mean.z()*post.truth.deposit);
156  mean_time += mean_tm*post.truth.deposit;
157  step_length += step->GetStepLength();
158  if ( 0 == cell ) {
159  cell = sensitive->cellID(step);
160  if ( 0 == cell ) {
161  cell = sensitive->volumeID(step) ;
162  sensitive->except("+++ Invalid CELL ID for hit!");
163  }
164  }
165  ++combined;
166  return *this;
167  }
168 
170  bool mustSaveTrack(const G4Track* tr) const {
171  return current > 0 && current != tr->GetTrackID();
172  }
173 
175  void extractHit(EInside ended) {
176  Geant4HitCollection* collection = sensitive->collection(0);
177  extractHit(collection, ended);
178  }
179 
180  TrackerWeighted& calc_dist_out(const G4VSolid* solid) {
181  Position v(pre.momentum.unit()), &p=post.position;
182  double dist = solid->DistanceToOut(G4ThreeVector(p.X(),p.Y(),p.Z()),
183  G4ThreeVector(v.X(),v.Y(),v.Z()));
184  distance_to_outside = dist;
185  return *this;
186  }
187 
188  TrackerWeighted& calc_dist_in(const G4VSolid* solid) {
189  Position v(pre.momentum.unit()), &p=pre.position;
190  double dist = solid->DistanceToOut(G4ThreeVector(p.X(),p.Y(),p.Z()),
191  G4ThreeVector(v.X(),v.Y(),v.Z()));
192  distance_to_inside = dist;
193  return *this;
194  }
195 
196  void extractHit(Geant4HitCollection* collection, EInside ended) {
197  if( DEBUG == printLevel() ) {
198  std::cout<<" DEBUG: Geant4TrackerWeightedSD::extractHit(Geant4HitCollection* collection, EInside ended) ...."<<std::endl;
199  std::cout<<" DEBUG: =================================================="<<std::endl;
200  }
201 
202  double deposit = pre.truth.deposit;
203  if ( current != -1 ) {
204  Position pos;
205  Momentum mom = 0.5 * (pre.momentum + post.momentum);
206  double time = deposit != 0 ? mean_time / deposit : mean_time;
207  char dist_in[64], dist_out[64];
208 
209  switch(hit_position_type) {
210  case POSITION_WEIGHTED:
211  pos = deposit != 0 ? mean_pos / deposit : mean_pos;
212  break;
213  case POSITION_PREPOINT:
214  pos = pre.position;
215  break;
216  case POSITION_POSTPOINT:
217  pos = post.position;
218  break;
219  case POSITION_MIDDLE:
220  default:
221  pos = (post.position + pre.position) / 2.0;
222  break;
223  }
224 
225  if ( ended == kSurface || distance_to_outside < std::numeric_limits<float>::epsilon() )
227  else if ( ended == kInside )
229  else if ( ended == kOutside )
231 
233  pre.truth.pdgID,
234  deposit,time, step_length,
235  pos, mom);
236  hit->flag = hit_flag;
237  hit->cellID = cell;
238  hit->g4ID = g4ID;
239 
240  dist_in[0] = dist_out[0] = 0;
241  if ( !(hit_flag&Geant4Tracker::Hit::HIT_STARTED_SURFACE) )
242  ::snprintf(dist_in,sizeof(dist_in)," [%.2e um]",distance_to_inside/CLHEP::um);
243  if ( !(hit_flag&Geant4Tracker::Hit::HIT_ENDED_SURFACE) )
244  ::snprintf(dist_out,sizeof(dist_out)," [%.2e um]",distance_to_outside/CLHEP::um);
245  sensitive->print("+++ G4Track:%5d CREATE hit[%03d]:%3d deps E:"
246  " %.2e keV Pos:%7.2f %7.2f %7.2f [mm] Start:%s%s%s%s End:%s%s%s%s",
247  pre.truth.trackID,int(collection->GetSize()),
248  combined,pre.truth.deposit/CLHEP::keV,
249  pos.X()/CLHEP::mm,pos.Y()/CLHEP::mm,pos.Z()/CLHEP::mm,
250  ((hit_flag&Geant4Tracker::Hit::HIT_STARTED_SURFACE) ? "SURFACE" : ""),
251  ((hit_flag&Geant4Tracker::Hit::HIT_STARTED_OUTSIDE) ? "OUTSIDE" : ""),
252  ((hit_flag&Geant4Tracker::Hit::HIT_STARTED_INSIDE) ? "INSIDE " : ""),
253  dist_in,
254  ((hit_flag&Geant4Tracker::Hit::HIT_ENDED_SURFACE) ? "SURFACE" : ""),
255  ((hit_flag&Geant4Tracker::Hit::HIT_ENDED_OUTSIDE) ? "OUTSIDE" : ""),
256  ((hit_flag&Geant4Tracker::Hit::HIT_ENDED_INSIDE) ? "INSIDE " : ""),
257  dist_out);
258  collection->add(hit);
259  }
260  clear();
261  }
262 
264  G4bool process(const G4Step* step, G4TouchableHistory* ) {
265  Geant4StepHandler h(step);
266  if( DEBUG == printLevel() ) {
267  std::cout<<" DEBUG: Geant4TrackerWeightedSD::process(const G4Step* step, G4TouchableHistory* ) ...."<<std::endl;
268  dumpStep( h, step);
269  }
270 
271  // std::cout << " process called - pre pos: " << h.prePos() << " post pos " << h.postPos()
272  // << " edep: " << h.deposit() << std::endl ;
273 
274  G4VSolid* preSolid = h.solid(h.pre);
275  G4VSolid* postSolid = h.solid(h.post);
276  G4ThreeVector local_pre = h.globalToLocalG4(h.prePosG4());
277  G4ThreeVector local_post = h.globalToLocalG4(h.postPosG4());
278  EInside pre_inside = preSolid->Inside(local_pre);
279  EInside post_inside = postSolid->Inside(local_post);
280 
281  const void* postPV = h.postVolume();
282  const void* prePV = h.preVolume();
283  const void* postSD = h.postSD();
284  const void* preSD = h.preSD();
285  G4VSolid* solid = (preSD == thisSD) ? preSolid : postSolid;
286  // Track went into new Volume, extracted the hit in prePV, then start a new hit in thisPV.
287  if ( current == h.trkID() && thisPV != 0 && prePV != thisPV ) {
288  if( DEBUG == printLevel() ) {
289  std::cout<<" DEBUG: Geant4TrackerWeightedSD: if ( current == h.trkID() && thisPV != 0 && prePV != thisPV ),"
290  <<" Track went into new Volume, extracted the hit in prePV, then start a new hit in thisPV."
291  << std::endl;
292  }
293  extractHit(post_inside);
294  start(step, h.pre);
295  }
296  // 1) Track killed inside SD: trace incomplete. This deposition must be added as well.
297  else if ( current == h.trkID() && !h.trkAlive() ) {
299  update(step).calc_dist_out(solid).extractHit(post_inside);
300  return true;
301  }
302  // 2) Track leaving SD volume. Sensitive detector changed. Store hit.
303  else if ( current == h.trkID() && postSD != thisSD ) {
304  update(step).calc_dist_out(solid).extractHit(kOutside);
305  return true;
306  }
307  // 3) Track leaving SD volume. Store hit.
308  else if ( current == h.trkID() && postSD == thisSD && post_inside == kSurface ) {
309  update(step).calc_dist_out(solid).extractHit(kSurface);
310  return true;
311  }
312  // 4) Track leaving SD volume. Store hit.
313  else if ( current == h.trkID() && postSD == thisSD && post_inside == kOutside ) {
314  update(step).calc_dist_out(solid).extractHit(post_inside);
315  return true;
316  }
317  // 5) Normal update: either intermediate deposition or track is going to be killed.
318  else if ( current == h.trkID() && postSD == thisSD && post_inside == kInside ) {
319  last_inside = post_inside;
320  update(step).calc_dist_out(solid);
321  return true;
322  }
323  // 6) Track from secondary created in SD volume. Store hit from previous.
324  // --> New hit will be created, to whom also this deposition belongs
325  else if ( current != h.trkID() && current >= 0 ) {
326  extractHit(last_inside);
327  }
328 
329  // If the hit got extracted, a new one must be set up
330  if ( current < 0 ) {
331  EInside inside = pre_inside;
332  // Track entering SD volume
333  if ( preSD != thisSD ) {
334  start(step, h.post);
335  inside = post_inside;
336  sensitive->print("++++++++++ Using POST step volume to start hit -- dubious ?");
337  }
338  else {
339  start(step, h.pre);
340  }
341  calc_dist_in(solid);
342  if ( inside == kSurface )
344  else if ( inside == kInside )
346  else if ( inside == kOutside )
348 
349  // New (secondary) track created by some process starting inside the volume
350  if ( inside == kInside ) {
352  }
353  }
354 
355  // Update Data
356  last_inside = post_inside;
357  update(step);
358  calc_dist_out(solid);
359 
360  // Track killed inside SD: trace incomplete. This deposition must be added as well.
361  if ( !h.trkAlive() ) {
363  extractHit(post_inside);
364  }
365  // Avoid dangling hits if the track leaves the sensitive volume
366  else if ( post_inside == kSurface ) {
367  extractHit(post_inside);
368  }
369  // Avoid dangling hits if the track leaves the sensitive volume
370  else if ( thisSD == preSD && (preSD != postSD || prePV != postPV) ) {
371  extractHit(post_inside);
372  }
373  // This should simply not happen!
374  else if ( thisSD == postSD && (preSD != postSD || prePV != postPV) ) {
375  sensitive->error("+++++ WRONG!!! Extract. How did we get here?");
376  extractHit(post_inside);
377  }
378  // In single hit mode we MUST write the hit after update
379  else if ( single_deposit_mode ) {
380  extractHit(post_inside);
381  }
382 
383  return true;
384  }
385 
387  void endEvent() {
388  // We need to add the possibly last added hit to the collection here.
389  // otherwise the last hit would be assigned to the next event and the
390  // MC truth would be screwed.
391  //
392  if ( current > 0 ) {
393  Geant4HitCollection* coll = sensitive->collection(0);
394  sensitive->print("++++++++++ Found dangling hit: Is the hit extraction logic correct?");
395  extractHit(coll,last_inside);
396  }
397  }
399  void startEvent() {
400  thisSD = dynamic_cast<G4VSensitiveDetector*>(&sensitive->detector());
401  }
402 
404  void dumpStep(const Geant4StepHandler& h, const G4Step* s) {
405  std::stringstream str;
406  str << " ----- step in detector " << h.sdName( s->GetPreStepPoint() )
407  << " prePos " << h.prePos()
408  << " postPos " << h.postPos()
409  << " preStatus " << h.preStepStatus()
410  << " postStatus " << h.postStepStatus()
411  << " preVolume " << h.volName( s->GetPreStepPoint() )
412  << " postVolume " << h.volName( s->GetPostStepPoint() )
413  << std::endl
414  << " momentum : " << std::scientific
415  << s->GetPreStepPoint()->GetMomentum()[0] << ", "
416  << s->GetPreStepPoint()->GetMomentum()[1]<< ", "
417  << s->GetPreStepPoint()->GetMomentum()[2]
418  << " / "
419  << s->GetPostStepPoint()->GetMomentum()[0] << ", "
420  << s->GetPostStepPoint()->GetMomentum()[1] << ", "
421  << s->GetPostStepPoint()->GetMomentum()[2]
422  << ", PDG: " << s->GetTrack()->GetDefinition()->GetPDGEncoding();
423  std::cout << str.str() << std::endl;
424  }
425 
427  G4bool process(const Geant4FastSimSpot* , G4TouchableHistory* ) {
428  sensitive->except("GFlash/FastSim action is not implemented for SD: %s", sensitive->c_name());
429  return false;
430  }
431  };
432 
435  declareProperty("HitPositionCombination", m_userData.hit_position_type);
436  declareProperty("CollectSingleDeposits", m_userData.single_deposit_mode);
437  m_userData.e_cut = m_sensitive.energyCutoff();
438  m_userData.sensitive = this;
439  }
440 
442  template <> void Geant4SensitiveAction<TrackerWeighted>::begin(G4HCofThisEvent* /* hce */) {
443  m_userData.startEvent();
444  }
445 
447  template <> void Geant4SensitiveAction<TrackerWeighted>::end(G4HCofThisEvent* /* hce */) {
448  m_userData.endEvent();
449  }
450 
453  m_collectionID = declareReadoutFilteredCollection<Geant4Tracker::Hit>();
454  }
455 
457  template <> void Geant4SensitiveAction<TrackerWeighted>::clear(G4HCofThisEvent* /* hce */) {
458  m_userData.clear();
459  }
460 
462  template <> G4bool
463  Geant4SensitiveAction<TrackerWeighted>::process(const G4Step* step, G4TouchableHistory* history) {
464  return m_userData.process(step, history);
465  }
466 
468  template <> bool
470  return m_userData.process(spot, history);
471  }
473  }
474 }
475 
476 using namespace dd4hep::sim;
477 
478 #include <DDG4/Factories.h>
dd4hep::sim::Geant4SensitiveAction::begin
virtual void begin(G4HCofThisEvent *hce) final
G4VSensitiveDetector interface: Method invoked at the begining of each event.
DECLARE_GEANT4SENSITIVE
#define DECLARE_GEANT4SENSITIVE(name)
Definition: Factories.h:204
dd4hep::sim::Geant4Tracker::Hit::momentum
Direction momentum
Hit direction.
Definition: Geant4Data.h:270
dd4hep::sim::Geant4Tracker::Hit::position
Position position
Hit position.
Definition: Geant4Data.h:268
dd4hep::sim::Geant4HitData::HIT_ENDED_OUTSIDE
@ HIT_ENDED_OUTSIDE
Definition: Geant4Data.h:121
dd4hep::sim::TrackerWeighted::process
G4bool process(const Geant4FastSimSpot *, G4TouchableHistory *)
GFLash processing callback.
Definition: Geant4TrackerWeightedSD.cpp:427
dd4hep::sim::Geant4SensitiveAction::defineCollections
virtual void defineCollections()
Define collections created by this sensitivie action object.
dd4hep::sim::Geant4HitData::flag
long flag
User flag to classify hits.
Definition: Geant4Data.h:126
dd4hep::sim::Geant4HitCollection::GetSize
virtual size_t GetSize() const override
Access the collection size.
Definition: Geant4HitCollection.h:321
dd4hep::sim::Geant4StepHandler::prePos
Position prePos() const
Returns the pre-step position.
Definition: Geant4StepHandler.h:84
dd4hep::sim::Geant4HitData::HIT_ENDED_SURFACE
@ HIT_ENDED_SURFACE
Definition: Geant4Data.h:120
dd4hep::sim::Geant4HitData::MonteCarloContrib::pdgID
int pdgID
Particle ID from the PDG table.
Definition: Geant4Data.h:143
v
View * v
Definition: MultiView.cpp:28
dd4hep::sim::Momentum
Position Momentum
Definition: Defs.h:27
dd4hep::sim::Geant4StepHandler::pre
G4StepPoint * pre
Definition: Geant4StepHandler.h:49
dd4hep::sim::Geant4Sensitive::detector
Geant4ActionSD & detector() const
Access to the sensitive detector object.
Definition: Geant4SensDetAction.cpp:171
dd4hep::sim::TrackerWeighted::calc_dist_out
TrackerWeighted & calc_dist_out(const G4VSolid *solid)
Definition: Geant4TrackerWeightedSD.cpp:180
dd4hep::sim::Geant4HitHandler::globalToLocalG4
G4ThreeVector globalToLocalG4(double x, double y, double z) const
Coordinate transformation to local coordinates.
Definition: Geant4HitHandler.cpp:64
dd4hep::sim::Geant4StepHandler::volName
const char * volName(const G4StepPoint *p, const char *undefined="") const
Definition: Geant4StepHandler.h:147
Geant4TrackingAction.h
dd4hep::sim::Geant4SensitiveAction::initialize
virtual void initialize() final
Initialization overload for specialization.
Geant4TrackerWeightedAction
Sensitive detector meant for tracking detectors with multiple ways to combine steps.
dd4hep::sim::Geant4HitCollection
Generic hit container class using Geant4HitWrapper objects.
Definition: Geant4HitCollection.h:201
Geant4EventAction.h
dd4hep::sim::Geant4HitData::HIT_KILLED_TRACK
@ HIT_KILLED_TRACK
Definition: Geant4Data.h:113
dd4hep::sim::Geant4Tracker::Hit::copyFrom
void copyFrom(const Hit &c)
Explicit assignment operation.
Definition: Geant4Data.cpp:133
dd4hep::sim::TrackerWeighted::endEvent
void endEvent()
Post-event action callback.
Definition: Geant4TrackerWeightedSD.cpp:387
dd4hep::sim::Geant4HitData::HIT_SECONDARY_TRACK
@ HIT_SECONDARY_TRACK
Definition: Geant4Data.h:114
dd4hep::sim::Geant4HitData::cellID
long long int cellID
cellID
Definition: Geant4Data.h:124
dd4hep::sim::Geant4HitHandler::trkID
int trkID() const
Access the G4 track ID.
Definition: Geant4HitHandler.h:73
dd4hep::sim::Geant4StepHandler::prePosG4
const G4ThreeVector & prePosG4() const
Returns the pre-step position as a G4ThreeVector.
Definition: Geant4StepHandler.h:89
Geant4SteppingAction.h
dd4hep::sim::Geant4FastSimSpot
Spot definition for fast simulation and GFlash.
Definition: Geant4FastSimSpot.h:71
epsilon
const double epsilon
Definition: test_cellid_position_converter.cpp:41
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::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::Geant4SensitiveAction::process
virtual bool process(const G4Step *step, G4TouchableHistory *history) final
G4VSensitiveDetector interface: Method for generating hit(s) using the G4Step object.
dd4hep::sim::Geant4StepHandler::preVolume
G4VPhysicalVolume * preVolume() const
Definition: Geant4StepHandler.h:175
dd4hep::sim::TrackerWeighted::extractHit
void extractHit(Geant4HitCollection *collection, EInside ended)
Definition: Geant4TrackerWeightedSD.cpp:196
dd4hep::sim::Geant4StepHandler::postStepStatus
const char * postStepStatus() const
Returns the post-step status in form of a string.
Definition: Geant4StepHandler.cpp:63
dd4hep::sim::TrackerWeighted::process
G4bool process(const G4Step *step, G4TouchableHistory *)
Method for generating hit(s) using the information of G4Step object.
Definition: Geant4TrackerWeightedSD.cpp:264
dd4hep::sim::Geant4StepHandler
Helper class to ease the extraction of information from a G4Step object.
Definition: Geant4StepHandler.h:46
dd4hep::sim::Geant4SensitiveAction::clear
virtual void clear(G4HCofThisEvent *hce) final
G4VSensitiveDetector interface: Method invoked if the event was aborted.
dd4hep::sim::Geant4Action::except
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
Definition: Geant4Action.cpp:256
dd4hep::sim::Geant4StepHandler::post
G4StepPoint * post
Definition: Geant4StepHandler.h:50
dd4hep::sim::Geant4HitData::HIT_ENDED_INSIDE
@ HIT_ENDED_INSIDE
Definition: Geant4Data.h:119
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::TrackerWeighted::mean_pos
Position mean_pos
Definition: Geant4TrackerWeightedSD.cpp:75
dd4hep::sim::Geant4HitHandler::trkAlive
bool trkAlive() const
Definition: Geant4HitHandler.h:92
dd4hep::sim::Geant4Action::error
void error(const char *fmt,...) const
Support of error messages.
Definition: Geant4Action.cpp:231
dd4hep::sim::Geant4Tracker::Hit
DDG4 tracker hit class used by the generic DDG4 tracker sensitive detector.
Definition: Geant4Data.h:263
G4VSensitiveDetector
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:59
dd4hep::sim::Geant4HitData::g4ID
long g4ID
Original Geant 4 track identifier of the creating track (debugging)
Definition: Geant4Data.h:128
dd4hep::sim::TrackerWeighted::extractHit
void extractHit(EInside ended)
Extract hit information and add the created hit to the collection.
Definition: Geant4TrackerWeightedSD.cpp:175
dd4hep::sim::TrackerWeighted::mustSaveTrack
bool mustSaveTrack(const G4Track *tr) const
Helper function to decide if the hit has to be extracted and saved in the collection.
Definition: Geant4TrackerWeightedSD.cpp:170
dd4hep::sim::Geant4HitData::MonteCarloContrib::deposit
double deposit
Total energy deposit in this hit.
Definition: Geant4Data.h:145
dd4hep::sim::TrackerWeighted::update
TrackerWeighted & update(const G4Step *step)
Update energy and track information during hit info accumulation.
Definition: Geant4TrackerWeightedSD.cpp:142
dd4hep::sim::Geant4StepHandler::solid
G4VSolid * solid(const G4StepPoint *p) const
Definition: Geant4StepHandler.h:154
dd4hep::sim::Geant4HitData::HIT_STARTED_OUTSIDE
@ HIT_STARTED_OUTSIDE
Definition: Geant4Data.h:118
dd4hep::sim::Geant4SensitiveAction
Template class to ease the construction of sensitive detectors using particle template specialization...
Definition: Geant4SensDetAction.h:514
dd4hep::sim::Geant4StepHandler::postVolume
G4VPhysicalVolume * postVolume() const
Definition: Geant4StepHandler.h:181
dd4hep::sim::Geant4Tracker::Hit::truth
Contribution truth
Monte Carlo / Geant4 information.
Definition: Geant4Data.h:276
dd4hep::sim::TrackerWeighted::startEvent
void startEvent()
Pre event action callback.
Definition: Geant4TrackerWeightedSD.cpp:399
dd4hep::sim::TrackerWeighted::pre
Geant4Tracker::Hit pre
Definition: Geant4TrackerWeightedSD.cpp:74
dd4hep::sim::Geant4Action::print
void print(const char *fmt,...) const
Support for messages with variable output level using output level.
Definition: Geant4Action.cpp:144
dd4hep::sim::Geant4StepHandler::postPosG4
const G4ThreeVector & postPosG4() const
Returns the post-step position as a G4ThreeVector.
Definition: Geant4StepHandler.h:98
dd4hep::sim::Geant4HitData::MonteCarloContrib::trackID
int trackID
Geant 4 Track identifier.
Definition: Geant4Data.h:141
dd4hep::sim::Geant4StepHandler::postPos
Position postPos() const
Returns the post-step position.
Definition: Geant4StepHandler.h:93
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:81
Factories.h
dd4hep::sim::TrackerWeighted::calc_dist_in
TrackerWeighted & calc_dist_in(const G4VSolid *solid)
Definition: Geant4TrackerWeightedSD.cpp:188
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep::sim::Geant4StepHandler::preSD
G4VSensitiveDetector * preSD() const
Definition: Geant4StepHandler.h:178
dd4hep::sim::Geant4Action::c_name
const char * c_name() const
Access name of the action.
Definition: Geant4Action.h:284
dist
double dist(const Position &p0, const Position &p1)
Definition: test_cellid_position_converter.cpp:45
dd4hep::sim::TrackerWeighted::start
TrackerWeighted & start(const G4Step *step, const G4StepPoint *point)
Start a new hit.
Definition: Geant4TrackerWeightedSD.cpp:118
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::TrackerWeighted::clear
TrackerWeighted & clear()
Clear collected information and restart for new hit.
Definition: Geant4TrackerWeightedSD.cpp:98
dd4hep::sim::TrackerWeighted::TrackerWeighted
TrackerWeighted()=default
Default constructor.
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4HitData::HIT_STARTED_INSIDE
@ HIT_STARTED_INSIDE
Definition: Geant4Data.h:116
dd4hep::sim::Geant4Tracker::Hit::storePoint
Hit & storePoint(const G4Step *step, const G4StepPoint *point)
Store Geant4 point and step information into tracker hit structure.
Definition: Geant4Data.cpp:154
dd4hep::sim::Geant4StepHandler::sdName
std::string sdName(const G4StepPoint *p, const std::string &undefined="") const
Definition: Geant4StepHandler.h:168
dd4hep::sim::Geant4HitCollection::add
void add(TYPE *hit_pointer)
Add a new hit with a check, that the hit is of the same type.
Definition: Geant4HitCollection.h:333
dd4hep::sim::Geant4Sensitive
The base class for Geant4 sensitive detector actions implemented by users.
Definition: Geant4SensDetAction.h:121
dd4hep::sim::Geant4StepHandler::postSD
G4VSensitiveDetector * postSD() const
Definition: Geant4StepHandler.h:184
dd4hep::sim::Geant4TrackerWeightedAction
Geant4SensitiveAction< TrackerWeighted > Geant4TrackerWeightedAction
Definition: Geant4TrackerWeightedSD.cpp:472
dd4hep::sim::Geant4StepHandler::preStepStatus
const char * preStepStatus() const
Returns the pre-step status in form of a string.
Definition: Geant4StepHandler.cpp:58
dd4hep::sim::Geant4HitData::HIT_STARTED_SURFACE
@ HIT_STARTED_SURFACE
Definition: Geant4Data.h:117
DD4hepUnits.h
dd4hep::sim::TrackerWeighted
Geant4 sensitive detector combining all deposits of one G4Track within one sensitive element.
Definition: Geant4TrackerWeightedSD.cpp:64
dd4hep::sim::Geant4Tracker::Hit::clear
Hit & clear()
Clear hit content.
Definition: Geant4Data.cpp:144
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::Geant4HitData::MonteCarloContrib::time
double time
Timestamp when this energy was deposited.
Definition: Geant4Data.h:147
dd4hep::sim::TrackerWeighted::dumpStep
void dumpStep(const Geant4StepHandler &h, const G4Step *s)
dumpStep
Definition: Geant4TrackerWeightedSD.cpp:404