forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.h
More file actions
228 lines (182 loc) · 6.98 KB
/
Stack.h
File metadata and controls
228 lines (182 loc) · 6.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/// \file Stack.h
/// \brief Definition of the Stack class
/// \author M. Al-Turany - June 2014
#ifndef ALICEO2_DATA_STACK_H_
#define ALICEO2_DATA_STACK_H_
#include "FairGenericStack.h"
#include "DetectorList.h"
#include "Rtypes.h"
#include "TMCProcess.h"
#include <map>
#include <stack>
#include <utility>
class TClonesArray;
class TParticle;
class TRefArray;
class FairLogger;
namespace AliceO2 {
namespace Data {
/// This class handles the particle stack for the transport simulation.
/// For the stack FILO functunality, it uses the STL stack. To store
/// the tracks during transport, a TParticle array is used.
/// At the end of the event, tracks satisfying the filter criteria
/// are copied to a MCTrack array, which is stored in the output.
///
/// The filtering criteria for the output tracks are:
/// - primary tracks are stored in any case.
/// - secondary tracks are stored if they have a minimal number of
/// points (sum of all detectors) and a minimal energy, or are the
///
/// The storage of secondaries can be switched off.
/// The storage of all mothers can be switched off.
/// By default, the minimal number of points is 1 and the energy cut is 0.
class Stack : public FairGenericStack {
public:
/// Default constructor
/// \param size Estimated track number
Stack(Int_t size = 100);
/// Default destructor
virtual ~Stack();
/// Add a TParticle to the stack.
/// Declared in TVirtualMCStack
/// \param toBeDone Flag for tracking
/// \param parentID Index of mother particle
/// \param pdgCode Particle type (PDG encoding)
/// \param px,py,pz Momentum components at start vertex [GeV]
/// \param e Total energy at start vertex [GeV]
/// \param vx,vy,vz Coordinates of start vertex [cm]
/// \param time Start time of track [s]
/// \param polx,poly,polz Polarisation vector
/// \param proc Production mechanism (VMC encoding)
/// \param ntr Track number (filled by the stack)
/// \param weight Particle weight
/// \param is Generation status code (whatever that means)
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);
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, Int_t secondParentId);
/// Get next particle for tracking from the stack.
/// Declared in TVirtualMCStack
/// Returns a pointer to the TParticle of the track
/// \param iTrack index of popped track (return)
virtual TParticle* PopNextTrack(Int_t& iTrack);
/// Get primary particle by index for tracking from stack
/// Declared in TVirtualMCStack
/// Returns a pointer to the TParticle of the track
/// \param iPrim index of primary particle
virtual TParticle* PopPrimaryForTracking(Int_t iPrim);
/// Set the current track number
/// Declared in TVirtualMCStack
/// \param iTrack track number
virtual void SetCurrentTrack(Int_t iTrack)
{
mIndexOfCurrentTrack = iTrack;
}
/// Get total number of tracks
/// Declared in TVirtualMCStack
virtual Int_t GetNtrack() const
{
return mNumberOfEntriesInParticles;
}
/// Get number of primary tracks
/// Declared in TVirtualMCStack
virtual Int_t GetNprimary() const
{
return mNumberOfPrimaryParticles;
}
/// Get the current track's particle
/// Declared in TVirtualMCStack
virtual TParticle* GetCurrentTrack() const;
/// Get the number of the current track
/// Declared in TVirtualMCStack
virtual Int_t GetCurrentTrackNumber() const
{
return mIndexOfCurrentTrack;
}
/// Get the track number of the parent of the current track
/// Declared in TVirtualMCStack
virtual Int_t GetCurrentParentTrackNumber() const;
/// Add a TParticle to the mParticles array
virtual void AddParticle(TParticle* part);
/// Fill the MCTrack output array, applying filter criteria
virtual void FillTrackArray();
/// Update the track index in the MCTracks and MCPoints
virtual void UpdateTrackIndex(TRefArray* detArray = 0);
/// Resets arrays and stack and deletes particles and tracks
virtual void Reset();
/// Register the MCTrack array to the Root Manager
virtual void Register();
/// Output to screen
/// \param iVerbose: 0=events summary, 1=track info
virtual void Print(Int_t iVerbose = 0) const;
/// Modifiers
void StoreSecondaries(Bool_t choice = kTRUE)
{
mStoreSecondaries = choice;
}
void SetMinPoints(Int_t min)
{
mMinPoints = min;
}
void SetEnergyCut(Double_t eMin)
{
mEnergyCut = eMin;
}
void StoreMothers(Bool_t choice = kTRUE)
{
mStoreMothers = choice;
}
/// Increment number of points for the current track in a given detector
/// \param iDet Detector unique identifier
void AddPoint(DetectorId iDet);
/// Increment number of points for an arbitrary track in a given detector
/// \param iDet Detector unique identifier
/// \param iTrack Track number
void AddPoint(DetectorId iDet, Int_t iTrack);
/// Accessors
TParticle* GetParticle(Int_t trackId) const;
TClonesArray* GetListOmParticles()
{
return mParticles;
}
/// Clone for worker (used in MT mode only)
virtual FairGenericStack* CloneStack() const;
private:
FairLogger* mLogger;
/// STL stack (FILO) used to handle the TParticles for tracking
std::stack<TParticle*> mStack; //!
/// Array of TParticles (contains all TParticles put into or created
/// by the transport
TClonesArray* mParticles; //!
/// Array of FairMCTracks containg the tracks written to the output
TClonesArray* mTracks;
/// STL map from particle index to storage flag
std::map<Int_t, Bool_t> mStoreMap; //!
std::map<Int_t, Bool_t>::iterator mStoreIterator; //!
/// STL map from particle index to track index
std::map<Int_t, Int_t> mIndexMap; //!
std::map<Int_t, Int_t>::iterator mIndexIterator; //!
/// STL map from track index and detector ID to number of MCPoints
std::map<std::pair<Int_t, Int_t>, Int_t> mPointsMap; //!
/// Some indices and counters
Int_t mIndexOfCurrentTrack; //! Index of current track
Int_t mNumberOfPrimaryParticles; //! Number of primary particles
Int_t mNumberOfEntriesInParticles; //! Number of entries in mParticles
Int_t mNumberOfEntriesInTracks; //! Number of entries in mTracks
Int_t mIndex; //! Used for merging
/// Variables defining the criteria for output selection
Bool_t mStoreMothers;
Bool_t mStoreSecondaries;
Int_t mMinPoints;
Double32_t mEnergyCut;
/// Mark tracks for output using selection criteria
void SelectTracks();
Stack(const Stack&);
Stack& operator=(const Stack&);
ClassDef(Stack, 1)
};
}
}
#endif