ReMId.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 ReMId()
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 ReMId()
48 {
49 
50  //Use a snapshot of the full dataset for running on the grid.
51  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";
52 
53 
54 
55 
56  //Pass the desired file to the spectrum loader.
57  SpectrumLoader loader(Full_MC);
58 
59  //Specify the binning of the histogram.
60  const Binning remidbins = Binning::Simple(81,-1/160.,1+1/160.);
61 
62  //Package cuts together.
63  const Cut kSignal = Signal && kVtx && k1Prong && kFiducial && kContainment;
64 
65  const Cut kBkg = Bkg && kVtx && k1Prong && kFiducial && kContainment;
66 
67  const Cut kNCBkg = NCBkg && kVtx && k1Prong && kFiducial && kContainment;
68 
70 
72 
73  //Define the spectrums to be filled from the loader.
74  Spectrum sig("ReMId",remidbins,loader,kReMId,kSignal);
75 
76  Spectrum bkg("ReMId",remidbins,loader,kReMId,kBkg);
77 
78  Spectrum ncbkg("ReMId",remidbins,loader,kReMId,kNCBkg);
79 
80  Spectrum ccpi0bkg("ReMId",remidbins,loader,kReMId,kCCPi0Bkg);
81 
82  Spectrum ccnonpi0bkg("ReMId",remidbins,loader,kReMId,kCCNonPi0Bkg);
83 
84 
85  //Load the spectrum.
86  loader.Go();
87 
88  TFile *fpid = new TFile("fReMIdOptVol.root","RECREATE");
89  sig.SaveTo(fpid->mkdir("sig"));
90  bkg.SaveTo(fpid->mkdir("bkg"));
91  ncbkg.SaveTo(fpid->mkdir("ncbkg"));
92  ccpi0bkg.SaveTo(fpid->mkdir("ccpi0bkg"));
93  ccnonpi0bkg.SaveTo(fpid->mkdir("ccnonpi0bkg"));
94 
95  fpid->Write();
96  std::cout << "\nOutput saved to " << fpid->GetName() << std::endl ;
97  fpid->Close();
98  return;
99 }
100 
101 #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
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);})
const Var kReMId([](const caf::SRProxy *sr){return sr->sel.remid.pid;})
const Binning remidbins
Definition: NumuCCIncBins.h:53
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;})
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
const Cut kFiducial([](const caf::SRProxy *sr){if(sr->vtx.nelastic==0 &&sr->mc.nnu==0) return false;if((sr->vtx.elastic[0].vtx.x)< -170.0) return false;if((sr->vtx.elastic[0].vtx.x) > 170.0) return false;if((sr->vtx.elastic[0].vtx.y)< -160.0) return false;if((sr->vtx.elastic[0].vtx.y) > 170.0) return false;if((sr->vtx.elastic[0].vtx.z)< 50.0) return false;if((sr->vtx.elastic[0].vtx.z) > 1100.0) return false;return true;})
loader
Definition: demo0.py:10
const Cut kContainment([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;if(sr->vtx.nelastic==0) return false;if(sr->vtx.elastic[0].fuzzyk.nshwlid==0) return false;if(sr->vtx.elastic[0].fuzzyk.npng==0) return false;for(unsigned int i=0;i< sr->vtx.elastic[0].fuzzyk.nshwlid;i++){if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.x)< -160.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.x) > 120.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.y)< -180.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.y) > 155.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.z)< 200.0) return false;if((sr->vtx.elastic[0].fuzzyk.png[i].shwlid.stop.z) > 1200.0) return false;}return true;})
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);})
void ReMId()
Definition: ReMId.C:47
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