FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndStack Class Reference

#include <PndStack.h>

Inheritance diagram for PndStack:

Public Member Functions

 PndStack (Int_t size=100)
 
virtual ~PndStack ()
 
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)
 
virtual TParticle * PopNextTrack (Int_t &iTrack)
 
virtual TParticle * PopPrimaryForTracking (Int_t iPrim)
 
virtual void SetCurrentTrack (Int_t iTrack)
 
virtual Int_t GetNtrack () const
 
virtual Int_t GetNprimary () const
 
virtual TParticle * GetCurrentTrack () const
 
virtual Int_t GetCurrentTrackNumber () const
 
virtual Int_t GetCurrentParentTrackNumber () const
 
virtual void AddParticle (TParticle *part)
 
virtual void FillTrackArray ()
 
virtual void UpdateTrackIndex (TRefArray *detArray)
 
virtual void Reset ()
 
virtual void Register ()
 
virtual void Print (Int_t iVerbose=0) const
 
void StoreSecondaries (Bool_t choice=kTRUE)
 
void SetMinPoints (Int_t min)
 
void SetEnergyCut (Double_t eMin)
 
void StoreMothers (Bool_t choice=kTRUE)
 
void SetPersistence (Bool_t choice)
 
void AddPoint (DetectorId iDet)
 
void AddPoint (DetectorId iDet, Int_t iTrack)
 
TParticle * GetParticle (Int_t trackId) const
 
TClonesArray * GetListOfParticles ()
 

Private Member Functions

void SelectTracks ()
 
void SetGeneratorFlags (Int_t myid)
 
 PndStack (const PndStack &L)
 
PndStackoperator= (const PndStack &)
 

Private Attributes

std::stack< TParticle * > fStack
 
TClonesArray * fParticles
 
TClonesArray * fTracks
 
std::map< Int_t, Bool_tfStoreMap
 
std::map< Int_t, Bool_t >::iterator fStoreIter
 
std::map< Int_t, Int_t > fIndexMap
 
std::map< Int_t, Int_t >::iterator fIndexIter
 
std::map< std::pair< Int_t,
Int_t >, Int_t > 
fPointsMap
 
Int_t fCurrentTrack
 
Int_t fNPrimaries
 Index of current track. More...
 
Int_t fNParticles
 Number of primary particles. More...
 
Int_t fNTracks
 Number of entries in fParticles. More...
 
Int_t fIndex
 Number of entries in fTracks. More...
 
Bool_t fStoreSecondaries
 Used for merging. More...
 
Int_t fMinPoints
 
Double32_t fEnergyCut
 
Bool_t fStoreMothers
 
Bool_t fPersistence
 

Detailed Description

Definition at line 45 of file PndStack.h.

Constructor & Destructor Documentation

PndStack::PndStack ( Int_t  size = 100)

Default constructor param size Estimated track number

Definition at line 27 of file PndStack.cxx.

References fIndexMap, fParticles, fPointsMap, fStoreMap, and fTracks.

27  :
29 {
30  fStoreMap.clear();
31  fIndexMap.clear();
32  fPointsMap.clear();
33  fParticles = new TClonesArray("TParticle", size);
34  fTracks = new TClonesArray("PndMCTrack", size);
35 }
TClonesArray * fTracks
Definition: PndStack.h:210
std::map< std::pair< Int_t, Int_t >, Int_t > fPointsMap
Definition: PndStack.h:224
Bool_t fStoreMothers
Definition: PndStack.h:239
Bool_t fPersistence
Definition: PndStack.h:240
Int_t fIndex
Number of entries in fTracks.
Definition: PndStack.h:232
Bool_t fStoreSecondaries
Used for merging.
Definition: PndStack.h:236
std::map< Int_t, Int_t >::iterator fIndexIter
Definition: PndStack.h:220
Int_t fMinPoints
Definition: PndStack.h:237
std::map< Int_t, Bool_t >::iterator fStoreIter
Definition: PndStack.h:215
std::map< Int_t, Bool_t > fStoreMap
Definition: PndStack.h:214
std::stack< TParticle * > fStack
Definition: PndStack.h:200
Int_t fNTracks
Number of entries in fParticles.
Definition: PndStack.h:231
std::map< Int_t, Int_t > fIndexMap
Definition: PndStack.h:219
Int_t fNParticles
Number of primary particles.
Definition: PndStack.h:230
Double32_t fEnergyCut
Definition: PndStack.h:238
Int_t fNPrimaries
Index of current track.
Definition: PndStack.h:229
TClonesArray * fParticles
Definition: PndStack.h:206
Int_t fCurrentTrack
Definition: PndStack.h:228
PndStack::~PndStack ( )
virtual

Destructor

Definition at line 42 of file PndStack.cxx.

References fParticles, and fTracks.

