All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
demo.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import cafana
4 
5 fname = '/pnfs/icarus/persistent/users/dmendez/SBNAnaFiles/test/icarus/gen-prodcorsika_genie_nooverburden__nuetest.caf.root'
6 
7 loader = cafana.SpectrumLoader(fname)
8 
9 kTruthEnergy = cafana.CSliceVar('if(sr.truth.index > 0) return sr.truth.E; else return -1.;')
10 
11 binsEnergy = cafana.Binning.Simple(50, 0, 5)
12 
13 axEnergy = cafana.HistAxis('True energy (GeV)', binsEnergy, kTruthEnergy)
14 sEnergy = cafana.Spectrum(loader, axEnergy, cafana.kNoCut)
15 
16 loader.Go()
17 
18 sEnergy.ToTH1(sEnergy.POT()).Draw('hist')