12#ifndef O2_CALIBRATION_TOFCHANNEL_CALIBRATOR_H
13#define O2_CALIBRATION_TOFCHANNEL_CALIBRATOR_H
52 explicit TOFChannelCalibDevice(std::shared_ptr<o2::base::GRPGeomRequest> req,
bool useCCDB,
bool attachChannelOffsetToLHCphase,
bool isCosmics,
bool perstrip =
false,
bool safe =
false) : mCCDBRequest(req), mUseCCDB(useCCDB), mAttachToLHCphase(attachChannelOffsetToLHCphase), mCosmics(isCosmics), mDoPerStrip(perstrip), mSafeMode(safe) {}
57 int minEnt = ic.options().get<
int>(
"min-entries");
58 int nb = std::max(500, ic.options().get<
int>(
"nbins"));
59 mRange = ic.options().get<
float>(
"range");
60 int isTest = ic.options().get<
bool>(
"do-TOF-channel-calib-in-test-mode");
61 bool updateAtEORonly = ic.options().get<
bool>(
"update-at-end-of-run-only");
62 auto slotL = ic.options().get<uint32_t>(
"tf-per-slot");
63 auto delay = ic.options().get<uint32_t>(
"max-delay");
64 auto updateInterval = ic.options().get<uint32_t>(
"update-interval");
65 auto deltaUpdateInterval = ic.options().get<uint32_t>(
"delta-update-interval");
66 mCalibrator = std::make_unique<o2::tof::TOFChannelCalibrator<T>>(minEnt, nb, mRange);
68 mCalibrator->doPerStrip(mDoPerStrip);
69 mCalibrator->doSafeMode(mSafeMode);
77 mCalibrator->setSlotLength(slotL);
78 mCalibrator->setCheckIntervalInfiniteSlot(updateInterval);
79 mCalibrator->setCheckDeltaIntervalInfiniteSlot(deltaUpdateInterval);
80 mCalibrator->setMaxSlotsDelay(delay);
82 if (updateAtEORonly) {
83 mCalibrator->setUpdateAtTheEndOfRunOnly();
86 mCalibrator->setIsTest(isTest);
87 mCalibrator->setDoCalibWithCosmics(mCosmics);
93 if (gSystem->AccessPathName(
"localTimeSlewing.root") ==
false) {
94 TFile* fsleewing = TFile::Open(
"localTimeSlewing.root");
128 long startTimeLHCphase = 0;
129 long startTimeChCalib = 0;
131 auto tfcounter = mCalibrator->getCurrentTFInfo().tfCounter;
134 const auto lhcPhaseIn = pc.inputs().get<
LHCphase*>(
"tofccdbLHCphase");
135 const auto channelCalibIn = pc.inputs().get<
TimeSlewing*>(
"tofccdbChannelCalib");
158 mCalibrator->setCalibTOFapi(mcalibTOFapi);
160 auto data = pc.inputs().get<gsl::span<T>>(
"input");
161 LOG(detail) <<
"Processing TF " << tfcounter <<
" with " <<
data.size() <<
" tracks";
168 mCalibrator->process(
data);
170 sendOutput(pc.outputs());
176 sendOutput(ec.outputs());
180 std::unique_ptr<o2::tof::TOFChannelCalibrator<T>> mCalibrator;
181 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
185 float mRange = 24000.f;
186 bool mUseCCDB =
false;
187 bool mAttachToLHCphase =
false;
188 bool mCosmics =
false;
189 bool mDoPerStrip =
false;
190 bool mSafeMode =
false;
191 bool mUpdateCCDB =
false;
199 const auto& payloadVec = mCalibrator->getTimeSlewingVector();
200 auto& infoVec = mCalibrator->getTimeSlewingInfoVector();
201 assert(payloadVec.size() == infoVec.size());
203 for (uint32_t
i = 0;
i < payloadVec.size();
i++) {
204 auto&
w = infoVec[
i];
206 LOG(info) <<
"Sending object " <<
w.getPath() <<
"/" <<
w.getFileName() <<
" of size " <<
image->size()
207 <<
" bytes, valid for " <<
w.getStartValidityTimestamp() <<
" : " <<
w.getEndValidityTimestamp();
212 if (payloadVec.size()) {
213 mCalibrator->initOutput();
224DataProcessorSpec getTOFChannelCalibDeviceSpec(
bool useCCDB,
bool attachChannelOffsetToLHCphase =
false,
bool isCosmics =
false,
bool perstrip =
false,
bool safe =
false)
229 std::vector<OutputSpec> outputs;
233 std::vector<InputSpec> inputs;
235 inputs.emplace_back(
"input",
"TOF",
"CALIBDATA");
237 inputs.emplace_back(
"input",
"TOF",
"INFOCALCLUS");
239 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(
true,
252 "calib-tofchannel-calibration",
255 AlgorithmSpec{adaptFromTask<device>(ccdbRequest, useCCDB, attachChannelOffsetToLHCphase, isCosmics, perstrip, safe)},
257 {
"min-entries",
VariantType::Int, 500, {
"minimum number of entries to fit channel histos"}},
260 {
"do-TOF-channel-calib-in-test-mode",
VariantType::Bool,
false, {
"to run in test mode for simplification"}},
262 {
"update-at-end-of-run-only",
VariantType::Bool,
false, {
"to update the CCDB only at the end of the run; has priority over calibrating in time slots"}},
263 {
"tf-per-slot",
VariantType::UInt32, 0u, {
"number of TFs per calibration time slot, if 0: close once statistics reached"}},
265 {
"update-interval",
VariantType::UInt32, 10u, {
"number of TF after which to try to finalize calibration"}},
266 {
"delta-update-interval",
VariantType::UInt32, 10u, {
"number of TF after which to try to finalize calibration, if previous attempt failed"}}}};
Class to store the output of the matching to TOF for calibration.
Utils and constants for calibration and related workflows.
Helper for geometry and GRP related CCDB requests.
Definition of the Names Generator class.
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static std::string getCCDBServer()
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(o2::framework::InitContext &ic) final
TOFChannelCalibDevice(std::shared_ptr< o2::base::GRPGeomRequest > req, bool useCCDB, bool attachChannelOffsetToLHCphase, bool isCosmics, bool perstrip=false, bool safe=false)
void run(o2::framework::ProcessingContext &pc) final
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
static constexpr long INFINITE_TIMESTAMP_SECONDS
void setTimeStamp(long t)
GLubyte GLubyte GLubyte GLubyte w
constexpr o2::header::DataOrigin gDataOriginTOF
constexpr TFType INFINITE_TF
constexpr double LHCOrbitMUS
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static void fillTFIDInfo(o2::framework::ProcessingContext &pc, o2::dataformats::TFIDInfo &ti)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"