Functions | Variables
nue_nd_datastability.C File Reference
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Core/LoadFromFile.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "3FlavorAna/Cuts/NueCuts2017.h"
#include "CAFAna/Vars/Vars.h"
#include "3FlavorAna/Vars/NueVars.h"
#include "CAFAna/Vars/GenieWeights.h"
#include "CAFAna/Vars/PPFXWeights.h"
#include "CAFAna/Vars/HistAxes.h"
#include "TCanvas.h"
#include "TH2.h"
#include "TFile.h"
#include "TLegend.h"
#include "TPad.h"
#include "TLine.h"
#include <vector>
#include <string>

Go to the source code of this file.

Functions

std::vector< Spectrum * > MakeCutFlowSpectra (SpectrumLoader *l, Var wei)
 
std::vector< HistAxisInitAxes ()
 
std::vector< Spectrum * > MakeKinSpectra (SpectrumLoader *l, Var wei, Cut sel)
 
std::vector< Spectrum * > MakeKin2DSpectra (SpectrumLoader *l, Var wei, Cut sel)
 
void CreateAndFillSpectra (std::string fname)
 
void CenterTitles (TH1 *h)
 
void MakePlot (std::string fname, std::string name, std::string xtitle)
 
void Make2DPlot (std::string fname, std::string name, std::string ytitle)
 
void MakePlots (std::string fname)
 
void nd_datastability (bool fillSpectra, std::string fname)
 

Variables

const Var kRun = SIMPLEVAR(hdr.run)
 
const Var kEPH ([](const caf::SRProxy *sr){if(sr->slc.nhit==0) return float(-1);return float(sr->slc.calE/sr->slc.nhit);})
 
const Var kHadCalE ([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(sr->slc.calE);return float(sr->slc.calE- sr->vtx.elastic.fuzzyk.png[0].shwlid.calE);})
 
const Var kShwLIDE ([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(-1);return float(sr->vtx.elastic.fuzzyk.png[0].shwlid.calE);})
 
const Var kShwLIDEPH ([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(-1);float cale=sr->vtx.elastic.fuzzyk.png[0].shwlid.calE;int nhit=sr->vtx.elastic.fuzzyk.png[0].shwlid.nhit;float eph=(nhit > 0)?cale/nhit:-1;return eph;})
 

Function Documentation

void CenterTitles ( TH1 *  h)

Definition at line 184 of file nue_nd_datastability.C.

Referenced by DrawContourCanvas(), febrates(), febshutoff(), FourBinAxis(), main(), MatrixElementContours(), MuonFit(), NusContoursPlusMINOS(), PID2DAxis(), plot_beam_peak(), PlotSystShifts(), and tbrecoplots().

185 {
186  h->GetXaxis()->CenterTitle();
187  h->GetYaxis()->CenterTitle();
188 }
void CreateAndFillSpectra ( std::string  fname)

Definition at line 118 of file nue_nd_datastability.C.

References ana::assert(), om::cout, allTimeWatchdog::endl, ana::SpectrumLoader::Go(), makeTrainCVSamples::int, ana::kCVNe, ana::kNue2017NDPresel, ana::kPPFXFluxCVWgt, ana::kStandardSpillCuts, ana::kXSecCVWgt2017, MakeCutFlowSpectra(), MakeKin2DSpectra(), MakeKinSpectra(), confusionMatrixTree::out, and ana::SpectrumLoaderBase::SetSpillCut().

Referenced by nd_datastability().

