@@ -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 }});
@@ -379,13 +412,13 @@ struct centralityStudy {
379412 LOGF (info, " Setting up for run: %i" , mRunNumber );
380413
381414 // only get object when switching runs
382- o2::parameters::GRPECSObject* grpo = ccdb ->getForRun <o2::parameters::GRPECSObject>(pathGRPECSObject, mRunNumber );
415+ o2::parameters::GRPECSObject* grpo = mCcdb ->getForRun <o2::parameters::GRPECSObject>(ccdb. pathGRPECSObject , mRunNumber );
383416 startOfRunTimestamp = grpo->getTimeStart ();
384417
385418 if (applyVertexZEqualization.value ) {
386419 // acquire vertex-Z equalization histograms if requested
387420 LOGF (info, " Acquiring vertex-Z profiles for run %i" , mRunNumber );
388- hCalibObjects = ccdb ->getForRun <TList>(pathVertexZ, mRunNumber );
421+ hCalibObjects = mCcdb ->getForRun <TList>(ccdb. pathVertexZ , mRunNumber );
389422
390423 hVtxZFV0A = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFV0A" ));
391424 hVtxZFT0A = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFT0A" ));
@@ -402,6 +435,77 @@ struct centralityStudy {
402435 }
403436 }
404437
438+ if (doprocessCollisionsWithCentrality && ccdb.fetchCentralityCalibration ) {
439+ LOGF (info, " Acquiring centrality calibration for run %i" , mRunNumber );
440+ TList* hCentralityObjects = nullptr ;
441+ hCentralityObjects = mCcdb ->getForRun <TList>(ccdb.pathCentrality , mRunNumber );
442+ hCentralityFV0A = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFV0" ));
443+ hCentralityFT0A = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFT0A" ));
444+ hCentralityFT0C = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFT0C" ));
445+ hCentralityFT0M = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFT0" ));
446+ hCentralityFDDM = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqFDD" ));
447+ hCentralityNTPV = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqNTracksPV" ));
448+ hCentralityNGlo = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqNGlobal" ));
449+ hCentralityMFT = dynamic_cast <TH1*>(hCentralityObjects->FindObject (" hCalibZeqMFT" ));
450+
451+ // won't capture null pointers -> explicitly check for those when attempting to evaluate
452+ auto reportSuccess = [](TH1* hist, std::string name) {
453+ if (!hist) {
454+ LOGF (info, " Calibration missing for %s" , name);
455+ } else {
456+ LOGF (info, " Calibration loaded for %s" , name);
457+ }
458+ };
459+
460+ reportSuccess (hCentralityFV0A, " FV0A" );
461+ reportSuccess (hCentralityFT0A, " FT0A" );
462+ reportSuccess (hCentralityFT0C, " FT0C" );
463+ reportSuccess (hCentralityFT0M, " FT0M" );
464+ reportSuccess (hCentralityFDDM, " FDDM" );
465+ reportSuccess (hCentralityNTPV, " NTPV" );
466+ reportSuccess (hCentralityNGlo, " NGlobals" );
467+ reportSuccess (hCentralityMFT, " MFT" );
468+
469+ LOGF (info, " Centrality calibration loading done." );
470+ auto getCent = [](TH1* hist, float mult) -> float {
471+ return hist ? hist->GetBinContent (mult) : 0.0 ;
472+ };
473+
474+ centFV0A = getCent (hCentralityFV0A, collision.multFV0A ());
475+ centFT0A = getCent (hCentralityFT0A, collision.multFT0A ());
476+ centFT0C = getCent (hCentralityFT0C, collision.multFT0C ());
477+ centFT0M = getCent (hCentralityFT0M, collision.multFT0A () + collision.multFT0C ());
478+ centFDDM = getCent (hCentralityFDDM, collision.multFDDA () + collision.multFDDC ());
479+ centNTPV = getCent (hCentralityNTPV, collision.multNTracksPV ());
480+ centNGlo = getCent (hCentralityNGlo, collision.multNTracksGlobal ());
481+ centMFT = getCent (hCentralityMFT, collision.mftNtracks ());
482+ } else if (doprocessCollisionsWithCentrality) {
483+ if constexpr (requires { collision.centFV0A (); }) {
484+ centFV0A = collision.centFV0A ();
485+ }
486+ if constexpr (requires { collision.centFT0A (); }) {
487+ centFT0A = collision.centFT0A ();
488+ }
489+ if constexpr (requires { collision.centFT0C (); }) {
490+ centFT0C = collision.centFT0C ();
491+ }
492+ if constexpr (requires { collision.centFT0M (); }) {
493+ centFT0M = collision.centFT0M ();
494+ }
495+ if constexpr (requires { collision.centFDDM (); }) {
496+ centFDDM = collision.centFDDM ();
497+ }
498+ if constexpr (requires { collision.centNTPV (); }) {
499+ centNTPV = collision.centNTPV ();
500+ }
501+ if constexpr (requires { collision.centNGlobal (); }) {
502+ centNGlo = collision.centNGlobal ();
503+ }
504+ if constexpr (requires { collision.centMFT (); }) {
505+ centMFT = collision.centMFT ();
506+ }
507+ }
508+
405509 if (!studies.doRunByRunHistograms ) {
406510 return ;
407511 }
@@ -652,7 +756,7 @@ struct centralityStudy {
652756 float timeToNeighbour = TMath::Min (
653757 std::abs (collision.timeToNext ()),
654758 std::abs (collision.timeToPrevious ()));
655- histos.fill (HIST (" hDeltaTimeVsCentrality" ), collision. centFT0C () , timeToNeighbour);
759+ histos.fill (HIST (" hDeltaTimeVsCentrality" ), centFT0C, timeToNeighbour);
656760 if (timeToNeighbour < minTimeDelta) {
657761 return ;
658762 }
@@ -830,44 +934,42 @@ struct centralityStudy {
830934 }
831935
832936 // if the table has centrality information
833- if constexpr (requires { collision.centFT0C (); }) {
834- // process FT0C centrality plots
835- histos.fill (HIST (" hCentrality" ), collision.centFT0C ());
836- histos.fill (HIST (" hNContribsVsCentrality" ), collision.centFT0C (), collision.multPVTotalContributors ());
837- histos.fill (HIST (" hNITSTPCTracksVsCentrality" ), collision.centFT0C (), collision.multNTracksITSTPC ());
838- histos.fill (HIST (" hNITSOnlyTracksVsCentrality" ), collision.centFT0C (), collision.multNTracksITSOnly ());
839- histos.fill (HIST (" hNGlobalTracksVsCentrality" ), collision.centFT0C (), collision.multNTracksGlobal ());
840- histos.fill (HIST (" hNMFTTracksVsCentrality" ), collision.centFT0C (), collision.mftNtracks ());
841- histos.fill (HIST (" hPVChi2VsCentrality" ), collision.centFT0C (), collision.multPVChi2 ());
842- if (studies.doRunByRunHistograms ) {
843- getHist (TH1, histPath + " hCentrality" )->Fill (collision.centFT0C ());
844- getHist (TH2, histPath + " hNContribsVsCentrality" )->Fill (collision.centFT0C (), collision.multPVTotalContributors ());
845- getHist (TH2, histPath + " hNITSTPCTracksVsCentrality" )->Fill (collision.centFT0C (), collision.multNTracksITSTPC ());
846- getHist (TH2, histPath + " hNITSOnlyTracksVsCentrality" )->Fill (collision.centFT0C (), collision.multNTracksITSOnly ());
847- getHist (TH2, histPath + " hNGlobalTracksVsCentrality" )->Fill (collision.centFT0C (), collision.multNTracksGlobal ());
848- getHist (TH2, histPath + " hNMFTTracksVsCentrality" )->Fill (collision.centFT0C (), collision.mftNtracks ());
849- getHist (TH2, histPath + " hPVChi2VsCentrality" )->Fill (collision.centFT0C (), collision.multPVChi2 ());
850- }
851- if (studies.doOccupancyStudyVsCentrality2d ) {
852- histos.fill (HIST (" hNcontribsProfileVsTrackOccupancyVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.centFT0C (), collision.multPVTotalContributors ());
853- histos.fill (HIST (" hNGlobalTracksProfileVsTrackOccupancyVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.centFT0C (), collision.multNTracksGlobal ());
854- histos.fill (HIST (" hNcontribsProfileVsFT0COccupancyVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.centFT0C (), collision.multPVTotalContributors ());
855- histos.fill (HIST (" hNGlobalTracksProfileVsFT0COccupancyVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.centFT0C (), collision.multNTracksGlobal ());
856- }
937+ // process FT0C centrality plots
938+ histos.fill (HIST (" hCentrality" ), centFT0C);
939+ histos.fill (HIST (" hNContribsVsCentrality" ), centFT0C, collision.multPVTotalContributors ());
940+ histos.fill (HIST (" hNITSTPCTracksVsCentrality" ), centFT0C, collision.multNTracksITSTPC ());
941+ histos.fill (HIST (" hNITSOnlyTracksVsCentrality" ), centFT0C, collision.multNTracksITSOnly ());
942+ histos.fill (HIST (" hNGlobalTracksVsCentrality" ), centFT0C, collision.multNTracksGlobal ());
943+ histos.fill (HIST (" hNMFTTracksVsCentrality" ), centFT0C, collision.mftNtracks ());
944+ histos.fill (HIST (" hPVChi2VsCentrality" ), centFT0C, collision.multPVChi2 ());
945+ if (studies.doRunByRunHistograms ) {
946+ getHist (TH1, histPath + " hCentrality" )->Fill (centFT0C);
947+ getHist (TH2, histPath + " hNContribsVsCentrality" )->Fill (centFT0C, collision.multPVTotalContributors ());
948+ getHist (TH2, histPath + " hNITSTPCTracksVsCentrality" )->Fill (centFT0C, collision.multNTracksITSTPC ());
949+ getHist (TH2, histPath + " hNITSOnlyTracksVsCentrality" )->Fill (centFT0C, collision.multNTracksITSOnly ());
950+ getHist (TH2, histPath + " hNGlobalTracksVsCentrality" )->Fill (centFT0C, collision.multNTracksGlobal ());
951+ getHist (TH2, histPath + " hNMFTTracksVsCentrality" )->Fill (centFT0C, collision.mftNtracks ());
952+ getHist (TH2, histPath + " hPVChi2VsCentrality" )->Fill (centFT0C, collision.multPVChi2 ());
953+ }
954+ if (studies.doOccupancyStudyVsCentrality2d ) {
955+ histos.fill (HIST (" hNcontribsProfileVsTrackOccupancyVsCentrality" ), collision.trackOccupancyInTimeRange (), centFT0C, collision.multPVTotalContributors ());
956+ histos.fill (HIST (" hNGlobalTracksProfileVsTrackOccupancyVsCentrality" ), collision.trackOccupancyInTimeRange (), centFT0C, collision.multNTracksGlobal ());
957+ histos.fill (HIST (" hNcontribsProfileVsFT0COccupancyVsCentrality" ), collision.ft0cOccupancyInTimeRange (), centFT0C, collision.multPVTotalContributors ());
958+ histos.fill (HIST (" hNGlobalTracksProfileVsFT0COccupancyVsCentrality" ), collision.ft0cOccupancyInTimeRange (), centFT0C, collision.multNTracksGlobal ());
959+ }
857960
858- if (studies.doOccupancyStudyVsCentrality3d ) {
859- histos.fill (HIST (" hTrackOccupancyVsNContribsVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.multPVTotalContributors (), collision.centFT0C ());
860- histos.fill (HIST (" hTrackOccupancyVsNGlobalTracksVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.multNTracksGlobal (), collision.centFT0C ());
861- histos.fill (HIST (" hFT0COccupancyVsNContribsVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.multPVTotalContributors (), collision.centFT0C ());
862- histos.fill (HIST (" hFT0COccupancyVsNGlobalTracksVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.multNTracksGlobal (), collision.centFT0C ());
863- }
961+ if (studies.doOccupancyStudyVsCentrality3d ) {
962+ histos.fill (HIST (" hTrackOccupancyVsNContribsVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.multPVTotalContributors (), centFT0C);
963+ histos.fill (HIST (" hTrackOccupancyVsNGlobalTracksVsCentrality" ), collision.trackOccupancyInTimeRange (), collision.multNTracksGlobal (), centFT0C);
964+ histos.fill (HIST (" hFT0COccupancyVsNContribsVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.multPVTotalContributors (), centFT0C);
965+ histos.fill (HIST (" hFT0COccupancyVsNGlobalTracksVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.multNTracksGlobal (), centFT0C);
864966 }
865967
866968 if constexpr (requires { collision.has_multBC (); }) {
867969 if (collision.has_multBC ()) {
868970 auto multbc = collision.template multBC_as <aod::MultBCs>();
869971 uint64_t bcTimestamp = multbc.timestamp ();
870- const float interactionRate = mRateFetcher .fetch (ccdb .service , bcTimestamp, mRunNumber , irSource.value , irCrashOnNull) / 1000 .; // kHz
972+ const float interactionRate = mRateFetcher .fetch (mCcdb .service , bcTimestamp, mRunNumber , ccdb. irSource .value , ccdb. irCrashOnNull ) / 1000 .; // kHz
871973 histos.fill (HIST (" hInteractionRate" ), interactionRate);
872974 if (studies.doRunByRunHistograms ) {
873975 getHist (TH1, histPath + " hInteractionRate" )->Fill (interactionRate);
@@ -1014,7 +1116,7 @@ struct centralityStudy {
10141116 histos.fill (HIST (" hFV0AT0C_BCs" ), (multbc.multFV0A () + multbc.multFT0C ()) * scale.factorFV0AT0C );
10151117
10161118 uint64_t bcTimestamp = multbc.timestamp ();
1017- const float interactionRate = mRateFetcher .fetch (ccdb .service , bcTimestamp, mRunNumber , irSource.value , irCrashOnNull) / 1000 .; // kHz
1119+ const float interactionRate = mRateFetcher .fetch (mCcdb .service , bcTimestamp, mRunNumber , ccdb. irSource .value , ccdb. irCrashOnNull ) / 1000 .; // kHz
10181120 histos.fill (HIST (" hInteractionRate_BCs" ), interactionRate);
10191121
10201122 if (studies.do2DPlots ) {
0 commit comments