67bool BadChannelCalibrator::hasEnoughData(
const Slot& slot)
const
69 static auto loggerStart = std::chrono::high_resolution_clock::now();
70 static auto loggerEnd = loggerStart;
73 auto nofChannels = pedData->
size();
76 auto nofCalibrated = std::count_if(pedData->
cbegin(), pedData->
cend(),
79 bool hasEnough = nofCalibrated > requiredChannels;
82 loggerEnd = std::chrono::high_resolution_clock::now();
83 std::chrono::duration<double, std::milli> loggerElapsed = loggerEnd - loggerStart;
84 if (mLoggingInterval > 0 && loggerElapsed.count() > mLoggingInterval) {
85 int minEntriesPerChannel{std::numeric_limits<int>::max()};
86 int maxEntriesPerChannel{0};
87 uint64_t averageEntriesPerChannel = 0;
88 std::for_each(pedData->
cbegin(), pedData->
cend(),
90 if (c.mEntries == 0) {
93 if (
c.mEntries > maxEntriesPerChannel) {
94 maxEntriesPerChannel = c.mEntries;
96 if (
c.mEntries < minEntriesPerChannel) {
97 minEntriesPerChannel = c.mEntries;
99 averageEntriesPerChannel +=
c.mEntries;
101 if (nofChannels > 0) {
102 averageEntriesPerChannel /= nofChannels;
104 LOGP(warning,
"channel stats: min={} max={} average={}", minEntriesPerChannel, maxEntriesPerChannel, averageEntriesPerChannel);
106 "nofChannelWithEnoughStat(>{})={} nofChannels={} requiredChannels={} hasEnough={}",
107 minNofEntries, nofCalibrated, nofChannels, requiredChannels, hasEnough);
108 loggerStart = std::chrono::high_resolution_clock::now();
114void BadChannelCalibrator::finalizeSlot(
Slot& slot)
117 auto pedestalThreshold = BadChannelCalibratorParam::Instance().maxPed;
118 auto noiseThreshold = BadChannelCalibratorParam::Instance().maxNoise;
120 mPedestalsVector.clear();
121 mBadChannelsVector.clear();
131 for (
const auto& ped : *pedestalData) {
132 if (ped.mEntries == 0) {
135 mPedestalsVector.emplace_back(ped);
137 if (ped.mPedestal < pedestalThreshold) {
138 if (ped.getRms() < noiseThreshold) {
144 mBadChannelsVector.emplace_back(ped.dsChannelId);
150 BadChannelCalibrator::emplaceNewSlot(
bool front, TFType tstart, TFType tend)
152 const int nThreads =
static_cast<int>(BadChannelCalibratorParam::Instance().nThreads);
153 auto& cont = getSlots();
154 auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend);
155 slot.setContainer(std::make_unique<PedestalData>());
156 slot.getContainer()->setNThreads(nThreads);