15#include <TDirectory.h>
27 double mean = 0, var = 0;
28 if (
getStat(is, en, mean, var) == 0) {
29 LOGF(info,
"Noise %2d %s with %10llu events %smean %8.1f rms %8.1f (ch) max=%d", is,
ChannelNames[is].
data(), en,
mHisto[is].
mOverflow ?
" IN_OVERFLOW" :
"",
39 if (
other.mOverflow) {
41 LOG(warn) <<
"NoiseCalibData" << __func__ <<
" Refusing to add an overflow. BREAK!";
44 for (int32_t is = 0; is <
NChannels; is++) {
45 if (
other.mHisto[is].mOverflow) {
47 LOG(warn) <<
"NoiseCalibData::" << __func__ <<
" Refusing to add an overflow histogram for ch " << is <<
" BREAK!";
53 uint32_t maxo =
other.mHisto[is].getMaxBin();
54 auto max = std::min(maxc, maxo) + 1;
55 for (int32_t
i = 0;
i <
max;
i++) {
57 auto poth =
other.mHisto[is].mData.find(
i);
58 if (pcur !=
mHisto[is].mData.end() && poth !=
other.mHisto[is].
mData.end()) {
59 uint64_t
sum = pcur->first + pcur->second;
60 if (
sum > 0xffffffff) {
61 LOG(warn) <<
"NoiseCalibData::" << __func__ <<
" Addition would result in an overflow for ch " << is <<
" BREAK!";
68 for (int32_t is = 0; is <
NChannels; is++) {
80 LOG(info) << __func__;
92 for (int32_t is = 0; is <
NChannels; is++) {
98 LOG(warn) <<
"Overflow bit set on signal " << is;
112 LOG(error) <<
"NoiseCalibData::operator+=(const NoiseCalibSummaryData* s): null pointer";
117 LOG(warn) << __func__ <<
" Refusing to add an overflow NoiseCalibSummaryData BREAK!";
121 for (int32_t is = 0; is <
NChannels; is++) {
122 if (s->mOverflowCh[is]) {
124 LOG(warn) << __func__ <<
" Refusing to add an overflow histogram for ch " << is <<
" BREAK!";
130 for (
auto& bin : s->mData) {
132 if (
sum > 0xffffffff) {
133 LOG(warn) << __func__ <<
" Addition would result in an overflow for ch " << bin.id() <<
" BREAK!";
143 for (
auto& bin : s->mData) {
159 LOGF(info,
"NoiseCalibData::setCreationTime %llu", ctime);
169 LOGF(info,
"NoiseCalibData::setCreationTime %llu", ctime);
177 LOGF(error,
"NoiseCalibData::getEntries channel index %d is out of range", is);
195 LOGF(error,
"NoiseCalibData::getMaxBin channel index %d is out of range", is);
216 LOGF(error,
"NoiseCalibData::getStat channel index %d is out of range", is);
233 mean = double(
sum) / double(en);
237 double diff =
key - mean;
238 sums = sums + (
value * diff * diff);
240 var = sums / (en - 1);
252 TDirectory* cwd = gDirectory;
253 TFile*
f =
new TFile(fn.data(),
"recreate");
255 LOG(error) <<
"Cannot create file: " << fn;
259 for (int32_t is = 0; is <
NChannels; is++) {
263 TString
n = TString::Format(
"h%d", is);
264 TString t = TString::Format(
"%sNoise %d %s", is_epn ?
"EPN " :
"", is,
ChannelNames[is].data());
265 TH1F
h(
n, t,
max + 1, -0.5 * factor, (
max + 0.5) * factor);
266 for (
int ibx = 0; ibx <
max; ibx++) {
267 h.SetBinContent(ibx + 1,
mHisto[is].mData[ibx] * factor);
270 h.Write(
"", TObject::kOverwrite);
285 for (int32_t is = 0; is <
NChannels; is++) {
312 for (int32_t is = 0; is <
NChannels; is++) {
329 for (
int ich = 0; ich <
NChannels; ich++) {
338 for (
auto& bin :
mData) {
339 nbin[bin.id()] = nbin[bin.id()] + 1;
340 ccont[bin.id()] = ccont[bin.id()] + bin.cont;
342 for (int32_t is = 0; is <
NChannels; is++) {
343 LOG(info) <<
"Summary ch " << is <<
" nbin = " << nbin[is] <<
" ccont = " << ccont[is];
Format of noise calibration intermediate data.
Class for time synchronization of RawReader instances.
float sum(float s, o2::dcs::DataPointValue v)
GLsizei const GLfloat * value
constexpr int NTimeBinsPerBC
constexpr std::string_view ChannelNames[]
uint64_t getEntries() const
Overflow flag (cannot accept more data)
int getStat(uint64_t &en, double &mean, double &var) const
uint32_t getMaxBin() const
std::map< uint32_t, uint32_t > mData
bool mOverflow
Map histogram container.
NoiseCalibSummaryData & getSummary()
int saveDebugHistos(const std::string fn, bool is_epn=false)
NoiseCalibChData mHisto[NChannels]
Overflow at least one ZDC channel.
NoiseCalibData & operator=(const NoiseCalibSummaryData &s)
uint32_t getMaxBin(int is) const
void mergeCreationTime(uint64_t ctime)
uint64_t mCTimeEnd
Time of processed time frame.
NoiseCalibData & operator+=(const NoiseCalibData &other)
Serialized data to be dispatched.
int getStat(int is, uint64_t &en, double &mean, double &var) const
NoiseCalibSummaryData mSummary
Sparse histogram of single channels.
bool mOverflow
Time of processed time frame.
uint64_t getEntries(int is) const
void setCreationTime(uint64_t ctime)
bool mOverflow
Time of processed time frame.
uint64_t mCTimeEnd
Time of processed time frame.
void clear()
Data of not empty bins.
std::vector< NoiseCalibBinData > mData
Channel overflow information.
std::array< bool, NChannels > mOverflowCh
Overflow of one channel.
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"