119 {
120  SpectrumLoader *lDa2(new SpectrumLoader("prod_caf_R16-11-12-feature_caf_size.b_nd_numi_fhc_epochs1-3c_v1_goodruns"));
121  SpectrumLoader *lDa3(new SpectrumLoader("prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns"));
122 
123  SpectrumLoader *lMC2(new SpectrumLoader("prod_caf_R16-11-12-feature_caf_size.b_nd_genie_nonswap_genierw_fhc_nova_v08_full_v1"));
124  SpectrumLoader *lMC3(new SpectrumLoader("prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1"));
125 
126  lDa2->SetSpillCut(kStandardSpillCuts);
127  lDa3->SetSpillCut(kStandardSpillCuts);
128  lMC2->SetSpillCut(kStandardSpillCuts);
129  lMC3->SetSpillCut(kStandardSpillCuts);
130 
132  Cut kNueND = kNue2017NDPresel && kCVNe > 0.75;
133 
134  std::vector<Spectrum*> mc_cutflow2 = MakeCutFlowSpectra(lMC2,wei);
135  std::vector<Spectrum*> mc_cutflow3 = MakeCutFlowSpectra(lMC3,wei);
136  std::vector<Spectrum*> da_cutflow2 = MakeCutFlowSpectra(lDa2,wei);
137  std::vector<Spectrum*> da_cutflow3 = MakeCutFlowSpectra(lDa3,wei);
138 
139  std::vector<Spectrum*> mc_kin2 = MakeKinSpectra(lMC2,wei,kNueND);
140  std::vector<Spectrum*> mc_kin3 = MakeKinSpectra(lMC3,wei,kNueND);
141  std::vector<Spectrum*> da_kin2 = MakeKinSpectra(lDa2,wei,kNueND);
142  std::vector<Spectrum*> da_kin3 = MakeKinSpectra(lDa3,wei,kNueND);
143 
144  std::vector<Spectrum*> mc_2D2 = MakeKin2DSpectra(lMC2,wei,kNueND);
145  std::vector<Spectrum*> mc_2D3 = MakeKin2DSpectra(lMC3,wei,kNueND);
146  std::vector<Spectrum*> da_2D2 = MakeKin2DSpectra(lDa2,wei,kNueND);
147  std::vector<Spectrum*> da_2D3 = MakeKin2DSpectra(lDa3,wei,kNueND);
148 
149  lDa2->Go();
150  lDa3->Go();
151  lMC2->Go();
152  lMC3->Go();
153 
154  std::cout << "fname " << fname << std::endl;
155  TFile *out = new TFile(fname.c_str(),"recreate");
156 
157  std::vector<std::string> cutname = {"nocut","dq","fiducial","contain",
158  "presel","ptp","cvn"};
159  assert(cutname.size() == da_cutflow2.size());
160  for (int cIdx = 0; cIdx < int(cutname.size()); cIdx++){
161  mc_cutflow2[cIdx]->SaveTo(out, ("prod2_mc_"+cutname[cIdx]).c_str());
162  mc_cutflow3[cIdx]->SaveTo(out, ("prod3_mc_"+cutname[cIdx]).c_str());
163 
164  da_cutflow2[cIdx]->SaveTo(out, ("prod2_da_"+cutname[cIdx]).c_str());
165  da_cutflow3[cIdx]->SaveTo(out, ("prod3_da_"+cutname[cIdx]).c_str());
166  }
167 
168  std::vector<std::string> varname = {"calE","NHit","EPH","shwE",
169  "shwEPH","HadE","pTp"};
170  assert(varname.size() == da_kin2.size());
171  for (int kIdx = 0; kIdx < int(varname.size()); kIdx++){
172  mc_kin2[kIdx]->SaveTo(out, ("prod2_mc_"+varname[kIdx]).c_str());
173  mc_kin3[kIdx]->SaveTo(out, ("prod3_mc_"+varname[kIdx]).c_str());
174  mc_2D2[kIdx]->SaveTo(out, ("prod2_mc_runvs"+varname[kIdx]).c_str());
175  mc_2D3[kIdx]->SaveTo(out, ("prod3_mc_runvs"+varname[kIdx]).c_str());
176 
177  da_kin2[kIdx]->SaveTo(out, ("prod2_da_"+varname[kIdx]).c_str());
178  da_kin3[kIdx]->SaveTo(out, ("prod3_da_"+varname[kIdx]).c_str());
179  da_2D2[kIdx]->SaveTo(out, ("prod2_da_runvs"+varname[kIdx]).c_str());
180  da_2D3[kIdx]->SaveTo(out, ("prod3_da_runvs"+varname[kIdx]).c_str());
181  }
182 }
const Var kCVNe
PID
Definition: Vars.cxx:35
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
std::vector< Spectrum * > MakeKinSpectra(SpectrumLoader *l, Var wei, Cut sel)
OStream cout
Definition: OStream.cxx:6
const Cut kNue2017NDPresel
Definition: NueCuts2017.h:285
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
std::vector< Spectrum * > MakeKin2DSpectra(SpectrumLoader *l, Var wei, Cut sel)
assert(nhit_max >=nhit_nbins)
std::vector< Spectrum * > MakeCutFlowSpectra(SpectrumLoader *l, Var wei)
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
const Var kXSecCVWgt2017
Definition: XsecTunes.h:36
std::vector<HistAxis> InitAxes ( )

