BmnRoot 26.10.0-19-g6979a6c6
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
CbmStack.h
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- CbmStack header file -----
3// ----- Created 10/08/04 by D. Bertini / V. Friese -----
4// -------------------------------------------------------------------------
5
6/** CbmStack.h
7 *@author D.Bertini <d.bertini@gsi.de>
8 *@author V.Friese <v.friese@gsi.de>
9 **
10 ** Version 14/06/07 by V. Friese
11 **
12 ** This class handles the particle stack for the transport simulation.
13 ** For the stack FILO functunality, it uses the STL stack. To store
14 ** the tracks during transport, a TParticle arry is used.
15 ** At the end of the event, tracks satisfying the filter criteria
16 ** are copied to a CbmMCTrack array, which is stored in the output.
17 **
18 ** The filtering criteria for the output tracks are:
19 ** - primary tracks are stored in any case.
20 ** - secondary tracks are stored if they have a minimal number of
21 ** points (sum of all detectors) and a minimal energy, or are the
22 **
23 ** The storage of secondaries can be switched off.
24 ** The storage of all mothers can be switched off.
25 ** By default, the minimal number of points is 1 and the energy cut is 0.
26 **/
27
28#ifndef CBMSTACK_H
29#define CBMSTACK_H
30
31#include "BmnDetectorList.h" // for DetectorId
32#include "FairGenericStack.h" // for FairGenericStack
33
34#include <TClonesArray.h> // for TClonesArray
35#include <TMCProcess.h> // for TMCProcess
36#include <TParticle.h> // for TParticle
37#include <TRefArray.h> // for TRefArray
38#include <map> // for map, map<>::iterator
39#include <stack> // for stack
40#include <utility> // for pair
41
43{
44 public:
45 /** Default constructor
46 *param size Estimated track number
47 **/
48 CbmStack(Int_t size = 100);
49
50 /** Destructor **/
51 virtual ~CbmStack();
52
53 /** Add a TParticle to the stack.
54 ** Declared in TVirtualMCStack
55 *@param toBeDone Flag for tracking
56 *@param parentID Index of mother particle
57 *@param pdgCode Particle type (PDG encoding)
58 *@param px,py,pz Momentum components at start vertex [GeV]
59 *@param e Total energy at start vertex [GeV]
60 *@param vx,vy,vz Coordinates of start vertex [cm]
61 *@param time Start time of track [s]
62 *@param polx,poly,polz Polarisation vector
63 *@param proc Production mechanism (VMC encoding)
64 *@param ntr Track number (filled by the stack)
65 *@param weight Particle weight
66 *@param is Generation status code (whatever that means)
67 **/
68 virtual void PushTrack(Int_t toBeDone,
69 Int_t parentID,
70 Int_t pdgCode,
71 Double_t px,
72 Double_t py,
73 Double_t pz,
74 Double_t e,
75 Double_t vx,
76 Double_t vy,
77 Double_t vz,
78 Double_t time,
79 Double_t polx,
80 Double_t poly,
81 Double_t polz,
82 TMCProcess proc,
83 Int_t& ntr,
84 Double_t weight,
85 Int_t is);
86
87 virtual void PushTrack(Int_t toBeDone,
88 Int_t parentID,
89 Int_t pdgCode,
90 Double_t px,
91 Double_t py,
92 Double_t pz,
93 Double_t e,
94 Double_t vx,
95 Double_t vy,
96 Double_t vz,
97 Double_t time,
98 Double_t polx,
99 Double_t poly,
100 Double_t polz,
101 TMCProcess proc,
102 Int_t& ntr,
103 Double_t weight,
104 Int_t is,
105 Int_t secondParentId);
106
107 /** Get next particle for tracking from the stack.
108 ** Declared in TVirtualMCStack
109 *@param iTrack index of popped track (return)
110 *@return Pointer to the TParticle of the track
111 **/
112 virtual TParticle* PopNextTrack(Int_t& iTrack);
113
114 /** Get primary particle by index for tracking from stack
115 ** Declared in TVirtualMCStack
116 *@param iPrim index of primary particle
117 *@return Pointer to the TParticle of the track
118 **/
119 virtual TParticle* PopPrimaryForTracking(Int_t iPrim);
120
121 /** Set the current track number
122 ** Declared in TVirtualMCStack
123 *@param iTrack track number
124 **/
125 virtual void SetCurrentTrack(Int_t iTrack) { fCurrentTrack = iTrack; }
126
127 /** Get total number of tracks
128 ** Declared in TVirtualMCStack
129 **/
130 virtual Int_t GetNtrack() const { return fNParticles; }
131
132 /** Get number of primary tracks
133 ** Declared in TVirtualMCStack
134 **/
135 virtual Int_t GetNprimary() const { return fNPrimaries; }
136
137 /** Get the current track's particle
138 ** Declared in TVirtualMCStack
139 **/
140 virtual TParticle* GetCurrentTrack() const;
141
142 /** Get the number of the current track
143 ** Declared in TVirtualMCStack
144 **/
145 virtual Int_t GetCurrentTrackNumber() const { return fCurrentTrack; }
146
147 /** Get the track number of the parent of the current track
148 ** Declared in TVirtualMCStack
149 **/
150 virtual Int_t GetCurrentParentTrackNumber() const;
151
152 /** Add a TParticle to the fParticles array **/
153 virtual void AddParticle(TParticle* part);
154
155 /** Fill the MCTrack output array, applying filter criteria **/
156 virtual void FillTrackArray();
157
158 /** Update the track index in the MCTracks and MCPoints **/
159 virtual void UpdateTrackIndex(TRefArray* detArray = 0);
160
161 /** Resets arrays and stack and deletes particles and tracks **/
162 virtual void Reset();
163
164 /** Register the MCTrack array to the Root Manager **/
165 virtual void Register();
166
167 /** Output to screen: the event summary, and the track info if the log level is debug1
168 **/
169 virtual void Print(Option_t*) const;
170
171 /** Modifiers **/
172 void StoreSecondaries(Bool_t choice = kTRUE) { fStoreSecondaries = choice; }
174 void SetEnergyCut(Double_t eMin) { fEnergyCut = eMin; }
175 void SetStartZCut(Double_t zMax) { fStartZCut = zMax; }
176 void StoreMothers(Bool_t choice = kTRUE) { fStoreMothers = choice; }
177
178 /** Increment number of points for the current track in a given detector
179 *@param iDet Detector unique identifier
180 **/
181 void AddPoint(DetectorId iDet);
182
183 /** Increment number of points for an arbitrary track in a given detector
184 *@param iDet Detector unique identifier
185 *@param iTrack Track number
186 **/
187 void AddPoint(DetectorId iDet, Int_t iTrack);
188
189 /** Accessors **/
190 TParticle* GetParticle(Int_t trackId) const;
192
194 {
195 for (Int_t ipart = 0; ipart < partArray->GetEntries(); ipart++) {
196 ((TParticle*)(partArray->At(ipart)))->SetUniqueID(fNPrimaries);
197 fStack.push((TParticle*)partArray->At(ipart));
198 AddParticle((TParticle*)partArray->At(ipart));
199 fNParticles++;
200 fNPrimaries++;
201 }
202 }
203
204 void SetParticleArray(TClonesArray* partArray, Int_t partFrom, Int_t partTo)
205 {
206 for (Int_t ipart = partFrom; ipart < partTo; ipart++) {
207 ((TParticle*)(partArray->At(ipart)))->SetUniqueID(fNPrimaries);
208 ((TParticle*)(partArray->At(ipart)))->SetStatusCode(fNPrimaries);
209 fStack.push((TParticle*)partArray->At(ipart));
210 AddParticle((TParticle*)partArray->At(ipart));
211 fNParticles++;
212 fNPrimaries++;
213 }
214 }
215
216 /** Clone this object (used in MT mode only) */
218 {
219 CbmStack* clonedStack = new CbmStack();
221 clonedStack->SetMinPoints(fMinPoints);
222 clonedStack->SetEnergyCut(fEnergyCut);
223 clonedStack->StoreMothers(fStoreMothers);
224 return clonedStack;
225 }
226
227 private:
228 /** STL stack (FILO) used to handle the TParticles for tracking **/
229 std::stack<TParticle*> fStack; //!
230
231 /** Array of TParticles (contains all TParticles put into or created
232 ** by the transport
233 **/
235
236 /** Array of CbmMCTracks containg the tracks written to the output **/
238
239 /** STL map from particle index to storage flag **/
240 std::map<Int_t, Bool_t> fStoreMap; //!
241 std::map<Int_t, Bool_t>::iterator fStoreIter; //!
242
243 /** STL map from particle index to track index **/
244 std::map<Int_t, Int_t> fIndexMap; //!
245 std::map<Int_t, Int_t>::iterator fIndexIter; //!
246
247 /** STL map from track index and detector ID to number of MCPoints **/
248 std::map<std::pair<Int_t, Int_t>, Int_t> fPointsMap; //!
249
250 /** Some indizes and counters **/
251 Int_t fCurrentTrack; //! Index of current track
252 Int_t fNPrimaries; //! Number of primary particles
253 Int_t fNParticles; //! Number of entries in fParticles
254 Int_t fNTracks; //! Number of entries in fTracks
255 Int_t fIndex; //! Used for merging
256
257 /** Variables defining the criteria for output selection **/
263
264 /** Mark tracks for output using selection criteria **/
265 void SelectTracks();
266
269
270 ClassDef(CbmStack, 2);
271};
272
273#endif
Defines unique identifiers (enum) for all BM@N detector systems.
DetectorId
BM@N DetectorID enumerator.
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:30
bool Bool_t
int Int_t
double Double32_t
double Double_t
constexpr Bool_t kTRUE
const char Option_t
#define ClassDef(name, id)
Int_t fCurrentTrack
Some indizes and counters.
Definition CbmStack.h:251
Int_t fNParticles
Number of primary particles.
Definition CbmStack.h:253
virtual void UpdateTrackIndex(TRefArray *detArray=0)
Update the track index in the MCTracks and MCPoints.
Definition CbmStack.cxx:243
void SetStartZCut(Double_t zMax)
Definition CbmStack.h:175
virtual TParticle * PopNextTrack(Int_t &iTrack)
Get next particle for tracking from the stack.
Definition CbmStack.cxx:133
void StoreSecondaries(Bool_t choice=kTRUE)
Modifiers.
Definition CbmStack.h:172
CbmStack(const CbmStack &)
virtual Int_t GetCurrentParentTrackNumber() const
Get the track number of the parent of the current track Declared in TVirtualMCStack.
Definition CbmStack.cxx:380
Int_t fIndex
Number of entries in fTracks.
Definition CbmStack.h:255
std::map< Int_t, Bool_t >::iterator fStoreIter
Definition CbmStack.h:241
Int_t fNPrimaries
Index of current track.
Definition CbmStack.h:252
void AddPoint(DetectorId iDet)
Increment number of points for the current track in a given detector.
Definition CbmStack.cxx:351
virtual Int_t GetNtrack() const
Get total number of tracks Declared in TVirtualMCStack.
Definition CbmStack.h:130
Bool_t fStoreSecondaries
Used for merging.
Definition CbmStack.h:258
void StoreMothers(Bool_t choice=kTRUE)
Definition CbmStack.h:176
virtual TParticle * PopPrimaryForTracking(Int_t iPrim)
Get primary particle by index for tracking from stack Declared in TVirtualMCStack.
Definition CbmStack.cxx:157
void SetMinPoints(Int_t min)
Definition CbmStack.h:173
Int_t fMinPoints
Definition CbmStack.h:259
virtual ~CbmStack()
Destructor.
Definition CbmStack.cxx:45
std::map< Int_t, Bool_t > fStoreMap
STL map from particle index to storage flag.
Definition CbmStack.h:240
virtual void Reset()
Resets arrays and stack and deletes particles and tracks.
Definition CbmStack.cxx:314
virtual void AddParticle(TParticle *part)
Add a TParticle to the fParticles array.
Definition CbmStack.cxx:188
virtual TParticle * GetCurrentTrack() const
Get the current track's particle Declared in TVirtualMCStack.
Definition CbmStack.cxx:178
void SetEnergyCut(Double_t eMin)
Definition CbmStack.h:174
virtual void Print(Option_t *) const
Output to screen: the event summary, and the track info if the log level is debug1.
Definition CbmStack.cxx:338
TParticle * GetParticle(Int_t trackId) const
Accessors.
Definition CbmStack.cxx:391
virtual Int_t GetNprimary() const
Get number of primary tracks Declared in TVirtualMCStack.
Definition CbmStack.h:135
std::map< Int_t, Int_t >::iterator fIndexIter
Definition CbmStack.h:245
Double32_t fEnergyCut
Definition CbmStack.h:260
virtual void FillTrackArray()
Fill the MCTrack output array, applying filter criteria.
Definition CbmStack.cxx:198
Int_t fNTracks
Number of entries in fParticles.
Definition CbmStack.h:254
CbmStack(Int_t size=100)
Default constructor param size Estimated track number.
Definition CbmStack.cxx:22
std::map< Int_t, Int_t > fIndexMap
STL map from particle index to track index.
Definition CbmStack.h:244
TClonesArray * GetListOfParticles()
Definition CbmStack.h:191
virtual Int_t GetCurrentTrackNumber() const
Get the number of the current track Declared in TVirtualMCStack.
Definition CbmStack.h:145
CbmStack & operator=(const CbmStack &)
TClonesArray * fParticles
Array of TParticles (contains all TParticles put into or created by the transport.
Definition CbmStack.h:234
std::map< std::pair< Int_t, Int_t >, Int_t > fPointsMap
STL map from track index and detector ID to number of MCPoints.
Definition CbmStack.h:248
Double_t fStartZCut
Definition CbmStack.h:261
virtual void SetCurrentTrack(Int_t iTrack)
Set the current track number Declared in TVirtualMCStack.
Definition CbmStack.h:125
virtual void PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode, Double_t px, Double_t py, Double_t pz, Double_t e, Double_t vx, Double_t vy, Double_t vz, Double_t time, Double_t polx, Double_t poly, Double_t polz, TMCProcess proc, Int_t &ntr, Double_t weight, Int_t is)
Add a TParticle to the stack.
Definition CbmStack.cxx:57
void SelectTracks()
Mark tracks for output using selection criteria.
Definition CbmStack.cxx:400
virtual FairGenericStack * CloneStack() const
Clone this object (used in MT mode only).
Definition CbmStack.h:217
virtual void Register()
Register the MCTrack array to the Root Manager.
Definition CbmStack.cxx:328
std::stack< TParticle * > fStack
STL stack (FILO) used to handle the TParticles for tracking.
Definition CbmStack.h:229
TClonesArray * fTracks
Array of CbmMCTracks containg the tracks written to the output.
Definition CbmStack.h:237
void SetParticleArray(TClonesArray *partArray, Int_t partFrom, Int_t partTo)
Definition CbmStack.h:204
Bool_t fStoreMothers
Definition CbmStack.h:262
void SetParticleArray(TClonesArray *partArray)
Definition CbmStack.h:193
Int_t GetEntries() const override
TObject * At(Int_t idx) const override