Skip to content

Commit c7404dc

Browse files
preghenellasawenzel
authored andcommitted
Allow access all primary particles for selective transport
1 parent 7acefbb commit c7404dc

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

DataFormats/simulation/include/SimulationDataFormat/Stack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class Stack : public FairGenericStack
225225
/// update values in the current event header
226226
void updateEventStats();
227227

228-
typedef std::function<bool(const TParticle& p)> TransportFcn;
228+
typedef std::function<bool(const TParticle& p, const std::vector<TParticle>& particles)> TransportFcn;
229229

230230
private:
231231
/// STL stack (FILO) used to handle the TParticles for tracking
@@ -283,7 +283,7 @@ class Stack : public FairGenericStack
283283

284284
bool mIsExternalMode = false; // is stack an external factory or directly used inside simulation?
285285

286-
TransportFcn mTransportPrimary = [](const TParticle& p) { return false; }; //! a function to inhibit the tracking of a particle
286+
TransportFcn mTransportPrimary = [](const TParticle& p, const std::vector<TParticle>& particles) { return false; }; //! a function to inhibit the tracking of a particle
287287

288288
// storage for track references
289289
std::vector<o2::TrackReference>* mTrackRefs = nullptr; //!

DataFormats/simulation/src/Stack.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ Stack::Stack(Int_t size)
8585
LOG(INFO) << param;
8686
TransportFcn transportPrimary;
8787
if (param.transportPrimary.compare("none") == 0) {
88-
transportPrimary = [](const TParticle& p) {
88+
transportPrimary = [](const TParticle& p, const std::vector<TParticle>& particles) {
8989
return false;
9090
};
9191
} else if (param.transportPrimary.compare("all") == 0) {
92-
transportPrimary = [](const TParticle& p) {
92+
transportPrimary = [](const TParticle& p, const std::vector<TParticle>& particles) {
9393
return true;
9494
};
9595
} else if (param.transportPrimary.compare("barrel") == 0) {
96-
transportPrimary = [](const TParticle& p) {
96+
transportPrimary = [](const TParticle& p, const std::vector<TParticle>& particles) {
9797
return (std::fabs(p.Eta()) < 2.0);
9898
};
9999
} else if (param.transportPrimary.compare("external") == 0) {
@@ -108,7 +108,7 @@ Stack::Stack(Int_t size)
108108
}
109109

110110
if (param.transportPrimaryInvert) {
111-
mTransportPrimary = [transportPrimary](const TParticle& p) { return !transportPrimary; };
111+
mTransportPrimary = [transportPrimary](const TParticle& p, const std::vector<TParticle>& particles) { return !transportPrimary; };
112112
} else {
113113
mTransportPrimary = transportPrimary;
114114
}
@@ -230,7 +230,7 @@ void Stack::PushTrack(Int_t toBeDone, Int_t parentId, Int_t pdgCode, Double_t px
230230
p.SetBit(ParticleStatus::kKeep);
231231
p.SetBit(ParticleStatus::kPrimary);
232232
if (toBeDone == 1) {
233-
if (mTransportPrimary(p)) {
233+
if (mTransportPrimary(p, mPrimaryParticles)) {
234234
p.SetBit(ParticleStatus::kToBeDone, 1);
235235
mNumberOfPrimariesforTracking++;
236236
} else {
File renamed without changes.
File renamed without changes.

run/SimExamples/Selective_Tranport/transportPDG.macro renamed to run/SimExamples/Selective_Transport/transportPDG.macro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
o2::data::Stack::TransportFcn
22
transportPDG(int pdg = 321)
33
{
4-
return [pdg](const TParticle& p) -> bool {
4+
return [pdg](const TParticle& p, const std::vector<TParticle>& particles) -> bool {
55
return p.GetPdgCode() == pdg;
66
};
77
}

0 commit comments

Comments
 (0)