42  {
43  if (fParticles) {
44  fParticles->Delete();
45  delete fParticles;
46  }
47  if (fTracks) {
48  fTracks->Delete();
49  delete fTracks;
50  }
51 }
TClonesArray * fTracks
Definition: PndStack.h:210
TClonesArray * fParticles
Definition: PndStack.h:206
PndStack::PndStack ( const PndStack L)
private

Member Function Documentation

void PndStack::AddParticle ( TParticle *  part)
virtual

Add a TParticle to the fParticles array

Definition at line 186 of file PndStack.cxx.

References fIndex, and fParticles.

186  {
187  TClonesArray& array = *fParticles;
188  TParticle* newPart = new(array[fIndex]) TParticle(*oldPart);
189  newPart->SetWeight(oldPart->GetWeight());
190  newPart->SetUniqueID(oldPart->GetUniqueID());
191  fIndex++;
192 }
Int_t fIndex
Number of entries in fTracks.
Definition: PndStack.h:232
TClonesArray * fParticles
Definition: PndStack.h:206
void PndStack::AddPoint ( DetectorId  iDet)

Increment number of points for the current track in a given detector

Parameters
iDetDetector unique identifier

Definition at line 408 of file PndStack.cxx.

References a, fCurrentTrack, and fPointsMap.

Referenced by PndRich::ProcessHits(), PndFts2::ProcessHits(), PndFts::ProcessHits(), PndFtof::ProcessHits(), PndEmc::ProcessHits(), PndGemDetector::ProcessHits(), PndSciT::ProcessHits(), PndStt::ProcessHits(), PndDrc::ProcessHits(), PndSdsDetector::ProcessHits(), PndDsk::ProcessHitsCerenkov(), PndDsk::ProcessHitsCerenkov_FLG(), PndMdt::ProcessHitsFast(), PndDsk::ProcessHitsParticle(), and PndMdt::ProcessHitsRoot().

408  {
409  Int_t iDet = detId;
410  pair<Int_t, Int_t> a(fCurrentTrack, iDet);
411  if ( fPointsMap.find(a) == fPointsMap.end() ) fPointsMap[a] = 1;
412  else fPointsMap[a]++;
413 }
std::map< std::pair< Int_t, Int_t >, Int_t > fPointsMap
Definition: PndStack.h:224
Int_t a
Definition: anaLmdDigi.C:126
Int_t fCurrentTrack
Definition: PndStack.h:228
void PndStack::AddPoint ( DetectorId  iDet,
Int_t  iTrack 
)

Increment number of points for an arbitrary track in a given detector

Parameters
iDetDetector unique identifier
iTrackTrack number

Definition at line 419 of file PndStack.cxx.

References a, and fPointsMap.

419  {
420  if ( iTrack < 0 ) return;
421  Int_t iDet = detId;
422  pair<Int_t, Int_t> a(iTrack, iDet);
423  if ( fPointsMap.find(a) == fPointsMap.end() ) fPointsMap[a] = 1;
424  else fPointsMap[a]++;
425 }
std::map< std::pair< Int_t, Int_t >, Int_t > fPointsMap
Definition: PndStack.h:224
Int_t a
Definition: anaLmdDigi.C:126
void PndStack::FillTrackArray ( )
virtual

Fill the MCTrack output array, applying filter criteria

Definition at line 198 of file PndStack.cxx.

References a, Bool_t, DEBUG, fIndexMap, fNParticles, fNTracks, fPointsMap, fStoreIter, fStoreMap, GetParticle(), kHYP, kRICH, Print(), SelectTracks(), SetGeneratorFlags(), PndMCTrack::SetNPoints(), store(), and track.

