Skip to content

Commit

Permalink
ITSMFT DeadMapBuilder ccdb upload when EoS not processed (AliceO2Grou…
Browse files Browse the repository at this point in the history
…p#12828)

* [WIP] ITSMFT DeadMapBuilder severity message reduced

* ccdb api in the workflow

* leaving option for offline processing

* dummy commit to trigger CI

* ec not nullptr

* Dummy commit to trigger CI

---------

Co-authored-by: Nicolo Valle <nicolo.valle@cern.ch>
  • Loading branch information
2 people authored and andreasmolander committed Apr 12, 2024
1 parent f6b618c commit 4f0f135
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -102,15 +103,17 @@ class ITSMFTDeadMapBuilder : public Task
std::vector<uint16_t> 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

Expand All @@ -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
Expand Down
83 changes: 62 additions & 21 deletions Detectors/ITSMFT/common/workflow/src/DeadMapBuilderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@ void ITSMFTDeadMapBuilder::init(InitContext& ic)
LOG(info) << "ITSMFTDeadMapBuilder init... " << mSelfName;

mTFSampling = ic.options().get<int>("tf-sampling");
mSamplingMode = ic.options().get<std::string>("sampling-mode");
mTFLength = ic.options().get<int>("tf-length");
mDoLocalOutput = ic.options().get<bool>("local-output");
mObjectName = ic.options().get<std::string>("outfile");
mCCDBUrl = ic.options().get<std::string>("ccdb-url");
if (mCCDBUrl == "none") {
mCCDBUrl = "";
}

mLocalOutputDir = ic.options().get<std::string>("output-dir");
mSkipStaticMap = ic.options().get<bool>("skip-static-map");

Expand Down Expand Up @@ -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<std::chrono::high_resolution_clock> start;
std::chrono::time_point<std::chrono::high_resolution_clock> end;
Expand All @@ -144,7 +147,16 @@ void ITSMFTDeadMapBuilder::run(ProcessingContext& pc)

mFirstOrbitTF = pc.services().get<o2::framework::TimingInfo>().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;
}

Expand Down Expand Up @@ -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<std::string, std::string> md = {
Expand All @@ -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;
Expand All @@ -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";
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -340,8 +379,10 @@ DataProcessorSpec getITSMFTDeadMapBuilderSpec(std::string datasource, bool doMFT
outputs,
AlgorithmSpec{adaptFromTask<ITSMFTDeadMapBuilder>(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."}}}};
Expand Down
4 changes: 2 additions & 2 deletions prodtests/full-system-test/aggregator-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f0f135

Please sign in to comment.