Functions | Variables
MakeCutFlow.C File Reference
#include "CAFAna/Analysis/Plots.h"
#include "CAFAna/Analysis/Exposures.h"
#include "CAFAna/Core/Loaders.h"
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Core/ReweightableSpectrum.h"
#include "Utilities/rootlogon.C"
#include "TCanvas.h"
#include "TColor.h"
#include "TFile.h"
#include "TGraph.h"
#include "TGraphAsymmErrors.h"
#include "TH1.h"
#include "TH2.h"
#include "TLatex.h"
#include "TLegend.h"
#include "TStyle.h"
#include "TSystem.h"
#include <fstream>
#include <iostream>
#include <string>

Go to the source code of this file.

Functions

TH1D * GetHistVectors (TFile *InF, std::string InDir, double Norm, bool Cosm=false)
 
void WriteOutEntries (std::vector< TH1D * > Hists, std::vector< double > &Entries)
 
void SetBin (TH1D *hist, size_t ind, double Val)
 
void SetHistProp (TH1D *hist, int Colour, double Width, double Offset)
 
void MakeCanvasForData (std::vector< double > Beam, std::vector< double > NuMuCC, std::vector< double > NotNuMuCC, std::vector< double > Cosm)
 
void MakeCanvasForSim (std::vector< double > NuMuCC, std::vector< double > NotNuMuCC, std::vector< double > Cosm)
 
void MakeNuEnergyPlots (std::vector< TH1D * > Data, std::vector< TH1D * > AllMont, std::vector< TH1D * > NotNuMuCC, std::vector< TH1D * > Cosm, bool WithData)
 
void MakeTextFile (std::string OutName, bool BarChart)
 
void MakeCutFlow ()
 

Variables

std::vector< std::stringCutNames
 
size_t NCuts = 0
 
TColor * Colour1 = new TColor(229, 0.37 , 0.05 , 0.67 ,"")
 
TColor * Colour2 = new TColor(230, 0 , 0.725, 0.659,"")
 
TColor * Colour3 = new TColor(231, 0.925, 0 , 0.549,"")
 
TColor * Colour4 = new TColor(232, 0.627, 0 , 0.373,"")
 
TColor * Colour5 = new TColor(233, 0 , 0.631, 0.569,"")
 
double POTNorm = 0
 
double LivNorm = 0
 

Function Documentation

TH1D * GetHistVectors ( TFile *  InF,
std::string  InDir,
double  Norm,
bool  Cosm = false 
)

Definition at line 191 of file MakeCutFlow.C.

References ana::kLivetime, and ana::Spectrum::LoadFrom().

Referenced by MakeCutFlow().

191  {
192  std::unique_ptr<Spectrum> Temp = Spectrum::LoadFrom( InF, InDir);
193  if ( Cosm ) return Temp -> ToTH1( Norm, kLivetime );
194  else return Temp -> ToTH1( Norm );
195 }
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
void MakeCanvasForData ( std::vector< double >  Beam,
std::vector< double >  NuMuCC,
std::vector< double >  NotNuMuCC,
std::vector< double >  Cosm 
)

Definition at line 241 of file MakeCutFlow.C.

References Draw(), GetXaxis(), GetYaxis(), MECModelEnuComparisons::i, submit_hadd::l, MakeTextFile(), NCuts, Preliminary(), SaveAs(), SetBin(), SetGridx(), SetHistProp(), SetLogx(), SetTitle(), and Write().

Referenced by MakeCutFlow().