198  {
199 
200  LOG(DEBUG) << "PndStack: Filling MCTrack array..." ;
201 
202  // --> Reset index map and number of output tracks
203  fIndexMap.clear();
204  fNTracks = 0;
205 
206  // --> Check tracks for selection criteria
207  SelectTracks();
208 
209  // --> Loop over fParticles array and copy selected tracks
210  for (Int_t iPart=0; iPart<fNParticles; iPart++) {
211 
212  fStoreIter = fStoreMap.find(iPart);
213  if (fStoreIter == fStoreMap.end() ) {
214  LOG(ERROR) << "PndStack: Particle "<<iPart<<" not found in storage map!" ;
215  Fatal("PndStack::FillTrackArray","Particle not found in storage map.");
216  }
217  Bool_t store = (*fStoreIter).second;
218 
219  if (store) {
220  PndMCTrack* track =
221  new( (*fTracks)[fNTracks]) PndMCTrack(GetParticle(iPart));
222  fIndexMap[iPart] = fNTracks;
223  // --> Set the number of points in the detectors for this track
224  for (Int_t iDet=kRICH; iDet<=kHYP; iDet++) {
225  pair<Int_t, Int_t> a(iPart, iDet);
226  track->SetNPoints(iDet, fPointsMap[a]);
227  }
228 
229  SetGeneratorFlags(iPart);
230 
231  fNTracks++;
232 
233  }else{
234  fIndexMap[iPart] = -2;
235  }
236 
237  }
238 
239  // --> Map index for primary mothers
240  fIndexMap[-1] = -1;
241 
242  // --> Screen output
243  Print(0);
244 
245 }
std::map< std::pair< Int_t, Int_t >, Int_t > fPointsMap
Definition: PndStack.h:224
PndRiemannTrack track
Definition: RiemannTest.C:33
void SetNPoints(Int_t iDet, Int_t np)
Definition: PndMCTrack.cxx:143
TParticle * GetParticle(Int_t trackId) const
Definition: PndStack.cxx:442
virtual void Print(Int_t iVerbose=0) const
Definition: PndStack.cxx:393
#define DEBUG
std::map< Int_t, Bool_t >::iterator fStoreIter
Definition: PndStack.h:215
std::map< Int_t, Bool_t > fStoreMap
Definition: PndStack.h:214
Int_t a
Definition: anaLmdDigi.C:126
void SetGeneratorFlags(Int_t myid)
Definition: PndStack.cxx:248
Int_t fNTracks
Number of entries in fParticles.
Definition: PndStack.h:231
std::map< Int_t, Int_t > fIndexMap
Definition: PndStack.h:219
vector< FitStore > store(3000)
Int_t fNParticles
Number of primary particles.
Definition: PndStack.h:230
void SelectTracks()
Definition: PndStack.cxx:454
Int_t PndStack::GetCurrentParentTrackNumber ( ) const
virtual

Get the track number of the parent of the current track Declared in TVirtualMCStack

Definition at line 432 of file PndStack.cxx.

References GetCurrentTrack().

432  {
433  TParticle* currentPart = GetCurrentTrack();
434  if ( currentPart ) return currentPart->GetFirstMother();
435  else return -1;
436 }
virtual TParticle * GetCurrentTrack() const
Definition: PndStack.cxx:173
TParticle * PndStack::GetCurrentTrack ( ) const
virtual

Get the current track's particle Declared in TVirtualMCStack

Definition at line 173 of file PndStack.cxx.

References fCurrentTrack, and GetParticle().

Referenced by GetCurrentParentTrackNumber().

173  {
174  TParticle* currentPart = GetParticle(fCurrentTrack);
175  if ( ! currentPart) {
176  LOG(WARNING) << "PndStack: Current track not found in stack!" ;
177  Warning("PndStack::GetCurrentTrack", "Track not found in stack");
178  }
179  return currentPart;
180 }
TParticle * GetParticle(Int_t trackId) const
Definition: PndStack.cxx:442
Int_t fCurrentTrack
Definition: PndStack.h:228
virtual Int_t PndStack::GetCurrentTrackNumber ( ) const
inlinevirtual

Get the number of the current track Declared in TVirtualMCStack

Definition at line 134 of file PndStack.h.

References fCurrentTrack.

134 { return fCurrentTrack; }
Int_t fCurrentTrack
Definition: PndStack.h:228
TClonesArray* PndStack::GetListOfParticles ( )
inline

Definition at line 192 of file PndStack.h.

References fParticles.

192 { return fParticles; }
TClonesArray * fParticles
Definition: PndStack.h:206
virtual Int_t PndStack::GetNprimary ( ) const
inlinevirtual

Get number of primary tracks Declared in TVirtualMCStack

Definition at line 122 of file PndStack.h.

References fNPrimaries.

122 { return fNPrimaries; }
Int_t fNPrimaries
Index of current track.
Definition: PndStack.h:229
virtual Int_t PndStack::GetNtrack ( ) const
inlinevirtual

Get total number of tracks Declared in TVirtualMCStack

Definition at line 116 of file PndStack.h.

References fNParticles.

Referenced by PndFastSim::Exec().

116 { return fNParticles; }
Int_t fNParticles
Number of primary particles.
Definition: PndStack.h:230
TParticle * PndStack::GetParticle ( Int_t  trackId) const

Accessors

Definition at line 442 of file PndStack.cxx.

References fNParticles, and fParticles.

Referenced by PndFastSim::Exec(), FillTrackArray(), GetCurrentTrack(), and SelectTracks().

442  {
443  if (trackID < 0 || trackID >= fNParticles) {
444  LOG(ERROR) << "PndStack: Particle index out of range." << trackID ;
445  Fatal("PndStack::GetParticle", "Index out of range");
446  }
447  return (TParticle*)fParticles->At(trackID);
448 }
Int_t fNParticles
Number of primary particles.
Definition: PndStack.h:230
TClonesArray * fParticles
Definition: PndStack.h:206
PndStack& PndStack::operator= ( const PndStack )
inlineprivate

Definition at line 248 of file PndStack.h.

248 {return *this;};
TParticle * PndStack::PopNextTrack ( Int_t &  iTrack)
virtual

