9#include <top/calibration/TOPChannelMaskAlgorithm.h>
10#include <framework/logging/Logger.h>
31 setDescription(
"Calibration algorithm for masking of dead and hot channels");
40 auto nhits = getObjectPtr<TH1F>(
"nhits");
42 double averageChannelHits = nhits->GetEntries() * nhits->GetMean() / 16 / 512;
43 B2INFO(
"Average number of good hits per channel: " << averageChannelHits);
49 string expNo = to_string(expRun[0].first);
50 while (expNo.length() < 4) expNo.insert(0,
"0");
51 string runNo = to_string(expRun[0].second);
52 while (runNo.length() < 5) runNo.insert(0,
"0");
53 string outputFileName =
"channelMask-e" + expNo +
"-r" + runNo +
".root";
54 m_file = TFile::Open(outputFileName.c_str(),
"recreate");
64 auto meanHits =
new TH1F(
"meanHits",
"Average number of hits per channel; slot number; average", 16, 0.5, 16.5);
65 auto rmsHits =
new TH1F(
"rmsHits",
"r.m.s of number of hits per channel; slot number; r.m.s", 16, 0.5, 16.5);
66 for (
int slot = 1; slot <= 16; slot++) {
67 string name =
"hits_" + to_string(slot);
68 auto h = getObjectPtr<TH1F>(name);
73 double rms = h->GetMaximum();
74 for (
int iter = 0; iter < 5; iter++) {
78 for (
int chan = 0; chan < h->GetNbinsX(); chan++) {
79 double y = h->GetBinContent(chan + 1);
80 if (y == 0 or fabs(y - mean) > 3 * rms)
continue;
87 rms =
sqrt(sumyy / n - mean * mean);
89 meanHits->SetBinContent(slot, mean);
90 rmsHits->SetBinContent(slot, rms);
91 double deadCut = mean / 5;
92 double hotCut = std::max(mean * 2, mean + 6 * rms);
94 for (
int chan = 0; chan < h->GetNbinsX(); chan++) {
95 double y = h->GetBinContent(chan + 1);
98 }
else if (y > hotCut) {
106 for (
int slot = 1; slot <= 16; slot++) {
107 string name =
"window_vs_asic_" + to_string(slot);
108 auto h = getObjectPtr<TH2F>(name);
111 auto h0 = h->ProjectionX();
113 for (
int asic = 0; asic < h->GetNbinsX(); asic++) {
114 double r = 1 - h1->GetBinContent(asic + 1) / h0->GetBinContent(asic + 1);
125 auto dead =
new TH1F(
"numDead",
"Number of dead channels; slot number; dead channels", 16, 0.5, 16.5);
126 auto hot =
new TH1F(
"numHot",
"Number of noisy channels; slot number; noisy channels", 16, 0.5, 16.5);
127 auto active =
new TH1F(
"activeFract",
"Fraction of active channels; slot number; active fraction", 16, 0.5, 16.5);
128 for (
int slot = 1; slot <= 16; slot++) {
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
const std::vector< Calibration::ExpRun > & getRunList() const
Get the list of runs for which calibration is called.
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
Channel status for all 512 channels of 16 modules.
int getNumOfDeadChannels() const
Returns number of dead channels.
int getNumOfNoisyChannels() const
Returns number of noisy channels.
double getActiveFraction() const
Returns fraction of active channels.
double m_minHits
minimal number of hits per channel needed for calibration
virtual EResult calibrate() final
algorithm implementation
int m_maxWindow
band upper limit in window_vs_asic
TOPChannelMaskAlgorithm()
Constructor.
TOPCalChannelMask * m_channelMask
masks of dead and hot channels
int m_minWindow
band lower limit in window_vs_asic
double sqrt(double a)
sqrt for double
void setNoisy(int moduleID, unsigned channel)
Sets a specific channel as noisy.
void setDead(int moduleID, unsigned channel)
Sets a specific channel as dead.
Abstract base class for different kinds of events.