Skip to content

Commit 4bbe6dd

Browse files
committed
Add option to override centrality calibration in centralityQa
1 parent 78a6979 commit 4bbe6dd

1 file changed

Lines changed: 172 additions & 43 deletions

File tree

Common/Tasks/centralityQa.cxx

Lines changed: 172 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -214,6 +234,60 @@ struct CentralityQa {
214234
histos.print();
215235
}
216236

237+
template <typename TCollision>
238+
void initRun(const TCollision& col)
239+
{
240+
if (centrality.useCustomCalibration) {
241+
if (!col.has_bc()) {
242+
return;
243+
}
244+
245+
const auto bc = col.template bc_as<aod::BCs>();
246+
if (bc.runNumber() == runNumber) {
247+
return;
248+
}
249+
250+
runNumber = bc.runNumber();
251+
LOGF(info, "Acquiring centrality calibration for run %i", runNumber);
252+
auto hCentralityObjects = ccdb->getForRun<TList>(centrality.pathCentrality, runNumber);
253+
if (!hCentralityObjects) {
254+
LOGF(info, "No centrality calibration list found for run %i", runNumber);
255+
}
256+
257+
auto getCalibration = [&hCentralityObjects](const std::string& estimator, const bool isProcessFunctionEnabled) -> TH1* {
258+
if (!isProcessFunctionEnabled) {
259+
LOGF(info, "Process function for %s is disabled -> skipping loading calibration", estimator.c_str());
260+
return nullptr;
261+
}
262+
263+
if (!hCentralityObjects) {
264+
LOGF(info, "Missing calibration object, failed to load calibration for %s ", estimator.c_str());
265+
return nullptr;
266+
}
267+
268+
TH1* hist = dynamic_cast<TH1*>(hCentralityObjects->FindObject(Form("hCalibZeq%s", estimator.c_str())));
269+
if (!hist) {
270+
LOGF(info, "Calibration missing for %s", estimator.c_str());
271+
} else {
272+
LOGF(info, "Calibration loaded for %s", estimator.c_str());
273+
}
274+
return hist;
275+
};
276+
277+
hCentralityFV0A = getCalibration("FV0", doprocessRun3_FV0A);
278+
hCentralityFT0A = getCalibration("FT0A", doprocessRun3_FT0A);
279+
hCentralityFT0C = getCalibration("FT0C", doprocessRun3_FT0C);
280+
hCentralityFT0CVariant1 = getCalibration("FT0CVariant1", doprocessRun3_FT0CVar1);
281+
hCentralityFT0CVariant2 = getCalibration("FT0CVariant2", doprocessRun3_FT0CVar2);
282+
hCentralityFT0M = getCalibration("FT0M", doprocessRun3_FT0M);
283+
hCentralityFDDM = getCalibration("FDDM", doprocessRun3_FDDM);
284+
hCentralityNTPV = getCalibration("NTPV", doprocessRun3_NTPV);
285+
hCentralityNGlo = getCalibration("NGlo", doprocessRun3_NGlobal);
286+
hCentralityMFT = getCalibration("MFT", doprocessRun3_MFT);
287+
LOGF(info, "Centrality calibration loading done.");
288+
}
289+
}
290+
217291
template <typename TCollision>
218292
bool isCollisionAccepted(TCollision const& collision)
219293
// check whether the collision passes our collision selections
@@ -505,6 +579,14 @@ struct CentralityQa {
505579
return true;
506580
}
507581

