source: trunk/MagicSoft/Mars/mtemp/mpisa/macros/first_ana.C@ 6230

Last change on this file since 6230 was 4055, checked in by stamerra, 21 years ago
*** empty log message ***
File size: 4.4 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Alessio Piccioli, 04/2004 <mailto:alessio.piccioli@pi.infn.it>
19! Author(s): Antonio Stamerra, 04/2004 <mailto:antonio.stamerra@pi.infn.it>
20!
21! Copyright: MAGIC Software Development, 2000-2004
22!
23!
24\* ======================================================================== */
25
26///////////////////////////////////////////////////////////////////////////
27//
28// first_ana.C
29// =============
30//
31// This macro produces a ON/OFF plot using the alpha HillasSrc branch
32// taken from an analysis file produced by the AnalisiHillas.C macro
33// The significance of excess events is also computed (simple calculation,
34// no Li-Ma)
35//
36///////////////////////////////////////////////////////////////////////////
37
38
39Float_t degTomm ( Float_t deg ) {
40 return deg / 57.29577951 * 17000 ;
41}
42
43Int_t first_ana ( Char_t *fNameOn = "crab.root" , Char_t *fNameOff = "offcrab.root" , Float_t minsize = 1000 , Float_t minWdeg = 0.00 , Float_t maxWdeg = 0.125 , Float_t minLdeg = 0.0 , Float_t maxLdeg = 0.26 , Float_t minDdeg = 0.2 , Float_t maxDdeg = 0.8 ) {
44
45 TFile *fileOn = new TFile ( fNameOn , "READ" ) ;
46 TFile *fileOff = new TFile ( fNameOff , "READ" ) ;
47
48 TTree *treeOn = (TTree *) fileOn -> Get ( "Parameters" ) ;
49 TTree *treeOff = (TTree *) fileOff -> Get ( "Parameters" ) ;
50
51 TString title ;
52
53 title = "Abs(Alpha) plot ON-Source" ;
54 TH1D *absalphaOn = new TH1D ( "absalphaOn" , title , 9 , 0 , 90 ) ;
55
56 title = "Abs(Alpha) plot ON-Source" ;
57 TH1D *absalphaOff = new TH1D ( "absalphaOff" , title , 9 , 0 , 90 ) ;
58
59 TString scut ;
60 scut = "MHillas.fSize>" ;
61 scut += minsize ;
62 cout << "CUT ON SIZE: " << scut << endl ;
63 TCut Scut = scut ;
64
65 scut = "" ;
66 scut += degTomm(minWdeg) ;
67 scut += " < MHillas.fWidth && MHillas.fWidth < " ;
68 scut += degTomm(maxWdeg) ;
69 cout << "CUT ON WIDTH: " << scut << endl ;
70 TCut Wcut = scut ;
71
72 scut = "" ;
73 scut += degTomm(minLdeg) ;
74 scut += " < MHillas.fLength && MHillas.fLength < " ;
75 scut += degTomm(maxLdeg) ;
76 cout << "CUT ON LENGTH: " << scut << endl ;
77 TCut Lcut = scut ;
78
79 scut = "" ;
80 scut += degTomm(minDdeg) ;
81 scut += " < MHillasSrc.fDist && MHillasSrc.fDist < " ;
82 scut += degTomm(maxDdeg) ;
83 cout << "CUT ON DIST: " << scut << endl ;
84 TCut Dcut = scut ;
85
86 treeOn -> Draw ( "abs(MHillasSrc.fAlpha)>>absalphaOn" , Scut && Wcut && Lcut && Dcut ) ;
87 treeOff -> Draw ( "abs(MHillasSrc.fAlpha)>>absalphaOff" , Scut && Wcut && Lcut && Dcut ) ;
88 Double_t alpha = absalphaOn -> Integral ( 4 , 9 ) / absalphaOff -> Integral ( 4 , 9 ) ;
89 Double_t evoff = absalphaOff -> Integral ( 1 , 3 ) ;
90
91 absalphaOff -> Scale ( alpha ) ;
92
93 Double_t fakeMax = absalphaOn -> GetMaximum ( ) ;
94 fakeMax *= 1.1 ;
95
96 Double_t fakeMin = absalphaOn -> GetMinimum ( ) ;
97 fakeMin *= 0.8 ;
98
99 TH2D *fake = new TH2D ( "fake" , "Mrk421 Sample B (ON/OFF) 15/02/2004" , 100 , 0 , 90 , 100 , fakeMin , fakeMax ) ;
100 fake -> GetXaxis ( ) -> SetTitle ( "Parameter Alpha (deg)" ) ;
101 fake -> GetYaxis ( ) -> SetTitle ( "NUmber of Events" ) ;
102 fake -> GetYaxis ( ) -> SetTitleOffset ( 1.3 ) ;
103 fake -> SetStats ( 0 ) ;
104
105 TCanvas *c = new TCanvas ( "c" , "Alpha Canvas" , 800 , 600 ) ;
106 c -> SetGridx ( ) ;
107 c -> SetGridy ( ) ;
108
109 absalphaOn -> SetMarkerStyle ( 22 ) ;
110 absalphaOn -> SetMarkerSize ( 2.7 ) ;
111 absalphaOff -> SetFillStyle ( 1001 ) ;
112 absalphaOff -> SetFillColor ( 3 ) ;
113
114 fake -> Draw ( ) ;
115 absalphaOff -> Draw ( "SAME" ) ;
116 absalphaOn -> Draw ( "SAMEE1" ) ;
117
118 Double_t evon = absalphaOn -> Integral ( 1 , 3 ) ;
119
120 cout << endl << "EntriesON:" << absalphaOn -> GetEntries ( ) ;
121 cout << endl << "EntriesOFF:" << absalphaOff -> GetEntries ( ) ;
122 cout << endl << "ON:" << evon << " OFF:" << evoff << " EXCESS:" << evon-evoff*alpha << " SIGMA:" << (evon-evoff*alpha)/TMath::Sqrt(evoff)/alpha << endl << endl ;
123
124}
125
Note: See TracBrowser for help on using the repository browser.