241  {
242  // --- Declare a canvas.
243  TCanvas *DataCan = new TCanvas( "DataCan", "Cut Efficiency Canvas for Data vs MC" );
244  DataCan -> SetLogx();
245  DataCan -> SetGridx();
246  DataCan -> SetLeftMargin(0.15);
247  DataCan -> SetRightMargin(0.05);
248 
249  double HistWidth = 0.2;
250 
251  // First Total Predicted flux.
252  TH1D *hTot = new TH1D( "TotalFlux", "", NCuts, 0, NCuts );
253  SetHistProp( hTot, 229, HistWidth, 0.7 );
254  for(size_t i=1; i<=NCuts; i++) {
255  double TotBin = NuMuCC[ NCuts-i ] + NotNuMuCC[ NCuts-i ] + Cosm[ NCuts-i ];
256  SetBin( hTot, i, TotBin );
257  }
258  // Draw.
259  hTot -> Draw("hbar0");
260 
261  // Now Beam background
262  TH1D *hBea = new TH1D("BeamBack","",NCuts, 0, NCuts);
263  SetHistProp( hBea, 230, HistWidth, 0.5 );
264  for(size_t i=1; i<=NCuts; i++) {
265  SetBin( hBea, i, NotNuMuCC[ NCuts-i ]);
266  }
267  hBea -> Draw("hbar0 same");
268 
269  // Now Cosmic background
270  TH1D *hCos = new TH1D("CosmBack","",NCuts, 0, NCuts);
271  SetHistProp( hCos, 231, HistWidth, 0.3 );
272  for(size_t i=1; i<=NCuts; i++) {
273  SetBin( hCos, i, Cosm[ NCuts-i ]);
274  }
275  hCos -> Draw("hbar0 same");
276 
277  // Last Data
278  TH1D *hDat = new TH1D("BeamData","",NCuts, 0, NCuts);
279  SetHistProp( hDat, 232, HistWidth, 0.1 );
280  for(size_t i=1; i<=NCuts; i++) {
281  SetBin( hDat, i, Beam[ NCuts-i ]);
282  }
283  hDat -> Draw("hbar0 same");
284 
285  // Add a legend to the plot.
286  TLegend *l = new TLegend(0.5,0.15,0.9,0.35);
287  l->AddEntry(hTot,"Predicted Num. Events","f");
288  l->AddEntry(hBea,"Beam Background" ,"f");
289  l->AddEntry(hCos,"Cosmic Background" ,"f");
290  l->AddEntry(hDat,"Recorded data" ,"f");
291  l->Draw();
292 
293  // Draw Preliminary()
294  Preliminary();
295 
296  // Set axis range etc.
297  hTot -> GetXaxis() -> SetLabelSize( 0.055 );
298  hTot -> GetYaxis() -> SetTitle("Events");
299  hTot -> GetYaxis() -> CenterTitle();
300  hTot -> GetYaxis() -> SetRangeUser( 1, 1e7 );
301  // And redraw axis
302  hTot -> Draw("axis same");
303 
304  // Finally, save the canvas.
305  DataCan -> SaveAs( "Plots/DataCutFlow_NuMu.pdf" );
306  DataCan -> SaveAs( "Plots/DataCutFlow_NuMu.png" );
307  DataCan -> Write ( "DataCutFlow_NuMu" );
308  MakeTextFile ( "DataCutFlow_NuMu", true );
309 
310  return;
311 }
tree Draw("slc.nhit")
void SetBin(TH1D *hist, size_t ind, double Val)
Definition: MakeCutFlow.C:205
size_t NCuts
Definition: MakeCutFlow.C:50
c1 SetGridx()
correl_xv GetYaxis() -> SetDecimals()
gargamelle SetTitle("Gargamelle #nu_{e} CC data")
void MakeTextFile(std::string OutName, bool BarChart)
Definition: MakeCutFlow.C:222
correl_xv GetXaxis() -> SetDecimals()
void SetHistProp(TH1D *hist, int Colour, double Width, double Offset)
Definition: MakeCutFlow.C:213
c1 SetLogx()
void Preliminary()
void Beam(bool isRHC)
cosmicTree SaveAs("cosmicTree.root")
gm Write()
void MakeCanvasForSim ( std::vector< double >  NuMuCC,
std::vector< double >  NotNuMuCC,
std::vector< double >  Cosm 
)

Definition at line 313 of file MakeCutFlow.C.

References Draw(), GetXaxis(), GetYaxis(), MECModelEnuComparisons::i, submit_hadd::l, MakeTextFile(), NCuts, Preliminary(), SaveAs(), SetBin(), SetGridx(), SetHistProp(), SetLogx(), SetTitle(), and Write().

Referenced by MakeCutFlow().