582+
float getCentrality(TH1* hist, const float mult, const float cent)
583+
{
584+
if (centrality.useCustomCalibration) {
585+
return hist ? hist->GetBinContent(hist->FindBin(mult)) : CentralityNotFound;
586+
}
587+
return cent;
588+
}
589+
508590
void processRun2PP(soa::Join<aod::Collisions, aod::EvSels, aod::CentRun2V0Ms, aod::CentRun2SPDTrks, aod::CentRun2SPDClss, aod::Mults>::iterator const& col)
509591
{
510592
if (!isCollisionAccepted(col)) {
@@ -548,115 +630,162 @@ struct CentralityQa {
548630
}
549631
PROCESS_SWITCH(CentralityQa, processRun2PPb, "Process with Run2 V0A multiplicitY centrality/multiplicity estimation", false);
550632

551-
void processRun3_FV0A(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFV0As>::iterator const& col)
633+
void processRun3_FV0A(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::CentFV0As>::iterator const& col, aod::BCs const&)
552634
{
553635
if (!isCollisionAccepted(col)) {
554636
return;
555637
}
556-
LOGF(debug, "centFV0A=%.0f", col.centFV0A());
557-
histos.fill(HIST("hCentFV0A"), col.centFV0A());
558-
histos.fill(HIST("hCentProfileFV0A"), col.centFV0A(), col.multNTracksPVetaHalf());
559-
histos.fill(HIST("hMultEta05VsCentFV0A"), col.centFV0A(), col.multNTracksPVetaHalf());
638+
639+
initRun(col);
640+
const float centFV0A = getCentrality(hCentralityFV0A, col.multFV0A(), col.centFV0A());
641+
642+
LOGF(debug, "centFV0A=%.0f", centFV0A);
643+
histos.fill(HIST("hCentFV0A"), centFV0A);
644+
histos.fill(HIST("hCentProfileFV0A"), centFV0A, col.multNTracksPVetaHalf());
645+
histos.fill(HIST("hMultEta05VsCentFV0A"), centFV0A, col.multNTracksPVetaHalf());
560646
}
561647
PROCESS_SWITCH(CentralityQa, processRun3_FV0A, "Process with Run 3 FV0A estimator", false);
562648

563-
void processRun3_FT0M(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFT0Ms>::iterator const& col)
649+
void processRun3_FT0M(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::CentFT0Ms>::iterator const& col, aod::BCs const&)
564650
{
565651
if (!isCollisionAccepted(col)) {
566652
return;
567653
}
568-
LOGF(debug, "centFT0M=%.0f", col.centFT0M());
569-
histos.fill(HIST("hCentFT0M"), col.centFT0M());
570-
histos.fill(HIST("hCentProfileFT0M"), col.centFT0M(), col.multNTracksPVetaHalf());
571-
histos.fill(HIST("hMultEta05VsCentFT0M"), col.centFT0M(), col.multNTracksPVetaHalf());
654+
655+
initRun(col);
656+
const float centFT0M = getCentrality(hCentralityFT0M, col.multFT0M(), col.centFT0M());
657+
LOGF(debug, "centFT0M=%.0f", centFT0M);
658+
histos.fill(HIST("hCentFT0M"), centFT0M);
659+
histos.fill(HIST("hCentProfileFT0M"), centFT0M, col.multNTracksPVetaHalf());
660+
histos.fill(HIST("hMultEta05VsCentFT0M"), centFT0M, col.multNTracksPVetaHalf());
572661
}
573662
PROCESS_SWITCH(CentralityQa, processRun3_FT0M, "Process with Run 3 FT0M estimator", false);
574663

575-
void processRun3_FT0A(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFT0As>::iterator const& col)
664+
void processRun3_FT0A(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::CentFT0As>::iterator const& col, aod::BCs const&)
576665
{
577666
if (!isCollisionAccepted(col)) {
578667
return;
579668
}
580-
histos.fill(HIST("hCentFT0A"), col.centFT0A());
581-
histos.fill(HIST("hCentProfileFT0A"), col.centFT0A(), col.multNTracksPVetaHalf());
582-
histos.fill(HIST("hMultEta05VsCentFT0A"), col.centFT0A(), col.multNTracksPVetaHalf());
669+
670+
initRun(col);
671+
const float centFT0A = getCentrality(hCentralityFT0A, col.multFT0A(), col.centFT0A());
672+
673+
LOGF(debug, "centFT0A=%.0f", centFT0A);
674+
histos.fill(HIST("hCentFT0A"), centFT0A);
675+
histos.fill(HIST("hCentProfileFT0A"), centFT0A, col.multNTracksPVetaHalf());
676+
histos.fill(HIST("hMultEta05VsCentFT0A"), centFT0A, col.multNTracksPVetaHalf());
583677
}
584678
PROCESS_SWITCH(CentralityQa, processRun3_FT0A, "Process with Run 3 FT0A estimator", false);
585679

586-
void processRun3_FT0C(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFT0Cs>::iterator const& col)
680+
void processRun3_FT0C(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::CentFT0Cs>::iterator const& col, aod::BCs const&)
587681
{
588682
if (!isCollisionAccepted(col)) {
589683
return;
590684
}
591-
histos.fill(HIST("hCentFT0C"), col.centFT0C());
592-
histos.fill(HIST("hCentProfileFT0C"), col.centFT0C(), col.multNTracksPVetaHalf());
593-
histos.fill(HIST("hMultEta05VsCentFT0C"), col.centFT0C(), col.multNTracksPVetaHalf());
685+
686+
initRun(col);
687+
const float centFT0C = getCentrality(hCentralityFT0C, col.multFT0C(), col.centFT0C());
688+
689+
LOGF(debug, "centFT0C=%.0f", centFT0C);
690+
histos.fill(HIST("hCentFT0C"), centFT0C);
691+
histos.fill(HIST("hCentProfileFT0C"), centFT0C, col.multNTracksPVetaHalf());
692+
histos.fill(HIST("hMultEta05VsCentFT0C"), centFT0C, col.multNTracksPVetaHalf());
594693
}
595694
PROCESS_SWITCH(CentralityQa, processRun3_FT0C, "Process with Run 3 FT0C estimator", false);
596695

597-
void processRun3_FT0CVar1(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFT0CVariant1s>::iterator const& col)
696+
void processRun3_FT0CVar1(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::CentFT0CVariant1s>::iterator const& col, aod::BCs const&)
598697
{
599698
if (!isCollisionAccepted(col)) {
600699
return;
601700
}
602-
histos.fill(HIST("hCentFT0CVar1"), col.centFT0CVariant1());
603-
histos.fill(HIST("hCentProfileFT0CVar1"), col.centFT0CVariant1(), col.multNTracksPVetaHalf());
604-
histos.fill(HIST("hMultEta05VsCentFT0CVar1"), col.centFT0CVariant1(), col.multNTracksPVetaHalf());
701+
702+
initRun(col);
703+
const float centFT0Cvar1 = getCentrality(hCentralityFT0CVariant1, col.multFT0C(), col.centFT0CVariant1());
704+
705+
LOGF(debug, "centFT0Cvar1=%.0f", centFT0Cvar1);
706+
histos.fill(HIST("hCentFT0CVar1"), centFT0Cvar1);
707+
histos.fill(HIST("hCentProfileFT0CVar1"), centFT0Cvar1, col.multNTracksPVetaHalf());
708+
histos.fill(HIST("hMultEta05VsCentFT0CVar1"), centFT0Cvar1, col.multNTracksPVetaHalf());
605709
}
606710
PROCESS_SWITCH(CentralityQa, processRun3_FT0CVar1, "Process with Run 3 FT0CVar1 estimator", false);
607711

608-
void processRun3_FT0CVar2(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFT0CVariant2s>::iterator const& col)
712+
void processRun3_FT0CVar2(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::CentFT0CVariant2s>::iterator const& col, aod::BCs const&)
609713
{
610714
if (!isCollisionAccepted(col)) {
611715
return;
612716
}
613-
histos.fill(HIST("hCentFT0CVar2"), col.centFT0CVariant2());
614-
histos.fill(HIST("hCentProfileFT0CVar2"), col.centFT0CVariant2(), col.multNTracksPVetaHalf());
615-
histos.fill(HIST("hMultEta05VsCentFT0CVar2"), col.centFT0CVariant2(), col.multNTracksPVetaHalf());
717+
718+
initRun(col);
719+
const float centFT0Cvar2 = getCentrality(hCentralityFT0CVariant2, col.multFT0C(), col.centFT0CVariant2());
720+
721+
LOGF(debug, "centFT0Cvar2=%.0f", centFT0Cvar2);
722+
histos.fill(HIST("hCentFT0CVar2"), centFT0Cvar2);
723+
histos.fill(HIST("hCentProfileFT0CVar2"), centFT0Cvar2, col.multNTracksPVetaHalf());
724+
histos.fill(HIST("hMultEta05VsCentFT0CVar2"), centFT0Cvar2, col.multNTracksPVetaHalf());
616725
}
617726
PROCESS_SWITCH(CentralityQa, processRun3_FT0CVar2, "Process with Run 3 FT0CVar2 estimator", false);
618727

619-
void processRun3_FDDM(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFDDMs>::iterator const& col)
728+
void processRun3_FDDM(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::CentFDDMs>::iterator const& col, aod::BCs const&)
620729
{
621730
if (!isCollisionAccepted(col)) {
622731
return;
623732
}
624-
histos.fill(HIST("hCentFDDM"), col.centFDDM());
625-
histos.fill(HIST("hCentProfileFDDM"), col.centFDDM(), col.multNTracksPVetaHalf());
626-
histos.fill(HIST("hMultEta05VsCentFDDM"), col.centFDDM(), col.multNTracksPVetaHalf());
733+
734+
initRun(col);
735+
const float centFDDM = getCentrality(hCentralityFDDM, col.multFDDM(), col.centFDDM());
736+
737+
LOGF(debug, "centFDDM=%.0f", centFDDM);
738+
histos.fill(HIST("hCentFDDM"), centFDDM);
739+
histos.fill(HIST("hCentProfileFDDM"), centFDDM, col.multNTracksPVetaHalf());
740+
histos.fill(HIST("hMultEta05VsCentFDDM"), centFDDM, col.multNTracksPVetaHalf());
627741
}
628742
PROCESS_SWITCH(CentralityQa, processRun3_FDDM, "Process with Run 3 FDDM estimator", false);
629743

630-
void processRun3_NTPV(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentNTPVs>::iterator const& col)
744+
void processRun3_NTPV(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::CentNTPVs>::iterator const& col, aod::BCs const&)
631745
{
632746
if (!isCollisionAccepted(col)) {
633747
return;
634748
}
635-
histos.fill(HIST("hCentNTPV"), col.centNTPV());
636-
histos.fill(HIST("hCentProfileNTPV"), col.centNTPV(), col.multNTracksPVetaHalf());
637-
histos.fill(HIST("hMultEta05VsCentNTPV"), col.centNTPV(), col.multNTracksPVetaHalf());
749+
750+
initRun(col);
751+
const float centNTPV = getCentrality(hCentralityNTPV, col.multNTracksPV(), col.centNTPV());
752+
753+
LOGF(debug, "centNTPV=%.0f", centNTPV);
754+
histos.fill(HIST("hCentNTPV"), centNTPV);
755+
histos.fill(HIST("hCentProfileNTPV"), centNTPV, col.multNTracksPVetaHalf());
756+
histos.fill(HIST("hMultEta05VsCentNTPV"), centNTPV, col.multNTracksPVetaHalf());
638757
}
639758
PROCESS_SWITCH(CentralityQa, processRun3_NTPV, "Process with Run 3 NTPV estimator", false);
640759

641-
void processRun3_NGlobal(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentNGlobals>::iterator const& col)
760+
void processRun3_NGlobal(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::MultsGlobal, aod::CentNGlobals>::iterator const& col, aod::BCs const&)
642761
{
643762
if (!isCollisionAccepted(col)) {
644763
return;
645764
}
646-
histos.fill(HIST("hCentNGlobal"), col.centNGlobal());
647-
histos.fill(HIST("hCentProfileNGlobal"), col.centNGlobal(), col.multNTracksPVetaHalf());
648-
histos.fill(HIST("hMultEta05VsCentNGlobal"), col.centNGlobal(), col.multNTracksPVetaHalf());
765+
766+
initRun(col);
767+
const float centNGlo = getCentrality(hCentralityNGlo, col.multNTracksGlobal(), col.centNGlobal());
768+
769+
LOGF(debug, "centNGlo=%.0f", centNGlo);
770+
histos.fill(HIST("hCentNGlobal"), centNGlo);
771+
histos.fill(HIST("hCentProfileNGlobal"), centNGlo, col.multNTracksPVetaHalf());
772+
histos.fill(HIST("hMultEta05VsCentNGlobal"), centNGlo, col.multNTracksPVetaHalf());
649773
}
650774
PROCESS_SWITCH(CentralityQa, processRun3_NGlobal, "Process with Run 3 NGlobal estimator", false);
651775

652-
void processRun3_MFT(soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentMFTs>::iterator const& col)
776+
void processRun3_MFT(soa::Join<aod::Collisions, aod::EvSels, aod::MultsRun3, aod::MFTMults, aod::CentMFTs>::iterator const& col, aod::BCs const&)
653777
{
654778
if (!isCollisionAccepted(col)) {
655779
return;
656780
}
657-
histos.fill(HIST("hCentMFT"), col.centMFT());
658-
histos.fill(HIST("hCentProfileMFT"), col.centMFT(), col.multNTracksPVetaHalf());
659-
histos.fill(HIST("hMultEta05VsCentMFT"), col.centMFT(), col.multNTracksPVetaHalf());
781+
782+
initRun(col);
783+
const float centMFT = getCentrality(hCentralityMFT, col.mftNtracks(), col.centMFT());
784+
785+
LOGF(debug, "centMFT=%.0f", centMFT);
786+
histos.fill(HIST("hCentMFT"), centMFT);
787+
histos.fill(HIST("hCentProfileMFT"), centMFT, col.multNTracksPVetaHalf());
788+
histos.fill(HIST("hMultEta05VsCentMFT"), centMFT, col.multNTracksPVetaHalf());
660789
}
661790
PROCESS_SWITCH(CentralityQa, processRun3_MFT, "Process with Run 3 MFT estimator", false);
662791

0 commit comments

Comments
 (0)