From 9b79284aaa5dd70d9560311130b92ef12dee47ba Mon Sep 17 00:00:00 2001 From: Matthias Kleiner Date: Wed, 6 Mar 2024 13:22:51 +0100 Subject: [PATCH] TPC: Adding option to add time offset when writing pad status map --- .../include/TPCWorkflow/TPCFactorizeIDCSpec.h | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeIDCSpec.h b/Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeIDCSpec.h index a4107690c941a..6c7be9a140e13 100644 --- a/Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeIDCSpec.h +++ b/Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeIDCSpec.h @@ -75,6 +75,8 @@ class TPCFactorizeIDCSpec : public o2::framework::Task mMetaFileDir = o2::utils::Str::rectifyDirectory(mMetaFileDir); } + mStatusMapOffsSec = ic.options().get("pad-status-map-offset"); + mStatusMapOffsNSlot = ic.options().get("pad-status-map-offset-nslots"); const std::string refGainMapFile = ic.options().get("gainMapFile"); if (!refGainMapFile.empty()) { LOGP(info, "Loading GainMap from file {}", refGainMapFile); @@ -196,6 +198,8 @@ class TPCFactorizeIDCSpec : public o2::framework::Task bool mSetDataTakingCont{true}; long mTimestampStart{0}; ///< time stamp of first TF uint64_t mRun{0}; ///< run number + float mStatusMapOffsSec = 0; ///< offset in seconds for writing pad staus map to CCDB + int mStatusMapOffsNSlot = 0; ///< offset in n slot units for writing pad staus map to CCDB const std::vector mFilter = {{"idcagg", ConcreteDataTypeMatcher{gDataOriginTPC, TPCDistributeIDCSpec::getDataDescriptionIDC(mLaneId)}, Lifetime::Sporadic}}; ///< filter for looping over input data void sendOutput(DataAllocator& output) @@ -262,33 +266,26 @@ class TPCFactorizeIDCSpec : public o2::framework::Task // store map in case it is no nullptr if (mEnableWritingPadStatusMap) { - if (!mPadFlagsMap) { - mPadFlagsMap = std::move(padStatusMap); - LOGP(info, "Writing pad status map to CCDB."); - o2::ccdb::CcdbObjectInfo ccdbInfoPadFlags(CDBTypeMap.at(sideA ? CDBType::CalIDCPadStatusMapA : CDBType::CalIDCPadStatusMapC), std::string{}, std::string{}, std::map{}, mTimestampStart, timeStampEnd); - auto imageFlagMap = o2::ccdb::CcdbApi::createObjectImage(mPadFlagsMap.get(), &ccdbInfoPadFlags); - LOGP(info, "Sending object {} / {} of size {} bytes, valid for {} : {} ", ccdbInfoPadFlags.getPath(), ccdbInfoPadFlags.getFileName(), imageFlagMap->size(), ccdbInfoPadFlags.getStartValidityTimestamp(), ccdbInfoPadFlags.getEndValidityTimestamp()); - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, getDataDescriptionCCDBIDCPadFlag(), 0}, *imageFlagMap.get()); - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, getDataDescriptionCCDBIDCPadFlag(), 0}, ccdbInfoPadFlags); - LOGP(info, "Pad status map written to CCDB"); - } else { - // check if map changed. if it changed update the map in the CCDB and store new map in buffer - if (!(*padStatusMap.get() == *mPadFlagsMap.get())) { - mPadFlagsMap = std::move(padStatusMap); - LOGP(info, "Pad status map changed"); - LOGP(info, "Writing pad status map to CCDB"); - o2::ccdb::CcdbObjectInfo ccdbInfoPadFlags(CDBTypeMap.at(sideA ? CDBType::CalIDCPadStatusMapA : CDBType::CalIDCPadStatusMapC), std::string{}, std::string{}, std::map{}, mTimestampStart, timeStampEnd); - auto imageFlagMap = o2::ccdb::CcdbApi::createObjectImage(mPadFlagsMap.get(), &ccdbInfoPadFlags); - LOGP(info, "Sending object {} / {} of size {} bytes, valid for {} : {} ", ccdbInfoPadFlags.getPath(), ccdbInfoPadFlags.getFileName(), imageFlagMap->size(), ccdbInfoPadFlags.getStartValidityTimestamp(), ccdbInfoPadFlags.getEndValidityTimestamp()); - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, getDataDescriptionCCDBIDCPadFlag(), 0}, *imageFlagMap.get()); - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, getDataDescriptionCCDBIDCPadFlag(), 0}, ccdbInfoPadFlags); - LOGP(info, "Pad status map written to CCDB"); - } - stop = timer::now(); - time = stop - start; - LOGP(info, "Pad status map CCDB time: {}", time.count()); - totalTime += time.count(); + long timeStampEndOffsPad = 0; + if (mStatusMapOffsSec > 0) { + timeStampEndOffsPad = mStatusMapOffsSec * 1000; + } else if (mStatusMapOffsNSlot > 0) { + const long length = timeStampEnd - mTimestampStart; + timeStampEndOffsPad = mStatusMapOffsNSlot * length; } + + mPadFlagsMap = std::move(padStatusMap); + LOGP(info, "Writing pad status map to CCDB with an offset of {}.", timeStampEndOffsPad); + o2::ccdb::CcdbObjectInfo ccdbInfoPadFlags(CDBTypeMap.at(sideA ? CDBType::CalIDCPadStatusMapA : CDBType::CalIDCPadStatusMapC), std::string{}, std::string{}, std::map{}, mTimestampStart, timeStampEnd + timeStampEndOffsPad); + auto imageFlagMap = o2::ccdb::CcdbApi::createObjectImage(mPadFlagsMap.get(), &ccdbInfoPadFlags); + LOGP(info, "Sending object {} / {} of size {} bytes, valid for {} : {} ", ccdbInfoPadFlags.getPath(), ccdbInfoPadFlags.getFileName(), imageFlagMap->size(), ccdbInfoPadFlags.getStartValidityTimestamp(), ccdbInfoPadFlags.getEndValidityTimestamp()); + output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, getDataDescriptionCCDBIDCPadFlag(), 0}, *imageFlagMap.get()); + output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, getDataDescriptionCCDBIDCPadFlag(), 0}, ccdbInfoPadFlags); + LOGP(info, "Pad status map written to CCDB"); + stop = timer::now(); + time = stop - start; + LOGP(info, "Pad status map CCDB time: {}", time.count()); + totalTime += time.count(); } stop = timer::now(); time = stop - start; @@ -501,6 +498,8 @@ DataProcessorSpec getTPCFactorizeIDCSpec(const int lane, const std::vector