313  {
314  // --- Declare a canvas.
315  TCanvas *SimCan = new TCanvas( "SimCan", "Cut Efficiency Canvas for MC" );
316  SimCan -> SetLogx();
317  SimCan -> SetGridx();
318  SimCan -> SetLeftMargin(0.15);
319  SimCan -> SetRightMargin(0.05);
320 
321  double HistWidth = 0.25;
322 
323  // NuMC CC.
324  TH1D *hNuMu = new TH1D( "NuMu", "", NCuts, 0, NCuts );
325  SetHistProp( hNuMu, 229, HistWidth, 0.625 );
326  for(size_t i=1; i<=NCuts; i++) {
327  SetBin( hNuMu, i, NuMuCC[ NCuts-i ]);
328  }
329  // Draw.
330  hNuMu -> Draw("hbar0");
331 
332  // Now Beam background
333  TH1D *hBeam = new TH1D("BeamBkg","",NCuts, 0, NCuts);
334  SetHistProp( hBeam, 230, HistWidth, 0.375 );
335  for(size_t i=1; i<=NCuts; i++) {
336  SetBin( hBeam, i, NotNuMuCC[ NCuts-i ]);
337  }
338  hBeam -> Draw("hbar0 same");
339 
340  // Now Cosmic background
341  TH1D *hCosm = new TH1D("Cosmics","",NCuts, 0, NCuts);
342  SetHistProp( hCosm, 231, HistWidth, 0.125 );
343  for(size_t i=1; i<=NCuts; i++) {
344  SetBin( hCosm, i, Cosm[ NCuts-i ]);
345  }
346  hCosm -> Draw("hbar0 same");
347 
348  // Add a legend to the plot.
349  TLegend *l = new TLegend(0.6,0.15,0.9,0.35);
350  l->AddEntry(hNuMu,"#nu_{#mu} Signal" ,"f");
351  l->AddEntry(hBeam,"Beam Background" ,"f");
352  l->AddEntry(hCosm,"Cosmic Background","f");
353  l->Draw();
354 
355  // Draw Preliminary()
356  Preliminary();
357 
358  // Set axis range etc.
359  hNuMu -> GetXaxis() -> SetLabelSize( 0.055 );
360  hNuMu -> GetYaxis() -> SetTitle("Events");
361  hNuMu -> GetYaxis() -> CenterTitle();
362  hNuMu -> GetYaxis() -> SetRangeUser( 1, 1e7 );
363  // And redraw axis
364  hNuMu -> Draw("axis same");
365 
366  // Finally, save the canvas.
367  SimCan -> SaveAs( "Plots/SimCutFlow_NuMu.pdf" );
368  SimCan -> SaveAs( "Plots/SimCutFlow_NuMu.png" );
369  SimCan -> Write ( "SimCutFlow_NuMu" );
370  MakeTextFile ( "SimCutFlow_NuMu", true );
371  return;
372 }
tree Draw("slc.nhit")
void SetBin(TH1D *hist, size_t ind, double Val)
Definition: MakeCutFlow.C:205
size_t NCuts
Definition: MakeCutFlow.C:50
c1 SetGridx()
correl_xv GetYaxis() -> SetDecimals()
gargamelle SetTitle("Gargamelle #nu_{e} CC data")
void MakeTextFile(std::string OutName, bool BarChart)
Definition: MakeCutFlow.C:222
correl_xv GetXaxis() -> SetDecimals()
void SetHistProp(TH1D *hist, int Colour, double Width, double Offset)
Definition: MakeCutFlow.C:213
c1 SetLogx()
void Preliminary()
cosmicTree SaveAs("cosmicTree.root")
gm Write()
void MakeCutFlow ( )

Definition at line 63 of file MakeCutFlow.C.

References cc(), cd(), om::cerr, plot_validation_datamc::Clone(), om::cout, CutNames, allTimeWatchdog::endl, GetHistVectors(), LivNorm, LoadData(), ana::Spectrum::LoadFrom(), MakeCanvasForData(), MakeCanvasForSim(), MakeNuEnergyPlots(), NCuts, OutFile, POT, POTNorm, string, and WriteOutEntries().

