From 32589ced2dfa4bad528a8a2cc77019d4a8e5e7bb Mon Sep 17 00:00:00 2001 From: marcellocosti Date: Tue, 15 Sep 2026 12:30:37 +0200 Subject: [PATCH] Dynamic fetching of Q-Vector corrections --- Common/TableProducer/qVectorsTable.cxx | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Common/TableProducer/qVectorsTable.cxx b/Common/TableProducer/qVectorsTable.cxx index 79825f9c875..b0dc442da0c 100644 --- a/Common/TableProducer/qVectorsTable.cxx +++ b/Common/TableProducer/qVectorsTable.cxx @@ -19,6 +19,7 @@ /// #include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/MetadataHelper.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/FT0Corrected.h" @@ -59,6 +60,8 @@ using namespace o2; using namespace o2::framework; +o2::common::core::MetadataHelper metadataInfo; // Metadata helper + using MyCollisions = soa::Join; @@ -106,6 +109,7 @@ struct QVectorsTable { Configurable> cfgnMods{"cfgnMods", {2, 3}, "Modulation of interest"}; Configurable cfgMaxCentrality{"cfgMaxCentrality", 100.f, "max. centrality for Q vector calibration"}; + Configurable autodetectApass{"autodetectApass", false, "Automatically detect the analysis pass of the Qvector corrections"}; Configurable useCorrectionForRun{"useCorrectionForRun", true, "Get Qvector corrections based on run number instead of timestamp"}; Configurable cfgGainEqPath{"cfgGainEqPath", "Users/j/junlee/Qvector/GainEq", "CCDB path for gain equalization constants"}; Configurable cfgQvecCalibPath{"cfgQvecCalibPath", "Analysis/EventPlane/QVecCorrections", "CCDB path for Q-vector calibration constants"}; @@ -293,14 +297,27 @@ struct QVectorsTable { } corrsQvecSp.clear(); + std::string periodFolder; + if (autodetectApass) { + // Construct a subfolder like LHCXX_apassY + int maxCharactersLHCYear = 5; // LHCXX + periodFolder = "/" + metadataInfo.get("LPMProductionTag").substr(0, maxCharactersLHCYear) + + "_" + metadataInfo.get("RecoPassName"); + } for (std::size_t i = 0; i < cfgnMods->size(); i++) { int ind = cfgnMods->at(i); fullPath = cfgQvecCalibPath; + if (autodetectApass) { + fullPath += periodFolder; + } fullPath += "/v"; fullPath += std::to_string(ind); auto modeCorrQvecSp = getForTsOrRun(fullPath, timestamp, runnumber); if (!modeCorrQvecSp) { fullPath = cfgQvecCalibPath; + if (autodetectApass) { + fullPath += periodFolder; + } fullPath += "/v2"; modeCorrQvecSp = getForTsOrRun(fullPath, timestamp, runnumber); } @@ -316,11 +333,17 @@ struct QVectorsTable { for (std::size_t i = 0; i < cfgnMods->size(); i++) { int ind = cfgnMods->at(i); fullPath = cfgQvecCalibPath; + if (autodetectApass) { + fullPath += periodFolder; + } fullPath += "/eseq"; fullPath += std::to_string(ind); auto modeCorrQvecEse = getForTsOrRun(fullPath, timestamp, runnumber); if (!modeCorrQvecEse) { fullPath = cfgQvecCalibPath; + if (autodetectApass) { + fullPath += periodFolder; + } fullPath += "/eseq2"; modeCorrQvecEse = getForTsOrRun(fullPath, timestamp, runnumber); } @@ -337,6 +360,9 @@ struct QVectorsTable { for (std::size_t i = 0; i < cfgnMods->size(); i++) { int ind = cfgnMods->at(i); fullPath = cfgShiftPath; + if (autodetectApass) { + fullPath += periodFolder; + } fullPath += "/v"; fullPath += std::to_string(ind); auto objshift = getForTsOrRun(fullPath, timestamp, runnumber); @@ -352,6 +378,9 @@ struct QVectorsTable { for (std::size_t i = 0; i < cfgnMods->size(); i++) { int ind = cfgnMods->at(i); fullPath = cfgShiftPath; + if (autodetectApass) { + fullPath += periodFolder; + } fullPath += "/eseq"; fullPath += std::to_string(ind); auto objshift = getForTsOrRun(fullPath, timestamp, runnumber); @@ -365,6 +394,9 @@ struct QVectorsTable { } fullPath = cfgGainEqPath; + if (autodetectApass) { + fullPath += periodFolder + "/GainEq"; + } fullPath += "/FT0"; const int nPixelsFT0 = 208; auto const* objft0Gain = getForTsOrRun>(fullPath, timestamp, runnumber); @@ -377,6 +409,9 @@ struct QVectorsTable { } fullPath = cfgGainEqPath; + if (autodetectApass) { + fullPath += periodFolder + "/GainEq"; + } fullPath += "/FV0"; const int nChannelsFV0 = 48; auto const* objfv0Gain = getForTsOrRun>(fullPath, timestamp, runnumber); @@ -917,6 +952,7 @@ struct QVectorsTable { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { + metadataInfo.initMetadata(cfgc); return WorkflowSpec{ adaptAnalysisTask(cfgc)}; }