CVNphoton.C
Go to the documentation of this file.
1 //Create a histogram from the cuts and variables defined in the singleprongCuts and singleprongVars headers.
2 #ifdef __CINT__
3 void CVNphoton()
4 {
5  std::cout << "Sorry, you must run in compiled mode" << std::endl;
6 }
7 #else
8 
9 #include "CAFAna/Core/Binning.h"
10 #include "CAFAna/Cuts/Cuts.h"
11 #include "CAFAna/Vars/FitVars.h"
12 #include "CAFAna/Analysis/Plots.h"
15 #include "CAFAna/Core/Spectrum.h"
18 #include "CAFAna/Vars/Vars.h"
19 
21 
22 #include "TCanvas.h"
23 #include "TH2.h"
24 #include "TStyle.h"
25 #include "TArrow.h"
26 #include "TH1.h"
27 #include "TH3.h"
28 #include "TFile.h"
29 #include "TLegend.h"
30 #include "TGraph.h"
31 #include <cmath>
32 #include <cassert>
33 #include <memory>
34 #include "TProfile.h"
35 #include <fstream>
36 #include <sstream>
37 #include <iostream>
38 #include <iomanip>
39 #include <stdarg.h>
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <string.h>
43 
44 
45 using namespace ana;
46 
47 void CVNphoton()
48 {
49  //Use a snapshot of the full dataset for running on the grid.
50  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";
51 
52 
53  //Pass the desired file to the spectrum loader.
54  SpectrumLoader loader(Full_MC);
55 
56 
57  //Specify the binning of the histogram.
58  const Binning pidbins = Binning::Simple(81,-1/160.,1+1/160.);
59 
60 
61  //Define Cuts
62  const Cut kSignal = Signal && Preselection && Energy;
63  const Cut kBkg = Bkg && Preselection && Energy;
64  const Cut kNCBkg = NCBkg && Preselection && Energy;
67 
68 
69  //Define the spectrums to be filled from the loader.
70  Spectrum sig("CVN Photon ID",pidbins,loader,kCVNphotonid,kSignal);
71  Spectrum bkg("CVN Photon ID",pidbins,loader,kCVNphotonid,kBkg);
72  Spectrum ncbkg("CVN Photon ID",pidbins,loader,kCVNphotonid,kNCBkg);
73  Spectrum ccpi0bkg("CVN Photon ID",pidbins,loader,kCVNphotonid,kCCPi0Bkg);
74  Spectrum ccnonpi0bkg("CVN Photon ID",pidbins,loader,kCVNphotonid,kCCNonPi0Bkg);
75 
76 
77  //Load the spectrum.
78  loader.Go();
79 
80  //Create a root file with all of the information.
81  TFile *fpenergy = new TFile("bkgsplittest.root","RECREATE");
82  sig.SaveTo(fpenergy->mkdir("sig"));
83  bkg.SaveTo(fpenergy->mkdir("bkg"));
84  ncbkg.SaveTo(fpenergy->mkdir("ncbkg"));
85  ccpi0bkg.SaveTo(fpenergy->mkdir("ccpi0bkg"));
86  ccnonpi0bkg.SaveTo(fpenergy->mkdir("ccnonpi0bkg"));
87 
88  fpenergy->Write();
89  std::cout << "\nOutput saved to " << fpenergy->GetName() << std::endl ;
90  fpenergy->Close();
91  return;
92 }
93 
94 #endif
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
void CVNphoton()
Definition: CVNphoton.C:47
const Var kCVNphotonid([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return 0.f;if(sr->vtx.elastic[0].fuzzyk.npng >1) return float(-1);return float(sr->vtx.elastic[0].fuzzyk.png[0].cvnpart.photonid);})
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 ana::Binning pidbins
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 Energy
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.
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