@@ -53,7 +53,7 @@ struct centralityStudy {
5353 HistogramRegistry histos{" Histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
5454 std::map<std::string, HistPtr> histPointers;
5555 std::string histPath;
56- Service<o2::ccdb::BasicCCDBManager> ccdb ;
56+ Service<o2::ccdb::BasicCCDBManager> mCcdb ;
5757 ctpRateFetcher mRateFetcher ;
5858 int mRunNumber ;
5959 uint64_t startOfRunTimestamp;
@@ -69,15 +69,39 @@ struct centralityStudy {
6969 TProfile* hVtxZFDDA;
7070 TProfile* hVtxZFDDC;
7171
72+ // calibration histograms
73+ TH1* hCentralityFV0A = nullptr ;
74+ TH1* hCentralityFT0A = nullptr ;
75+ TH1* hCentralityFT0C = nullptr ;
76+ TH1* hCentralityFT0M = nullptr ;
77+ TH1* hCentralityFDDM = nullptr ;
78+ TH1* hCentralityNTPV = nullptr ;
79+ TH1* hCentralityNGlo = nullptr ;
80+ TH1* hCentralityMFT = nullptr ;
81+
82+ float centFV0A = 105 .f;
83+ float centFT0A = 105 .f;
84+ float centFT0C = 105 .f;
85+ float centFT0M = 105 .f;
86+ float centFDDM = 105 .f;
87+ float centNTPV = 105 .f;
88+ float centNGlo = 105 .f;
89+ float centMFT = 105 .f;
90+
7291 // Configurables
7392 Configurable<bool > applyVertexZEqualization{" applyVertexZEqualization" , false , " 0 - no, 1 - yes" };
7493 Configurable<float > minTimeDelta{" minTimeDelta" , -1 .0f , " reject collision if another collision is this close or less in time" };
7594
76- Configurable<std::string> ccdbURL{" ccdbURL" , " http://alice-ccdb.cern.ch" , " ccdb url" };
77- Configurable<std::string> pathGRPECSObject{" pathGRPECSObject" , " GLO/Config/GRPECS" , " Path to GRPECS object" };
78- Configurable<std::string> pathVertexZ{" pathVertexZ" , " Users/d/ddobrigk/Centrality/Calibration" , " Path to vertexZ profiles" };
79- Configurable<std::string> irSource{" irSource" , " ZNC hadronic" , " Source of the interaction rate: (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)" };
80- Configurable<bool > irCrashOnNull{" irCrashOnNull" , false , " Flag to avoid CTP RateFetcher crash." };
95+ struct : ConfigurableGroup {
96+ std::string prefix = " ccdb" ;
97+ Configurable<std::string> ccdbURL{" ccdbURL" , " http://alice-ccdb.cern.ch" , " ccdb url" };
98+ Configurable<std::string> pathCentrality{" pathCentrality" , " Centrality/Estimators" , " path to centrality calibration" };
99+ Configurable<std::string> pathGRPECSObject{" pathGRPECSObject" , " GLO/Config/GRPECS" , " Path to GRPECS object" };
100+ Configurable<std::string> pathVertexZ{" pathVertexZ" , " Users/d/ddobrigk/Centrality/Calibration" , " Path to vertexZ profiles" };
101+ Configurable<std::string> irSource{" irSource" , " ZNC hadronic" , " Source of the interaction rate: (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)" };
102+ Configurable<bool > irCrashOnNull{" irCrashOnNull" , false , " Flag to avoid CTP RateFetcher crash." };
103+ Configurable<bool > fetchCentralityCalibration{" fetchCentralityCalibration" , false , " Flag to fetch the centrality calibration within the task instead of the centrality table" };
104+ } ccdb;
81105
82106 // _______________________________________
83107 // Configurable group
@@ -212,10 +236,19 @@ struct centralityStudy {
212236 hVtxZFDDA = nullptr ;
213237 hVtxZFDDC = nullptr ;
214238
215- ccdb->setURL (ccdbURL);
216- // ccdb->setCaching(true);
217- // ccdb->setLocalObjectValidityChecking();
218- ccdb->setFatalWhenNull (false );
239+ hCentralityFV0A = nullptr ;
240+ hCentralityFT0A = nullptr ;
241+ hCentralityFT0C = nullptr ;
242+ hCentralityFT0M = nullptr ;
243+ hCentralityFDDM = nullptr ;
244+ hCentralityNTPV = nullptr ;
245+ hCentralityNGlo = nullptr ;
246+ hCentralityMFT = nullptr ;
247+
248+ mCcdb ->setURL (ccdb.ccdbURL );
249+ // mCcdb->setCaching(true);
250+ // mCcdb->setLocalObjectValidityChecking();
251+ mCcdb ->setFatalWhenNull (false );
219252
220253 if (doprocessCollisions || doprocessCollisionsWithCentrality) {
221254 histos.add (" hCollisionSelection" , " hCollisionSelection" , kTH1D , {{20 , -0 .5f , +19 .5f }});
@@ -380,13 +413,13 @@ struct centralityStudy {
380413 LOGF (info, " Setting up for run: %i" , mRunNumber );
381414
382415 // only get object when switching runs
383- o2::parameters::GRPECSObject* grpo = ccdb ->getForRun <o2::parameters::GRPECSObject>(pathGRPECSObject, mRunNumber );
416+ o2::parameters::GRPECSObject* grpo = mCcdb ->getForRun <o2::parameters::GRPECSObject>(ccdb. pathGRPECSObject , mRunNumber );
384417 startOfRunTimestamp = grpo->getTimeStart ();
385418
386419 if (applyVertexZEqualization.value ) {
387420 // acquire vertex-Z equalization histograms if requested
388421 LOGF (info, " Acquiring vertex-Z profiles for run %i" , mRunNumber );
389- hCalibObjects = ccdb ->getForRun <TList>(pathVertexZ, mRunNumber );
422+ hCalibObjects = mCcdb ->getForRun <TList>(ccdb. pathVertexZ , mRunNumber );
390423
391424 hVtxZFV0A = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFV0A" ));
392425 hVtxZFT0A = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFT0A" ));
@@ -403,6 +436,77 @@ struct centralityStudy {
403436 }
404437 }
405438
439+ if (doprocessCollisionsWithCentrality && ccdb.fetchCentralityCalibration ) {
440+ LOGF (info, " Acquiring centrality calibration for run %i" , mRunNumber );
441+ TList* hCentralityObjects = nullptr ;
442+ hCentralityObjects = mCcdb ->getForRun <TList>(ccdb.pathCentrality , mRunNumber );
443+ hCentralityFV0A = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFV0" ));
444+ hCentralityFT0A = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFT0A" ));
445+ hCentralityFT0C = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFT0C" ));
446+ hCentralityFT0M = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFT0" ));
447+ hCentralityFDDM = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFDD" ));
448+ hCentralityNTPV = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqNTracksPV" ));
449+ hCentralityNGlo = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqNGlobal" ));
450+ hCentralityMFT = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqMFT" ));
451+
452+ // won't capture null pointers -> explicitly check for those when attempting to evaluate
453+ auto reportSuccess = [](TH1* hist, std::string name) {
454+ if (!hist) {
455+ LOGF (info, " Calibration missing for %s" , name);
456+ } else {
457+ LOGF (info, " Calibration loaded for %s" , name);
458+ }
459+ };
460+
461+ reportSuccess (hCentralityFV0A, " FV0A" );
462+ reportSuccess (hCentralityFT0A, " FT0A" );
463+ reportSuccess (hCentralityFT0C, " FT0C" );
464+ reportSuccess (hCentralityFT0M, " FT0M" );
465+ reportSuccess (hCentralityFDDM, " FDDM" );
466+ reportSuccess (hCentralityNTPV, " NTPV" );
467+ reportSuccess (hCentralityNGlo, " NGlobals" );
468+ reportSuccess (hCentralityMFT, " MFT" );
469+
470+ LOGF (info, " Centrality calibration loading done." );
471+ auto getCent = [](TH1* hist, float mult) -> float {
472+ return hist ? hist->GetBinContent (mult) : 0.0 ;
473+ };
474+
475+ centFV0A = getCent (hCentralityFV0A, collision.multFV0A ());
476+ centFT0A = getCent (hCentralityFT0A, collision.multFT0A ());
477+ centFT0C = getCent (hCentralityFT0C, collision.multFT0C ());
478+ centFT0M = getCent (hCentralityFT0M, collision.multFT0A () + collision.multFT0C ());
479+ centFDDM = getCent (hCentralityFDDM, collision.multFDDA () + collision.multFDDC ());
480+ centNTPV = getCent (hCentralityNTPV, collision.multNTracksPV ());
481+ centNGlo = getCent (hCentralityNGlo, collision.multNTracksGlobal ());
482+ centMFT = getCent (hCentralityMFT, collision.mftNtracks ());
483+ } else if (doprocessCollisionsWithCentrality) {
484+ if constexpr (requires { collision.centFV0A (); }) {
485+ centFV0A = collision.centFV0A ();
486+ }
487+ if constexpr (requires { collision.centFT0A (); }) {
488+ centFT0A = collision.centFT0A ();
489+ }
490+ if constexpr (requires { collision.centFT0C (); }) {
491+ centFT0C = collision.centFT0C ();
492+ }
493+ if constexpr (requires { collision.centFT0M (); }) {
494+ centFT0M = collision.centFT0M ();
495+ }
496+ if constexpr (requires { collision.centFDDM (); }) {
497+ centFDDM = collision.centFDDM ();
498+ }
499+ if constexpr (requires { collision.centNTPV (); }) {
500+ centNTPV = collision.centNTPV ();
501+ }
502+ if constexpr (requires { collision.centNGlobal (); }) {
503+ centNGlo = collision.centNGlobal ();
504+ }
505+ if constexpr (requires { collision.centMFT (); }) {
506+ centMFT = collision.centMFT ();
507+ }
508+ }
509+
406510 if (!studies.doRunByRunHistograms ) {
407511 return ;
408512 }
@@ -654,7 +758,7 @@ struct centralityStudy {
654758 float timeToNeighbour = TMath::Min (
655759 std::abs (collision.timeToNext ()),
656760 std::abs (collision.timeToPrevious ()));
657- histos.fill (HIST (" hDeltaTimeVsCentrality" ), collision. centFT0C () , timeToNeighbour);
761+ histos.fill (HIST (" hDeltaTimeVsCentrality" ), centFT0C, timeToNeighbour);
658762 if (timeToNeighbour < minTimeDelta) {
659763 return ;
660764 }
@@ -832,44 +936,42 @@ struct centralityStudy {
832936 }
833937
834938 // if the table has centrality information
835- if constexpr (requires { collision.centFT0C (); }) {
836- // process FT0C centrality plots
837- histos.fill (HIST (" hCentrality" ), collision.centFT0C ());
838- histos.fill (HIST (" hNContribsVsCentrality" ), collision.centFT0C (), collision.multPVTotalContributors ());
839- histos.fill (HIST (" hNITSTPCTracksVsCentrality" ), collision.centFT0C (), collision.multNTracksITSTPC ());
840- histos.fill (HIST (" hNITSOnlyTracksVsCentrality" ), collision.centFT0C (), collision.multNTracksITSOnly ());
841- histos.fill (HIST (" hNGlobalTracksVsCentrality" ), collision.centFT0C (), collision.multNTracksGlobal ());
842- histos.fill (HIST (" hNMFTTracksVsCentrality" ), collision.centFT0C (), collision.mftNtracks ());
843- histos.fill (HIST (" hPVChi2VsCentrality" ), collision.centFT0C (), collision.multPVChi2 ());
844- if (studies.doRunByRunHistograms ) {
845- getHist (TH1, histPath + " hCentrality" )->Fill (collision.centFT0C ());
846- getHist (TH2, histPath + " hNContribsVsCentrality" )->Fill (collision.centFT0C (), collision.multPVTotalContributors ());
847- getHist (TH2, histPath + " hNITSTPCTracksVsCentrality" )->Fill (collision.centFT0C (), collision.multNTracksITSTPC ());
848- getHist (TH2, histPath + " hNITSOnlyTracksVsCentrality" )->Fill (collision.centFT0C (), collision.multNTracksITSOnly ());
849- getHist (TH2, histPath + " hNGlobalTracksVsCentrality" )->Fill (collision.centFT0C (), collision.multNTracksGlobal ());
850- getHist (TH2, histPath + " hNMFTTracksVsCentrality" )->Fill (collision.centFT0C (), collision.mftNtracks ());
851- getHist (TH2, histPath + " hPVChi2VsCentrality" )->Fill (collision.centFT0C (), collision.multPVChi2 ());
852- }
853- if (studies.doOccupancyStudyVsCentrality2d ) {
854- histos.fill (HIST (" hNcontribsProfileVsTrackOccupancyVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.centFT0C (), collision.multPVTotalContributors ());
855- histos.fill (HIST (" hNGlobalTracksProfileVsTrackOccupancyVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.centFT0C (), collision.multNTracksGlobal ());
856- histos.fill (HIST (" hNcontribsProfileVsFT0COccupancyVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.centFT0C (), collision.multPVTotalContributors ());
857- histos.fill (HIST (" hNGlobalTracksProfileVsFT0COccupancyVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.centFT0C (), collision.multNTracksGlobal ());
858- }
939+ // process FT0C centrality plots
940+ histos.fill (HIST (" hCentrality" ), centFT0C);
941+ histos.fill (HIST (" hNContribsVsCentrality" ), centFT0C, collision.multPVTotalContributors ());
942+ histos.fill (HIST (" hNITSTPCTracksVsCentrality" ), centFT0C, collision.multNTracksITSTPC ());
943+ histos.fill (HIST (" hNITSOnlyTracksVsCentrality" ), centFT0C, collision.multNTracksITSOnly ());
944+ histos.fill (HIST (" hNGlobalTracksVsCentrality" ), centFT0C, collision.multNTracksGlobal ());
945+ histos.fill (HIST (" hNMFTTracksVsCentrality" ), centFT0C, collision.mftNtracks ());
946+ histos.fill (HIST (" hPVChi2VsCentrality" ), centFT0C, collision.multPVChi2 ());
947+ if (studies.doRunByRunHistograms ) {
948+ getHist (TH1, histPath + " hCentrality" )->Fill (centFT0C);
949+ getHist (TH2, histPath + " hNContribsVsCentrality" )->Fill (centFT0C, collision.multPVTotalContributors ());
950+ getHist (TH2, histPath + " hNITSTPCTracksVsCentrality" )->Fill (centFT0C, collision.multNTracksITSTPC ());
951+ getHist (TH2, histPath + " hNITSOnlyTracksVsCentrality" )->Fill (centFT0C, collision.multNTracksITSOnly ());
952+ getHist (TH2, histPath + " hNGlobalTracksVsCentrality" )->Fill (centFT0C, collision.multNTracksGlobal ());
953+ getHist (TH2, histPath + " hNMFTTracksVsCentrality" )->Fill (centFT0C, collision.mftNtracks ());
954+ getHist (TH2, histPath + " hPVChi2VsCentrality" )->Fill (centFT0C, collision.multPVChi2 ());
955+ }
956+ if (studies.doOccupancyStudyVsCentrality2d ) {
957+ histos.fill (HIST (" hNcontribsProfileVsTrackOccupancyVsCentrality" ), collision.trackOccupancyInTimeRange (), centFT0C, collision.multPVTotalContributors ());
958+ histos.fill (HIST (" hNGlobalTracksProfileVsTrackOccupancyVsCentrality" ), collision.trackOccupancyInTimeRange (), centFT0C, collision.multNTracksGlobal ());
959+ histos.fill (HIST (" hNcontribsProfileVsFT0COccupancyVsCentrality" ), collision.ft0cOccupancyInTimeRange (), centFT0C, collision.multPVTotalContributors ());
960+ histos.fill (HIST (" hNGlobalTracksProfileVsFT0COccupancyVsCentrality" ), collision.ft0cOccupancyInTimeRange (), centFT0C, collision.multNTracksGlobal ());
961+ }
859962
860- if (studies.doOccupancyStudyVsCentrality3d ) {
861- histos.fill (HIST (" hTrackOccupancyVsNContribsVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.multPVTotalContributors (), collision.centFT0C ());
862- histos.fill (HIST (" hTrackOccupancyVsNGlobalTracksVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.multNTracksGlobal (), collision.centFT0C ());
863- histos.fill (HIST (" hFT0COccupancyVsNContribsVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.multPVTotalContributors (), collision.centFT0C ());
864- histos.fill (HIST (" hFT0COccupancyVsNGlobalTracksVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.multNTracksGlobal (), collision.centFT0C ());
865- }
963+ if (studies.doOccupancyStudyVsCentrality3d ) {
964+ histos.fill (HIST (" hTrackOccupancyVsNContribsVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.multPVTotalContributors (), centFT0C);
965+ histos.fill (HIST (" hTrackOccupancyVsNGlobalTracksVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.multNTracksGlobal (), centFT0C);
966+ histos.fill (HIST (" hFT0COccupancyVsNContribsVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.multPVTotalContributors (), centFT0C);
967+ histos.fill (HIST (" hFT0COccupancyVsNGlobalTracksVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.multNTracksGlobal (), centFT0C);
866968 }
867969
868970 if constexpr (requires { collision.has_multBC (); }) {
869971 if (collision.has_multBC ()) {
870972 auto multbc = collision.template multBC_as <aod::MultBCs>();
871973 uint64_t bcTimestamp = multbc.timestamp ();
872- const float interactionRate = mRateFetcher .fetch (ccdb .service , bcTimestamp, mRunNumber , irSource.value , irCrashOnNull) / 1000 .; // kHz
974+ const float interactionRate = mRateFetcher .fetch (mCcdb .service , bcTimestamp, mRunNumber , ccdb. irSource .value , ccdb. irCrashOnNull ) / 1000 .; // kHz
873975 histos.fill (HIST (" hInteractionRate" ), interactionRate);
874976 if constexpr (requires { collision.FT0C (); }) {
875977 histos.fill (HIST (" hInteractionRateVsCentrality" ), collision.centFT0C (), interactionRate);
@@ -1022,7 +1124,7 @@ struct centralityStudy {
10221124 histos.fill (HIST (" hFV0AT0C_BCs" ), (multbc.multFV0A () + multbc.multFT0C ()) * scale.factorFV0AT0C );
10231125
10241126 uint64_t bcTimestamp = multbc.timestamp ();
1025- const float interactionRate = mRateFetcher .fetch (ccdb .service , bcTimestamp, mRunNumber , irSource.value , irCrashOnNull) / 1000 .; // kHz
1127+ const float interactionRate = mRateFetcher .fetch (mCcdb .service , bcTimestamp, mRunNumber , ccdb. irSource .value , ccdb. irCrashOnNull ) / 1000 .; // kHz
10261128 histos.fill (HIST (" hInteractionRate_BCs" ), interactionRate);
10271129
10281130 if (studies.do2DPlots ) {
0 commit comments