1 | // The aim of this macro is to show the cuts applied to the
|
---|
2 | // events that survive the g/h separation cuts + the alpha cut.
|
---|
3 | // The macro can be modified easily to show other things...
|
---|
4 |
|
---|
5 | // This program reads a TTree (specified by the user) and
|
---|
6 | // stores the array containing the variables specified by
|
---|
7 | // the user into pointer to arrays. This is done through
|
---|
8 | // the member function TTree::Draw()
|
---|
9 |
|
---|
10 | // Selection rules (cuts) are allowed. In such case, only
|
---|
11 | // the variables of the events that pass the cuts specified are
|
---|
12 | // stored into the arrays.
|
---|
13 |
|
---|
14 |
|
---|
15 | // It works with arrays of pointers
|
---|
16 | // and plot N quantities in the N pads of the same Canvas.
|
---|
17 | // single strings that contain
|
---|
18 | // the quantities to be plotted are used.
|
---|
19 |
|
---|
20 | // This program is an alternative to another (faster?) more
|
---|
21 | // professional way of getting info from a Tree.
|
---|
22 |
|
---|
23 |
|
---|
24 | // As input, this macro needs a root file that is
|
---|
25 | // generated by the SupercutsONOFF programs, which is
|
---|
26 | // the root file containing the TTrees with the needed info.
|
---|
27 |
|
---|
28 | // The user must write
|
---|
29 |
|
---|
30 | // 1) Name of the root file with the info (Path included!!)
|
---|
31 |
|
---|
32 | // 2) Name of the output ps file produced by the macro (with path included!!)
|
---|
33 |
|
---|
34 |
|
---|
35 | gROOT -> Reset();
|
---|
36 |
|
---|
37 | void SCDynamicalSupercutsApplied()
|
---|
38 | {
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | char* RootFile = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt_MC/RootFileDynCuts.root"};
|
---|
44 |
|
---|
45 | char* OutputPsFilename = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt_MC/DynamicalCutsLengthWidthDistApplied.eps"};
|
---|
46 |
|
---|
47 |
|
---|
48 | char* Xaxis = "log(SIZE/[photons])";
|
---|
49 |
|
---|
50 | char* YaxisVector[6] = {"LENGTH UP [\\circ]", "LENGTH LOW [\\circ]",
|
---|
51 | "WIDTH UP [\\circ]", "WIDTH LOW [\\circ]",
|
---|
52 | "DIST UP [\\circ]", "DIST LOW [\\circ]"};
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 |
|
---|
63 | // Name of the root file that contains the Tree
|
---|
64 | char* TreeName = {"SupercutsAppliedTrainONThetaRange0_1570mRad"}; // Name of the Tree that contains the variables that have to plotted
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 | const Int_t NQuantitiesToBePlot = 6;
|
---|
69 |
|
---|
70 | // Write here the quantities to be plot
|
---|
71 |
|
---|
72 | TString QuantitiesToBePlot[NQuantitiesToBePlot] =
|
---|
73 | {"SupercutsApplied.LengthUp:log10(ShowerParameters.Size)",
|
---|
74 | "SupercutsApplied.LengthLow:log10(ShowerParameters.Size)",
|
---|
75 | "SupercutsApplied.WidthUp:log10(ShowerParameters.Size)",
|
---|
76 | "SupercutsApplied.WidthLow:log10(ShowerParameters.Size)",
|
---|
77 | "SupercutsApplied.DistUp:log10(ShowerParameters.Size)",
|
---|
78 | "SupercutsApplied.DistLow:log10(ShowerParameters.Size)"};
|
---|
79 |
|
---|
80 |
|
---|
81 | // Write here the number of rows and columns in the ps file
|
---|
82 |
|
---|
83 | const Int_t Nrows = 2;
|
---|
84 | const Int_t Ncolumns = 3;
|
---|
85 |
|
---|
86 | // Title of Canvas.. not really important...
|
---|
87 |
|
---|
88 | TString CanvasTitle = ("Dynamical cuts in Length, Width and Dist");
|
---|
89 |
|
---|
90 | // 0 for not using and 1 for using Selection cut
|
---|
91 | Int_t UseSelectionCut = 1;
|
---|
92 | // Section rule to be applied in the data to be plotted
|
---|
93 | char* SelectionCut = {"(SupercutsApplied.Hadronness < 0.5) && ShowerParameters.Alpha < 12"};
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 | // Vectors where variables will be stored
|
---|
98 | Int_t ArrayDimension[NQuantitiesToBePlot];
|
---|
99 | Double_t* VarYArray[NQuantitiesToBePlot];
|
---|
100 | Double_t* VarXArray[NQuantitiesToBePlot];
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 | // Vector of pointers to TFile objects and TTree objects that will be used to retrieve
|
---|
106 | // requested info from root file.
|
---|
107 |
|
---|
108 | TFile* FileVector[NQuantitiesToBePlot];
|
---|
109 | TTree* TreeVector[NQuantitiesToBePlot];
|
---|
110 |
|
---|
111 | // Vector of pointers to graph objects where quantities will be plot
|
---|
112 |
|
---|
113 | TGraph* GraphVector[NQuantitiesToBePlot];
|
---|
114 |
|
---|
115 |
|
---|
116 | // Options available for plotting the histo are the following ones:
|
---|
117 | // "prof" -->> Profile
|
---|
118 | // "goff" -->> No draw variables in TTree::Draw()
|
---|
119 | // "" -->> No special option is set
|
---|
120 |
|
---|
121 | char* DrawingOption = {"goff"};
|
---|
122 |
|
---|
123 |
|
---|
124 | TString selection = UseSelectionCut ? SelectionCut : NULL;
|
---|
125 |
|
---|
126 |
|
---|
127 |
|
---|
128 | // Tree is read and stored in dynamic memory pointed by pointer tree.
|
---|
129 |
|
---|
130 | // TFile file (RootFile);
|
---|
131 | // TTree* tree = (TTree*) file.Get(TreeName);
|
---|
132 |
|
---|
133 |
|
---|
134 |
|
---|
135 |
|
---|
136 | // Loop in which arrays are retrieved from root file and
|
---|
137 | // array dimensions (with events surviving the selection)
|
---|
138 | // are retrieved too.
|
---|
139 |
|
---|
140 | for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
|
---|
141 | {
|
---|
142 |
|
---|
143 |
|
---|
144 | FileVector[i] = new TFile(RootFile, "READ");
|
---|
145 |
|
---|
146 | TreeVector[i] = (TTree*) FileVector[i] -> Get(TreeName);
|
---|
147 |
|
---|
148 | // Array dimension of temporal vectors where the variables
|
---|
149 | // that will be plotted are stored can be modify accordingly
|
---|
150 | // with the nnumber of events of the Tree
|
---|
151 |
|
---|
152 | TreeVector[i] -> SetEstimate(TreeVector[i] -> GetEntries());
|
---|
153 |
|
---|
154 | // Requested info is "plotted"
|
---|
155 |
|
---|
156 | TreeVector[i] -> Draw(QuantitiesToBePlot[i].Data(), selection, DrawingOption);
|
---|
157 |
|
---|
158 |
|
---|
159 | // Let's find out the REAL length of the vectors we want
|
---|
160 | // to get from the tree (Selection rules may have removed some events)
|
---|
161 |
|
---|
162 | ArrayDimension[i] = TreeVector[i] -> GetSelectedRows();
|
---|
163 |
|
---|
164 | // Vectors are retrieved
|
---|
165 |
|
---|
166 | VarYArray[i] = TreeVector[i] -> GetV1();
|
---|
167 | VarXArray[i] = TreeVector[i] -> GetV2();
|
---|
168 |
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 |
|
---|
173 | // Silly info is displayed for testing...
|
---|
174 |
|
---|
175 |
|
---|
176 |
|
---|
177 | for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
|
---|
178 | {
|
---|
179 | cout << "Events that passed the selection for quantity "
|
---|
180 | << QuantitiesToBePlot[i] << " : " << ArrayDimension[i] << endl;
|
---|
181 | }
|
---|
182 |
|
---|
183 |
|
---|
184 | // Initialization of the graphs with the info contained in the vectors
|
---|
185 | // Kind of default features are set for all graphs
|
---|
186 |
|
---|
187 |
|
---|
188 | TAxis* axispointer;
|
---|
189 |
|
---|
190 |
|
---|
191 |
|
---|
192 | for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
|
---|
193 | {
|
---|
194 | GraphVector[i] = new TGraph (ArrayDimension[i], VarXArray[i], VarYArray[i]);
|
---|
195 |
|
---|
196 | GraphVector[i] -> SetTitle(QuantitiesToBePlot[i].Data());
|
---|
197 |
|
---|
198 |
|
---|
199 | GraphVector[i]->SetFillColor(19);
|
---|
200 | GraphVector[i]->SetMarkerColor(2);
|
---|
201 | GraphVector[i]->SetMarkerStyle(21);
|
---|
202 | GraphVector[i]->SetMarkerSize(0.5);
|
---|
203 |
|
---|
204 | axispointer = GraphVector[i] -> GetXaxis();
|
---|
205 | axispointer -> SetTitle(Xaxis);
|
---|
206 | axispointer -> SetTitleOffset(1.3);
|
---|
207 | axispointer -> SetTitleSize(0.05);
|
---|
208 |
|
---|
209 |
|
---|
210 | axispointer = GraphVector[i] -> GetYaxis();
|
---|
211 | axispointer -> SetTitle(YaxisVector[i]);
|
---|
212 | axispointer -> SetTitleOffset(1.5);
|
---|
213 | axispointer -> SetTitleSize(0.05);
|
---|
214 |
|
---|
215 |
|
---|
216 | }
|
---|
217 |
|
---|
218 |
|
---|
219 |
|
---|
220 |
|
---|
221 | /*
|
---|
222 | // Let's output some of their components:
|
---|
223 |
|
---|
224 | for ( Int_t i = 0; i < ArrayDimension[]0; i++)
|
---|
225 | {
|
---|
226 | cout << VarXArray[0][i] << " " << VarYArray[0][i] << endl;
|
---|
227 |
|
---|
228 | }
|
---|
229 | */
|
---|
230 |
|
---|
231 |
|
---|
232 | // TCanvas is defined with the NQuantitiesToBePlot Pads where the graphs
|
---|
233 | // will be plotted
|
---|
234 |
|
---|
235 | TCanvas* Canvas = new TCanvas(CanvasTitle, CanvasTitle, 600, 800);
|
---|
236 | Canvas -> SetBorderMode(0);
|
---|
237 | Canvas -> Divide(Nrows, Ncolumns);
|
---|
238 |
|
---|
239 |
|
---|
240 | // gStyle -> SetFrameFillColor(10);
|
---|
241 | gStyle -> SetPadLeftMargin (0.15);
|
---|
242 | gStyle -> SetPadRightMargin (0.05);
|
---|
243 | gStyle -> SetPadTopMargin (0.00);
|
---|
244 | gStyle -> SetPadBottomMargin (0.20);
|
---|
245 |
|
---|
246 | gStyle -> SetOptTitle(0);
|
---|
247 |
|
---|
248 | // Graphs are plot in canvas
|
---|
249 |
|
---|
250 | for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
|
---|
251 | {
|
---|
252 | Canvas -> cd(i+1);
|
---|
253 | gPad -> SetBorderMode(0);
|
---|
254 | gPad->SetGridx();
|
---|
255 | gPad->SetGridy();
|
---|
256 | //gPad -> SetPadTopMargin (0.05);
|
---|
257 | //gPad -> SetPadBottomMargin (0.15);
|
---|
258 |
|
---|
259 | GraphVector[i] -> Draw("AP");
|
---|
260 | }
|
---|
261 |
|
---|
262 |
|
---|
263 |
|
---|
264 | Canvas -> SaveAs(OutputPsFilename);
|
---|
265 |
|
---|
266 |
|
---|
267 | }
|
---|
268 |
|
---|
269 |
|
---|
270 |
|
---|
271 |
|
---|
272 |
|
---|
273 |
|
---|