twodstudyvtxcont.C
Go to the documentation of this file.
1 // Do a proper prediction, with all the components included
2 
3 #ifdef __CINT__
4 void twodstudyvtxcont()
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 //////////////////////////
29 
30 ///////NCPi0 Headers//////
31 #include "/nova/app/users/acedeno/tag_releaseS17-09-24/NDAna/ncpi0_Systematics/ncpi0Bins.h"
32 #include "/nova/app/users/acedeno/tag_releaseS17-09-24/NDAna/ncpi0_Systematics/ncpi0Cuts.h"
33 #include "/nova/app/users/acedeno/tag_releaseS17-09-24/NDAna/ncpi0_Systematics/ncpi0Vars.h"
34 /////////////////////////
35 
36 using namespace ana;
37 
38 
39 
41 
42 {
43 
44  /*********************************************************************************************************************/
45 
46  //Enviroment variables and wildcards work
47 
48  const std::string MC = "dataset_def_name_newest_snapshot prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
49  //const std::string Numi = "prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns";
50 
51  /*********************************************************************************************************************/
52 
53  //Create loader for each 'data' type
54 
55  SpectrumLoader mcloader(MC);
56  //SpectrumLoader dataloader(Numi);
57 
58  /*********************************************************************************************************************/
59 
60  ///////////Data////////////
61 
62  ////////////Spectrum w/ kNueNDCont cut (Data)////////////////////////////
63 
64  //Spectrum ndNumi(" Prong 1 Shower Length [cm]",PLBins,dataloader, kprong3L,kNueNDCont);
65 
66  /*********************************************************************************************************************/
67 
68  ///////////MC///////////////
69 
70  /////////2 prong event spectrum analysis/////////////
71 
72  /////All interactions///////////
73 
74  ///vertex
75 
76  Spectrum nd2dplot2prongx("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarX,k2ProngPreSel2CVN);
77  Spectrum nd2dplot2prongy("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarY,k2ProngPreSel2CVN);
78  Spectrum nd2dplot2prongz("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,FidVarZ,k2ProngPreSel2CVN);
79 
80  ///containment
81 
82  Spectrum nd2dplot2prongcontX("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopX,k2ProngPreSel2CVN);
83  Spectrum nd2dplot2prongcontY("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopY,k2ProngPreSel2CVN);
84  Spectrum nd2dplot2prongcontZ("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,ContStopZ,k2ProngPreSel2CVN);
85 
86 
87  /////CC Non pi0 Interactions/////////\
88 
89  ///vertex
90 
91  Spectrum nd2dplot2prongCCNonPi0x("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarX,kIsCCNonPi02P);
92  Spectrum nd2dplot2prongCCNonPi0y("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarY,kIsCCNonPi02P);
93  Spectrum nd2dplot2prongCCNonPi0z("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,FidVarZ,kIsCCNonPi02P);
94 
95  ///containment
96 
97  Spectrum nd2dplot2prongCCNonPi0contX("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopX,kIsCCNonPi02P);
98  Spectrum nd2dplot2prongCCNonPi0contY("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopY,kIsCCNonPi02P);
99  Spectrum nd2dplot2prongCCNonPi0contZ("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,ContStopZ,kIsCCNonPi02P);
100 
101  /////NC Non pi0 Interactions/////////\
102 
103  ///vertex
104 
105  Spectrum nd2dplot2prongNCNonPi0x("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarX,kIsNCNonPi02P);
106  Spectrum nd2dplot2prongNCNonPi0y("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarY,kIsNCNonPi02P);
107  Spectrum nd2dplot2prongNCNonPi0z("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,FidVarZ,kIsNCNonPi02P);
108 
109  ///containment
110 
111  Spectrum nd2dplot2prongNCNonPi0contX("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopX,kIsNCNonPi02P);
112  Spectrum nd2dplot2prongNCNonPi0contY("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopY,kIsNCNonPi02P);
113  Spectrum nd2dplot2prongNCNonPi0contZ("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,ContStopZ,kIsNCNonPi02P);
114 
115  /////CC pi0 Interactions/////////\
116 
117  ///vertex
118 
119  Spectrum nd2dplot2prongCCPi0x("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarX,kIsCCPi02P);
120  Spectrum nd2dplot2prongCCPi0y("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarY,kIsCCPi02P);
121  Spectrum nd2dplot2prongCCPi0z("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,FidVarZ,kIsCCPi02P);
122 
123  ///containment
124 
125  Spectrum nd2dplot2prongCCPi0contX("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopX,kIsCCPi02P);
126  Spectrum nd2dplot2prongCCPi0contY("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopY,kIsCCPi02P);
127  Spectrum nd2dplot2prongCCPi0contZ("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,ContStopZ,kIsCCPi02P);
128 
129  /////NC pi0 Interactions/////////\
130 
131  ///vertex
132 
133  Spectrum nd2dplot2prongNCPi0x("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarX,kIsNCPi02P);
134  Spectrum nd2dplot2prongNCPi0y("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarY,kIsNCPi02P);
135  Spectrum nd2dplot2prongNCPi0z("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,FidVarZ,kIsNCPi02P);
136 
137  ///containment
138 
139  Spectrum nd2dplot2prongNCPi0contX("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopX,kIsNCPi02P);
140  Spectrum nd2dplot2prongNCPi0contY("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopY,kIsNCPi02P);
141  Spectrum nd2dplot2prongNCPi0contZ("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,ContStopZ,kIsNCPi02P);
142 
143  /////NC pi0 low energy Interactions/////////\
144 
145  ///vertex
146 
147  Spectrum nd2dplot2prongNCPi0Lx("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarX, kIsNCPi0L2P);
148  Spectrum nd2dplot2prongNCPi0Ly("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,FidVarY, kIsNCPi0L2P);
149  Spectrum nd2dplot2prongNCPi0Lz("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,FidVarZ, kIsNCPi0L2P);
150 
151  ///containment
152 
153  Spectrum nd2dplot2prongNCPi0LcontX("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopX, kIsNCPi0L2P);
154  Spectrum nd2dplot2prongNCPi0LcontY("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxXY,ContStopY, kIsNCPi0L2P);
155  Spectrum nd2dplot2prongNCPi0LcontZ("#pi^{0} True Energy [GeV] vs. #pi^{0} Reconstructed Mass [GeV]",mcloader,Pi0Massbins,kPi0RecoMass,bins_for_vtxZ,ContStopZ, kIsNCPi0L2P);
156 
157 
158 
159  /*********************************************************************************************************************/
160 
161  // Once all spectra are registered, loop through input files, extracting variable values and filling histograms.
162  //Total POT is accumulated and used to set spectra POT.
163 
164  mcloader.Go();
165  //dataloader.Go();
166 
167 
168 
169  /*********************************************************************************************************************/
170 
171  ///saving root file//
172 
173  TFile *out = new TFile("2dvtxcontsutyplotsdifferentinteractions.root","RECREATE");
174  //ndNumi.SaveTo(out->mkdir("ndNumi"));
175  //ndNCMCSig.SaveTo(out->mkdir("ndNCMCSig"));
176 
177  ////2D Plots 2 prong///////
178  /////All interactions///////////
179  nd2dplot2prongx.SaveTo(out->mkdir("nd2dplot2prongx"));
180  nd2dplot2prongy.SaveTo(out->mkdir("nd2dplot2prongy"));
181  nd2dplot2prongz.SaveTo(out->mkdir("nd2dplot2prongz"));
182 
183  nd2dplot2prongcontX.SaveTo(out->mkdir("nd2dplot2prongcontX"));
184  nd2dplot2prongcontY.SaveTo(out->mkdir("nd2dplot2prongcontY"));
185  nd2dplot2prongcontZ.SaveTo(out->mkdir("nd2dplot2prongcontZ"));
186 
187  /////CC Non pi0 Interactions///////////
188  nd2dplot2prongCCNonPi0x.SaveTo(out->mkdir("nd2dplot2prongCCNonPi0x"));
189  nd2dplot2prongCCNonPi0y.SaveTo(out->mkdir("nd2dplot2prongCCNonPi0y"));
190  nd2dplot2prongCCNonPi0z.SaveTo(out->mkdir("nd2dplot2prongCCNonPi0z"));
191 
192  nd2dplot2prongCCNonPi0contX.SaveTo(out->mkdir("nd2dplot2prongCCNonPi0contX"));
193  nd2dplot2prongCCNonPi0contY.SaveTo(out->mkdir("nd2dplot2prongCCNonPi0contY"));
194  nd2dplot2prongCCNonPi0contZ.SaveTo(out->mkdir("nd2dplot2prongCCNonPi0contZ"));
195 
196  /////NC Non pi0 Interactions///////////
197  nd2dplot2prongNCNonPi0x.SaveTo(out->mkdir("nd2dplot2prongNCNonPi0x"));
198  nd2dplot2prongNCNonPi0y.SaveTo(out->mkdir("nd2dplot2prongNCNonPi0y"));
199  nd2dplot2prongNCNonPi0z.SaveTo(out->mkdir("nd2dplot2prongNCNonPi0z"));
200 
201  nd2dplot2prongNCNonPi0contX.SaveTo(out->mkdir("nd2dplot2prongNCNonPi0contX"));
202  nd2dplot2prongNCNonPi0contY.SaveTo(out->mkdir("nd2dplot2prongNCNonPi0contY"));
203  nd2dplot2prongNCNonPi0contZ.SaveTo(out->mkdir("nd2dplot2prongNCNonPi0contZ"));
204 
205  /////CC Pi0 interactions///////////
206  nd2dplot2prongCCPi0x.SaveTo(out->mkdir("nd2dplot2prongCCPi0x"));
207  nd2dplot2prongCCPi0y.SaveTo(out->mkdir("nd2dplot2prongCCPi0y"));
208  nd2dplot2prongCCPi0z.SaveTo(out->mkdir("nd2dplot2prongCCPi0z"));
209 
210  nd2dplot2prongCCPi0contX.SaveTo(out->mkdir("nd2dplot2prongCCPi0contX"));
211  nd2dplot2prongCCPi0contY.SaveTo(out->mkdir("nd2dplot2prongCCPi0contY"));
212  nd2dplot2prongCCPi0contZ.SaveTo(out->mkdir("nd2dplot2prongCCPi0contZ"));
213 
214  /////NC Pi0 interactions///////////
215  nd2dplot2prongNCPi0x.SaveTo(out->mkdir("nd2dplot2prongNCPi0x"));
216  nd2dplot2prongNCPi0y.SaveTo(out->mkdir("nd2dplot2prongNCPi0y"));
217  nd2dplot2prongNCPi0z.SaveTo(out->mkdir("nd2dplot2prongNCPi0z"));
218 
219  nd2dplot2prongNCPi0contX.SaveTo(out->mkdir("nd2dplot2prongNCPi0contX"));
220  nd2dplot2prongNCPi0contY.SaveTo(out->mkdir("nd2dplot2prongNCPi0contY"));
221  nd2dplot2prongNCPi0contZ.SaveTo(out->mkdir("nd2dplot2prongNCPi0contZ"));
222 
223  /////NC Pi0 low energy interactions///////////
224  nd2dplot2prongNCPi0Lx.SaveTo(out->mkdir("nd2dplot2prongNCPi0Lx"));
225  nd2dplot2prongNCPi0Ly.SaveTo(out->mkdir("nd2dplot2prongNCPi0Ly"));
226  nd2dplot2prongNCPi0Lz.SaveTo(out->mkdir("nd2dplot2prongNCPi0Lz"));
227 
228  nd2dplot2prongNCPi0LcontX.SaveTo(out->mkdir("nd2dplot2prongNCPi0LcontX"));
229  nd2dplot2prongNCPi0LcontY.SaveTo(out->mkdir("nd2dplot2prongNCPi0LcontY"));
230  nd2dplot2prongNCPi0LcontZ.SaveTo(out->mkdir("nd2dplot2prongNCPi0LcontZ"));
231 
232 
233 
234  std::cout<<"\nOutput saved to " << out->GetName()<<std::endl;
235 
236 
237  out->Close();
238 
239  return;
240 
241 }
242 
243 #endif
244 
const Var kPi0RecoMass([](const caf::SRProxy *sr){float pi0mass;float dotproduct;if(sr->vtx.nelastic==0) return 0.0f;if(sr->mc.nnu==0) return 0.0f;if(sr->mc.nu[0].prim.size()==0) return 0.0f;if(sr->vtx.elastic[0].fuzzyk.npng< 2) return float(-1);dotproduct=sr->vtx.elastic[0].fuzzyk.png[0].shwlid.dir.Unit().Dot(sr->vtx.elastic[0].fuzzyk.png[1].shwlid.dir.Unit());pi0mass=sqrt((2 *(sr->vtx.elastic[0].fuzzyk.png[0].shwlid.calE *sr->vtx.elastic[0].fuzzyk.png[1].shwlid.calE))*(1-dotproduct));return pi0mass;})
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var ContStopZ([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return-10.0f;if(sr->vtx.nelastic==0) return-10.0f;return float(sr->vtx.elastic[0].fuzzyk.png[0].shwlid.stop.z);})
const Cut kIsNCNonPi02P
Definition: ncpi0Cuts.h:873
const Var ContStopX([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return-10.0f;if(sr->vtx.nelastic==0) return-10.0f;return float(sr->vtx.elastic[0].fuzzyk.png[0].shwlid.stop.x);})
const Var FidVarY([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return-10.0f;if(sr->vtx.nelastic==0) return-10.0f;return float(sr->vtx.elastic[0].vtx.y);})
const Cut kIsNCPi0L2P
Definition: ncpi0Cuts.h:894
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Var ContStopY([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return-10.0f;if(sr->vtx.nelastic==0) return-10.0f;return float(sr->vtx.elastic[0].fuzzyk.png[0].shwlid.stop.y);})
const Cut kIsCCPi02P
Definition: ncpi0Cuts.h:897
const Binning Pi0Massbins
Definition: ncpi0Bins.h:28
const Cut kIsNCPi02P
Definition: ncpi0Cuts.h:891
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
const Var FidVarZ([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return-10.0f;if(sr->vtx.nelastic==0) return-10.0f;return float(sr->vtx.elastic[0].vtx.z);})
OStream cout
Definition: OStream.cxx:6
const Cut k2ProngPreSel2CVN
Definition: ncpi0Cuts.h:864
const Binning bins_for_vtxXY
Definition: ncpi0Bins.h:35
const Cut kIsCCNonPi02P
Definition: ncpi0Cuts.h:870
void twodstudyvtxcont()
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Var FidVarX([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return-10.0f;if(sr->vtx.nelastic==0) return-10.0f;return float(sr->vtx.elastic[0].vtx.x);})
Fiducial volume Variable///.
const Binning bins_for_vtxZ
Definition: ncpi0Bins.h:39
enum BeamMode string