12 #include <dqm/analysis/modules/DQMHistAnalysisARICHMonObj.h>
15 #include <dqm/analysis/modules/DQMHistAnalysis.h>
39 DQMHistAnalysisARICHMonObjModule::DQMHistAnalysisARICHMonObjModule()
43 setDescription(
"Example module for making MonitoringObject in DQMHistAnalysis module");
58 m_c_main =
new TCanvas(
"arich_main",
"main", 1500, 800);
59 m_c_mask =
new TCanvas(
"arich_mask",
"mask", 750, 1600);
60 m_c_mirror =
new TCanvas(
"arich_mirror",
"mirror", 1000, 1000);
61 m_c_tracks =
new TCanvas(
"arich_tracks",
"tracks", 500, 500);
89 TGaxis::SetMaxDigits(3);
90 gStyle->SetPalette(1);
91 gStyle->SetOptStat(0);
95 TH1* chHit =
findHist(
"ARICH/chHit");
97 TH1* hitsPerTrack =
findHist(
"ARICH/hitsPerTrack");
98 TH1* theta =
findHist(
"ARICH/theta");
99 TH2* tracks2D = (TH2*)
findHist(
"ARICH/tracks2D");
100 TH1* hitsPerEvent =
findHist(
"ARICH/hitsPerEvent");
101 TH2* hapdHitPerEvent = (TH2*)
findHist(
"ARICH/hapdHitPerEvent");
102 TH2* thetaPhi = (TH2*)
findHist(
"ARICH/thetaPhi");
103 TH3* mirrorThetaPhi = (TH3*)
findHist(
"ARICH/mirrorThetaPhi");
104 TH1* chDigit =
findHist(
"ARICH/chDigit");
105 TH1* hapdDigit =
findHist(
"ARICH/hapdDigit");
107 if (chHit == NULL) {
m_monObj->
setVariable(
"comment",
"No arich histograms in file"); B2INFO(
"Histogram named chHit is not found.");
return;}
108 if (chHit->GetEntries() == 0) {
m_monObj->
setVariable(
"comment",
"No arich hits in histograms"); B2INFO(
"No arich hits in histograms.");
return;}
121 pp1->SetTitle(
"Number of hits / APD / event");
122 pp1->SetOption(
"colz");
125 pp2->SetMaximum(0.1 / 36.);
126 pp2->SetMinimum(0.0001 / 36.);
127 pp2->SetTitle(
"Number of hits / channel / event");
129 pflash =
new TH2Poly();
130 pflash->SetTitle(
"Number of flash (>40 hits) / event");
133 if (hitsPerEvent) nevt = hitsPerEvent->GetEntries();
141 pp1->SetMaximum(0.1);
143 pp1->SetMinimum(0.0001);
144 pp2->SetMaximum(0.1 / 36.);
152 pp1->GetXaxis()->SetTickLength(0);
153 pp1->GetYaxis()->SetTickLength(0);
157 TH1F* flash = (TH1F*)hapdHitPerEvent->ProjectionX(
"flash", 40, 144);
159 if (nevt)
m_hapdHist->Scale(1. /
float(nevt));
165 for (
int isec = 0; isec < 6; isec++) {
166 double x1 = rlin * cos(M_PI / 3.*isec);
167 double x2 = rlout * cos(M_PI / 3.*isec);
168 double y1 = rlin * sin(M_PI / 3.*isec);
169 double y2 = rlout * sin(M_PI / 3.*isec);
170 TLine* line =
new TLine(x1, y1, x2, y2);
172 x1 = rlin * cos(M_PI / 3.*isec + M_PI / 6.);
173 y1 = rlin * sin(M_PI / 3.*isec + M_PI / 6.);
174 TText* lab =
new TText(x1, y1, TString::Format(
"S-%d", isec + 1));
175 lab->SetTextAlign(22);
176 lab->SetTextSize(0.03);
185 double trkevt = nevt > 0 ? tracks2D->GetEntries() / nevt : 0;
186 int ntracks = tracks2D->GetEntries();
190 if (ntracks == 0) comment =
"No arich tracks in file.";
191 if (theta->GetEntries() == 0) comment.append(
" No cherenkov photons available");
194 tracks2D->SetTitle(TString::Format(
"Track distribution (avg %f trk/evt)", trkevt));
195 tracks2D->Draw(
"colz");
199 double sigbkg[8] = {0};
201 if (theta->GetEntries() == 0)
return;
202 TF1* f1 =
new TF1(
"thcFit",
"gaus(0)+gaus(3)", 0.2, 0.4);
203 f1->SetParameters(0.8 * theta->GetMaximum(), 0.323, 0.016, 0.2 * theta->GetMaximum() , 0.323, 0.13);
204 f1->FixParameter(5, 0.13);
205 f1->SetParName(0,
"C");
206 f1->SetParName(1,
"mean");
207 f1->SetParName(2,
"sigma");
208 f1->SetParName(3,
"p0");
209 f1->SetParName(4,
"p1");
210 int status = theta->Fit(f1,
"R");
211 double xmin = f1->GetParameter(1) - 2.*f1->GetParameter(2);
212 double xmax = f1->GetParameter(1) + 2.*f1->GetParameter(2);
213 double tmp = f1->GetParameter(3);
214 f1->SetParameter(3, 0);
215 double nphot = f1->Integral(xmin, xmax);
216 f1->SetParameter(3, tmp);
217 tmp = f1->GetParameter(0);
218 f1->SetParameter(0, 0);
219 double nbkg = f1->Integral(xmin, xmax);
220 f1->SetParameter(0, tmp);
224 sigbkg[1] = f1->GetParameter(0) > 0 ? nphot * f1->GetParError(0) / f1->GetParameter(0) : 0.;
226 sigbkg[3] = f1->GetParameter(3) > 0 ? nbkg * f1->GetParError(3) / f1->GetParameter(3) : 0.;
227 sigbkg[4] = f1->GetParameter(1);
228 sigbkg[5] = f1->GetParError(1);
229 sigbkg[6] = f1->GetParameter(2);
230 sigbkg[7] = f1->GetParError(2);
231 if (theta->GetBinWidth(1) == 0)
return;
233 sigbkg[1] /
float(ntracks) / theta->GetBinWidth(1));
235 sigbkg[3] /
float(ntracks) / theta->GetBinWidth(1));
238 std::cout << sigbkg[0] <<
" " << sigbkg[1] / float(ntracks) / theta->GetBinWidth(1) << std::endl;
243 TH1F* thetaCl = (TH1F*)theta->Clone(
"thetaCl");
244 thetaCl->SetLineColor(16);
245 thetaCl->SetLineWidth(2);
246 thetaCl->SetTitle(
"");
248 gStyle->SetOptTitle(0);
250 if (mirrorThetaPhi) {
251 for (
int i = 1; i < 18 + 1; i++) {
252 TH1F* hmir = (TH1F*)mirrorThetaPhi->ProjectionZ(TString::Format(
"hmir_%d", i), i, i, 1, 10000);
253 hmir->SetTitle(TString::Format(
"mirror %d", i));
254 if (hmir->GetEntries() > 0) hmir->Scale(theta->GetEntries() / hmir->GetEntries());
256 hmir->SetLineWidth(2);
257 int iplot = (i - 1) / 2;
258 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));}
260 hmir->SetLineColor(2); hmir->Draw(
"sames hist");
261 leg[iplot]->AddEntry(hmir, TString::Format(
"mirror %d", i));
267 gStyle->SetOptTitle(1);
271 if (chDigit != NULL && nevt) chDigit->Scale(1. / nevt);
273 chHit->Scale(1. / nevt);
274 flash->Scale(1. / nevt);
276 int nhot = 0, ndead = 0;
277 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);
278 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);
279 TH2F* deadCh =
new TH2F(
"arich_dead",
"Number of channels in APD with no hits", 42, 0.5, 42.5, 40, 0.5, 40.5);
280 TH2F* falseCh =
new TH2F(
"arich_false",
"Number of wrongly masked channels in APD (masked but not dead/hot)", 42, 0.5, 42.5, 40,
283 TH1F* occ =
new TH1F(
"arich_occ",
"nhits / nevt for all channels; nhits/nevt;# of chn", 500, 0, 0.005);
286 if (chDigit != NULL) {
287 double hotlim = 0.005;
288 for (
int i = 0; i < chDigit->GetNbinsX(); i++) {
289 int hapd = i / 144 + 1;
int chip = (i % 144) / 36 + 1;
290 int binx = (
hapd - 1) % 42 + 1;
int biny = ((
hapd - 1) / 42) * 4 + chip;
291 if (chDigit->GetBinContent(i + 1) > hotlim) { hotCh->Fill(binx, biny); nhot++;}
292 if (chDigit->GetBinContent(i + 1) == 0) {
293 deadCh->Fill(binx, biny);
294 if (hapdDigit->GetBinContent(
hapd) != 0) ndead++;
296 if (chHit->GetBinContent(i + 1) == 0 && chDigit->GetBinContent(i + 1) < hotlim
297 && chDigit->GetBinContent(i + 1) > 0.00002) falseCh->Fill(binx, biny);
298 if (chHit->GetBinContent(i + 1) > hotlim) hotCh1->Fill(binx, biny);
299 occ->Fill(chHit->GetBinContent(i + 1));
302 for (
int i = 0; i < hapdDigit->GetNbinsX(); i++) {
303 if (hapdDigit->GetBinContent(i + 1) == 0) ndeadHapd++;
315 pflash->Draw(
"colz");
322 hotCh->Draw(
"colz text");
324 deadCh->Draw(
"colz text");
326 hotCh1->Draw(
"colz text");
328 falseCh->Draw(
"colz text");
330 for (
int i = 0; i < 42; i++) {
331 double x1 = i + 0.5 + 1;
332 TLine* line =
new TLine(x1, 0.5, x1, 40.5);
338 for (
int i = 0; i < 40; i++) {
339 double y1 = i + 0.5 + 1;
340 TLine* line =
new TLine(0.5, y1, 42.5, y1);
341 if ((i + 1) % 4 == 0) line->SetLineColor(2);
342 else line->SetLineColor(15);
349 bits->SetLineWidth(2);
350 bits->SetLineColor(2);
351 bits->SetOption(
"hist");
352 bits->SetFillStyle(3010);
353 bits->SetFillColor(3);
355 hitsPerTrack->SetLineWidth(2);
356 hitsPerTrack->SetLineColor(2);
357 hitsPerTrack->SetOption(
"hist");
358 hitsPerEvent->SetLineWidth(2);
359 hitsPerEvent->SetLineColor(2);
360 hitsPerEvent->SetOption(
"hist");
363 m_c_main->cd(2); bits->Draw(); bits->GetYaxis()->SetTitleOffset(0.5);
365 m_c_main->cd(4); hitsPerTrack->Draw();
366 m_c_main->cd(5); hitsPerEvent->Draw();
368 if (thetaPhi != NULL) thetaPhi->Draw(
"colz");
372 m_monObj->
setVariable(
"hitsPerEvent", hitsPerEvent ? hitsPerEvent->GetMean() : 0, hitsPerEvent ? hitsPerEvent->GetMeanError() : -1);
375 B2DEBUG(20,
"DQMHistAnalysisARICHMonObj : endRun called");
381 B2DEBUG(20,
"terminate called");