Get next particle for tracking from the stack. Declared in TVirtualMCStack

Parameters
iTrackindex of popped track (return)
Returns
Pointer to the TParticle of the track

Definition at line 116 of file PndStack.cxx.

References fCurrentTrack, and fStack.

116  {
117 
118  // If end of stack: Return empty pointer
119  if (fStack.empty()) {
120  iTrack = -1;
121  return NULL;
122  }
123 
124  // If not, get next particle from stack
125  TParticle* thisParticle = fStack.top();
126  fStack.pop();
127 
128  if ( !thisParticle) {
129  iTrack = 0;
130  return NULL;
131  }
132 
133  fCurrentTrack = thisParticle->GetStatusCode();
134  iTrack = fCurrentTrack;
135 
136  return thisParticle;
137 
138 }
std::stack< TParticle * > fStack
Definition: PndStack.h:200
Int_t fCurrentTrack
Definition: PndStack.h:228
TParticle * PndStack::PopPrimaryForTracking ( Int_t  iPrim)
virtual

Get primary particle by index for tracking from stack Declared in TVirtualMCStack

Parameters
iPrimindex of primary particle
Returns
Pointer to the TParticle of the track

Definition at line 144 of file PndStack.cxx.

References fNPrimaries, fParticles, and kDoneBit.

144  {
145 
146  // Get the iPrimth particle from the fStack TClonesArray. This
147  // should be a primary (if the index is correct).
148 
149  // Test for index
150  if (iPrim < 0 || iPrim >= fNPrimaries) {
151  LOG(ERROR) << "PndStack: Primary index out of range! " << iPrim ;
152  Fatal("PndStack::PopPrimaryForTracking", "Index out of range");
153  }
154 
155  // Return the iPrim-th TParticle from the fParticle array. This should be
156  // a primary.
157  TParticle* part = (TParticle*)fParticles->At(iPrim);
158 
159  if ( ! (part->GetMother(0) < 0) ) {
160  LOG(ERROR) << "PndStack:: Not a primary track! , " <<iPrim ;
161  Fatal("PndStack::PopPrimaryForTracking", "Not a primary track");
162  }
163 
164  if(!part->TestBit(kDoneBit)) return NULL;
165  else return part;
166 
167 }
Int_t fNPrimaries
Index of current track.
Definition: PndStack.h:229
TClonesArray * fParticles
Definition: PndStack.h:206
void PndStack::Print ( Int_t  iVerbose = 0) const
virtual

Output to screen

Parameters
iVerbose0=events summary, 1=track info

Definition at line 393 of file PndStack.cxx.

References DEBUG, fNParticles, fNPrimaries, fNTracks, and fTracks.

Referenced by FillTrackArray().

393  {
394  LOG(DEBUG) << " PndStack: Number of primaries = " <<fNPrimaries
395  << "\n Total number of particles = " << fNParticles
396  << "\n Number of tracks in output = " << fNTracks ;
397 
398  if (iVerbose) {
399  for (Int_t iTrack=0; iTrack<fNTracks; iTrack++)
400  ((PndMCTrack*) fTracks->At(iTrack))->Print(iTrack);
401  }
402 }
TClonesArray * fTracks
Definition: PndStack.h:210
virtual void Print(Int_t iVerbose=0) const
Definition: PndStack.cxx:393
#define DEBUG
Int_t fNTracks
Number of entries in fParticles.
Definition: PndStack.h:231
Int_t fNParticles
Number of primary particles.
Definition: PndStack.h:230
Int_t iVerbose
Int_t fNPrimaries
Index of current track.
Definition: PndStack.h:229
void PndStack::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

Add a TParticle to the stack. Declared in TVirtualMCStack

Parameters
toBeDoneFlag for tracking
parentIDIndex of mother particle
pdgCodeParticle type (PDG encoding)
px,py,pzMomentum components at start vertex [GeV]
eTotal energy at start vertex [GeV]
vx,vy,vzCoordinates of start vertex [cm]
timeStart time of track [s]
polx,poly,polzPolarisation vector
procProduction mechanism (VMC encoding)
ntrTrack number (filled by the stack)
weightParticle weight
isGeneration status code (whatever that means)

Definition at line 57 of file PndStack.cxx.

Referenced by PndFastSim::Exec().

62  {
63 
64  PushTrack( toBeDone, parentId, pdgCode,
65  px, py, pz,
66  e, vx, vy, vz,
67  time, polx, poly,
68  polz, proc, ntr,
69  weight, is, -1);
70 }
static int is
Definition: ranlxd.cxx:374
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: PndStack.cxx:57
double pz[39]
Definition: pipisigmas.h:14
void PndStack::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 
)
virtual

Definition at line 73 of file PndStack.cxx.

References fNParticles, fNPrimaries, fParticles, fStack, kDoneBit, and particle.

