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

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