Skip to content

Commit fdce1f9

Browse files
authored
Update
1 parent 7108359 commit fdce1f9

File tree

1 file changed

+67
-68
lines changed

1 file changed

+67
-68
lines changed

Common/TableProducer/multPercentile.cxx

Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,18 @@ struct multiplicityPercentile {
195195

196196
} centralityConfig;
197197

198+
struct TagRun2V0MCalibration {
199+
bool lCalibLoaded;
200+
TList* lCalibObjectsMultiplicity;
201+
TProfile* hVtxZFV0A;
202+
TProfile* hVtxZFT0A;
203+
TProfile* hVtxZFT0C;
204+
TProfile* hVtxZFDDA;
205+
TProfile* hVtxZFDDC;
206+
TProfile* hVtxZNTracks;
207+
} centralityCalib;
208+
198209
int mRunNumber;
199-
bool lCalibLoaded;
200-
TList* lCalibObjectsMultiplicity;
201-
TProfile* hVtxZFV0A;
202-
TProfile* hVtxZFT0A;
203-
TProfile* hVtxZFT0C;
204-
TProfile* hVtxZFDDA;
205-
206-
TProfile* hVtxZFDDC;
207-
TProfile* hVtxZNTracks;
208210
std::vector<int> mEnabledMultiplicityTables; // Vector of enabled multiplicity tables
209211
std::vector<int> mEnabledCentralityTables; // Vector of enabled centrality tables
210212

