Skip to content

Commit cc19587

Browse files
authored
PrimaryGenerator that can propagate mother/daughter indices (#4361)
* PrimaryGenerator that can propagate mother/daughter indices * Pass mother2 as secondparent when pushing track to stack
1 parent e3e527a commit cc19587

3 files changed

Lines changed: 45 additions & 27 deletions

File tree

Generators/include/Generators/PrimaryGenerator.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,14 @@ class PrimaryGenerator : public FairPrimaryGenerator
5555
**/
5656
Bool_t GenerateEvent(FairGenericStack* pStack) override;
5757

58-
/** Public method AddTrack
59-
Adding a track to the MC stack. To be called within the ReadEvent
60-
methods of the registered generators.
61-
*@param pdgid Particle ID (PDG code)
62-
*@param px,py,pz Momentum coordinates [GeV]
63-
*@param vx,vy,vz Track origin relative to event vertex
64-
**/
58+
/** ALICE-o2 AddTrack with mother/daughter indices **/
6559
void AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t pz,
6660
Double_t vx, Double_t vy, Double_t vz,
67-
Int_t parent = -1, Bool_t wanttracking = true,
61+
Int_t mother1 = -1, Int_t mother2 = -1,
62+
Int_t daughter1 = -1, Int_t daughter2 = -1,
63+
Bool_t wanttracking = true,
6864
Double_t e = -9e9, Double_t tof = 0.,
69-
Double_t weight = 0., TMCProcess proc = kPPrimary) override;
65+
Double_t weight = 0., TMCProcess proc = kPPrimary);
7066

7167
/** initialize the generator **/
7268
Bool_t Init() override;

Generators/src/Generator.cxx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "Generators/Generator.h"
1414
#include "Generators/Trigger.h"
15+
#include "Generators/PrimaryGenerator.h"
1516
#include "FairPrimaryGenerator.h"
1617
#include "FairLogger.h"
1718
#include <cmath>
@@ -97,20 +98,29 @@ Bool_t
9798
{
9899
/** add tracks **/
99100

101+
auto o2primGen = dynamic_cast<PrimaryGenerator*>(primGen);
102+
if (!o2primGen) {
103+
LOG(FATAL) << "PrimaryGenerator is not a o2::eventgen::PrimaryGenerator";
104+
return kFALSE;
105+
}
106+
100107
/** loop over particles **/
101108
for (const auto& particle : mParticles) {
102-
primGen->AddTrack(particle.GetPdgCode(),
103-
particle.Px() * mMomentumUnit,
104-
particle.Py() * mMomentumUnit,
105-
particle.Pz() * mMomentumUnit,
106-
particle.Vx() * mPositionUnit,
107-
particle.Vy() * mPositionUnit,
108-
particle.Vz() * mPositionUnit,
109-
particle.GetMother(0),
110-
particle.GetStatusCode() == 1,
111-
particle.Energy() * mEnergyUnit,
112-
particle.T() * mTimeUnit,
113-
particle.GetWeight());
109+
o2primGen->AddTrack(particle.GetPdgCode(),
110+
particle.Px() * mMomentumUnit,
111+
particle.Py() * mMomentumUnit,
112+
particle.Pz() * mMomentumUnit,
113+
particle.Vx() * mPositionUnit,
114+
particle.Vy() * mPositionUnit,
115+
particle.Vz() * mPositionUnit,
116+
particle.GetMother(0),
117+
particle.GetMother(1),
118+
particle.GetDaughter(0),
119+
particle.GetDaughter(1),
120+
particle.GetStatusCode() == 1,
121+
particle.Energy() * mEnergyUnit,
122+
particle.T() * mTimeUnit,
123+
particle.GetWeight());
114124
}
115125

116126
/** success **/

Generators/src/PrimaryGenerator.cxx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ Bool_t PrimaryGenerator::GenerateEvent(FairGenericStack* pStack)
116116

117117
void PrimaryGenerator::AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t pz,
118118
Double_t vx, Double_t vy, Double_t vz,
119-
Int_t parent, Bool_t wanttracking,
119+
Int_t mother1, Int_t mother2,
120+
Int_t daughter1, Int_t daughter2,
121+
Bool_t wanttracking,
120122
Double_t e, Double_t tof,
121123
Double_t weight, TMCProcess proc)
122124
{
@@ -146,9 +148,19 @@ void PrimaryGenerator::AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t
146148
Int_t ntr = 0; // Track number; to be filled by the stack
147149
Int_t status = 0; // Generation status
148150

149-
if (parent != -1) {
150-
parent += fMCIndexOffset;
151-
} // correct for tracks which are in list before generator is called
151+
// correct for tracks which are in list before generator is called
152+
if (mother1 != -1) {
153+
mother1 += fMCIndexOffset;
154+
}
155+
if (mother2 != -1) {
156+
mother2 += fMCIndexOffset;
157+
}
158+
if (daughter1 != -1) {
159+
daughter1 += fMCIndexOffset;
160+
}
161+
if (daughter2 != -1) {
162+
daughter2 += fMCIndexOffset;
163+
}
152164

153165
/** if it is a K0/antiK0 to be tracked, convert it into K0s/K0L.
154166
@@ -170,9 +182,9 @@ void PrimaryGenerator::AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t
170182
}
171183

172184
/** add track to stack **/
173-
fStack->PushTrack(doTracking, parent, pdgid, px, py, pz,
185+
fStack->PushTrack(doTracking, mother1, pdgid, px, py, pz,
174186
e, vx, vy, vz, tof, polx, poly, polz, proc, ntr,
175-
weight, status, parent);
187+
weight, status, mother2);
176188

177189
fNTracks++;
178190
}

0 commit comments

Comments
 (0)