Belle II Software  release-08-01-10
SensorTraversal.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #ifndef SENSORTRAVERSAL_H
10 #define SENSORTRAVERSAL_H
11 
12 #include <G4ThreeVector.hh>
13 
14 namespace Belle2 {
19  namespace fangs {
26  public:
32  void add(const G4ThreeVector& position, double depEnergy, double length)
33  {
34  m_depEnergy += depEnergy;
35  m_length += length;
36  m_exitPosition = position;
37  }
38 
40  int getTrackID() const { return m_trackID; }
42  int getLadderID() const { return m_ladderID; }
44  int getSensorID() const { return m_sensorID; }
46  int getPDGCode() const { return m_pdgCode; }
48  double getDepEnergy() const { return m_depEnergy; }
50  double getLength() const { return m_length; }
52  double getEntryTime() const { return m_entryTime; }
54  const G4ThreeVector& getEntryMomentum() const { return m_entryMomentum; }
56  const G4ThreeVector& getEntryPosition() const { return m_entryPosition; }
58  const G4ThreeVector& getLocalEntryPosition() const { return m_localentryPosition; }
60  const G4ThreeVector& getExitPosition() const { return m_exitPosition; }
61 
62 
63 
65  bool isContained() const { return m_contained; }
67  bool isPrimary() const { return m_primary; }
68 
70  void hasEntered() { m_contained = false; }
72  void hasLeft() { m_contained = false; }
73 
75  void setInitial(int trackID, int ladderID, int sensorID, int pdgCode, bool primary, const G4ThreeVector& position,
76  const G4ThreeVector& localposition, const G4ThreeVector& momentum, double time)
77  {
78  m_trackID = trackID;
79  m_ladderID = ladderID;
80  m_sensorID = sensorID;
81  m_pdgCode = pdgCode;
82  m_primary = primary;
83  m_entryPosition = position;
84  m_localentryPosition = localposition;
85  m_entryMomentum = momentum;
86  m_entryTime = time;
87  }
88 
90  void reset()
91  {
92  m_trackID = 0;
93  m_ladderID = 0;
94  m_sensorID = 0;
95  m_pdgCode = 0;
96  m_depEnergy = 0;
97  m_length = 0;
98  m_contained = true;
99  m_primary = false;
100  m_entryTime = 0;
101  }
102 
104  bool check(int trackID, int ladderID, int sensorID)
105  {
106  // object not set yet so we can use it
107  if (m_trackID == 0) return true;
108  return (trackID == m_trackID && ladderID == m_ladderID && sensorID == m_sensorID);
109  }
110 
111  private:
113  G4ThreeVector m_entryMomentum;
115  G4ThreeVector m_entryPosition;
117  G4ThreeVector m_localentryPosition;
119  G4ThreeVector m_exitPosition;
121  int m_trackID {0};
123  int m_ladderID {0};
125  int m_sensorID {0};
127  int m_pdgCode {0};
129  double m_depEnergy {0};
131  double m_length {0};
133  double m_entryTime {0};
135  bool m_contained {true};
137  bool m_primary {false};
138  };
139 
140  }
142 } //Belle2 namespace
143 #endif // SENSORTRAVERSAL_H
Class to keep track of the traversal of the sensitive volume for one track.
int getPDGCode() const
get PDG code of the particle
int getLadderID() const
get the ladder ID
G4ThreeVector m_entryMomentum
Entry Position.
const G4ThreeVector & getEntryMomentum() const
get entry momentum
double m_entryTime
time the track entered the volume
void add(const G4ThreeVector &position, double depEnergy, double length)
add a new step
bool check(int trackID, int ladderID, int sensorID)
check if a track belongs to this object
int getSensorID() const
get the sensor ID
const G4ThreeVector & getExitPosition() const
get exit position
bool isPrimary() const
return whether the track belongs to a primary particle
G4ThreeVector m_entryPosition
Entry Position.
void hasLeft()
indicate that the track left the current volume
void setInitial(int trackID, int ladderID, int sensorID, int pdgCode, bool primary, const G4ThreeVector &position, const G4ThreeVector &localposition, const G4ThreeVector &momentum, double time)
set initial values for a new track
const G4ThreeVector & getEntryPosition() const
get entry position
int getTrackID() const
get Geant4 trackID
double m_depEnergy
Total deposited energy by this track.
double getEntryTime() const
get entry time
double getDepEnergy() const
get total energy deposition
double m_length
length of the sensor traversal
int m_pdgCode
PDG code for the particle.
void reset()
reset to be used again
const G4ThreeVector & getLocalEntryPosition() const
get local entry position
void hasEntered()
indicate that the track originated outisde the current volume
G4ThreeVector m_localentryPosition
Local Entry Position.
G4ThreeVector m_exitPosition
Exit Position.
bool m_primary
Indication whether track is from a primary particle.
bool m_contained
Indication wether the track is completely contained inside the volume.
bool isContained() const
return whether the track was contained in the volume so far
double getLength() const
get flight length so far
Abstract base class for different kinds of events.