8#include "FairDetector.h"
10#include "FairLogger.h"
11#include "FairMCPoint.h"
12#include "FairRootManager.h"
17#include <TVirtualMC.h>
76 PushTrack(toBeDone, parentId, pdgCode, px, py, pz, e, vx, vy, vz, time, polx, poly, polz, proc, ntr, weight, is,
110 Int_t daughter1Id = -1;
111 Int_t daughter2Id = -1;
113 TParticle(pdgCode, trackId, parentId, nPoints, daughter1Id, daughter2Id, px, py, pz, e, vx, vy, vz, time);
164 LOG(fatal) <<
"Primary index out of range!" << iPrim;
171 LOG(fatal) <<
"Not a primary track!" << iPrim;
182 LOG(warn) <<
"Current track not found in stack!";
201 LOG(debug) <<
"Filling MCTrack array...";
216 LOG(fatal) <<
"Particle " << iPart <<
" not found in storage map! ";
218 store = (*fStoreIter).second;
226 pair<Int_t, Int_t> a(iPart, iDet);
245 LOG(info) <<
"Updating track indices...";
256 LOG(fatal) <<
"Particle index " << iMotherOld <<
" not found in index map!";
271 while ((det =
static_cast<FairDetector*
>(fDetIter->Next()))) {
275 while ((hitArray = det->GetCollection(iColl++))) {
280 for (
Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
282 Int_t iTrack = point->GetTrackID();
292 LOG(fatal) <<
"Particle index " << iTrack <<
" not found in index map!";
302 point->SetTrackID(trid);
303 point->AddLink(FairLink(
"MCTrack", trid));
310 LOG(info) <<
"...stack and " << nColl <<
" collections updated.";
331 FairRootManager::Instance()->Register(
"MCTrack",
"Stack",
fTracks,
kTRUE);
333 FairRootManager::Instance()->RegisterAny(
"MCTrack",
fTracks,
kTRUE);
340 LOG(info) <<
"CbmStack: Number of primaries = " <<
fNPrimaries;
341 LOG(info) <<
" Total number of particles = " <<
fNParticles;
342 LOG(info) <<
" Number of tracks in output = " <<
fNTracks;
343 if (gLogger->IsLogNeeded(fair::Severity::debug1)) {
355 pair<Int_t, Int_t> a(iTr, iDet);
371 pair<Int_t, Int_t> a(iTr, iDet);
394 LOG(fatal) <<
"Particle index " << trackID <<
" out of range.";
422 Int_t nPoints = 0, nPointsFHCAL = 0, nPointsNoFHCAL = 0;
425 pair<Int_t, Int_t> a(
i, iDet);
451 if (nPointsFHCAL && !nPointsNoFHCAL)
459 if (mass < 1.8 && mother->GetPDG()->Mass() < 1.8) {
460 if (mass > 1.0 || mother->
GetPDG()->
Mass() > 1.0)
491 std::multimap<Int_t, Int_t> moths;
492 std::multimap<Int_t, Int_t>::iterator it;
493 pair<std::multimap<Int_t, Int_t>::iterator, std::multimap<Int_t, Int_t>::iterator> ret;
494 std::map<Int_t, Bool_t> copyMap =
fStoreMap;
498 moths.insert(pair<Int_t, Int_t>(iMother,
i));
504 while (iMother >= 0) {
506 ret = moths.equal_range(iMother);
507 for (it = ret.first; it != ret.second; ++it)
Int_t GetMotherId() const
void SetNPoints(Int_t iDet, Long64_t np)
void SetMotherId(Int_t id)
Modifiers.
Int_t fCurrentTrack
Some indizes and counters.
Int_t fNParticles
Number of primary particles.
virtual void UpdateTrackIndex(TRefArray *detArray=0)
Update the track index in the MCTracks and MCPoints.
virtual TParticle * PopNextTrack(Int_t &iTrack)
Get next particle for tracking from the stack.
virtual Int_t GetCurrentParentTrackNumber() const
Get the track number of the parent of the current track Declared in TVirtualMCStack.
Int_t fIndex
Number of entries in fTracks.
Int_t fNPrimaries
Index of current track.
void AddPoint(DetectorId iDet)
Increment number of points for the current track in a given detector.
Bool_t fStoreSecondaries
Used for merging.
virtual TParticle * PopPrimaryForTracking(Int_t iPrim)
Get primary particle by index for tracking from stack Declared in TVirtualMCStack.
virtual ~CbmStack()
Destructor.
virtual void Reset()
Resets arrays and stack and deletes particles and tracks.
virtual void AddParticle(TParticle *part)
Add a TParticle to the fParticles array.
std::map< Int_t, Bool_t >::iterator fStoreIter
virtual TParticle * GetCurrentTrack() const
Get the current track's particle Declared in TVirtualMCStack.
virtual void Print(Option_t *) const
Output to screen: the event summary, and the track info if the log level is debug1.
TParticle * GetParticle(Int_t trackId) const
Accessors.
TClonesArray * fParticles
Array of TParticles (contains all TParticles put into or created by the transport.
virtual void FillTrackArray()
Fill the MCTrack output array, applying filter criteria.
Int_t fNTracks
Number of entries in fParticles.
CbmStack(Int_t size=100)
Default constructor param size Estimated track number.
std::map< Int_t, Int_t >::iterator fIndexIter
std::map< Int_t, Bool_t > fStoreMap
STL map from particle index to storage flag.
TClonesArray * fTracks
Array of CbmMCTracks containg the tracks written to the output.
std::stack< TParticle * > fStack
STL stack (FILO) used to handle the TParticles for tracking.
std::map< Int_t, Int_t > fIndexMap
STL map from particle index to track index.
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)
Add a TParticle to the stack.
void SelectTracks()
Mark tracks for output using selection criteria.
virtual void Register()
Register the MCTrack array to the Root Manager.
std::map< std::pair< Int_t, Int_t >, Int_t > fPointsMap
STL map from track index and detector ID to number of MCPoints.
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
virtual UInt_t GetUniqueID() const
virtual void SetUniqueID(UInt_t uid)
Int_t GetStatusCode() const
Float_t GetWeight() const
TParticlePDG * GetPDG(Int_t mode=0) const
Int_t GetFirstMother() const
void SetWeight(Float_t weight=1)
void SetPolarisation(const TVector3 &v)
void SetFirstMother(int code)
Int_t GetMother(Int_t i) const
void Momentum(TLorentzVector &v) const
TIterator * MakeIterator(Bool_t dir=kIterForward) const override