From af46925c6902cd25087093c25368cac617b0f515 Mon Sep 17 00:00:00 2001 From: Roberto Preghenella Date: Tue, 19 Jan 2021 11:42:47 +0100 Subject: [PATCH 1/2] Check for selective primary transport also in case of parallel sim --- .../include/SimulationDataFormat/Stack.h | 2 ++ DataFormats/simulation/src/Stack.cxx | 28 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/DataFormats/simulation/include/SimulationDataFormat/Stack.h b/DataFormats/simulation/include/SimulationDataFormat/Stack.h index ff55904d9342c..fee8d3e3c32f1 100644 --- a/DataFormats/simulation/include/SimulationDataFormat/Stack.h +++ b/DataFormats/simulation/include/SimulationDataFormat/Stack.h @@ -311,6 +311,8 @@ class Stack : public FairGenericStack /// \param iTrack Track number void addHit(int iDet, Int_t iTrack); + void handleTransportPrimary(TParticle& p); + ClassDefOverride(Stack, 1); }; diff --git a/DataFormats/simulation/src/Stack.cxx b/DataFormats/simulation/src/Stack.cxx index 41f5f8fd1acd5..4b969c91865d2 100644 --- a/DataFormats/simulation/src/Stack.cxx +++ b/DataFormats/simulation/src/Stack.cxx @@ -230,13 +230,7 @@ void Stack::PushTrack(Int_t toBeDone, Int_t parentId, Int_t pdgCode, Double_t px p.SetBit(ParticleStatus::kKeep); p.SetBit(ParticleStatus::kPrimary); if (toBeDone == 1) { - if (mTransportPrimary(p, mPrimaryParticles)) { - p.SetBit(ParticleStatus::kToBeDone, 1); - mNumberOfPrimariesforTracking++; - } else { - p.SetBit(ParticleStatus::kToBeDone, 0); - p.SetBit(ParticleStatus::kInhibited, 1); - } + handleTransportPrimary(p); } else { p.SetBit(ParticleStatus::kToBeDone, 0); } @@ -256,6 +250,20 @@ void Stack::PushTrack(Int_t toBeDone, Int_t parentId, Int_t pdgCode, Double_t px mStack.push(p); } +void Stack::handleTransportPrimary(TParticle& p) +{ + // this function tests whether we really want to transport + // this particle and sets the relevant bits accordingly + + if (mTransportPrimary(p, mPrimaryParticles)) { + p.SetBit(ParticleStatus::kToBeDone, 1); + mNumberOfPrimariesforTracking++; + } else { + p.SetBit(ParticleStatus::kToBeDone, 0); + p.SetBit(ParticleStatus::kInhibited, 1); + } +} + void Stack::PushTrack(int toBeDone, TParticle& p) { // printf("stack -> Pushing Primary toBeDone %5d %5d parentId %5d pdgCode %5d is %5d entries %5d \n", toBeDone, p.TestBit(ParticleStatus::kToBeDone), p.GetFirstMother(), p.GetPdgCode(), p.GetStatusCode(), mNumberOfEntriesInParticles); @@ -266,12 +274,12 @@ void Stack::PushTrack(int toBeDone, TParticle& p) if (p.GetUniqueID() == 0) { // one to one mapping for primaries mIndexMap[mNumberOfPrimaryParticles] = mNumberOfPrimaryParticles; - mNumberOfPrimaryParticles++; - mPrimaryParticles.push_back(p); // Push particle on the stack if (p.TestBit(ParticleStatus::kPrimary) && p.TestBit(ParticleStatus::kToBeDone)) { - mNumberOfPrimariesforTracking++; + handleTransportPrimary(p); } + mNumberOfPrimaryParticles++; + mPrimaryParticles.push_back(p); mStack.push(p); mTracks->emplace_back(p); } From 8ffd45ddb561dba66550a60261c4bfa914e1a1d1 Mon Sep 17 00:00:00 2001 From: Roberto Preghenella Date: Tue, 19 Jan 2021 13:22:09 +0100 Subject: [PATCH 2/2] Add inhibited flag to MCTrack::PropEncoding and reduce hitmask bitfield --- .../include/SimulationDataFormat/MCTrack.h | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/DataFormats/simulation/include/SimulationDataFormat/MCTrack.h b/DataFormats/simulation/include/SimulationDataFormat/MCTrack.h index 307e398453884..87f57c3a0f406 100644 --- a/DataFormats/simulation/include/SimulationDataFormat/MCTrack.h +++ b/DataFormats/simulation/include/SimulationDataFormat/MCTrack.h @@ -194,6 +194,14 @@ class MCTrackT } bool getToBeDone() const { return ((PropEncoding)mProp).toBeDone; } + void setInhibited(bool f) + { + auto prop = ((PropEncoding)mProp); + prop.inhibited = f; + mProp = prop.i; + } + bool getInhibited() const { return ((PropEncoding)mProp).inhibited; } + /// get the string representation of the production process const char* getProdProcessAsString() const; @@ -226,12 +234,15 @@ class MCTrackT struct { int storage : 1; // encoding whether to store this track to the output int process : 6; // encoding process that created this track (enough to store TMCProcess from ROOT) - int hitmask : 24; // encoding hits per detector + int hitmask : 21; // encoding hits per detector + int reserved1 : 1; // bit reserved for possible future purposes + int reserved2 : 1; // bit reserved for possible future purposes + int inhibited : 1; // whether tracking of this was inhibited int toBeDone : 1; // whether this (still) needs tracking --> we might more complete information to cover full ParticleStatus space }; }; - ClassDefNV(MCTrackT, 3); + ClassDefNV(MCTrackT, 4); }; template @@ -318,6 +329,11 @@ inline MCTrackT::MCTrackT(const TParticle& part) setProcess(part.GetUniqueID()); // extract toBeDone flag setToBeDone(part.TestBit(ParticleStatus::kToBeDone)); + // extract inhibited flag + if (part.TestBit(ParticleStatus::kInhibited)) { + setToBeDone(true); // if inhibited, it had to be done: restore flag + setInhibited(true); + } } template