pidPlot.C
Go to the documentation of this file.
1 #include <iostream.h>
2 #include <math.h>
3 
4 void pidPlot(string input) {
5  gROOT->ForceStyle();
6 
7  TChain *ch=new TChain("t");
8  ch->SetMakeClass(1); //<===== important
9  ch->Add(input.c_str());
10 
11  int truelabel=0;
12  double numu=0;
13  double nue=0;
14  double nutau=0;
15  double nc=0;
16  double cosmic=0;
17 
18  ch->SetBranchAddress("truelabel",&truelabel);
19 
20  ch->SetBranchAddress("truelabel",&truelabel);
21  ch->SetBranchAddress("numu",&numu);
22  ch->SetBranchAddress("nue",&nue);
23  ch->SetBranchAddress("nutau",&nutau);
24  ch->SetBranchAddress("nc",&nc);
25  ch->SetBranchAddress("cosmic",&cosmic);
26 
27 
28  TH1D *numuPID_numu= new TH1D( "numuPID_numu", "", 100,0,1);
29  TH1D *numuPID_nue= new TH1D( "numuPID_nue", "", 100,0,1);
30  TH1D *numuPID_nutau= new TH1D( "numuPID_nutau", "", 100,0,1);
31  TH1D *numuPID_nc= new TH1D( "numuPID_nc", "", 100,0,1);
32  TH1D *numuPID_cosmic= new TH1D( "numuPID_cosmic", "", 100,0,1);
33 
34  TH1D *nuePID_numu= new TH1D( "nuePID_numu", "", 100,0,1);
35  TH1D *nuePID_nue= new TH1D( "nuePID_nue", "", 100,0,1);
36  TH1D *nuePID_nutau= new TH1D( "nuePID_nutau", "", 100,0,1);
37  TH1D *nuePID_nc= new TH1D( "nuePID_nc", "", 100,0,1);
38  TH1D *nuePID_cosmic= new TH1D( "nuePID_cosmic", "", 100,0,1);
39 
40  TH1D *ncPID_numu= new TH1D( "ncPID_numu", "", 100,0,1);
41  TH1D *ncPID_nue= new TH1D( "ncPID_nue", "", 100,0,1);
42  TH1D *ncPID_nutau= new TH1D( "ncPID_nutau", "", 100,0,1);
43  TH1D *ncPID_nc= new TH1D( "ncPID_nc", "", 100,0,1);
44  TH1D *ncPID_cosmic= new TH1D( "ncPID_cosmic", "", 100,0,1);
45 
46  TH1D *cosmicPID_numu= new TH1D( "cosmicPID_numu", "", 100,0,1);
47  TH1D *cosmicPID_nue= new TH1D( "cosmicPID_nue", "", 100,0,1);
48  TH1D *cosmicPID_nutau= new TH1D( "cosmicPID_nutau", "", 100,0,1);
49  TH1D *cosmicPID_nc= new TH1D( "cosmicPID_nc", "", 100,0,1);
50  TH1D *cosmicPID_cosmic= new TH1D( "cosmicPID_cosmic", "", 100,0,1);
51 
52  //heatmap->SetBit(TH1::kCanRebin);
53  Int_t nevent =ch.GetEntries();
54  for(Int_t i=0;i<nevent;i++){
55  ch->GetEntry(i);
56  if(truelabel==0){
57  numuPID_numu->Fill(numu);
58  nuePID_numu->Fill(nue);
59  ncPID_numu->Fill(nc);
60  cosmicPID_numu->Fill(cosmic);
61 
62  }
63  if(truelabel==1){
64  numuPID_nue->Fill(numu);
65  nuePID_nue->Fill(nue);
66  ncPID_nue->Fill(nc);
67  cosmicPID_nue->Fill(cosmic);
68 
69  }
70  if(truelabel==2){
71  numuPID_nutau->Fill(numu);
72  nuePID_nutau->Fill(nue);
73  ncPID_nutau->Fill(nc);
74  cosmicPID_nutau->Fill(cosmic);
75 
76  }
77  if(truelabel==3){
78  numuPID_nc->Fill(numu);
79  nuePID_nc->Fill(nue);
80  ncPID_nc->Fill(nc);
81  cosmicPID_nc->Fill(cosmic);
82 
83  }
84  if(truelabel==4){
85  numuPID_cosmic->Fill(numu);
86  nuePID_cosmic->Fill(nue);
87  ncPID_cosmic->Fill(nc);
88  cosmicPID_cosmic->Fill(cosmic);
89 
90  }
91  }
92 
93  string title="numuID";
94 
95  TCanvas c1("c1",title.c_str(),1400,1000);
96 
97  numuPID_numu->SetTitle("");
98  numuPID_numu->SetXTitle("NuMu PID");
99  numuPID_numu->SetYTitle("Test Sample Events");
100  numuPID_numu->GetXaxis()->CenterTitle();
101  numuPID_numu->GetYaxis()->CenterTitle();
102 
103  numuPID_numu->SetLineWidth(3);
104  numuPID_nue->SetLineWidth(3);
105  numuPID_nutau->SetLineWidth(3);
106  numuPID_nc->SetLineWidth(3);
107  numuPID_cosmic->SetLineWidth(3);
108 
109  numuPID_numu->SetLineColor(kGreen+2);
110  numuPID_nue->SetLineColor(kViolet);
111  numuPID_nutau->SetLineColor(kRed);
112  numuPID_nc->SetLineColor(kBlue);
113  numuPID_cosmic->SetLineColor(kGray);
114 
115 
116  numuPID_numu->GetYaxis()->SetTitleSize(0.05);
117  numuPID_numu->GetXaxis()->SetTitleSize(0.06);
118  numuPID_numu->GetYaxis()->SetLabelSize(.03);
119  numuPID_numu->GetXaxis()->SetLabelSize(.03);
120  numuPID_numu->GetYaxis()->SetTitleOffset(1.5);
121  numuPID_numu->GetXaxis()->SetTitleOffset(0.9);
122 
123  numuPID_numu->DrawNormalized("hist")->GetYaxis()->SetRangeUser(0,0.5);
124  numuPID_nue->DrawNormalized("histsame");
125  numuPID_nutau->DrawNormalized("histsame");
126  numuPID_nc->DrawNormalized("histsame");
127  numuPID_cosmic->DrawNormalized("histsame");
128  gPad->RedrawAxis();
129 
130  TLegend *mylegend = new TLegend(0.6,0.6,0.8,0.8);
131  mylegend->AddEntry(numuPID_numu,"NuMu CC","L");
132  mylegend->AddEntry(numuPID_nue,"NuE","L");
133  mylegend->AddEntry(numuPID_nutau,"NuTau CC","L");
134  mylegend->AddEntry(numuPID_nc,"NC","L");
135  mylegend->AddEntry(numuPID_cosmic,"Cosmic","L");
136  mylegend->SetFillStyle(0);
137  mylegend->Draw("same");
138 
139  string output = "plots/"+title+".png";
140  c1.Print(output.c_str());
141  string output = "plots/"+title+".C";
142  c1.Print(output.c_str());
143  string output = "plots/"+title+".eps";
144  c1.Print(output.c_str());
145 
146  ////////////
147 
148  string title2="nueID";
149 
150  TCanvas c2("c2",title2.c_str(),1400,1000);
151 
152  nuePID_nue->SetTitle("");
153  nuePID_nue->SetXTitle("NuE PID");
154  nuePID_nue->SetYTitle("Test Sample Events");
155  nuePID_nue->GetXaxis()->CenterTitle();
156  nuePID_nue->GetYaxis()->CenterTitle();
157 
158  nuePID_numu->SetLineWidth(3);
159  nuePID_nue->SetLineWidth(3);
160  nuePID_nutau->SetLineWidth(3);
161  nuePID_nc->SetLineWidth(3);
162  nuePID_cosmic->SetLineWidth(3);
163 
164  nuePID_numu->SetLineColor(kGreen+2);
165  nuePID_nue->SetLineColor(kViolet);
166  nuePID_nutau->SetLineColor(kRed);
167  nuePID_nc->SetLineColor(kBlue);
168  nuePID_cosmic->SetLineColor(kGray);
169 
170  nuePID_nue->GetYaxis()->SetTitleSize(0.05);
171  nuePID_nue->GetXaxis()->SetTitleSize(0.06);
172  nuePID_nue->GetYaxis()->SetLabelSize(.03);
173  nuePID_nue->GetXaxis()->SetLabelSize(.03);
174  nuePID_nue->GetYaxis()->SetTitleOffset(1.5);
175  nuePID_nue->GetXaxis()->SetTitleOffset(0.9);
176 
177  nuePID_nue->DrawNormalized("hist")->GetYaxis()->SetRangeUser(0,0.5);
178  nuePID_numu->DrawNormalized("histsame");
179  nuePID_nutau->DrawNormalized("histsame");
180  nuePID_nc->DrawNormalized("histsame");
181  nuePID_cosmic->DrawNormalized("histsame");
182  gPad->RedrawAxis();
183  mylegend->Draw("same");
184  string output2 = "plots/"+title2+".png";
185  c2.Print(output2.c_str());
186  string output2 = "plots/"+title2+".C";
187  c2.Print(output2.c_str());
188  string output2 = "plots/"+title2+".eps";
189  c2.Print(output2.c_str());
190 
191  ////////////
192 
193  string title3="ncID";
194 
195  TCanvas c3("c3",title3.c_str(),1400,1000);
196 
197  ncPID_nc->SetTitle("");
198  ncPID_nc->SetXTitle("NC PID");
199  ncPID_nc->SetYTitle("Test Sample Events");
200  ncPID_nc->GetXaxis()->CenterTitle();
201  ncPID_nc->GetYaxis()->CenterTitle();
202 
203  ncPID_numu->SetLineWidth(3);
204  ncPID_nue->SetLineWidth(3);
205  ncPID_nutau->SetLineWidth(3);
206  ncPID_nc->SetLineWidth(3);
207  ncPID_cosmic->SetLineWidth(3);
208 
209  ncPID_numu->SetLineColor(kGreen+2);
210  ncPID_nue->SetLineColor(kViolet);
211  ncPID_nutau->SetLineColor(kRed);
212  ncPID_nc->SetLineColor(kBlue);
213  ncPID_cosmic->SetLineColor(kGray);
214 
215  ncPID_nc->GetYaxis()->SetTitleSize(0.05);
216  ncPID_nc->GetXaxis()->SetTitleSize(0.06);
217  ncPID_nc->GetYaxis()->SetLabelSize(.03);
218  ncPID_nc->GetXaxis()->SetLabelSize(.03);
219  ncPID_nc->GetYaxis()->SetTitleOffset(1.5);
220  ncPID_nc->GetXaxis()->SetTitleOffset(0.9);
221 
222  ncPID_nc->DrawNormalized("hist")->GetYaxis()->SetRangeUser(0,0.5);
223  ncPID_numu->DrawNormalized("histsame");
224  ncPID_nutau->DrawNormalized("histsame");
225  ncPID_nue->DrawNormalized("histsame");
226  ncPID_cosmic->DrawNormalized("histsame");
227  gPad->RedrawAxis();
228  mylegend->Draw("same");
229  string output3 = "plots/"+title3+".png";
230  c3.Print(output3.c_str());
231  string output3 = "plots/"+title3+".C";
232  c3.Print(output3.c_str());
233  string output3 = "plots/"+title3+".eps";
234  c3.Print(output3.c_str());
235 
236  ////////////
237 
238  string title4="cosmicID";
239 
240  TCanvas c4("c4",title4.c_str(),1400,1000);
241 
242  cosmicPID_cosmic->SetTitle("");
243  cosmicPID_cosmic->SetXTitle("Cosmic PID");
244  cosmicPID_cosmic->SetYTitle("Test Sample Events");
245  cosmicPID_cosmic->GetXaxis()->CenterTitle();
246  cosmicPID_cosmic->GetYaxis()->CenterTitle();
247 
248  cosmicPID_numu->SetLineWidth(3);
249  cosmicPID_nue->SetLineWidth(3);
250  cosmicPID_nutau->SetLineWidth(3);
251  cosmicPID_nc->SetLineWidth(3);
252  cosmicPID_cosmic->SetLineWidth(3);
253 
254  cosmicPID_numu->SetLineColor(kGreen+2);
255  cosmicPID_nue->SetLineColor(kViolet);
256  cosmicPID_nutau->SetLineColor(kRed);
257  cosmicPID_nc->SetLineColor(kBlue);
258  cosmicPID_cosmic->SetLineColor(kGray);
259 
260  cosmicPID_cosmic->GetYaxis()->SetTitleSize(0.05);
261  cosmicPID_cosmic->GetXaxis()->SetTitleSize(0.06);
262  cosmicPID_cosmic->GetYaxis()->SetLabelSize(.03);
263  cosmicPID_cosmic->GetXaxis()->SetLabelSize(.03);
264  cosmicPID_cosmic->GetYaxis()->SetTitleOffset(1.5);
265  cosmicPID_cosmic->GetXaxis()->SetTitleOffset(0.9);
266 
267  cosmicPID_cosmic->DrawNormalized("hist")->GetYaxis()->SetRangeUser(0,0.5);
268  cosmicPID_numu->DrawNormalized("histsame");
269  cosmicPID_nutau->DrawNormalized("histsame");
270  cosmicPID_nc->DrawNormalized("histsame");
271  cosmicPID_nue->DrawNormalized("histsame");
272  gPad->RedrawAxis();
273  mylegend->Draw("same");
274  string output4 = "plots/"+title4+".png";
275  c4.Print(output4.c_str());
276  string output4 = "plots/"+title4+".C";
277  c4.Print(output4.c_str());
278  string output4 = "plots/"+title4+".eps";
279  c4.Print(output4.c_str());
280 
281  return;
282 }
283 
ofstream output
c2
Definition: demo5.py:33
Sum up livetimes from individual cosmic triggers.
Int_t nevent
Definition: macro.C:10
c1
Definition: demo5.py:24
void pidPlot(string input)
Definition: pidPlot.C:4