78  {
79 
80  (void)is; // To remove "unused" warnings
81  // --> Get TParticle array
82  TClonesArray& partArray = *fParticles;
83 
84  // --> Create new TParticle and add it to the TParticle array
85  Int_t trackId = fNParticles;
86  Int_t nPoints = 0;
87  Int_t daughter1Id = -1;
88  Int_t daughter2Id = -1;
89  TParticle* particle =
90  new(partArray[fNParticles++]) TParticle(pdgCode, trackId, parentId,
91  nPoints, daughter1Id,
92  daughter2Id, px, py, pz, e,
93  vx, vy, vz, time);
94  particle->SetLastMother(secondparentID);
95  particle->SetPolarisation(polx, poly, polz);
96  particle->SetWeight(weight);
97  particle->SetUniqueID(proc);
98 
99  // --> Increment counter
100  if (parentId < 0) fNPrimaries++;
101 
102  // --> Set argument variable
103  ntr = trackId;
104 
105  // --> Push particle on the stack if toBeDone is set
106  if (toBeDone == 1) {
107  particle->SetBit(kDoneBit);
108  fStack.push(particle);
109  }
110 }
const int particle
std::stack< TParticle * > fStack
Definition: PndStack.h:200
static int is
Definition: ranlxd.cxx:374
Int_t fNParticles
Number of primary particles.
Definition: PndStack.h:230
Int_t fNPrimaries
Index of current track.
Definition: PndStack.h:229
TClonesArray * fParticles
Definition: PndStack.h:206
double pz[39]
Definition: pipisigmas.h:14
void PndStack::Register ( )
virtual

Register the MCTrack array to the Root Manager

Definition at line 385 of file PndStack.cxx.

References fPersistence, and fTracks.

385  {
386  FairRootManager::Instance()->Register("MCTrack", "Stack", fTracks, fPersistence);
387 }
TClonesArray * fTracks
Definition: PndStack.h:210
Bool_t fPersistence
Definition: PndStack.h:240
void PndStack::Reset ( )
virtual

Resets arrays and stack and deletes particles and tracks

Definition at line 371 of file PndStack.cxx.

References fCurrentTrack, fIndex, fNParticles, fNPrimaries, fNTracks, fParticles, fPointsMap, fStack, and fTracks.

371  {
372  fIndex = 0;
373  fCurrentTrack = -1;
375  while (! fStack.empty() ) fStack.pop();
376  fParticles->Clear();
377  fTracks->Clear();
378  fPointsMap.clear();
379 }
TClonesArray * fTracks
Definition: PndStack.h:210
std::map< std::pair< Int_t, Int_t >, Int_t > fPointsMap
Definition: PndStack.h:224
Int_t fIndex
Number of entries in fTracks.
Definition: PndStack.h:232
std::stack< TParticle * > fStack
Definition: PndStack.h:200
Int_t fNTracks
Number of entries in fParticles.
Definition: PndStack.h:231
Int_t fNParticles
Number of primary particles.
Definition: PndStack.h:230
Int_t fNPrimaries
Index of current track.
Definition: PndStack.h:229
TClonesArray * fParticles
Definition: PndStack.h:206
Int_t fCurrentTrack
Definition: PndStack.h:228
void PndStack::SelectTracks ( )
private

Mark tracks for output using selection criteria

Definition at line 454 of file PndStack.cxx.

References a, Bool_t, Double_t, energy, fEnergyCut, fMinPoints, fNParticles, fPointsMap, fStoreMap, fStoreMothers, fStoreSecondaries, GetParticle(), i, kHYP, kRICH, p, and store().

Referenced by FillTrackArray().

