Belle II Software development
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
14namespace Belle2 {
19 namespace claws {
26 public:
33 void add(const G4ThreeVector& position, double depEnergy, double visibleEnergy, double length)
34 {
35 m_depEnergy += depEnergy;
36 m_visibleEnergy += visibleEnergy;
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 getVisibleEnergy() const { return m_visibleEnergy; }
54 double getLength() const { return m_length; }
56 double getEntryTime() const { return m_entryTime; }
58 const G4ThreeVector& getEntryMomentum() const { return m_entryMomentum; }
60 const G4ThreeVector& getEntryPosition() const { return m_entryPosition; }
62 const G4ThreeVector& getExitPosition() const { return m_exitPosition; }
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& 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_entryMomentum = momentum;
85 m_entryTime = time;
86 }
87
89 void reset()
90 {
91 m_trackID = 0;
92 m_ladderID = 0;
93 m_sensorID = 0;
94 m_pdgCode = 0;
95 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_exitPosition;
119 int m_trackID {0};
121 int m_ladderID {0};
123 int m_sensorID {0};
125 int m_pdgCode {0};
127 double m_depEnergy {0};
129 double m_visibleEnergy {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.
double m_entryTime
time the track entered the volume
double m_visibleEnergy
Total visible energy by this track.
bool check(int trackID, int ladderID, int sensorID)
check if a track belongs to this object
double getVisibleEnergy() const
get visible energy deposition
int getSensorID() const
get the sensor ID
const G4ThreeVector & getEntryMomentum() const
get entry momentum
bool isPrimary() const
return whether the track belongs to a primary particle
const G4ThreeVector & getExitPosition() const
get exit position
G4ThreeVector m_entryPosition
Entry Position.
void hasLeft()
indicate that the track left the current volume
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
void setInitial(int trackID, int ladderID, int sensorID, int pdgCode, bool primary, const G4ThreeVector &position, const G4ThreeVector &momentum, double time)
set initial values for a new track
void add(const G4ThreeVector &position, double depEnergy, double visibleEnergy, double length)
add a new step
int m_pdgCode
PDG code for the particle.
void reset()
reset to be used again
void hasEntered()
indicate that the track originated outisde the current volume
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.