Functions
NueCCIncCrossSectionFunctions.h File Reference
#include "NDAna/nuecc_inc/NueCCIncTemplateFit.h"
#include "RooUnfoldResponse.h"
#include "RooUnfoldBayes.h"

Go to the source code of this file.

Functions

void PrintChiSq (TString str)
 
void Plot2D (TH2F *hist, std::string outName, bool setLog=false)
 
TH3F * GetEfficiency (TH3F *num, TH3F *denom)
 
TH1F * DoUnfolding (TH1F *hMeasured, TH2F *hResponse, int iter)
 
void CalculateXSec (TH3F *hNumerator, TH1F *hFlux, TH3F *hEff, std::string dataName, std::string xsecResult, double numTargets)
 

Function Documentation

void CalculateXSec ( TH3F *  hNumerator,
TH1F *  hFlux,
TH3F *  hEff,
std::string  dataName,
std::string  xsecResult,
double  numTargets 
)

Definition at line 213 of file NueCCIncCrossSectionFunctions.h.

References e, and outf.

216 {
217  TFile* outf = new TFile("CrossSection_MCResults.root","update");
218 
219  if(xsecResult == "energy"){
220  TH3F* hXSec = (TH3F*)hNumerator->Clone("hXSec");
221 
222  //3D Efficiency Correction
223  hXSec->Divide(hEff);
224 
225  TH1F* hXSec1D = (TH1F*)hXSec->ProjectionZ("hXSec1D");
226  TH1F* hTrueVar = (TH1F*)hXSec1D->Clone("clone");
227  hFlux->Scale(1e-4);//nu/cm^2 from nu/m^2
228  hXSec1D->Divide(hFlux);
229  hXSec1D->Scale(1./numTargets);
230  hXSec1D->SetTitle("");
231  hXSec1D->GetXaxis()->SetTitle("Neutrino Energy, E_{#nu} (GeV)");
232  hXSec1D->GetYaxis()->SetTitle("#sigma (cm^{2}/nucleon)");
233  hXSec1D->GetXaxis()->CenterTitle();
234  hXSec1D->GetYaxis()->CenterTitle();
235 
236  char name[50];
237  sprintf(name, "%s_%s_%s_%s", "mc", dataName.c_str(), xsecResult.c_str(),
238  "xsec");
239  hXSec1D->SetName(name);
240  hXSec1D->Write();
241  sprintf(name, "%s_%s_%s_%s", "mc", dataName.c_str(), xsecResult.c_str(),
242  "truevar_eff_corrected");
243  hTrueVar->SetName(name);
244  hTrueVar->Write();
245  sprintf(name, "%s_%s_%s_%s", "mc", dataName.c_str(), xsecResult.c_str(),
246  "efficiency");
247  hEff->SetName(name);
248  hEff->Write();
249 
250  outf->Close();
251  }
252  if(xsecResult == "electron"){
253  TH3F* hXSec = (TH3F*)hNumerator->Clone("hXSec");
254  //3D Efficiency Correction
255  hXSec->Divide(hEff);
256 
257  TH1F* hXSec1D = (TH1F*)hXSec->ProjectionY("hXSec1D");
258  TH1F* hTrueVar = (TH1F*)hXSec1D->Clone("clone");
259  hFlux->Scale(1e-4);//nu/cm^2 from nu/m^2
260  double fluxtot = hFlux->Integral();
261  hXSec1D->Scale(1./fluxtot);
262  hXSec1D->Scale(1./numTargets);
263  hXSec1D->Scale(1,"width");
264  hXSec1D->SetTitle("");
265  hXSec1D->GetXaxis()->SetTitle("Electron Energy, E_{e} (GeV)");
266  hXSec1D->GetYaxis()->SetTitle("#sigma (cm^{2}/nucleon GeV)");
267  hXSec1D->GetXaxis()->CenterTitle();
268  hXSec1D->GetYaxis()->CenterTitle();
269 
270  char name[50];
271  sprintf(name, "%s_%s_%s_%s", "mc", dataName.c_str(), xsecResult.c_str(),
272  "xsec");
273  hXSec1D->SetName(name);
274 
275  hXSec1D->Write();
276  sprintf(name, "%s_%s_%s_%s", "mc", dataName.c_str(), xsecResult.c_str(),
277  "truevar_eff_corrected");
278  hTrueVar->SetName(name);
279  hTrueVar->Write();
280  sprintf(name, "%s_%s_%s_%s", "mc", dataName.c_str(), xsecResult.c_str(),
281  "efficiency");
282  hEff->SetName(name);
283  hEff->Write();
284 
285  outf->Close();
286  }
287  if(xsecResult == "cos"){
288  TH3F* hXSec = (TH3F*)hNumerator->Clone("hXSec");
289 
290  //3D Efficiency Correction
291  hXSec->Divide(hEff);
292 
293  TH1F* hXSec1D = (TH1F*)hXSec->ProjectionX("hXSec1D");
294  TH1F* hTrueVar = (TH1F*)hXSec1D->Clone("clone");
295 
296  hFlux->Scale(1e-4);//nu/cm^2 from nu/m^2
297  double fluxtot = hFlux->Integral();
298  hXSec1D->Scale(1./fluxtot);
299  hXSec1D->Scale(1./numTargets);
300  hXSec1D->Scale(1,"width");
301  hXSec1D->SetTitle("");
302  hXSec1D->GetXaxis()->SetTitle("cos #theta_{e}");
303  hXSec1D->GetYaxis()->SetTitle("#sigma (cm^{2}/nucleon cos #theta)");
304  hXSec1D->GetXaxis()->CenterTitle();
305  hXSec1D->GetYaxis()->CenterTitle();
306 
307  char name[50];
308  sprintf(name, "%s_%s_%s_%s", "mc", dataName.c_str(), xsecResult.c_str(),
309  "xsec");
310  hXSec1D->SetName(name);
311 
312  hXSec1D->Write();
313  sprintf(name, "%s_%s_%s_%s", "mc", dataName.c_str(), xsecResult.c_str(),
314  "truevar_eff_corrected");
315  hTrueVar->SetName(name);
316  hTrueVar->Write();
317  sprintf(name, "%s_%s_%s_%s", "mc", dataName.c_str(), xsecResult.c_str(),
318  "efficiency");
319  hEff->SetName(name);
320  hEff->Write();
321 
322  outf->Close();
323  }
324 }
const XML_Char * name
Definition: expat.h:151
TFile * outf
Definition: testXsec.C:51
std::string dataName
Float_t e
Definition: plot.C:35
TH1F* DoUnfolding ( TH1F *  hMeasured,
TH2F *  hResponse,
int  iter 
)

