demo0.py
Go to the documentation of this file.
1 # Make a simple spectrum plot
2 
3 import cafana
4 
5 # Environment variables and wildcards work. Most commonly you want a SAM
6 # dataset. Pass -ss --limit 1 on the cafe command line to make this take a
7 # reasonable amount of time for demo purposes.
8 fname = 'prod_sumdecaf_R17-03-01-prod3reco.k_fd_genie_nonswap_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1'
9 
10 loader = cafana.SpectrumLoader(fname)
11 
12 bins = cafana.Binning.Simple(100, 0, 1000)
13 
14 # Arbitrary code to extract value from StandardRecord. Must be in C++ like this
15 kTrackLen = cafana.CVar('''
16 if(sr.trk.kalman.ntracks == 0) return 0.0f;
17 return float(sr.trk.kalman.tracks[0].len);
18 ''')
19 
20 # Spectrum to be filled from the loader
21 length = cafana.Spectrum("Track length (cm)", bins, loader, kTrackLen, cafana.kIsNumuCC);
22 
23 # Do it!
24 loader.Go()
25 
26 # How to scale histograms
27 pot = 18e20
28 
29 # We have histograms
30 length.ToTH1(pot).Draw('hist')
tree Draw("slc.nhit")