@@ -242,13 +244,14 @@ struct multiplicityPercentile {
242244
TH1* mhVtxAmpCorr = nullptr;
243245
TH1* mhMultSelCalib = nullptr;
244246
} Run2CL1Info;
245-
struct CalibrationInfo {
247+
248+
struct CentralityCalibration {
246249
std::string name = "";
247250
bool mCalibrationStored = false;
248251
TH1* mhMultSelCalib = nullptr;
249252
float mMCScalePars[6] = {0.0};
250253
TFormula* mMCScale = nullptr;
251-
explicit CalibrationInfo(std::string name)
254+
explicit CentralityCalibration(std::string name)
252255
: name(name),
253256
mCalibrationStored(false),
254257
mhMultSelCalib(nullptr),
@@ -273,15 +276,15 @@ struct multiplicityPercentile {
273276
return true;
274277
}
275278
};
276-
CalibrationInfo fv0aInfo = CalibrationInfo("FV0");
277-
CalibrationInfo ft0mInfo = CalibrationInfo("FT0");
278-
CalibrationInfo ft0aInfo = CalibrationInfo("FT0A");
279-
CalibrationInfo ft0cInfo = CalibrationInfo("FT0C");
280-
CalibrationInfo ft0cVariant1Info = CalibrationInfo("FT0Cvar1");
281-
CalibrationInfo fddmInfo = CalibrationInfo("FDD");
282-
CalibrationInfo ntpvInfo = CalibrationInfo("NTracksPV");
283-
CalibrationInfo nGlobalInfo = CalibrationInfo("NGlobal");
284-
CalibrationInfo mftInfo = CalibrationInfo("MFT");
279+
CentralityCalibration fv0aInfo = CentralityCalibration("FV0");
280+
CentralityCalibration ft0mInfo = CentralityCalibration("FT0");
281+
CentralityCalibration ft0aInfo = CentralityCalibration("FT0A");
282+
CentralityCalibration ft0cInfo = CentralityCalibration("FT0C");
283+
CentralityCalibration ft0cVariant1Info = CentralityCalibration("FT0Cvar1");
284+
CentralityCalibration fddmInfo = CentralityCalibration("FDD");
285+
CentralityCalibration ntpvInfo = CentralityCalibration("NTracksPV");
286+
CentralityCalibration nGlobalInfo = CentralityCalibration("NGlobal");
287+
CentralityCalibration mftInfo = CentralityCalibration("MFT");
285288

286289
// Debug output
287290
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::QAObject};
@@ -426,8 +429,8 @@ struct multiplicityPercentile {
426429
aod::FDDs const&)
427430
{
428431
// reserve memory for multiplicity tables
429-
for (const auto& i : mEnabledMultiplicityTables) {
430-
switch (i) {
432+
for (const auto tableId : mEnabledMultiplicityTables) {
433+
switch (tableId) {
431434
case kFV0Mults: // FV0
432435
tableFV0.reserve(collisions.size());
433436
tableFV0AOuter.reserve(collisions.size());
@@ -471,14 +474,14 @@ struct multiplicityPercentile {
471474
case kMultMCExtras: // MC extra information (nothing to do in the data)
472475
break;
473476
default:
474-
LOG(fatal) << "Unknown table requested: " << i;
477+
LOG(fatal) << "Unknown table requested: " << tableId;
475478
break;
476479
}
477480
}
478481

479482
// reserve memory for centrality tables
480-
for (auto const& table : mEnabledCentralityTables) {
481-
switch (table) {
483+
for (auto const tableId : mEnabledCentralityTables) {
484+
switch (tableId) {
482485
case centrality::kFV0As:
483486
centFV0A.reserve(collisions.size());
484487
break;
@@ -507,7 +510,7 @@ struct multiplicityPercentile {
507510
centMFTs.reserve(collisions.size());
508511
break;
509512
default:
510-
LOGF(fatal, "Table %d not supported in Run3", table);
513+
LOGF(fatal, "Table %d not supported in Run3", tableId);
511514
break;
512515
}
513516
}
@@ -586,8 +589,8 @@ struct multiplicityPercentile {
586589
}
587590

588591
// First we compute the multiplicity
589-
for (const auto& i : mEnabledMultiplicityTables) {
590-
switch (i) {
592+
for (const auto tableId : mEnabledMultiplicityTables) {
593+
switch (tableId) {
591594
case kFV0Mults: // FV0
592595
{
593596
multFV0A = 0.f;
@@ -795,56 +798,50 @@ struct multiplicityPercentile {
795798
} break;
796799
default: // Default
797800
{
798-
LOG(fatal) << "Unknown table requested: " << i;
801+
LOG(fatal) << "Unknown table requested: " << tableId;
799802
} break;
800803
}
801804
}
805+
806+
if (mEnabledCentralityTables.size() == 0){// If no centrality table is required skip the rest
807+
continue;
808+
}
802809

803810
if (bc.runNumber() != mRunNumber) {
804811
mRunNumber = bc.runNumber(); // mark that this run has been attempted already regardless of outcome
805812
LOGF(info, "timestamp=%llu, run number=%d", bc.timestamp(), bc.runNumber());
806-
TList* callst = nullptr;
813+
TList* calibrationList = nullptr;
807814
// Check if the ccdb path is a root file
808-
if (ccdbConfig.ccdbPath.value.find(".root") != std::string::npos) {
815+
if (ccdbConfig.ccdbPath.value.find(".root") != std::string::npos) { // File
816+
LOG(info) << "Fetching centrality calibration from TFile" << ccdbConfig.ccdbPath.value.c_str() << " and pass '" << ccdbConfig.reconstructionPass.value << "'";
809817
TFile f(ccdbConfig.ccdbPath.value.c_str(), "READ");
810-
f.GetObject(ccdbConfig.reconstructionPass.value.c_str(), callst);
811-
if (!callst) {
818+
f.GetObject(ccdbConfig.reconstructionPass.value.c_str(), calibrationList);
819+
if (!calibrationList) {
812820
f.ls();
813821
LOG(fatal) << "No calibration list " << ccdbConfig.reconstructionPass.value << " found in the file " << ccdbConfig.ccdbPath.value;
814822
}
815-
} else {
823+
} else { // CCDB
824+
LOG(info) << "Fetching centrality calibration from ccdb" << ccdbConfig.ccdbPath.value << " and pass '" << ccdbConfig.reconstructionPass.value << "'";
825+
std::map<std::string, std::string> metadata;
816826
if (ccdbConfig.reconstructionPass.value == "") {
817-
callst = ccdb->getForRun<TList>(ccdbConfig.ccdbPath, bc.runNumber());
818-
} else if (ccdbConfig.reconstructionPass.value == "metadata") {
819-
std::map<std::string, std::string> metadata;
820-
metadata["RecoPassName"] = metadataInfo.get("RecoPassName");
827+
LOG(info) << "No pass required";
828+
} else{ if (ccdbConfig.reconstructionPass.value == "metadata") {
821829
LOGF(info, "Loading CCDB for reconstruction pass (from metadata): %s", metadataInfo.get("RecoPassName"));
822-
callst = ccdb->getSpecificForRun<TList>(ccdbConfig.ccdbPath, bc.runNumber(), metadata);
823-
} else {
824-
std::map<std::string, std::string> metadata;
825-
metadata["RecoPassName"] = ccdbConfig.reconstructionPass.value;
826-
LOGF(info, "Loading CCDB for reconstruction pass (from provided argument): %s", ccdbConfig.reconstructionPass.value);
827-
callst = ccdb->getSpecificForRun<TList>(ccdbConfig.ccdbPath, bc.runNumber(), metadata);
830+
ccdbConfig.reconstructionPass.value = metadataInfo.get("RecoPassName");
828831
}
832+
metadata["RecoPassName"] = ccdbConfig.reconstructionPass.value;
833+
}
834+
calibrationList = ccdb->getSpecificForRun<TList>(ccdbConfig.ccdbPath, bc.runNumber(), metadata);
829835
}
830836

831-
fv0aInfo.mCalibrationStored = false;
832-
ft0mInfo.mCalibrationStored = false;
833-
ft0aInfo.mCalibrationStored = false;
834-
ft0cInfo.mCalibrationStored = false;
835-
ft0cVariant1Info.mCalibrationStored = false;
836-
fddmInfo.mCalibrationStored = false;
837-
ntpvInfo.mCalibrationStored = false;
838-
nGlobalInfo.mCalibrationStored = false;
839-
mftInfo.mCalibrationStored = false;
840-
if (callst != nullptr) {
837+
if (calibrationList != nullptr) {
841838
if (produceHistograms) {
842-
listCalib->Add(callst->Clone(Form("%i", bc.runNumber())));
839+
listCalib->Add(calibrationList->Clone(Form("%i", bc.runNumber())));
843840
}
844841
LOGF(info, "Getting new histograms with %d run number for %d run number", mRunNumber, bc.runNumber());
845-
auto getccdb = [callst, bc](struct CalibrationInfo& estimator, const Configurable<std::string> generatorName) { // TODO: to consider the name inside the estimator structure
846-
estimator.mhMultSelCalib = reinterpret_cast<TH1*>(callst->FindObject(TString::Format("hCalibZeq%s", estimator.name.c_str()).Data()));
847-
estimator.mMCScale = reinterpret_cast<TFormula*>(callst->FindObject(TString::Format("%s-%s", generatorName->c_str(), estimator.name.c_str()).Data()));
842+
auto getccdb = [calibrationList, bc](struct CentralityCalibration& estimator, const Configurable<std::string> generatorName) { // TODO: to consider the name inside the estimator structure
843+
estimator.mhMultSelCalib = reinterpret_cast<TH1*>(calibrationList->FindObject(TString::Format("hCalibZeq%s", estimator.name.c_str()).Data()));
844+
estimator.mMCScale = reinterpret_cast<TFormula*>(calibrationList->FindObject(TString::Format("%s-%s", generatorName->c_str(), estimator.name.c_str()).Data()));
848845
if (estimator.mhMultSelCalib != nullptr) {
849846
if (generatorName->length() != 0) {
850847
LOGF(info, "Retrieving MC calibration for %d, generator name: %s", bc.runNumber(), generatorName->c_str());
@@ -915,7 +912,9 @@ struct multiplicityPercentile {
915912
* @param multiplicity The multiplicity value.
916913
*/
917914

918-
auto populateTable = [&](auto& table, struct CalibrationInfo& estimator, float multiplicity) {
915+
auto populateCentralityTable = [&](auto& table,
916+
struct CentralityCalibration& estimator,
917+
float multiplicity) {
919918
const bool assignOutOfRange = embedINELgtZEROselection && !collision.isInelGt0();
920919
auto scaleMC = [](float x, float pars[6]) {
921920
return std::pow(((pars[0] + pars[1] * std::pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]);
@@ -940,31 +939,31 @@ struct multiplicityPercentile {
940939
for (auto const& table : mEnabledCentralityTables) {
941940
switch (table) {
942941
case centrality::kFV0As:
943-
populateTable(centFV0A, fv0aInfo, multZeqFV0A);
942+
populateCentralityTable(centFV0A, fv0aInfo, multZeqFV0A);
944943
break;
945944
case centrality::kFT0Ms:
946-
const float perC = populateTable(centFT0M, ft0mInfo, multZeqFT0A + multZeqFT0C);
945+
const float perC = populateCentralityTable(centFT0M, ft0mInfo, multZeqFT0A + multZeqFT0C);
947946
break;
948947
case centrality::kFT0As:
949-
const float perC = populateTable(centFT0A, ft0aInfo, multZeqFT0A);
948+
const float perC = populateCentralityTable(centFT0A, ft0aInfo, multZeqFT0A);
950949
break;
951950
case centrality::kFT0Cs:
952-
const float perC = populateTable(centFT0C, ft0cInfo, multZeqFT0C);
951+
const float perC = populateCentralityTable(centFT0C, ft0cInfo, multZeqFT0C);
953952
break;
954953
case centrality::kFT0CVariant1s:
955-
populateTable(centFT0CVariant1, ft0cVariant1Info, multZeqFT0C);
954+
populateCentralityTable(centFT0CVariant1, ft0cVariant1Info, multZeqFT0C);
956955
break;
957956
case centrality::kFDDMs:
958-
populateTable(centFDDM, fddmInfo, multZeqFDDA + multZeqFDDC);
957+
populateCentralityTable(centFDDM, fddmInfo, multZeqFDDA + multZeqFDDC);
959958
break;
960959
case centrality::kNTPVs:
961-
populateTable(centNTPV, ntpvInfo, multZeqNTracksPV);
960+
populateCentralityTable(centNTPV, ntpvInfo, multZeqNTracksPV);
962961
break;
963962
case centrality::kNGlobals:
964-
populateTable(centNGlobals, nGlobalInfo, multNTracksGlobal);
963+
populateCentralityTable(centNGlobals, nGlobalInfo, multNTracksGlobal);
965964
break;
966965
case centrality::kMFTs:
967-
populateTable(centMFTs, mftInfo, mftNtracks);
966+
populateCentralityTable(centMFTs, mftInfo, mftNtracks);
968967
break;
969968
default:
970969
LOGF(fatal, "Table %d not supported in Run3", table);

0 commit comments

Comments
 (0)