Definition at line 76 of file nue_nd_datastability.C.

References file_size_ana::axes, ana::kCaloE, kEPH, ana::kHadCalE, ana::kNHit, ana::kPtP, kShwLIDE, kShwLIDEPH, and ana::Binning::Simple().

Referenced by MakeKin2DSpectra(), and MakeKinSpectra().

77 {
78  std::vector<HistAxis> axes;
79 
80  axes.push_back(HistAxis("CalE",Binning::Simple(200,0,5),kCaloE));
81  axes.push_back(HistAxis("NHit",Binning::Simple(200,0,200),kNHit));
82  axes.push_back(HistAxis("NHit",Binning::Simple(200,0,0.05),kEPH));
83  axes.push_back(HistAxis("ShwE",Binning::Simple(200,0,5),kShwLIDE));
84  axes.push_back(HistAxis("ShwEPH",Binning::Simple(200,0,0.05),kShwLIDEPH));
85  axes.push_back(HistAxis("HadE",Binning::Simple(200,0,2),kHadCalE));
86  axes.push_back(HistAxis("pTp",Binning::Simple(100,0,1),kPtP));
87 
88  return axes;
89 }
const Var kHadCalE([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(sr->slc.calE);return float(sr->slc.calE- sr->vtx.elastic.fuzzyk.png[0].shwlid.calE);})
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
const Var kPtP
Transverse momentum fraction in slice.
Definition: NueVars.cxx:90
const Var kCaloE
Summed calorimetric energy of all hits in slice, uncorrected.
Definition: Vars.cxx:52
const Var kShwLIDE([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(-1);return float(sr->vtx.elastic.fuzzyk.png[0].shwlid.calE);})
kNHit
Definition: demo1.py:19
const Var kEPH([](const caf::SRProxy *sr){if(sr->slc.nhit==0) return float(-1);return float(sr->slc.calE/sr->slc.nhit);})
const Var kShwLIDEPH([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(-1);float cale=sr->vtx.elastic.fuzzyk.png[0].shwlid.calE;int nhit=sr->vtx.elastic.fuzzyk.png[0].shwlid.nhit;float eph=(nhit > 0)?cale/nhit:-1;return eph;})
void Make2DPlot ( std::string  fname,
std::string  name,
std::string  ytitle 
)

Definition at line 288 of file nue_nd_datastability.C.

References allTimeWatchdog::can, ana::CenterTitles(), plot_validation_datamc::fname, MECModelEnuComparisons::i, kBlue, kGreen, kRed, MECModelEnuComparisons::leg, pot, ana::Spectrum::POT(), runNovaSAM::release, and ana::Spectrum::ToTH2().

Referenced by MakePlots().

