7 #include "FairDetector.h"
8 #include "FairMCPoint.h"
10 #include "FairRootManager.h"
11 #include "FairMCEventHeader.h"
14 #include "TLorentzVector.h"
15 #include "TParticle.h"
16 #include "TRefArray.h"
28 fStack(),
fParticles(), fTracks(), fStoreMap(), fStoreIter(), fIndexMap(), fIndexIter(), fPointsMap(), fCurrentTrack(-1), fNPrimaries(0), fNParticles(0), fNTracks(0), fIndex(0), fStoreSecondaries(kTRUE), fMinPoints(1), fEnergyCut(0), fStoreMothers(kTRUE), fPersistence(kTRUE)
33 fParticles =
new TClonesArray(
"TParticle", size);
34 fTracks =
new TClonesArray(
"PndMCTrack", size);
61 Double_t polz, TMCProcess proc, Int_t& ntr,
77 Double_t polz, TMCProcess proc, Int_t& ntr,
78 Double_t weight, Int_t
is,Int_t secondparentID) {
87 Int_t daughter1Id = -1;
88 Int_t daughter2Id = -1;
90 new(partArray[
fNParticles++]) TParticle(pdgCode, trackId, parentId,
92 daughter2Id, px, py, pz, e,
94 particle->SetLastMother(secondparentID);
95 particle->SetPolarisation(polx, poly, polz);
96 particle->SetWeight(weight);
97 particle->SetUniqueID(proc);
125 TParticle* thisParticle =
fStack.top();
128 if ( !thisParticle) {
151 LOG(ERROR) <<
"PndStack: Primary index out of range! " << iPrim ;
152 Fatal(
"PndStack::PopPrimaryForTracking",
"Index out of range");
157 TParticle* part = (TParticle*)
fParticles->At(iPrim);
159 if ( ! (part->GetMother(0) < 0) ) {
160 LOG(ERROR) <<
"PndStack:: Not a primary track! , " <<iPrim ;
161 Fatal(
"PndStack::PopPrimaryForTracking",
"Not a primary track");
164 if(!part->TestBit(
kDoneBit))
return NULL;
175 if ( ! currentPart) {
176 LOG(WARNING) <<
"PndStack: Current track not found in stack!" ;
177 Warning(
"PndStack::GetCurrentTrack",
"Track not found in stack");
188 TParticle* newPart =
new(array[
fIndex]) TParticle(*oldPart);
189 newPart->SetWeight(oldPart->GetWeight());
190 newPart->SetUniqueID(oldPart->GetUniqueID());
200 LOG(
DEBUG) <<
"PndStack: Filling MCTrack array..." ;
214 LOG(ERROR) <<
"PndStack: Particle "<<iPart<<
" not found in storage map!" ;
215 Fatal(
"PndStack::FillTrackArray",
"Particle not found in storage map.");
224 for (Int_t iDet=
kRICH; iDet<=
kHYP; iDet++) {
225 pair<Int_t, Int_t>
a(iPart, iDet);
256 LOG(ERROR)<<
"=== This should not happen negative index in MAP!!" ;
264 Int_t daughters=0, daughtersp=0;
267 for (Int_t
i=0;
i<
n;
i++) {
270 m=part->GetMother(0);
274 m=part->GetMother(1);
281 LOG(ERROR)<<
"=== Problem!!! part mother -2" ;
287 if( ((TParticle*)
fParticles->At(myid))->GetMother(0)!=mymo1){
288 LOG(ERROR)<<
"=== Problem: Mothers != "<< myid ;
291 if(daughters!=0 && daughtersp!=0){
292 LOG(ERROR)<<
"=== Problem: particle with index "<<myid<<
" has daughters= "<<daughters<<
" && daughtersp= "<<daughtersp ;
305 LOG(
DEBUG) <<
"PndStack: Updating track indizes..." ;
308 FairMCEventHeader* header = (FairMCEventHeader*)FairRootManager::Instance()->GetObject(
"MCEventHeader.");
316 LOG(ERROR) <<
"PndStack: Particle index "<<iMotherOld<<
" not found in dex map! " ;
317 Fatal(
"PndStack::UpdateTrackIndex",
"Particle index not found in map");
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");
332 TIterator* detIter = detList->MakeIterator();
334 FairDetector* det = NULL;
335 while ((det = (FairDetector*) detIter->Next())) {
339 TClonesArray* hitArray;
340 while ((hitArray = det->GetCollection(iColl++))) {
342 Int_t nPoints = hitArray->GetEntriesFast();
345 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
346 FairMCPoint*
point = (FairMCPoint*) hitArray->At(iPoint);
347 Int_t iTrack = point->GetTrackID();
351 LOG(ERROR) <<
"PndStack: Particle index "<<iTrack<<
" not found in index map! " ;
352 Fatal(
"PndStack::UpdateTrackIndex",
353 "Particle index not found in map");
355 point->SetTrackID((*fIndexIter).second);
357 point->SetLink(FairLink(-1, (header->GetEventID()-1),
"MCTrack", (*fIndexIter).second));
363 LOG(
DEBUG) <<
"...stack and "<<nColl<<
" collections updated." ;
395 <<
"\n Total number of particles = " <<
fNParticles
396 <<
"\n Number of tracks in output = " <<
fNTracks ;
399 for (Int_t iTrack=0; iTrack<
fNTracks; iTrack++)
420 if ( iTrack < 0 )
return;
422 pair<Int_t, Int_t>
a(iTrack, iDet);
434 if ( currentPart )
return currentPart->GetFirstMother();
444 LOG(ERROR) <<
"PndStack: Particle index out of range." << trackID ;
445 Fatal(
"PndStack::GetParticle",
"Index out of range");
466 Int_t iMother = thisPart->GetMother(0);
468 thisPart->Momentum(p);
473 if(eKin < 0.0) eKin=0.0;
476 for (Int_t iDet=
kRICH; iDet<=
kHYP; iDet++) {
477 pair<Int_t, Int_t>
a(
i, iDet);
483 if (iMother < 0) store = kTRUE;
500 while(iMother >= 0) {
virtual TParticle * PopPrimaryForTracking(Int_t iPrim)
virtual Int_t GetCurrentParentTrackNumber() const
std::map< std::pair< Int_t, Int_t >, Int_t > fPointsMap
virtual TParticle * PopNextTrack(Int_t &iTrack)
void SetNPoints(Int_t iDet, Int_t np)
TParticle * GetParticle(Int_t trackId) const
Int_t fIndex
Number of entries in fTracks.
Bool_t fStoreSecondaries
Used for merging.
void SetGeneratorDecayed(void)
void AddPoint(DetectorId iDet)
virtual void Print(Int_t iVerbose=0) const
std::map< Int_t, Int_t >::iterator fIndexIter
std::map< Int_t, Bool_t >::iterator fStoreIter
std::map< Int_t, Bool_t > fStoreMap
void SetGeneratorFlags(Int_t myid)
std::stack< TParticle * > fStack
Int_t fNTracks
Number of entries in fParticles.
virtual TParticle * GetCurrentTrack() const
std::map< Int_t, Int_t > fIndexMap
vector< FitStore > store(3000)
Int_t fNParticles
Number of primary particles.
virtual void UpdateTrackIndex(TRefArray *detArray)
virtual void FillTrackArray()
Int_t GetSecondMotherID() const
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)
void SetSecondMotherID(Int_t id)
void SetGeneratorCreated(void)
void SetMotherID(Int_t id)
Int_t fNPrimaries
Index of current track.
Int_t GetMotherID() const
virtual void AddParticle(TParticle *part)
TClonesArray * fParticles