454  {
455 
456  // --> Clear storage map
457  fStoreMap.clear();
458 
459  // --> Check particles in the fParticle array
460  for (Int_t i=0; i<fNParticles; i++) {
461 
462  TParticle* thisPart = GetParticle(i);
463  Bool_t store = kTRUE;
464 
465  // --> Get track parameters
466  Int_t iMother = thisPart->GetMother(0);
467  TLorentzVector p;
468  thisPart->Momentum(p);
469  Double_t energy = p.E();
470  Double_t mass = p.M();
471 // Double_t mass = thisPart->GetMass();// Why?? Mass (given by generator) is inside by Lorentzvector!!! I dont care about PSG mass!
472  Double_t eKin = energy - mass;
473  if(eKin < 0.0) eKin=0.0; // sometimes due to different PDG masses between ROOT and G4!!!!!!
474  // --> Calculate number of points
475  Int_t nPoints = 0;
476  for (Int_t iDet=kRICH; iDet<=kHYP; iDet++) {
477  pair<Int_t, Int_t> a(i, iDet);
478  if ( fPointsMap.find(a) != fPointsMap.end() )
479  nPoints += fPointsMap[a];
480  }
481 
482  // --> Check for cuts (store primaries in any case)
483  if (iMother < 0) store = kTRUE;
484  else {
485  if (!fStoreSecondaries) store = kFALSE;
486  if (nPoints < fMinPoints) store = kFALSE;
487  if (eKin < fEnergyCut) store = kFALSE;
488  }
489 
490  // --> Set storage flag
491  fStoreMap[i] = store;
492 
493  }
494 
495  // --> If flag is set, flag recursively mothers of selected tracks
496  if (fStoreMothers) {
497  for (Int_t i=0; i<fNParticles; i++) {
498  if (fStoreMap[i]) {
499  Int_t iMother = GetParticle(i)->GetMother(0);
500  while(iMother >= 0) {
501  fStoreMap[iMother] = kTRUE;
502  iMother = GetParticle(iMother)->GetMother(0);
503  }
504  }
505  }
506  }
507 
508 }
std::map< std::pair< Int_t, Int_t >, Int_t > fPointsMap
Definition: PndStack.h:224
Int_t i
Definition: run_full.C:25
TParticle * GetParticle(Int_t trackId) const
Definition: PndStack.cxx:442
Bool_t fStoreMothers
Definition: PndStack.h:239
Bool_t fStoreSecondaries
Used for merging.
Definition: PndStack.h:236
Double_t p
Definition: anasim.C:58
Int_t fMinPoints
Definition: PndStack.h:237
std::map< Int_t, Bool_t > fStoreMap
Definition: PndStack.h:214
Int_t a
Definition: anaLmdDigi.C:126
Double_t
vector< FitStore > store(3000)
Int_t fNParticles
Number of primary particles.
Definition: PndStack.h:230
Double32_t fEnergyCut
Definition: PndStack.h:238
Double_t energy
Definition: plot_dirc.C:15
virtual void PndStack::SetCurrentTrack ( Int_t  iTrack)
inlinevirtual

Set the current track number Declared in TVirtualMCStack

Parameters
iTracktrack number

Definition at line 110 of file PndStack.h.

References fCurrentTrack.

110 { fCurrentTrack = iTrack; }
Int_t fCurrentTrack
Definition: PndStack.h:228
void PndStack::SetEnergyCut ( Double_t  eMin)
inline

Definition at line 172 of file PndStack.h.

References fEnergyCut.

172 { fEnergyCut = eMin; }
Double32_t fEnergyCut
Definition: PndStack.h:238
void PndStack::SetGeneratorFlags ( Int_t  myid)
private

Definition at line 248 of file PndStack.cxx.

References fIndexMap, fParticles, fTracks, PndMCTrack::GetMotherID(), i, m, n, PndMCTrack::SetGeneratorCreated(), and PndMCTrack::SetGeneratorDecayed().

Referenced by FillTrackArray().

249 {
250  if(myid<0) return;
251 
252  PndMCTrack* mytrack;
253  {
254  Int_t myid2=fIndexMap[myid];
255  if(myid2<0){
256  LOG(ERROR)<<"=== This should not happen negative index in MAP!!" ;
257  return;
258  }
259 
260  mytrack = (PndMCTrack*)fTracks->At(myid2);
261  }
262 
263  Int_t n;
264  Int_t daughters=0, daughtersp=0;
265  // fParticles; // TParticle
266  n=fParticles->GetEntries();
267  for (Int_t i=0; i<n; i++) {
268  TParticle* part = (TParticle*)fParticles->At(i);
269  Int_t m;
270  m=part->GetMother(0);
271  if(myid==m){
272  daughters++;
273  }else if(m==-1){
274  m=part->GetMother(1);
275  if(myid==m){
276  daughtersp++;
277  }
278  }else if(m==-2){
279  // removed should not happen before this is called
280  // and anyway not on the TParticle Level
281  LOG(ERROR)<<"=== Problem!!! part mother -2" ;
282  }
283  }
284 
285  Int_t mymo1=mytrack->GetMotherID();
286 
287  if( ((TParticle*)fParticles->At(myid))->GetMother(0)!=mymo1){
288  LOG(ERROR)<<"=== Problem: Mothers != "<< myid ;
289  }
290  if(mymo1==-1){
291  if(daughters!=0 && daughtersp!=0){
292  LOG(ERROR)<<"=== Problem: particle with index "<<myid<<" has daughters= "<<daughters<<" && daughtersp= "<<daughtersp ;
293  }
294 
295  mytrack->SetGeneratorCreated();
296  if(daughtersp>0) mytrack->SetGeneratorDecayed();
297 // cout << myid <<" ("<<mytrack->GetPdgCode()<<"): "<<daughters<<","<<daughtersp<<" ==> " <<mytrack->IsGeneratorCreated()<<" "<<mytrack->IsGeneratorDecayed()<<" "<<mytrack->IsGeneratorLast()<<endl;
298  }
299 }
TClonesArray * fTracks
Definition: PndStack.h:210
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
int n
void SetGeneratorDecayed(void)
Definition: PndMCTrack.h:88
std::map< Int_t, Int_t > fIndexMap
Definition: PndStack.h:219
void SetGeneratorCreated(void)
Definition: PndMCTrack.h:87
Int_t GetMotherID() const
Definition: PndMCTrack.h:74
TClonesArray * fParticles
Definition: PndStack.h:206
void PndStack::SetMinPoints ( Int_t  min)
inline

