demo2p5a.C
Go to the documentation of this file.
1 // Example of how to save a spectra to disk.
2 //
3 // As a PSA, when running CAFAna on the grid, you should ALWAYS
4 // save your CAFAna products (spectra, extrap objetcs, etc.) to
5 // disk. Plotting things, running fits and what not is then done
6 // in a separate macro (see demo2p5b for an example of this.)
7 
8 #include "CAFAna/Core/Binning.h"
9 #include "CAFAna/Cuts/Cuts.h"
11 #include "CAFAna/Core/Spectrum.h"
13 #include "CAFAna/Vars/Vars.h"
14 
15 #include "TFile.h"
16 
17 using namespace ana;
18 
19 
20 void demo2p5a()
21 {
22  const std::string fname = "prod_sumdecaf_R17-03-01-prod3reco.k_fd_genie_nonswap_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1";
23 
24  SpectrumLoader loader(fname);
25 
26  const Binning bins = Binning::Simple(100, 0, 1000);
27 
28  const Var kNHit([](const caf::SRProxy* sr)
29  {
30  return sr->slc.nhit;
31  });
32 
33  Spectrum nhit("Number of hits in slice", bins, loader, kNHit, kIsNumuCC);
34 
35 
36 
37  // Do it!
38  loader.Go();
39 
40 
41 
42  // Now save to disk...
43  TFile *outFile = new TFile("save_your_spectra_to_disk.root","RECREATE");
44 
45  nhit.SaveTo(outFile->mkdir("dir_nhit_spectra"));
46 
47  outFile->Close();
48 }
void demo2p5a()
Definition: demo2p5a.C:20
const Cut kIsNumuCC(CCFlavSel(14, 14))
Select CC .
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
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
nhit
Definition: demo1.py:25
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
caf::Proxy< unsigned int > nhit
Definition: SRProxy.h:1315
TFile * outFile
Definition: PlotXSec.C:135
const Var kNHit
Definition: Vars.cxx:71
caf::StandardRecord * sr
virtual void Go() override
Load all the registered spectra.
loader
Definition: demo0.py:10
const Binning bins
Definition: NumuCC_CPiBin.h:8
caf::Proxy< caf::SRSlice > slc
Definition: SRProxy.h:2142
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