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
9293void 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
101105void SVStudySpec::run (ProcessingContext& pc)
@@ -161,23 +165,24 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
161165 v0ext.v0 = v0sel;
162166 }
163167 v0ext.v0ID = v0id;
164- o2::MCCompLabel lb;
168+ o2::MCCompLabel lb[2 ];
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);
168173 auto gidset = recoData.getSingleDetectorRefs (gid);
169- lb = recoData.getTrackMCLabel (gid);
170- if (lb.isValid ()) {
171- prInfo.corrGlo = !lb.isFake ();
174+ lb[ip] = recoData.getTrackMCLabel (gid);
175+ if (lb[ip] .isValid ()) {
176+ prInfo.corrGlo = !lb[ip] .isFake ();
172177 }
173178 // get TPC tracks, if any
174179 if (gidset[GTrackID::TPC].isSourceSet ()) {
175180 const auto & tpcTr = recoData.getTPCTrack (gidset[GTrackID::TPC]);
176181 prInfo.trackTPC = tpcTr;
177182 prInfo.nClTPC = tpcTr.getNClusters ();
178- lb = recoData.getTrackMCLabel (gidset[GTrackID::TPC]);
179- if (lb.isValid ()) {
180- prInfo.corrTPC = !lb.isFake ();
183+ lb[ip] = recoData.getTrackMCLabel (gidset[GTrackID::TPC]);
184+ if (lb[ip] .isValid ()) {
185+ prInfo.corrTPC = !lb[ip] .isFake ();
181186 }
182187 }
183188 // get ITS tracks, if any
@@ -186,9 +191,9 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
186191 if (gidset[GTrackID::ITS].isSourceSet ()) {
187192 const auto & itsTr = recoData.getITSTrack (gidset[GTrackID::ITS]);
188193 prInfo.nClITS = itsTr.getNClusters ();
189- lb = recoData.getTrackMCLabel (gidset[GTrackID::ITS]);
190- if (lb.isValid ()) {
191- prInfo.corrITS = !lb.isFake ();
194+ lb[ip] = recoData.getTrackMCLabel (gidset[GTrackID::ITS]);
195+ if (lb[ip] .isValid ()) {
196+ prInfo.corrITS = !lb[ip] .isFake ();
192197 }
193198 for (int il = 0 ; il < 7 ; il++) {
194199 if (itsTr.hasHitOnLayer (il)) {
@@ -198,9 +203,9 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
198203 } else {
199204 const auto & itsTrf = recoData.getITSABRefs ()[gidset[GTrackID::ITSAB]];
200205 prInfo.nClITS = itsTrf.getNClusters ();
201- lb = recoData.getTrackMCLabel (gidset[GTrackID::ITSAB]);
202- if (lb.isValid ()) {
203- prInfo.corrITS = !lb.isFake ();
206+ lb[ip] = recoData.getTrackMCLabel (gidset[GTrackID::ITSAB]);
207+ if (lb[ip] .isValid ()) {
208+ prInfo.corrITS = !lb[ip] .isFake ();
204209 }
205210 for (int il = 0 ; il < 7 ; il++) {
206211 if (itsTrf.hasHitOnLayer (il)) {
@@ -211,13 +216,24 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
211216 }
212217 if (gidset[GTrackID::ITSTPC].isSourceSet ()) {
213218 auto mtc = recoData.getTPCITSTrack (gidset[GTrackID::ITSTPC]);
214- lb = recoData.getTrackMCLabel (gidset[GTrackID::ITSTPC]);
219+ lb[ip] = recoData.getTrackMCLabel (gidset[GTrackID::ITSTPC]);
215220 prInfo.chi2ITSTPC = mtc.getChi2Match ();
216- if (lb.isValid ()) {
217- prInfo.corrITSTPC = !lb.isFake ();
221+ if (lb[ip] .isValid ()) {
222+ prInfo.corrITSTPC = !lb[ip] .isFake ();
218223 }
219224 }
220225 }
226+ if (mUseMC && lb[ip].isValid ()) { // temp store of mctrks
227+ mcTrks[ip] = mcReader->getTrack (lb[ip]);
228+ }
229+ }
230+ if (mUseMC && (mcTrks[0 ] != nullptr ) && (mcTrks[1 ] != nullptr )) {
231+ // check majority vote on mother particle otherwise leave pdg -1
232+ if (lb[0 ].getSourceID () == lb[1 ].getSourceID () && lb[0 ].getEventID () == lb[1 ].getEventID () &&
233+ mcTrks[0 ]->getMotherTrackId () == mcTrks[1 ]->getMotherTrackId () && mcTrks[0 ]->getMotherTrackId () >= 0 ) {
234+ const auto mother = mcReader->getTrack (lb[0 ].getSourceID (), lb[0 ].getEventID (), mcTrks[0 ]->getMotherTrackId ());
235+ v0ext.mcPID = mother->GetPdgCode ();
236+ }
221237 }
222238 return v0ext;
223239}
0 commit comments