Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext co
outputs,
AlgorithmSpec(adaptFromTask<FT0EventsPerBcProcessor>(ccdbRequest)),
Options{
{"save-to-file", VariantType::Bool, false, {"Save calibration object to local file"}},
{"slot-len-sec", VariantType::UInt32, 3600u, {"Duration of each slot in seconds"}},
{"one-object-per-run", VariantType::Bool, false, {"If set, workflow creates only one calibration object per run"}},
{"min-entries-number", VariantType::UInt32, 5000u, {"Minimum number of entries required for a slot to be valid"}},
Expand All @@ -45,4 +46,4 @@ o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext co
WorkflowSpec workflow;
workflow.emplace_back(dataProcessorSpec);
return workflow;
}
}
22 changes: 21 additions & 1 deletion Detectors/FIT/FT0/calibration/workflow/FT0EventsPerBcSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class FT0EventsPerBcProcessor final : public o2::framework::Task
void init(o2::framework::InitContext& ic) final
{
o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest);
mSaveToFile = ic.options().get<bool>("save-to-file");

if (ic.options().hasOption("slot-len-sec")) {
mSlotLenSec = ic.options().get<uint32_t>("slot-len-sec");
}
Expand Down Expand Up @@ -73,6 +75,10 @@ class FT0EventsPerBcProcessor final : public o2::framework::Task

void run(o2::framework::ProcessingContext& pc) final
{
const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
if (tinfo.globalRunNumberChanged || mRunNoFromDH < 1) { // new run is starting
mRunNoFromDH = tinfo.runNumber;
}
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
auto digits = pc.inputs().get<gsl::span<o2::ft0::Digit>>("digits");
o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo());
Expand Down Expand Up @@ -107,6 +113,18 @@ class FT0EventsPerBcProcessor final : public o2::framework::Task
<< " bytes, valid for " << info->getStartValidityTimestamp() << " : " << info->getEndValidityTimestamp();
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "EventsPerBc", idx}, *image.get());
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "EventsPerBc", idx}, *info.get());
if (mSaveToFile) {
std::string fnout = fmt::format("ft0eventsPerBC_run_{}_{}_{}.root", mRunNoFromDH, info->getStartValidityTimestamp(), info->getEndValidityTimestamp());
try {
TFile flout(fnout.c_str(), "recreate");
flout.WriteObjectAny(&payload, "o2::ft0::EventsPerBc", o2::ccdb::CcdbApi::CCDBOBJECT_ENTRY);
LOGP(info, R"(Saved to file, can upload as: o2-ccdb-upload -f {} --starttimestamp {} --endtimestamp {} -k "ccdb_object" --path {} -m "runNumber={};AdjustableEOV=true;")",
fnout, info->getStartValidityTimestamp(), info->getEndValidityTimestamp(), info->getPath(), mRunNoFromDH);
flout.Close();
} catch (const std::exception& ex) {
LOGP(error, "failed to store object to file {}, error: {}", fnout, ex.what());
}
}
}

if (tvxHists.size()) {
Expand All @@ -118,11 +136,13 @@ class FT0EventsPerBcProcessor final : public o2::framework::Task
std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
std::unique_ptr<o2::ft0::EventsPerBcCalibrator> mCalibrator;
bool mOneObjectPerRun;
bool mSaveToFile = false;
int mRunNoFromDH = 0;
uint32_t mSlotLenSec;
uint32_t mMinNumberOfEntries;
int32_t mMinAmplitudeSideA;
int32_t mMinAmplitudeSideC;
int32_t mMinSumOfAmplitude;
};
} // namespace o2::calibration
#endif
#endif