23 #include <TClonesArray.h>
24 #include <TIterator.h>
25 #include <TLorentzVector.h>
26 #include <TParticle.h>
27 #include <TRefArray.h>
28 #include <TVirtualMC.h>
41 , fParticles(new TClonesArray(
"TParticle", size))
42 , fTracks(new TClonesArray(
"MyProjMCTrack", size))
53 , fStoreSecondaries(kTRUE)
56 , fStoreMothers(kTRUE)
64 , fParticles(new TClonesArray(
"TParticle", 100))
65 , fTracks(new TClonesArray(
"MyProjMCTrack", 100))
76 , fStoreSecondaries(right.fStoreSecondaries)
77 , fMinPoints(right.fMinPoints)
78 , fEnergyCut(right.fEnergyCut)
79 , fStoreMothers(right.fStoreMothers)
117 toBeDone, parentId, pdgCode, px, py, pz, e, vx, vy, vz, time, polx, poly, polz, proc, ntr, weight, is, -1);
139 Int_t secondparentID)
143 TClonesArray& partArray = *fParticles;
146 Int_t trackId = fNParticles;
148 Int_t daughter1Id = -1;
149 Int_t daughter2Id = -1;
150 TParticle* particle =
new (partArray[fNParticles++])
151 TParticle(pdgCode, trackId, parentId, nPoints, daughter1Id, daughter2Id, px, py, pz, e, vx, vy, vz, time);
152 particle->SetPolarisation(polx, poly, polz);
153 particle->SetWeight(weight);
154 particle->SetUniqueID(proc);
166 fStack.push(particle);
176 if (fStack.empty()) {
182 TParticle* thisParticle = fStack.top();
190 fCurrentTrack = thisParticle->GetStatusCode();
191 iTrack = fCurrentTrack;
205 if (iPrim < 0 || iPrim >= fNPrimaries) {
206 LOG(fatal) <<
"MyProjStack: Primary index out of range! " << iPrim;
211 TParticle* part = (TParticle*)fParticles->At(iPrim);
212 if (!(part->GetMother(0) < 0)) {
213 LOG(fatal) <<
"MyProjStack:: Not a primary track! " << iPrim;
223 TParticle* currentPart =
GetParticle(fCurrentTrack);
225 LOG(warning) <<
"MyProjStack: Current track not found in stack!";
234 TClonesArray& array = *fParticles;
235 TParticle* newPart =
new (array[fIndex]) TParticle(*oldPart);
236 newPart->SetWeight(oldPart->GetWeight());
237 newPart->SetUniqueID(oldPart->GetUniqueID());
246 LOG(debug) <<
"MyProjStack: Filling MCTrack array...";
256 for (Int_t iPart = 0; iPart < fNParticles; iPart++) {
264 Bool_t store = kTRUE;
268 fIndexMap[iPart] = fNTracks;
271 pair<Int_t, Int_t> a(iPart, iDet);
276 fIndexMap[iPart] = -2;
351 fNPrimaries = fNParticles = fNTracks = 0;
352 while (!fStack.empty()) {
364 if (gMC && (!gMC->IsMT())) {
375 cout <<
"-I- MyProjStack: Number of primaries = " << fNPrimaries << endl;
376 cout <<
" Total number of particles = " << fNParticles << endl;
377 cout <<
" Number of tracks in output = " << fNTracks << endl;
379 for (Int_t iTrack = 0; iTrack < fNTracks; iTrack++) {
391 pair<Int_t, Int_t> a(fCurrentTrack, iDet);
392 if (fPointsMap.find(a) == fPointsMap.end()) {
407 pair<Int_t, Int_t> a(iTrack, iDet);
408 if (fPointsMap.find(a) == fPointsMap.end()) {
421 return currentPart->GetFirstMother();
431 if (trackID < 0 || trackID >= fNParticles) {
432 LOG(fatal) <<
"MyProjStack: Particle index " << trackID <<
" out of range.";
434 return (TParticle*)fParticles->At(trackID);
439 void MyProjStack::SelectTracks()
446 for (Int_t i = 0; i < fNParticles; i++) {
449 Bool_t store = kTRUE;
452 Int_t iMother = thisPart->GetMother(0);
454 thisPart->Momentum(p);
455 Double_t energy = p.E();
456 Double_t mass = p.M();
458 Double_t eKin = energy - mass;
463 pair<Int_t, Int_t> a(i, iDet);
464 if (fPointsMap.find(a) != fPointsMap.end()) {
465 nPoints += fPointsMap[a];
473 if (!fStoreSecondaries) {
476 if (nPoints < fMinPoints) {
479 if (eKin < fEnergyCut) {
485 fStoreMap[i] = store;
490 for (Int_t i = 0; i < fNParticles; i++) {
493 while (iMother >= 0) {
494 fStoreMap[iMother] = kTRUE;
virtual void FillTrackArray()
virtual TParticle * PopPrimaryForTracking(Int_t iPrim)
static FairRootManager * Instance()
virtual TParticle * PopNextTrack(Int_t &iTrack)
ClassImp(FairEventBuilder)
TParticle * GetParticle(Int_t trackId) const
virtual TParticle * GetCurrentTrack() const
virtual void Print(Int_t iVerbose=0) const
virtual void AddParticle(TParticle *part)
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 SetNPoints(Int_t iDet, Int_t np)
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
virtual void UpdateTrackIndex(TRefArray *detArray=0)
virtual Int_t GetCurrentParentTrackNumber() const
void AddPoint(DetectorId iDet)
void RegisterAny(const char *name, T *&obj, Bool_t toFile)
MyProjStack(Int_t size=100)