FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairStack.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -------------------------------------------------------------------------
9 // ----- FairStack header file -----
10 // ----- Created 10/08/04 by D. Bertini / V. Friese -----
11 // -------------------------------------------------------------------------
12 
35 #ifndef FAIRSTACK_H
36 #define FAIRSTACK_H
37 
38 #include "FairDetectorList.h" // for DetectorId
39 #include "FairGenericStack.h" // for FairGenericStack
40 
41 #include <Rtypes.h> // for Int_t, Double_t, Bool_t, etc
42 #include <TMCProcess.h> // for TMCProcess
43 #include <TParticle.h>
44 #include <map> // for map, map<>::iterator
45 #include <stack> // for stack
46 #include <utility> // for pair
47 
48 class TClonesArray;
49 class TRefArray;
50 
52 {
53  public:
57  FairStack(Int_t size = 100);
58 
60  virtual ~FairStack();
61 
77  virtual void PushTrack(Int_t toBeDone,
78  Int_t parentID,
79  Int_t pdgCode,
80  Double_t px,
81  Double_t py,
82  Double_t pz,
83  Double_t e,
84  Double_t vx,
85  Double_t vy,
86  Double_t vz,
87  Double_t time,
88  Double_t polx,
89  Double_t poly,
90  Double_t polz,
91  TMCProcess proc,
92  Int_t& ntr,
93  Double_t weight,
94  Int_t is);
95 
96  virtual void PushTrack(Int_t toBeDone,
97  Int_t parentID,
98  Int_t pdgCode,
99  Double_t px,
100  Double_t py,
101  Double_t pz,
102  Double_t e,
103  Double_t vx,
104  Double_t vy,
105  Double_t vz,
106  Double_t time,
107  Double_t polx,
108  Double_t poly,
109  Double_t polz,
110  TMCProcess proc,
111  Int_t& ntr,
112  Double_t weight,
113  Int_t is,
114  Int_t secondParentId);
115 
121  virtual TParticle* PopNextTrack(Int_t& iTrack);
122 
128  virtual TParticle* PopPrimaryForTracking(Int_t iPrim);
129 
134  virtual void SetCurrentTrack(Int_t iTrack) { fCurrentTrack = iTrack; }
135 
139  virtual Int_t GetNtrack() const { return fNParticles; }
140 
144  virtual Int_t GetNprimary() const { return fNPrimaries; }
145 
149  virtual TParticle* GetCurrentTrack() const;
150 
154  virtual Int_t GetCurrentTrackNumber() const; // { return fCurrentTrack; }
155 
159  virtual Int_t GetCurrentParentTrackNumber() const;
160 
162  virtual void AddParticle(TParticle* part);
163 
165  virtual void FillTrackArray();
166 
168  virtual void UpdateTrackIndex(TRefArray* detArray = 0);
169 
171  virtual void Reset();
172 
174  virtual void Register();
175 
179  virtual void Print(Option_t*) const;
180 
182  void StoreSecondaries(Bool_t choice = kTRUE) { fStoreSecondaries = choice; }
183  void SetMinPoints(Int_t min) { fMinPoints = min; }
184  void SetEnergyCut(Double_t eMin) { fEnergyCut = eMin; }
185  void StoreMothers(Bool_t choice = kTRUE) { fStoreMothers = choice; }
186 
190  void AddPoint(DetectorId iDet);
191 
196  void AddPoint(DetectorId iDet, Int_t iTrack);
197 
199  TParticle* GetParticle(Int_t trackId) const;
200  TClonesArray* GetListOfParticles() { return fParticles; }
201 
202  void SetParticleArray(TClonesArray* partArray)
203  {
204  for (Int_t ipart = 0; ipart < partArray->GetEntries(); ipart++) {
205  ((TParticle*)(partArray->At(ipart)))->SetUniqueID(fNPrimaries);
206  fStack.push((TParticle*)partArray->At(ipart));
207  AddParticle((TParticle*)partArray->At(ipart));
208  fNParticles++;
209  fNPrimaries++;
210  }
211  }
212 
213  void SetParticleArray(TClonesArray* partArray, Int_t partFrom, Int_t partTo)
214  {
215  for (Int_t ipart = partFrom; ipart < partTo; ipart++) {
216  ((TParticle*)(partArray->At(ipart)))->SetUniqueID(fNPrimaries);
217  ((TParticle*)(partArray->At(ipart)))->SetStatusCode(fNPrimaries);
218  fStack.push((TParticle*)partArray->At(ipart));
219  AddParticle((TParticle*)partArray->At(ipart));
220  fNParticles++;
221  fNPrimaries++;
222  }
223  }
224 
226  virtual FairGenericStack* CloneStack() const
227  {
228  FairStack* clonedStack = new FairStack();
229  clonedStack->StoreSecondaries(fStoreSecondaries);
230  clonedStack->SetMinPoints(fMinPoints);
231  clonedStack->SetEnergyCut(fEnergyCut);
232  clonedStack->StoreMothers(fStoreMothers);
233  return clonedStack;
234  }
235 
236  private:
238  std::stack<TParticle*> fStack;
239 
243  TClonesArray* fParticles;
244 
246  TClonesArray* fTracks;
247 
249  std::map<Int_t, Bool_t> fStoreMap;
250  std::map<Int_t, Bool_t>::iterator fStoreIter;
251 
253  std::map<Int_t, Int_t> fIndexMap;
254  std::map<Int_t, Int_t>::iterator fIndexIter;
255 
257  std::map<std::pair<Int_t, Int_t>, Int_t> fPointsMap;
258 
260  Int_t fCurrentTrack;
261  Int_t fNPrimaries;
262  Int_t fNParticles;
263  Int_t fNTracks;
264  Int_t fIndex;
265 
267  Bool_t fStoreSecondaries;
268  Int_t fMinPoints;
269  Double32_t fEnergyCut;
270  Bool_t fStoreMothers;
271 
273  void SelectTracks();
274 
275  FairStack(const FairStack&);
276  FairStack& operator=(const FairStack&);
277 
278  ClassDef(FairStack, 1);
279 };
280 
281 #endif
DetectorId
virtual void Print(Option_t *) const
Definition: FairStack.cxx:332
virtual TParticle * PopNextTrack(Int_t &iTrack)
Definition: FairStack.cxx:137
virtual FairGenericStack * CloneStack() const
Definition: FairStack.h:226
virtual Int_t GetCurrentTrackNumber() const
Definition: FairStack.cxx:242
void SetParticleArray(TClonesArray *partArray, Int_t partFrom, Int_t partTo)
Definition: FairStack.h:213
void SetMinPoints(Int_t min)
Definition: FairStack.h:183
virtual TParticle * GetCurrentTrack() const
Definition: FairStack.cxx:180
virtual Int_t GetCurrentParentTrackNumber() const
Definition: FairStack.cxx:380
virtual Int_t GetNtrack() const
Definition: FairStack.h:139
virtual void AddParticle(TParticle *part)
Definition: FairStack.cxx:189
virtual void Reset()
Definition: FairStack.cxx:309
virtual TParticle * PopPrimaryForTracking(Int_t iPrim)
Definition: FairStack.cxx:160
TClonesArray * GetListOfParticles()
Definition: FairStack.h:200
virtual void UpdateTrackIndex(TRefArray *detArray=0)
Definition: FairStack.cxx:252
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)
Definition: FairStack.cxx:63
void SetParticleArray(TClonesArray *partArray)
Definition: FairStack.h:202
virtual Int_t GetNprimary() const
Definition: FairStack.h:144
virtual void Register()
Definition: FairStack.cxx:323
void SetEnergyCut(Double_t eMin)
Definition: FairStack.h:184
virtual void FillTrackArray()
Definition: FairStack.cxx:198
FairStack(Int_t size=100)
Definition: FairStack.cxx:30
virtual ~FairStack()
Definition: FairStack.cxx:51
void AddPoint(DetectorId iDet)
Definition: FairStack.cxx:344
void StoreSecondaries(Bool_t choice=kTRUE)
Definition: FairStack.h:182
void StoreMothers(Bool_t choice=kTRUE)
Definition: FairStack.h:185
virtual void SetCurrentTrack(Int_t iTrack)
Definition: FairStack.h:134
TParticle * GetParticle(Int_t trackId) const
Definition: FairStack.cxx:390