cafana_vars.C
Go to the documentation of this file.
1 // Author: Prabhjot Singh (prabhjot@fnal.gov; prabhjot.singh@qmul.ac.uk)
2 // Date: 4 Feb 2021
3 // Purpose: To draw some cafana variable to startup CAFAna
4 //
5 // Command: cafe -b -q -l 1 --numubarccinc ../NDAna/numubarcc_low_hadronic/Analysis/cafana_vars.C
6 // To run it over all dataset remove -l 1 option
7 //
8 // Includes
9 // CAFAna specific
10 #include "CAFAna/Core/Binning.h"
11 #include "CAFAna/Cuts/Cuts.h"
12 #include "CAFAna/Core/Spectrum.h"
14 #include "CAFAna/Vars/Vars.h"
15 #include "CAFAna/Cuts/TruthCuts.h"
16 
17 // NDAna includes
19 
20 // Standard Record
22 
23 // ROOT includes
24 #include "TCanvas.h"
25 #include "TH1.h"
26 #include "TH2.h"
27 #include "TFile.h"
28 
29 
30 using namespace ana;
31 
33 {
34 
35  // Get the dataset
36  const std::string dataset_name = "nd_rhc_prod5_decaf_minus_muonid_training_minus_fakedata";
37 
38  // Start spectrum loader
39  SpectrumLoader loader(dataset_name);
40 
41  // Binning: let's use some simple binning
42  const Binning bins = Binning::Simple(100, 0, 10);
43 
44  // True neutrino energy variable
45  const Var kTrueENu = kTrueE;
46 
47  // Introduce some selections
48  const Cut kSelections = xsec::numubarcc::kIsNumubarCC;
49 
50  // Make a spectrum
51  Spectrum TrueEnu("True Neutrnio Enery (GeV)", bins, loader, kTrueENu, kSelections);
52 
53  // Go ahead with spectrum loader
54  loader.Go();
55 
56  // POT for scaling histograms
57  const double potrhc = 9e20;
58 
59  // Draw historam - Instead of drawing, save it in an output root file
60  // Make a root file and save histogram in it
61  TFile* f_output = new TFile("histogram.root", "recreate");
62  TrueEnu. SaveTo(f_output->mkdir("dir_true_spectra"), "neutrino_true_enerrgy");
63  f_output ->Close();
64 
65 // TrueEnu.ToTH1(potrhc)->Draw("hist");
66 }// end of main function
Represent the binning of a Spectrum's x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
virtual void Go() override
Load all the registered spectra.
const Var kTrueENu
loader
Definition: demo0.py:10
const Binning bins
Definition: NumuCC_CPiBin.h:8
void cafana_vars()
Definition: cafana_vars.C:32
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
enum BeamMode string