@@ -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