CVNphotonSplit.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 CVNphotonSplit()
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 
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 kTotal = Preselection && Energy;
63  const Cut kelectron = kElectron && Preselection && Energy;
64  const Cut kmuon = kMuon && Preselection && Energy;
65  const Cut kphoton = kPhoton && Preselection && Energy;
66  const Cut kpiplus = kPiPlus && Preselection && Energy;
67 
68 
69  //Define the spectrums to be filled from the loader.
70  Spectrum total("CVN Photon ID",pidbins,loader,kCVNphotonid,kTotal);
71  Spectrum electron("CVN Photon ID",pidbins,loader,kCVNphotonid,kelectron);
72  Spectrum muon("CVN Photon ID",pidbins,loader,kCVNphotonid,kmuon);
73  Spectrum photon("CVN Photon ID",pidbins,loader,kCVNphotonid,kphoton);
74  Spectrum piplus("CVN Photon ID",pidbins,loader,kCVNphotonid,kpiplus);
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("fCVNphotonSplit.root","RECREATE");
82  total.SaveTo(fpenergy->mkdir("total"));
83  electron.SaveTo(fpenergy->mkdir("electron"));
84  muon.SaveTo(fpenergy->mkdir("muon"));
85  photon.SaveTo(fpenergy->mkdir("photon"));
86  piplus.SaveTo(fpenergy->mkdir("piplus"));
87 
88 
89  fpenergy->Write();
90  std::cout << "\nOutput saved to " << fpenergy->GetName() << std::endl ;
91  fpenergy->Close();
92  return;
93 }
94 
95 #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 kElectron([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return false;if(sr->mc.nnu==0) return false;if(sr->vtx.elastic[0].fuzzyk.npng==0) return false;if(sr->vtx.elastic[0].fuzzyk.png[0].truth.pdg==11) return true;return false;})
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
const Cut kPhoton([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return false;if(sr->mc.nnu==0) return false;if(sr->vtx.elastic[0].fuzzyk.npng==0) return false;if(sr->vtx.elastic[0].fuzzyk.png[0].truth.pdg==22) return true;return false;})
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const ana::Binning pidbins
const Cut kPiPlus([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return false;if(sr->mc.nnu==0) return false;if(sr->vtx.elastic[0].fuzzyk.npng==0) return false;if(sr->vtx.elastic[0].fuzzyk.png[0].truth.pdg==211) return true;return false;})
void CVNphotonSplit()
const Cut Energy
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
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Cut kMuon([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0) return false;if(sr->mc.nnu==0) return false;if(sr->vtx.elastic[0].fuzzyk.npng==0) return false;if(sr->vtx.elastic[0].fuzzyk.png[0].truth.pdg==13) return true;return false;})
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
enum BeamMode string