Skip to content

Commit c5bd2e4

Browse files
committed
Provide MC generator status code as part of MCTrack
Status codes provided from MC generators (as part of TParticle) are now propagated and stored in MCTrack (for primary particles). This should allow to fill the necessary information in AOD tables. Some future memory optimization can be done and is targeted (avoiding extra data member for this).
1 parent 5ac8c36 commit c5bd2e4

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

DataFormats/simulation/include/SimulationDataFormat/MCTrack.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ class MCTrackT
187187
/// get the production process (id) of this track
188188
int getProcess() const { return ((PropEncoding)mProp).process; }
189189

190+
/// get generator status code
191+
int getStatusCode() const { return mStatusCode; }
192+
190193
void setToBeDone(bool f)
191194
{
192195
auto prop = ((PropEncoding)mProp);
@@ -245,6 +248,11 @@ class MCTrackT
245248
};
246249
};
247250

251+
// Additional status codes for MC generator information.
252+
// NOTE: This additional memory cost might be reduced by using bits elsewhere
253+
// such as part of mProp (process) or mPDG
254+
Int_t mStatusCode = 0;
255+
248256
ClassDefNV(MCTrackT, 4);
249257
};
250258

@@ -326,7 +334,8 @@ inline MCTrackT<T>::MCTrackT(const TParticle& part)
326334
mStartVertexCoordinatesY(part.Vy()),
327335
mStartVertexCoordinatesZ(part.Vz()),
328336
mStartVertexCoordinatesT(part.T() * 1e09),
329-
mProp(0)
337+
mProp(0),
338+
mStatusCode(0)
330339
{
331340
// our convention is to communicate the process as (part) of the unique ID
332341
setProcess(part.GetUniqueID());
@@ -339,6 +348,8 @@ inline MCTrackT<T>::MCTrackT(const TParticle& part)
339348
setToBeDone(true); // if inhibited, it had to be done: restore flag
340349
setInhibited(true);
341350
}
351+
// set MC generator status code only for primaries
352+
mStatusCode = part.TestBit(ParticleStatus::kPrimary) ? part.GetStatusCode() : -1;
342353
}
343354

344355
template <typename T>

Generators/include/Generators/PrimaryGenerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class PrimaryGenerator : public FairPrimaryGenerator
6363
Int_t daughter1 = -1, Int_t daughter2 = -1,
6464
Bool_t wanttracking = true,
6565
Double_t e = -9e9, Double_t tof = 0.,
66-
Double_t weight = 0., TMCProcess proc = kPPrimary);
66+
Double_t weight = 0., TMCProcess proc = kPPrimary, Int_t generatorStatus = 0);
6767

6868
/** initialize the generator **/
6969
Bool_t Init() override;

Generators/src/Generator.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ Bool_t
135135
particle.Energy() * mEnergyUnit,
136136
particle.T() * mTimeUnit,
137137
particle.GetWeight(),
138-
(TMCProcess)particle.GetUniqueID());
138+
(TMCProcess)particle.GetUniqueID(),
139+
particle.GetStatusCode()); // generator status information passed as status code field
139140
}
140141

141142
/** success **/

Generators/src/PrimaryGenerator.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void PrimaryGenerator::AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t
126126
Int_t daughter1, Int_t daughter2,
127127
Bool_t wanttracking,
128128
Double_t e, Double_t tof,
129-
Double_t weight, TMCProcess proc)
129+
Double_t weight, TMCProcess proc, Int_t generatorStatus)
130130
{
131131
/** add track **/
132132

@@ -152,7 +152,7 @@ void PrimaryGenerator::AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t
152152
Double_t poly = 0.;
153153
Double_t polz = 0.;
154154
Int_t ntr = 0; // Track number; to be filled by the stack
155-
Int_t status = 0; // Generation status
155+
Int_t status = generatorStatus; // Generation status
156156

157157
// correct for tracks which are in list before generator is called
158158
if (mother1 != -1) {

0 commit comments

Comments
 (0)