source: trunk/MagicSoft/Mars/mtemp/mifae/macros/alpha_plot.C@ 4308

Last change on this file since 4308 was 3947, checked in by rico, 21 years ago
*** empty log message ***
File size: 27.8 KB
Line 
1Double_t ChiSquareNDof(TH1D *h1, TH1D *h2)
2{
3 Double_t chiq = 0.;
4 Double_t chi;
5 Double_t error;
6 Int_t nbinsnozero = 0;
7
8 Int_t nbins = h1->GetNbinsX();
9 if (nbins != h2->GetNbinsX() || nbins == 0)
10 return -1;
11
12 for (UInt_t bin=1; bin<=nbins; bin++)
13 {
14 error = sqrt(h1->GetBinError(bin)*h1->GetBinError(bin) +
15 h2->GetBinError(bin)*h2->GetBinError(bin));
16 if (error != 0)
17 {
18 chi = (h1->GetBinContent(bin)-h2->GetBinContent(bin))/error;
19 chiq += chi*chi;
20 nbinsnozero++;
21 }
22 }
23
24 return chiq/nbinsnozero;
25}
26
27//void alpha_plot(TString f_on_name = "../HillasFiles/20040319_Mrk421_30_15.KDummy*.root",
28void alpha_plot(TString f_on_name = "../HillasFiles/20040319_OffMrk421_30_15.KDummy*.root",
29 TString f_off_name = "../HillasFiles/20040319_OffMrk421_30_15.KDummy*.root",
30 TString f_src_name = "../HillasFiles/20040319_OffMrk421.fake.pos")
31/*void alpha_plot(TString f_on_name = "../HillasFiles/mrk421OnMisp3015*.root",
32 TString f_off_name = "../HillasFiles/mrk421OffMisp3015*.root",
33 TString f_src_name = "../HillasFiles/20040215_Mrk421.pos")
34*/
35{
36
37 const UInt_t numEntries = 100000000;
38
39 //cuts
40 Float_t sizemin = 500.; //[ADC]
41 Float_t sizemax = 10000000000.; //[ADC]
42 Float_t widthmin = 0.;
43 Float_t widthmax = 0.8;
44 Float_t lengthmin = 0.;
45 Float_t lengthmax = 0.8;
46 Float_t distmin = 0.;
47 Float_t distmax = 2.;
48 Float_t alphamin = 0.;
49 Float_t alphamax = 90.;
50
51 //integration
52 Float_t sigexccmin = 0.;
53 Float_t sigexccmax = 30.;
54 Float_t bkgnormmin = 0.;
55 Float_t bkgnormmax = 90.;
56
57 gStyle->SetOptStat(111111);
58 gStyle->SetOptFit();
59
60 //
61 // Make a loop only for the ON data:
62 //
63
64 MParList plist_on;
65 MTaskList tlist_on;
66 plist_on.AddToList(&tlist_on);
67
68 // ON containers
69 MGeomCamMagic geomcam;
70 MSrcPosCam source_on;
71 MHillas hillas;
72 MHillasSrc hillasscr;
73
74 plist_on.AddToList(&geomcam);
75 plist_on.AddToList(&source_on);
76 plist_on.AddToList(&hillas);
77 plist_on.AddToList(&hillasscr);
78
79 //create some 1-dim histo to test only for the ON distribution of dist, width , length, size...
80 MH3 hDist_on("MHillasSrc.fDist/315.");
81 hDist_on.SetName("Dist_on");
82 plist_on.AddToList(&hDist_on);
83 MBinning binsDist_on("BinningDist_on");
84 Int_t nbins_Dist = 20;
85 Float_t min_Dist = 0.;
86 Float_t max_Dist = distmax*1.2;
87 binsDist_on.SetEdges(nbins_Dist, min_Dist, max_Dist);
88 plist_on.AddToList(&binsDist_on);
89
90 MH3 hWidth_on("MHillas.fWidth/315.");
91 hWidth_on.SetName("Width_on");
92 plist_on.AddToList(&hWidth_on);
93 MBinning binsWidth_on("BinningWidth_on");
94 Int_t nbins_Width = 20;
95 Float_t min_Width = 0.;
96 Float_t max_Width = widthmax*1.2;
97 binsWidth_on.SetEdges(nbins_Width, min_Width, max_Width);
98 plist_on.AddToList(&binsWidth_on);
99
100 MH3 hLength_on("MHillas.fLength/315.");
101 hLength_on.SetName("Length_on");
102 plist_on.AddToList(&hLength_on);
103 MBinning binsLength_on("BinningLength_on");
104 Int_t nbins_Length = 20;
105 Float_t min_Length = 0.;
106 Float_t max_Length = lengthmax*1.2;
107 binsLength_on.SetEdges(nbins_Length, min_Length, max_Length);
108 plist_on.AddToList(&binsLength_on);
109
110 MH3 hSize_on("log10(MHillas.fSize)");
111 hSize_on.SetName("Size_on");
112 plist_on.AddToList(&hSize_on);
113 MBinning binsSize_on("BinningSize_on");
114 Int_t nbins_Size = 60;
115 Float_t min_Size = log10(sizemin)*0.8;
116 Float_t max_Size = log10(1000000)*1.2;
117 binsSize_on.SetEdges(nbins_Size, min_Size, max_Size);
118 plist_on.AddToList(&binsSize_on);
119
120 //create a histo to fill the alpha values: one alpha plot form 0 to +90 deg in abs value
121 MH3 hAlpha_on_abs("abs(MHillasSrc.fAlpha)");
122 hAlpha_on_abs.SetName("Alpha_on_abs");
123 plist_on.AddToList(&hAlpha_on_abs);
124 MBinning binsAlpha_on_abs("BinningAlpha_on_abs");
125 Int_t nbins_abs = 9;
126 Float_t minalpha_abs = 0.;
127 Float_t maxalpha_abs =90.;
128 binsAlpha_on_abs.SetEdges(nbins_abs, minalpha_abs, maxalpha_abs);
129 plist_on.AddToList(&binsAlpha_on_abs);
130
131 //create a histo to fill the alpha values: one alpha plot form -90 to +90 deg.
132 MH3 hAlpha_on("MHillasSrc.fAlpha");
133 hAlpha_on.SetName("Alpha_on");
134 plist_on.AddToList(&hAlpha_on);
135 MBinning binsAlpha_on("BinningAlpha_on");
136 Int_t nbins = nbins_abs*2;
137 Float_t minalpha = -90.;
138 Float_t maxalpha = 90.;
139 binsAlpha_on.SetEdges(nbins, minalpha, maxalpha);
140 plist_on.AddToList(&binsAlpha_on);
141
142
143 MH3 hSrcPos_on("MSrcPosCam.fX","MSrcPosCam.fY");
144 hSrcPos_on.SetName("SrcPos_on");
145 plist_on.AddToList(&hSrcPos_on);
146 MBinning binsSrcPos_onX("BinningSrcPos_onX");
147 MBinning binsSrcPos_onY("BinningSrcPos_onY");
148 Int_t nbins_srcpos = 400;
149 Float_t minsrcpos = -600.;
150 Float_t maxsrcpos = 600.;
151 binsSrcPos_onX.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
152 binsSrcPos_onY.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
153 plist_on.AddToList(&binsSrcPos_onX);
154 plist_on.AddToList(&binsSrcPos_onY);
155
156 MH3 hDAQEvtNumber_on("MRawEvtHeader.fDAQEvtNumber");
157 hDAQEvtNumber_on.SetName("DAQEvtNumber_on");
158 plist_on.AddToList(&hDAQEvtNumber_on);
159 MBinning binsDAQEvtNumber_onX("BinningDAQEvtNumber_onX");
160 Int_t nbins_evtnum = 1000;
161 Float_t minevtnum = 0.;
162 Float_t maxevtnum = 1000.;
163 binsDAQEvtNumber_onX.SetEdges(nbins_evtnum,minevtnum,maxevtnum);
164 plist_on.AddToList(&binsDAQEvtNumber_onX);
165
166 //
167 //tasks
168 //
169
170 MReadTree read_on("Parameters", f_on_name);
171 read_on.DisableAutoScheme();
172
173
174 //cuts
175 TString sizestr = "MHillas.fSize < ";
176 sizestr += sizemin;
177 sizestr += " || ";
178 sizestr += "MHillas.fSize > ";
179 sizestr += sizemax;
180 MF sizefilter(sizestr);
181
182 TString widthstr = "{MHillas.fWidth/315.} < ";
183 widthstr += widthmin;
184 widthstr += " || ";
185 widthstr += "{MHillas.fWidth/315.} > ";
186 widthstr += widthmax;
187 MF widthfilter(widthstr);
188
189 TString lengthstr = "{MHillas.fLength/315.} < ";
190 lengthstr += lengthmin;
191 lengthstr += " || ";
192 lengthstr += "{MHillas.fLength/315.} > ";
193 lengthstr += lengthmax;
194 MF lengthfilter(lengthstr);
195
196 TString diststr = "{MHillasSrc.fDist/315.} < ";
197 diststr += distmin;
198 diststr += " || ";
199 diststr += "{MHillasSrc.fDist/315.} > ";
200 diststr += distmax;
201 MF distfilter(diststr);
202
203 TString alphastr = "{abs(MHillasSrc.fAlpha)} < ";
204 alphastr += alphamin;
205 alphastr += " || ";
206 alphastr += "{abs(MHillasSrc.fAlpha)} > ";
207 alphastr += alphamax;
208 MF alphafilter(alphastr);
209
210 MF evenfilter("{MRawEvtHeader.fDAQEvtNumber%3}<0.5");
211 MF oddfilter("{MRawEvtHeader.fDAQEvtNumber%3}>0.5");
212
213 MContinue cont_size(&sizefilter);
214 MContinue cont_width(&widthfilter);
215 MContinue cont_length(&lengthfilter);
216 MContinue cont_dist(&distfilter);
217 MContinue cont_alpha(&alphafilter);
218 MContinue cont_even(&evenfilter);
219 MContinue cont_odd(&oddfilter);
220
221 MSrcPosFromFile srccalc(f_src_name);
222
223 MHillasSrcCalc csrc_on;
224
225 // fill all histograms
226 MFillH falpha_on_abs(&hAlpha_on_abs);
227 MFillH falpha_on(&hAlpha_on);
228 MFillH fdist_on(&hDist_on);
229 MFillH fwidth_on(&hWidth_on);
230 MFillH flength_on(&hLength_on);
231 MFillH fsize_on(&hSize_on);
232 MFillH fsrcpos_on(&hSrcPos_on);
233 MFillH fevtnum_on(&hDAQEvtNumber_on);
234
235
236 // prints
237 MPrint pevent("MRawEvtHeader");
238 MPrint phillas("MHillas");
239 MPrint phillassrc("MHillasSrc");
240 MPrint psrcpos("MSrcPosCam");
241
242 //tasklist
243 tlist_on.AddToList(&read_on);
244 tlist_on.AddToList(&srccalc);
245 tlist_on.AddToList(&csrc_on);
246 tlist_on.AddToList(&fsrcpos_on);
247 tlist_on.AddToList(&cont_odd);
248 tlist_on.AddToList(&cont_size);
249 tlist_on.AddToList(&cont_width);
250 tlist_on.AddToList(&cont_length);
251 tlist_on.AddToList(&cont_dist);
252 tlist_on.AddToList(&cont_alpha);
253 tlist_on.AddToList(&falpha_on_abs);
254 tlist_on.AddToList(&falpha_on);
255 tlist_on.AddToList(&fdist_on);
256 tlist_on.AddToList(&fwidth_on);
257 tlist_on.AddToList(&flength_on);
258 tlist_on.AddToList(&fsize_on);
259 tlist_on.AddToList(&fevtnum_on);
260
261 // Create and setup the eventloop
262 MEvtLoop loop_on;
263 loop_on.SetParList(&plist_on);
264 //loop_on.SetDisplay(display);
265
266 MProgressBar bar;
267 loop_on.SetProgressBar(&bar);
268
269 if (!loop_on.Eventloop(numEntries))
270 return;
271
272 tlist_on.PrintStatistics();
273
274 //
275 // Make a loop only for the OFF data:
276 //
277
278 MParList plist_off;
279 MTaskList tlist_off;
280 plist_off.AddToList(&tlist_off);
281
282 MSrcPosCam source_off;
283
284 plist_off.AddToList(&geomcam);
285 plist_off.AddToList(&source_off);
286 plist_off.AddToList(&hillas);
287 plist_off.AddToList(&hillasscr);
288
289 //create some 1-dim histo to test only for the OFF distribution of dist, width , length, size...
290 MH3 hDist_off("MHillasSrc.fDist/315.");
291 hDist_off.SetName("Dist_off");
292 plist_off.AddToList(&hDist_off);
293 MBinning binsDist_off("BinningDist_off");
294 binsDist_off.SetEdges(nbins_Dist, min_Dist, max_Dist);
295 plist_off.AddToList(&binsDist_off);
296
297 MH3 hWidth_off("MHillas.fWidth/315.");
298 hWidth_off.SetName("Width_off");
299 plist_off.AddToList(&hWidth_off);
300 MBinning binsWidth_off("BinningWidth_off");
301 binsWidth_off.SetEdges(nbins_Width, min_Width, max_Width);
302 plist_off.AddToList(&binsWidth_off);
303
304 MH3 hLength_off("MHillas.fLength/315.");
305 hLength_off.SetName("Length_off");
306 plist_off.AddToList(&hLength_off);
307 MBinning binsLength_off("BinningLength_off");
308 binsLength_off.SetEdges(nbins_Length, min_Length, max_Length);
309 plist_off.AddToList(&binsLength_off);
310
311 MH3 hSize_off("log10(MHillas.fSize)");
312 hSize_off.SetName("Size_off");
313 plist_off.AddToList(&hSize_off);
314 MBinning binsSize_off("BinningSize_off");
315 binsSize_off.SetEdges(nbins_Size, min_Size, max_Size);
316 plist_off.AddToList(&binsSize_off);
317
318 //create a histo to fill the alpha values: from 0 to 90 deg -> abs value
319 MH3 hAlpha_off_abs("abs(MHillasSrc.fAlpha)");
320 hAlpha_off_abs.SetName("Alpha_off_abs");
321 plist_off.AddToList(&hAlpha_off_abs);
322 MBinning binsAlpha_off_abs("BinningAlpha_off_abs");
323 binsAlpha_off_abs.SetEdges(nbins_abs, minalpha_abs, maxalpha_abs);
324 plist_off.AddToList(&binsAlpha_off_abs);
325
326 //create a histo to fill the alpha values: from -90 to 90 deg
327 MH3 hAlpha_off("MHillasSrc.fAlpha");
328 hAlpha_off.SetName("Alpha_off");
329 plist_off.AddToList(&hAlpha_off);
330 MBinning binsAlpha_off("BinningAlpha_off");
331 binsAlpha_off.SetEdges(nbins, minalpha, maxalpha);
332 plist_off.AddToList(&binsAlpha_off);
333
334
335 MH3 hSrcPos_off("MSrcPosCam.fX","MSrcPosCam.fY");
336 hSrcPos_off.SetName("SrcPos_off");
337 plist_off.AddToList(&hSrcPos_off);
338 MBinning binsSrcPos_offX("BinningSrcPos_offX");
339 MBinning binsSrcPos_offY("BinningSrcPos_offY");
340 binsSrcPos_offX.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
341 binsSrcPos_offY.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
342 plist_off.AddToList(&binsSrcPos_offX);
343 plist_off.AddToList(&binsSrcPos_offY);
344
345 MH3 hDAQEvtNumber_off("MRawEvtHeader.fDAQEvtNumber");
346 hDAQEvtNumber_off.SetName("DAQEvtNumber_off");
347 plist_off.AddToList(&hDAQEvtNumber_off);
348 MBinning binsDAQEvtNumber_offX("BinningDAQEvtNumber_offX");
349 Int_t nbins_evtnum = 100;
350 Float_t minevtnum = 0.;
351 Float_t maxevtnum = 100.;
352 binsDAQEvtNumber_offX.SetEdges(nbins_evtnum,minevtnum,maxevtnum);
353 plist_off.AddToList(&binsDAQEvtNumber_offX);
354
355 //tasks
356 MReadTree read_off("Parameters", f_off_name);
357 read_off.DisableAutoScheme();
358
359 srccalc.SetMode(MSrcPosFromFile::kOff);
360
361 MHillasSrcCalc csrc_off;
362
363 // fill all histograms
364 MFillH falpha_off_abs(&hAlpha_off_abs);
365 MFillH falpha_off(&hAlpha_off);
366 MFillH fdist_off(&hDist_off);
367 MFillH fwidth_off(&hWidth_off);
368 MFillH flength_off(&hLength_off);
369 MFillH fsize_off(&hSize_off);
370 MFillH fsrcpos_off(&hSrcPos_off);
371 MFillH fevtnum_off(&hDAQEvtNumber_off);
372
373 //tasklist
374 tlist_off.AddToList(&read_off);
375 tlist_off.AddToList(&srccalc);
376 tlist_off.AddToList(&csrc_off);
377 tlist_off.AddToList(&fsrcpos_off);
378 tlist_off.AddToList(&cont_even);
379 tlist_off.AddToList(&cont_size);
380 tlist_off.AddToList(&cont_width);
381 tlist_off.AddToList(&cont_length);
382 tlist_off.AddToList(&cont_dist);
383 tlist_off.AddToList(&cont_alpha);
384 tlist_off.AddToList(&falpha_off_abs);
385 tlist_off.AddToList(&falpha_off);
386 tlist_off.AddToList(&fdist_off);
387 tlist_off.AddToList(&fwidth_off);
388 tlist_off.AddToList(&flength_off);
389 tlist_off.AddToList(&fsize_off);
390 tlist_off.AddToList(&fevtnum_off);
391
392 // Create and setup the eventloop
393 MEvtLoop loop_off;
394 loop_off.SetParList(&plist_off);
395 //loop_off.SetDisplay(display);
396
397 MProgressBar bar_off;
398 loop_off.SetProgressBar(&bar_off);
399
400 if (!loop_off.Eventloop(numEntries))
401 return;
402
403 tlist_off.PrintStatistics();
404
405 // ############################################################################
406 // look for the histograms
407 // ############################################################################
408
409 TH1F *hist_size_on = (TH1F*)hSize_on.GetHist();
410 TH1F *hist_size_off = (TH1F*)hSize_off.GetHist();
411
412 TH1F *hist_dist_on = (TH1F*)hDist_on.GetHist();
413 TH1F *hist_dist_off = (TH1F*)hDist_off.GetHist();
414
415 TH1F *hist_width_on = (TH1F*)hWidth_on.GetHist();
416 TH1F *hist_width_off = (TH1F*)hWidth_off.GetHist();
417
418 TH1F *hist_length_on = (TH1F*)hLength_on.GetHist();
419 TH1F *hist_length_off = (TH1F*)hLength_off.GetHist();
420
421 TH1F *hist_on_abs = (TH1F*)hAlpha_on_abs.GetHist();
422 TH1F *hist_off_abs = (TH1F*)hAlpha_off_abs.GetHist();
423
424 TH1F *hist_on = (TH1F*)hAlpha_on.GetHist();
425 TH1F *hist_off = (TH1F*)hAlpha_off.GetHist();
426
427
428 // ############################################################################
429 // Calculate significance and excess:
430 // ############################################################################
431
432 Double_t norm_on_abs = (Double_t) hist_on_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
433 Double_t exces_on_abs = (Double_t) hist_on_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
434 Double_t norm_off_abs = (Double_t) hist_off_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
435 Double_t exces_off_abs = (Double_t) hist_off_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
436 Double_t norm = norm_on_abs/norm_off_abs;
437
438 char text_tit_alpha[256];
439 sprintf(text_tit_alpha, " Alpha Plot On and Off ");
440 hist_off_abs->SetTitle(text_tit_alpha);
441 hist_on_abs->SetTitle(text_tit_alpha);
442
443 Double_t excess = exces_on_abs - exces_off_abs*norm;
444 Double_t sign = excess / sqrt( exces_on_abs + norm*norm*exces_off_abs );
445 Double_t int_off = (Double_t) hist_off_abs->Integral(1, 18);
446 int hist_on_entries = (int) hist_on_abs->GetEntries();
447 int hist_off_entries = (int) hist_off_abs->GetEntries();
448
449 cout << "---> Normalization F factor =\t" << norm <<endl;
450 cout << "---> Excess =\t\t\t" << excess <<endl;
451 cout << "---> Significancia =\t\t" << sign <<endl;
452 cout << "---> entries on =\t\t" << hist_on_entries <<endl;
453 cout << "---> entries off =\t\t" << hist_off_entries <<endl;
454 cout << "---> integral off =\t\t" << int_off <<endl;
455
456 Float_t shiftx;
457
458 //
459 //Create the display -> from now on, all histos are plotted
460 MStatusDisplay *display = new MStatusDisplay;
461 display->SetUpdateTime(3000);
462 display->Resize(850,700);
463
464 // ############################################################################
465 // Draw SIZE
466 // ############################################################################
467 display->AddTab("SIZE");
468
469 gPad->cd();
470
471 gPad->SetLogy();
472 hist_size_on->Sumw2();
473 hist_size_off->Sumw2();
474 hist_size_off->Scale(norm);
475 hist_size_on->SetLineColor(kBlack);
476 hist_size_on->SetMarkerStyle(21);
477 hist_size_on->SetMarkerSize(0.7);
478 hist_size_on->SetMarkerColor(kBlack);
479 hist_size_off->SetFillColor(46);
480 hist_size_off->SetLineColor(46);
481 hist_size_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
482 hist_size_off->SetMinimum(0.1);
483 hist_size_on->SetMinimum(0.1);
484 hist_size_on->SetTitle("SIZE distribution");
485 hist_size_off->SetTitle("SIZE distribution");
486
487 hist_size_on->DrawCopy("E1P");
488
489 // move stat box to make them all visible
490 gPad->Update();
491 TPaveStats* pavs_on_size = (TPaveStats*) hist_size_on->GetListOfFunctions()->FindObject("stats");
492 if(pavs_on_size){
493 shiftx = pavs_on_size->GetX2NDC() - pavs_on_size->GetX1NDC();
494 pavs_on_size->SetX1NDC(pavs_on_size->GetX1NDC() - shiftx);
495 pavs_on_size->SetX2NDC(pavs_on_size->GetX2NDC() - shiftx);
496 }
497 gPad->Modified();
498 gPad->Update();
499
500 hist_size_off->DrawCopy("HISTSAME");
501 hist_size_off->DrawCopy("ESAME");
502
503 gPad->Modified();
504 gPad->Update();
505
506 Double_t chisize = ChiSquareNDof((TH1D*)hist_size_on,(TH1D*)hist_size_off);
507
508 Double_t x_label_pos = log10(1000000)*0.7;
509 Double_t y_label_pos = log10((hist_size_on->GetBinContent(hist_size_on->GetMaximumBin()))/2.);
510 Double_t textsize = 0.03;
511
512 char text_size[256];
513 sprintf(text_size,"ChiSquare/NDof = %4.2f",chisize);
514
515 TLatex *tsize = new TLatex(x_label_pos, y_label_pos, text_size);
516 tsize->SetTextSize(textsize);
517// tsize->Draw();
518
519 gPad->Modified();
520 gPad->Update();
521
522 // ############################################################################
523 // DrawCopy DIST
524 // ############################################################################
525 display->AddTab("DIST");
526
527 gPad->cd();
528
529 hist_dist_on->Sumw2();
530 hist_dist_off->Sumw2();
531 hist_dist_off->Scale(norm);
532 hist_dist_on->SetLineColor(kBlack);
533 hist_dist_on->SetMarkerStyle(21);
534 hist_dist_on->SetMarkerSize(0.7);
535 hist_dist_on->SetMarkerColor(kBlack);
536 hist_dist_off->SetFillColor(46);
537 hist_dist_off->SetLineColor(46);
538 hist_dist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
539 hist_dist_off->SetMinimum(0.);
540 hist_dist_on->SetTitle("DIST distribution");
541 hist_dist_off->SetTitle("DIST distribution");
542
543 hist_dist_on->DrawCopy("E1P");
544
545 // move stat box to make them all visible
546 gPad->Update();
547 TPaveStats* pavs_on_dist = (TPaveStats*) hist_dist_on->GetListOfFunctions()->FindObject("stats");
548 if(pavs_on_dist){
549 shiftx = pavs_on_dist->GetX2NDC() - pavs_on_dist->GetX1NDC();
550 pavs_on_dist->SetX1NDC(pavs_on_dist->GetX1NDC() - shiftx);
551 pavs_on_dist->SetX2NDC(pavs_on_dist->GetX2NDC() - shiftx);
552 }
553 gPad->Modified();
554 gPad->Update();
555
556 hist_dist_off->DrawCopy("HISTSAME");
557 hist_dist_off->DrawCopy("ESAME");
558 hist_dist_on->DrawCopy("E1PSAME");
559
560 Double_t chidist = ChiSquareNDof((TH1D*)hist_dist_on,(TH1D*)hist_dist_off);
561
562 x_label_pos = distmax*0.7;
563 y_label_pos = hist_dist_on->GetBinContent(hist_dist_on->GetMaximumBin())/2.;
564
565 char text_dist[256];
566 sprintf(text_size,"ChiSquare/NDof = %4.2f",chidist);
567
568 TLatex *tdist = new TLatex(x_label_pos, y_label_pos, text_dist);
569 tdist->SetTextSize(textsize);
570// tdist->Draw();
571
572 gPad->Modified();
573 gPad->Update();
574
575 // ############################################################################
576 // DrawCopy WIDTH
577 // ############################################################################
578 display->AddTab("WIDTH");
579
580 gPad->cd();
581
582 hist_width_off->Sumw2();
583 hist_width_off->Scale(norm);
584 hist_width_on->SetLineColor(kBlack);
585 hist_width_on->SetMarkerStyle(21);
586 hist_width_on->SetMarkerSize(0.7);
587 hist_width_on->SetMarkerColor(kBlack);
588 hist_width_off->SetFillColor(46);
589 hist_width_off->SetLineColor(46);
590 hist_width_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
591 hist_width_off->SetMinimum(0.);
592 hist_width_on->SetTitle("WIDTH distribution");
593 hist_width_off->SetTitle("WIDTH distribution");
594
595 hist_width_on->DrawCopy("E1P");
596
597 // move stat box to make them all visible
598 gPad->Update();
599 TPaveStats* pavs_on_width = (TPaveStats*) hist_width_on->GetListOfFunctions()->FindObject("stats");
600 if(pavs_on_width){
601 shiftx = pavs_on_width->GetX2NDC() - pavs_on_width->GetX1NDC();
602 pavs_on_width->SetX1NDC(pavs_on_width->GetX1NDC() - shiftx);
603 pavs_on_width->SetX2NDC(pavs_on_width->GetX2NDC() - shiftx);
604 }
605 gPad->Modified();
606 gPad->Update();
607
608 hist_width_off->DrawCopy("HISTSAME");
609 hist_width_off->DrawCopy("ESAME");
610 hist_width_on->DrawCopy("E1PSAME");
611
612 Double_t chiwidth = ChiSquareNDof((TH1D*)hist_width_on,(TH1D*)hist_width_off);
613
614 x_label_pos = widthmax*0.7;
615 y_label_pos = hist_width_on->GetBinContent(hist_width_on->GetMaximumBin())/2.;
616
617 char text_width[256];
618 sprintf(text_size,"ChiSquare/NDof = %4.2f",chiwidth);
619
620 TLatex *twidth = new TLatex(x_label_pos, y_label_pos, text_width);
621 twidth->SetTextSize(textsize);
622// twidth->Draw();
623
624 gPad->Modified();
625 gPad->Update();
626
627 // ############################################################################
628 // DrawCopy LENGTH
629 // ############################################################################
630 display->AddTab("LENGTH");
631
632 gPad->cd();
633
634 hist_length_on->Sumw2();
635 hist_length_off->Sumw2();
636 hist_length_off->Scale(norm);
637 hist_length_on->SetLineColor(kBlack);
638 hist_length_on->SetMarkerStyle(21);
639 hist_length_on->SetMarkerSize(0.7);
640 hist_length_on->SetMarkerColor(kBlack);
641 hist_length_off->SetFillColor(46);
642 hist_length_off->SetLineColor(46);
643 hist_length_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
644 hist_length_off->SetMinimum(0.);
645 hist_length_on->SetTitle("LENGTH distribution");
646 hist_length_off->SetTitle("LENGTH distribution");
647
648 hist_length_on->DrawCopy("E1P");
649
650 // move stat box to make them all visible
651 gPad->Update();
652 TPaveStats* pavs_on_length = (TPaveStats*) hist_length_on->GetListOfFunctions()->FindObject("stats");
653 if(pavs_on_length){
654 shiftx = pavs_on_length->GetX2NDC() - pavs_on_length->GetX1NDC();
655 pavs_on_length->SetX1NDC(pavs_on_length->GetX1NDC() - shiftx);
656 pavs_on_length->SetX2NDC(pavs_on_length->GetX2NDC() - shiftx);
657 }
658 gPad->Modified();
659 gPad->Update();
660
661 hist_length_off->DrawCopy("HISTSAME");
662 hist_length_off->DrawCopy("ESAME");
663 hist_length_on->DrawCopy("E1PSAME");
664
665 Double_t chilength = ChiSquareNDof((TH1D*)hist_length_on,(TH1D*)hist_length_off);
666
667 x_label_pos = lengthmax*0.7;
668 y_label_pos = hist_length_on->GetBinContent(hist_length_on->GetMaximumBin())/2.;
669
670 char text_length[256];
671 sprintf(text_size,"ChiSquare/NDof = %4.2f",chilength);
672
673 TLatex *tlength = new TLatex(x_label_pos, y_label_pos, text_length);
674 tlength->SetTextSize(textsize);
675// tlength->Draw();
676
677 gPad->Modified();
678 gPad->Update();
679
680 // ############################################################################
681 // DrawCopy normalized ALPHA plot
682 // ############################################################################
683 display->AddTab("ALPHA");
684
685 gPad->cd();
686
687 hist_on_abs->Sumw2();
688 hist_off_abs->SetStats(0);
689 hist_off_abs->Sumw2();
690 hist_off_abs->Scale(norm);
691 hist_on_abs->SetStats(0); //-> Do NOT show the legend with statistics
692 hist_on_abs->SetLineColor(kBlack);
693 hist_on_abs->SetMarkerStyle(21);
694 //hist_on_abs->SetMarkerSize();
695 hist_on_abs->SetMarkerColor(kBlack);
696 hist_on_abs->SetMarkerSize(0.7);
697 hist_off_abs->SetFillColor(46);
698 hist_off_abs->SetLineColor(46);
699 hist_off_abs->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
700 hist_off_abs->SetMinimum(0.);
701 hist_on_abs->SetTitle("Alpha plot");
702 hist_off_abs->SetTitle("Alpha plot");
703
704
705 hist_on_abs->DrawCopy("E1P");
706 hist_off_abs->DrawCopy("HISTSAME");
707 hist_off_abs->DrawCopy("ESAME");
708 hist_on_abs->DrawCopy("E1PSAME");
709
710
711 //draw the LEGEND with excess and significance values in the alpha plot:
712 char text_Fnorm[256], text_excess[256], text_sign[256];
713 char text_entries_on[256], text_entries_off[256], text_integral_off[256];
714 int hist_on_entries = (int) hist_on_abs->GetEntries();
715 int hist_off_entries = (int) hist_off_abs->GetEntries();
716 sprintf(text_Fnorm, " F norm = %.3f", norm);
717 sprintf(text_excess, " Excess = %.3f", excess);
718 sprintf(text_sign, " Significance = %.3f", sign);
719 sprintf(text_entries_on, " Entries ON = %d", hist_on_entries);
720 sprintf(text_entries_off, " Entries OFF = %d", hist_off_entries);
721 sprintf(text_integral_off," Integral OFF = %d", int_off);
722
723 x_label_pos = alphamax*0.7;
724 y_label_pos = (hist_on_abs->GetBinContent(hist_on_abs->GetMaximumBin()))/1.6; //2.;
725 Double_t y_label_step = y_label_pos / 8.;
726
727 TLatex *t0 = new TLatex(x_label_pos, y_label_pos - y_label_step*0, text_Fnorm);
728 t0->SetTextSize(textsize);
729 t0->Draw();
730 TLatex *t1 = new TLatex(x_label_pos, y_label_pos - y_label_step*1, text_excess);
731 t1->SetTextSize(textsize);
732 t1->Draw();
733 TLatex *t2 = new TLatex(x_label_pos, y_label_pos - y_label_step*2, text_sign);
734 t2->SetTextSize(textsize);
735 t2->Draw();
736 TLatex *t3 = new TLatex(x_label_pos, y_label_pos - y_label_step*3, text_entries_on);
737 t3->SetTextSize(textsize);
738 t3->Draw();
739 TLatex *t4 = new TLatex(x_label_pos, y_label_pos - y_label_step*4, text_entries_off);
740 t4->SetTextSize(textsize);
741 t4->Draw();
742 TLatex *t5 = new TLatex(x_label_pos, y_label_pos - y_label_step*5, text_integral_off);
743 t5->SetTextSize(textsize);
744 t5->Draw();
745
746
747 Double_t chialpha = ChiSquareNDof((TH1D*)hist_on_abs,(TH1D*)hist_off_abs);
748
749 y_label_pos = (hist_on_abs->GetBinContent(hist_on_abs->GetMaximumBin()))/2.;
750
751 char text_alpha[256];
752 sprintf(text_size,"ChiSquare/NDof = %4.2f",chialpha);
753
754 TLatex *talpha = new TLatex(x_label_pos, y_label_pos, text_alpha);
755 talpha->SetTextSize(textsize);
756// talpha->Draw();
757
758 gPad->Modified();
759 gPad->Update();
760
761 // ############################################################################
762 // DrawCopy normalized alpha histos for alpha form -90 to 90 deg.
763 // ############################################################################
764 display->AddTab("ALPHA +-90");
765
766 gPad->cd();
767
768 hist_on->Sumw2();
769 hist_off->SetStats(0);
770 hist_off->Sumw2();
771 hist_off->Scale(norm);
772 hist_off->SetFillColor(46);
773 hist_off->SetLineColor(46);
774 hist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
775 hist_off->SetMinimum(0.);
776 hist_on->SetStats(0); //-> Do NOT show the legend with statistics
777 hist_on->SetLineColor(kBlack);
778 hist_on->SetMarkerStyle(21);
779 hist_on->SetMarkerSize(0.7);
780 hist_on->SetMarkerColor(kBlack);
781 hist_on->SetTitle("Alpha plot form -90 to 90 deg");
782 hist_off->SetTitle("Alpha plot form -90 to 90 deg");
783
784 hist_on->DrawCopy("E1P");
785 hist_off->DrawCopy("HISTSAME");
786 hist_off->DrawCopy("ESAME");
787 hist_on->DrawCopy("E1PSAME");
788
789 Double_t chialpha90 = ChiSquareNDof((TH1D*)hist_on,(TH1D*)hist_off);
790
791 x_label_pos = alphamax*0.5;
792 y_label_pos = hist_on->GetBinContent(hist_on->GetMaximumBin())/2.;
793
794 char text_alpha90[256];
795 sprintf(text_alpha90,"ChiSquare/NDof = %4.2f",chialpha90);
796
797 TLatex *talpha90 = new TLatex(x_label_pos, y_label_pos, text_alpha90);
798 talpha90->SetTextSize(textsize);
799// talpha90->Draw();
800
801 gPad->Update();
802 gPad->Modified();
803
804
805 cout << "---> ChiSquare/NDof [Size] =\t\t" << chisize << endl;
806 cout << "---> ChiSquare/NDof [Dist] =\t\t" << chidist << endl;
807 cout << "---> ChiSquare/NDof [Width] =\t\t" << chiwidth << endl;
808 cout << "---> ChiSquare/NDof [Length] =\t\t" << chilength << endl;
809 cout << "---> ChiSquare/NDof [Abs(Alpha)] =\t" << chialpha << endl;
810 cout << "---> ChiSquare/NDof [Alpha] =\t\t" << chialpha90 << endl;
811
812
813 display->AddTab("SRCPOS ON");
814 TH2F *hist_srcpos_on = (TH2F*)hSrcPos_on.GetHist();
815 hist_srcpos_on->DrawCopy("BOX");
816
817 display->AddTab("SRCPOS OFF");
818 TH2F *hist_srcpos_off = (TH2F*)hSrcPos_off.GetHist();
819 hist_srcpos_off->DrawCopy("BOX");
820
821 display->AddTab("EVTNUM ON");
822 TH1F *hist_evtnum_on = (TH1F*)hDAQEvtNumber_on.GetHist();
823 hist_evtnum_on->DrawCopy();
824
825 display->AddTab("EVTNUM OFF");
826 TH1F *hist_evtnum_off = (TH1F*)hDAQEvtNumber_off.GetHist();
827 hist_evtnum_off->DrawCopy();
828
829 cout << "Done!!" <<endl;
830
831}
832
833
834
Note: See TracBrowser for help on using the repository browser.