Belle II Software  release-05-01-25
DQMHistAnalysisARICH.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Kindo Haruki, Luka Santelj *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 // Own include
12 #include <dqm/analysis/modules/DQMHistAnalysisARICH.h>
13 
14 //DQM
15 #include <dqm/analysis/modules/DQMHistAnalysis.h>
16 
17 #include <TH1F.h>
18 #include <TH2F.h>
19 #include <TCanvas.h>
20 #include <TLine.h>
21 #include <TClass.h>
22 #include <TROOT.h>
23 
24 #include <fstream>
25 #include <vector>
26 #include <algorithm>
27 
28 using namespace std;
29 using namespace Belle2;
30 
31 //-----------------------------------------------------------------
32 // Register module
33 //-----------------------------------------------------------------
34 
35 REG_MODULE(DQMHistAnalysisARICH);
36 
37 DQMHistAnalysisARICHModule::DQMHistAnalysisARICHModule()
39 {
40  // set module description (e.g. insert text)
41  setDescription("Modify and analyze the data quality histograms of ARICH");
43  addParam("debug", m_debug, "debug mode", false);
44  addParam("alert", m_enableAlert, "Enable color alert", true);
45 }
46 
48 {
49 }
50 
52 {
53  gROOT->cd();
54 
55  //definition of new TObjects for modification and analysis
56  for (int i = 0; i < 5; i++) {
57  m_LineForMB[i] = new TLine();
58  m_LineForMB[i]->SetLineStyle(3);
59  m_LineForMB[i]->SetLineWidth(1);
60  m_LineForMB[i]->SetLineColor(kBlack);
61  }
62 
63  m_apdHist = new ARICHChannelHist("tmpChHist", "tmpChHist", 2);
64  m_apdPoly = new TH2Poly();
65  m_apdPoly->SetName("ARICH/apdHitMap");
66  m_apdPoly->SetTitle("# of hits/APD/event");
67  m_apdPoly->SetOption("colz");
68  m_c_apdHist = new TCanvas("ARICH/c_apdHist");
69 
70  B2DEBUG(20, "DQMHistAnalysisARICH: initialized.");
71 }
72 
74 {
75 }
76 
78 {
79 
80  //Show alert by empty bins = red and strange entries = yellow
81  //Draw lines on mergerHits histogram for shifters to divide sectors
82  TH1* m_h_mergerHit = findHist("ARICH/mergerHit");
83  m_c_mergerHit = find_canvas("ARICH/c_mergerHit");
84  if (m_h_mergerHit != NULL && m_c_mergerHit != NULL) {
85  m_c_mergerHit->Clear();
86  m_c_mergerHit->cd();
87  m_h_mergerHit->SetMinimum(0);
88  m_h_mergerHit->Draw("hist");
89  gPad->Update();
90 
91  int alertMerger = 0;
92  double mean = m_h_mergerHit->Integral() / 72;
93  for (int i = 0; i < 72; i++) {
94  int hit = m_h_mergerHit->GetBinContent(i + 1);
95  if ((bool)hit ^ (bool)m_h_mergerHit->GetEntries()) {
96  //only if the empty bin is not a masked merger, show alert.
97  auto itr = std::find(maskedMergers.begin(), maskedMergers.end(), i + 1);
98  if (itr == maskedMergers.end()) {
99  alertMerger = 2;
100  break;
101  }
102  }
103  if (hit > mean * 100 && alertMerger < 1) alertMerger = 1;
104  }
105  if (m_enableAlert && m_minStats < m_h_mergerHit->GetEntries()) m_c_mergerHit->SetFillColor(alertColor[alertMerger]);
106 
107  //Draw lines divide the sectors
108  for (int i = 0; i < 5; i++) {
109  m_LineForMB[i]->DrawLine(12 * (i + 1) + 0.5, 0, 12 * (i + 1) + 0.5, gPad->GetUymax());
110  }
111 
112  m_c_mergerHit->Modified();
113  } else {
114  B2INFO("Histogram/canvas named mergerHit is not found.");
115  }
116 
117 
118  //Show alert by the ratio of center 2 bins to side 2bins. <1.5 = red, <2 = yellow
119  TH1* m_h_bits = findHist("ARICH/bits");
120  m_c_bits = find_canvas("ARICH/c_bits");
121  if (m_h_bits != NULL && m_c_bits != NULL) {
122  m_c_bits->Clear();
123  m_c_bits->cd();
124  m_h_bits->SetMinimum(0);
125  m_h_bits->Draw("hist");
126  gPad->Update();
127 
128  int alertBits = 0;
130  double side = m_h_bits->GetBinContent(2) + m_h_bits->GetBinContent(5);
131  double center = m_h_bits->GetBinContent(3) + m_h_bits->GetBinContent(4);
132  if (center / side < 2) alertBits = 1;
133  if (center / side < 1.5) alertBits = 2;
134  if (m_enableAlert && m_minStats < m_h_bits->GetEntries()) m_c_bits->SetFillColor(alertColor[alertBits]);
135 
136  m_c_bits->Modified();
137  } else {
138  B2INFO("Histogram/canvas named bits is not found.");
139  }
140 
141  //Show alert by no entry = red and 0 peak = yellow
142  TH1* m_h_hitsPerEvent = findHist("ARICH/hitsPerEvent");
143  m_c_hitsPerEvent = find_canvas("ARICH/c_hitsPerEvent");
144  if (m_h_hitsPerEvent != NULL && m_c_hitsPerEvent != NULL) {
145  m_c_hitsPerEvent->Clear();
146  m_c_hitsPerEvent->cd();
147  m_h_hitsPerEvent->SetMinimum(0);
148  m_h_hitsPerEvent->Draw("hist");
149  gPad->Update();
150 
151  int alertHitsPerEvent = 0;
152  double mean = m_h_hitsPerEvent->GetMean();
153  if (mean < 1) alertHitsPerEvent = 1;
154  double entry = m_h_hitsPerEvent->GetEntries();
155  if (entry == 0) alertHitsPerEvent = 2;
156  if (m_enableAlert) m_c_hitsPerEvent->SetFillColor(alertColor[alertHitsPerEvent]);
157 
158  m_c_hitsPerEvent->Modified();
159  } else {
160  B2INFO("Histogram/canvas named hitsPerEvent is not found.");
161  }
162 
163  //Draw 2D hit map of channels and APDs
164  TH1* m_h_chHit = findHist("ARICH/chipHit");
165  if (m_h_chHit != NULL) {
166  int nevt = 0;
167  TH1* htmp = findHist("ARICH/hitsPerEvent");
168  if (htmp) nevt = htmp->GetEntries();
169  m_apdHist->fillFromTH1(m_h_chHit);
170  if (nevt) m_apdHist->Scale(1. / float(nevt));
171  m_apdPoly->SetMaximum(0.1);
173  m_apdPoly->SetMinimum(0.0001);
174  m_c_apdHist->Clear();
175  m_c_apdHist->cd();
176  m_apdPoly->Draw("colz");
177  m_apdPoly->GetXaxis()->SetTickLength(0);
178  m_apdPoly->GetYaxis()->SetTickLength(0);
179  gPad->SetLogz();
180  m_c_apdHist->Update();
181  } else {
182  B2INFO("Histogram named chipHit is not found.");
183  }
184 
185 }
186 
188 {
189  B2DEBUG(20, "DQMHistAnalysisARICH : endRun called");
190 }
191 
193 {
194 
195  B2DEBUG(20, "terminate called");
196 }
197 
198 TCanvas* DQMHistAnalysisARICHModule::find_canvas(TString canvas_name)
199 {
200  TIter nextckey(gROOT->GetListOfCanvases());
201  TObject* cobj = NULL;
202 
203  while ((cobj = (TObject*)nextckey())) {
204  if (cobj->IsA()->InheritsFrom("TCanvas")) {
205  if (cobj->GetName() == canvas_name)
206  break;
207  }
208  }
209  return (TCanvas*)cobj;
210 }
Belle2::DQMHistAnalysisARICHModule::event
virtual void event() override
Event processor.
Definition: DQMHistAnalysisARICH.cc:77
Belle2::DQMHistAnalysisARICHModule::m_c_bits
TCanvas * m_c_bits
Canvas for modified bits histogram.
Definition: DQMHistAnalysisARICH.h:105
Belle2::DQMHistAnalysisARICHModule::m_c_apdHist
TCanvas * m_c_apdHist
Canvas for 2D hit map of APDs.
Definition: DQMHistAnalysisARICH.h:112
Belle2::DQMHistAnalysisARICHModule::m_c_mergerHit
TCanvas * m_c_mergerHit
Canvas for modified mergerHit histogram.
Definition: DQMHistAnalysisARICH.h:106
Belle2::DQMHistAnalysisARICHModule::alertColor
int alertColor[3]
Alert color of canvases.
Definition: DQMHistAnalysisARICH.h:99
Belle2::ARICHChannelHist
ARICH histogram with HAPD plane 3 options for bin segmentation are available type 0 - one bin per HAP...
Definition: ARICHChannelHist.h:37
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::DQMHistAnalysisARICHModule::m_enableAlert
bool m_enableAlert
Enable alert by base color of canvases.
Definition: DQMHistAnalysisARICH.h:97
Belle2::DQMHistAnalysisARICHModule::m_c_hitsPerEvent
TCanvas * m_c_hitsPerEvent
Canvas for modified hitsPerTrack histogram.
Definition: DQMHistAnalysisARICH.h:107
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:82
Belle2::DQMHistAnalysisARICHModule::m_apdHist
Belle2::ARICHChannelHist * m_apdHist
ARICH TObject to draw hit map for each APD.
Definition: DQMHistAnalysisARICH.h:110
Belle2::DQMHistAnalysisARICHModule::m_LineForMB
TLine * m_LineForMB[5]
Lines to divide the sectors on mergerHit histogram.
Definition: DQMHistAnalysisARICH.h:104
Belle2::DQMHistAnalysisARICHModule::terminate
virtual void terminate() override
Termination action.
Definition: DQMHistAnalysisARICH.cc:192
Belle2::DQMHistAnalysisModule::findHist
static TH1 * findHist(const std::string &histname)
Find histogram.
Definition: DQMHistAnalysis.cc:83
Belle2::DQMHistAnalysisARICHModule::find_canvas
TCanvas * find_canvas(TString cname)
Find canvas by name.
Definition: DQMHistAnalysisARICH.cc:198
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::DQMHistAnalysisARICHModule::m_debug
bool m_debug
debug
Definition: DQMHistAnalysisARICH.h:96
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DQMHistAnalysisARICHModule::initialize
virtual void initialize() override
Initialize the Module.
Definition: DQMHistAnalysisARICH.cc:51
Belle2::ARICHChannelHist::setPoly
void setPoly(TH2Poly *poly)
Fill pure TH2Poly from ARICHChannelHist, makes bins and fills content.
Definition: ARICHChannelHist.cc:238
Belle2::DQMHistAnalysisARICHModule::~DQMHistAnalysisARICHModule
virtual ~DQMHistAnalysisARICHModule()
Destructor.
Definition: DQMHistAnalysisARICH.cc:47
Belle2::Module::addParam
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:562
Belle2::ARICHChannelHist::fillFromTH1
void fillFromTH1(TH1 *hist)
Fill the channelHist from the histogram Type 0 channelHist has to be filled with 420*144bin TH1 (each...
Definition: ARICHChannelHist.cc:205
Belle2::DQMHistAnalysisARICHModule::endRun
virtual void endRun() override
End-of-run action.
Definition: DQMHistAnalysisARICH.cc:187
Belle2::DQMHistAnalysisARICHModule::maskedMergers
std::vector< int > maskedMergers
The id numbers of masked merger boards to avoid unnecessary alert.
Definition: DQMHistAnalysisARICH.h:114
Belle2::DQMHistAnalysisARICHModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: DQMHistAnalysisARICH.cc:73
Belle2::DQMHistAnalysisARICHModule::m_apdPoly
TH2Poly * m_apdPoly
hit map for each APD
Definition: DQMHistAnalysisARICH.h:111
Belle2::DQMHistAnalysisModule
The base class for the histogram analysis module.
Definition: DQMHistAnalysis.h:27