demo1.py
Go to the documentation of this file.
1 # Make two simple spectrum plots
2 
3 import cafana
4 
5 import ROOT
6 
7 fname = 'prod_sumdecaf_R17-03-01-prod3reco.k_fd_genie_nonswap_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1'
8 
9 loader = cafana.SpectrumLoader(fname)
10 
11 bins = cafana.Binning.Simple(100, 0, 1000)
12 
13 kTrackLen = cafana.CVar('''
14 if(sr.trk.kalman.ntracks == 0) return 0.0f;
15 return float(sr.trk.kalman.tracks[0].len);
16 ''')
17 
18 # For the simplest cases, can just provide the variable name to return
19 kNHit = cafana.SimpleVar('slc.nhit')
20 
21 # Spectrum to be filled from the loader
22 length = cafana.Spectrum('Track length (cm)', bins, loader, kTrackLen, cafana.kIsNumuCC)
23 
24 # And a second one...
25 nhit = cafana.Spectrum("Number of hits in slice", bins, loader, kNHit, cafana.kIsNumuCC)
26 
27 # Do it!
28 loader.Go()
29 
30 # How to scale histograms
31 pot = 18e20
32 
33 # We have histograms
34 length.ToTH1(pot).Draw('hist')
35 canv = ROOT.TCanvas()
36 nhit.ToTH1(pot).Draw('hist')
37 
tree Draw("slc.nhit")