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++) {
258 fStoreIter = fStoreMap.find(iPart);
259 if (fStoreIter == fStoreMap.end()) {
260 LOG(fatal) <<
"MyProjStack: Particle " << iPart <<
" not found in storage map! ";
262 Bool_t store = (*fStoreIter).second;
266 fIndexMap[iPart] = fNTracks;
269 pair<Int_t, Int_t> a(iPart, iDet);
274 fIndexMap[iPart] = -2;
290 LOG(debug) <<
"MyProjStack: Updating track indizes...";
294 for (Int_t i = 0; i < fNTracks; i++) {
297 fIndexIter = fIndexMap.find(iMotherOld);
298 if (fIndexIter == fIndexMap.end()) {
299 LOG(fatal) <<
"MyProjStack: Particle index " << iMotherOld <<
" not found in dex map! ";
317 TClonesArray* hitArray;
320 Int_t nPoints = hitArray->GetEntriesFast();
323 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
327 fIndexIter = fIndexMap.find(iTrack);
328 if (fIndexIter == fIndexMap.end()) {
329 LOG(fatal) <<
"MyProjStack: Particle index " << iTrack <<
" not found in index map! ";
337 LOG(debug) <<
"...stack and " << nColl <<
" collections updated.";
346 fNPrimaries = fNParticles = fNTracks = 0;
347 while (!fStack.empty()) {
359 if (gMC && (!gMC->IsMT())) {
370 cout <<
"-I- MyProjStack: Number of primaries = " << fNPrimaries << endl;
371 cout <<
" Total number of particles = " << fNParticles << endl;
372 cout <<
" Number of tracks in output = " << fNTracks << endl;
374 for (Int_t iTrack = 0; iTrack < fNTracks; iTrack++) {
386 pair<Int_t, Int_t> a(fCurrentTrack, iDet);
387 if (fPointsMap.find(a) == fPointsMap.end()) {
402 pair<Int_t, Int_t> a(iTrack, iDet);
403 if (fPointsMap.find(a) == fPointsMap.end()) {
416 return currentPart->GetFirstMother();
426 if (trackID < 0 || trackID >= fNParticles) {
427 LOG(fatal) <<
"MyProjStack: Particle index " << trackID <<
" out of range.";
429 return (TParticle*)fParticles->At(trackID);
434 void MyProjStack::SelectTracks()
441 for (Int_t i = 0; i < fNParticles; i++) {
444 Bool_t store = kTRUE;
447 Int_t iMother = thisPart->GetMother(0);
449 thisPart->Momentum(p);
450 Double_t energy = p.E();
451 Double_t mass = p.M();
453 Double_t eKin = energy - mass;
458 pair<Int_t, Int_t> a(i, iDet);
459 if (fPointsMap.find(a) != fPointsMap.end()) {
460 nPoints += fPointsMap[a];
468 if (!fStoreSecondaries) {
471 if (nPoints < fMinPoints) {
474 if (eKin < fEnergyCut) {
480 fStoreMap[i] = store;
485 for (Int_t i = 0; i < fNParticles; i++) {
488 while (iMother >= 0) {
489 fStoreMap[iMother] = kTRUE;
Int_t GetMotherId() const
virtual void FillTrackArray()
void SetLink(FairLink link)
Sets the Links with a single FairLink.
virtual TParticle * PopPrimaryForTracking(Int_t iPrim)
void SetMotherId(Int_t id)
static FairRootManager * Instance()
virtual TParticle * PopNextTrack(Int_t &iTrack)
ClassImp(FairEventBuilder)
TParticle * GetParticle(Int_t trackId) const
Int_t GetTrackID() const
event identifier
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)
virtual void SetTrackID(Int_t id)
void SetNPoints(Int_t iDet, Int_t np)
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
virtual TClonesArray * GetCollection(Int_t iColl) const =0
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)