demo1.C
Go to the documentation of this file.
1 // Make two simple spectrum plots
2 
4 
5 #include "CAFAna/Core/Binning.h"
6 #include "CAFAna/Cuts/Cuts.h"
7 #include "CAFAna/Core/Spectrum.h"
9 #include "CAFAna/Vars/Vars.h"
10 
12 
13 #include "TCanvas.h"
14 #include "TH2.h"
15 
16 using namespace ana;
17 
18 
19 void demo1()
20 {
21  const std::string fname = "prod_sumdecaf_R19-11-18-prod5reco.f_fd_genie_N1810j0211a_nonswap_fhc_nova_v08_full_v1_numu2020";
22 
23  SpectrumLoader loader(fname);
24 
25  const Binning bins = Binning::Simple(100, 0, 1000);
26 
27  // Specify variables needed and arbitrary code to extract value from
28  // SRProxy
29  const Var kTrackLen([](const caf::SRProxy* sr)
30  {
31  if(sr->trk.kalman.ntracks == 0) return 0.0f;
32  return float(sr->trk.kalman.tracks[0].len);
33  });
34 
35  const Var kNHit([](const caf::SRProxy* sr)
36  {
37  return sr->slc.nhit;
38  });
39 
40 
41  // Spectrum to be filled from the loader
42  Spectrum len("Track length (cm)", bins, loader, kTrackLen, kIsNumuCC);
43 
44  // And a second one...
45  Spectrum nhit("Number of hits in slice", bins, loader, kNHit, kIsNumuCC);
46 
47  // Do it!
48  loader.Go();
49 
50  // How to scale histograms
51  const double pot = 18e20;
52 
53  // We have histograms
54  len.ToTH1(pot)->Draw("hist");
55  new TCanvas;
56  nhit.ToTH1(pot)->Draw("hist");
57 }
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
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
caf::Proxy< size_t > ntracks
Definition: SRProxy.h:1778
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
caf::Proxy< caf::SRTrackBranch > trk
Definition: SRProxy.h:2145
const Var kNHit
Definition: Vars.cxx:71
#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
caf::Proxy< caf::SRSlice > slc
Definition: SRProxy.h:2142
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
caf::Proxy< std::vector< caf::SRKalmanTrack > > tracks
Definition: SRProxy.h:1780
void demo1()
Definition: demo1.C:19
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
enum BeamMode string