289 {
290  TCanvas *can = new TCanvas();
291 
292  Spectrum *mc_prod2 = LoadFromFile<Spectrum>(fname,"prod2_mc_runvs"+name).release();
293  Spectrum *mc_prod3 = LoadFromFile<Spectrum>(fname,"prod3_mc_runvs"+name).release();
294  Spectrum *da_prod2 = LoadFromFile<Spectrum>(fname,"prod2_da_runvs"+name).release();
295  Spectrum *da_prod3 = LoadFromFile<Spectrum>(fname,"prod3_da_runvs"+name).release();
296  double pot = da_prod3->POT();
297 
298  TH2F *mc2 = (TH2F*)mc_prod2->ToTH2(pot);
299  TH2F *mc3 = (TH2F*)mc_prod3->ToTH2(pot);
300  TH2F *da2 = (TH2F*)da_prod2->ToTH2(pot);
301  TH2F *da3 = (TH2F*)da_prod3->ToTH2(pot);
302 
303  int nrebin = 2;
304  if (name == "HadE" || name == "shwE")
305  nrebin = 4;
306  mc2->RebinX(nrebin);
307  mc3->RebinX(nrebin);
308  da2->RebinX(nrebin);
309  da3->RebinX(nrebin);
310 
311  TH1D *pmc2 = (TH1D*)mc2->ProfileX((name+"pmc2").c_str());
312  TH1D *pmc3 = (TH1D*)mc3->ProfileX((name+"pmc3").c_str());
313  TH1D *pda2 = (TH1D*)da2->ProfileX((name+"pda2").c_str());
314  TH1D *pda3 = (TH1D*)da3->ProfileX((name+"pda3").c_str());
315 
316  pmc2->SetLineColor(kBlue);
317  pmc3->SetLineColor(kRed);
318  pda2->SetLineColor(kGreen+2);
319  pda3->SetLineColor(kBlack);
320 
321  pda2->GetXaxis()->SetTitle("Run");
322  pda2->GetYaxis()->SetTitle(ytitle.c_str());
323  CenterTitles(pda2);
324 
325  int nnonzero = 0;
326  double avgval = 0;
327  for (int i = 1; i <= pda3->GetNbinsX(); i++){
328  double curcont = pda3->GetBinContent(i);
329  if (curcont != 0){
330  nnonzero++;
331  avgval += curcont;
332  }
333  }
334  avgval /= nnonzero;
335  pda2->GetYaxis()->SetRangeUser(0.5*avgval,1.5*avgval);
336 
337  pda2->Draw();
338  pda3->Draw("same");
339  pmc3->Draw("same");
340  pmc2->Draw("same");
341 
342  TLegend *leg = new TLegend(0.6,0.65,0.85,0.85);
343  leg->AddEntry(pda2, "Data prod2", "le");
344  leg->AddEntry(pmc2, "MC prod2", "le");
345  leg->AddEntry(pda3, "Data prod3", "le");
346  leg->AddEntry(pmc3, "MC prod3", "le");
347  leg->Draw();
348 
349 
350  can->SaveAs(("Fig_nddatastability_"+name+"_vsrun.png").c_str());
351 }
const XML_Char * name
Definition: expat.h:151
enum BeamMode kRed
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Definition: Spectrum.cxx:165
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
void CenterTitles(TH1 *h)
#define pot
double POT() const
Definition: Spectrum.h:227
enum BeamMode kGreen
enum BeamMode kBlue
std::vector<Spectrum*> MakeCutFlowSpectra ( SpectrumLoader l,
Var  wei 
)

Definition at line 55 of file nue_nd_datastability.C.

References allInOneTrainingPlots::axis, cut, update_sam_good_runs_metadata::cuts, ana::kCaloE, ana::kCVNe, ana::kNoCut, ana::kNoShift, ana::kNue2017NDContain, ana::kNue2017NDEnergy, ana::kNue2017NDFiducial, ana::kNue2017NDFrontPlanes, ana::kNue2017NDNHits, ana::kNue2017NDProngLength, ana::kNueDQ2017CVN, runNovaSAM::ret, and ana::Binning::Simple().

Referenced by CreateAndFillSpectra().

