Skip to content

Commit 63c7419

Browse files
committed
Possibility to dump FT0 eventsPerBC to file
1 parent 6c245ee commit 63c7419

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Detectors/FIT/FT0/calibration/workflow/FT0EventsPerBcProcessor-Workflow.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext co
3535
outputs,
3636
AlgorithmSpec(adaptFromTask<FT0EventsPerBcProcessor>(ccdbRequest)),
3737
Options{
38+
{"save-to-file", VariantType::Bool, false, {"Save calibration object to local file"}},
3839
{"slot-len-sec", VariantType::UInt32, 3600u, {"Duration of each slot in seconds"}},
3940
{"one-object-per-run", VariantType::Bool, false, {"If set, workflow creates only one calibration object per run"}},
4041
{"min-entries-number", VariantType::UInt32, 5000u, {"Minimum number of entries required for a slot to be valid"}},
@@ -45,4 +46,4 @@ o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext co
4546
WorkflowSpec workflow;
4647
workflow.emplace_back(dataProcessorSpec);
4748
return workflow;
48-
}
49+
}

Detectors/FIT/FT0/calibration/workflow/FT0EventsPerBcSpec.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class FT0EventsPerBcProcessor final : public o2::framework::Task
3535
void init(o2::framework::InitContext& ic) final
3636
{
3737
o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest);
38+
mSaveToFile = ic.options().get<bool>("save-to-file");
39+
3840
if (ic.options().hasOption("slot-len-sec")) {
3941
mSlotLenSec = ic.options().get<uint32_t>("slot-len-sec");
4042
}
@@ -73,6 +75,10 @@ class FT0EventsPerBcProcessor final : public o2::framework::Task
7375

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

112130
if (tvxHists.size()) {
@@ -118,11 +136,13 @@ class FT0EventsPerBcProcessor final : public o2::framework::Task
118136
std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
119137
std::unique_ptr<o2::ft0::EventsPerBcCalibrator> mCalibrator;
120138
bool mOneObjectPerRun;
139+
bool mSaveToFile = false;
140+
int mRunNoFromDH = 0;
121141
uint32_t mSlotLenSec;
122142
uint32_t mMinNumberOfEntries;
123143
int32_t mMinAmplitudeSideA;
124144
int32_t mMinAmplitudeSideC;
125145
int32_t mMinSumOfAmplitude;
126146
};
127147
} // namespace o2::calibration
128-
#endif
148+
#endif

0 commit comments

Comments
 (0)