Belle II Software development
ARICHChannelMaskMaker.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <arich/calibration/ARICHChannelMaskMaker.h>
9#include <arich/dbobjects/ARICHChannelMask.h>
10#include <TH2F.h>
11
12using namespace Belle2;
13
15{
17 " --------------------- ARICHChannelMask Calibration Algorithm -----------------\n"
18 " \n"
19 " Produces channel mask for arich hot/dead channels, based on criteria of \n"
20 " minimal and maximal occupancy \n"
21 " ------------------------------------------------------------------------------\n"
22 );
23}
24
26{
27
28 auto hist = getObjectPtr<TH2F>("ch_occupancy");
29 if (!hist) return c_Failure;
30
31 B2INFO("Number of Entries in ARICH ch_occupancy histogram was " << hist->GetEntries());
32
33 const int NumberOfChannelsPerHapd = 144;
34 int numChannels = hist->GetNbinsX();
35
36 int nevt = hist->GetBinContent(numChannels, 1);
37
38 auto* mask = new ARICHChannelMask();
39
40 double ringChnAvg[7] = {0.};
41 // double ringChnAvgS2N[7] = {0.};
42 const int hapdInRing[7] = {42, 48, 54, 60, 66, 72, 78};
43
44 for (int bin = 1; bin < numChannels; ++bin) {
45 int moduleID = (bin - 1) / NumberOfChannelsPerHapd + 1;
46 double nsig = hist->GetBinContent(bin, 2) + hist->GetBinContent(bin, 3) - hist->GetBinContent(bin, 1) - hist->GetBinContent(bin, 4);
47 // double s2n = nsig / (hist->GetBinContent(bin, 2) + hist->GetBinContent(bin, 3));
48 int ring = getRing(moduleID);
49 if (nsig / float(nevt) > 0.02) continue; // skip channels with anomalously high occupancy
50 ringChnAvg[ring] += nsig;
51 // ringChnAvgS2N[ring] += s2n;
52 }
53
54 for (int i = 0; i < 7; i++) {
55 ringChnAvg[i] /= float(hapdInRing[i] * NumberOfChannelsPerHapd);
56 // ringChnAvgS2N[i] /= float(hapdInRing[i] * NumberOfChannelsPerHapd);
57 }
58 B2INFO("Average hits in channel in outer HAPD ring is " << ringChnAvg[6] << " (which is less that minimally required, " <<
59 m_minHitPerChn << ")");
60 if (ringChnAvg[6] < m_minHitPerChn) return c_NotEnoughData;
61
62 for (int bin = 1; bin < numChannels; ++bin) {
63 int moduleID = (bin - 1) / NumberOfChannelsPerHapd + 1;
64 int channelID = (bin - 1) % NumberOfChannelsPerHapd;
65 double nsig = hist->GetBinContent(bin, 2) + hist->GetBinContent(bin, 3) - hist->GetBinContent(bin, 1) - hist->GetBinContent(bin, 4);
66 double s2n = nsig / (hist->GetBinContent(bin, 2) + hist->GetBinContent(bin, 3));
67 int ring = getRing(moduleID);
68 bool value = true;
69 if (nsig < ringChnAvg[ring]*m_minFrac || s2n < m_minS2N) value = false;
70 mask->setActiveCh(moduleID, channelID, value);
71 }
72
73 saveCalibration(mask);
74
75 return c_OK;
76
77}
78
79
81{
82 if (modID <= 42) return 0;
83 if (modID <= 90) return 1;
84 if (modID <= 144) return 2;
85 if (modID <= 204) return 3;
86 if (modID <= 270) return 4;
87 if (modID <= 342) return 5;
88 if (modID <= 420) return 6;
89 return -1; // -1 if invalid input
90}
ARICHChannelMaskMaker()
Constructor set the prefix to TestCalibration.
double m_minHitPerChn
Minimal number of hits in the channel in the outter HAPD ring, collect more data if not satisfied.
int getRing(int modID)
get hapd ring number from moduleID
double m_minFrac
Minimal number of signal hits (bit 1+2-0-3) in channel / average number of signal hits in channel in ...
virtual EResult calibrate() override
Run algo on data.
double m_minS2N
Minimal signal/(signal+noise) for channel (for hot channels)
The Class for ARICH HAPD channel mask.
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)
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
@ c_Failure
Failed =3 in Python.
Abstract base class for different kinds of events.