@@ -48,6 +48,7 @@ struct CentralityQa {
4848 bool isMC = false ;
4949 int runNumber{};
5050 uint64_t startOfRunTimestamp{};
51+ static constexpr float CentralityNotFound = 105 .f;
5152
5253 Configurable<int > nBins{" nBins" , 1050 , " number of bins" };
5354 ConfigurableAxis axisMultiplicity{" axisMultiplicity" , {1000 , 0 , 1000 }, " Multiplicity" };
@@ -113,9 +114,28 @@ struct CentralityQa {
113114 Configurable<bool > rejectIsFlangeEvent{" rejectIsFlangeEvent" , false , " reject is flange event" };
114115 } bcsel;
115116
117+ struct : ConfigurableGroup {
118+ std::string prefix = " centrality" ;
119+ Configurable<bool > useCustomCalibration{" useCustomCalibration" , false , " override the centrality from the central calibration with a different calibration provided in pathCentrality" };
120+ Configurable<std::string> ccdbURL{" ccdbURL" , " http://alice-ccdb.cern.ch" , " ccdb url" };
121+ Configurable<std::string> pathCentrality{" pathCentrality" , " Centrality/Estimators" , " path to centrality calibration if useCustomCalibration is enabled" };
122+ } centrality;
123+
124+ // calibration histograms
125+ TH1 * hCentralityFV0A = nullptr ;
126+ TH1 * hCentralityFT0A = nullptr ;
127+ TH1 * hCentralityFT0C = nullptr ;
128+ TH1 * hCentralityFT0CVariant1 = nullptr ;
129+ TH1 * hCentralityFT0CVariant2 = nullptr ;
130+ TH1 * hCentralityFT0M = nullptr ;
131+ TH1 * hCentralityFDDM = nullptr ;
132+ TH1 * hCentralityNTPV = nullptr ;
133+ TH1 * hCentralityNGlo = nullptr ;
134+ TH1 * hCentralityMFT = nullptr ;
135+
116136 void init (o2::framework::InitContext& /* initContext*/ )
117137 {
118- ccdb->setURL (" http://alice-ccdb.cern.ch " );
138+ ccdb->setURL (centrality. ccdbURL );
119139 ccdb->setCaching (true );
120140 ccdb->setLocalObjectValidityChecking ();
121141
@@ -220,6 +240,60 @@ struct CentralityQa {
220240 histos.print ();
221241 }
222242
243+ template <typename TCollision>
244+ void initRun (const TCollision& col)
245+ {
246+ if (centrality.useCustomCalibration ) {
247+ if (!col.has_bc ()) {
248+ return ;
249+ }
250+
251+ const auto bc = col.template bc_as <aod::BCs>();
252+ if (bc.runNumber () == runNumber) {
253+ return ;
254+ }
255+
256+ runNumber = bc.runNumber ();
257+ LOGF (info, " Acquiring centrality calibration for run %i" , runNumber);
258+ auto hCentralityObjects = ccdb->getForRun <TList>(centrality.pathCentrality , runNumber);
259+ if (!hCentralityObjects) {
260+ LOGF (info, " No centrality calibration list found for run %i" , runNumber);
261+ }
262+
263+ auto getCalibration = [&hCentralityObjects](const std::string& estimator, const bool isProcessFunctionEnabled) -> TH1 * {
264+ if (!isProcessFunctionEnabled) {
265+ LOGF (info, " Process function for %s is disabled -> skipping loading calibration" , estimator.c_str ());
266+ return nullptr ;
267+ }
268+
269+ if (!hCentralityObjects) {
270+ LOGF (info, " Missing calibration object, failed to load calibration for %s " , estimator.c_str ());
271+ return nullptr ;
272+ }
273+
274+ TH1 * hist = dynamic_cast <TH1 *>(hCentralityObjects->FindObject (Form (" hCalibZeq%s" , estimator.c_str ())));
275+ if (!hist) {
276+ LOGF (info, " Calibration missing for %s" , estimator.c_str ());
277+ } else {
278+ LOGF (info, " Calibration loaded for %s" , estimator.c_str ());
279+ }
280+ return hist;
281+ };
282+
283+ hCentralityFV0A = getCalibration (" FV0" , doprocessRun3_FV0A);
284+ hCentralityFT0A = getCalibration (" FT0A" , doprocessRun3_FT0A);
285+ hCentralityFT0C = getCalibration (" FT0C" , doprocessRun3_FT0C);
286+ hCentralityFT0CVariant1 = getCalibration (" FT0CVariant1" , doprocessRun3_FT0CVar1);
287+ hCentralityFT0CVariant2 = getCalibration (" FT0CVariant2" , doprocessRun3_FT0CVar2);
288+ hCentralityFT0M = getCalibration (" FT0M" , doprocessRun3_FT0M);
289+ hCentralityFDDM = getCalibration (" FDDM" , doprocessRun3_FDDM);
290+ hCentralityNTPV = getCalibration (" NTPV" , doprocessRun3_NTPV);
291+ hCentralityNGlo = getCalibration (" NGlo" , doprocessRun3_NGlobal);
292+ hCentralityMFT = getCalibration (" MFT" , doprocessRun3_MFT);
293+ LOGF (info, " Centrality calibration loading done." );
294+ }
295+ }
296+
223297 template <typename TCollision>
224298 bool isCollisionAccepted (TCollision const & collision)
225299 // check whether the collision passes our collision selections
@@ -511,6 +585,14 @@ struct CentralityQa {
511585 return true ;
512586 }
513587
588+ float getCentrality (TH1 * hist, const float mult, const float cent)
589+ {
590+ if (centrality.useCustomCalibration ) {
591+ return hist ? hist->GetBinContent (hist->FindBin (mult)) : CentralityNotFound;
592+ }
593+ return cent;
594+ }
595+
514596 void processRun2PP (soa::Join<aod::Collisions, aod::EvSels, aod::CentRun2V0Ms, aod::CentRun2SPDTrks, aod::CentRun2SPDClss, aod::Mults>::iterator const & col)
515597 {
516598 if (!isCollisionAccepted (col)) {
@@ -554,115 +636,162 @@ struct CentralityQa {
554636 }
555637 PROCESS_SWITCH (CentralityQa, processRun2PPb, " Process with Run2 V0A multiplicitY centrality/multiplicity estimation" , false );
556638
557- void processRun3_FV0A (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentFV0As>::iterator const & col)
639+ void processRun3_FV0A (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::CentFV0As>::iterator const & col, aod::BCs const & )
558640 {
559641 if (!isCollisionAccepted (col)) {
560642 return ;
561643 }
562- LOGF (debug, " centFV0A=%.0f" , col.centFV0A ());
563- histos.fill (HIST (" hCentFV0A" ), col.centFV0A ());
564- histos.fill (HIST (" hCentProfileFV0A" ), col.centFV0A (), col.multNTracksPVetaHalf ());
565- histos.fill (HIST (" hMultEta05VsCentFV0A" ), col.centFV0A (), col.multNTracksPVetaHalf ());
644+
645+ initRun (col);
646+ const float centFV0A = getCentrality (hCentralityFV0A, col.multFV0A (), col.centFV0A ());
647+
648+ LOGF (debug, " centFV0A=%.0f" , centFV0A);
649+ histos.fill (HIST (" hCentFV0A" ), centFV0A);
650+ histos.fill (HIST (" hCentProfileFV0A" ), centFV0A, col.multNTracksPVetaHalf ());
651+ histos.fill (HIST (" hMultEta05VsCentFV0A" ), centFV0A, col.multNTracksPVetaHalf ());
566652 }
567653 PROCESS_SWITCH (CentralityQa, processRun3_FV0A, " Process with Run 3 FV0A estimator" , false );
568654
569- void processRun3_FT0M (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentFT0Ms>::iterator const & col)
655+ void processRun3_FT0M (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::CentFT0Ms>::iterator const & col, aod::BCs const & )
570656 {
571657 if (!isCollisionAccepted (col)) {
572658 return ;
573659 }
574- LOGF (debug, " centFT0M=%.0f" , col.centFT0M ());
575- histos.fill (HIST (" hCentFT0M" ), col.centFT0M ());
576- histos.fill (HIST (" hCentProfileFT0M" ), col.centFT0M (), col.multNTracksPVetaHalf ());
577- histos.fill (HIST (" hMultEta05VsCentFT0M" ), col.centFT0M (), col.multNTracksPVetaHalf ());
660+
661+ initRun (col);
662+ const float centFT0M = getCentrality (hCentralityFT0M, col.multFT0M (), col.centFT0M ());
663+ LOGF (debug, " centFT0M=%.0f" , centFT0M);
664+ histos.fill (HIST (" hCentFT0M" ), centFT0M);
665+ histos.fill (HIST (" hCentProfileFT0M" ), centFT0M, col.multNTracksPVetaHalf ());
666+ histos.fill (HIST (" hMultEta05VsCentFT0M" ), centFT0M, col.multNTracksPVetaHalf ());
578667 }
579668 PROCESS_SWITCH (CentralityQa, processRun3_FT0M, " Process with Run 3 FT0M estimator" , false );
580669
581- void processRun3_FT0A (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentFT0As>::iterator const & col)
670+ void processRun3_FT0A (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::CentFT0As>::iterator const & col, aod::BCs const & )
582671 {
583672 if (!isCollisionAccepted (col)) {
584673 return ;
585674 }
586- histos.fill (HIST (" hCentFT0A" ), col.centFT0A ());
587- histos.fill (HIST (" hCentProfileFT0A" ), col.centFT0A (), col.multNTracksPVetaHalf ());
588- histos.fill (HIST (" hMultEta05VsCentFT0A" ), col.centFT0A (), col.multNTracksPVetaHalf ());
675+
676+ initRun (col);
677+ const float centFT0A = getCentrality (hCentralityFT0A, col.multFT0A (), col.centFT0A ());
678+
679+ LOGF (debug, " centFT0A=%.0f" , centFT0A);
680+ histos.fill (HIST (" hCentFT0A" ), centFT0A);
681+ histos.fill (HIST (" hCentProfileFT0A" ), centFT0A, col.multNTracksPVetaHalf ());
682+ histos.fill (HIST (" hMultEta05VsCentFT0A" ), centFT0A, col.multNTracksPVetaHalf ());
589683 }
590684 PROCESS_SWITCH (CentralityQa, processRun3_FT0A, " Process with Run 3 FT0A estimator" , false );
591685
592- void processRun3_FT0C (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentFT0Cs>::iterator const & col)
686+ void processRun3_FT0C (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::CentFT0Cs>::iterator const & col, aod::BCs const & )
593687 {
594688 if (!isCollisionAccepted (col)) {
595689 return ;
596690 }
597- histos.fill (HIST (" hCentFT0C" ), col.centFT0C ());
598- histos.fill (HIST (" hCentProfileFT0C" ), col.centFT0C (), col.multNTracksPVetaHalf ());
599- histos.fill (HIST (" hMultEta05VsCentFT0C" ), col.centFT0C (), col.multNTracksPVetaHalf ());
691+
692+ initRun (col);
693+ const float centFT0C = getCentrality (hCentralityFT0C, col.multFT0C (), col.centFT0C ());
694+
695+ LOGF (debug, " centFT0C=%.0f" , centFT0C);
696+ histos.fill (HIST (" hCentFT0C" ), centFT0C);
697+ histos.fill (HIST (" hCentProfileFT0C" ), centFT0C, col.multNTracksPVetaHalf ());
698+ histos.fill (HIST (" hMultEta05VsCentFT0C" ), centFT0C, col.multNTracksPVetaHalf ());
600699 }
601700 PROCESS_SWITCH (CentralityQa, processRun3_FT0C, " Process with Run 3 FT0C estimator" , false );
602701
603- void processRun3_FT0CVar1 (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentFT0CVariant1s>::iterator const & col)
702+ void processRun3_FT0CVar1 (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::CentFT0CVariant1s>::iterator const & col, aod::BCs const & )
604703 {
605704 if (!isCollisionAccepted (col)) {
606705 return ;
607706 }
608- histos.fill (HIST (" hCentFT0CVar1" ), col.centFT0CVariant1 ());
609- histos.fill (HIST (" hCentProfileFT0CVar1" ), col.centFT0CVariant1 (), col.multNTracksPVetaHalf ());
610- histos.fill (HIST (" hMultEta05VsCentFT0CVar1" ), col.centFT0CVariant1 (), col.multNTracksPVetaHalf ());
707+
708+ initRun (col);
709+ const float centFT0Cvar1 = getCentrality (hCentralityFT0CVariant1, col.multFT0C (), col.centFT0CVariant1 ());
710+
711+ LOGF (debug, " centFT0Cvar1=%.0f" , centFT0Cvar1);
712+ histos.fill (HIST (" hCentFT0CVar1" ), centFT0Cvar1);
713+ histos.fill (HIST (" hCentProfileFT0CVar1" ), centFT0Cvar1, col.multNTracksPVetaHalf ());
714+ histos.fill (HIST (" hMultEta05VsCentFT0CVar1" ), centFT0Cvar1, col.multNTracksPVetaHalf ());
611715 }
612716 PROCESS_SWITCH (CentralityQa, processRun3_FT0CVar1, " Process with Run 3 FT0CVar1 estimator" , false );
613717
614- void processRun3_FT0CVar2 (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentFT0CVariant2s>::iterator const & col)
718+ void processRun3_FT0CVar2 (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::CentFT0CVariant2s>::iterator const & col, aod::BCs const & )
615719 {
616720 if (!isCollisionAccepted (col)) {
617721 return ;
618722 }
619- histos.fill (HIST (" hCentFT0CVar2" ), col.centFT0CVariant2 ());
620- histos.fill (HIST (" hCentProfileFT0CVar2" ), col.centFT0CVariant2 (), col.multNTracksPVetaHalf ());
621- histos.fill (HIST (" hMultEta05VsCentFT0CVar2" ), col.centFT0CVariant2 (), col.multNTracksPVetaHalf ());
723+
724+ initRun (col);
725+ const float centFT0Cvar2 = getCentrality (hCentralityFT0CVariant2, col.multFT0C (), col.centFT0CVariant2 ());
726+
727+ LOGF (debug, " centFT0Cvar2=%.0f" , centFT0Cvar2);
728+ histos.fill (HIST (" hCentFT0CVar2" ), centFT0Cvar2);
729+ histos.fill (HIST (" hCentProfileFT0CVar2" ), centFT0Cvar2, col.multNTracksPVetaHalf ());
730+ histos.fill (HIST (" hMultEta05VsCentFT0CVar2" ), centFT0Cvar2, col.multNTracksPVetaHalf ());
622731 }
623732 PROCESS_SWITCH (CentralityQa, processRun3_FT0CVar2, " Process with Run 3 FT0CVar2 estimator" , false );
624733
625- void processRun3_FDDM (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentFDDMs>::iterator const & col)
734+ void processRun3_FDDM (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::CentFDDMs>::iterator const & col, aod::BCs const & )
626735 {
627736 if (!isCollisionAccepted (col)) {
628737 return ;
629738 }
630- histos.fill (HIST (" hCentFDDM" ), col.centFDDM ());
631- histos.fill (HIST (" hCentProfileFDDM" ), col.centFDDM (), col.multNTracksPVetaHalf ());
632- histos.fill (HIST (" hMultEta05VsCentFDDM" ), col.centFDDM (), col.multNTracksPVetaHalf ());
739+
740+ initRun (col);
741+ const float centFDDM = getCentrality (hCentralityFDDM, col.multFDDM (), col.centFDDM ());
742+
743+ LOGF (debug, " centFDDM=%.0f" , centFDDM);
744+ histos.fill (HIST (" hCentFDDM" ), centFDDM);
745+ histos.fill (HIST (" hCentProfileFDDM" ), centFDDM, col.multNTracksPVetaHalf ());
746+ histos.fill (HIST (" hMultEta05VsCentFDDM" ), centFDDM, col.multNTracksPVetaHalf ());
633747 }
634748 PROCESS_SWITCH (CentralityQa, processRun3_FDDM, " Process with Run 3 FDDM estimator" , false );
635749
636- void processRun3_NTPV (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentNTPVs>::iterator const & col)
750+ void processRun3_NTPV (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::CentNTPVs>::iterator const & col, aod::BCs const & )
637751 {
638752 if (!isCollisionAccepted (col)) {
639753 return ;
640754 }
641- histos.fill (HIST (" hCentNTPV" ), col.centNTPV ());
642- histos.fill (HIST (" hCentProfileNTPV" ), col.centNTPV (), col.multNTracksPVetaHalf ());
643- histos.fill (HIST (" hMultEta05VsCentNTPV" ), col.centNTPV (), col.multNTracksPVetaHalf ());
755+
756+ initRun (col);
757+ const float centNTPV = getCentrality (hCentralityNTPV, col.multNTracksPV (), col.centNTPV ());
758+
759+ LOGF (debug, " centNTPV=%.0f" , centNTPV);
760+ histos.fill (HIST (" hCentNTPV" ), centNTPV);
761+ histos.fill (HIST (" hCentProfileNTPV" ), centNTPV, col.multNTracksPVetaHalf ());
762+ histos.fill (HIST (" hMultEta05VsCentNTPV" ), centNTPV, col.multNTracksPVetaHalf ());
644763 }
645764 PROCESS_SWITCH (CentralityQa, processRun3_NTPV, " Process with Run 3 NTPV estimator" , false );
646765
647- void processRun3_NGlobal (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentNGlobals>::iterator const & col)
766+ void processRun3_NGlobal (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::MultsGlobal, aod:: CentNGlobals>::iterator const & col, aod::BCs const & )
648767 {
649768 if (!isCollisionAccepted (col)) {
650769 return ;
651770 }
652- histos.fill (HIST (" hCentNGlobal" ), col.centNGlobal ());
653- histos.fill (HIST (" hCentProfileNGlobal" ), col.centNGlobal (), col.multNTracksPVetaHalf ());
654- histos.fill (HIST (" hMultEta05VsCentNGlobal" ), col.centNGlobal (), col.multNTracksPVetaHalf ());
771+
772+ initRun (col);
773+ const float centNGlo = getCentrality (hCentralityNGlo, col.multNTracksGlobal (), col.centNGlobal ());
774+
775+ LOGF (debug, " centNGlo=%.0f" , centNGlo);
776+ histos.fill (HIST (" hCentNGlobal" ), centNGlo);
777+ histos.fill (HIST (" hCentProfileNGlobal" ), centNGlo, col.multNTracksPVetaHalf ());
778+ histos.fill (HIST (" hMultEta05VsCentNGlobal" ), centNGlo, col.multNTracksPVetaHalf ());
655779 }
656780 PROCESS_SWITCH (CentralityQa, processRun3_NGlobal, " Process with Run 3 NGlobal estimator" , false );
657781
658- void processRun3_MFT (soa::Join<aod::Collisions, aod::EvSels, aod::Mults , aod::CentMFTs>::iterator const & col)
782+ void processRun3_MFT (soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3 , aod::MFTMults, aod:: CentMFTs>::iterator const & col, aod::BCs const & )
659783 {
660784 if (!isCollisionAccepted (col)) {
661785 return ;
662786 }
663- histos.fill (HIST (" hCentMFT" ), col.centMFT ());
664- histos.fill (HIST (" hCentProfileMFT" ), col.centMFT (), col.multNTracksPVetaHalf ());
665- histos.fill (HIST (" hMultEta05VsCentMFT" ), col.centMFT (), col.multNTracksPVetaHalf ());
787+
788+ initRun (col);
789+ const float centMFT = getCentrality (hCentralityMFT, col.mftNtracks (), col.centMFT ());
790+
791+ LOGF (debug, " centMFT=%.0f" , centMFT);
792+ histos.fill (HIST (" hCentMFT" ), centMFT);
793+ histos.fill (HIST (" hCentProfileMFT" ), centMFT, col.multNTracksPVetaHalf ());
794+ histos.fill (HIST (" hMultEta05VsCentMFT" ), centMFT, col.multNTracksPVetaHalf ());
666795 }
667796 PROCESS_SWITCH (CentralityQa, processRun3_MFT, " Process with Run 3 MFT estimator" , false );
668797
0 commit comments