23#include "TObjString.h"
35 mLoggingInterval = ic.
options().
get<
int>(
"logging-interval") * 1000;
37 mCalibrator = std::make_unique<o2::mch::calibration::BadChannelCalibrator>();
39 mCalibrator->setUpdateAtTheEndOfRunOnly();
40 mCalibrator->setLoggingInterval(mLoggingInterval);
41 mTimeStamp = std::numeric_limits<uint64_t>::max();
50void BadChannelCalibrationDevice::logStats(
size_t dataSize)
52 static auto loggerStart = std::chrono::high_resolution_clock::now();
53 static auto loggerEnd = loggerStart;
54 static size_t nDigits = 0;
55 static size_t nTF = 0;
56 static size_t nTFtot = 0;
57 static size_t nTFtotWithData = 0;
59 if (mLoggingInterval == 0) {
70 loggerEnd = std::chrono::high_resolution_clock::now();
71 std::chrono::duration<double, std::milli> loggerElapsed = loggerEnd - loggerStart;
72 if (loggerElapsed.count() > mLoggingInterval) {
73 LOG(warning) <<
"received " << nDigits <<
" digits in " << nTF <<
" time frames";
74 LOG(warning) <<
"received " << nTFtotWithData <<
" time frames with data out of " << nTFtot <<
" total time frames ("
75 << ((nTFtot > 0) ? (nTFtotWithData * 100.0) / nTFtot : 0.0) <<
"%)";
78 loggerStart = std::chrono::high_resolution_clock::now();
90 mTimeStamp = std::min(mTimeStamp, mCalibrator->getCurrentTFInfo().creation);
91 auto data = pc.
inputs().
get<gsl::span<o2::mch::calibration::PedestalDigit>>(
"digits");
92 mCalibrator->process(
data);
96 if (mCalibrator->readyToSend(reason)) {
97 mHasEnoughStat =
true;
98 LOGP(warning,
"We're ready to send output to CCDB ({})", reason);
99 sendOutput(pc.
outputs(), reason);
111 std::map<std::string, std::string> md;
112 md[
"upload-reason"] = reason;
121 if (mCalibrator->readyToSend(reason)) {
122 mHasEnoughStat =
true;
124 sendOutput(ec.
outputs(),
"End Of Stream");
130 std::stringstream csv;
131 csv << fmt::format(
"solarid,dsid,ch\n");
134 csv << fmt::format(
"{},{},{}\n",
135 c.getSolarId(),
c.getElinkId(),
c.getChannel());
151 LOG(warning) <<
"Sending object " << payloadInfo->
getPath()
154 <<
" of size " <<
image->size()
163 std::string_view reason)
165 auto& slot = mCalibrator->getFirstSlot();
166 const auto pedData = slot.getContainer();
167 uint64_t nentries = std::accumulate(pedData->cbegin(), pedData->cend(),
169 [&](uint64_t
n,
const PedestalChannel&
c) { return n +
170 static_cast<uint64_t>(c.mEntries); });
171 std::string reason_with_entries;
173 if (pedData->size() > 0) {
174 int mean =
static_cast<int>(std::round(
static_cast<float>(nentries) / pedData->size()));
175 reason_with_entries = fmt::format(
"{} ; <entries per channel>={}", reason, mean);
177 reason_with_entries = fmt::format(
"{} ; no entries", reason);
180 LOGP(warning,
"sendOutput: {}", reason_with_entries);
181 mCalibrator->finalize();
184 if (mHasEnoughStat) {
187 const auto& badChannels = mCalibrator->getBadChannelsVector();
188 auto info =
createCcdbInfo(badChannels, mTimeStamp, reason_with_entries);
197 TObjString badChannelsPOD(
toCSV(badChannels).c_str());
198 auto infoPOD =
createCcdbInfo(badChannelsPOD, mTimeStamp, reason_with_entries);
202 LOGP(info,
"csv={}", badChannelsPOD.String().Data());
204 LOGP(
error,
"CCDB not updated: {}", reason_with_entries);
211 mCalibrator->getPedestalsVector());
212 if (mHasEnoughStat) {
214 mCalibrator->getBadChannelsVector());
Utils and constants for calibration and related workflows.
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
char error[CURL_ERROR_SIZE]
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 generateFileName(const std::string &inp)
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
long getEndValidityTimestamp() const
const std::string & getPath() const
static constexpr long DAY
const std::string & getObjectType() const
long getStartValidityTimestamp() const
const std::string & getFileName() const
static const BadChannelCalibratorParam & Instance()
T get(const char *key) const
DataAllocator & outputs()
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
void logStats(size_t dataSize)
constexpr TFType INFINITE_TF
std::string toCSV(const std::vector< o2::mch::DsChannelId > &channels)
ccdb::CcdbObjectInfo createCcdbInfo(const T &object, uint64_t timeStamp, std::string_view reason)
void sendCalibrationOutput(o2::framework::DataAllocator &output, header::DataHeader::SubSpecificationType subSpec, T *payload, o2::ccdb::CcdbObjectInfo *payloadInfo)
static void fillTFIDInfo(o2::framework::ProcessingContext &pc, o2::dataformats::TFIDInfo &ti)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
static std::string getClassName(const T &obj)
get the class name of the object
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< ChannelData > channels