56 {
57  std::vector<Spectrum*> ret;
58  HistAxis axis("CalE",Binning::Simple(10,0,5),kCaloE);
59  //HistAxis axis = kNueSAEnergyAxis;
60 
61 
62  std::vector<Cut> cuts = {kNoCut};
63  cuts.push_back(kNueDQ2017CVN);
64  cuts.push_back(cuts.back() && kNue2017NDFiducial);
65  cuts.push_back(cuts.back() && kNue2017NDContain && kNue2017NDFrontPlanes);
66  cuts.push_back(cuts.back() && kNue2017NDNHits &&
68  cuts.push_back(cuts.back() && kCVNe>0.75);
69 
70  for (Cut cut : cuts)
71  ret.push_back(new Spectrum(*l,axis,cut,kNoShift,wei));
72 
73  return ret;
74 }
const Cut kNue2017NDEnergy
Definition: NueCuts2017.h:271
const Var kCVNe
PID
Definition: Vars.cxx:35
const Cut kNueDQ2017CVN([](const caf::SRProxy *sr){if(sr->sel.nuecosrej.hitsperplane >=8) return false;if(!sr->vtx.elastic.IsValid) return false;if(sr->vtx.elastic.fuzzyk.npng==0) return false;return true;})
Definition: NueCuts2017.h:28
const Cut kNue2017NDProngLength
Definition: NueCuts2017.h:277
const Cut kNue2017NDNHits
Definition: NueCuts2017.h:265
const Var kCaloE
Summed calorimetric energy of all hits in slice, uncorrected.
Definition: Vars.cxx:52
const Cut kNue2017NDFrontPlanes
No hits in the first 5 planes of the detector, doc 12879.
std::vector< float > Spectrum
Definition: Constants.h:728
const SystShifts kNoShift
Definition: SystShifts.cxx:22
const Cut cut
Definition: exporter_fd.C:30
const Cut kNue2017NDContain([](const caf::SRProxy *sr){for(unsigned int ix=0;ix< sr->vtx.elastic.fuzzyk.nshwlid;++ix){TVector3 start=sr->vtx.elastic.fuzzyk.png[ix].shwlid.start;TVector3 stop=sr->vtx.elastic.fuzzyk.png[ix].shwlid.stop;if(std::min(start.X(), stop.X())< -170.0) return false;if(std::max(start.X(), stop.X()) > 170.0) return false;if(std::min(start.Y(), stop.Y())< -170.0) return false;if(std::max(start.Y(), stop.Y()) > 170.0) return false;if(std::min(start.Z(), stop.Z())< 100.0) return false;if(std::max(start.Z(), stop.Z()) > 1225.0) return false;}return true;})
Loose containtment on start and end of all showers, docdb-12943.
Definition: NueCuts2017.h:259
const Cut kNue2017NDFiducial([](const caf::SRProxy *sr){assert(sr->vtx.elastic.IsValid &&"Must apply DQ cuts");if(sr->vtx.elastic.vtx.X()< -100.0) return false;if(sr->vtx.elastic.vtx.X() > 160.0) return false;if(sr->vtx.elastic.vtx.Y()< -160.0) return false;if(sr->vtx.elastic.vtx.Y() > 100.0) return false;if(sr->vtx.elastic.vtx.Z()< 150.0) return false;if(sr->vtx.elastic.vtx.Z() > 900.0) return false;return true;})
Cut on ND vertex position.
Definition: NueCuts2017.h:256
std::vector<Spectrum*> MakeKin2DSpectra ( SpectrumLoader l,
Var  wei,
Cut  sel 
)

Definition at line 102 of file nue_nd_datastability.C.

References file_size_ana::axes, allInOneTrainingPlots::axis, InitAxes(), ana::kNoShift, runNovaSAM::ret, and ana::Binning::Simple().

Referenced by CreateAndFillSpectra().

103 {
104  std::vector<Spectrum*> ret;
105 
106  HistAxis runaxis("Run",Binning::Simple(200,10300,12300),kRun);
107 
108  std::vector<HistAxis> axes = InitAxes();
109  for (HistAxis axis : axes)
110  ret.push_back(new Spectrum(*l,runaxis,axis,sel,kNoShift,wei));
111 
112  return ret;
113 }
std::vector< float > Spectrum
Definition: Constants.h:728
std::vector< HistAxis > InitAxes()
const SystShifts kNoShift
Definition: SystShifts.cxx:22
const Var kRun
std::vector<Spectrum*> MakeKinSpectra ( SpectrumLoader l,
Var  wei,
Cut  sel 
)

Definition at line 91 of file nue_nd_datastability.C.

References file_size_ana::axes, allInOneTrainingPlots::axis, InitAxes(), ana::kNoShift, and runNovaSAM::ret.

Referenced by CreateAndFillSpectra().

92 {
93  std::vector<Spectrum*> ret;
94 
95  std::vector<HistAxis> axes = InitAxes();
96  for (HistAxis axis : axes)
97  ret.push_back(new Spectrum(*l,axis,sel,kNoShift,wei));
98 
99  return ret;
100 }
std::vector< float > Spectrum
Definition: Constants.h:728
std::vector< HistAxis > InitAxes()
const SystShifts kNoShift
Definition: SystShifts.cxx:22
void MakePlot ( std::string  fname,
std::string  name,
std::string  xtitle 
)

Definition at line 190 of file nue_nd_datastability.C.

References allTimeWatchdog::can, ana::CenterTitles(), e, plot_validation_datamc::fname, kBlue, kGreen, kRed, MECModelEnuComparisons::leg, cet::sqlite::max(), std::max(), ana::Spectrum::POT(), runNovaSAM::release, and ana::Spectrum::ToTH1().

Referenced by MakePlots().

191 {
192  TCanvas *can = new TCanvas();
193 
194  Spectrum *da_prod2=LoadFromFile<Spectrum>(fname,"prod2_da_"+name).release();
195  Spectrum *da_prod3=LoadFromFile<Spectrum>(fname,"prod3_da_"+name).release();
196  double da_pot2 = da_prod2->POT();
197  double da_pot3 = da_prod3->POT();
198  Spectrum *mc_prod2=LoadFromFile<Spectrum>(fname,"prod2_mc_"+name).release();
199  Spectrum *mc_prod3=LoadFromFile<Spectrum>(fname,"prod3_mc_"+name).release();
200  double mc_pot2 = mc_prod2->POT();
201  double mc_pot3 = mc_prod3->POT();
202 
203  TH1 *da2 = da_prod2->ToTH1(da_pot3);
204  TH1 *da3 = da_prod3->ToTH1(da_pot3);
205  TH1 *mc2 = mc_prod2->ToTH1(da_pot3);
206  TH1 *mc3 = mc_prod3->ToTH1(da_pot3);
207 
208  TH1 *rat_da2 = da_prod2->ToTH1(da_pot3);
209  TH1 *rat_da3 = da_prod3->ToTH1(da_pot3);
210  TH1 *rat_mc3 = mc_prod3->ToTH1(da_pot3);
211 
212  int nrebin = 1;
213  if (name == "EPH" || name == "shwEPH") nrebin = 10;
214  if (name == "calE" || name == "shwE" ||
215  name == "HadE" || name == "NHit") nrebin = 20;
216  da2->Rebin(nrebin);
217  da3->Rebin(nrebin);
218  mc2->Rebin(nrebin);
219  mc3->Rebin(nrebin);
220  rat_da2->Rebin(nrebin);
221  rat_da3->Rebin(nrebin);
222  rat_mc3->Rebin(nrebin);
223 
224  rat_da2->Divide(mc2);
225  rat_da3->Divide(mc2);
226  rat_mc3->Divide(mc2);
227 
228  TPad *pRat = new TPad(("rat"+name) .c_str(),"",0,0,1,0.35);
229  TPad *pSpec= new TPad(("spec"+name).c_str(),"",0,0.35,1,1);
230 
231  pRat->Draw();
232  pSpec->Draw();
233 
234  pSpec->cd();
235  gPad->SetBottomMargin(0);
236  mc2->SetLineColor(kBlue);
237  mc3->SetLineColor(kRed);
238  da2->SetLineColor(kGreen+2);
239  da3->SetLineColor(kBlack);
240  da2->SetMinimum(1e-3);
241 
242  double max = std::max(da2->GetMaximum(),da3->GetMaximum());
243  max = std::max(max,mc2->GetMaximum());
244  max = std::max(max,mc3->GetMaximum());
245 
246  da2->SetMaximum(1.2*max);
247  da2->GetXaxis()->SetTitle("");
248  da2->GetYaxis()->SetTitle("Events");
249  da2->SetTitle("");
250  CenterTitles(da2);
251  da2->GetXaxis()->SetTitleSize(0.06);
252  da2->Draw("E");
253  da3->Draw("E,same");
254  mc2->Draw("E,same");
255  mc3->Draw("E,same");
256  TLegend *leg = new TLegend(0.6,0.65,0.85,0.85);
257  leg->AddEntry(da2, "Data prod2", "le");
258  leg->AddEntry(mc2, "MC prod2", "le");
259  leg->AddEntry(da3, "Data prod3", "le");
260  leg->AddEntry(mc3, "MC prod3", "le");
261  leg->Draw();
262 
263  rat_mc3->SetLineColor(kRed);
264  rat_da2->SetLineColor(kGreen+2);
265  rat_da3->SetLineColor(kBlack);
266 
267  pRat->cd();
268  gPad->SetTopMargin(0);
269  gPad->SetBottomMargin(0.2);
270  rat_mc3->GetXaxis()->SetTitle(xtitle.c_str());
271  rat_mc3->GetYaxis()->SetTitle("Various Ratios");
272  rat_mc3->SetTitle("");
273  CenterTitles(rat_mc3);
274  rat_mc3->GetXaxis()->SetTitleSize(0.10);
275  rat_mc3->GetXaxis()->SetLabelSize(0.08);
276  rat_mc3->GetXaxis()->SetTitleOffset(0.8);
277  rat_mc3->GetYaxis()->SetTitleSize(0.10);
278  rat_mc3->GetYaxis()->SetLabelSize(0.08);
279  rat_mc3->GetYaxis()->SetTitleOffset(0.5);
280  rat_mc3->GetYaxis()->SetRangeUser(0.5001,1.4999);
281  rat_mc3->Draw();
282  rat_da2->Draw("same");
283  rat_da3->Draw("same");
284 
285  can->SaveAs(("Fig_nddatastability_"+name+".png").c_str());
286 }
T max(const caf::Proxy< T > &a, T b)
const XML_Char * name
Definition: expat.h:151
enum BeamMode kRed
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
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
void CenterTitles(TH1 *h)
double POT() const
Definition: Spectrum.h:227
Float_t e
Definition: plot.C:35
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
enum BeamMode kGreen
enum BeamMode kBlue
void MakePlots ( std::string  fname)

Definition at line 354 of file nue_nd_datastability.C.

References Make2DPlot(), and MakePlot().

Referenced by nd_datastability().

355 {
356  Make2DPlot(fname,"calE","CalE [GeV]");
357  Make2DPlot(fname,"NHit","NHit");
358  Make2DPlot(fname,"EPH","CalE / NHit [GeV]");
359  Make2DPlot(fname,"HadE","HadE [GeV]");
360  Make2DPlot(fname,"shwE","ShwE [GeV]");
361  Make2DPlot(fname,"shwEPH","ShwE / ShwNHit [GeV]");
362 
363 
364 
365  MakePlot(fname,"calE","CalE [GeV]");
366  MakePlot(fname,"NHit","NHit");
367  MakePlot(fname,"EPH","CalE / NHit [GeV]");
368  MakePlot(fname,"HadE","HadE [GeV]");
369  MakePlot(fname,"shwE","ShwE [GeV]");
370  MakePlot(fname,"shwEPH","ShwE / ShwNHit [GeV]");
371 
372  MakePlot(fname,"nocut","CalE [GeV]");
373  MakePlot(fname,"dq","CalE [GeV]");
374  MakePlot(fname,"fiducial","CalE [GeV]");
375  MakePlot(fname,"contain","CalE [GeV]");
376  MakePlot(fname,"presel","CalE [GeV]");
377  MakePlot(fname,"ptp","CalE [GeV]");
378  MakePlot(fname,"cvn","CalE [GeV]");
379 }
void Make2DPlot(std::string fname, std::string name, std::string ytitle)
void MakePlot(std::string fname, std::string name, std::string xtitle)
void nd_datastability ( bool  fillSpectra,
std::string  fname 
)

Definition at line 382 of file nue_nd_datastability.C.

References CreateAndFillSpectra(), and MakePlots().

383 {
384  if (fillSpectra)
386  else
387  MakePlots(fname);
388 
389 }
void CreateAndFillSpectra(std::string fname)
void MakePlots(std::string fname)

Variable Documentation

const Var kEPH([](const caf::SRProxy *sr){if(sr->slc.nhit==0) return float(-1);return float(sr->slc.calE/sr->slc.nhit);})

Referenced by InitAxes().

const Var kHadCalE([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(sr->slc.calE);return float(sr->slc.calE- sr->vtx.elastic.fuzzyk.png[0].shwlid.calE);})
const Var kRun = SIMPLEVAR(hdr.run)

Definition at line 26 of file nue_nd_datastability.C.

const Var kShwLIDE([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(-1);return float(sr->vtx.elastic.fuzzyk.png[0].shwlid.calE);})

Referenced by InitAxes().

const Var kShwLIDEPH([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(-1);float cale=sr->vtx.elastic.fuzzyk.png[0].shwlid.calE;int nhit=sr->vtx.elastic.fuzzyk.png[0].shwlid.nhit;float eph=(nhit > 0)?cale/nhit:-1;return eph;})

Referenced by InitAxes().