Skip to content

Commit 03ddd89

Browse files
committed
Update on ccdb fetching
1 parent bde993b commit 03ddd89

File tree

1 file changed

+72
-81
lines changed

1 file changed

+72
-81
lines changed

PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx

Lines changed: 72 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ struct UccZdc {
169169
Configurable<std::string> paTHmeanNch{"paTHmeanNch", "Users/o/omvazque/FitMeanNch_9May2025", "base path to the ccdb object"};
170170
Configurable<std::string> paTHsigmaNch{"paTHsigmaNch", "Users/o/omvazque/FitSigmaNch_9May2025", "base path to the ccdb object"};
171171

172-
// the efficiency has been previously stored in the CCDB as TH1F histogram
173-
TH1F* efficiency = nullptr;
174-
TF1* fSigmaNch = nullptr;
175-
TF1* fMeanNch = nullptr;
176-
177172
void init(InitContext const&)
178173
{
179174
// define axes you want to use
@@ -208,6 +203,7 @@ struct UccZdc {
208203
x->SetBinLabel(16, "Within TDC cut?");
209204
x->SetBinLabel(17, "Within ZEM cut?");
210205

206+
LOG(info) << "\tuseTimeStamps=" << useTimeStamps.value;
211207
LOG(info) << "\titsRequirement=" << itsRequirement.value;
212208
LOG(info) << "\trequireITS=" << requireITS.value;
213209
LOG(info) << "\trequireTPC=" << requireTPC.value;
@@ -512,13 +508,15 @@ struct UccZdc {
512508
registry.fill(HIST("hEventCounter"), EvCutLabel::Zem);
513509
}
514510

515-
bool areParsLoaded{false};
516-
if (useTimeStamps) {
517-
areParsLoaded = loadMeanSigmaNchParams(foundBC.timestamp());
518-
} else {
519-
areParsLoaded = loadMeanSigmaNchParams(foundBC.runNumber());
511+
// Load Mean Nch and Sigma Nch from CCDB
512+
auto fMeanNch = ccdb->getForRun<TF1>(paTHmeanNch.value, foundBC.runNumber());
513+
auto fSigmaNch = ccdb->getForRun<TF1>(paTHsigmaNch.value, foundBC.runNumber());
514+
if (!fMeanNch) {
515+
LOGF(fatal, "Could not load fMeanNch from %s", paTHmeanNch.value.c_str());
516+
return;
520517
}
521-
if (!areParsLoaded) {
518+
if (!fSigmaNch) {
519+
LOGF(fatal, "Could not load fSigmaNch from %s", paTHsigmaNch.value.c_str());
522520
return;
523521
}
524522

@@ -669,24 +667,21 @@ struct UccZdc {
669667
}
670668

671669
// Load Efficiency correction
672-
bool isEffLoaded{false};
673-
if (useTimeStamps) {
674-
isEffLoaded = loadEfficiencyCorrection(foundBC.timestamp());
675-
} else {
676-
isEffLoaded = loadEfficiencyCorrection(foundBC.runNumber());
677-
}
678-
if (!isEffLoaded) {
670+
auto efficiency = ccdb->getForRun<TH1F>(paTH.value, foundBC.runNumber());
671+
if (!efficiency) {
672+
LOGF(fatal, "Could not load efficiency from %s", paTH.value.c_str());
679673
return;
680674
}
681675

682676
// Get Nch-based selection objects from the CCDB
683-
bool areParsLoaded{false};
684-
if (useTimeStamps) {
685-
areParsLoaded = loadMeanSigmaNchParams(foundBC.timestamp());
686-
} else {
687-
areParsLoaded = loadMeanSigmaNchParams(foundBC.runNumber());
677+
auto fMeanNch = ccdb->getForRun<TF1>(paTHmeanNch.value, foundBC.runNumber());
678+
auto fSigmaNch = ccdb->getForRun<TF1>(paTHsigmaNch.value, foundBC.runNumber());
679+
if (!fMeanNch) {
680+
LOGF(fatal, "Could not load fMeanNch from %s", paTHmeanNch.value.c_str());
681+
return;
688682
}
689-
if (!areParsLoaded) {
683+
if (!fSigmaNch) {
684+
LOGF(fatal, "Could not load fSigmaNch from %s", paTHsigmaNch.value.c_str());
690685
return;
691686
}
692687

@@ -799,13 +794,14 @@ struct UccZdc {
799794
}
800795

801796
// Load Efficiency correction
802-
bool isEffLoaded{false};
803-
if (useTimeStamps) {
804-
isEffLoaded = loadEfficiencyCorrection(foundBC.timestamp());
805-
} else {
806-
isEffLoaded = loadEfficiencyCorrection(foundBC.runNumber());
807-
}
808-
if (!isEffLoaded) {
797+
// bool isEffLoaded{false};
798+
// if (useTimeStamps) { isEffLoaded = loadEfficiencyCorrection(foundBC.timestamp()); }
799+
// else { isEffLoaded = loadEfficiencyCorrection(foundBC.runNumber()); }
800+
// if(!isEffLoaded) { return; }
801+
802+
auto efficiency = ccdb->getForRun<TH1F>(paTH.value, foundBC.runNumber());
803+
if (!efficiency) {
804+
LOGF(fatal, "Could not load efficiency from %s", paTH.value.c_str());
809805
return;
810806
}
811807

@@ -1034,64 +1030,59 @@ struct UccZdc {
10341030
}
10351031
}
10361032

1033+
/*
10371034
template <typename T>
10381035
bool loadMeanSigmaNchParams(const T& parameter)
10391036
{
1040-
fMeanNch = nullptr;
1041-
fSigmaNch = nullptr;
1042-
// Get Nch-based selection objects from the CCDB
1043-
if (useTimeStamps) {
1044-
fMeanNch = ccdb->getForTimeStamp<TF1>(paTHmeanNch.value, parameter);
1045-
fSigmaNch = ccdb->getForTimeStamp<TF1>(paTHsigmaNch.value, parameter);
1046-
} else {
1047-
fMeanNch = ccdb->getForRun<TF1>(paTHmeanNch.value, parameter);
1048-
fSigmaNch = ccdb->getForRun<TF1>(paTHsigmaNch.value, parameter);
1049-
// auto efficiency = ccdb->getForRun<TH1F>(paTH.value, foundBC.runNumber());
1050-
}
1051-
if (!fMeanNch) {
1052-
LOGF(fatal, "Could not load fMeanNch from %s", paTHmeanNch.value.c_str());
1053-
return false;
1054-
}
1055-
if (!fSigmaNch) {
1056-
LOGF(fatal, "Could not load fSigmaNch from %s", paTHsigmaNch.value.c_str());
1057-
return false;
1058-
}
1059-
// if (fMeanNch) {
1060-
// LOGF(info, "Loaded fMeanNch from %s (%p)", paTHmeanNch.value.c_str(), (void*)fMeanNch);
1061-
// }
1062-
// if (fSigmaNch) {
1063-
// LOGF(info, "Loaded fSigmaNch from %s (%p)", paTHsigmaNch.value.c_str(), (void*)fSigmaNch);
1064-
// }
1065-
if (!fMeanNch || !fSigmaNch) {
1066-
return false;
1067-
} else {
1068-
return true;
1069-
}
1037+
fMeanNch = nullptr;
1038+
fSigmaNch = nullptr;
1039+
// Get Nch-based selection objects from the CCDB
1040+
if(useTimeStamps){
1041+
fMeanNch = ccdb->getForTimeStamp<TF1>(paTHmeanNch.value, parameter);
1042+
fSigmaNch = ccdb->getForTimeStamp<TF1>(paTHsigmaNch.value, parameter);
1043+
} else{
1044+
fMeanNch = ccdb->getForRun<TF1>(paTHmeanNch.value, parameter);
1045+
fSigmaNch = ccdb->getForRun<TF1>(paTHsigmaNch.value, parameter);
1046+
// auto efficiency = ccdb->getForRun<TH1F>(paTH.value, foundBC.runNumber());
1047+
}
1048+
if (!fMeanNch) {
1049+
LOGF(fatal, "Could not load fMeanNch from %s", paTHmeanNch.value.c_str());
1050+
return false;
1051+
}
1052+
if (!fSigmaNch) {
1053+
LOGF(fatal, "Could not load fSigmaNch from %s", paTHsigmaNch.value.c_str());
1054+
return false;
1055+
}
1056+
// if (fMeanNch) {
1057+
// LOGF(info, "Loaded fMeanNch from %s (%p)", paTHmeanNch.value.c_str(), (void*)fMeanNch);
1058+
// }
1059+
// if (fSigmaNch) {
1060+
// LOGF(info, "Loaded fSigmaNch from %s (%p)", paTHsigmaNch.value.c_str(), (void*)fSigmaNch);
1061+
// }
1062+
if(!fMeanNch || !fSigmaNch) { return false; }
1063+
else{ return true; }
10701064
}
10711065
10721066
template <typename T>
10731067
bool loadEfficiencyCorrection(const T& parameter)
10741068
{
1075-
efficiency = nullptr;
1076-
// Get Nch-based selection objects from the CCDB
1077-
if (useTimeStamps) {
1078-
efficiency = ccdb->getForTimeStamp<TH1F>(paTH.value, parameter);
1079-
} else {
1080-
efficiency = ccdb->getForRun<TH1F>(paTH.value, parameter);
1081-
}
1082-
if (!efficiency) {
1083-
LOGF(fatal, "Could not load efficiency from %s", paTH.value.c_str());
1084-
return false;
1085-
}
1086-
// if (efficiency) {
1087-
// LOGF(info, "Loaded efficiency from %s (%p)", paTH.value.c_str(), (void*)efficiency);
1088-
// }
1089-
if (!efficiency) {
1090-
return false;
1091-
} else {
1092-
return true;
1093-
}
1094-
}
1069+
efficiency = nullptr;
1070+
// Get Nch-based selection objects from the CCDB
1071+
if(useTimeStamps){
1072+
efficiency = ccdb->getForTimeStamp<TH1F>(paTH.value, parameter);
1073+
} else{
1074+
efficiency = ccdb->getForRun<TH1F>(paTH.value, parameter);
1075+
}
1076+
if (!efficiency) {
1077+
LOGF(fatal, "Could not load efficiency from %s", paTH.value.c_str());
1078+
return false;
1079+
}
1080+
// if (efficiency) {
1081+
// LOGF(info, "Loaded efficiency from %s (%p)", paTH.value.c_str(), (void*)efficiency);
1082+
// }
1083+
if(!efficiency) { return false; }
1084+
else{ return true; }
1085+
}*/
10951086
};
10961087

10971088
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)