예제 #1
0
import cafana

# Environment variables and wildcards work. Most commonly you want a SAM
# dataset. Pass -ss --limit 1 on the cafe command line to make this take a
# reasonable amount of time for demo purposes.
fname = 'prod_sumdecaf_R17-03-01-prod3reco.k_fd_genie_nonswap_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1'

loader = cafana.SpectrumLoader(fname)

bins = cafana.Binning.Simple(100, 0, 1000)

# Arbitrary code to extract value from StandardRecord. Must be in C++ like this
kTrackLen = cafana.CVar('''
if(sr.trk.kalman.ntracks == 0) return 0.0f;
return float(sr.trk.kalman.tracks[0].len);
''')

# Spectrum to be filled from the loader
length = cafana.Spectrum("Track length (cm)", bins, loader, kTrackLen,
                         cafana.kIsNumuCC)

# Do it!
loader.Go()

# How to scale histograms
pot = 18e20

# We have histograms
length.ToTH1(pot).Draw('hist')
예제 #2
0
파일: demo.py 프로젝트: SBNSoftware/sbnana
#!/usr/bin/env python

import cafana

fname = '/pnfs/icarus/persistent/users/dmendez/SBNAnaFiles/test/icarus/gen-prodcorsika_genie_nooverburden__nuetest.caf.root'

loader = cafana.SpectrumLoader(fname)

kTruthEnergy = cafana.CSliceVar(
    'if(sr.truth.index > 0) return sr.truth.E; else return -1.;')

binsEnergy = cafana.Binning.Simple(50, 0, 5)

axEnergy = cafana.HistAxis('True energy (GeV)', binsEnergy, kTruthEnergy)
sEnergy = cafana.Spectrum(loader, axEnergy, cafana.kNoCut)

loader.Go()

sEnergy.ToTH1(sEnergy.POT()).Draw('hist')
예제 #3
0
    MC_Truth = cafana.CVar('''
return float(sr.mc.nu[0].x);
''')

    MC_mode = cafana.CVar('''
return float(sr.mc.nu[0].mode);
''')

    kCrudeMuonSel = cafana.CCut('''
if(sr.trk.kalman.ntracks == 0) return false;
return bool(sr.trk.kalman.tracks[0].len > 200);
''')

    # Spectrum to be filled from the loader
    length = cafana.Spectrum("{}".format(MC_mode), bins, loader, MC_Truth,
                             cafana.kIsNumuCC)

    # Do it!
    loader.Go()

    # How to scale histograms
    pot = 18e20

    # We have histograms
    hist_plot = length.ToTH1(pot)
    hist_plot.Draw('hist')

    # Output mode
    print('Mode value is', MC_mode)
예제 #4
0
    # Arbitrary code to extract value from StandardRecord. Must be in C++ like this

    MC_Truth = cafana.CVar('''
return float(sr.mc.nu[0].x);
''')

    kNumuCutND2018 = cafana.CCut('''
return (sr->energy.numu.trkccE > 0 && // nothing is terribly wrong
sr->sel.remid.pid > 0   &&    // ensures at least 1 3D Kalman track with a remid value
sr->slc.nhit > 20       &&    // low hits stuff is junk
sr->slc.ncontplanes > 4 &&    // remove really vertical stuff
sr->trk.cosmic.ntracks > 0 ); // need a cosmic track
''')

    # Spectrum to be filled from the loader
    length = cafana.Spectrum("{}".format(MC_mode), bins, loader, MC_Truth,
                             kNumuCutND2018)

    # Do it!
    loader.Go()

    # How to scale histograms
    pot = 18e20

    # We have histograms
    hist_plot = length.ToTH1(pot)
    h = hist_plot.Draw('hist')
    h.savefig("MC_Plot_{}_of_10.pdf".format(i), bbox_inches='tight')

    # Output mode
    print('Mode value is', MC_mode)
예제 #5
0
    # Arbitrary code to extract value from StandardRecord. Must be in C++ like this
    kTrackLen = cafana.CVar('''
if(sr.trk.kalman.ntracks == 0) return 0.0f;
return float(sr.trk.kalman.tracks[0].len);
''')

    MC_Truth = cafana.CVar('''
return float(sr.mc.nu[0].x);
''')

    MC_mode = cafana.CVar('''
return float(sr.mc.nu[0].mode);
''')

    # Spectrum to be filled from the loader
    length = cafana.Spectrum("{}".format(MC_mode), bins, loader, MC_Truth, cafana.kIsNumuCC, cafana.kNoShift, cafana.kGibuuWeight);

    # Do it!
    loader.Go()
    
    # How to scale histograms
    pot = 18e20

    # We have histograms
    hist_plot = length.ToTH1(pot).Draw('hist')
    hist_plot

    # Output mode
    print('Mode value is', MC_mode)
    
	
예제 #6
0
      }

      return ( sr->trk.kalman.ntracks > sr->trk.kalman.idxremid
               && sr->slc.firstplane > 1   // skip 0 and 1
               && sr->slc.lastplane  < 212 // skip 212 and 213
              && sr->trk.kalman.tracks[0].start.Z() < 1100
                 // vertex definitely outside mC
            && ( sr->trk.kalman.tracks[0].stop.Z() < 1275
                    || sr->sel.contain.kalyposattrans < 55 ) // air gap
               && sr->sel.contain.kalfwdcellnd > 5
               && sr->sel.contain.kalbakcellnd > 10 );
       }
   );''')

    # Spectrum to be filled from the loader
    length = cafana.Spectrum(bins, loader, MC_Truth, cafana.kIsNumuCC)

    # Do it!
    loader.Go()

    # How to scale histograms
    pot = 18e20

    # We have histograms
    hist_plot = length.ToTH1(pot).Draw('hist')

    def histogram_plot(hist, outFile):

        # initialisation
        # gROOT.SetStyle("Plain") ;
        # gStyle.SetOptStat(0)