Belle II Software  release-05-02-19
SensorTraversal.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2014 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 #pragma once
12 #ifndef VXD_SIMULATION_SENSORTRAVERSAL_H
13 #define VXD_SIMULATION_SENSORTRAVERSAL_H
14 
15 #include <G4ThreeVector.hh>
16 #include <vector>
17 
18 namespace Belle2 {
27  struct StepInformation {
34  StepInformation(const G4ThreeVector& stepPosition, const G4ThreeVector& stepMomentum, double stepElectrons, double stepTime,
35  double stepLength):
36  position(stepPosition), momentum(stepMomentum), electrons(stepElectrons), time(stepTime), length(stepLength) {}
38  G4ThreeVector position;
40  G4ThreeVector momentum;
42  double electrons;
44  double time {0};
46  double length {0};
47  };
48 
54  class SensorTraversal: public std::vector<StepInformation> {
55  public:
57  typedef std::pair<iterator, iterator> range;
58 
60  SensorTraversal() = default;
61 
67  void add(const G4ThreeVector& position, const G4ThreeVector& momentum, double electrons, double time, double length)
68  {
69  m_electrons += electrons;
70  m_length += length;
71  emplace_back(position, momentum, m_electrons, time, m_length);
72  }
73 
75  int getTrackID() const { return m_trackID; }
77  int getPDGCode() const { return m_pdgCode; }
79  double getElectrons() const { return m_electrons; }
81  double getLength() const { return m_length; }
83  bool isContained() const { return m_contained; }
85  bool isPrimary() const { return m_primary; }
86 
88  void hasEntered() { m_contained = false; }
90  void hasLeft() { m_contained = false; }
91 
93  void setInitial(int trackID, int pdgCode, bool primary)
94  {
95  m_trackID = trackID;
96  m_pdgCode = pdgCode;
97  m_primary = primary;
98  }
99 
101  void reset()
102  {
103  m_trackID = 0;
104  m_pdgCode = 0;
105  m_electrons = 0;
106  m_length = 0;
107  m_contained = true;
108  m_primary = false;
109  clear();
110  }
111 
112  private:
114  int m_trackID {0};
116  int m_pdgCode {0};
118  double m_electrons {0};
120  double m_length {0};
122  bool m_contained {true};
124  bool m_primary {false};
125  };
126 
128 } //Belle2 namespace
129 #endif // VXD_SIMULATION_SENSORTRAVERSAL_H
Belle2::SensorTraversal::m_primary
bool m_primary
Indication whether track is from a primary particle.
Definition: SensorTraversal.h:124
Belle2::StepInformation::time
double time
timestamp of the step
Definition: SensorTraversal.h:44
Belle2::SensorTraversal
Class to keep track of the traversal of the sensitive volume for one track.
Definition: SensorTraversal.h:54
Belle2::SensorTraversal::getElectrons
double getElectrons() const
get total number of deposited electrons so far
Definition: SensorTraversal.h:79
Belle2::StepInformation::electrons
double electrons
Number of deposited electrons.
Definition: SensorTraversal.h:42
Belle2::StepInformation::StepInformation
StepInformation(const G4ThreeVector &stepPosition, const G4ThreeVector &stepMomentum, double stepElectrons, double stepTime, double stepLength)
Construct a new instance.
Definition: SensorTraversal.h:34
Belle2::SensorTraversal::m_electrons
double m_electrons
Total number of electrons deposited by this track.
Definition: SensorTraversal.h:118
Belle2::SensorTraversal::getLength
double getLength() const
get flight length so far
Definition: SensorTraversal.h:81
Belle2::SensorTraversal::m_length
double m_length
length of the sensor traversal
Definition: SensorTraversal.h:120
Belle2::SensorTraversal::add
void add(const G4ThreeVector &position, const G4ThreeVector &momentum, double electrons, double time, double length)
add a new step
Definition: SensorTraversal.h:67
Belle2::StepInformation::position
G4ThreeVector position
Step position.
Definition: SensorTraversal.h:38
Belle2::SensorTraversal::hasLeft
void hasLeft()
indicate that the track left the current volume
Definition: SensorTraversal.h:90
Belle2::SensorTraversal::SensorTraversal
SensorTraversal()=default
Use default constructor.
Belle2::SensorTraversal::getPDGCode
int getPDGCode() const
get PDG code of the particle
Definition: SensorTraversal.h:77
Belle2::SensorTraversal::setInitial
void setInitial(int trackID, int pdgCode, bool primary)
set initial values for a new track
Definition: SensorTraversal.h:93
Belle2::StepInformation
Simple struct to keep information about steps in the sensitive detector.
Definition: SensorTraversal.h:27
Belle2::SensorTraversal::getTrackID
int getTrackID() const
get Geant4 trackID
Definition: SensorTraversal.h:75
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SensorTraversal::range
std::pair< iterator, iterator > range
Iterator pair for a set of points.
Definition: SensorTraversal.h:57
Belle2::SensorTraversal::reset
void reset()
reset to be used again
Definition: SensorTraversal.h:101
Belle2::SensorTraversal::isPrimary
bool isPrimary() const
return whether the track belongs to a primary particle
Definition: SensorTraversal.h:85
Belle2::SensorTraversal::m_pdgCode
int m_pdgCode
PDG code for the particle.
Definition: SensorTraversal.h:116
Belle2::SensorTraversal::m_trackID
int m_trackID
Geant4 Track ID.
Definition: SensorTraversal.h:114
Belle2::StepInformation::momentum
G4ThreeVector momentum
Step momentum.
Definition: SensorTraversal.h:40
Belle2::StepInformation::length
double length
length of the track
Definition: SensorTraversal.h:46
Belle2::SensorTraversal::hasEntered
void hasEntered()
indicate that the track originated outisde the current volume
Definition: SensorTraversal.h:88
Belle2::SensorTraversal::m_contained
bool m_contained
Indication wether the track is completely contained inside the volume.
Definition: SensorTraversal.h:122
Belle2::SensorTraversal::isContained
bool isContained() const
return whether the track was contained in the volume so far
Definition: SensorTraversal.h:83