print_nus17_fd_cut_tables2D.C
Go to the documentation of this file.
1 // This macro is used to make the nue energy blessed plots. (see doc 11789)
2 // Oscillation parameters are same as those in nue_ana_basic macro
3 
5 #include "CAFAna/Cuts/Cuts.h"
7 #include "CAFAna/Cuts/NueCutsFirstAna.h"
10 #include "CAFAna/Core/Spectrum.h"
11 #include "CAFAna/Vars/Vars.h"
12 #include "CAFAna/Cuts/TimingCuts.h"
13 #include "CAFAna/Analysis/Plots.h"
14 #include "CAFAna/Analysis/Style.h"
17 
18 #include "OscLib/OscCalcDumb.h"
19 #include "OscLib/OscCalcSterile.h"
22 
24 
25 #include "TH1D.h"
26 #include "TH2.h"
27 #include "TCanvas.h"
28 #include "TColor.h"
29 #include "TGraph.h"
30 #include "THStack.h"
31 #include "TMultiGraph.h"
32 #include "TLine.h"
33 #include "TLegend.h"
34 #include "TString.h"
35 #include "Utilities/rootlogon.C"
36 
37 using namespace ana;
38 
39 
40 const double pot_val = 9.0e20; // POT
41 const double livetime = 440.; // seconds
42 
43 
45  TH1*& hSig, TH1*& hNue, TH1*& hCC, TH1*& hTau, TH1*& hTotBkg)
46 {
47  hSig = pred->PredictComponent(calc,
51  hSig->SetLineColor(kNCBackgroundColor);
52 
53 
54  hNue = pred->PredictComponent(calc,
58  hNue->SetLineColor(kNueSignalColor);
59 
60  hCC = pred->PredictComponent(calc,
64  hCC->SetLineColor(kNumuBackgroundColor);
65 
66  hTau = pred->PredictComponent(calc,
70  hTau->SetLineColor(kMagenta);
71 
72  hTotBkg = (TH1*)hNue->Clone(UniqueName().c_str());
73  hTotBkg->Add(hCC);
74  hTotBkg->Add(hTau);
75 
76  hTotBkg->SetLineColor(kTotalMCColor);
77 }
79  TH2*& hSig, TH2*&hTotBkg)
80 {
81  hSig = pred->PredictComponent(calc,
85 
86  TH1* hNue = pred->PredictComponent(calc,
90 
91  TH1* hCC = pred->PredictComponent(calc,
95 
96  TH1* hBeam = pred->PredictComponent(calc,
100 
101  hTotBkg = (TH2*)hNue->Clone(UniqueName().c_str());
102  hTotBkg->Add(hCC);
103  hTotBkg->Add(hBeam);
104 
105 }
106 
107 
108 //------------------------------------------------------------
109 
111  const std::string pred_basename,
112  const std::string spec_basename,
113  const std::string fname,
114  const double cos_scaling,
115  const int ncuts,
116  bool savePlots=false)
117 {
119 
120 
121 
122  for(int ic = 7; ic < ncuts_nminus1; ic++){
123 
124  char name[50];
125 
126  sprintf(name, "%s_%s_%s",
127  pred_basename.c_str(),
128  cutnames_nminus1[ic].c_str(),
129  "2Dtime");
130 
131  std::cout << "name: "<< name << std::endl;
132  IPrediction* pred =
133  LoadFromFile<IPrediction>(fname, name).release();
134 
135  sprintf(name, "%s_%s_%s",
136  spec_basename.c_str(),
137  cutnames_nminus1[ic].c_str(),
138  "2Dtime");
139  std::cout << "name: "<< name << std::endl;
140  Spectrum* spec =
141  LoadFromFile<Spectrum>(fname, name).release();
142 
143  TH2 *sighist, *bghist;
144  GetSpectra2D(pred, osc, sighist, bghist);
145  std::cout << "here: "<< std::endl;
146  TH2* coshist = spec->ToTH2(cos_scaling,
148 
149  new TCanvas;
150 
151  //coshist->RebinX(3);
152  //coshist->RebinY(2);
153  ///coshist->SetTitle("Cosmic Data");
154  // coshist->GetXaxis()->SetTitle("Shower Maximum Y coordinate (cm)");
155  //coshist->GetYaxis()->SetTitle("p_{T}/p");
156  coshist->GetXaxis()->CenterTitle();
157  coshist->GetYaxis()->CenterTitle();
158 
159  coshist->Draw("colz");
160  Preliminary();
161  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dcos.png").c_str());
162  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dcos.eps").c_str());
163  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dcos.pdf").c_str());
164  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dcos.root").c_str());
165 
166  new TCanvas;
167  ///gStyle->SetTitleAlign(11);
168  //sighist->RebinX(3);
169  //sighist->RebinY(2);
170  //sighist->SetTitle("NC Signal");
171  //sighist->GetXaxis()->SetTitle("Shower Maximum Y coordinate (cm)");
172  //sighist->GetYaxis()->SetTitle("p_{T}/p");
173  sighist->GetXaxis()->CenterTitle();
174  sighist->GetYaxis()->CenterTitle();
175  sighist->Draw("colz");
176  Preliminary();
177  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dsig.png").c_str());
178  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dsig.eps").c_str());
179  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dsig.pdf").c_str());
180  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dsig.root").c_str());
181 
182 
183  new TCanvas;
184  bghist->Draw("colz");
185  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dbg.png").c_str());
186  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dbg.eps").c_str());
187  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dbg.pdf").c_str());
188  gPad->SaveAs(("plots2D/time_"+spec_basename+cutnames_nminus1[ic]+"2Dbg.root").c_str());
189 
190  }
191 
192 }
193 
194 //------------------------------------------------------------
195 
196 void print_nus17_fd_cut_tables2D(bool savePlots=false)
197 {
198 
199  //std::string fname = "/nova/ana/users/gsdavies/nus/nus17/FD_cutTable_extendedE.root";
200  std::string fname = "/nova/ana/users/gsdavies/nus/nus17/mcv1_2D_cut_tables_v2.root";
201  //std::string fname = "mcv1_cutTable.root";
202 
203  // cosmic livetime scaling
204  TFile fin(fname.c_str());
205  if(fin.IsZombie()){
206  std::cerr << "File: " << fname << " does not exist. Check the name." << std::endl;
207  exit(0);
208  }
209 
210 
211  TH1D* time = (TH1D*)gDirectory->Get("time_cos");
212  double scaling = 440.;
213 
214  char name[15];
215 
216 
217  std::cout<<"\n--------------------------------------"
218  <<"\n---------------N-1 Table -------------\n";
219 
221  "pred_nminus1",
222  "spec_nminus1",
223  fname, scaling, ncuts_nminus1, savePlots);
224 
225  std::cout<<"\n------------------------------------------"
226  <<"\n--------------Cut Flow Table -------------\n";
227 
228  // print_tables(cutnames,
229  // "pred",
230  // "spec",
231  // fname, scaling, ncuts, savePlots);
232 
233 }
TString fin
Definition: Style.C:24
const XML_Char * name
Definition: expat.h:151
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Definition: Spectrum.cxx:165
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
virtual Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const =0
(&#39; appearance&#39;)
Definition: IPrediction.h:18
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
(&#39;beam &#39;)
Definition: IPrediction.h:15
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
Adapt the PMNS_Sterile calculator to standard interface.
OStream cerr
Definition: OStream.cxx:7
osc::OscCalcDumb calc
const Color_t kNumuBackgroundColor
Definition: Style.h:30
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Color_t kNueSignalColor
Definition: Style.h:19
void scaling(TH1D *hIn, const double shape_scale)
Charged-current interactions.
Definition: IPrediction.h:39
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
const std::string cutnames[ncuts]
const std::string cutnames_nminus1[ncuts_nminus1]
Oscillation probability calculators.
Definition: Calcs.h:5
void Preliminary()
OStream cout
Definition: OStream.cxx:6
const int ncuts_nminus1
exit(0)
Neutral-current interactions.
Definition: IPrediction.h:40
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
const Color_t kTotalMCColor
Definition: Style.h:16
All neutrinos, any flavor.
Definition: IPrediction.h:26
const int ncuts
const Color_t kNCBackgroundColor
Definition: Style.h:22
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
enum BeamMode string