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#pragma once
10#ifndef VXD_SIMULATION_SENSORTRAVERSAL_H
11#define VXD_SIMULATION_SENSORTRAVERSAL_H
12
13#include <G4ThreeVector.hh>
14#include <vector>
15
16namespace Belle2 {
33 StepInformation(const G4ThreeVector& stepPosition, const G4ThreeVector& stepMomentum, double stepElectrons, double stepTime,
34 double stepLength):
35 position(stepPosition), momentum(stepMomentum), electrons(stepElectrons), time(stepTime), length(stepLength) {}
37 G4ThreeVector position;
39 G4ThreeVector momentum;
41 double electrons;
43 double time {0};
45 double length {0};
46 };
47
53 class SensorTraversal: public std::vector<StepInformation> {
54 public:
56 typedef std::pair<iterator, iterator> range;
57
59 SensorTraversal() = default;
60
68 void add(const G4ThreeVector& position, const G4ThreeVector& momentum, double electrons, double time, double length)
69 {
70 m_electrons += electrons;
71 m_length += length;
72 emplace_back(position, momentum, m_electrons, time, m_length);
73 }
74
76 int getTrackID() const { return m_trackID; }
78 int getPDGCode() const { return m_pdgCode; }
80 double getElectrons() const { return m_electrons; }
82 double getLength() const { return m_length; }
84 bool isContained() const { return m_contained; }
86 bool isPrimary() const { return m_primary; }
87
89 void hasEntered() { m_contained = false; }
91 void hasLeft() { m_contained = false; }
92
94 void setInitial(int trackID, int pdgCode, bool primary)
95 {
96 m_trackID = trackID;
97 m_pdgCode = pdgCode;
98 m_primary = primary;
99 }
100
102 void reset()
103 {
104 m_trackID = 0;
105 m_pdgCode = 0;
106 m_electrons = 0;
107 m_length = 0;
108 m_contained = true;
109 m_primary = false;
110 clear();
111 }
112
113 private:
115 int m_trackID {0};
117 int m_pdgCode {0};
119 double m_electrons {0};
121 double m_length {0};
123 bool m_contained {true};
125 bool m_primary {false};
126 };
127
129} //Belle2 namespace
130#endif // VXD_SIMULATION_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
double getElectrons() const
get total number of deposited electrons so far
void setInitial(int trackID, int pdgCode, bool primary)
set initial values for a new track
int m_trackID
Geant4 Track ID.
SensorTraversal()=default
Use default constructor.
bool isPrimary() const
return whether the track belongs to a primary particle
void hasLeft()
indicate that the track left the current volume
int getTrackID() const
get Geant4 trackID
double m_electrons
Total number of electrons deposited by this track.
void add(const G4ThreeVector &position, const G4ThreeVector &momentum, double electrons, double time, double length)
add a new step
double m_length
length of the sensor traversal
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
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
std::pair< iterator, iterator > range
Iterator pair for a set of points.
double getLength() const
get flight length so far
Abstract base class for different kinds of events.
Simple struct to keep information about steps in the sensitive detector.
G4ThreeVector momentum
Step momentum.
double electrons
Number of deposited electrons.
StepInformation(const G4ThreeVector &stepPosition, const G4ThreeVector &stepMomentum, double stepElectrons, double stepTime, double stepLength)
Construct a new instance.
G4ThreeVector position
Step position.
double length
length of the track
double time
timestamp of the step