ShwZOpt.C
Go to the documentation of this file.
1 #include "CAFAna/Core/Binning.h"
2 #include "CAFAna/Cuts/Cuts.h"
3 #include "CAFAna/Vars/FitVars.h"
7 #include "CAFAna/Core/Spectrum.h"
10 #include "CAFAna/Vars/Vars.h"
11 
13 
14 #include "TCanvas.h"
15 #include "TH2.h"
16 #include "TStyle.h"
17 #include "TArrow.h"
18 #include "TH1.h"
19 #include "TH3.h"
20 #include "TFile.h"
21 #include "TLegend.h"
22 #include "TGraph.h"
23 #include <cmath>
24 #include <cassert>
25 #include <memory>
26 #include "TProfile.h"
27 #include <fstream>
28 #include <sstream>
29 #include <iostream>
30 #include <iomanip>
31 #include <stdarg.h>
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <string.h>
35 
36 using namespace ana;
37 
38 void ShwZOpt()
39 {
40  const std::string Full_MC = "dataset_def_name_newest_snapshot prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
41 
42  //Pass the desired file to the spectrum loader.
43  SpectrumLoader loader(Full_MC);
44 
45 
46  const Binning fidz = Binning::Simple(100,0,1600);
47 
48  const Cut kSignal = Signal && kVtx && k1Prong;
49  const Cut kBkg = Bkg && kVtx && k1Prong;
50  const Cut kNCBkg = NCBkg && kVtx && k1Prong;
51  const Cut kCCPi0Bkg = CCPi0Bkg && kVtx && k1Prong;
52  const Cut kCCNonPi0Bkg = CCNonPi0Bkg && kVtx && k1Prong;
53 
54 
55  //Define spectra for vertex in Z view.
56  Spectrum sigfidz("Vertex in Z",fidz,loader,kShwz,kSignal);
57  Spectrum bkgfidz("Vertex in Z",fidz,loader,kShwz,kBkg);
58  Spectrum ncbkgfidz("Vertex in Z",fidz,loader,kShwz,kNCBkg);
59  Spectrum ccpi0bkgfidz("Vertex in Z",fidz,loader,kShwz,kCCPi0Bkg);
60  Spectrum ccnonpi0bkgfidz("Vertex in Z",fidz,loader,kShwz,kCCNonPi0Bkg);
61 
62 
63  //Load the spectra from the dataset.
64  loader.Go();
65 
66  //Create root file and fill it with each spectrum.
67  TFile *fvolumes = new TFile("containmentZoptimization.root","RECREATE");
68 
69  sigfidz.SaveTo(fvolumes->mkdir("sigfidz"));
70  bkgfidz.SaveTo(fvolumes->mkdir("bkgfidz"));
71  ncbkgfidz.SaveTo(fvolumes->mkdir("ncbkgfidz"));
72  ccpi0bkgfidz.SaveTo(fvolumes->mkdir("ccpi0bkgfidz"));
73  ccnonpi0bkgfidz.SaveTo(fvolumes->mkdir("ccnonpi0bkgfidz"));
74 
75  fvolumes->Write();
76  std::cout << "\nOutput saved to " << fvolumes->GetName() << std::endl ;
77  fvolumes->Close();
78  return;
79 }
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
const Cut k1Prong([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0 &&sr->mc.nnu==0) return false;return(sr->vtx.elastic[0].fuzzyk.npng==1);})
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 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;})
void ShwZOpt()
Definition: ShwZOpt.C:38
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;})
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
loader
Definition: demo0.py:10
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
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.
const Cut kVtx([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0 &&sr->mc.nnu==0) return false;return(sr->vtx.nelastic==0);})
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
const Var kShwz([](const caf::SRProxy *sr){return sr->vtx.elastic[0].fuzzyk.png[0].shwlid.stop.z;})
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