NAIA  1.1.1
MCTruth.h
Go to the documentation of this file.
1 
8 #ifndef NAIA_MCTRUTH_H
9 #define NAIA_MCTRUTH_H
10 
11 // gbatch headers
12 #ifdef ENABLE_PRODUCTION_CODE
13 #include "root.h"
14 #endif
15 
17 #include "Containers/Utils.h"
19 
20 #include "TVector3.h"
21 
22 #include <array>
23 #include <map>
24 #include <vector>
25 
26 namespace NAIA {
27 
32 struct MCParticle {
33  int PDGCode = 0;
34  int Z = 0;
35  unsigned int A = 0;
36  float Mass = 0;
37  // clang-format off
38  std::vector<TVector3> Position;
39  std::vector<TVector3> Momentum;
40  // clang-format on
41  int partID = -1;
42  int parentID = -1;
43  int Proc1 = -1;
44  int Proc2 = -1;
45 
51  [[nodiscard]] double GetGenMomentum() const {
52  static constexpr std::string_view routine_name{"MCTruth::GetGenMomentum"};
53 
54  if (!Momentum.empty()) {
56  } else {
57  getLogger(routine_name)->error("No generation momentum available");
58  throw std::runtime_error("No generation momentum available");
59  }
60  }
61 
67  [[nodiscard]] TVector3 GetGenPosition() const {
68  static constexpr std::string_view routine_name{"MCTruth::GetGenPosition"};
69 
70  if (!Position.empty()) {
72  } else {
73  getLogger(routine_name)->error("No generation position available");
74  throw std::runtime_error("No generation position available");
75  }
76  }
77 
83  [[nodiscard]] int NSkip() const { return (Proc1 << 24) | Proc2; }
84 };
85 
93 class MCTruthBaseData : public TObject {
94 public:
95 #ifdef ENABLE_PRODUCTION_CODE
96  bool Fill(AMSEventR *evPtr);
97 #endif
98 
103  void Clear();
104 
109  void Dump() const;
110 
112 
113 private:
114  ClassDef(MCTruthBaseData, 2)
115 };
116 
125 class MCTruthPlusData : public TObject {
126 public:
130  struct TrMCHit {
131  int pID = 0;
132  std::array<float, 3> Coo;
133  std::array<float, 3> Mom;
134  };
135 
136 #ifdef ENABLE_PRODUCTION_CODE
137  bool Fill(AMSEventR *evPtr);
138  bool FillTrMCHit(TrTrackR *pTrTrack, float tof_beta);
139 #endif
140 
145  void Clear();
146 
151  void Dump() const;
152 
153  // clang-format off
154  std::vector<MCParticle> Secondaries;
156  // clang-format on
157 
158 private:
159  ClassDef(MCTruthPlusData, 1)
160 };
161 
170 class MCTruthBase : public OnDemandContainer<MCTruthBase>, public MCTruthBaseData {
171 public:
172  static const std::string BranchName;
173 
175 };
176 
185 class MCTruthPlus : public OnDemandContainer<MCTruthPlus>, public MCTruthPlusData {
186 public:
187  static const std::string BranchName;
188 
190 };
191 
192 } // namespace NAIA
193 #endif
NAIA::MCTruthBaseData
Container class for base MCTruth info.
Definition: MCTruth.h:93
NAIA::MCTruthBaseData::Dump
void Dump() const
Dump on screen container content.
Definition: MCTruth.cpp:12
NAIA::MCParticle
Simple struct to describe a MC particle.
Definition: MCTruth.h:32
NAIA::MCParticle::Z
int Z
particle charge
Definition: MCTruth.h:34
NAIA::MCTruthPlusData::Clear
void Clear()
Clear container content.
Definition: MCTruth.cpp:42
NAIA::MCParticle::Position
std::vector< TVector3 > Position
particle position at different z-heights.
Definition: MCTruth.h:38
NAIA::MCTruthPlusData::TrMCHit::Coo
std::array< float, 3 > Coo
hit position
Definition: MCTruth.h:132
NAIA::MCTruthPlusData::Dump
void Dump() const
Dump on screen container content.
Definition: MCTruth.cpp:27
NAIA
Definition: Event.h:13
NAIA::MCParticle::partID
int partID
Particle track ID according to Geant4.
Definition: MCTruth.h:41
NAIA::getLogger
auto getLogger(std::string_view fnName)
Create a new logger with a given function name.
Definition: Logging.h:20
NAIA::OnDemandContainer
Mixin class to add "read-on-demand" behavior to an existing container class.
Definition: OnDemandContainer.h:44
Utils.h
NAIA::MCParticle::Momentum
std::vector< TVector3 > Momentum
particle momentum at different z-heights.
Definition: MCTruth.h:39
NAIA::MCTruthBase::MCTruthBase
MCTruthBase()
Definition: MCTruth.h:174
NAIA::MCTruthPlus
Accessor class for MCTruthPlus info.
Definition: MCTruth.h:185
NAIA::MCParticle::Mass
float Mass
particle mass in GeV/c^2
Definition: MCTruth.h:36
NAIA::MCParticle::PDGCode
int PDGCode
particle PDG code
Definition: MCTruth.h:33
NAIA::MCParticle::parentID
int parentID
Parent particle track ID according to Geant4.
Definition: MCTruth.h:42
NAIA::MCParticle::GetGenPosition
TVector3 GetGenPosition() const
Get the particle generation position.
Definition: MCTruth.h:67
NAIA::MCTruth::GenerationPoint
@ GenerationPoint
Definition: Utils.h:377
NAIA::MCTruthPlusData::Secondaries
std::vector< MCParticle > Secondaries
list of particles created by interaction of the primary particle
Definition: MCTruth.h:154
NAIA::MCParticle::A
unsigned int A
particle mass number
Definition: MCTruth.h:35
NAIA::MCTruthPlusData::TrackMCHits
LayerVariable< TrMCHit > TrackMCHits
A collection of the closest MCHit to the TrTrack cluster on each layer.
Definition: MCTruth.h:155
NAIA::MCTruthBaseData::Primary
MCParticle Primary
primary particle
Definition: MCTruth.h:111
NAIA::MCTruthPlus::MCTruthPlus
MCTruthPlus()
Definition: MCTruth.h:189
NAIA::MCTruthPlusData::TrMCHit::pID
int pID
particle PID
Definition: MCTruth.h:131
NAIA::MCTruthPlusData::TrMCHit
Simple struct for MC tracker hits.
Definition: MCTruth.h:130
NAIA::MCTruthPlus::BranchName
static const std::string BranchName
Definition: MCTruth.h:187
NAIA::LayerVariable
std::map< unsigned int, T > LayerVariable
Definition: Utils.h:54
NAIA::MCTruthBase::BranchName
static const std::string BranchName
Definition: MCTruth.h:172
Logging.h
NAIA::MCParticle::Proc1
int Proc1
secondary creation process (G4VProcess::ProcessType)
Definition: MCTruth.h:43
NAIA::MCParticle::GetGenMomentum
double GetGenMomentum() const
Get the particle generation momentum.
Definition: MCTruth.h:51
NAIA::MCTruthPlusData
Container class for additional MCTruth info.
Definition: MCTruth.h:125
NAIA::MCParticle::Proc2
int Proc2
secondary creation subprocess (G4VProcess::ProcessSubType)
Definition: MCTruth.h:44
NAIA::MCTruthPlusData::TrMCHit::Mom
std::array< float, 3 > Mom
hit momentum
Definition: MCTruth.h:133
NAIA::MCTruthBaseData::Clear
void Clear()
Clear container content.
Definition: MCTruth.cpp:10
OnDemandContainer.h
OnDemandContainer container class description.
NAIA::MCParticle::NSkip
int NSkip() const
Reconstruct the original value of nskip from gbatch.
Definition: MCTruth.h:83
NAIA::MCTruthBase
Accessor class for MCTruthBase info.
Definition: MCTruth.h:170