8 #include "FairDetector.h"
9 #include "FairMCPoint.h"
11 #include "FairRootManager.h"
13 #include "TClonesArray.h"
14 #include "TLorentzVector.h"
15 #include "TParticle.h"
16 #include "TRefArray.h"
32 , fParticles(new TClonesArray(
"TParticle", size))
33 , fTracks(new TClonesArray(
"CbmMCTrack", size))
42 , fStoreSecondaries(kTRUE)
45 , fStoreMothers(kTRUE)
46 , fdoTracking(kTRUE) {}
130 Int_t generatorParentId) {
136 if (parentId == -1 && generatorParentId <
fNParticles)
137 parentId = generatorParentId;
142 Int_t daughter1Id = -1;
143 Int_t daughter2Id = -1;
144 TParticle* particle =
145 new ((*fParticles)[
fNParticles++]) TParticle(pdgCode,
159 particle->SetPolarisation(polx, poly, polz);
160 particle->SetWeight(weight);
164 particle->SetUniqueID(proc);
188 TParticle* thisParticle =
fStack.top();
213 TParticle* part = (TParticle*)
fParticles->At(iPrim);
214 assert(part->GetUniqueID() == kPPrimary);
223 if (!currentPart) { LOG(warn) <<
"Current track not found in stack!"; }
232 TParticle* newPart =
new (array[
fIndex]) TParticle(*oldPart);
233 newPart->SetWeight(oldPart->GetWeight());
234 newPart->SetUniqueID(oldPart->GetUniqueID());
246 auto nParticles =
static_cast<std::size_t
>(
fParticles->GetEntriesFast());
247 assert(store.size() == nParticles);
254 for (Int_t indexP = 0; indexP <
fParticles->GetEntriesFast(); indexP++) {
259 Int_t indexT =
fTracks->GetEntriesFast();
270 auto it =
fPointsMap.find(make_pair(indexP, detector));
284 LOG(info) <<
"CbmStack: " <<
fParticles->GetEntriesFast() <<
" particles, "
285 <<
fNTracks <<
" written to output.";
293 LOG(debug) <<
"Updating track indizes...";
302 LOG(fatal) <<
"Particle index " << iMotherOld
303 <<
" not found in dex map! ";
309 TIterator* detIter = detList->MakeIterator();
311 FairDetector* det =
nullptr;
312 while ((det = (FairDetector*) detIter->Next())) {
317 TClonesArray* hitArray;
318 while ((hitArray = det->GetCollection(iColl++))) {
320 Int_t nPoints = hitArray->GetEntriesFast();
323 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
324 FairMCPoint* point = (FairMCPoint*) hitArray->At(iPoint);
325 Int_t iTrack = point->GetTrackID();
329 LOG(fatal) <<
"Particle index " << iTrack
330 <<
" not found in index map! ";
332 point->SetTrackID((*fIndexIter).second);
333 point->SetLink(FairLink(
"MCTrack", (*fIndexIter).second));
340 LOG(debug) <<
"...stack and " << nColl <<
" collections updated.";
362 FairRootManager::Instance()->Register(
"MCTrack",
"Stack",
fTracks, kTRUE);
369 LOG(debug) <<
"Number of primaries = " <<
fNPrimaries;
370 LOG(debug) <<
"Total number of particles = " <<
fNParticles;
371 LOG(debug) <<
"Number of tracks in output = " <<
fNTracks;
372 if (FairLogger::GetLogger()->IsLogNeeded(fair::Severity::debug1)) {
373 for (Int_t iTrack = 0; iTrack <
fNTracks; iTrack++) {
374 LOG(debug1) <<
"MCTrack " << iTrack
396 if (iTrack < 0) {
return; }
397 pair<Int_t, ECbmModuleId> a(iTrack, detId);
411 return currentPart->GetFirstMother();
422 LOG(fatal) <<
"Particle index " << trackID <<
" out of range.";