diff --git a/Detectors/ITSMFT/common/workflow/include/ITSMFTWorkflow/DeadMapBuilderSpec.h b/Detectors/ITSMFT/common/workflow/include/ITSMFTWorkflow/DeadMapBuilderSpec.h index 89e5a437dcdb8..99dca8475f2a6 100644 --- a/Detectors/ITSMFT/common/workflow/include/ITSMFTWorkflow/DeadMapBuilderSpec.h +++ b/Detectors/ITSMFT/common/workflow/include/ITSMFTWorkflow/DeadMapBuilderSpec.h @@ -92,6 +92,7 @@ class ITSMFTDeadMapBuilder : public Task long mTimeStart = -1; // TODO: better to use RCT info? + std::string mCCDBUrl = ""; std::string mObjectName; std::string mLocalOutputDir; @@ -102,15 +103,17 @@ class ITSMFTDeadMapBuilder : public Task std::vector mDeadMapTF{}; unsigned long mFirstOrbitTF = 0x0; + unsigned long mFirstOrbitRun = 0x0; std::string mDataSource = "chipsstatus"; int mTFSampling = 1000; + std::string mSamplingMode = "first-orbit-run"; // Use this default to ensure process of first TF. At the moment, use any other option to sample on absolute orbit value. o2::itsmft::TimeDeadMap mMapObject; void finalizeOutput(); - void PrepareOutputCcdb(DataAllocator& output); + void PrepareOutputCcdb(EndOfStreamContext* ec, std::string ccdburl); // Utils @@ -121,9 +124,6 @@ class ITSMFTDeadMapBuilder : public Task // Flag to avoid that endOfStream and stop are both done bool isEnded = false; - - // Run stop requested flag for EoS operations - bool mRunStopRequested = false; }; // Create a processor spec diff --git a/Detectors/ITSMFT/common/workflow/src/DeadMapBuilderSpec.cxx b/Detectors/ITSMFT/common/workflow/src/DeadMapBuilderSpec.cxx index d9dff0a6edca4..3194a62d6b273 100644 --- a/Detectors/ITSMFT/common/workflow/src/DeadMapBuilderSpec.cxx +++ b/Detectors/ITSMFT/common/workflow/src/DeadMapBuilderSpec.cxx @@ -47,9 +47,15 @@ void ITSMFTDeadMapBuilder::init(InitContext& ic) LOG(info) << "ITSMFTDeadMapBuilder init... " << mSelfName; mTFSampling = ic.options().get("tf-sampling"); + mSamplingMode = ic.options().get("sampling-mode"); mTFLength = ic.options().get("tf-length"); mDoLocalOutput = ic.options().get("local-output"); mObjectName = ic.options().get("outfile"); + mCCDBUrl = ic.options().get("ccdb-url"); + if (mCCDBUrl == "none") { + mCCDBUrl = ""; + } + mLocalOutputDir = ic.options().get("output-dir"); mSkipStaticMap = ic.options().get("skip-static-map"); @@ -131,9 +137,6 @@ void ITSMFTDeadMapBuilder::finalizeOutput() // Main running function void ITSMFTDeadMapBuilder::run(ProcessingContext& pc) { - if (mRunStopRequested) { // give up when run stop request arrived - return; - } std::chrono::time_point start; std::chrono::time_point end; @@ -144,7 +147,16 @@ void ITSMFTDeadMapBuilder::run(ProcessingContext& pc) mFirstOrbitTF = pc.services().get().firstTForbit; - if ((unsigned long)(mFirstOrbitTF / mTFLength) % mTFSampling != 0) { + if (mFirstOrbitRun == 0x0) { + mFirstOrbitRun = mFirstOrbitTF; + } + + long sampled_orbit = mFirstOrbitTF; + if (mSamplingMode == "first-orbit-run") { + sampled_orbit = sampled_orbit - mFirstOrbitRun; + } + + if ((sampled_orbit / mTFLength) % mTFSampling != 0) { return; } @@ -235,9 +247,11 @@ void ITSMFTDeadMapBuilder::run(ProcessingContext& pc) } ////////////////////////////////////////////////////////////////////////////// -void ITSMFTDeadMapBuilder::PrepareOutputCcdb(DataAllocator& output) +void ITSMFTDeadMapBuilder::PrepareOutputCcdb(EndOfStreamContext* ec, std::string ccdburl = "") { + // if ccdburl is specified, the object is sent to ccdb from this workflow + long tend = o2::ccdb::getCurrentTimestamp(); std::map md = { @@ -253,16 +267,39 @@ void ITSMFTDeadMapBuilder::PrepareOutputCcdb(DataAllocator& output) info.setAdjustableEOV(); - LOG(info) << "Sending object " << info.getPath() << "/" << info.getFileName() - << " of size " << image->size() << "bytes, valid for " - << info.getStartValidityTimestamp() << " : " << info.getEndValidityTimestamp(); + if (ec != nullptr) { - if (mRunMFT) { - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "TimeDeadMap", 1}, *image.get()); - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TimeDeadMap", 1}, info); - } else { - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "TimeDeadMap", 0}, *image.get()); - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TimeDeadMap", 0}, info); + LOG(info) << "Sending object " << info.getPath() << "/" << info.getFileName() + << "to ccdb-populator, of size " << image->size() << " bytes, valid for " + << info.getStartValidityTimestamp() << " : " << info.getEndValidityTimestamp(); + + if (mRunMFT) { + ec->outputs().snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "TimeDeadMap", 1}, *image.get()); + ec->outputs().snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TimeDeadMap", 1}, info); + } else { + ec->outputs().snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "TimeDeadMap", 0}, *image.get()); + ec->outputs().snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TimeDeadMap", 0}, info); + } + } + + else if (!ccdburl.empty()) { // send from this workflow + + LOG(info) << mSelfName << "sending object " << ccdburl << "/browse/" << info.getFileName() + << " of size " << image->size() << " bytes, valid for " + << info.getStartValidityTimestamp() << " : " << info.getEndValidityTimestamp(); + + o2::ccdb::CcdbApi mApi; + mApi.init(ccdburl); + mApi.storeAsBinaryFile( + &image->at(0), image->size(), info.getFileName(), info.getObjectType(), + info.getPath(), info.getMetaData(), + info.getStartValidityTimestamp(), info.getEndValidityTimestamp()); + o2::ccdb::adjustOverriddenEOV(mApi, info); + } + + else { + + LOG(warning) << "PrepareOutputCcdb called with empty arguments. Doing nothing."; } return; @@ -273,11 +310,11 @@ void ITSMFTDeadMapBuilder::PrepareOutputCcdb(DataAllocator& output) // tells that there will be no more input data void ITSMFTDeadMapBuilder::endOfStream(EndOfStreamContext& ec) { - if (!isEnded && !mRunStopRequested) { - LOG(info) << "endOfStream report:" << mSelfName; + if (!isEnded) { + LOG(info) << "endOfStream report: " << mSelfName; finalizeOutput(); if (mMapObject.getEvolvingMapSize() > 0) { - PrepareOutputCcdb(ec.outputs()); + PrepareOutputCcdb(&ec); } else { LOG(warning) << "Time-dependent dead map is empty and will not be forwarded as output"; } @@ -291,12 +328,14 @@ void ITSMFTDeadMapBuilder::endOfStream(EndOfStreamContext& ec) void ITSMFTDeadMapBuilder::stop() { if (!isEnded) { - LOG(info) << "stop() report:" << mSelfName; + LOG(info) << "stop() report: " << mSelfName; finalizeOutput(); - if (mDoLocalOutput) { - LOG(info) << "stop() not sending object as output. ccdb will not be populated."; + if (!mCCDBUrl.empty()) { + std::string detname = mRunMFT ? "MFT" : "ITS"; + LOG(warning) << "endOfStream not processed. Sending output to ccdb from the " << detname << "deadmap builder workflow."; + PrepareOutputCcdb(nullptr, mCCDBUrl); } else { - LOG(error) << "stop() not sending object as output. ccdb will not be populated."; + LOG(warning) << "endOfStream not processed. Nothing forwarded as output."; } isEnded = true; } @@ -340,8 +379,10 @@ DataProcessorSpec getITSMFTDeadMapBuilderSpec(std::string datasource, bool doMFT outputs, AlgorithmSpec{adaptFromTask(datasource, doMFT)}, Options{{"tf-sampling", VariantType::Int, 1000, {"Process every Nth TF. Selection according to first TF orbit."}}, + {"sampling-mode", VariantType::String, "first-orbit-run", {"Use absolute orbit value or offset from first processed orbit."}}, {"tf-length", VariantType::Int, 32, {"Orbits per TF."}}, {"skip-static-map", VariantType::Bool, false, {"Do not fill static part of the map."}}, + {"ccdb-url", VariantType::String, "", {"CCDB url. Ignored if endOfStream is processed."}}, {"outfile", VariantType::String, objectname_default, {"ROOT object file name."}}, {"local-output", VariantType::Bool, false, {"Save ROOT tree file locally."}}, {"output-dir", VariantType::String, "./", {"ROOT tree local output directory."}}}}; diff --git a/prodtests/full-system-test/aggregator-workflow.sh b/prodtests/full-system-test/aggregator-workflow.sh index 1bce657f796bc..e3317d760730e 100755 --- a/prodtests/full-system-test/aggregator-workflow.sh +++ b/prodtests/full-system-test/aggregator-workflow.sh @@ -199,11 +199,11 @@ if [[ $AGGREGATOR_TASKS == BARREL_TF ]] || [[ $AGGREGATOR_TASKS == ALL ]]; then fi # ITS if [[ $CALIB_ITS_DEADMAP_TIME == 1 ]]; then - add_W o2-itsmft-deadmap-builder-workflow "${CALIB_ITS_DEADMAP_TIME_OPT:-}" + add_W o2-itsmft-deadmap-builder-workflow "--ccdb-url $CCDB_POPULATOR_UPLOAD_PATH ${CALIB_ITS_DEADMAP_TIME_OPT:-}" fi # MFT if [[ $CALIB_MFT_DEADMAP_TIME == 1 ]]; then - add_W o2-itsmft-deadmap-builder-workflow "--runmft ${CALIB_MFT_DEADMAP_TIME_OPT:---skip-static-map}" + add_W o2-itsmft-deadmap-builder-workflow "--runmft --ccdb-url $CCDB_POPULATOR_UPLOAD_PATH ${CALIB_MFT_DEADMAP_TIME_OPT:---skip-static-map}" fi # TOF if [[ $CALIB_TOF_LHCPHASE == 1 ]] || [[ $CALIB_TOF_CHANNELOFFSETS == 1 ]]; then