Belle II Software  release-05-01-25
SensorTraversal.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2015 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef SENSORTRAVERSAL_H
12 #define SENSORTRAVERSAL_H
13 
14 #include <G4ThreeVector.hh>
15 
16 namespace Belle2 {
21  namespace fangs {
27  class SensorTraversal {
28  public:
34  void add(const G4ThreeVector& position, double depEnergy, double length)
35  {
36  m_depEnergy += depEnergy;
37  m_length += length;
38  m_exitPosition = position;
39  }
40 
42  int getTrackID() const { return m_trackID; }
44  int getLadderID() const { return m_ladderID; }
46  int getSensorID() const { return m_sensorID; }
48  int getPDGCode() const { return m_pdgCode; }
50  double getDepEnergy() const { return m_depEnergy; }
52  double getLength() const { return m_length; }
54  double getEntryTime() const { return m_entryTime; }
56  const G4ThreeVector& getEntryMomentum() const { return m_entryMomentum; }
58  const G4ThreeVector& getEntryPosition() const { return m_entryPosition; }
60  const G4ThreeVector& getLocalEntryPosition() const { return m_localentryPosition; }
62  const G4ThreeVector& getExitPosition() const { return m_exitPosition; }
63 
64 
65 
67  bool isContained() const { return m_contained; }
69  bool isPrimary() const { return m_primary; }
70 
72  void hasEntered() { m_contained = false; }
74  void hasLeft() { m_contained = false; }
75 
77  void setInitial(int trackID, int ladderID, int sensorID, int pdgCode, bool primary, const G4ThreeVector& position,
78  const G4ThreeVector& localposition, const G4ThreeVector& momentum, double time)
79  {
80  m_trackID = trackID;
81  m_ladderID = ladderID;
82  m_sensorID = sensorID;
83  m_pdgCode = pdgCode;
84  m_primary = primary;
85  m_entryPosition = position;
86  m_localentryPosition = localposition;
87  m_entryMomentum = momentum;
88  m_entryTime = time;
89  }
90 
92  void reset()
93  {
94  m_trackID = 0;
95  m_ladderID = 0;
96  m_sensorID = 0;
97  m_pdgCode = 0;
98  m_depEnergy = 0;
99  m_length = 0;
100  m_contained = true;
101  m_primary = false;
102  m_entryTime = 0;
103  }
104 
106  bool check(int trackID, int ladderID, int sensorID)
107  {
108  // object not set yet so we can use it
109  if (m_trackID == 0) return true;
110  return (trackID == m_trackID && ladderID == m_ladderID && sensorID == m_sensorID);
111  }
112 
113  private:
115  G4ThreeVector m_entryMomentum;
117  G4ThreeVector m_entryPosition;
119  G4ThreeVector m_localentryPosition;
121  G4ThreeVector m_exitPosition;
123  int m_trackID {0};
125  int m_ladderID {0};
127  int m_sensorID {0};
129  int m_pdgCode {0};
131  double m_depEnergy {0};
133  double m_length {0};
135  double m_entryTime {0};
137  bool m_contained {true};
139  bool m_primary {false};
140  };
141 
142  }
144 } //Belle2 namespace
145 #endif // SENSORTRAVERSAL_H
Belle2::fangs::SensorTraversal::m_ladderID
int m_ladderID
Ladder ID.
Definition: SensorTraversal.h:133
Belle2::fangs::SensorTraversal::m_trackID
int m_trackID
Geant4 Track ID.
Definition: SensorTraversal.h:131
Belle2::fangs::SensorTraversal::m_localentryPosition
G4ThreeVector m_localentryPosition
Local Entry Position.
Definition: SensorTraversal.h:127
Belle2::fangs::SensorTraversal::getEntryPosition
const G4ThreeVector & getEntryPosition() const
get entry position
Definition: SensorTraversal.h:66
Belle2::fangs::SensorTraversal::hasLeft
void hasLeft()
indicate that the track left the current volume
Definition: SensorTraversal.h:82
Belle2::fangs::SensorTraversal::m_entryMomentum
G4ThreeVector m_entryMomentum
Entry Position.
Definition: SensorTraversal.h:123
Belle2::fangs::SensorTraversal::m_length
double m_length
length of the sensor traversal
Definition: SensorTraversal.h:141
Belle2::fangs::SensorTraversal::getTrackID
int getTrackID() const
get Geant4 trackID
Definition: SensorTraversal.h:50
Belle2::fangs::SensorTraversal::getDepEnergy
double getDepEnergy() const
get total energy deposition
Definition: SensorTraversal.h:58
Belle2::fangs::SensorTraversal::m_sensorID
int m_sensorID
Sensor ID.
Definition: SensorTraversal.h:135
Belle2::fangs::SensorTraversal::getSensorID
int getSensorID() const
get the sensor ID
Definition: SensorTraversal.h:54
Belle2::fangs::SensorTraversal::m_entryPosition
G4ThreeVector m_entryPosition
Entry Position.
Definition: SensorTraversal.h:125
Belle2::fangs::SensorTraversal::check
bool check(int trackID, int ladderID, int sensorID)
check if a track belongs to this object
Definition: SensorTraversal.h:114
Belle2::fangs::SensorTraversal::isContained
bool isContained() const
return whether the track was contained in the volume so far
Definition: SensorTraversal.h:75
Belle2::fangs::SensorTraversal::hasEntered
void hasEntered()
indicate that the track originated outisde the current volume
Definition: SensorTraversal.h:80
Belle2::fangs::SensorTraversal::getLength
double getLength() const
get flight length so far
Definition: SensorTraversal.h:60
Belle2::fangs::SensorTraversal::m_exitPosition
G4ThreeVector m_exitPosition
Exit Position.
Definition: SensorTraversal.h:129
Belle2::fangs::SensorTraversal::getPDGCode
int getPDGCode() const
get PDG code of the particle
Definition: SensorTraversal.h:56
Belle2::fangs::SensorTraversal::m_primary
bool m_primary
Indication whether track is from a primary particle.
Definition: SensorTraversal.h:147
Belle2::fangs::SensorTraversal::getLadderID
int getLadderID() const
get the ladder ID
Definition: SensorTraversal.h:52
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::fangs::SensorTraversal::isPrimary
bool isPrimary() const
return whether the track belongs to a primary particle
Definition: SensorTraversal.h:77
Belle2::fangs::SensorTraversal::getEntryMomentum
const G4ThreeVector & getEntryMomentum() const
get entry momentum
Definition: SensorTraversal.h:64
Belle2::fangs::SensorTraversal::setInitial
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
Definition: SensorTraversal.h:85
Belle2::fangs::SensorTraversal::getLocalEntryPosition
const G4ThreeVector & getLocalEntryPosition() const
get local entry position
Definition: SensorTraversal.h:68
Belle2::fangs::SensorTraversal::m_contained
bool m_contained
Indication wether the track is completely contained inside the volume.
Definition: SensorTraversal.h:145
Belle2::fangs::SensorTraversal::m_pdgCode
int m_pdgCode
PDG code for the particle.
Definition: SensorTraversal.h:137
Belle2::fangs::SensorTraversal::reset
void reset()
reset to be used again
Definition: SensorTraversal.h:100
Belle2::fangs::SensorTraversal::m_entryTime
double m_entryTime
time the track entered the volume
Definition: SensorTraversal.h:143
Belle2::fangs::SensorTraversal::m_depEnergy
double m_depEnergy
Total deposited energy by this track.
Definition: SensorTraversal.h:139
Belle2::fangs::SensorTraversal::getExitPosition
const G4ThreeVector & getExitPosition() const
get exit position
Definition: SensorTraversal.h:70
Belle2::fangs::SensorTraversal::add
void add(const G4ThreeVector &position, double depEnergy, double length)
add a new step
Definition: SensorTraversal.h:42
Belle2::fangs::SensorTraversal::getEntryTime
double getEntryTime() const
get entry time
Definition: SensorTraversal.h:62