bdtstudyplotter.C
Go to the documentation of this file.
1 /* Gets ND Data/MC Numu varaibles spectra and converts them into POT normalized histograms.
2  */
3 #ifdef __CINT__
4 void bdtstudyplotter()
5 {
6  std::cout<<" Sorry, you must run in compiled mode" <<std::endl;
7 }
8 #else
9 #include "TLine.h"
10 #include "Rtypes.h"
11 
12 #include "TCanvas.h"
13 #include "TFile.h"
14 #include "TGraph.h"
15 #include "TH1.h"
16 #include "TH2.h"
17 #include "TMath.h"
18 #include "TGaxis.h"
19 #include "TMultiGraph.h"
20 #include "TLegend.h"
21 #include "TLegendEntry.h"
22 #include "TLatex.h"
23 #include "TStyle.h"
24 #include "THStack.h"
25 #include "TPaveText.h"
26 #include "TList.h"
27 #include "TGaxis.h"
28 #include "TAttLine.h"
29 #include "TAttMarker.h"
30 
31 #include <cmath>
32 #include <iostream>
33 #include <vector>
34 #include <list>
35 #include <sstream>
36 #include <string>
37 #include <sstream>
38 #include <fstream>
39 #include <iomanip>
40 
41 #include "CAFAna/Core/Binning.h"
42 #include "CAFAna/Cuts/Cuts.h"
43 #include "CAFAna/Core/Spectrum.h"
45 #include "CAFAna/Vars/Vars.h"
46 #include "CAFAna/Core/Utilities.h"
47 #include "CAFAna/Analysis/Plots.h"
48 #include "CAFAna/Cuts/SpillCuts.h"
50 #include "CAFAna/Cuts/TruthCuts.h"
53 #include "CAFAna/Analysis/Style.h"
54 #include "TColor.h"
55 #include "Utilities/rootlogon.C"
56 
57 
58 
59 using namespace ana;
61 {
62  TLatex* prelim = new TLatex(.9, .95, "NOvA Simulation");
63  prelim->SetTextColor(kGray+1);
64  prelim->SetNDC();
65  prelim->SetTextSize(2/30.);
66  prelim->SetTextAlign(32);
67  TGaxis::SetMaxDigits(3);
68  prelim->Draw();
69 }
70 
72 {
73  TLatex* prelim = new TLatex(.9, .95, "NOvA Preliminary");
74  prelim->SetTextColor(kBlue);
75  prelim->SetNDC();
76  prelim->SetTextSize(2/30.);
77  prelim->SetTextAlign(32);
78  TGaxis::SetMaxDigits(3);
79  prelim->Draw();
80 }
81 
83 {
84 
85 ///Read the Spectrum Root file /////
86 
87  TFile *f1= new TFile ("/nova/app/users/acedeno/tag_releasesS18-06-14/NDAna/ncpi0_semi_inc_png_cvn/BDTSpectrum_FlatFluxdatasetslh15.root","READ");
88  f1->cd();
89 
90 
91 
92  ///load reco mass 2 prong CVN cuts spectrums///// (stacked) /////
93  auto sndMC3PRem=*Spectrum::LoadFrom(f1->GetDirectory("ndMC3PRem"));
94  auto sndNCNonPi0Rem=*Spectrum::LoadFrom(f1->GetDirectory("ndNCNonPi0Rem"));
95  auto sndNCPi0Rem=*Spectrum::LoadFrom(f1->GetDirectory("ndNCPi0Rem"));
96  auto sndCCPi0Rem=*Spectrum::LoadFrom(f1->GetDirectory("ndCCPi0Rem"));
97  auto sndNCPi0LRem=*Spectrum::LoadFrom(f1->GetDirectory("ndNCPi0LRem"));
98  auto sndCCNonPi0Rem=*Spectrum::LoadFrom(f1->GetDirectory("ndCCNonPi0Rem"));
99 
100 
101  ///How to Scale Histogram////
102 
103  // double myPOT=sndMC.POT();
104  const double myPOT = 8.12e20;
105 
106  ///load histogram /////
107 
108  auto hndMC3PRem = sndMC3PRem.ToTH1(myPOT);
109  auto hndNCNonPi0Rem = sndNCNonPi0Rem.ToTH1(myPOT);
110  auto hndCCPi0Rem = sndCCPi0Rem.ToTH1(myPOT);
111  auto hndNCPi0Rem = sndNCPi0Rem.ToTH1(myPOT);
112  auto hndNCPi0LRem = sndNCPi0LRem.ToTH1(myPOT);
113  auto hndCCNonPi0Rem = sndCCNonPi0Rem.ToTH1(myPOT);
114 
115 
116  TString outDir2 = "/nova/app/users/acedeno/tag_releasesS18-06-14/NDAna/ncpi0_semi_inc_png_cvn/BDTGStudy";
117  //TString outDir2 = "/nova/app/users/acedeno/tag_releaseS17-09-24/NDAna/ncpi0_Systematics/NcPi0Plots/March_PCVN_Analysis/";
118  struct FileUp{
120  };
121  struct DateUp{
123  };
124 
125  const int File =2;
126  const FileUp CurrentFile[File] = {
127  {"/BDTG_Distribution"},
128  {"/BDTG_Distribution_stacked"},
129 
130 
131  };
132 
133  const int Date = 1;
134  const DateUp CurrentDate[Date] = {
135  {"_07-03-18_BDTG_FlatFlux_slh_15"},
136  };
137 
138 
139 /*********************************************************************************************************************/
140 
141 /// Plot 6 ///
142  //gStyle->SetTitleY(0.9);
143  TCanvas *cs6 = new TCanvas("cs6","cs6",10,10,855,500);
144  cs6->cd();
145 
146  hndNCPi0LRem->SetLineColor(kOrange);
147  hndNCPi0LRem->SetLineWidth(1);
148 
149  hndCCPi0Rem->SetLineColor(kMagenta);
150  hndCCPi0Rem->SetLineWidth(1);
151 
152 
153  hndCCNonPi0Rem->SetLineColor(kAzure);
154  hndCCNonPi0Rem->SetLineWidth(1);
155 
156 
157  hndNCNonPi0Rem->SetLineColor(kCyan);
158  hndNCNonPi0Rem->SetLineWidth(1);
159 
160 
161  hndNCPi0Rem->SetLineColor(kGreen);
162  hndNCPi0Rem->SetLineWidth(1);
163 
164 
165  hndMC3PRem->SetLineColor(kRed);
166  hndMC3PRem->SetLineWidth(1);
167  //hndNumiRemIDData->SetMarkerStyle(2);
168  //hndNumiRemIDData->SetMarkerSize(10);
169 
170 
171 
172  hndMC3PRem->Draw("hist E1");
173  hndCCPi0Rem->Draw("hist E1 same");
174  hndCCNonPi0Rem->Draw("hist E1 same");
175  hndNCPi0LRem->Draw("hist E1 same");
176  hndNCPi0Rem->Draw("hist E1 same");
177  hndNCNonPi0Rem->Draw("hist E1 same");
178  hndMC3PRem->SetMaximum(6000);
179  hndMC3PRem->GetXaxis()->SetRangeUser(-1.,1.);
180  hndMC3PRem->GetYaxis()->SetTitle("Events/ 8e20 POT");
181 
182  //hndNumiRemIDData->Draw("same");
183  TLegend * leg6 = new TLegend(0.55,0.5,0.65,0.82);
184  //leg2->SetTextAlign(40);
185  leg6->SetTextFont(42);
186  leg6->SetTextSize(0.05);
187  leg6->SetFillStyle(0);
188  //leg6->AddEntry(hndNumiRemIDData,"Data","kFullDotSmall");
189  leg6->AddEntry(hndMC3PRem,"Selection","kFullDotSmall");
190  leg6->AddEntry(hndCCPi0Rem,"CCPi0","kFullDotSmall");
191  leg6->AddEntry(hndCCNonPi0Rem,"CCNonPi0","kFullDotSmall");
192  leg6->AddEntry(hndNCPi0LRem,"NC w/Pi0 < 0.3 E","kFullDotSmall");
193  leg6->AddEntry(hndNCPi0Rem,"NC w/Pi0 > 0.3 E","kFullDotSmall");
194  leg6->AddEntry(hndNCNonPi0Rem,"NCNonPi0","kFullDotSmall");
195 
196  leg6->Draw("same");
197  NDSimulation();
198  //cs6->SaveAs("/nova/app/users/acedeno/tag_releaseS17-09-24/NDAna/ncpi0_Systematics/NcPi0Plots/plot7_2Pr_0_3_CVN07__RemID_11-02-17.pdf");
199  cs6->SaveAs(outDir2+CurrentFile[0].name.c_str()+CurrentDate[0].date.c_str()+".png");
200 
201  /*********************************************************************************************************************/
202 
203  /// Plot 4 ///
204 
205  TCanvas *cs4 = new TCanvas("cs4","cs4",10,10,855,500);
206  THStack *hs4 = new THStack("hs4","");
207 
208  hndNCPi0LRem->SetLineColor(kBlack);
209  hndNCPi0LRem->SetFillColor(kOrange);
210  hndNCPi0LRem->SetLineWidth(1);;
211  hndNCPi0LRem->SetMarkerStyle(21);
212  hndNCPi0LRem->SetMarkerColor(kOrange);
213  hs4->Add(hndNCPi0LRem);
214 
215  //TH1D *c2_hndCCPi0 = new TH1D("c2_ndCCPi0","ndCCPi0",100,-4,4);
216  hndCCPi0Rem->SetLineColor(kBlack);
217  hndCCPi0Rem->SetFillColor(kMagenta);
218  hndCCPi0Rem->SetLineWidth(1);;
219  hndCCPi0Rem->SetMarkerStyle(21);
220  hndCCPi0Rem->SetMarkerColor(kMagenta);
221 
222  hs4->Add(hndCCPi0Rem);
223  //TH1D *c2_hndCCNonPi0 = new TH1D("c2_hndCCNonPi0","hndCCNonPi0",100,-4,4);
224  hndCCNonPi0Rem->SetLineColor(kBlack);
225  hndCCNonPi0Rem->SetFillColor(kAzure);
226  hndCCNonPi0Rem->SetLineWidth(1);;
227  hndCCNonPi0Rem->SetMarkerStyle(21);
228  hndCCNonPi0Rem->SetMarkerColor(kAzure);
229  hs4->Add(hndCCNonPi0Rem);
230 
231  //TH1D *c2_hndNCPi0 = new TH1D("c2_ndNCPi0","ndNCPi0",100,-4,4);
232  hndNCNonPi0Rem->SetLineColor(kBlack);
233  hndNCNonPi0Rem->SetFillColor(kCyan);
234  hndNCNonPi0Rem->SetLineWidth(1);;
235  hndNCNonPi0Rem->SetMarkerStyle(21);
236  hndNCNonPi0Rem->SetMarkerColor(kCyan);
237  hs4->Add(hndNCNonPi0Rem);
238 
239  //TH1D *c2_hndNCPi0L = new TH1D("c2_ndNCPi0L","ndNCPi0L",100,-4,4);
240  hndNCPi0Rem->SetLineColor(kBlack);
241  hndNCPi0Rem->SetFillColor(kGreen);
242  hndNCPi0Rem->SetLineWidth(1);;
243  hndNCPi0Rem->SetMarkerStyle(21);
244  hndNCPi0Rem->SetMarkerColor(kGreen);
245  hs4->Add(hndNCPi0Rem);
246 
247  //TCanvas *cs2 = new TCanvas("cs2","cs2",10,10,855,500);
248  TText T4; T4.SetTextFont(42); T4.SetTextAlign(21);
249  hs4->Draw("hist"); T4.DrawTextNDC(.5,.95,"");
250  hs4->GetYaxis()->SetTitle("Events/ 8e20 POT");
251  hs4->GetXaxis()->SetTitle("BDTG");
252  hs4->SetMaximum(6000);
253  hs4->GetXaxis()->SetRangeUser(-1.,1.);
254  gPad->Modified();
255  cs4->cd();
256  //cs2->SetTopMargin(0.18);
257  hndMC3PRem->SetLineColor(kRed);
258  hndMC3PRem->SetLineWidth(3);
259  //hndNumiCVN2PRData->SetMarkerStyle(2);
260  //hndNumiCVN2PRData->SetMarkerSize(3);
261 
262 
263  hndMC3PRem->Draw("same");
264  //hndNumiCVN2PRData->Draw("same");
265  TLegend * leg4 = new TLegend(0.55,0.5,0.65,0.82);
266  //leg2->SetTextAlign(40);
267  leg4->SetTextFont(42);
268  leg4->SetTextSize(0.05);
269  leg4->SetFillStyle(0);
270  //leg4->AddEntry(hndNumiCVN2PRData,"Data","kFullDotSmall");
271  leg4->AddEntry(hndMC3PRem,"Selection","kFullDotSmall");
272  leg4->AddEntry(hndCCPi0Rem,"CCPi0","kFullDotSmall");
273  leg4->AddEntry(hndCCNonPi0Rem,"CCNonPi0","kFullDotSmall");
274  leg4->AddEntry(hndNCPi0LRem,"NC w/Pi0 < 0.3 E","kFullDotSmall");
275  leg4->AddEntry(hndNCPi0Rem,"NC w/Pi0 > 0.3 E","kFullDotSmall");
276  leg4->AddEntry(hndNCNonPi0Rem,"NCNonPi0","kFullDotSmall");
277 
278  leg4->Draw("same");
279  NDSimulation();
280  //cs4->SaveAs("/nova/app/users/acedeno/tag_releaseS17-09-24/NDAna/ncpi0_Systematics/NcPi0Plots/plot5_2Pr_0_3_CVN07__11-02-17.pdf");
281  cs4->SaveAs(outDir2+CurrentFile[1].name.c_str()+CurrentDate[0].date.c_str()+".png");
282  /*********************************************************************************************************************/
283 
284  f1->Close();
285 
286 }
287 #endif
const XML_Char * name
Definition: expat.h:151
enum BeamMode kOrange
::xsd::cxx::tree::date< char, simple_type > date
Definition: Database.h:186
enum BeamMode kRed
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void NDSimulation1()
const DateUp CurrentDate[Date]
const int Date
void bdtstudyplotter()
const FileUp CurrentFile[File]
void NDSimulation()
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:563
Float_t f1
TLatex * prelim
Definition: Xsec_final.C:133
std::string date
OStream cout
Definition: OStream.cxx:6
TString outDir2
const int File
enum BeamMode kGreen
enum BeamMode kBlue
enum BeamMode string