63  {
64  // Where are my input files?
65  std::string InBase = "/nova/ana/users/karlwarb/NuMu_BoxOpening2017/CutFlowFiles/";
66  std::string MontNa = "CutFlow_MC.root";
67  std::string DataNa = "CutFlow_Data.root";
68 
69  std::string MontLoc = InBase + MontNa;
70  std::string DataLoc = InBase + DataNa;
71 
72  std::cerr << "Loading;"
73  << "\n\t Monte Carlo - " << MontLoc
74  << "\n\t Data Files - " << DataLoc
75  << std::endl;
76 
77  TFile *MontFile = TFile::Open( MontLoc.c_str() );
78  TFile *DataFile = TFile::Open( DataLoc.c_str() );
79 
80  // --- Do my cuts.
81  CutNames.emplace_back("NoCut");
82  CutNames.emplace_back("Quality");
83  CutNames.emplace_back("Containment");
84  CutNames.emplace_back("Particle_ID");
85  CutNames.emplace_back("Cosmic_Rej");
86 
87  NCuts = CutNames.size();
88 
89  // --- Define my histograms.
90  // Data
91  std::vector<TH1D*> hBeam;
92  std::vector<TH1D*> hCosm;
93  // Mont
94  std::vector<TH1D*> hAllMont;
95  std::vector<TH1D*> hNuMuCC;
96  std::vector<TH1D*> hAllNue;
97  std::vector<TH1D*> hNuEToMu;
98  std::vector<TH1D*> hAllNC;
99  std::vector<TH1D*> hAllTau;
100 
101  // --- Need to specify my POT and LiveTime
102  // Beam POT
103  std::unique_ptr<Spectrum> TempSpec_Beam = Spectrum::LoadFrom( DataFile, TString(CutNames[2])+TString("_BeamNus") ) ;
104  POTNorm = TempSpec_Beam -> POT();
105  // Cosm Livetime
106  std::unique_ptr<Spectrum> TempSpec_Cosm = Spectrum::LoadFrom( DataFile, TString(CutNames[2])+TString("_Cosmics") ) ;
107  LivNorm = TempSpec_Cosm->Livetime();
108  // What numbers did I get?
109  std::cerr << "\n My POT is " << POTNorm << ". My cosmic livetime is " << LivNorm << "\n" << std::endl;
110 
111  // --- Loop through my vector of cut names, and load the histograms.
112  for (size_t cc=0; cc<NCuts; ++cc) {
113  // --- Data strings.
115 
116  // --- Load the Monte Carlo
117  hAllMont.push_back( GetHistVectors( MontFile, CutNames[cc]+"_FullMC" , POTNorm, false ) );
118  hNuMuCC .push_back( GetHistVectors( MontFile, CutNames[cc]+"_NuMuCC" , POTNorm, false ) );
119  hAllNue .push_back( GetHistVectors( MontFile, CutNames[cc]+"_AllNue" , POTNorm, false ) );
120  hNuEToMu.push_back( GetHistVectors( MontFile, CutNames[cc]+"_NuEToMu", POTNorm, false ) );
121  hAllNC .push_back( GetHistVectors( MontFile, CutNames[cc]+"_AllNC" , POTNorm, false ) );
122  hAllTau .push_back( GetHistVectors( MontFile, CutNames[cc]+"_AllTau" , POTNorm, false ) );
123  // --- Load the Data
124  hBeam.push_back( GetHistVectors( DataFile, LoadData+"_BeamNus", POTNorm, false ) );
125  hCosm.push_back( GetHistVectors( DataFile, LoadData+"_Cosmics", LivNorm, true ) );
126  }
127 
128  // --- How many events in each sample?
129  // Data
130  std::vector<double> nBeam;
131  std::vector<double> nCosm;
132  // Mont
133  std::vector<double> nAllMont;
134  std::vector<double> nNuMuCC;
135  std::vector<double> nAllNue;
136  std::vector<double> nNuEToMu;
137  std::vector<double> nAllNC;
138  std::vector<double> nAllTau;
139 
140  // Data
141  std::cout << "\nNow for Beam Data" << std::endl; WriteOutEntries( hBeam, nBeam );
142  std::cout << "\nNow for Cosmics" << std::endl; WriteOutEntries( hCosm, nCosm );
143  // Mont
144  std::cout << "\nNow for All MC" << std::endl; WriteOutEntries( hAllMont, nAllMont );
145  std::cout << "\nNow for NuMU CC" << std::endl; WriteOutEntries( hNuMuCC , nNuMuCC );
146  std::cout << "\nNow for All NuE" << std::endl; WriteOutEntries( hAllNue , nAllNue );
147  std::cout << "\nNow for NuE to NuMu"<< std::endl; WriteOutEntries( hNuEToMu, nNuEToMu );
148  std::cout << "\nNow for All NC" << std::endl; WriteOutEntries( hAllNC , nAllNC );
149  std::cout << "\nNow for All NuTau" << std::endl; WriteOutEntries( hAllTau , nAllTau );
150 
151  // --- Make a histogram which is the sum of everything but NuMuCC.
152  std::cout << "\nNow for everything that is not NuMuCC" << std::endl;
153  std::vector<TH1D*> hNotNuMuCC;
154  std::vector<double> nNotNuMuCC;
155  for (size_t cc=0; cc<NCuts; ++cc) {
156  TH1D* TempHist = (TH1D*)hAllNue[cc]->Clone();
157  TempHist -> Add( hNuEToMu[cc] );
158  TempHist -> Add( hAllNC [cc] );
159  TempHist -> Add( hAllTau [cc] );
160 
161  double TempSum = nAllNue[cc] + nNuEToMu[cc] + nAllNC[cc] + nAllTau[cc];
162 
163  hNotNuMuCC.push_back( TempHist );
164  nNotNuMuCC.push_back( TempSum );
165 
166  std::cout << "\tCut: " << CutNames[cc] << " - " << nNotNuMuCC[cc] << std::endl;
167  }
168  // --- Now lets start drawing things!!!
169  std::cerr << "\n\nNow lets start plotting things..." << std::endl;
170 
171  std::string OutName = "Plots/CutFlowPlots_NuMu_Ana2017.root";
172  TFile *OutFile = new TFile(OutName.c_str(), "RECREATE");
173  OutFile -> cd();
174 
175  // --- Make a canvas for FD Data, TotalPred, BeamBkg, Cosmics
176  MakeCanvasForData( nBeam, nNuMuCC, nNotNuMuCC, nCosm );
177 
178  // --- Make a canvas for event rate without data
179  MakeCanvasForSim ( nNuMuCC, nNotNuMuCC, nCosm );
180 
181  // --- Make canvases for Neutrino Energy Plots with Data
182  MakeNuEnergyPlots( hBeam, hAllMont, hNotNuMuCC, hCosm, true );
183 
184  // --- Make canvases for Neutrino Energy Plots without Data
185  MakeNuEnergyPlots( hBeam, hAllMont, hNotNuMuCC, hCosm, false );
186 
187  return;
188 }
size_t NCuts
Definition: MakeCutFlow.C:50
OStream cerr
Definition: OStream.cxx:7
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
double POTNorm
Definition: MakeCutFlow.C:59
double LivNorm
Definition: MakeCutFlow.C:60
void MakeNuEnergyPlots(std::vector< TH1D * > Data, std::vector< TH1D * > AllMont, std::vector< TH1D * > NotNuMuCC, std::vector< TH1D * > Cosm, bool WithData)
Definition: MakeCutFlow.C:374
Spectrum LoadData(bool nd, bool rhc=false)
Function to load NuS data file.
OStream cout
Definition: OStream.cxx:6
std::vector< double > POT
void cc()
Definition: test_ana.C:28
void WriteOutEntries(std::vector< TH1D * > Hists, std::vector< double > &Entries)
Definition: MakeCutFlow.C:197
void MakeCanvasForSim(std::vector< double > NuMuCC, std::vector< double > NotNuMuCC, std::vector< double > Cosm)
Definition: MakeCutFlow.C:313
TFile * OutFile
void MakeCanvasForData(std::vector< double > Beam, std::vector< double > NuMuCC, std::vector< double > NotNuMuCC, std::vector< double > Cosm)
Definition: MakeCutFlow.C:241
c cd(1)
TH1D * GetHistVectors(TFile *InF, std::string InDir, double Norm, bool Cosm=false)
Definition: MakeCutFlow.C:191
std::vector< std::string > CutNames
Definition: MakeCutFlow.C:49
enum BeamMode string
void MakeNuEnergyPlots ( std::vector< TH1D * >  Data,
std::vector< TH1D * >  AllMont,
std::vector< TH1D * >  NotNuMuCC,
std::vector< TH1D * >  Cosm,
bool  WithData 
)

