Skip to content

Commit

Permalink
Update utility for timestamp extraction to optimize it + switches for…
Browse files Browse the repository at this point in the history
… IDC task what to plot
  • Loading branch information
Laura Serksnyte committed Sep 23, 2024
1 parent 9ac0bcf commit 60ade6d
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 37 deletions.
2 changes: 2 additions & 0 deletions Modules/TPC/include/TPC/IDCs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<TCanvas> mIDCZeroScale;
std::unique_ptr<TCanvas> mIDCZerOverview;
std::unique_ptr<TCanvas> mIDCZeroSides;
Expand Down
121 changes: 86 additions & 35 deletions Modules/TPC/src/IDCs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<const boost::property_tree::ptree&> doIDC1Exists = config.get_child_optional("qc.postprocessing." + id + ".doIDC1");
if (doIDC1Exists) {
auto doIDC1 = config.get<std::string>("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<const boost::property_tree::ptree&> doFourierExists = config.get_child_optional("qc.postprocessing." + id + ".doFourier");
if (doFourierExists) {
auto doIDCFourier = config.get<std::string>("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)
Expand All @@ -137,20 +169,18 @@ void IDCs::initialize(Trigger, framework::ServiceRegistryRef)
mIDCZeroRadialProf.reset();
mIDCZeroStacksA.reset();
mIDCZeroStacksC.reset();
mIDCOneSides1D.reset();
mFourierCoeffsA.reset();
mFourierCoeffsC.reset();

mIDCZeroScale = std::make_unique<TCanvas>("c_sides_IDC0_scale");
mIDCZerOverview = std::make_unique<TCanvas>("c_sides_IDC0_overview");
mIDCZeroRadialProf = std::make_unique<TCanvas>("c_sides_IDC0_radialProfile");
mIDCZeroStacksA = std::make_unique<TCanvas>("c_GEMStacks_IDC0_1D_ASide");
mIDCZeroStacksC = std::make_unique<TCanvas>("c_GEMStacks_IDC0_1D_CSide");

mIDCOneSides1D = std::make_unique<TCanvas>("c_sides_IDC1_1D");

mFourierCoeffsA = std::make_unique<TCanvas>("c_FourierCoefficients_1D_ASide");
mFourierCoeffsC = std::make_unique<TCanvas>("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();
Expand All @@ -161,47 +191,58 @@ 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<TCanvas>("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<TCanvas>("c_FourierCoefficients_1D_ASide");
mFourierCoeffsC = std::make_unique<TCanvas>("c_FourierCoefficients_1D_CSide");
getObjectsManager()->startPublishing(mFourierCoeffsA.get());
getObjectsManager()->startPublishing(mFourierCoeffsC.get());
}
}

void IDCs::update(Trigger, framework::ServiceRegistryRef)
{
std::vector<long> availableTimestampsIDCZeroA = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC0A), 1, mTimestamps["IDCZero"]);
std::vector<long> availableTimestampsIDCZeroC = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC0C), 1, mTimestamps["IDCZero"]);
std::vector<long> availableTimestampsIDCOneA = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC1A), 1, mTimestamps["IDCOne"]);
std::vector<long> availableTimestampsIDCOneC = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDC1C), 1, mTimestamps["IDCOne"]);
std::vector<long> availableTimestampsFFTA = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDCFourierA), 1, mTimestamps["FourierCoeffs"]);
std::vector<long> availableTimestampsFFTC = getDataTimestamps(mCdbApi, CDBTypeMap.at(CDBType::CalIDCFourierC), 1, mTimestamps["FourierCoeffs"]);
std::vector<long> availableTimestampsIDCDeltaA{ 0 };
std::vector<long> availableTimestampsIDCDeltaC{ 0 };
std::vector<long> availableTimestampsIDCOneA{ 0 };
std::vector<long> availableTimestampsIDCOneC{ 0 };
std::vector<long> availableTimestampsFFTA{ 0 };
std::vector<long> 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();
mIDCZerOverview.get()->Clear();
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;
Expand All @@ -214,14 +255,20 @@ void IDCs::update(Trigger, framework::ServiceRegistryRef)

