KaliVeda
Toolkit for HIC analysis
KVDetectorStack.cpp
1 #include "KVDetectorStack.h"
2 #include "KVDetector.h"
3 
5 
6 
7 
10 {
11  fDetectors.Add(D);
12 }
13 
14 
15 
17 
19 {
20  Add(&D);
21 }
22 
23 
24 
27 
29 {
30  // \return total energy loss in stack for given incident energy
31 
32  auto E0 = Einc;
33  for (auto d : fDetectors) {
34  E0 -= dynamic_cast<KVDetector*>(d)->GetTotalDeltaE(Z, A, E0);
35  if (E0 <= 0)
36  return Einc;
37  }
38  return Einc - E0;
39 }
40 
41 
42 
45 
47 {
48  // \return residual energy after all detectors in stack
49 
50  return Einc - GetDeltaE(Z, A, Einc);
51 }
52 
53 
54 
57 
59 {
60  // \return total energy loss in stack given residual energy
61 
62  return GetIncidentEnergyFromERes(Z, A, Eres) - Eres;
63 }
64 
65 
66 
73 
75 {
76  // \return incident energy for particle having residual energy after stack
77  //
78  // \param layers optional:
79  // + layers<0 - ignore last abs(layers) detectors
80  // + layers>0 - ignore first layers detectors
81 
82  auto ndets = fDetectors.GetEntries();
83  bool ignore_some = layers.has_value();
84  auto ignore_first = (ignore_some && layers.value() > 0) ? ndets - layers.value() : ndets;
85  auto ignore_last = (ignore_some && layers.value() < 0) ? -layers.value() : 0;
86 
87  double Einc;
89  KVDetector* d;
90  while ((d = (KVDetector*)it())) {
91  if (ignore_last) {
92  --ignore_last;
93  continue;
94  }
95  if (!ignore_first)
96  continue;
97  --ignore_first;
98  Einc = d->GetIncidentEnergyFromERes(Z, A, Eres);
99  Eres = Einc;
100  }
101  return Einc;
102 }
103 
104 
105 
112 
114 {
115  // \return punch through energy for particle
116  //
117  // This is the incident energy required to arrive just before the last detector
118  // with the punch through energy for *that* detector, i.e. having that as residual
119  // energy after passing all but the last layer of the stack
120 
121  auto eres = dynamic_cast<KVDetector*>(fDetectors.Last())->GetPunchThroughEnergy(Z, A);
122  return GetIncidentEnergyFromERes(Z, A, eres, -1);
123 }
124 
125 
126 
136 
138 {
139  // Simulate passage of charged particle through the detector stack.
140  //
141  // Particle energy will decrease according to energy losses in detectors.
142  //
143  //If the optional argument 'norm' is given, it is supposed to be a vector
144  //normal to the detectors in the stack, oriented from the origin towards the detectors.
145  //In this case the effective thicknesses of the detector's absorbers 'seen' by the particle
146  //depending on its direction of motion is used for the calculation.
147 
148  for (auto d : fDetectors) {
149  dynamic_cast<KVDetector*>(d)->DetectParticle(&N, norm);
150  }
151 }
152 
153 
154 
157 
159 {
160  // Calls KVDetector::Clear() for each detector in stack.
161  for (auto d : fDetectors) {
162  d->Clear(opt);
163  }
164 }
165 
166 
167 
int Int_t
#define d(i)
double Double_t
const char Option_t
const Bool_t kIterBackward
#define N
Easily calculate energy losses etc. in a stack of detectors.
Double_t GetDeltaE(Int_t Z, Int_t A, Double_t Einc)
Double_t GetPunchThroughEnergy(Int_t Z, Int_t A)
Double_t GetIncidentEnergyFromERes(Int_t Z, Int_t A, Double_t Eres, std::optional< int >=std::nullopt)
void Clear(Option_t *opt="") override
Calls KVDetector::Clear() for each detector in stack.
void DetectParticle(KVNucleus &, TVector3 *=nullptr)
Double_t GetDeltaEFromERes(Int_t Z, Int_t A, Double_t Eres)
KVUnownedList fDetectors
void Add(KVDetector *)
Double_t GetERes(Int_t Z, Int_t A, Double_t Einc)
Base class for detector geometry description, interface to energy-loss calculations.
Definition: KVDetector.h:159
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:123
TObject * Last() const override
virtual Int_t GetEntries() const
ClassImp(TPyArg)