Definition at line 374 of file MakeCutFlow.C.

References bin, cc(), plot_validation_datamc::Clone(), om::cout, CutNames, Draw(), allTimeWatchdog::endl, GetXaxis(), GetYaxis(), ana::GraphWithPoissonErrors(), ana::kLivetime, kViolet, submit_hadd::l, LivNorm, MakeTextFile(), std::max(), NCuts, Preliminary(), SaveAs(), SetFillColor(), SetLineColor(), SetLineWidth(), SetMarkerColor(), SetMarkerStyle(), SetMaximum(), SetTitle(), string, TotBkg(), and Write().

Referenced by MakeCutFlow().

374  {
375  std::string sWData = "_WithData";
376  if (!WithData) sWData = "_WithoutData";
377  // --- Want a plot for each cut level.
378  for(size_t cc=0; cc<NCuts; cc++) {
379  // Determine the name and write it out.
380  std::string CanName = CutNames[cc] + "_NuEnergy" + sWData;
381  std::cout << "\nNow looking at Cut Tier: " << CutNames[cc] << " ==> Can Name is " << CanName << std::endl;
382  // Make my Total background plot
383  TH1D* TotBkg = (TH1D*)NotNuMuCC[cc] -> Clone();
384  TotBkg -> Add( Cosm[cc] );
385  // Make my Total predicted plot.
386  TH1D* TotPred = (TH1D*)AllMont [cc] -> Clone();
387  TotPred -> Add( Cosm[cc] );
388 
389  // --- Scale my hists in X.
390  TH1D* ScPred = (TH1D*)TotPred ->Clone(); ScPred->Scale(0.1,"width");
391  TH1D* ScBeam = (TH1D*)NotNuMuCC[cc]->Clone(); ScBeam->Scale(0.1,"width");
392  TH1D* ScBkg = (TH1D*)TotBkg ->Clone(); ScBkg ->Scale(0.1,"width");
393  TH1D* ScCosm = (TH1D*)Cosm[cc] ->Clone(); ScCosm->Scale(0.1,"width");
394  TH1D* ScData = (TH1D*)Data[cc] ->Clone(); ScData->Scale(0.1,"width");
395 
396  // --- Set my line colours and styles.
397  // Total Predicted
398  ScPred -> SetLineColor (kViolet-1);
399  // Total background
400  ScBkg -> SetLineColor (kGray+1);
401  ScBkg -> SetFillColor (kGray+1);
402  // Cosmic background
403  ScCosm -> SetLineColor (kAzure+1);
404  ScCosm -> SetFillColor (kAzure+1);
405  // Beam background
406  ScBeam -> SetLineColor (kAzure+1);
407  ScBeam -> SetFillColor (kAzure+1);
408 
409  // Set axis labels
410  ScPred -> GetXaxis() -> SetTitle("Reconstructed Neutrino Energy (GeV)");
411  ScPred -> GetXaxis() -> SetLabelSize( ScPred->GetXaxis()->GetTitleSize() );
412  ScPred -> GetXaxis() -> CenterTitle();
413  ScPred -> GetYaxis() -> SetTitle("Events / 0.1 GeV");
414  ScPred -> GetYaxis() -> SetLabelSize( ScPred->GetYaxis()->GetTitleSize() );
415  ScPred -> GetYaxis() -> CenterTitle();
416 
417  // --- Find Maximum value.
418  double MaxVal = std::max( ScPred->GetMaximum(), std::max( ScBkg->GetMaximum(), ScCosm->GetMaximum() ) );
419  if (WithData) MaxVal = std::max( MaxVal , ScData->GetMaximum() );
420 
421  // --- Scale my hists in Y.
422  if ( CanName.find("NoCut" ) != std::string::npos ||
423  CanName.find("Quality") != std::string::npos
424  ) {
425  ScPred->Scale(0.001);
426  ScBkg ->Scale(0.001);
427  ScCosm->Scale(0.001);
428  ScBeam->Scale(0.001);
429  ScData->Scale(0.001);
430  ScPred -> GetYaxis() -> SetTitle("10^{3} Events / 0.1 GeV");
431  MaxVal = MaxVal / 1000;
432  }
433  ScPred -> SetMaximum( MaxVal * 1.2 );
434  if ( WithData && (cc==3 || cc==4) )
435  ScPred -> SetMaximum( MaxVal * 1.4 );
436 
437  // --- Make Data plot a GraphWithPoissonErrors
438  TGraphAsymmErrors* grData = GraphWithPoissonErrors(ScData, false, false);
439  TGraphAsymmErrors* grCosm = GraphWithPoissonErrors(ScCosm, false, false);
440  // Cosmics
441  grCosm -> SetMarkerStyle(kFullCircle);
442  grCosm -> SetLineColor (1);
443  grCosm -> SetFillColor (1);
444  grCosm -> SetLineWidth (2);
445  if (WithData) grCosm -> SetMarkerColor(kAzure+1);
446 
447  for (int bin=0; bin < grCosm->GetN(); ++bin) {
448  double myscale = (kLivetime/LivNorm);
449  grCosm->SetPointEYlow (bin, myscale * grCosm->GetErrorYlow (bin));
450  grCosm->SetPointEYhigh(bin, myscale * grCosm->GetErrorYhigh(bin));
451  }
452 
453  // Data
454  grData -> SetMarkerStyle(kFullCircle);
455  grData -> SetLineWidth (2);
456 
457 
458  TCanvas* NuEnCan = new TCanvas( CanName.c_str(), CanName.c_str() );
459  ScPred -> Draw("hist");
460  if (!WithData) {
461  ScBeam -> Draw("hist same");
462  grCosm -> Draw("ep same" );
463  } else {
464  ScBkg -> Draw("hist same");
465  ScCosm -> Draw("hist same");
466  grData -> Draw("ep same" );
467  }
468 
469  // Add a legend to the plot.
470  TLegend *l = new TLegend(0.58,0.68,0.88,0.88);
471  if (WithData)
472  l->AddEntry(grData,"FD Data","lep");
473  l->AddEntry(ScPred,"Total Predicted" ,"l");
474  if (WithData) {
475  l->AddEntry(ScBkg ,"Total Background","f");
476  l->AddEntry(ScCosm,"Cosmic Background","f");
477  } else {
478  l->AddEntry(grCosm,"Cosmic Background","lep");
479  l->AddEntry(ScBeam,"Beam Background" ,"f");
480  }
481 
482  l->SetFillStyle(0);
483  l->Draw();
484 
485  // Draw Preliminary()
486  Preliminary();
487  // And redraw axis
488  ScPred -> Draw("axis same");
489 
490  // Finally, save the canvas.
491  NuEnCan -> SaveAs( TString("Plots/")+TString(CanName)+TString(".pdf") );
492  NuEnCan -> SaveAs( TString("Plots/")+TString(CanName)+TString(".png") );
493  NuEnCan -> Write ( CanName.c_str() );
494  MakeTextFile ( CanName, false );
495  }
496  return;
497 }
T max(const caf::Proxy< T > &a, T b)
tree Draw("slc.nhit")
size_t NCuts
Definition: MakeCutFlow.C:50
bin1_2sigma SetFillColor(3)
h7 SetMaximum(maxY)
correl_xv GetYaxis() -> SetDecimals()
double TotBkg(std::vector< double > integrals)
TGraphAsymmErrors * GraphWithPoissonErrors(const TH1 *h, bool noErrorsXaxis, bool drawEmptyBins)
Calculate statistical errors appropriate for small Poisson numbers.
Definition: Plots.cxx:912
fVtxDx SetMarkerStyle(20)
gargamelle SetTitle("Gargamelle #nu_{e} CC data")
void MakeTextFile(std::string OutName, bool BarChart)
Definition: MakeCutFlow.C:222
double LivNorm
Definition: MakeCutFlow.C:60
correl_xv GetXaxis() -> SetDecimals()
hmean SetLineWidth(2)
hmean SetLineColor(4)
h1 SetMarkerColor(4)
float bin[41]
Definition: plottest35.C:14
void Preliminary()
OStream cout
Definition: OStream.cxx:6
void cc()
Definition: test_ana.C:28
enum BeamMode kViolet
cosmicTree SaveAs("cosmicTree.root")
gm Write()
std::vector< std::string > CutNames
Definition: MakeCutFlow.C:49
enum BeamMode string
void MakeTextFile ( std::string  OutName,
bool  BarChart 
)

