@@ -109,7 +109,7 @@ class TrackMCStudy : public Task
109109 void updateTimeDependentParams (ProcessingContext& pc);
110110 float getDCAYCut (float pt) const ;
111111
112- gsl::span< const MCTrack> mCurrMCTracks ;
112+ const std::vector<o2:: MCTrack>* mCurrMCTracks = nullptr ;
113113 TVector3 mCurrMCVertex ;
114114 o2::tpc::VDriftHelper mTPCVDriftHelper {};
115115 o2::tpc::CorrectionMapsLoader mTPCCorrMapsLoader {};
@@ -124,7 +124,7 @@ class TrackMCStudy : public Task
124124 bool mCheckSV = false ; // < check SV binding (apart from prongs availability)
125125 bool mRecProcStage = false ; // < flag that the MC particle was added only at the stage of reco tracks processing
126126 int mNTPCOccBinLength = 0 ; // /< TPC occ. histo bin length in TBs
127- float mNTPCOccBinLengthInv ;
127+ float mNTPCOccBinLengthInv = - 1 .f ;
128128 int mVerbose = 0 ;
129129 float mITSTimeBiasMUS = 0 .f;
130130 float mITSROFrameLengthMUS = 0 .f; // /< ITS RO frame in mus
@@ -182,7 +182,7 @@ void TrackMCStudy::run(ProcessingContext& pc)
182182 }
183183 mDecProdLblPool .clear ();
184184 mMCVtVec .clear ();
185- mCurrMCTracks = {} ;
185+ mCurrMCTracks = nullptr ;
186186
187187 recoData.collectData (pc, *mDataRequest .get ()); // select tracks of needed type, with minimal cuts, the real selected will be done in the vertexer
188188 updateTimeDependentParams (pc); // Make sure this is called after recoData.collectData, which may load some conditions
@@ -346,6 +346,21 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
346346 }
347347 break ;
348348 }
349+ if (mNTPCOccBinLengthInv > 0 .f ) {
350+ mcVtx.occTPCV .resize (params.nOccBinsDrift );
351+ int grp = TMath::Max (1 , TMath::Nint (params.nTBPerOccBin * mNTPCOccBinLengthInv ));
352+ for (int ib = 0 ; ib < params.nOccBinsDrift ; ib++) {
353+ float smb = 0 ;
354+ int tbs = occBin + TMath::Nint (ib * params.nTBPerOccBin * mNTPCOccBinLengthInv );
355+ for (int ig = 0 ; ig < grp; ig++) {
356+ if (tbs >= 0 && tbs < int (mTBinClOccHist .size ())) {
357+ smb += mTBinClOccHist [tbs];
358+ }
359+ tbs++;
360+ }
361+ mcVtx.occTPCV [ib] = smb;
362+ }
363+ }
349364 if (rofCount >= ITSClusROFRec.size ()) {
350365 mITSOcc .push_back (0 ); // IR after the last ROF
351366 }
@@ -362,13 +377,15 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
362377 if (nev != (int )mMCVtVec .size ()) {
363378 LOGP (debug, " source {} has {} events while {} MC vertices were booked" , curSrcMC, nev, mMCVtVec .size ());
364379 okAccVtx = false ;
380+ if (nev > (int )mMCVtVec .size ()) { // QED
381+ continue ;
382+ }
365383 }
366384 for (curEvMC = 0 ; curEvMC < nev; curEvMC++) {
367385 if (mVerbose > 1 ) {
368386 LOGP (info, " Event {}" , curEvMC);
369387 }
370- const auto & mt = mcReader.getTracks (curSrcMC, curEvMC);
371- mCurrMCTracks = gsl::span<const MCTrack>(mt.data (), mt.size ());
388+ mCurrMCTracks = &mcReader.getTracks (curSrcMC, curEvMC);
372389 const_cast <o2::dataformats::MCEventHeader&>(mcReader.getMCEventHeader (curSrcMC, curEvMC)).GetVertex (mCurrMCVertex );
373390 if (okAccVtx) {
374391 auto & pos = mMCVtVec [curEvMC].pos ;
@@ -378,7 +395,7 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
378395 pos[2 ] = mCurrMCVertex .Z ();
379396 }
380397 }
381- for (int itr = 0 ; itr < mCurrMCTracks . size (); itr++) {
398+ for (int itr = 0 ; itr < mCurrMCTracks -> size (); itr++) {
382399 processMCParticle (curSrcMC, curEvMC, itr);
383400 }
384401 }
@@ -425,11 +442,10 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
425442 if (lbl.getSourceID () != curSrcMC || lbl.getEventID () != curEvMC) {
426443 curSrcMC = lbl.getSourceID ();
427444 curEvMC = lbl.getEventID ();
428- const auto & mt = mcReader.getTracks (curSrcMC, curEvMC);
429- mCurrMCTracks = gsl::span<const MCTrack>(mt.data (), mt.size ());
445+ mCurrMCTracks = &mcReader.getTracks (curSrcMC, curEvMC);
430446 const_cast <o2::dataformats::MCEventHeader&>(mcReader.getMCEventHeader (curSrcMC, curEvMC)).GetVertex (mCurrMCVertex );
431447 }
432- if (!acceptMCCharged (mCurrMCTracks [lbl.getTrackID ()], lbl)) {
448+ if (!acceptMCCharged ((* mCurrMCTracks ) [lbl.getTrackID ()], lbl)) {
433449 continue ;
434450 }
435451 entry = mSelMCTracks .find (lbl);
@@ -977,7 +993,7 @@ float TrackMCStudy::getDCAYCut(float pt) const
977993
978994bool TrackMCStudy::processMCParticle (int src, int ev, int trid)
979995{
980- const auto & mcPart = mCurrMCTracks [trid];
996+ const auto & mcPart = (* mCurrMCTracks ) [trid];
981997 int pdg = mcPart.GetPdgCode ();
982998 bool res = false ;
983999 while (true ) {
@@ -999,7 +1015,7 @@ bool TrackMCStudy::processMCParticle(int src, int ev, int trid)
9991015 break ;
10001016 }
10011017 for (int idd = idd0; idd <= idd1; idd++) {
1002- const auto & product = mCurrMCTracks [idd];
1018+ const auto & product = (* mCurrMCTracks ) [idd];
10031019 auto lbld = o2::MCCompLabel (idd, ev, src);
10041020 if (!acceptMCCharged (product, lbld, decay)) {
10051021 decay = -1 ; // discard decay
@@ -1097,11 +1113,17 @@ bool TrackMCStudy::addMCParticle(const MCTrack& mcPart, const o2::MCCompLabel& l
10971113 mcEntry.mcTrackInfo .bcInTF = mIntBC [lb.getEventID ()];
10981114 mcEntry.mcTrackInfo .occTPC = mTPCOcc [lb.getEventID ()];
10991115 mcEntry.mcTrackInfo .occITS = mITSOcc [lb.getEventID ()];
1100- mcEntry.mcTrackInfo .addedAtRecStage = mRecProcStage ;
1116+ mcEntry.mcTrackInfo .occTPCV = mMCVtVec [lb.getEventID ()].occTPCV ;
1117+ if (mRecProcStage ) {
1118+ mcEntry.mcTrackInfo .setAddedAtRecStage ();
1119+ }
1120+ if (o2::mcutils::MCTrackNavigator::isPhysicalPrimary (mcPart, *mCurrMCTracks )) {
1121+ mcEntry.mcTrackInfo .setPrimary ();
1122+ }
11011123 int moth = -1 ;
11021124 o2::MCCompLabel mclbPar;
11031125 if ((moth = mcPart.getMotherTrackId ()) >= 0 ) {
1104- const auto & mcPartPar = mCurrMCTracks [moth];
1126+ const auto & mcPartPar = (* mCurrMCTracks ) [moth];
11051127 mcEntry.mcTrackInfo .pdgParent = mcPartPar.GetPdgCode ();
11061128 }
11071129 if (mcPart.isPrimary () && mcReader.getNEvents (lb.getSourceID ()) == mMCVtVec .size ()) {
0 commit comments