59 if (mRunStartTime == 0) {
61 mValidityTime = mRunStartTime + 31622400000;
72 LOG(detail) <<
"[PHOSBadMapCalibDevice - run] Received " <<
cells.size() <<
" cells, running calibration ...";
73 for (
const auto&
c :
cells) {
74 float e =
c.getEnergy();
75 if (e > mElowMin && e < mElowMax) {
76 mMeanLow->Fill(
c.getAbsId() - 1792);
78 if (e > mEhighMin && e < mEhighMax) {
79 mMeanHigh->Fill(
c.getAbsId() - 1792);
80 mMeanTime->Fill(
c.getAbsId() - 1792,
c.getTime());
86 auto chi2list = ctx.
inputs().
get<gsl::span<short>>(
"fitqa");
87 LOG(info) <<
"[PHOSBadMapCalibDevice - run] Received " << chi2list.size() <<
" Chi2, running calibration ...";
88 auto b = chi2list.begin();
89 while (
b != chi2list.end()) {
94 mChi2norm->Fill(absId - 1792);
95 mChi2->Fill(absId - 1792,
c);
100 if (mStatistics <= 0) {
103 if (mStatistics % 100 == 0) {
104 LOG(info) << mStatistics <<
" left to produce pedestal BadMap";
107 auto cells = ctx.
inputs().
get<gsl::span<o2::phos::Cell>>(
"cells");
108 LOG(
debug) <<
"[PHOSBadMapCalibDevice - run] Received " <<
cells.size() <<
" cells, running calibration ...";
109 for (
const auto&
c :
cells) {
110 if (
c.getHighGain()) {
111 mHGMean->Fill(
c.getAbsId() - 1792,
c.getEnergy());
112 mHGRMS->Fill(
c.getAbsId() - 1792, 1.e+7 *
c.getTime());
113 mHGNorm->Fill(
c.getAbsId() - 1792, 1.);
115 mLGMean->Fill(
c.getAbsId() - 1792);
116 mLGRMS->Fill(
c.getAbsId() - 1792, 1.e+7 *
c.getTime());
117 mLGNorm->Fill(
c.getAbsId() - 1792, 1.);
121 if (mStatistics <= 0) {
122 LOG(info) <<
"Start calculating bad map";
185 mBadMap = std::make_unique<BadChannelsMap>();
192 if (mMeanLow->Integral() < 1.e+4) {
193 LOG(error) <<
"Insufficient statistics: " << mMeanLow->Integral() <<
" entries in lowE histo, do nothing";
199 float nMinLow = std::max(
float(0.), nMean - 6 * nRMS);
200 float nMaxLow = nMean + 6 * nRMS;
201 LOG(info) <<
"Limits for low E histo: " << nMinLow <<
"<n<" << nMaxLow;
202 for (
int i = 1;
i <= mMeanLow->GetNbinsX();
i++) {
203 int c = mMeanLow->GetBinContent(
i);
204 if (c < nMinLow || c > nMaxLow) {
205 mBadMap->addBadChannel(
i + 1792);
209 float nMinHigh = std::max(
float(0.), nMean - 6 * nRMS);
210 float nMaxHigh = nMean + 6 * nRMS;
211 LOG(info) <<
"Limits for high E histo: " << nMinHigh <<
"<n<" << nMaxHigh;
212 for (
int i = 1;
i <= mMeanHigh->GetNbinsX();
i++) {
213 int c = mMeanHigh->GetBinContent(
i);
214 if (c < nMinHigh || c > nMaxHigh) {
215 mBadMap->addBadChannel(
i + 1792);
221 if (mChi2norm->Integral() < 1.e+4) {
222 LOG(important) <<
"Insufficient statistics: " << mChi2norm->Integral() <<
" entries in chi2Norm histo, do nothing";
225 mChi2->Divide(mChi2norm.get());
228 float nMinHigh = std::max(
float(0.), nMean - 6 * nRMS);
229 float nMaxHigh = nMean + 6 * nRMS;
230 for (
int i = 1;
i <= mChi2->GetNbinsX();
i++) {
231 int c = mChi2->GetBinContent(
i);
232 if (c < nMinHigh || c > nMaxHigh) {
233 mBadMap->addBadChannel(
i + 1792);
239 if (mHGNorm->Integral() < 2.e+4) {
240 LOG(important) <<
"Insufficient statistics: " << mHGNorm->Integral() <<
" entries in mHGNorm histo, do nothing";
244 mHGMean->Divide(mHGNorm.get());
246 float nMinHigh = std::max(
float(0.), nMean - 6 * nRMS);
247 float nMaxHigh = nMean + 6 * nRMS;
248 LOG(info) <<
"Limits for HG mean: " << nMinHigh <<
" < meanHG < " << nMaxHigh;
250 for (
int i = 1;
i <= mHGMean->GetNbinsX();
i++) {
251 int c = mHGMean->GetBinContent(
i);
252 if (c < nMinHigh || c > nMaxHigh) {
253 mBadMap->addBadChannel(
i + 1792);
257 LOG(info) <<
"HG mean: removed " << nBad <<
" channels";
258 mLGMean->Divide(mLGNorm.get());
260 nMinHigh = std::max(
float(0.), nMean - 6 * nRMS);
261 nMaxHigh = nMean + 6 * nRMS;
262 LOG(info) <<
"Limits for LG mean: " << nMinHigh <<
" < meanHG < " << nMaxHigh;
264 for (
int i = 1;
i <= mLGMean->GetNbinsX();
i++) {
265 int c = mLGMean->GetBinContent(
i);
266 if (c < nMinHigh || c > nMaxHigh) {
267 mBadMap->addBadChannel(
i + 1792);
271 LOG(info) <<
" LG mean: removed " << nBad <<
" channels";
272 mHGRMS->Divide(mHGNorm.get());
274 nMinHigh = std::max(
float(0.), nMean - 6 * nRMS);
275 nMaxHigh = nMean + 6 * nRMS;
276 LOG(info) <<
"Limits for HG RMS: " << nMinHigh <<
" < HG rms < " << nMaxHigh;
278 for (
int i = 1;
i <= mHGRMS->GetNbinsX();
i++) {
279 int c = mHGRMS->GetBinContent(
i);
280 if (c < nMinHigh || c > nMaxHigh) {
281 mBadMap->addBadChannel(
i + 1792);
285 LOG(info) <<
" HG RMS: removed " << nBad <<
" channels";
286 mLGRMS->Divide(mHGNorm.get());
288 nMinHigh = std::max(
float(0.), nMean - 6 * nRMS);
289 nMaxHigh = nMean + 6 * nRMS;
290 LOG(info) <<
"Limits for LG RMS: " << nMinHigh <<
" < LG rms < " << nMaxHigh;
292 for (
int i = 1;
i <= mLGRMS->GetNbinsX();
i++) {
293 int c = mLGRMS->GetBinContent(
i);
294 if (c < nMinHigh || c > nMaxHigh) {
295 mBadMap->addBadChannel(
i + 1792);
299 LOG(info) <<
" LG RMS: removed " << nBad <<
" channels";
312 std::map<short, int> histo{};
313 for (
int i = 1;
i <= tmp->GetNbinsX();
i++) {
314 int c = tmp->GetBinContent(
i);
316 histo[
c] = histo[
c] + 1;
319 float mean = 0, rms = 0, nTot = 0, maxN = 0.;
320 for (
const auto& [
n, nCells] : histo) {
322 rms +=
n *
n * nCells;
328 const float eps = 0.05;
330 for (std::map<short, int>::reverse_iterator iter = histo.rbegin(); iter != histo.rend(); ++iter) {
331 float nextMean = mean - iter->first * iter->second;
332 float nextRMS = rms - iter->first * iter->first * iter->second;
333 float nextTot = nTot - iter->second;
334 if (nTot == 0. || nextTot == 0.) {
337 if (mean / nTot - nextMean / nextTot > eps * mean / nTot) {
346 for (std::map<short, int>::iterator iter = histo.begin(); iter != histo.end(); ++iter) {
347 float nextMean = mean - iter->first * iter->second;
348 float nextRMS = rms - iter->first * iter->first * iter->second;
349 float nextTot = nTot - iter->second;
350 if (nTot == 0. || nextTot == 0.) {
353 if (mean / nTot - nextMean / nextTot > eps * mean / nTot) {
365 nRMS = rms - nMean * nMean;
404 std::vector<InputSpec> inputs;
419 std::vector<OutputSpec> outputs;
426 o2::framework::adaptFromTask<PHOSBadMapCalibDevice>(
mode),
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.
ServiceRegistryRef services()
The services registry associated with this processing context.