Definition at line 150 of file NueCCIncCrossSectionFunctions.h.

References demo5::c1, chisquared::c3, om::cout, allTimeWatchdog::endl, and Simulation().

Referenced by makeXSecPlots1D(), and makeXSecPlots2D().

151 {
152  /*
153  //Pretty Colors
154  //-------------------------------------------------------------------------
155  const Int_t NRGBs = 9;
156  const Int_t NCont = 255;
157 
158  Double_t stops[NRGBs] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
159  Double_t red[9] = { 251./255., 235./255., 223./255., 214./255., 196./255., 188./255., 157./255., 102./255., 37./255.};
160  Double_t green[9] = { 251./255., 185./255., 132./255., 91./255., 67./255., 37./255., 25./255., 29./255., 37./255.};
161  Double_t blue[9] = { 251./255., 187./255., 137./255., 98./255., 66./255., 45./255., 33./255., 32./255., 37./255.};
162  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
163  gStyle->SetNumberContours(NCont);
164 */
165 
166 
167  RooUnfoldResponse ResponseMatrix(0,0,hResponse, "ResponseMatrix");
168  std::cout << "Using Overflow? : " <<
169  ResponseMatrix.UseOverflowStatus() << std::endl;
170  if(!ResponseMatrix.UseOverflowStatus()){
171  ResponseMatrix.UseOverflow(1);
172  std::cout << "Using Overflow, now? : " <<
173  ResponseMatrix.UseOverflowStatus() << std::endl;
174  }
175 
176  RooUnfoldBayes unfold(&ResponseMatrix, hMeasured, iter);
177  TH1F* hunfolded = (TH1F*)unfold.Hreco();
178  //TMatrixD covMatrix = unfold.Ereco();
179 
180  //Draw Response Matrix
181  TCanvas *c1 = new TCanvas("c1","c1");
182  hResponse->SetMarkerColor(kBlack);
183  hResponse->Draw("COLZ TEXT");
184  gStyle->SetPaintTextFormat("4.f");
185  Simulation();
186  c1->SaveAs("Plots/response_matrix.png");
187  c1->Close();
188  delete c1;
189 
190  /*
191  //Draw covarivance matrix
192  TCanvas *c2 = new TCanvas("c2","c2");
193  covMatrix.Draw("COLZ TEXT");
194  gStyle->SetPaintTextFormat("4.f");
195  Simulation();
196  c2->SaveAs("Plots/covariance_matrix.png");
197  c2->Close();
198  delete c2;
199  */
200 
201  //Draw Unfolded Histogram
202  TCanvas *c3 = new TCanvas("c3","c3");
203  hunfolded->SetTitle("");
204  hunfolded->Draw();
205  Simulation();
206  c3->SaveAs("Plots/unfolded_signal_estimate.png");
207  c3->Close();
208  delete c3;
209 
210  return hunfolded;
211 }
void Simulation()
Definition: tools.h:16
OStream cout
Definition: OStream.cxx:6
c1
Definition: demo5.py:24
TH3F* GetEfficiency ( TH3F *  num,
TH3F *  denom 
)

Definition at line 142 of file NueCCIncCrossSectionFunctions.h.

References nd_projection_maker::eff.

143 {
144  TH3F* eff = (TH3F*)num->Clone("eff");
145  eff->Divide(denom);
146 
147  return eff;
148 }
int num
Definition: f2_nu.C:119
void Plot2D ( TH2F *  hist,
std::string  outName,
bool  setLog = false 
)

Definition at line 16 of file NueCCIncCrossSectionFunctions.h.

References demo5::c1, confusionMatrixTree::out, and ana::UniqueName().

17 {
18  TCanvas *c1 = new TCanvas(ana::UniqueName().c_str(),"c1");
19  c1->SetLeftMargin(0.20);
20  c1->SetRightMargin(0.20);
21  if(setLog)c1->SetLogz();
22  hist->GetZaxis()->SetTitleOffset(1.10);
23  hist->GetXaxis()->CenterTitle();
24  hist->GetYaxis()->CenterTitle();
25  hist->GetZaxis()->CenterTitle();
26  hist->Draw("COLZ");
27  char out[50];
28  sprintf(out, "Plots/%s", outName.c_str());
29  c1->SaveAs(out);
30  return;
31 }
c1
Definition: demo5.py:24
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
void PrintChiSq ( TString  str)

Definition at line 7 of file NueCCIncCrossSectionFunctions.h.

References prelim.

8 {
9  TLatex* prelim = new TLatex(.22, .85, str);
10  prelim->SetTextColor(kBlack);
11  prelim->SetNDC();
12  prelim->SetTextSize(0.05);
13  prelim->Draw();
14 }
TLatex * prelim
Definition: Xsec_final.C:133