@@ -90,7 +90,7 @@ class CheckResidSpec : public Task
9090 void updateTimeDependentParams (ProcessingContext& pc);
9191 bool refitPV (o2::dataformats::PrimaryVertex& pv, int vid);
9292 bool refitITStrack (o2::track::TrackParCov& track, GTrackID gid);
93- bool processITSTrack (const o2::its::TrackITS& iTrack, const o2::dataformats::PrimaryVertex& pv, o2::checkresid::Track& resTrack);
93+ bool processITSTrack (const o2::its::TrackITS& iTrack, const o2::dataformats::PrimaryVertex& pv, o2::checkresid::Track& resTrack, o2::track::PID pid );
9494 void bookHistos ();
9595 void fillHistos (const o2::checkresid::Track& trc);
9696 void postProcessHistos ();
@@ -115,6 +115,7 @@ class CheckResidSpec : public Task
115115 bool mFillHistos = true ;
116116 bool mFillTree = true ;
117117 std::vector<std::unique_ptr<o2::HistoManager>> mHManV {};
118+ std::vector<o2::dataformats::PrimaryVertex> mPVUsed ;
118119 o2::HistoManager* mHMan = nullptr ;
119120};
120121
@@ -255,6 +256,7 @@ void CheckResidSpec::process()
255256 static int TFCount = 0 ;
256257 int nv = vtxRefs.size () - 1 ;
257258 std::vector<std::vector<checkresid::Track>> slots;
259+ mPVUsed .clear ();
258260 slots.resize (mNThreads );
259261 int nvGood = 0 , nvUse = 0 , nvRefFail = 0 ;
260262 long pvFitDuration{};
@@ -276,55 +278,74 @@ void CheckResidSpec::process()
276278 }
277279 }
278280 nvUse++;
281+ mPVUsed .push_back (pve);
282+ const auto & itsContRefs = vtref.getITSGloContributors ();
283+ int idMinITSGlo = 0 , idMaxITSGlo = 0 ;
284+ if (params.useITSGloContributors ) {
285+ if (itsContRefs.getFirstEntry () < vtref.getEntries () && itsContRefs.getEntries () == 0 ) {
286+ LOGP (fatal, " Usage of stored ITS global contributors is requested but they are missing" );
287+ }
288+ idMinITSGlo = itsContRefs.getFirstEntry ();
289+ idMaxITSGlo = idMinITSGlo + itsContRefs.getEntries ();
290+ }
291+ int cntPVCont = 0 ;
279292 for (int is = 0 ; is < GTrackID::NSources; is++) {
280- if (!mTracksSrc [is] || !mRecoData ->isTrackSourceLoaded (is)) {
293+ if (!params. useITSGloContributors && (! mTracksSrc [is] || !mRecoData ->isTrackSourceLoaded (is) )) {
281294 continue ;
282295 }
283296 int idMin = vtref.getFirstEntryOfSource (is), idMax = idMin + vtref.getEntriesOfSource (is);
284297 DetID::mask_t dm = GTrackID::getSourceDetectorsMask (is);
285298 if (!dm[DetID::ITS]) {
286299 continue ;
287300 }
288- if (dm[DetID::TPC] && params.minTPCCl > 0 && !mRecoData ->isTrackSourceLoaded (GTrackID::TPC)) {
289- LOGP (fatal, " Cut on TPC tracks is requested by they are not loaded" );
290- }
291301#ifdef WITH_OPENMP
292302#pragma omp parallel for schedule(dynamic) num_threads(mNThreads)
293303#endif
294304 for (int i = idMin; i < idMax; i++) {
295305 auto vid = trackIndex[i];
296306 bool pvCont = vid.isPVContributor ();
297- if (!pvCont && params.pvcontribOnly ) {
298- continue ;
299- }
300- if (dm[DetID::TPC] && params.minTPCCl > 0 && mRecoData ->getTPCTrack (mRecoData ->getTPCContributorGID (vid)).getNClusters () < params.minTPCCl ) {
307+ if (!pvCont && (params.pvcontribOnly || params.useITSGloContributors )) {
301308 continue ;
302309 }
303- auto gidITS = mRecoData ->getITSContributorGID (vid);
304- if (gidITS.getSource () != GTrackID::ITS) {
305- continue ;
310+ GTrackID gidITS;
311+ o2::track::PID pidITS;
312+ if (params.useITSGloContributors ) {
313+ int id = idMinITSGlo + cntPVCont;
314+ if (id >= idMaxITSGlo) {
315+ LOGP (fatal, " Calculated GlobalContributor ITS track index {} exceeds number of stored indices {}" , id, itsContRefs.getEntries ());
316+ }
317+ pidITS = trackIndex[id].getSource ();
318+ gidITS = GTrackID (trackIndex[id].getIndex (), GTrackID::ITS);
319+ cntPVCont++;
320+ } else {
321+ gidITS = mRecoData ->getITSContributorGID (vid);
322+ if (gidITS.getSource () != GTrackID::ITS) {
323+ continue ;
324+ }
306325 }
307- const auto & trc = mRecoData ->getTrackParam (vid);
308326 const auto & itsTrack = mRecoData ->getITSTrack (gidITS);
309327 if (itsTrack.getNClusters () < params.minITSCl ) {
310328 continue ;
311329 }
330+ const auto & trc = params.useITSGloContributors ? ((o2::track::TrackParCov&)itsTrack) : mRecoData ->getTrackParam (vid);
331+ if (!params.useITSGloContributors ) {
332+ pidITS = trc.getPID ();
333+ }
312334 auto pt = trc.getPt ();
313335 if (pt < params.minPt || pt > params.maxPt ) {
314336 continue ;
315337 }
316338 if (std::abs (trc.getTgl ()) > params.maxTgl ) {
317339 continue ;
318340 }
319-
320341#ifdef WITH_OPENMP
321342 auto & accum = slots[omp_get_thread_num ()];
322343#else
323344 auto & accum = slots[0 ];
324345#endif
325346 auto & resTrack = accum.emplace_back ();
326347 resTrack.gid = vid;
327- if (!processITSTrack (itsTrack, pve, resTrack)) {
348+ if (!processITSTrack (itsTrack, pve, resTrack, pidITS )) {
328349 accum.pop_back ();
329350 continue ;
330351 }
@@ -342,15 +363,28 @@ void CheckResidSpec::process()
342363 }
343364 }
344365 }
366+ if (mDBGOut ) {
367+ (*mDBGOut ) << " pvUsed" << " pv=" << mPVUsed << " \n " ;
368+ }
369+ if (mHMan ) {
370+ for (const auto & pv : mPVUsed ) {
371+ mHMan ->getHisto (20000 + 0 )->Fill (pv.getX ());
372+ mHMan ->getHisto (20000 + 1 )->Fill (pv.getY ());
373+ mHMan ->getHisto (20000 + 2 )->Fill (pv.getZ ());
374+ mHMan ->getHisto (20000 + 3 )->Fill (pv.getNContributors ());
375+ }
376+ }
345377 LOGP (info, " processed {} PVs out of {} good vertices (out of {} in total), PV refits took {} mus, {} refits failed" , nvUse, nvGood, nv, pvFitDuration, nvRefFail);
346378 TFCount++;
347379}
348380
349- bool CheckResidSpec::processITSTrack (const o2::its::TrackITS& iTrack, const o2::dataformats::PrimaryVertex& pv, o2::checkresid::Track& resTrack)
381+ bool CheckResidSpec::processITSTrack (const o2::its::TrackITS& iTrack, const o2::dataformats::PrimaryVertex& pv, o2::checkresid::Track& resTrack, o2::track::PID pid )
350382{
351383 const auto itsClRefs = mRecoData ->getITSTracksClusterRefs ();
352384 auto trFitInw = iTrack.getParamOut (); // seed for inward refit
353385 auto trFitOut = iTrack.getParamIn (); // seed for outward refit
386+ trFitInw.setPID (pid);
387+ trFitOut.setPID (pid);
354388 auto prop = o2::base::Propagator::Instance ();
355389 auto geom = o2::its::GeometryTGeo::Instance ();
356390 float pvAlpha = 0 ;
@@ -502,12 +536,22 @@ bool CheckResidSpec::refitPV(o2::dataformats::PrimaryVertex& pv, int vid)
502536 gidsITS.reserve (ntr);
503537 const auto & vtref = mRecoData ->getPrimaryVertexMatchedTrackRefs ()[vid];
504538 auto trackIndex = mRecoData ->getPrimaryVertexMatchedTracks ();
505- int itr = vtref.getFirstEntry (), itLim = itr + vtref.getEntries ();
506- for (; itr < itLim; itr++) {
507- auto tid = trackIndex[itr];
508- if (tid.isPVContributor () && mRecoData ->isTrackSourceLoaded (tid.getSource ())) {
509- tracks.emplace_back ().setPID (mRecoData ->getTrackParam (tid).getPID ());
510- gidsITS.push_back (mRecoData ->getITSContributorGID (tid));
539+ const auto & itsContRefs = vtref.getITSGloContributors ();
540+ if (params.useITSGloContributors && itsContRefs.getEntries ()) {
541+ int itr = itsContRefs.getFirstEntry (), itLim = itr + itsContRefs.getEntries ();
542+ for (; itr < itLim; itr++) {
543+ auto tid = trackIndex[itr]; // these are ITS tracks, the Source part is substituted by the PID!!!
544+ tracks.emplace_back ().setPID (tid.getSource ());
545+ gidsITS.emplace_back (tid.getIndex (), GTrackID::ITS);
546+ }
547+ } else {
548+ int itr = vtref.getFirstEntry (), itLim = itr + vtref.getEntries ();
549+ for (; itr < itLim; itr++) {
550+ auto tid = trackIndex[itr];
551+ if (tid.isPVContributor () && mRecoData ->isTrackSourceLoaded (tid.getSource ())) {
552+ tracks.emplace_back ().setPID (mRecoData ->getTrackParam (tid).getPID ());
553+ gidsITS.push_back (mRecoData ->getITSContributorGID (tid));
554+ }
511555 }
512556 }
513557 ntr = tracks.size ();
@@ -693,6 +737,11 @@ void CheckResidSpec::bookHistos()
693737 auto htgl2p = new TH2F (fmt::format (" dPar{}_IBOBtgl_pull" , ip).c_str (), fmt::format (" pull #Delta par{} IB-OB vs tg#lambda;tg#lambda;pull #Delta par{}" , ip, ip).c_str (), params.nBinsTgl , -params.maxTgl , params.maxTgl , params.nBinsRes , -params.maxPull , params.maxPull );
694738 mHMan ->addHisto (htgl2p, 13000 + ip * 10 + 5 );
695739 }
740+ // used PV
741+ mHMan ->addHisto (new TH1F (" pvX" , " PV X;x;" , params.nBinsPVXYZ , -params.maxHPVXY , params.maxHPVXY ), 20000 + 0 );
742+ mHMan ->addHisto (new TH1F (" pvY" , " PV Y;y;" , params.nBinsPVXYZ , -params.maxHPVXY , params.maxHPVXY ), 20000 + 1 );
743+ mHMan ->addHisto (new TH1F (" pvZ" , " PV Z;z;" , params.nBinsPVXYZ , -params.maxHPVZ , -params.maxHPVZ ), 20000 + 2 );
744+ mHMan ->addHisto (new TH1F (" pvN" , " PV Contributors;Nc;" , params.maxHPVN , 1.5 , params.maxHPVN + 1.5 ), 20000 + 3 );
696745}
697746
698747void CheckResidSpec::postProcessHistos ()
0 commit comments