Definition at line 222 of file MakeCutFlow.C.

References om::cout, allTimeWatchdog::endl, confusionMatrixTree::out, and string.

Referenced by MakeCanvasForData(), MakeCanvasForSim(), and MakeNuEnergyPlots().

222  {
223  // Determine output name, and caption.
224  std::string FNa = "Plots/"+OutName+".txt";
225  while (OutName.find("_") != std::string::npos) OutName.replace(OutName.find("_"),1," ");
226  std::string Cap = "Plot showing the number of events passing cuts for " + OutName;
227  if (BarChart) {
228  std::string DaCap = "for expected data rates, taken from MC and Cosmic sidebands.";
229  if (OutName.find("Data") != std::string::npos) DaCap = "with NuMi data shown, along with estimates from MC and Cosmic sidebands.";
230  Cap = "A bar chart showing the number of events changes as subsequent cuts are applied, " + DaCap;
231  }
232  std::cout << "\nFile name: " << FNa << "\n\tCaption: " << Cap << std::endl;
233  // Write to file.
234  std::ofstream TxtOut ( FNa.c_str(), std::ofstream::out );
235  TxtOut << Cap;
236  TxtOut.close();
237  // Done.
238  return;
239 }
def BarChart(node, total, depth=0, startpos=0)
OStream cout
Definition: OStream.cxx:6
enum BeamMode string
void SetBin ( TH1D *  hist,
size_t  ind,
double  Val 
)

