resolutionstudy.C
Go to the documentation of this file.
1 // Do a proper prediction, with all the components included
2 
3 #ifdef __CINT__
4 void resolutionstudy()
5 {
6  std::cout << "Sorry, you must run in compiled mode" << std::endl;
7 }
8 #else
9 
10 //CAFAna Libraries
11 #include "CAFAna/Cuts/Cuts.h"
12 #include "CAFAna/Analysis/Plots.h"
13 #include "CAFAna/Core/SpectrumLoaderMockData.h"
16 #include "CAFAna/Core/Spectrum.h"
18 #include "CAFAna/Vars/Vars.h"
20 
21 
22 //Plotting Libraries
23 #include "TCanvas.h"
24 #include "TH2.h"
25 #include "TH1.h"
26 #include "TFitResultPtr.h"
27 #include "TLegend.h"
28 
31 
32 
33 using namespace ana;
34 
35 const double pot = 8.08988e+20;
36 
37 void saveS(Spectrum s, string name)
38 {
39  TH1D *h = s.ToTH1(s.POT());
40  h->SetName(name.c_str());
41  h->SetLineColor(kRed);
42  h->Write();
43 }
44 
45 void saveS1(Spectrum s, string name)
46 {
47  TH2 *h1 = s.ToTH2(s.POT());
48  h1->SetName(name.c_str());
49  h1->SetLineColor(kRed);
50  h1->Write();
51 }
52 
53 
54 /***************************************/
56 
57 {
58  //Define Dataset
59  const std::string MC = "dataset_def_name_newest_snapshot prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
60 
61  const Binning DeltaEBins = Binning::Simple(100,-1.5,1.5);
62 
63  SpectrumLoader mcloader(MC);
64 
65  const Cut kSignal = Signal && Preselection;
66  const Cut kBkg = Bkg && Preselection;
67  const Cut kNCBkg = NCBkg && Preselection;
70 
71  //Define Resolution Spectra with CVN Photon cut considered
72  Spectrum PreselEnRes("Presel (True-Reco) Total Energy [GeV]",DeltaEBins, mcloader,kDeltaEnergy,Preselection && kNCPi0BDTID>0.85);
73  Spectrum SigEnRes("Signal (True-Reco) Total Energy [GeV]",DeltaEBins,mcloader,kDeltaEnergy,kSignal && kNCPi0BDTID>0.85);
74  Spectrum BkgEnRes("Background (True-Reco) Total Energy [GeV]",DeltaEBins,mcloader,kDeltaEnergy,kBkg && kNCPi0BDTID>0.85);
75 
76  mcloader.Go();
77 
78  //Save to root file
79  TFile *out = new TFile("EnergyResolution1DSpectraHighBDTCut.root","RECREATE");
80 
81  PreselEnRes.SaveTo(out->mkdir("PreselEnRes"));
82  SigEnRes.SaveTo(out->mkdir("SigEnRes"));
83  BkgEnRes.SaveTo(out->mkdir("BkgEnRes"));
84  //CCPi0EnRes.SaveTo(out->mkdir("CCPi0EnRes"));
85  //NCNoPi0EnRes.SaveTo(out->mkdir("NCNoPi0EnRes"));
86  //CCNoPi0EnRes.SaveTo(out->mkdir("CCNoPi0EnRes"));
87 
88  std::cout<<"\nOutput saved to " << out->GetName()<<std::endl;
89  out->Close();
90  return;
91 }
92 #endif
const XML_Char * name
Definition: expat.h:151
const Var kNCPi0BDTID
Definition: NDNCPi0Xsec.h:23
enum BeamMode kRed
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Definition: Spectrum.cxx:165
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Cut Signal
Definition: ncpi0Cuts.h:811
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:148
const Cut Preselection
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Cut NCBkg([](const caf::SRProxy *sr){float MassOfPi0=0.135;float kinetic=-10;float en=-99;if(sr->mc.nnu==0) return false;if(sr->vtx.nelastic==0) return false;if(sr->mc.nu[0].prim.size()==0) return false;int nbofprim=sr->mc.nu[0].prim.size();int countpi=0;for(int i=0;i< nbofprim;i++){if(sr->mc.nu[0].prim[i].pdg==111){en=sr->mc.nu[0].prim[i].p.E;kinetic=en-MassOfPi0;countpi++;}}if(countpi==0 &&!sr->mc.nu[0].iscc) return true;return false;})
const XML_Char * s
Definition: expat.h:262
const Cut CCPi0Bkg([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;if(sr->vtx.nelastic==0) return false;if(sr->mc.nu[0].prim.size()==0) return false;int nbofprim=sr->mc.nu[0].prim.size();int countpi=0;for(int i=0;i< nbofprim;i++){if(sr->mc.nu[0].prim[i].pdg==111) countpi++;}if(countpi > 0 &&sr->mc.nu[0].iscc) return true;return false;})
const Cut kNCBkg([](const caf::SRProxy *sr){float MassOfPi0=0.135;float kinetic=-10;float en=-99;if(sr->mc.nnu==0) return false;if(sr->vtx.nelastic==0) return false;if(sr->mc.nu[0].prim.size()==0) return false;int nbofprim=sr->mc.nu[0].prim.size();int countpi=0;for(int i=0;i< nbofprim;i++){if(sr->mc.nu[0].prim[i].pdg==111){en=sr->mc.nu[0].prim[i].p.E;kinetic=en-MassOfPi0;if(kinetic > 0.5) countpi++;}}if(countpi==0 &&!sr->mc.nu[0].iscc) return true;return false;})
void saveS1(Spectrum s, string name)
const Cut Bkg
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
double POT() const
Definition: Spectrum.h:227
const double pot
OStream cout
Definition: OStream.cxx:6
const Cut kCCNonPi0Bkg([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;if(sr->vtx.nelastic==0) return false;if(sr->mc.nu[0].prim.size()==0) return false;int nbofprim=sr->mc.nu[0].prim.size();int countpi=0;for(int i=0;i< nbofprim;i++){if(sr->mc.nu[0].prim[i].pdg==111) countpi++;}if(countpi==0 &&sr->mc.nu[0].iscc) return true;return false;})
const Cut kSignal
Definition: SINCpi0_Cuts.h:325
TH1F * h1
void resolutionstudy()
const Cut CCNonPi0Bkg([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;if(sr->vtx.nelastic==0) return false;if(sr->mc.nu[0].prim.size()==0) return false;int nbofprim=sr->mc.nu[0].prim.size();int countpi=0;for(int i=0;i< nbofprim;i++){if(sr->mc.nu[0].prim[i].pdg==111) countpi++;}if(countpi==0 &&sr->mc.nu[0].iscc) return true;return false;})
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
void saveS(Spectrum s, string name)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
const Cut kCCPi0Bkg([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;if(sr->vtx.nelastic==0) return false;if(sr->mc.nu[0].prim.size()==0) return false;int nbofprim=sr->mc.nu[0].prim.size();int countpi=0;for(int i=0;i< nbofprim;i++){if(sr->mc.nu[0].prim[i].pdg==111) countpi++;}if(countpi > 0 &&sr->mc.nu[0].iscc) return true;return false;})
enum BeamMode string