41 auto slotL = ic.options().get<uint32_t>(
"tf-per-slot");
42 auto delay = ic.options().get<uint32_t>(
"max-delay");
43 auto updateInterval = ic.options().get<uint32_t>(
"updateInterval");
44 bool updateAtTheEndOfRunOnly = ic.options().get<
bool>(
"updateAtTheEndOfRunOnly");
45 mCalibrator = std::make_unique<o2::cpv::NoiseCalibrator>();
46 mCalibrator->setSlotLength(slotL);
47 mCalibrator->setMaxSlotsDelay(delay);
48 if (updateAtTheEndOfRunOnly) {
49 mCalibrator->setUpdateAtTheEndOfRunOnly();
51 mCalibrator->setCheckIntervalInfiniteSlot(updateInterval);
52 LOG(info) <<
"CPVNoiseCalibratorSpec initialized";
53 LOG(info) <<
"tf-per-slot = " << slotL;
54 LOG(info) <<
"max-delay = " << delay;
55 LOG(info) <<
"updateInterval = " << updateInterval;
56 LOG(info) <<
"updateAtTheEndOfRunOnly = " << updateAtTheEndOfRunOnly;
63 LOG(info) <<
"NoiseCalibratorSpec::finaliseCCDB() : accessing CPV/PedestalRun/ChannelEfficiencies";
64 auto pedEffs =
static_cast<std::vector<float>*
>(obj);
65 mCalibrator->setPedEfficiencies(pedEffs);
66 LOG(info) <<
"NoiseCalibratorSpec::finaliseCCDB() : I got pedestal efficiencies vetor of size " << pedEffs->size();
70 LOG(info) <<
"NoiseCalibratorSpec::finaliseCCDB() : accessing CPV/PedestalRun/DeadChannels";
71 auto deadChs =
static_cast<std::vector<int>*
>(obj);
72 mCalibrator->setDeadChannels(deadChs);
73 LOG(info) <<
"NoiseCalibratorSpec::finaliseCCDB() : I got dead channels vetor of size " << deadChs->size();
77 LOG(info) <<
"NoiseCalibratorSpec::finaliseCCDB() : accessing CPV/PedestalRun/HighPedChannels";
78 auto highPeds =
static_cast<std::vector<int>*
>(obj);
79 mCalibrator->setHighPedChannels(highPeds);
80 LOG(info) <<
"NoiseCalibratorSpec::finaliseCCDB() : I got high pedestals vetor of size " << highPeds->size();
84 LOG(info) <<
"NoiseCalibratorSpec::finaliseCCDB() : accessing CPV/Config/PersistentBadChannels";
85 auto persBadChs =
static_cast<std::vector<int>*
>(obj);
86 mCalibrator->setPersistentBadChannels(persBadChs);
87 LOG(info) <<
"NoiseCalibratorSpec::finaliseCCDB() : I got persistent bad channels vector of size " << persBadChs->size();
97 TFType tfcounter = mCalibrator->getCurrentTFInfo().startTime;
100 static bool isConfigFetched =
false;
101 if (!isConfigFetched) {
102 pc.inputs().get<std::vector<float>*>(
"pedeffs");
103 pc.inputs().get<std::vector<int>*>(
"persbadchs");
104 pc.inputs().get<std::vector<int>*>(
"deadchs");
105 pc.inputs().get<std::vector<int>*>(
"highpeds");
107 LOG(info) <<
"NoiseCalibratorSpec::run() : fetching o2::cpv::CPVCalibParams from CCDB";
109 LOG(info) <<
"NoiseCalibratorSpec::run() : o2::cpv::CPVCalibParams::Instance() now is following:";
111 mCalibrator->configParameters();
112 isConfigFetched =
true;
116 auto&&
digits = pc.inputs().get<gsl::span<o2::cpv::Digit>>(
"digits");
117 auto&& trigrecs = pc.inputs().get<gsl::span<o2::cpv::TriggerRecord>>(
"trigrecs");
119 LOG(detail) <<
"Processing TF " << tfcounter <<
" with " <<
digits.size() <<
" digits in " << trigrecs.size() <<
" trigger records.";
120 auto& slotTF = mCalibrator->getSlotForTF(tfcounter);
122 for (
auto trigrec = trigrecs.begin(); trigrec != trigrecs.end(); trigrec++) {
125 auto&& digitsInOneEvent =
digits.subspan((*trigrec).getFirstEntry(), (*trigrec).getNumberOfObjects());
126 if ((trigrec + 1) == trigrecs.end()) {
128 mCalibrator->process(digitsInOneEvent);
130 slotTF.getContainer()->fill(digitsInOneEvent);
134 auto infoVecSize = mCalibrator->getCcdbInfoBadChannelMapVector().size();
135 auto badMapVecSize = mCalibrator->getBadChannelMapVector().size();
136 if (infoVecSize > 0) {
137 LOG(detail) <<
"Created " << infoVecSize <<
" ccdb infos and " << badMapVecSize <<
" BadChannelMap objects for TF " << tfcounter;
139 sendOutput(pc.outputs());
143 std::unique_ptr<o2::cpv::NoiseCalibrator> mCalibrator;
144 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
153 const auto& payloadVec = mCalibrator->getBadChannelMapVector();
154 auto&& infoVec = mCalibrator->getCcdbInfoBadChannelMapVector();
156 assert(payloadVec.size() == infoVec.size());
157 if (payloadVec.size() == 0) {
161 for (uint32_t
i = 0;
i < payloadVec.size();
i++) {
162 auto&
w = infoVec[
i];
164 LOG(info) <<
"Sending object " <<
w.getPath() <<
"/" <<
w.getFileName() <<
" of size " <<
image->size()
165 <<
" bytes, valid for " <<
w.getStartValidityTimestamp() <<
" : " <<
w.getEndValidityTimestamp();
169 mCalibrator->initOutput();
180 std::vector<InputSpec> inputs;
181 inputs.emplace_back(
"digits",
"CPV",
"DIGITS", 0, Lifetime::Timeframe);
182 inputs.emplace_back(
"trigrecs",
"CPV",
"DIGITTRIGREC", 0, Lifetime::Timeframe);
183 inputs.emplace_back(
"pedeffs",
"CPV",
"CPV_PedEffs", 0, Lifetime::Condition,
ccdbParamSpec(
"CPV/PedestalRun/ChannelEfficiencies"));
184 inputs.emplace_back(
"deadchs",
"CPV",
"CPV_DeadChnls", 0, Lifetime::Condition,
ccdbParamSpec(
"CPV/PedestalRun/DeadChannels"));
185 inputs.emplace_back(
"highpeds",
"CPV",
"CPV_HighThrs", 0, Lifetime::Condition,
ccdbParamSpec(
"CPV/PedestalRun/HighPedChannels"));
186 inputs.emplace_back(
"calibparams",
"CPV",
"CPV_CalibPars", 0, Lifetime::Condition,
ccdbParamSpec(
"CPV/Config/CPVCalibParams"));
187 inputs.emplace_back(
"persbadchs",
"CPV",
"CPV_PersiBads", 0, Lifetime::Condition,
ccdbParamSpec(
"CPV/Config/PersistentBadChannels"));
189 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(
true,
196 std::vector<OutputSpec> outputs;
202 "cpv-noise-calibration",
209 {
"updateAtTheEndOfRunOnly",
VariantType::Bool,
false, {
"finalize the slots and prepare the CCDB entries only at the end of the run."}},
210 {
"updateInterval",
VariantType::UInt32, 10u, {
"try to finalize the slot (and produce calibration) when the updateInterval has passed.\n To be used together with tf-per-slot = 0"}}}};
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 run(o2::framework::ProcessingContext &pc) final
CPVNoiseCalibratorSpec(std::shared_ptr< o2::base::GRPGeomRequest > req)
void init(o2::framework::InitContext &ic) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
void printKeyValues(bool showProv=true, bool useLogger=false) const final
static const CPVCalibParams & Instance()
GLubyte GLubyte GLubyte GLubyte w
constexpr TFType INFINITE_TF
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"
std::vector< Digit > digits