demo0.C
Go to the documentation of this file.
1 // Make a simple spectrum plot
2 
3 #include "CAFAna/Core/Binning.h"
4 #include "CAFAna/Cuts/Cuts.h"
5 #include "CAFAna/Core/Spectrum.h"
7 #include "CAFAna/Vars/Vars.h"
8 
10 
11 #include "TCanvas.h"
12 #include "TH2.h"
13 
14 using namespace ana;
15 
16 
17 void demo0()
18 {
19  // Environment variables and wildcards work. Most commonly you want a SAM
20  // dataset. Pass -ss --limit 1 on the cafe command line to make this take a
21  // reasonable amount of time for demo purposes.
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  // Specify variables needed and arbitrary code to extract value from
29  // SRProxy
30  const Var kTrackLen([](const caf::SRProxy* sr)
31  {
32  if(sr->trk.kalman.ntracks == 0) return 0.0f;
33  return float(sr->trk.kalman.tracks[0].len);
34  });
35 
36  // Spectrum to be filled from the loader
37  Spectrum len("Track length (cm)", bins, loader, kTrackLen, kIsNumuCC);
38 
39  // Do it!
40  loader.Go();
41 
42  // How to scale histograms
43  const double pot = 18e20;
44 
45  // We have histograms
46  len.ToTH1(pot)->Draw("hist");
47 }
const XML_Char int len
Definition: expat.h:262
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
void demo0()
Definition: demo0.C:17
caf::Proxy< size_t > ntracks
Definition: SRProxy.h:1778
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
caf::Proxy< caf::SRTrackBranch > trk
Definition: SRProxy.h:2145
#define pot
caf::StandardRecord * sr
virtual void Go() override
Load all the registered spectra.
loader
Definition: demo0.py:10
kTrackLen
Definition: demo0.py:15
const Binning bins
Definition: NumuCC_CPiBin.h:8
caf::Proxy< caf::SRKalman > kalman
Definition: SRProxy.h:1797
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
caf::Proxy< std::vector< caf::SRKalmanTrack > > tracks
Definition: SRProxy.h:1780
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
enum BeamMode string