12#ifndef O2_CALIBRATION_LHCCLOCK_CALIBRATOR_H
13#define O2_CALIBRATION_LHCCLOCK_CALIBRATOR_H
47 LHCClockCalibDevice(std::shared_ptr<o2::base::GRPGeomRequest> req,
bool useCCDB) : mCCDBRequest(req), mUseCCDB(useCCDB) {}
52 int minEnt = std::max(300, ic.options().get<
int>(
"min-entries"));
53 int nb = std::max(500, ic.options().get<
int>(
"nbins"));
54 auto slotL = ic.options().get<uint32_t>(
"tf-per-slot");
55 auto delay = ic.options().get<uint32_t>(
"max-delay");
56 mCalibrator = std::make_unique<o2::tof::LHCClockCalibrator>(minEnt, nb);
57 mCalibrator->setSlotLength(slotL);
58 mCalibrator->setMaxSlotsDelay(delay);
64 if (gSystem->AccessPathName(
"localTimeSlewing.root") ==
false) {
65 TFile* fsleewing = TFile::Open(
"localTimeSlewing.root");
84 LOG(
debug) <<
"We are running LHCPhase";
86 auto data = pc.inputs().get<gsl::span<o2::dataformats::CalibInfoTOF>>(
"input");
90 const auto lhcPhaseIn = pc.inputs().get<
LHCphase*>(
"tofccdbLHCphase");
91 const auto channelCalibIn = pc.inputs().get<
TimeSlewing*>(
"tofccdbChannelCalib");
113 mCalibrator->setCalibTOFapi(mcalibTOFapi);
115 if (
data.size() == 0) {
124 LOG(
debug) <<
"Processing TF " << mCalibrator->getCurrentTFInfo().tfCounter <<
" with " <<
data.size() <<
" tracks";
125 mCalibrator->process(
data);
126 sendOutput(pc.outputs());
127 const auto& infoVec = mCalibrator->getLHCphaseInfoVector();
128 LOG(info) <<
"Processed TF " << mCalibrator->getCurrentTFInfo().tfCounter <<
" with " <<
data.size() <<
" tracks, for which we created " << infoVec.size() <<
" objects";
147 LOG(info) <<
"Finalizing calibration";
149 sendOutput(ec.outputs());
156 std::unique_ptr<o2::tof::LHCClockCalibrator> mCalibrator;
157 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
158 bool mUpdateCCDB =
false;
159 bool mUseCCDB =
true;
167 const auto& payloadVec = mCalibrator->getLHCphaseVector();
168 auto& infoVec = mCalibrator->getLHCphaseInfoVector();
169 assert(payloadVec.size() == infoVec.size());
171 for (uint32_t
i = 0;
i < payloadVec.size();
i++) {
172 auto&
w = infoVec[
i];
174 LOG(info) <<
"Sending object " <<
w.getPath() <<
"/" <<
w.getFileName() <<
" of size " <<
image->size()
175 <<
" bytes, valid for " <<
w.getStartValidityTimestamp() <<
" : " <<
w.getEndValidityTimestamp();
179 if (payloadVec.size()) {
180 mCalibrator->initOutput();
194 std::vector<InputSpec> inputs{{
"input",
"TOF",
"CALIBDATA"}};
195 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(
true,
204 inputs.emplace_back(
"tofccdbLHCphase",
"TOF",
"LHCphaseCal", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/LHCphase"));
205 inputs.emplace_back(
"tofccdbChannelCalib",
"TOF",
"ChannelCalibCal", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/ChannelCalib"));
209 std::vector<OutputSpec> outputs;
213 "calib-lhcclock-calibration",
220 {
"min-entries",
VariantType::Int, 500, {
"minimum number of entries to fit single time slot"}},
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.
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
LHCClockCalibDevice(std::shared_ptr< o2::base::GRPGeomRequest > req, bool useCCDB)
void init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) 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 gDataOriginCTP
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"