idcZeroA = mCdbApi.retrieveFromTFileAny<IDCZero>(CDBTypeMap.at(CDBType::CalIDC0A), std::map<std::string, std::string>{}, availableTimestampsIDCZeroA[0]);
idcZeroC = mCdbApi.retrieveFromTFileAny<IDCZero>(CDBTypeMap.at(CDBType::CalIDC0C), std::map<std::string, std::string>{}, availableTimestampsIDCZeroC[0]);

if (mDoIDCDelta) {
idcDeltaA = mCdbApi.retrieveFromTFileAny<IDCDelta<unsigned char>>(CDBTypeMap.at(CDBType::CalIDCDeltaA), std::map<std::string, std::string>{}, availableTimestampsIDCDeltaA[0]);
idcDeltaC = mCdbApi.retrieveFromTFileAny<IDCDelta<unsigned char>>(CDBTypeMap.at(CDBType::CalIDCDeltaC), std::map<std::string, std::string>{}, availableTimestampsIDCDeltaC[0]);
}
idcOneA = mCdbApi.retrieveFromTFileAny<IDCOne>(CDBTypeMap.at(CDBType::CalIDC1A), std::map<std::string, std::string>{}, availableTimestampsIDCOneA[0]);
idcOneC = mCdbApi.retrieveFromTFileAny<IDCOne>(CDBTypeMap.at(CDBType::CalIDC1C), std::map<std::string, std::string>{}, availableTimestampsIDCOneC[0]);
idcFFTA = mCdbApi.retrieveFromTFileAny<FourierCoeff>(CDBTypeMap.at(CDBType::CalIDCFourierA), std::map<std::string, std::string>{}, availableTimestampsFFTA[0]);
idcFFTC = mCdbApi.retrieveFromTFileAny<FourierCoeff>(CDBTypeMap.at(CDBType::CalIDCFourierC), std::map<std::string, std::string>{}, availableTimestampsFFTC[0]);
if (mDoIDC1) {
idcOneA = mCdbApi.retrieveFromTFileAny<IDCOne>(CDBTypeMap.at(CDBType::CalIDC1A), std::map<std::string, std::string>{}, availableTimestampsIDCOneA[0]);
idcOneC = mCdbApi.retrieveFromTFileAny<IDCOne>(CDBTypeMap.at(CDBType::CalIDC1C), std::map<std::string, std::string>{}, availableTimestampsIDCOneC[0]);
}

if (mDoFourier) {
idcFFTA = mCdbApi.retrieveFromTFileAny<FourierCoeff>(CDBTypeMap.at(CDBType::CalIDCFourierA), std::map<std::string, std::string>{}, availableTimestampsFFTA[0]);
idcFFTC = mCdbApi.retrieveFromTFileAny<FourierCoeff>(CDBTypeMap.at(CDBType::CalIDCFourierC), std::map<std::string, std::string>{}, availableTimestampsFFTC[0]);
}

if (idcZeroA && idcZeroC) {
mCCDBHelper.setIDCZero(idcZeroA, Side::A);
Expand Down Expand Up @@ -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());
Expand Down
17 changes: 15 additions & 2 deletions Modules/TPC/src/Utility.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,30 @@ std::vector<long> getDataTimestamps(const o2::ccdb::CcdbApi& cdbApi, const std::
{
std::vector<long> outVec{};
std::vector<long> tmpVec{};

std::vector<std::string> fileList = o2::utils::Str::tokenize(cdbApi.list(path.data()), '\n');
std::vector<long> tmpVec2{};

if (limit == -1) {
// get the timestamp of the latest version of the file
std::vector<std::string> 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<std::string> 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) {
break;
}
}
} 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<std::string> 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);
Expand Down

0 comments on commit 60ade6d

Please sign in to comment.