Definition at line 171 of file PndStack.h.

References fMinPoints, and min().

Referenced by Config().

171 { fMinPoints = min; }
Int_t fMinPoints
Definition: PndStack.h:237
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
void PndStack::SetPersistence ( Bool_t  choice)
inline

Definition at line 174 of file PndStack.h.

References choice, and fPersistence.

Referenced by Config().

174 { fPersistence = choice; }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:75
Bool_t fPersistence
Definition: PndStack.h:240
void PndStack::StoreMothers ( Bool_t  choice = kTRUE)
inline

Definition at line 173 of file PndStack.h.

References choice, and fStoreMothers.

173 { fStoreMothers = choice; }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:75
Bool_t fStoreMothers
Definition: PndStack.h:239
void PndStack::StoreSecondaries ( Bool_t  choice = kTRUE)
inline

Modifiers

Definition at line 170 of file PndStack.h.

References choice, and fStoreSecondaries.

Referenced by Config().

#define choice(c1, c2, c3)
Definition: PndCAMath.h:75
Bool_t fStoreSecondaries
Used for merging.
Definition: PndStack.h:236
void PndStack::UpdateTrackIndex ( TRefArray *  detArray)
virtual

Update the track index in the MCTracks and MCPoints

Definition at line 303 of file PndStack.cxx.

References DEBUG, fIndexIter, fIndexMap, fNTracks, fTracks, PndMCTrack::GetMotherID(), PndMCTrack::GetSecondMotherID(), i, point, PndMCTrack::SetMotherID(), PndMCTrack::SetSecondMotherID(), and track.

303  {
304 
305  LOG(DEBUG) << "PndStack: Updating track indizes..." ;
306  Int_t nColl = 0;
307 
308  FairMCEventHeader* header = (FairMCEventHeader*)FairRootManager::Instance()->GetObject("MCEventHeader.");
309 
310  // First update mother ID in MCTracks
311  for (Int_t i=0; i<fNTracks; i++) {
312  PndMCTrack* track = (PndMCTrack*)fTracks->At(i);
313  Int_t iMotherOld = track->GetMotherID();
314  fIndexIter = fIndexMap.find(iMotherOld);
315  if (fIndexIter == fIndexMap.end()) {
316  LOG(ERROR) << "PndStack: Particle index "<<iMotherOld<<" not found in dex map! " ;
317  Fatal("PndStack::UpdateTrackIndex","Particle index not found in map");
318  }
319  track->SetMotherID( (*fIndexIter).second );
320  if(iMotherOld==-1){
321  iMotherOld = track->GetSecondMotherID();
322  fIndexIter = fIndexMap.find(iMotherOld);
323  if (fIndexIter == fIndexMap.end()) {
324  LOG(ERROR) << "PndStack: Particle index "<<iMotherOld<<" not found in dex map! (second mother id)" ;
325  Fatal("PndStack::UpdateTrackIndex","Particle index not found in map");
326  }
327  track->SetSecondMotherID( (*fIndexIter).second );
328  }
329  }
330 
331  // Now iterate through all active detectors
332  TIterator* detIter = detList->MakeIterator();
333  detIter->Reset();
334  FairDetector* det = NULL;
335  while ((det = (FairDetector*) detIter->Next())) {
336 
337  // --> Get hit collections from detector
338  Int_t iColl = 0;
339  TClonesArray* hitArray;
340  while ((hitArray = det->GetCollection(iColl++))) {
341  nColl++;
342  Int_t nPoints = hitArray->GetEntriesFast();
343 
344  // --> Update track index for all MCPoints in the collection
345  for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
346  FairMCPoint* point = (FairMCPoint*) hitArray->At(iPoint);
347  Int_t iTrack = point->GetTrackID();
348 
349  fIndexIter = fIndexMap.find(iTrack);
350  if (fIndexIter == fIndexMap.end()) {
351  LOG(ERROR) << "PndStack: Particle index "<<iTrack<<" not found in index map! " ;
352  Fatal("PndStack::UpdateTrackIndex",
353  "Particle index not found in map");
354  }
355  point->SetTrackID((*fIndexIter).second);
356 // std::cout << "Header->GetEventID() " << header->GetEventID() << std::endl;
357  point->SetLink(FairLink(-1, (header->GetEventID()-1), "MCTrack", (*fIndexIter).second));
358  }
359 
360  } // Collections of this detector
361  } // List of active detectors
362 
363  LOG(DEBUG) << "...stack and "<<nColl<<" collections updated." ;
364  delete detIter;
365 }
TClonesArray * fTracks
Definition: PndStack.h:210
Int_t i
Definition: run_full.C:25
PndRiemannTrack track
Definition: RiemannTest.C:33
std::map< Int_t, Int_t >::iterator fIndexIter
Definition: PndStack.h:220
#define DEBUG
TClonesArray * point
Definition: anaLmdDigi.C:29
Int_t fNTracks
Number of entries in fParticles.
Definition: PndStack.h:231
std::map< Int_t, Int_t > fIndexMap
Definition: PndStack.h:219
Int_t GetSecondMotherID() const
Definition: PndMCTrack.h:75
void SetSecondMotherID(Int_t id)
Definition: PndMCTrack.h:94
void SetMotherID(Int_t id)
Definition: PndMCTrack.h:93
Int_t GetMotherID() const
Definition: PndMCTrack.h:74

