@@ -72,9 +72,11 @@ using PID = o2::track::PID;
7272
7373// structure for storing the output tree
7474struct particle {
75+ // mc properties
7576 int pdg = -1 ;
77+ bool fakeMatch = 0 ;
78+ // reco properties
7679 int sign = -1 ;
77- float rofBC;
7880 float p, pt, pTPC, pITS, eta, phi, tgL, chi2ITS, chi2TPC, chi2ITSTPC;
7981 int nClusTPC;
8082 float dEdx, nSigmaDeu, nSigmaP, nSigmaK, nSigmaPi, nSigmaE;
@@ -118,12 +120,8 @@ class PIDStudy : public Task
118120 std::vector<int > mClusterSizes ;
119121 gsl::span<const o2::itsmft::CompClusterExt> mClusters ;
120122 gsl::span<const int > mInputITSidxs ;
121- std::vector<o2::MCTrack> mMCTracks ;
122123 const o2::itsmft::TopologyDictionary* mDict = nullptr ;
123124
124- // output vector
125- std::vector<particle> mParticles ;
126-
127125 std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut ;
128126 std::string mOutName ;
129127 std::shared_ptr<o2::steer::MCKinematicsReader> mKineReader ;
@@ -136,10 +134,6 @@ void PIDStudy::init(InitContext& ic)
136134
137135 if (mUseMC ) { // for counting the missed K0shorts
138136 mKineReader = std::make_unique<o2::steer::MCKinematicsReader>(" collisioncontext.root" );
139- for (int iEvent{0 }; iEvent < mKineReader ->getNEvents (0 ); iEvent++) {
140- auto mctrk = mKineReader ->getTracks (0 , iEvent);
141- mMCTracks .insert (mMCTracks .end (), mctrk.begin (), mctrk.end ());
142- }
143137 }
144138 auto & params = o2::its::study::PIDStudyParamConfig::Instance ();
145139 mOutName = params.outFileName ;
@@ -192,9 +186,16 @@ void PIDStudy::process(o2::globaltracking::RecoContainer& recoData)
192186{
193187 loadData (recoData);
194188 auto ITSTPCtracks = recoData.getTPCITSTracks ();
189+ LOGP (debug, " Found {} ITSTPC tracks." , ITSTPCtracks.size ());
190+
191+ gsl::span<const o2::MCCompLabel> mcLabelsITS, mcLabelsTPC;
192+ if (mUseMC ) {
193+ mcLabelsITS = recoData.getITSTracksMCLabels ();
194+ mcLabelsTPC = recoData.getTPCTracksMCLabels ();
195+ LOGP (debug, " Found {} ITS labels." , mcLabelsITS.size ());
196+ LOGP (debug, " Found {} TPC labels." , mcLabelsTPC.size ());
197+ }
195198
196- LOG (debug) << " Data loaded, looping over tracks..."
197- << " , number of ITS-TPC tracks: " << ITSTPCtracks.size ();
198199 for (unsigned int iTrack{0 }; iTrack < ITSTPCtracks.size (); ++iTrack) {
199200
200201 auto & ITSTPCtrack = ITSTPCtracks[iTrack];
@@ -205,6 +206,17 @@ void PIDStudy::process(o2::globaltracking::RecoContainer& recoData)
205206 auto ITStrack = recoData.getITSTrack (ITSTPCtrack.getRefITS ());
206207 auto TPCtrack = recoData.getTPCTrack (ITSTPCtrack.getRefTPC ());
207208
209+ if (mUseMC ) {
210+ // MC info
211+ auto & mcLabelITS = mcLabelsITS[ITSTPCtrack.getRefITS ().getIndex ()];
212+ auto & mcLabelTPC = mcLabelsTPC[ITSTPCtrack.getRefTPC ().getIndex ()];
213+ if (mcLabelITS.getTrackID () != (int )mcLabelTPC.getTrackID ()) {
214+ part.fakeMatch = 1 ;
215+ }
216+ auto mctrk = mKineReader ->getTrack (mcLabelITS);
217+ part.pdg = mctrk->GetPdgCode ();
218+ }
219+
208220 part.sign = ITSTPCtrack.getSign ();
209221 part.clSizesITS = getTrackClusterSizes (ITStrack);
210222 part.p = ITSTPCtrack.getP ();
@@ -236,6 +248,10 @@ void PIDStudy::process(o2::globaltracking::RecoContainer& recoData)
236248 part.nSigmaPi = computeNSigma (PID ::Pion, TPCtrack, 0.07 );
237249 part.nSigmaE = computeNSigma (PID ::Electron, TPCtrack, 0.07 );
238250
251+ if (mUseMC ) {
252+ (*mDBGOut ) << " outTree"
253+ << " pdg=" << part.pdg << " fakeMatch=" << part.fakeMatch ;
254+ }
239255 (*mDBGOut ) << " outTree"
240256 << " sign=" << part.sign << " p=" << part.p << " pt=" << part.pt << " pTPC=" << part.pTPC << " pITS=" << part.pITS
241257 << " eta=" << part.eta << " phi=" << part.phi << " tgL=" << part.tgL << " chi2ITS=" << part.chi2ITS << " chi2TPC="
0 commit comments