Skip to content

Commit 25df4ba

Browse files
committed
SVStudy: Add mc mother pdg code
1 parent 3615d30 commit 25df4ba

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/V0Ext.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
#include "ReconstructionDataFormats/V0.h"
1818
#include "SimulationDataFormat/MCCompLabel.h"
1919

20-
namespace o2
21-
{
22-
namespace dataformats
20+
namespace o2::dataformats
2321
{
2422

2523
struct ProngInfoExt {
@@ -40,10 +38,10 @@ struct V0Ext {
4038
V0Index v0ID;
4139
std::array<ProngInfoExt, 2> prInfo{};
4240
const ProngInfoExt& getPrInfo(int i) const { return prInfo[i]; }
43-
ClassDefNV(V0Ext, 1);
41+
int mcPID = -1;
42+
ClassDefNV(V0Ext, 2);
4443
};
4544

46-
} // namespace dataformats
47-
} // namespace o2
45+
} // namespace o2::dataformats
4846

4947
#endif

Detectors/GlobalTrackingWorkflow/study/src/SVStudy.cxx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "DetectorsBase/GeometryManager.h"
2323
#include "SimulationDataFormat/MCEventLabel.h"
2424
#include "SimulationDataFormat/MCUtils.h"
25+
#include "SimulationDataFormat/MCTrack.h"
2526
#include "CommonDataFormat/BunchFilling.h"
2627
#include "CommonUtils/NameConf.h"
2728
#include "DataFormatsFT0/RecPoints.h"
@@ -86,7 +87,7 @@ class SVStudySpec : public Task
8687
float mBz = 0;
8788
GTrackID::mask_t mTracksSrc{};
8889
o2::vertexing::DCAFitterN<2> mFitterV0;
89-
o2::steer::MCKinematicsReader mcReader; // reader of MC information
90+
std::unique_ptr<o2::steer::MCKinematicsReader> mcReader; // reader of MC information
9091
};
9192

9293
void SVStudySpec::init(InitContext& ic)
@@ -96,6 +97,9 @@ void SVStudySpec::init(InitContext& ic)
9697
mRefit = ic.options().get<bool>("refit");
9798
mSelK0 = ic.options().get<float>("sel-k0");
9899
mMaxEta = ic.options().get<float>("max-eta");
100+
if (mUseMC) {
101+
mcReader = std::make_unique<o2::steer::MCKinematicsReader>("collisioncontext.root");
102+
}
99103
}
100104

101105
void SVStudySpec::run(ProcessingContext& pc)
@@ -162,6 +166,7 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
162166
}
163167
v0ext.v0ID = v0id;
164168
o2::MCCompLabel lb;
169+
const o2::MCTrack* mcTrks[2];
165170
for (int ip = 0; ip < 2; ip++) {
166171
auto& prInfo = v0ext.prInfo[ip];
167172
auto gid = v0ext.v0ID.getProngID(ip);
@@ -218,6 +223,16 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
218223
}
219224
}
220225
}
226+
if (mUseMC) { // temp store of mctrks
227+
mcTrks[ip] = mcReader->getTrack(lb);
228+
}
229+
}
230+
if (mUseMC && (mcTrks[0] != nullptr) && (mcTrks[1] != nullptr)) {
231+
// check majority vote on mother particle otherwise leave pdg -1
232+
if (mcTrks[0]->getMotherTrackId() == mcTrks[1]->getMotherTrackId()) {
233+
const auto mother = mcReader->getTrack(lb.getSourceID(), lb.getEventID(), mcTrks[0]->getMotherTrackId());
234+
v0ext.mcPID = mother->GetPdgCode();
235+
}
221236
}
222237
return v0ext;
223238
}

0 commit comments

Comments
 (0)