diff --git a/Modules/TPC/include/TPC/IDCs.h b/Modules/TPC/include/TPC/IDCs.h index f571416027..7dcc6e442a 100644 --- a/Modules/TPC/include/TPC/IDCs.h +++ b/Modules/TPC/include/TPC/IDCs.h @@ -73,6 +73,8 @@ class IDCs : public quality_control::postprocessing::PostProcessingInterface o2::ccdb::CcdbApi mCdbApi; std::string mHost; bool mDoIDCDelta = false; + bool mDoIDC1 = false; + bool mDoFourier = false; std::unique_ptr mIDCZeroScale; std::unique_ptr mIDCZerOverview; std::unique_ptr mIDCZeroSides; diff --git a/Modules/TPC/src/IDCs.cxx b/Modules/TPC/src/IDCs.cxx index 128226efc0..ff80e5c96f 100644 --- a/Modules/TPC/src/IDCs.cxx +++ b/Modules/TPC/src/IDCs.cxx @@ -126,6 +126,38 @@ void IDCs::configure(const boost::property_tree::ptree& config) mDoIDCDelta = false; ILOG(Warning, Support) << "Option 'doIDCDelta' is missing. Using default value 'false'." << ENDM; } + + boost::optional doIDC1Exists = config.get_child_optional("qc.postprocessing." + id + ".doIDC1"); + if (doIDC1Exists) { + auto doIDC1 = config.get("qc.postprocessing." + id + ".doIDC1"); + if (doIDC1 == "1" || doIDC1 == "true" || doIDC1 == "True" || doIDC1 == "TRUE" || doIDC1 == "yes") { + mDoIDC1 = true; + } else if (doIDC1 == "0" || doIDC1 == "false" || doIDC1 == "False" || doIDC1 == "FALSE" || doIDC1 == "no") { + mDoIDC1 = false; + } else { + mDoIDC1 = false; + ILOG(Warning, Support) << "No valid input for 'doIDC1'. Using default value 'false'." << ENDM; + } + } else { + mDoIDC1 = false; + ILOG(Warning, Support) << "Option 'doIDC1' is missing. Using default value 'false'." << ENDM; + } + + boost::optional doFourierExists = config.get_child_optional("qc.postprocessing." + id + ".doFourier"); + if (doFourierExists) { + auto doIDCFourier = config.get("qc.postprocessing." + id + ".doFourier"); + if (doIDCFourier == "1" || doIDCFourier == "true" || doIDCFourier == "True" || doIDCFourier == "TRUE" || doIDCFourier == "yes") { + mDoFourier = true; + } else if (doIDCFourier == "0" || doIDCFourier == "false" || doIDCFourier == "False" || doIDCFourier == "FALSE" || doIDCFourier == "no") { + mDoFourier = false; + } else { + mDoFourier = false; + ILOG(Warning, Support) << "No valid input for 'doFourier'. Using default value 'false'." << ENDM; + } + } else { + mDoFourier = false; + ILOG(Warning, Support) << "Option 'doFourier' is missing. Using default value 'false'." << ENDM; + } } void IDCs::initialize(Trigger, framework::ServiceRegistryRef) @@ -137,9 +169,6 @@ void IDCs::initialize(Trigger, framework::ServiceRegistryRef) mIDCZeroRadialProf.reset(); mIDCZeroStacksA.reset(); mIDCZeroStacksC.reset(); - mIDCOneSides1D.reset(); - mFourierCoeffsA.reset(); - mFourierCoeffsC.reset(); mIDCZeroScale = std::make_unique("c_sides_IDC0_scale"); mIDCZerOverview = std::make_unique("c_sides_IDC0_overview"); @@ -147,10 +176,11 @@ void IDCs::initialize(Trigger, framework::ServiceRegistryRef) mIDCZeroStacksA = std::make_unique("c_GEMStacks_IDC0_1D_ASide"); mIDCZeroStacksC = std::make_unique("c_GEMStacks_IDC0_1D_CSide"); - mIDCOneSides1D = std::make_unique("c_sides_IDC1_1D"); - - mFourierCoeffsA = std::make_unique("c_FourierCoefficients_1D_ASide"); - mFourierCoeffsC = std::make_unique("c_FourierCoefficients_1D_CSide"); + getObjectsManager()->startPublishing(mIDCZeroScale.get()); + getObjectsManager()->startPublishing(mIDCZerOverview.get()); + getObjectsManager()->startPublishing(mIDCZeroRadialProf.get()); + getObjectsManager()->startPublishing(mIDCZeroStacksA.get()); + getObjectsManager()->startPublishing(mIDCZeroStacksC.get()); if (mDoIDCDelta) { mIDCDeltaStacksA.reset(); @@ -161,32 +191,51 @@ void IDCs::initialize(Trigger, framework::ServiceRegistryRef) getObjectsManager()->startPublishing(mIDCDeltaStacksC.get()); } - getObjectsManager()->startPublishing(mIDCZeroScale.get()); - getObjectsManager()->startPublishing(mIDCZerOverview.get()); - getObjectsManager()->startPublishing(mIDCZeroRadialProf.get()); - getObjectsManager()->startPublishing(mIDCZeroStacksA.get()); - getObjectsManager()->startPublishing(mIDCZeroStacksC.get()); - - getObjectsManager()->startPublishing(mIDCOneSides1D.get()); + if (mDoIDC1) { + mIDCOneSides1D.reset(); + mIDCOneSides1D = std::make_unique("c_sides_IDC1_1D"); + getObjectsManager()->startPublishing(mIDCOneSides1D.get()); + } - getObjectsManager()->startPublishing(mFourierCoeffsA.get()); - getObjectsManager()->startPublishing(mFourierCoeffsC.get()); + if (mDoFourier) { + mFourierCoeffsA.reset(); + mFourierCoeffsC.reset(); + mFourierCoeffsA = std::make_unique("c_FourierCoefficients_1D_ASide"); + mFourierCoeffsC = std::make_unique("c_FourierCoefficients_1D_CSide"); + getObjectsManager()->startPublishing(mFourierCoeffsA.get()); + getObjectsManager()->startPublishing(mFourierCoeffsC.get()); + } } void IDCs::update(Trigger, framework::ServiceRegistryRef) { std::vector availableTimestampsIDCZeroA = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC0A), 1, mTimestamps["IDCZero"]); std::vector availableTimestampsIDCZeroC = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC0C), 1, mTimestamps["IDCZero"]); - std::vector availableTimestampsIDCOneA = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC1A), 1, mTimestamps["IDCOne"]); - std::vector availableTimestampsIDCOneC = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC1C), 1, mTimestamps["IDCOne"]); - std::vector availableTimestampsFFTA = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDCFourierA), 1, mTimestamps["FourierCoeffs"]); - std::vector availableTimestampsFFTC = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDCFourierC), 1, mTimestamps["FourierCoeffs"]); std::vector availableTimestampsIDCDeltaA{ 0 }; std::vector availableTimestampsIDCDeltaC{ 0 }; + std::vector availableTimestampsIDCOneA{ 0 }; + std::vector availableTimestampsIDCOneC{ 0 }; + std::vector availableTimestampsFFTA{ 0 }; + std::vector availableTimestampsFFTC{ 0 }; if (mDoIDCDelta) { availableTimestampsIDCDeltaA = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDCDeltaA), 1, mTimestamps["IDCDelta"]); availableTimestampsIDCDeltaC = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDCDeltaC), 1, mTimestamps["IDCDelta"]); + mIDCDeltaStacksA.get()->Clear(); + mIDCDeltaStacksC.get()->Clear(); + } + + if (mDoIDC1) { + availableTimestampsIDCOneA = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC1A), 1, mTimestamps["IDCOne"]); + availableTimestampsIDCOneC = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC1C), 1, mTimestamps["IDCOne"]); + mIDCOneSides1D.get()->Clear(); + } + + if (mDoFourier) { + availableTimestampsFFTA = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDCFourierA), 1, mTimestamps["FourierCoeffs"]); + availableTimestampsFFTC = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDCFourierC), 1, mTimestamps["FourierCoeffs"]); + mFourierCoeffsA.get()->Clear(); + mFourierCoeffsC.get()->Clear(); } mIDCZeroScale.get()->Clear(); @@ -194,14 +243,6 @@ void IDCs::update(Trigger, framework::ServiceRegistryRef) mIDCZeroRadialProf.get()->Clear(); mIDCZeroStacksA.get()->Clear(); mIDCZeroStacksC.get()->Clear(); - mIDCOneSides1D.get()->Clear(); - mFourierCoeffsA.get()->Clear(); - mFourierCoeffsC.get()->Clear(); - - if (mDoIDCDelta) { - mIDCDeltaStacksA.get()->Clear(); - mIDCDeltaStacksC.get()->Clear(); - } o2::tpc::IDCZero* idcZeroA = nullptr; o2::tpc::IDCZero* idcZeroC = nullptr; @@ -214,14 +255,20 @@ void IDCs::update(Trigger, framework::ServiceRegistryRef) idcZeroA = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDC0A), std::map{}, availableTimestampsIDCZeroA[0]); idcZeroC = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDC0C), std::map{}, availableTimestampsIDCZeroC[0]); + if (mDoIDCDelta) { idcDeltaA = mCdbApi.retrieveFromTFileAny>(CDBTypeMap.at(CDBType::CalIDCDeltaA), std::map{}, availableTimestampsIDCDeltaA[0]); idcDeltaC = mCdbApi.retrieveFromTFileAny>(CDBTypeMap.at(CDBType::CalIDCDeltaC), std::map{}, availableTimestampsIDCDeltaC[0]); } - idcOneA = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDC1A), std::map{}, availableTimestampsIDCOneA[0]); - idcOneC = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDC1C), std::map{}, availableTimestampsIDCOneC[0]); - idcFFTA = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDCFourierA), std::map{}, availableTimestampsFFTA[0]); - idcFFTC = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDCFourierC), std::map{}, availableTimestampsFFTC[0]); + if (mDoIDC1) { + idcOneA = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDC1A), std::map{}, availableTimestampsIDCOneA[0]); + idcOneC = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDC1C), std::map{}, availableTimestampsIDCOneC[0]); + } + + if (mDoFourier) { + idcFFTA = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDCFourierA), std::map{}, availableTimestampsFFTA[0]); + idcFFTC = mCdbApi.retrieveFromTFileAny(CDBTypeMap.at(CDBType::CalIDCFourierC), std::map{}, availableTimestampsFFTC[0]); + } if (idcZeroA && idcZeroC) { mCCDBHelper.setIDCZero(idcZeroA, Side::A); @@ -290,10 +337,14 @@ void IDCs::finalize(Trigger, framework::ServiceRegistryRef) getObjectsManager()->stopPublishing(mIDCZeroStacksA.get()); getObjectsManager()->stopPublishing(mIDCZeroStacksC.get()); - getObjectsManager()->stopPublishing(mIDCOneSides1D.get()); + if (mDoIDC1) { + getObjectsManager()->stopPublishing(mIDCOneSides1D.get()); + } - getObjectsManager()->stopPublishing(mFourierCoeffsA.get()); - getObjectsManager()->stopPublishing(mFourierCoeffsC.get()); + if (mDoFourier) { + getObjectsManager()->stopPublishing(mFourierCoeffsA.get()); + getObjectsManager()->stopPublishing(mFourierCoeffsC.get()); + } if (mDoIDCDelta) { getObjectsManager()->stopPublishing(mIDCDeltaStacksA.get()); diff --git a/Modules/TPC/src/Utility.cxx b/Modules/TPC/src/Utility.cxx index d538581e0e..2b4fe15ce6 100644 --- a/Modules/TPC/src/Utility.cxx +++ b/Modules/TPC/src/Utility.cxx @@ -174,10 +174,20 @@ std::vector getDataTimestamps(const o2::ccdb::CcdbApi& cdbApi, const std:: { std::vector outVec{}; std::vector tmpVec{}; - - std::vector fileList = o2::utils::Str::tokenize(cdbApi.list(path.data()), '\n'); + std::vector tmpVec2{}; if (limit == -1) { + // get the timestamp of the latest version of the file + std::vector fileList_forLastEntry = o2::utils::Str::tokenize(cdbApi.list(path.data(), true), '\n'); + for (const auto& metaData : fileList_forLastEntry) { + getTimestamp(metaData, tmpVec2); + if (tmpVec2.size() == 1) { + break; + } + } + // get the list of files for the latest timestamp 3 days (multiple files are used only in DCSPTemperature task, three days seem safe) + // added some seconds to upper timestamp limit as the ccdbapi uses creation timestamp, not validity! + std::vector fileList = o2::utils::Str::tokenize(cdbApi.list(path.data(), false, "text/plain", tmpVec2.front() + 600000, tmpVec2.front() - 86400000), '\n'); for (const auto& metaData : fileList) { getTimestamp(metaData, outVec); if (outVec.size() == nFiles) { @@ -185,6 +195,9 @@ std::vector getDataTimestamps(const o2::ccdb::CcdbApi& cdbApi, const std:: } } } else { + // get file list for requested timestamp minus three days + // added some seconds to upper timestamp limit as the ccdbapi uses creation timestamp, not validity! + std::vector fileList = o2::utils::Str::tokenize(cdbApi.list(path.data(), false, "text/plain", limit + 600000, limit - 86400000), '\n'); for (const auto& metaData : fileList) { if (outVec.size() < nFiles) { getTimestamp(metaData, tmpVec);