10 #include <dqm/analysis/modules/DQMHistAnalysisARICHMonObj.h>
34 DQMHistAnalysisARICHMonObjModule::DQMHistAnalysisARICHMonObjModule()
38 setDescription(
"Example module for making MonitoringObject in DQMHistAnalysis module");
53 m_c_main =
new TCanvas(
"arich_main",
"main", 1500, 800);
54 m_c_mask =
new TCanvas(
"arich_mask",
"mask", 750, 1600);
55 m_c_mirror =
new TCanvas(
"arich_mirror",
"mirror", 1000, 1000);
56 m_c_tracks =
new TCanvas(
"arich_tracks",
"tracks", 500, 500);
75 TGaxis::SetMaxDigits(3);
76 gStyle->SetPalette(1);
77 gStyle->SetOptStat(0);
81 TH1* chHit =
findHist(
"ARICH/chHit");
83 TH1* hitsPerTrack =
findHist(
"ARICH/hitsPerTrack");
84 TH1* theta =
findHist(
"ARICH/theta");
85 TH2* tracks2D = (TH2*)
findHist(
"ARICH/tracks2D");
86 TH1* hitsPerEvent =
findHist(
"ARICH/hitsPerEvent");
87 TH2* hapdHitPerEvent = (TH2*)
findHist(
"ARICH/hapdHitPerEvent");
88 TH2* thetaPhi = (TH2*)
findHist(
"ARICH/thetaPhi");
89 TH3* mirrorThetaPhi = (TH3*)
findHist(
"ARICH/mirrorThetaPhi");
90 TH1* chDigit =
findHist(
"ARICH/chDigit");
91 TH1* hapdDigit =
findHist(
"ARICH/hapdDigit");
93 if (chHit == NULL) {
m_monObj->
setVariable(
"comment",
"No arich histograms in file"); B2INFO(
"Histogram named chHit is not found.");
return;}
94 if (chHit->GetEntries() == 0) {
m_monObj->
setVariable(
"comment",
"No arich hits in histograms"); B2INFO(
"No arich hits in histograms.");
return;}
107 pp1->SetTitle(
"Number of hits / APD / event");
108 pp1->SetOption(
"colz");
111 pp2->SetMaximum(0.1 / 36.);
112 pp2->SetMinimum(0.0001 / 36.);
113 pp2->SetTitle(
"Number of hits / channel / event");
116 pflash->SetTitle(
"Number of flash (>40 hits) / event");
119 if (hitsPerEvent) nevt = hitsPerEvent->GetEntries();
127 pp1->SetMaximum(0.1);
129 pp1->SetMinimum(0.0001);
130 pp2->SetMaximum(0.1 / 36.);
138 pp1->GetXaxis()->SetTickLength(0);
139 pp1->GetYaxis()->SetTickLength(0);
143 TH1F* flash = (TH1F*)hapdHitPerEvent->ProjectionX(
"flash", 40, 144);
145 if (nevt)
m_hapdHist->Scale(1. /
float(nevt));
151 for (
int isec = 0; isec < 6; isec++) {
152 double x1 = rlin * cos(M_PI / 3.*isec);
153 double x2 = rlout * cos(M_PI / 3.*isec);
154 double y1 = rlin * sin(M_PI / 3.*isec);
155 double y2 = rlout * sin(M_PI / 3.*isec);
156 TLine* line =
new TLine(x1, y1, x2, y2);
158 x1 = rlin * cos(M_PI / 3.*isec + M_PI / 6.);
159 y1 = rlin * sin(M_PI / 3.*isec + M_PI / 6.);
160 TText* lab =
new TText(x1, y1, TString::Format(
"S-%d", isec + 1));
161 lab->SetTextAlign(22);
162 lab->SetTextSize(0.03);
171 double trkevt = nevt > 0 ? tracks2D->GetEntries() / nevt : 0;
172 int ntracks = tracks2D->GetEntries();
176 if (ntracks == 0) comment =
"No arich tracks in file.";
177 if (theta->GetEntries() == 0) comment.append(
" No cherenkov photons available");
180 tracks2D->SetTitle(TString::Format(
"Track distribution (avg %f trk/evt)", trkevt));
181 tracks2D->Draw(
"colz");
185 double sigbkg[8] = {0};
187 if (theta->GetEntries() == 0)
return;
188 TF1* f1 =
new TF1(
"thcFit",
"gaus(0)+gaus(3)", 0.2, 0.4);
189 f1->SetParameters(0.8 * theta->GetMaximum(), 0.323, 0.016, 0.2 * theta->GetMaximum(), 0.323, 0.13);
190 f1->FixParameter(5, 0.13);
191 f1->SetParName(0,
"C");
192 f1->SetParName(1,
"mean");
193 f1->SetParName(2,
"sigma");
194 f1->SetParName(3,
"p0");
195 f1->SetParName(4,
"p1");
196 int status = theta->Fit(f1,
"R");
197 double xmin = f1->GetParameter(1) - 2.*f1->GetParameter(2);
198 double xmax = f1->GetParameter(1) + 2.*f1->GetParameter(2);
199 double tmp = f1->GetParameter(3);
200 f1->SetParameter(3, 0);
201 double nphot = f1->Integral(xmin, xmax);
202 f1->SetParameter(3, tmp);
203 tmp = f1->GetParameter(0);
204 f1->SetParameter(0, 0);
205 double nbkg = f1->Integral(xmin, xmax);
206 f1->SetParameter(0, tmp);
210 sigbkg[1] = f1->GetParameter(0) > 0 ? nphot * f1->GetParError(0) / f1->GetParameter(0) : 0.;
212 sigbkg[3] = f1->GetParameter(3) > 0 ? nbkg * f1->GetParError(3) / f1->GetParameter(3) : 0.;
213 sigbkg[4] = f1->GetParameter(1);
214 sigbkg[5] = f1->GetParError(1);
215 sigbkg[6] = f1->GetParameter(2);
216 sigbkg[7] = f1->GetParError(2);
217 if (theta->GetBinWidth(1) == 0)
return;
219 sigbkg[1] /
float(ntracks) / theta->GetBinWidth(1));
221 sigbkg[3] /
float(ntracks) / theta->GetBinWidth(1));
224 std::cout << sigbkg[0] <<
" " << sigbkg[1] / float(ntracks) / theta->GetBinWidth(1) << std::endl;
229 TH1F* thetaCl = (TH1F*)theta->Clone(
"thetaCl");
230 thetaCl->SetLineColor(16);
231 thetaCl->SetLineWidth(2);
232 thetaCl->SetTitle(
"");
234 gStyle->SetOptTitle(0);
236 if (mirrorThetaPhi) {
237 for (
int i = 1; i < 18 + 1; i++) {
238 TH1F* hmir = (TH1F*)mirrorThetaPhi->ProjectionZ(TString::Format(
"hmir_%d", i), i, i, 1, 10000);
239 hmir->SetTitle(TString::Format(
"mirror %d", i));
240 if (hmir->GetEntries() > 0) hmir->Scale(theta->GetEntries() / hmir->GetEntries());
242 hmir->SetLineWidth(2);
243 int iplot = (i - 1) / 2;
244 if ((i - 1) % 2 == 0) {
m_c_mirror->cd(iplot + 1); thetaCl->Draw(
"hist"); hmir->SetLineColor(1); hmir->Draw(
"sames hist"); leg[iplot] =
new TLegend(0.1, 0.75, 0.4, 0.9); leg[iplot]->AddEntry(hmir, TString::Format(
"mirror %d", i));}
246 hmir->SetLineColor(2); hmir->Draw(
"sames hist");
247 leg[iplot]->AddEntry(hmir, TString::Format(
"mirror %d", i));
253 gStyle->SetOptTitle(1);
257 if (chDigit != NULL && nevt) chDigit->Scale(1. / nevt);
259 chHit->Scale(1. / nevt);
260 flash->Scale(1. / nevt);
262 int nhot = 0, ndead = 0;
263 TH2F* hotCh =
new TH2F(
"arich_hot",
"Number of channels in APD with >0.5% occ.", 42, 0.5, 42.5, 40, 0.5, 40.5);
264 TH2F* hotCh1 =
new TH2F(
"arich_hot1",
"Number of channels in APD with >0.5% occ. after mask", 42, 0.5, 42.5, 40, 0.5, 40.5);
265 TH2F* deadCh =
new TH2F(
"arich_dead",
"Number of channels in APD with no hits", 42, 0.5, 42.5, 40, 0.5, 40.5);
266 TH2F* falseCh =
new TH2F(
"arich_false",
"Number of wrongly masked channels in APD (masked but not dead/hot)", 42, 0.5, 42.5, 40,
269 TH1F* occ =
new TH1F(
"arich_occ",
"nhits / nevt for all channels; nhits/nevt;# of chn", 500, 0, 0.005);
272 if (chDigit != NULL) {
273 double hotlim = 0.005;
274 for (
int i = 0; i < chDigit->GetNbinsX(); i++) {
275 int hapd = i / 144 + 1;
int chip = (i % 144) / 36 + 1;
276 int binx = (
hapd - 1) % 42 + 1;
int biny = ((
hapd - 1) / 42) * 4 + chip;
277 if (chDigit->GetBinContent(i + 1) > hotlim) { hotCh->Fill(binx, biny); nhot++;}
278 if (chDigit->GetBinContent(i + 1) == 0) {
279 deadCh->Fill(binx, biny);
280 if (hapdDigit->GetBinContent(
hapd) != 0) ndead++;
282 if (chHit->GetBinContent(i + 1) == 0 && chDigit->GetBinContent(i + 1) < hotlim
283 && chDigit->GetBinContent(i + 1) > 0.00002) falseCh->Fill(binx, biny);
284 if (chHit->GetBinContent(i + 1) > hotlim) hotCh1->Fill(binx, biny);
285 occ->Fill(chHit->GetBinContent(i + 1));
288 for (
int i = 0; i < hapdDigit->GetNbinsX(); i++) {
289 if (hapdDigit->GetBinContent(i + 1) == 0) ndeadHapd++;
308 hotCh->Draw(
"colz text");
310 deadCh->Draw(
"colz text");
312 hotCh1->Draw(
"colz text");
314 falseCh->Draw(
"colz text");
316 for (
int i = 0; i < 42; i++) {
317 double x1 = i + 0.5 + 1;
318 TLine* line =
new TLine(x1, 0.5, x1, 40.5);
324 for (
int i = 0; i < 40; i++) {
325 double y1 = i + 0.5 + 1;
326 TLine* line =
new TLine(0.5, y1, 42.5, y1);
327 if ((i + 1) % 4 == 0) line->SetLineColor(2);
328 else line->SetLineColor(15);
336 bits->SetLineWidth(2);
337 bits->SetLineColor(2);
338 bits->SetOption(
"hist");
339 bits->SetFillStyle(3010);
340 bits->SetFillColor(3);
344 hitsPerTrack->SetLineWidth(2);
345 hitsPerTrack->SetLineColor(2);
346 hitsPerTrack->SetOption(
"hist");
349 hitsPerEvent->SetLineWidth(2);
350 hitsPerEvent->SetLineColor(2);
351 hitsPerEvent->SetOption(
"hist");
355 if (bits) { bits->Draw(); bits->GetYaxis()->SetTitleOffset(0.5); }
357 if (theta) theta->Draw();
359 if (hitsPerTrack) hitsPerTrack->Draw();
361 if (hitsPerEvent) hitsPerEvent->Draw();
363 if (thetaPhi != NULL) thetaPhi->Draw(
"colz");
367 m_monObj->
setVariable(
"hitsPerEvent", hitsPerEvent ? hitsPerEvent->GetMean() : 0, hitsPerEvent ? hitsPerEvent->GetMeanError() : -1);
370 B2DEBUG(20,
"DQMHistAnalysisARICHMonObj : endRun called");
376 B2DEBUG(20,
"terminate called");
ARICH histogram with HAPD plane 3 options for bin segmentation are available type 0 - one bin per HAP...
void fillFromTH1(TH1 *hist)
Fill the channelHist from the histogram Type 0 channelHist has to be filled with 420*144bin TH1 (each...
void setPoly(TH2Poly *poly)
Fill pure TH2Poly from ARICHChannelHist, makes bins and fills content.
void initialize() override final
Initialize the Module.
~DQMHistAnalysisARICHMonObjModule()
Destructor.
Belle2::ARICHChannelHist * m_apdHist
ARICH TObject to draw hit map for each APD.
MonitoringObject * m_monObj
MonitoringObject to be produced by this module.
Belle2::ARICHChannelHist * m_hapdHist
ARICH TObject to draw flash map for each hapd.
void terminate() override final
Termination action.
TCanvas * m_c_mask
Canvas with histograms related to channel masking.
TCanvas * m_c_main
Canvas with main run summary histograms.
TCanvas * m_c_mirror
Canvas with histograms related to mirrors.
void endRun() override final
End-of-run action.
TH2Poly * pp2
2D hitmap of number of hits per channel per event
TCanvas * m_c_tracks
Canvas with histograms related to tracks.
TH2Poly * pflash
2D hitmap of number of flash (>40 hits) per event
TH2Poly * pp1
2D hitmap of number of hits per APD per event
The base class for the histogram analysis module.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
static MonitoringObject * getMonitoringObject(const std::string &histname)
Get MonitoringObject with given name (new object is created if non-existing)
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...
void setVariable(const std::string &var, float val, float upErr=-1., float dwErr=-1)
set value to float variable (new variable is made if not yet existing)
void addCanvas(TCanvas *canv)
Add Canvas to monitoring object.
TH1F * hapd[6]
histogram of hits for each hapd
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.