1919// /
2020
2121#include " Common/Core/EventPlaneHelper.h"
22+ #include " Common/Core/MetadataHelper.h"
2223#include " Common/DataModel/Centrality.h"
2324#include " Common/DataModel/EventSelection.h"
2425#include " Common/DataModel/FT0Corrected.h"
5960using namespace o2 ;
6061using namespace o2 ::framework;
6162
63+ o2::common::core::MetadataHelper metadataInfo; // Metadata helper
64+
6265using MyCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::FT0sCorrected,
6366 aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs, aod::CentFV0As>;
6467
@@ -106,6 +109,7 @@ struct QVectorsTable {
106109 Configurable<std::vector<int >> cfgnMods{" cfgnMods" , {2 , 3 }, " Modulation of interest" };
107110 Configurable<float > cfgMaxCentrality{" cfgMaxCentrality" , 100 .f , " max. centrality for Q vector calibration" };
108111
112+ Configurable<bool > autodetectApass{" autodetectApass" , false , " Automatically detect the analysis pass of the Qvector corrections" };
109113 Configurable<bool > useCorrectionForRun{" useCorrectionForRun" , true , " Get Qvector corrections based on run number instead of timestamp" };
110114 Configurable<std::string> cfgGainEqPath{" cfgGainEqPath" , " Users/j/junlee/Qvector/GainEq" , " CCDB path for gain equalization constants" };
111115 Configurable<std::string> cfgQvecCalibPath{" cfgQvecCalibPath" , " Analysis/EventPlane/QVecCorrections" , " CCDB path for Q-vector calibration constants" };
@@ -293,14 +297,27 @@ struct QVectorsTable {
293297 }
294298
295299 corrsQvecSp.clear ();
300+ std::string periodFolder;
301+ if (autodetectApass) {
302+ // Construct a subfolder like LHCXX_apassY
303+ int maxCharactersLHCYear = 5 ; // LHCXX
304+ periodFolder = " /" + metadataInfo.get (" LPMProductionTag" ).substr (0 , maxCharactersLHCYear) +
305+ " _" + metadataInfo.get (" RecoPassName" );
306+ }
296307 for (std::size_t i = 0 ; i < cfgnMods->size (); i++) {
297308 int ind = cfgnMods->at (i);
298309 fullPath = cfgQvecCalibPath;
310+ if (autodetectApass) {
311+ fullPath += periodFolder;
312+ }
299313 fullPath += " /v" ;
300314 fullPath += std::to_string (ind);
301315 auto modeCorrQvecSp = getForTsOrRun<TH3F >(fullPath, timestamp, runnumber);
302316 if (!modeCorrQvecSp) {
303317 fullPath = cfgQvecCalibPath;
318+ if (autodetectApass) {
319+ fullPath += periodFolder;
320+ }
304321 fullPath += " /v2" ;
305322 modeCorrQvecSp = getForTsOrRun<TH3F >(fullPath, timestamp, runnumber);
306323 }
@@ -316,11 +333,17 @@ struct QVectorsTable {
316333 for (std::size_t i = 0 ; i < cfgnMods->size (); i++) {
317334 int ind = cfgnMods->at (i);
318335 fullPath = cfgQvecCalibPath;
336+ if (autodetectApass) {
337+ fullPath += periodFolder;
338+ }
319339 fullPath += " /eseq" ;
320340 fullPath += std::to_string (ind);
321341 auto modeCorrQvecEse = getForTsOrRun<TH3F >(fullPath, timestamp, runnumber);
322342 if (!modeCorrQvecEse) {
323343 fullPath = cfgQvecCalibPath;
344+ if (autodetectApass) {
345+ fullPath += periodFolder;
346+ }
324347 fullPath += " /eseq2" ;
325348 modeCorrQvecEse = getForTsOrRun<TH3F >(fullPath, timestamp, runnumber);
326349 }
@@ -337,6 +360,9 @@ struct QVectorsTable {
337360 for (std::size_t i = 0 ; i < cfgnMods->size (); i++) {
338361 int ind = cfgnMods->at (i);
339362 fullPath = cfgShiftPath;
363+ if (autodetectApass) {
364+ fullPath += periodFolder;
365+ }
340366 fullPath += " /v" ;
341367 fullPath += std::to_string (ind);
342368 auto objshift = getForTsOrRun<TProfile3D>(fullPath, timestamp, runnumber);
@@ -352,6 +378,9 @@ struct QVectorsTable {
352378 for (std::size_t i = 0 ; i < cfgnMods->size (); i++) {
353379 int ind = cfgnMods->at (i);
354380 fullPath = cfgShiftPath;
381+ if (autodetectApass) {
382+ fullPath += periodFolder;
383+ }
355384 fullPath += " /eseq" ;
356385 fullPath += std::to_string (ind);
357386 auto objshift = getForTsOrRun<TProfile3D>(fullPath, timestamp, runnumber);
@@ -365,6 +394,9 @@ struct QVectorsTable {
365394 }
366395
367396 fullPath = cfgGainEqPath;
397+ if (autodetectApass) {
398+ fullPath += periodFolder + " /GainEq" ;
399+ }
368400 fullPath += " /FT0" ;
369401 const int nPixelsFT0 = 208 ;
370402 auto const * objft0Gain = getForTsOrRun<std::vector<float >>(fullPath, timestamp, runnumber);
@@ -377,6 +409,9 @@ struct QVectorsTable {
377409 }
378410
379411 fullPath = cfgGainEqPath;
412+ if (autodetectApass) {
413+ fullPath += periodFolder + " /GainEq" ;
414+ }
380415 fullPath += " /FV0" ;
381416 const int nChannelsFV0 = 48 ;
382417 auto const * objfv0Gain = getForTsOrRun<std::vector<float >>(fullPath, timestamp, runnumber);
@@ -917,6 +952,7 @@ struct QVectorsTable {
917952
918953WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
919954{
955+ metadataInfo.initMetadata (cfgc);
920956 return WorkflowSpec{
921957 adaptAnalysisTask<QVectorsTable>(cfgc)};
922958}
0 commit comments