resPlotND.C
Go to the documentation of this file.
1 //Run using: root -b -q -l Eff.C
2 
3 #include <iostream.h>
4 #include <fstream>
5 #include <iomanip.h>
6 #include <sstream>
7 #include <string>
8 #include <cstring>
9 #include <cmath>
10 
11 
12 
13 
14 void resPlotND()
15 {
16 
17 
18 
19  std::cout<<"Hello Susie!"<<std::endl;
20 
21  file = TFile("./2DPlotsForFitting.root", "READ");
22 
23  //TH1F *histBa = file.Get("9"); //muon resolution - all act
24  //TH1F *histBa = file.Get("12"); //muon resolution - act + cat, cat only
25  //TH1F *histBa = file.Get("15"); //muon resolution - act + cat
26  //TH1F *histBa = file.Get("18"); //muon resolution
27 
28  //TH1F *histBa = file.Get("21"); //hadron qe resolution
29  //TH1F *histBa = file.Get("24"); //hadron nonqe resolution
30  //TH1F *histBa = file.Get("27"); //hadron cc resolution
31  //TH1F *histBa = file.Get("30"); //neutrino qe resolution
32  //TH1F *histBa = file.Get("33"); //neutrino nonqe resolution
33  TH1F *histBa = file.Get("36"); //neutrino cc resolution
34 
35  histBa->GetXaxis()->CenterTitle();
36  histBa->GetYaxis()->CenterTitle();
37 
38  //TF1* SusieFit = new TF1("SusieFit","[0]*exp(-0.5*((x-[1])*(x-[1]))/([2]*[2]))",-0.5,0.5); //For act muons
39  //TF1* SusieFit = new TF1("SusieFit","[0]*exp(-0.5*((x-[1])*(x-[1]))/([2]*[2]))",-0.2,0.2); //For cat muons
40  //TF1* SusieFit = new TF1("SusieFit","[0]*exp(-0.5*((x-[1])*(x-[1]))/([2]*[2]))",-.6,0.3); //For qe hadrons
41  //TF1* SusieFit = new TF1("SusieFit","[0]*exp(-0.5*((x-[1])*(x-[1]))/([2]*[2]))",-.6,0.3); //For nonqe hadrons
42  //TF1* SusieFit = new TF1("SusieFit","[0]*exp(-0.5*((x-[1])*(x-[1]))/([2]*[2]))",-.6,0.3); //For cc hadrons
43  //TF1* SusieFit = new TF1("SusieFit","[0]*exp(-0.5*((x-[1])*(x-[1]))/([2]*[2]))",-0.1,0.1); //For qe neutrino
44  //TF1* SusieFit = new TF1("SusieFit","[0]*exp(-0.5*((x-[1])*(x-[1]))/([2]*[2]))",-0.12,0.2); //For nonqe neutrino
45  TF1* SusieFit = new TF1("SusieFit","[0]*exp(-0.5*((x-[1])*(x-[1]))/([2]*[2]))",-0.12,0.2); //For cc neutrino
46 
47 
48  SusieFit->SetParName(0,"Amplitude");
49  SusieFit->SetParName(1,"Mean");
50  SusieFit->SetParName(2,"Sigma");
51 
52  //**************Switch between these parameters for different populations
53 
54  //Muon fits - all act
55  //SusieFit->SetParameter(1,0);
56  //SusieFit->SetParameter(0,2000000);
57  //SusieFit->SetParameter(2,0.05);
58 
59  //Muon fits - cat
60  //SusieFit->SetParameter(1,0);
61  //SusieFit->SetParameter(0,1400);
62  //SusieFit->SetParameter(2,0.1);
63 
64  //QE fits
65  //SusieFit->SetParameter(1,0);
66  //SusieFit->SetParameter(0,200);
67  //SusieFit->SetParameter(2,0.05);
68 
69  //nonQE fits
70  SusieFit->SetParameter(1,0);
71  SusieFit->SetParameter(0,800);
72  SusieFit->SetParameter(2,0.05);
73 
74 
75 
76 
77  TCanvas* c4 = new TCanvas("c4","c4");
78  //histBa->GetXaxis()->SetTitle("(Reco - True Neutrino Energy)/True Neutrino Energy");
79  histBa->GetYaxis()->SetTitle("Slices");
80  histBa->GetXaxis()->SetRangeUser(-1,1);
81  //histBa->GetYaxis()->SetNoExponent(kTRUE);
82  histBa->Fit(SusieFit, "R");
83 
84  std::stringstream susiestream;
85  std::string susiestring;
86 
87  susiestream<<"Mean = "<<setprecision(3)<<SusieFit->GetParameter(1);
88  susiestring = susiestream.str();
89  char * susiecstr;
90  susiecstr = new char [susiestring.size()+1];
91  strcpy(susiecstr, susiestring.c_str());
92 
93  std::stringstream susiestream1;
94  std::string susiestring1;
95 
96  double sig = SusieFit->GetParameter(2);
97  double write = fabs(sig);
98 
99  susiestream1<<"Sigma = "<<setprecision(3)<<write;
100  susiestring1 = susiestream1.str();
101  char * susiecstr1;
102  susiecstr1 = new char [susiestring1.size()+1];
103  strcpy(susiecstr1, susiestring1.c_str());
104 
105  std::stringstream susiestream11;
106  std::string susiestring11;
107 
108  susiestream11<<"#chi^{2} / ndf = "<<setprecision(3)<<(SusieFit->GetChisquare())<<" / "<<(SusieFit->GetNDF());
109  susiestring11 = susiestream11.str();
110  char * susiecstr11;
111  susiecstr11 = new char [susiestring11.size()+1];
112  strcpy(susiecstr11, susiestring11.c_str());
113 
114 
115  std::stringstream susiestream111;
116  std::string susiestring111;
117 
118  susiestream111<<"Mean = "<<setprecision(3)<<histBa->GetMean(1);
119  susiestring111 = susiestream111.str();
120  char * susiecstr111;
121  susiecstr111 = new char [susiestring111.size()+1];
122  strcpy(susiecstr111, susiestring111.c_str());
123 
124 
125  std::stringstream susiestream112;
126  std::string susiestring112;
127  susiestream112<<"RMS = "<<setprecision(3)<<histBa->GetRMS(1);
128  susiestring112 = susiestream112.str();
129  char * susiecstr112;
130  susiecstr112 = new char [susiestring112.size()+1];
131  strcpy(susiecstr112, susiestring112.c_str());
132 
133  std::stringstream susiestream113;
134  std::string susiestring113;
135  susiestream113<<"Fit Parameters: ";
136  susiestring113 = susiestream113.str();
137  char * susiecstr113;
138  susiecstr113 = new char [susiestring113.size()+1];
139  strcpy(susiecstr113, susiestring113.c_str());
140 
141  std::stringstream susiestream114;
142  std::string susiestring114;
143  susiestream114<<" ";
144  susiestring114 = susiestream114.str();
145  char * susiecstr114;
146  susiecstr114 = new char [susiestring114.size()+1];
147  strcpy(susiecstr114, susiestring114.c_str());
148 
149  pave1 = TPaveText(0.6, 0.5, 0.85, 0.8, "NDC");
150 
151  TText *s333 = pave1.AddText(susiecstr111);
152  s333->SetTextAlign(11);
153  s333->SetTextSize(0.04);
154  s333->SetTextFont(42);
155  TText *s332 = pave1.AddText(susiecstr112);
156  s332->SetTextAlign(11);
157  s332->SetTextSize(0.04);
158  s332->SetTextFont(42);
159  TText *s330 = pave1.AddText(susiecstr114);
160  s330->SetTextAlign(11);
161  s330->SetTextSize(0.04);
162  s330->SetTextFont(42);
163  TText *s331 = pave1.AddText(susiecstr113);
164  s331->SetTextAlign(11);
165  s331->SetTextSize(0.04);
166  s331->SetTextFont(42);
167  TText *s2 = pave1.AddText(susiecstr);
168  s2->SetTextAlign(11);
169  s2->SetTextSize(0.04);
170  s2->SetTextFont(42);
171  TText *s3 = pave1.AddText(susiecstr1);
172  s3->SetTextAlign(11);
173  s3->SetTextSize(0.04);
174  s3->SetTextFont(42);
175  TText *s33 = pave1.AddText(susiecstr11);
176  s33->SetTextAlign(11);
177  s33->SetTextSize(0.04);
178  s33->SetTextFont(42);
179 
180  pave1.SetFillColor(10);
181  pave1.SetLineColor(10);
182  pave1.SetShadowColor(10);
183  pave1.Draw();
184 
185  //Switch depending on type currently making
186  //c4->Print("muonRes_allAct.pdf");
187  //c4->Print("muonRes_actCat_CatOnly.pdf");
188  //c4->Print("muonRes_actCat_tog.pdf");
189  //c4->Print("muonRes.pdf");
190  //c4->Print("hadronRes_QE.pdf");
191  //c4->Print("hadronRes_nonQE.pdf");
192  //c4->Print("hadronRes_CC.pdf");
193  //c4->Print("neutrinoRes_QE.pdf");
194  //c4->Print("neutrinoRes_nonQE.pdf");
195  c4->Print("neutrinoRes_CC.pdf");
196 
197 
198 
199 
200 }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
write
Run ND cosmics.
void resPlotND()
Definition: resPlotND.C:14
OStream cout
Definition: OStream.cxx:6
TFile * file
Definition: cellShifts.C:17
enum BeamMode string