Belle II Software  release-05-01-25
ARICHChannelMaskMaker.cc
1 #include <arich/calibration/ARICHChannelMaskMaker.h>
2 #include <arich/dbobjects/ARICHChannelMask.h>
3 #include <TH2F.h>
4 
5 using namespace Belle2;
6 
8 {
10  " --------------------- ARICHChannelMask Calibration Algoritm ------------------\n"
11  " \n"
12  " Produces channel mask for arich hot/dead channels, based on criteria of \n"
13  " minimal and maximal occupancy \n"
14  " ------------------------------------------------------------------------------\n"
15  );
16 }
17 
19 {
20 
21  auto hist = getObjectPtr<TH2F>("ch_occupancy");
22  if (!hist) return c_Failure;
23 
24  B2INFO("Number of Entries in ARICH ch_occupancy histogram was " << hist->GetEntries());
25 
26  const int NumberOfChannelsPerHapd = 144;
27  int numChannels = hist->GetNbinsX();
28 
29  int nevt = hist->GetBinContent(numChannels, 1);
30 
31  auto* mask = new ARICHChannelMask();
32 
33  double ringChnAvg[7] = {0.};
34  double ringChnAvgS2N[7] = {0.};
35  int hapdInRing[7] = {42, 48, 54, 60, 66, 72, 78};
36 
37  for (int bin = 1; bin < numChannels; ++bin) {
38  int moduleID = (bin - 1) / NumberOfChannelsPerHapd + 1;
39  double nsig = hist->GetBinContent(bin, 2) + hist->GetBinContent(bin, 3) - hist->GetBinContent(bin, 1) - hist->GetBinContent(bin, 4);
40  double s2n = nsig / (hist->GetBinContent(bin, 2) + hist->GetBinContent(bin, 3));
41  int ring = getRing(moduleID);
42  if (nsig / float(nevt) > 0.02) continue; // skip channels with anomalously high occupancy
43  ringChnAvg[ring] += nsig;
44  ringChnAvgS2N[ring] += s2n;
45  }
46 
47  for (int i = 0; i < 7; i++) {
48  ringChnAvg[i] /= float(hapdInRing[i] * NumberOfChannelsPerHapd);
49  ringChnAvgS2N[i] /= float(hapdInRing[i] * NumberOfChannelsPerHapd);
50  }
51  B2INFO("Average hits in channel in outter HAPD ring is " << ringChnAvg[6] << " (which is less that minimaly required, " <<
52  m_minHitPerChn << ")");
53  if (ringChnAvg[6] < m_minHitPerChn) return c_NotEnoughData;
54 
55  for (int bin = 1; bin < numChannels; ++bin) {
56  int moduleID = (bin - 1) / NumberOfChannelsPerHapd + 1;
57  int channelID = (bin - 1) % NumberOfChannelsPerHapd;
58  double nsig = hist->GetBinContent(bin, 2) + hist->GetBinContent(bin, 3) - hist->GetBinContent(bin, 1) - hist->GetBinContent(bin, 4);
59  double s2n = nsig / (hist->GetBinContent(bin, 2) + hist->GetBinContent(bin, 3));
60  int ring = getRing(moduleID);
61  bool value = true;
62  if (nsig < ringChnAvg[ring]*m_minFrac || s2n < m_minS2N) value = false;
63  mask->setActiveCh(moduleID, channelID, value);
64  }
65 
66  saveCalibration(mask);
67 
68  return c_OK;
69 
70 }
71 
72 
74 {
75  if (modID <= 42) return 0;
76  if (modID <= 90) return 1;
77  if (modID <= 144) return 2;
78  if (modID <= 204) return 3;
79  if (modID <= 270) return 4;
80  if (modID <= 342) return 5;
81  if (modID <= 420) return 6;
82  return -1; // -1 if invalid input
83 }
Belle2::ARICHChannelMaskMaker::m_minS2N
double m_minS2N
Minimal signal/(signal+noise) for channel (for hot channels)
Definition: ARICHChannelMaskMaker.h:66
Belle2::ARICHChannelMaskMaker::calibrate
virtual EResult calibrate() override
Run algo on data.
Definition: ARICHChannelMaskMaker.cc:18
Belle2::ARICHChannelMask
The Class for ARICH HAPD channel mask.
Definition: ARICHChannelMask.h:35
Belle2::ARICHChannelMaskMaker::m_minHitPerChn
double m_minHitPerChn
Minimal number of hits in the channel in the outter HAPD ring, collect more data if not satisfied.
Definition: ARICHChannelMaskMaker.h:68
Belle2::ARICHChannelMaskMaker::ARICHChannelMaskMaker
ARICHChannelMaskMaker()
Constructor set the prefix to TestCalibration.
Definition: ARICHChannelMaskMaker.cc:7
Belle2::CalibrationAlgorithm::saveCalibration
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
Definition: CalibrationAlgorithm.cc:290
Belle2::CalibrationAlgorithm::c_OK
@ c_OK
Finished successfuly =0 in Python.
Definition: CalibrationAlgorithm.h:51
Belle2::CalibrationAlgorithm::setDescription
void setDescription(const std::string &description)
Set algorithm description (in constructor)
Definition: CalibrationAlgorithm.h:331
Belle2::ARICHChannelMaskMaker::m_minFrac
double m_minFrac
Minimal number of signal hits (bit 1+2-0-3) in channel / average number of signal hits in channel in ...
Definition: ARICHChannelMaskMaker.h:64
Belle2::ARICHChannelMaskMaker::getRing
int getRing(int modID)
get hapd ring number from moduleID
Definition: ARICHChannelMaskMaker.cc:73
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CalibrationAlgorithm::c_Failure
@ c_Failure
Failed =3 in Python.
Definition: CalibrationAlgorithm.h:54
Belle2::CalibrationAlgorithm::EResult
EResult
The result of calibration.
Definition: CalibrationAlgorithm.h:50
Belle2::CalibrationAlgorithm::c_NotEnoughData
@ c_NotEnoughData
Needs more data =2 in Python.
Definition: CalibrationAlgorithm.h:53
Belle2::CalibrationAlgorithm
Base class for calibration algorithms.
Definition: CalibrationAlgorithm.h:47