Skip to content

Commit 5eb299c

Browse files
author
Victor
committed
[PWGCF] DptDpt - Consistent access to CCDB per period
1 parent e6a1d6e commit 5eb299c

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

PWGCF/TableProducer/dptDptFilter.cxx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,10 @@ struct DptDptFilter {
538538
struct : ConfigurableGroup {
539539
std::string prefix = "cfgCCDB";
540540
Configurable<std::string> url{"url", "http://ccdb-test.cern.ch:8080", "The CCDB url for the input file"};
541-
Configurable<std::string> pathName{"pathName", "", "The CCDB path for the input file. Default \"\", i.e. don't load from CCDB"};
541+
Configurable<std::string> pathNameCorrections{"pathNameCorrections", "", "The CCDB path for the corrections file. Default \"\", i.e. don't load from CCDB"};
542+
Configurable<std::string> pathNamePID{"pathNamePID", "", "The CCDB path for the PID adjusts file. Default \"\", i.e. don't load from CCDB"};
542543
Configurable<std::string> date{"date", "20220307", "The CCDB date for the input file"};
543-
Configurable<std::string> period{"period", "LHC22o", "The CCDB dataset period for the input file"};
544+
Configurable<std::string> sufix{"suffix", "", "Dataset period suffix for metadata discrimination"};
544545
} cfginputfile;
545546
Configurable<bool> cfgFullDerivedData{"cfgFullDerivedData", false, "Produce the full derived data for external storage. Default false"};
546547
Configurable<std::string> cfgCentMultEstimator{"cfgCentMultEstimator", "V0M", "Centrality/multiplicity estimator detector: V0M,CL0,CL1,FV0A,FT0M,FT0A,FT0C,NTPV,NOCM: none. Default V0M"};
@@ -1099,9 +1100,8 @@ struct DptDptFilterTracks {
10991100
bool storedccdbinfo = false;
11001101

11011102
std::string cfgCCDBUrl{"http://ccdb-test.cern.ch:8080"};
1102-
std::string cfgCCDBPathName{""};
1103+
std::string cfgCCDBPathNamePID{""};
11031104
std::string cfgCCDBDate{"20220307"};
1104-
std::string cfgCCDBPeriod{"LHC22o"};
11051105

11061106
Configurable<bool> cfgOutDebugInfo{"cfgOutDebugInfo", false, "Out detailed debug information per track into a text file. Default false"};
11071107
Configurable<bool> cfgFullDerivedData{"cfgFullDerivedData", false, "Produce the full derived data for external storage. Default false"};
@@ -1171,9 +1171,8 @@ struct DptDptFilterTracks {
11711171
}
11721172
/* self configure the CCDB access to the input file */
11731173
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.url", cfgCCDBUrl, false);
1174-
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.pathName", cfgCCDBPathName, false);
1174+
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.pathNamePID", cfgCCDBPathNamePID, false);
11751175
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.date", cfgCCDBDate, false);
1176-
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.period", cfgCCDBPeriod, false);
11771176

11781177
/* create the output list which will own the task histograms */
11791178
TList* fOutputList = new TList();
@@ -1440,9 +1439,9 @@ struct DptDptFilterTracks {
14401439
using namespace analysis::dptdptfilter;
14411440

14421441
/* let's get a potential PID adjustment */
1443-
if (cfgCCDBPathName.length() > 0 && !storedccdbinfo) {
1444-
LOGF(info, "Getting information for PID adjustment from %s, at %s, for %s", cfgCCDBPathName.c_str(), cfgCCDBDate.c_str(), cfgCCDBPeriod.c_str());
1445-
TList* pidinfo = getCCDBInput(ccdb, cfgCCDBPathName.c_str(), cfgCCDBDate.c_str(), cfgCCDBPeriod.c_str());
1442+
if ((cfgCCDBDate.length() > 0) && (cfgCCDBPathNamePID.length() > 0) && !storedccdbinfo) {
1443+
LOGF(info, "Getting information for PID adjustment from %s, at %s", cfgCCDBPathNamePID.c_str(), cfgCCDBDate.c_str());
1444+
TList* pidinfo = getCCDBInput(ccdb, cfgCCDBPathNamePID.c_str(), cfgCCDBDate.c_str());
14461445
if (pidinfo != nullptr) {
14471446
pidselector.storePIDAdjustments(pidinfo);
14481447
}

PWGCF/TableProducer/dptDptFilter.h

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -804,21 +804,35 @@ struct DptDptTrackSelection {
804804
bool requirePvContributor = false;
805805
};
806806

807-
inline TList* getCCDBInput(auto& ccdb, const char* ccdbpath, const char* ccdbdate, const char* period = "")
807+
inline TList* getCCDBInput(auto& ccdb, const char* ccdbpath, const char* ccdbdate, bool periodInPath = false, const std::string& suffix = "")
808808
{
809809
std::tm cfgtm = {};
810810
std::stringstream ss(ccdbdate);
811811
ss >> std::get_time(&cfgtm, "%Y%m%d");
812812
cfgtm.tm_hour = 12;
813813
int64_t timestamp = std::mktime(&cfgtm) * 1000;
814814

815-
TList* lst = nullptr;
816-
if (std::strlen(period) != 0) {
817-
std::map<std::string, std::string> metadata{{"Period", period}};
818-
lst = ccdb->template getSpecific<TList>(ccdbpath, timestamp, metadata);
819-
} else {
820-
lst = ccdb->template getForTimeStamp<TList>(ccdbpath, timestamp);
815+
auto cleanPeriod = [](const auto& str) {
816+
std::string tmpStr = str;
817+
size_t pos = tmpStr.find('_');
818+
if (pos != std::string::npos) {
819+
tmpStr.erase(pos);
820+
}
821+
return tmpStr;
822+
};
823+
824+
std::string actualPeriod = cleanPeriod(metadataInfo.get("LPMProductionTag"));
825+
std::string actualPath = ccdbpath;
826+
if (periodInPath) {
827+
actualPath = actualPath + "/" + actualPeriod;
828+
}
829+
if (suffix.length() > 0) {
830+
actualPeriod = actualPeriod + "_" + suffix;
821831
}
832+
833+
TList* lst = nullptr;
834+
std::map<std::string, std::string> metadata{{"Period", actualPeriod}};
835+
lst = ccdb->template getSpecific<TList>(actualPath, timestamp, metadata);
822836
if (lst != nullptr) {
823837
LOGF(info, "Correctly loaded CCDB input object");
824838
} else {

PWGCF/Tasks/dptDptCorrelations.cxx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -908,9 +908,9 @@ struct DptDptCorrelations {
908908
TList* ccdblst = nullptr;
909909
bool loadfromccdb = false;
910910
std::string cfgCCDBUrl{"http://ccdb-test.cern.ch:8080"};
911-
std::string cfgCCDBPathName{""};
911+
std::string cfgCCDBPathNameCorrections{""};
912912
std::string cfgCCDBDate{"20220307"};
913-
std::string cfgCCDBPeriod{"LHC22o"};
913+
std::string cfgCCDBSuffix{""};
914914

915915
/* pair conversion suppression defaults */
916916
static constexpr float kCfgPairCutDefaults[1][5] = {{-1, -1, -1, -1, -1}};
@@ -972,10 +972,10 @@ struct DptDptCorrelations {
972972

973973
/* self configure the CCDB access to the input file */
974974
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.url", cfgCCDBUrl, false);
975-
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.pathName", cfgCCDBPathName, false);
975+
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.pathNameCorrections", cfgCCDBPathNameCorrections, false);
976976
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.date", cfgCCDBDate, false);
977-
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.period", cfgCCDBPeriod, false);
978-
loadfromccdb = cfgCCDBPathName.length() > 0;
977+
getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDB.suffix", cfgCCDBSuffix, false);
978+
loadfromccdb = (cfgCCDBDate.length() > 0) && (cfgCCDBPathNameCorrections.length() > 0);
979979

980980
/* update the potential binning change */
981981
etabinwidth = (etaup - etalow) / static_cast<float>(etabins);
@@ -1230,7 +1230,7 @@ struct DptDptCorrelations {
12301230

12311231
if (ccdblst == nullptr) {
12321232
if (loadfromccdb) {
1233-
ccdblst = getCCDBInput(ccdb, cfgCCDBPathName.c_str(), cfgCCDBDate.c_str());
1233+
ccdblst = getCCDBInput(ccdb, cfgCCDBPathNameCorrections.c_str(), cfgCCDBDate.c_str(), true, cfgCCDBSuffix);
12341234
}
12351235
}
12361236

@@ -1326,7 +1326,7 @@ struct DptDptCorrelations {
13261326

13271327
if (ccdblst == nullptr) {
13281328
if (loadfromccdb) {
1329-
ccdblst = getCCDBInput(ccdb, cfgCCDBPathName.c_str(), cfgCCDBDate.c_str());
1329+
ccdblst = getCCDBInput(ccdb, cfgCCDBPathNameCorrections.c_str(), cfgCCDBDate.c_str(), true, cfgCCDBSuffix);
13301330
}
13311331
}
13321332

@@ -1646,6 +1646,7 @@ struct DptDptCorrelations {
16461646

16471647
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
16481648
{
1649+
o2::analysis::dptdptfilter::metadataInfo.initMetadata(cfgc);
16491650
WorkflowSpec workflow{
16501651
adaptAnalysisTask<DptDptCorrelations>(cfgc, TaskName{"DptDptCorrelationsRec"}, SetDefaultProcesses{{{"processRecLevel", true}, {"processRecLevelMixed", false}, {"processCleaner", false}}}), // o2-linter: disable=name/o2-task (It is adapted multiple times)
16511652
adaptAnalysisTask<DptDptCorrelations>(cfgc, TaskName{"DptDptCorrelationsGen"}, SetDefaultProcesses{{{"processGenLevel", false}, {"processGenLevelMixed", false}, {"processCleaner", true}}})}; // o2-linter: disable=name/o2-task (It is adapted multiple times)

0 commit comments

Comments
 (0)