nue_decomp_scales_for_make_decomp.C
Go to the documentation of this file.
1 #ifdef __CINT__
2 void nue_decomp_scales(bool makeFile = false)
3 {
4  std::cout << "Sorry, you must run in compiled mode" << std::endl;
5 }
6 #else
7 
8 #include "CAFAna/Core/HistAxis.h"
9 #include "CAFAna/Core/Spectrum.h"
11 #include "CAFAna/Cuts/TimingCuts.h"
12 #include "CAFAna/Cuts/Cuts.h"
13 #include "CAFAna/Cuts/NueCutsSecondAna.h"
16 #include "CAFAna/Cuts/SpillCuts.h"
18 #include "CAFAna/Decomp/IDecomp.h"
26 #include "CAFAna/Vars/HistAxes.h"
30 #include "CAFAna/Vars/Vars.h"
31 #include "CAFAna/Vars/XsecTunes.h"
32 
34 
35 #include "TCanvas.h"
36 #include "TFile.h"
37 #include "TH1.h"
38 #include "TLegend.h"
39 #include "TPad.h"
40 
41 #include <iostream>
42 #include <memory>
43 
44 using namespace ana;
45 
46 //To be used with files produced with naming scheme /CAFAna/nue/Ana2018/Decomp/make_michel.C
47 
48 void nue_decomp_scales_for_make_decomp(bool makeCombo = false, bool makeProp = false)
49 {
50  //These are root file that contain the decompositions. Were made using make_michel.C with updated 2020 cuts.
51  //std::string filename = "nue_dcmp.FHC2020.root";
52  std::string filename = "nue_dcmp.RHC2020.root";
53  TFile* fin = new TFile(filename.c_str(), "read");
54 
55  //Only used for FHC in the analysis
56  if(makeCombo){
57  std::cout << "Extracting Combo scales...";
58  std::string dname="nue_decomps/michelbenDCMP";
59  MichelDecomp* michel = LoadFromFile<MichelDecomp>(fin, dname).release();
60 
61 
62  double pot = michel->Data_Component().POT();
63  std::cout << "Michel decomp POT is: " << pot << std::endl;
64 
65 
66 
67 
68  TH1* data = michel->Data_Component().ToTH1(pot);
69  TH1* nue_nom = michel->MC_NueComponent().ToTH1(pot);
70  TH1* numu_nom = michel->MC_NumuComponent().ToTH1(pot);
71  TH1* antinue_nom = michel->MC_AntiNueComponent().ToTH1(pot);
72  TH1* antinumu_nom = michel->MC_AntiNumuComponent().ToTH1(pot);
73  TH1* nc_nom = michel->MC_NCComponent().ToTH1(pot);
74 
75 
76 
77  TH1* nue_ratio = (TH1*)((michel->NueComponent().ToTH1(pot))->Clone("nue"));
78  nue_ratio->Divide(nue_nom);
79 
80  TH1* antinue_ratio = (TH1*)((michel->AntiNueComponent().ToTH1(pot))->Clone("antinue"));
81  antinue_ratio->Divide(antinue_nom);
82 
83  TH1* antinumu_ratio = (TH1*)((michel->AntiNumuComponent().ToTH1(pot))->Clone("antinumu"));
84  antinumu_ratio->Divide(antinumu_nom);
85 
86  TH1* numu_ratio = (TH1*)((michel->NumuComponent().ToTH1(pot))->Clone("numu"));
87  numu_ratio->Divide(numu_nom);
88 
89  TH1* nc_ratio = (TH1*)((michel->NCComponent().ToTH1(pot))->Clone("nc"));
90  nc_ratio->Divide(nc_nom);
91 
92  TFile* outputFile = new TFile("nue2020_fhc_combo_decomp_ratios.root", "update");
93  outputFile->cd();
94  nue_ratio->Write();
95  numu_ratio->Write();
96  nc_ratio->Write();
97  antinue_ratio->Write();
98  antinumu_ratio->Write();
99  outputFile->Close();
100  delete outputFile;
101  }
102  //Used for RHC in the analysis
103  if(makeProp){
104 
105  std::string dname="nue_decomps/propDCMP";
106 
107  ana::ProportionalDecomp* prop = ana::LoadFromFile<ana::ProportionalDecomp>(fin,dname).release();
108 
109  double pot = prop->Data_Component().POT();
110  std::cout << "Proportional decomp POT is: " << pot << std::endl;
111 
112 
113 
114  TH1* data = prop->Data_Component().ToTH1(pot);
115  TH1* nue_nom = prop->MC_NueComponent().ToTH1(pot);
116  TH1* numu_nom = prop->MC_NumuComponent().ToTH1(pot);
117  TH1* antinue_nom = prop->MC_AntiNueComponent().ToTH1(pot);
118  TH1* antinumu_nom = prop->MC_AntiNumuComponent().ToTH1(pot);
119  TH1* nc_nom = prop->MC_NCComponent().ToTH1(pot);
120 
121 
122  TH1* nue_ratio = (TH1*)((prop->NueComponent().ToTH1(pot))->Clone("nue"));
123  nue_ratio->Divide(nue_nom);
124 
125  TH1* antinue_ratio = (TH1*)((prop->AntiNueComponent().ToTH1(pot))->Clone("antinue"));
126  antinue_ratio->Divide(antinue_nom);
127 
128  TH1* antinumu_ratio = (TH1*)((prop->AntiNumuComponent().ToTH1(pot))->Clone("antinumu"));
129  antinumu_ratio->Divide(antinumu_nom);
130 
131  TH1* numu_ratio = (TH1*)((prop->NumuComponent().ToTH1(pot))->Clone("numu"));
132  numu_ratio->Divide(numu_nom);
133 
134  TH1* nc_ratio = (TH1*)((prop->NCComponent().ToTH1(pot))->Clone("nc"));
135  nc_ratio->Divide(nc_nom);
136 
137  TFile* outputFile = new TFile("nue2020_rhc_prop_decomp_ratios.root", "update");
138  outputFile->cd();
139  nue_ratio->Write();
140  numu_ratio->Write();
141  nc_ratio->Write();
142  antinue_ratio->Write();
143  antinumu_ratio->Write();
144  outputFile->Close();
145  delete outputFile;
146 
147  }
148 
149 
150 
151 
152 
153 
154 }
155 #endif
TString fin
Definition: Style.C:24
virtual Spectrum Data_Component() const override
Spectrum AntiNueComponent() const override
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
Spectrum MC_AntiNumuComponent() const override
Spectrum Data_Component() const override
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:148
virtual Spectrum AntiNumuComponent() const override
virtual Spectrum NCComponent() const override
string filename
Definition: shutoffs.py:106
virtual Spectrum NumuComponent() const override
Spectrum MC_NueComponent() const override
Spectrum MC_AntiNueComponent() const override
virtual Spectrum AntiNueComponent() const override
const XML_Char const XML_Char * data
Definition: expat.h:268
Spectrum MC_AntiNumuComponent() const override
Spectrum MC_NumuComponent() const override
virtual Spectrum NueComponent() const override
#define pot
Spectrum AntiNumuComponent() const override
void nue_decomp_scales_for_make_decomp(bool makeCombo=false, bool makeProp=false)
double POT() const
Definition: Spectrum.h:227
OStream cout
Definition: OStream.cxx:6
Spectrum MC_NumuComponent() const override
Splits Data proportionally according to MC.
Spectrum NumuComponent() const override
Spectrum MC_NueComponent() const override
Spectrum MC_NCComponent() const override
Spectrum MC_AntiNueComponent() const override
Spectrum NCComponent() const override
void nue_decomp_scales(bool makeFile=false)
Spectrum MC_NCComponent() const override
Spectrum NueComponent() const override
enum BeamMode string