nue_fnex_vs_fnex.C
Go to the documentation of this file.
1 //Author: Prabhjot Singh (prabhjot@fnal.gov).
2 //Dated: 15 Dec 2016 at 04:32 am
3 //Compare FNEX predictions at two different best fit points.
4 //1. In this case FNEX predictions are compared at CAF best fit point and FNEX best fit points.
5 
6 #include <Header.h>
7 #include <HistogramAttr.h>
8 #include <iostream>
9 #include <fstream>
10 
12 
13  TH1F* fnex_caf_bestfit;
14  TH1F* fnex_fnex_bestfit;
15 
16  TString det_caf;
17  TString plotorfit = "plot";
18  // TString plotorfit = "fit/Fit";
19 
20  ofstream summary;
21  summary .open("Images/fnexvscaf/summary.txt");
22 
23  int first_intr = 0;
24  int last_intr = 0;
25 
26  TString PID[] = { "Low" , "Mid", "High"};
27 
28  TString datamc[] = {"mc"};
29 
30  TString fnex_intr[] = {"me", "ee", "mm", "nc", "em", "mt", "eebar", "mtbar", "mmbar", "mebar"};
31  //no embar in Mid and High pids
32 
33  TString det[] = {"FD"};
34 
35  TFile* file_fnex_bestfit = new TFile("/nova/ana/users/prabhjot/FNEX/nue_analysis/realdata/fnex_fitpoint_hist.root", "read"); //fnex prediction at fnex best fit point
36 
37  TFile* file_caf_bestfit = new TFile("/nova/ana/users/prabhjot/FNEX/nue_analysis/realdata/plotpointjob_caf_bestfitpoint/fnex_plotpoint_hist.root");
38 
39  for(int idet = 0; idet < sizeof(det)/sizeof(det[0]); idet++){
40  if(det[idet]=="ND"){
41  det_caf = "nd";
42  first_intr = 0;
43  last_intr = 3;
44  }
45  else if(det[idet]=="FD"){
46  det_caf = "fd";
47  first_intr = 0;
48  last_intr = sizeof(fnex_intr)/sizeof(fnex_intr[0]);
49  }
50 
51  for(int ipid = 0; ipid < sizeof(PID)/sizeof(PID[0]); ipid++){
52 
53  for(int idatamc = 0; idatamc < sizeof(datamc)/sizeof(datamc[0]); idatamc++){
54 
55  for(int intr = first_intr; intr < last_intr; intr++){
56 
57  if(datamc[idatamc]=="mc") fnex_caf_bestfit = (TH1F*)file_caf_bestfit->Get("plot/MultiExperiment/NOvA_NuESel_"+PID[ipid]+"PID_NuMuSel/CorrectedStacks/"+det[idet]+datamc[idatamc]+"_"+fnex_intr[intr]+"Corrected");
58 
59  if(datamc[idatamc]=="mc") fnex_fnex_bestfit = (TH1F*)file_fnex_bestfit->Get("fit/Fit/MultiExperiment/NOvA_NuESel_"+PID[ipid]+"PID_NuMuSel/CorrectedStacks/"+det[idet]+datamc[idatamc]+"_"+fnex_intr[intr]+"Corrected");
60 
61  if(!fnex_caf_bestfit){
62  std::cout << "CAF histogram: " << plotorfit+"/MultiExperiment/NOvA_NuESel_"+PID[ipid]+"PID_NuMuSel/CorrectedStacks/"+det[idet]+datamc[idatamc]+"_"+fnex_intr[intr]+"Corrected" << " does not exists." << std::endl;
63  std::cout << "---------------------->>>>>>>>>>>> ABORTING >>>>>>>>>>>>>>>>--------------------------" << std::endl;
64  abort();
65  }//condition to check if fnex histogram exists or not
66 
67  if(!fnex_fnex_bestfit){
68  std::cout << "FNEX histogram: " << plotorfit+"/MultiExperiment/NOvA_NuESel_"+PID[ipid]+"PID_NuMuSel/CorrectedStacks/"+det[idet]+datamc[idatamc]+"_"+fnex_intr[intr]+"Corrected" << " does not exists." << std::endl;
69  std::cout << "---------------------->>>>>>>>>>>> ABORTING >>>>>>>>>>>>>>>>--------------------------" << std::endl;
70  abort();
71  }//condition to check if fnex histogram exists or not
72 
73  //Rebin histograms
74  fnex_caf_bestfit ->Rebin(2);
75  fnex_fnex_bestfit ->Rebin(2);
76 
77  //Write integrals of different histograms in a summary file
78  summary << "//---------------------------------------------------------------//" << std::endl;
79  summary << "PID : " << PID[ipid] << " PID" << std::endl;
80  summary << "Detector : " << det[idet] << std::endl;
81  summary << "Data or MC : " << datamc[idatamc] << std::endl;
82  summary << "Interaction : " << fnex_intr[intr] << std::endl;
83  // summary << std::fixed;
84  // summary << std::setprecision(2);
85  summary << "CAF : events: " << fnex_caf_bestfit->Integral() << std::endl;
86  summary << "FNEX: events: " << fnex_fnex_bestfit->Integral() << std::endl;
87  summary << "//---------------------------------------------------------------//" << std::endl;
88 
89  CompareHistos(fnex_caf_bestfit, fnex_fnex_bestfit, "E^{reco}_{#nu} (GeV)", "Events", 632, 600, 2, 1, 0.60, 0.53, 0.86, 0.88, PID[ipid]+"PID_"+det[idet]+datamc[idatamc]+"_"+fnex_intr[intr], "CAF Best", "FNEX Best", "fnex_caf_bestfit_vs_fnex_bestfit_"+PID[ipid]+"PID_"+det[idet]+datamc[idatamc]+"_"+fnex_intr[intr]);
90  }//end of loop over all interactions.
91  }//end of loop over data or mc
92  }//end of loop over all PIDs
93  }//end of loop over detector type
94  summary .close();
95 }//end of main function
void nue_fnex_vs_fnex()
bool datamc
Definition: fnexvscaf.C:20
void CompareHistos(TH1 *hbase_orig, TH1 *hsec_orig, TString xlabel, TString ylabel, int cbase, int csec, int lbase, int lsec, float x1, float y1, float x2, float y2, TString legtitle, TString legbase, TString legsec, TString savefile)
OStream cout
Definition: OStream.cxx:6
ofstream summary