10#include <dqm/analysis/modules/DQMHistAnalysisARICH.h>
36 setDescription(
"Modify and analyze the data quality histograms of ARICH");
41 addParam(
"badApdOccLimit",
m_badApdOccLimit,
"Occupancy limit for bad APDs (in fraction of average occupancy)", 0.3);
50 for (
int i = 0; i < 5; i++) {
60 m_apdPoly->SetTitle(
"# of hits/APD/event");
64 addDeltaPar(
"ARICH",
"bitsPerChannel", HistDelta::c_Events,
80 B2DEBUG(20,
"DQMHistAnalysisARICH: initialized.");
105 TH1* m_h_mergerHit =
findHist(
"ARICH/mergerHit");
110 m_h_mergerHit->SetMinimum(0);
111 m_h_mergerHit->Draw(
"hist");
115 double mean = m_h_mergerHit->Integral() / 72;
116 for (
int i = 0; i < 72; i++) {
117 int hit = m_h_mergerHit->GetBinContent(i + 1);
118 if ((
bool)hit ^ (
bool)m_h_mergerHit->GetEntries()) {
126 if (hit > mean * 100 && alertMerger < 1) alertMerger = 1;
131 for (
int i = 0; i < 5; i++) {
132 m_LineForMB[i]->DrawLine(12 * (i + 1) + 0.5, 0, 12 * (i + 1) + 0.5, gPad->GetUymax());
137 B2INFO(
"Histogram/canvas named mergerHit is not found.");
142 TH1* m_h_bits =
findHist(
"ARICH/bits");
144 if (m_h_bits != NULL &&
m_c_bits != NULL) {
147 m_h_bits->SetMinimum(0);
148 m_h_bits->Draw(
"hist");
151 double side = m_h_bits->GetBinContent(2) + m_h_bits->GetBinContent(5);
152 double center = m_h_bits->GetBinContent(3) + m_h_bits->GetBinContent(4);
160 B2INFO(
"Histogram/canvas named bits is not found.");
164 TH1* m_h_hitsPerEvent =
findHist(
"ARICH/hitsPerEvent");
170 m_h_hitsPerEvent->SetMinimum(0);
171 m_h_hitsPerEvent->Draw(
"hist");
173 nEvents = m_h_hitsPerEvent->GetEntries();
174 int alertHitsPerEvent = 0;
175 double mean = m_h_hitsPerEvent->GetMean();
176 if (mean < 1) alertHitsPerEvent = 1;
177 double entry = m_h_hitsPerEvent->GetEntries();
178 if (entry == 0) alertHitsPerEvent = 2;
183 B2INFO(
"Histogram/canvas named hitsPerEvent is not found.");
187 TH1* m_h_chHit =
findHist(
"ARICH/chipHit");
188 if (m_h_chHit != NULL) {
190 TH1* htmp =
findHist(
"ARICH/hitsPerEvent");
191 if (htmp) nevt = htmp->GetEntries();
193 if (nevt)
m_apdHist->Scale(1. /
float(nevt));
205 B2INFO(
"Histogram named chipHit is not found.");
208 TH1F* chDigit = (TH1F*)
findHist(
"ARICH/chDigit");
211 if (chDigit != NULL && nEvents != 0) {
212 avgOcc = chDigit->GetEntries() / 60480.;
214 for (
int i = 0; i < chDigit->GetNbinsX(); i++) {
215 int nhit = chDigit->GetBinContent(i + 1);
216 if ((nhit - 3. *
sqrt(nhit)) /
float(nEvents) >
m_hotLimit) nhot++;
223 TH1F* hapdDigit = (TH1F*)
findHist(
"ARICH/hapdDigit");
224 if (hapdDigit != NULL && avgOcc * 144. > 100.) {
225 for (
int i = 0; i < hapdDigit->GetNbinsX(); i++) {
226 if (hapdDigit->GetBinContent(i + 1) == 0) ndeadHapd++;
231 auto h_theta =
getDelta(
"ARICH",
"theta", 0,
false);
233 auto h_thetaInt = (TH1F*)
findHist(
"ARICH/theta");
234 if (h_theta != NULL && c_theta != NULL && h_thetaInt != NULL) {
235 int binmax = h_theta->GetMaximumBin();
236 double x = h_theta->GetXaxis()->GetBinCenter(binmax);
241 if (h_theta->GetEntries() > 0) h_theta->Scale(h_thetaInt->GetEntries() /
double(h_theta->GetEntries()));
243 h_theta->Draw(
"same");
249 if (avgOcc * 36. < 100.) {
254 auto h_bitsPerChannel =
getDelta(
"ARICH",
"bitsPerChannel", 0,
true);
255 if (h_bitsPerChannel == NULL)
return;
256 TH1F* apdHits =
new TH1F(
"apdHits",
"nSigHits/nevt for all apds", 1680, -0.5, 1679.5);
258 for (
int i = 1; i < 60481; i++) {
259 int nnoise = h_bitsPerChannel->GetBinContent(1, i) + h_bitsPerChannel->GetBinContent(4, i);
260 int nsig = h_bitsPerChannel->GetBinContent(2, i) + h_bitsPerChannel->GetBinContent(3, i) - nnoise;
261 double sig2noise = float(nsig) / float(nsig + nnoise);
262 if (sig2noise > 0.2) avg += nsig;
263 if (i % 36 == 0 && i > 1) {
264 apdHits->SetBinContent(i / 36 + 1, avg);
270 double ringApdAvg[7] = {0.};
272 const int hapdInRing[7] = {42, 48, 54, 60, 66, 72, 78};
275 for (
int i = 1; i < 1681; i++) {
276 int hapd = (i - 1) / 4 + 1;
277 ringApdAvg[
getRing(
hapd)] += apdHits->GetBinContent(i);
280 for (
int i = 0; i < 7; i++) {
281 ringApdAvg[i] /= float(4.*hapdInRing[i]);
284 for (
int i = 0; i < 1680; i++) {
286 int nhits = apdHits->GetBinContent(i + 1);
298 if (modID <= 42)
return 0;
299 if (modID <= 90)
return 1;
300 if (modID <= 144)
return 2;
301 if (modID <= 204)
return 3;
302 if (modID <= 270)
return 4;
303 if (modID <= 342)
return 5;
304 if (modID <= 420)
return 6;
310 B2DEBUG(20,
"DQMHistAnalysisARICH : endRun called");
316 B2DEBUG(20,
"terminate called");
ARICH histogram with HAPD plane 3 options for bin segmentation are available type 0 - one bin per HAP...
double m_hotLimit
Occupancy limit for hot channels.
double m_badApdOccLimit
Occupancy threshold for bad APDs, in units of average APD occupancy.
void initialize() override final
Initialize the Module.
TCanvas * m_c_apdHist
Canvas for 2D hit map of APDs.
TH2Poly * m_apdPoly
hit map for each APD
TLine * m_LineForMB[5]
Lines to divide the sectors on mergerHit histogram.
TCanvas * m_c_mergerHit
Canvas for modified mergerHit histogram.
int getRing(int modID)
Returns ring number of HAPD with given moduleID.
bool m_enableAlert
Enable alert by base color of canvases.
Belle2::ARICHChannelHist * m_apdHist
ARICH TObject to draw hit map for each APD.
void terminate() override final
Termination action.
void event() override final
Event processor.
double m_sigBitFracLowAlarm
Alarm limit for overall signal/background fraction.
void endRun() override final
End-of-run action.
TCanvas * m_c_bits
Canvas for modified bits histogram.
std::vector< int > maskedMergers
The id numbers of masked merger boards to avoid unnecessary alert.
void beginRun() override final
begin-of-run action.
int m_minStats
The lower limit on the number of events to enable the alert.
TCanvas * m_c_hitsPerEvent
Canvas for modified hitsPerTrack histogram.
DQMHistAnalysisARICHModule()
Constructor.
double m_sigBitFracLowWarn
Warning limit for overall signal/background fraction.
int alertColor[3]
Alert color of canvases.
static TCanvas * findCanvas(TString cname)
Find canvas by name.
int registerEpicsPV(const std::string &pvname, const std::string &keyname="")
EPICS related Functions.
static void addDeltaPar(const std::string &dirname, const std::string &histname, HistDelta::EDeltaType t, int p, unsigned int a=1)
Add Delta histogram parameters.
static void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
TH1 * getDelta(const std::string &fullname, int n=0, bool onlyIfUpdated=true)
Get Delta histogram.
DQMHistAnalysisModule()
Constructor / Destructor.
EStatus
Status flag of histogram/canvas.
@ c_StatusError
Analysis result: Severe issue found.
@ c_StatusWarning
Analysis result: Warning, there may be minor issues.
@ c_StatusGood
Analysis result: Good.
double getEpicsPV(const std::string &keyname)
Read value from a EPICS PV.
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.
void setEpicsPV(const std::string &keyname, double value)
Write value to a EPICS PV.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
TH1F * hapd[6]
histogram of hits for each hapd
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.