Definition at line 205 of file MakeCutFlow.C.

References CutNames, GetXaxis(), NCuts, SetBinContent(), and string.

Referenced by MakeCanvasForData(), and MakeCanvasForSim().

205  {
206  hist -> SetBinContent( ind, Val );
207  std::string BinText = CutNames[ NCuts-ind ];
208  while (BinText.find("_") != std::string::npos) BinText.replace(BinText.find("_"),1," ");
209  hist -> GetXaxis() -> SetBinLabel( ind, BinText.c_str() );
210  return;
211 }
size_t NCuts
Definition: MakeCutFlow.C:50
correl_xv GetXaxis() -> SetDecimals()
cout<< "--"<< endl;for(Int_t iP=1;iP<=hyz->GetNbinsX();iP++){for(Int_t iC=1;iC<=hyz->GetNbinsY();iC++){if(hyv->GetBinContent(iP, iC)>-999){goal_hyv-> SetBinContent(iP, iC,-(dy[iP-1][iC-1]))
std::vector< std::string > CutNames
Definition: MakeCutFlow.C:49
enum BeamMode string
void SetHistProp ( TH1D *  hist,
int  Colour,
double  Width,
double  Offset 
)

Definition at line 213 of file MakeCutFlow.C.

References SetFillColor(), and SetStats().

Referenced by MakeCanvasForData(), and MakeCanvasForSim().

213  {
214  hist -> SetFillColor( Colour );
215  hist -> SetBarWidth ( Width );
216  hist -> SetBarOffset( Offset );
217  hist -> SetStats(0);
218  for (int bi=0; bi<hist->GetNbinsY(); ++bi) hist->SetBinContent( bi, 0 );
219  return;
220 }
bin1_2sigma SetFillColor(3)
double Width(Resonance_t res)
resonance width (GeV)
size_t Offset(bool allow_default)
Value passed to –offset, or 0 if not specified.
Definition: Utilities.cxx:396
correl_xv SetStats(0)
void WriteOutEntries ( std::vector< TH1D * >  Hists,
std::vector< double > &  Entries 
)

Definition at line 197 of file MakeCutFlow.C.

References cc(), om::cout, CutNames, allTimeWatchdog::endl, Integral(), and NCuts.

Referenced by MakeCutFlow().

197  {
198  for (size_t cc=0; cc<NCuts; ++cc) {
199  std::cout << "\tCut: " << CutNames[cc] << " - " << Hists[cc]->Integral() << std::endl;
200  Entries.push_back( Hists[cc]->Integral() );
201  }
202  return;
203 }
size_t NCuts
Definition: MakeCutFlow.C:50
double Integral(const Spectrum &s, const double pot, int cvnregion)
OStream cout
Definition: OStream.cxx:6
void cc()
Definition: test_ana.C:28
std::vector< std::string > CutNames
Definition: MakeCutFlow.C:49

Variable Documentation

TColor* Colour1 = new TColor(229, 0.37 , 0.05 , 0.67 ,"")

Definition at line 53 of file MakeCutFlow.C.

TColor* Colour2 = new TColor(230, 0 , 0.725, 0.659,"")

Definition at line 54 of file MakeCutFlow.C.

TColor* Colour3 = new TColor(231, 0.925, 0 , 0.549,"")

Definition at line 55 of file MakeCutFlow.C.

TColor* Colour4 = new TColor(232, 0.627, 0 , 0.373,"")

Definition at line 56 of file MakeCutFlow.C.

TColor* Colour5 = new TColor(233, 0 , 0.631, 0.569,"")

Definition at line 57 of file MakeCutFlow.C.

std::vector<std::string> CutNames
double LivNorm = 0

Definition at line 60 of file MakeCutFlow.C.

Referenced by MakeCutFlow(), and MakeNuEnergyPlots().

size_t NCuts = 0
double POTNorm = 0

Definition at line 59 of file MakeCutFlow.C.

Referenced by MakeCutFlow().