Member Data Documentation

Int_t PndStack::fCurrentTrack
private

Some indizes and counters

Definition at line 228 of file PndStack.h.

Referenced by AddPoint(), GetCurrentTrack(), GetCurrentTrackNumber(), PopNextTrack(), Reset(), and SetCurrentTrack().

Double32_t PndStack::fEnergyCut
private

Definition at line 238 of file PndStack.h.

Referenced by SelectTracks(), and SetEnergyCut().

Int_t PndStack::fIndex
private

Number of entries in fTracks.

Definition at line 232 of file PndStack.h.

Referenced by AddParticle(), and Reset().

std::map<Int_t, Int_t>::iterator PndStack::fIndexIter
private

Definition at line 220 of file PndStack.h.

Referenced by UpdateTrackIndex().

std::map<Int_t, Int_t> PndStack::fIndexMap
private

STL map from particle index to track index

Definition at line 219 of file PndStack.h.

Referenced by FillTrackArray(), PndStack(), SetGeneratorFlags(), and UpdateTrackIndex().

Int_t PndStack::fMinPoints
private

Definition at line 237 of file PndStack.h.

Referenced by SelectTracks(), and SetMinPoints().

Int_t PndStack::fNParticles
private

Number of primary particles.

Definition at line 230 of file PndStack.h.

Referenced by FillTrackArray(), GetNtrack(), GetParticle(), Print(), PushTrack(), Reset(), and SelectTracks().

Int_t PndStack::fNPrimaries
private

Index of current track.

Definition at line 229 of file PndStack.h.

Referenced by GetNprimary(), PopPrimaryForTracking(), Print(), PushTrack(), and Reset().

Int_t PndStack::fNTracks
private

Number of entries in fParticles.

Definition at line 231 of file PndStack.h.

Referenced by FillTrackArray(), Print(), Reset(), and UpdateTrackIndex().

TClonesArray* PndStack::fParticles
private

Array of TParticles (contains all TParticles put into or created by the transport

Definition at line 206 of file PndStack.h.

Referenced by AddParticle(), GetListOfParticles(), GetParticle(), PndStack(), PopPrimaryForTracking(), PushTrack(), Reset(), SetGeneratorFlags(), and ~PndStack().

Bool_t PndStack::fPersistence
private

Definition at line 240 of file PndStack.h.

Referenced by Register(), and SetPersistence().

std::map<std::pair<Int_t, Int_t>, Int_t> PndStack::fPointsMap
private

STL map from track index and detector ID to number of MCPoints

Definition at line 224 of file PndStack.h.

Referenced by AddPoint(), FillTrackArray(), PndStack(), Reset(), and SelectTracks().

std::stack<TParticle*> PndStack::fStack
private

STL stack (FILO) used to handle the TParticles for tracking

Definition at line 200 of file PndStack.h.

Referenced by PopNextTrack(), PushTrack(), and Reset().

std::map<Int_t, Bool_t>::iterator PndStack::fStoreIter
private

Definition at line 215 of file PndStack.h.

Referenced by FillTrackArray().

std::map<Int_t, Bool_t> PndStack::fStoreMap
private

STL map from particle index to storage flag

Definition at line 214 of file PndStack.h.

Referenced by FillTrackArray(), PndStack(), and SelectTracks().

Bool_t PndStack::fStoreMothers
private

Definition at line 239 of file PndStack.h.

Referenced by SelectTracks(), and StoreMothers().

Bool_t PndStack::fStoreSecondaries
private

Used for merging.

Variables defining the criteria for output selection

Definition at line 236 of file PndStack.h.

Referenced by SelectTracks(), and StoreSecondaries().

TClonesArray* PndStack::fTracks
private

Array of PndMCTracks containg the tracks written to the output

Definition at line 210 of file PndStack.h.

Referenced by PndStack(), Print(), Register(), Reset(), SetGeneratorFlags(), UpdateTrackIndex(), and ~PndStack().


The documentation for this class was generated from the following files: