@@ -369,6 +369,28 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
369369 trf.gid = vid; // account(iv, vid);
370370 trf.pvID = pvID;
371371 trf.pvLabel = pvLbl;
372+ while (dm[DetID::ITS] && dm[DetID::TPC]) { // this track should have both ITS and TPC parts, if ITS was mismatched, fill it to its proper MC track slot
373+ auto gidSet = recoData.getSingleDetectorRefs (vid);
374+ if (!gidSet[GTrackID::ITS].isSourceSet ()) {
375+ break ; // AB track, nothing to check
376+ }
377+ auto lblITS = recoData.getTrackMCLabel (gidSet[GTrackID::ITS]);
378+ if (lblITS == trackFamily.mcTrackInfo .label ) {
379+ break ; // correct match, no need for special treatment
380+ }
381+ const auto & trcITSF = recoData.getTrackParam (gidSet[GTrackID::ITS]);
382+ if (trcITSF.getPt () < params.minPt || std::abs (trcITSF.getTgl ()) > params.maxTgl ) {
383+ break ; // ignore this track
384+ }
385+ auto entryOfFake = mSelMCTracks .find (lblITS);
386+ if (entryOfFake == mSelMCTracks .end ()) { // this MC track was not selected
387+ break ;
388+ }
389+ auto & trackFamilyOfFake = entryOfFake->second ;
390+ auto & trfOfFake = trackFamilyOfFake.recTracks .emplace_back ();
391+ trfOfFake.gid = gidSet[GTrackID::ITS]; // account(iv, vid);
392+ break ;
393+ }
372394 if (mVerbose > 1 ) {
373395 LOGP (info, " Matched rec track {} to MC track {}" , vid.asString (), entry->first .asString ());
374396 }
@@ -408,28 +430,49 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
408430 int tcnt = 0 ;
409431 for (auto & tref : tracks) {
410432 if (tref.gid .isSourceSet ()) {
433+ auto gidSet = recoData.getSingleDetectorRefs (tref.gid );
411434 tref.track = recoData.getTrackParam (tref.gid );
412- tref.isFake = recoData.getTrackMCLabel (tref.gid ).isFake ();
435+ if (recoData.getTrackMCLabel (tref.gid ).isFake ()) {
436+ tref.flags |= RecTrack::FakeGLO;
437+ }
413438 auto msk = tref.gid .getSourceDetectorsMask ();
414439 if (msk[DetID::ITS]) {
415- auto gidITS = recoData.getITSContributorGID (tref.gid );
416- tref.pattITS = getITSPatt (gidITS, tref.nClITS );
417- if (gidITS.getSource () == VTIndex::ITS && trackFam.entITS < 0 ) { // has ITS track rather than AB tracklet
418- trackFam.entITS = tcnt;
440+ if (gidSet[GTrackID::ITS].isSourceSet ()) { // has ITS track rather than AB tracklet
441+ tref.pattITS = getITSPatt (gidSet[GTrackID::ITS], tref.nClITS );
442+ if (trackFam.entITS < 0 ) {
443+ trackFam.entITS = tcnt;
444+ }
445+ auto lblITS = recoData.getTrackMCLabel (gidSet[GTrackID::ITS]);
446+ if (lblITS.isFake ()) {
447+ tref.flags |= RecTrack::FakeITS;
448+ }
449+ if (lblITS == trackFam.mcTrackInfo .label ) {
450+ trackFam.entITSFound = tcnt;
451+ }
452+ } else { // AB ITS tracklet
453+ tref.pattITS = getITSPatt (gidSet[GTrackID::ITSAB], tref.nClITS );
454+ if (recoData.getTrackMCLabel (gidSet[GTrackID::ITSAB]).isFake ()) {
455+ tref.flags |= RecTrack::FakeITS;
456+ }
419457 }
420458 if (msk[DetID::TPC] && trackFam.entITSTPC < 0 ) { // has both ITS and TPC contribution
421459 trackFam.entITSTPC = tcnt;
460+ if (recoData.getTrackMCLabel (gidSet[GTrackID::ITSTPC]).isFake ()) {
461+ tref.flags |= RecTrack::FakeITSTPC;
462+ }
422463 }
423464 }
424465 if (msk[DetID::TPC]) {
425- auto gidTPC = recoData.getTPCContributorGID (tref.gid );
426- const auto & trtpc = recoData.getTPCTrack (gidTPC);
466+ const auto & trtpc = recoData.getTPCTrack (gidSet[GTrackID::TPC]);
427467 tref.nClTPC = trtpc.getNClusters ();
428468 tref.lowestPadRow = getLowestPadrow (trtpc);
429469 if (trackFam.entTPC < 0 ) {
430470 trackFam.entTPC = tcnt;
431471 trackFam.tpcT0 = trtpc.getTime0 ();
432472 }
473+ if (recoData.getTrackMCLabel (gidSet[GTrackID::TPC]).isFake ()) {
474+ tref.flags |= RecTrack::FakeTPC;
475+ }
433476 }
434477 float ts = 0 , terr = 0 ;
435478 if (tref.gid .getSource () != GTrackID::ITS) {
@@ -473,16 +516,20 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
473516 std::string decTreeName = fmt::format (" dec{}" , params.decayPDG [id]);
474517 for (const auto & dec : mDecaysMaps [id]) {
475518 decFam.clear ();
519+ bool skip = false ;
476520 for (int idd = dec.daughterFirst ; idd <= dec.daughterLast ; idd++) {
477521 auto dtLbl = mDecProdLblPool [idd]; // daughter MC label
478522 const auto & dtFamily = mSelMCTracks [dtLbl];
479523 if (dtFamily.mcTrackInfo .pdgParent != dec.pdg ) {
480524 LOGP (error, " {}-th decay (pdg={}): {} in {}:{} range refers to MC track with pdgParent = {}" , id, params.decayPDG [id], idd, dec.daughterFirst , dec.daughterLast , dtFamily.mcTrackInfo .pdgParent );
481- continue ;
525+ skip = true ;
526+ break ;
482527 }
483528 decFam.push_back (dtFamily);
484529 }
485- (*mDBGOut ) << decTreeName.c_str () << " pdgPar=" << dec.pdg << " trPar=" << dec.parent << " prod=" << decFam << " \n " ;
530+ if (!skip) {
531+ (*mDBGOut ) << decTreeName.c_str () << " pdgPar=" << dec.pdg << " trPar=" << dec.parent << " prod=" << decFam << " \n " ;
532+ }
486533 }
487534 }
488535
@@ -745,7 +792,7 @@ bool TrackMCStudy::addMCParticle(const MCTrack& mcPart, const o2::MCCompLabel& l
745792 mcEntry.mcTrackInfo .occITS = mITSOcc [lb.getEventID ()];
746793 int moth = -1 ;
747794 o2::MCCompLabel mclbPar;
748- if (!mcPart. isPrimary () && (moth = mcPart.getMotherTrackId ()) >= 0 ) {
795+ if ((moth = mcPart.getMotherTrackId ()) >= 0 ) {
749796 const auto & mcPartPar = mCurrMCTracks [moth];
750797 mcEntry.mcTrackInfo .pdgParent = mcPartPar.GetPdgCode ();
751798 }
0 commit comments