コード例 #1
0
    def __init__(self, geom, file=None):
        super(larlite_manager_base, self).__init__(geom, file)
        manager.__init__(self, geom, file)
        QtCore.QObject.__init__(self)
        # For the larlite manager, need both the ana_processor and
        # the storage manager
        self._process = fmwk.ana_processor()
        self._mgr = fmwk.storage_manager()

        self._keyTable = dict()
        self._drawnClasses = dict()

        if file != None:
            self.setInputFiles(file)

        self._n_entries = 0

        # Toggle whether or not to draw wires:
        self._drawWires = False
        self._drawParams = False
        self._drawTruth = False

        self._wireDrawer = None
        self._truthDrawer = None

        # Lariat has special meanings to event/spill/run
        self._spill = 0
コード例 #2
0
ファイル: larlite_manager.py プロジェクト: larlight/larlite
    def __init__(self, geom, file=None):
        super(larlite_manager_base, self).__init__(geom, file)
        manager.__init__(self, geom, file)
        QtCore.QObject.__init__(self)
        # For the larlite manager, need both the ana_processor and
        # the storage manager
        self._process = fmwk.ana_processor()
        self._mgr = fmwk.storage_manager()

        self._keyTable = dict()
        self._drawnClasses = dict()

        if file != None:
            self.setInputFiles(file)

        self._n_entries = 0

        # Toggle whether or not to draw wires:
        self._drawWires = False
        self._drawParams = False
        self._drawTruth = False

        self._wireDrawer = None
        self._truthDrawer = None

        # Lariat has special meanings to event/spill/run
        self._spill = 0
コード例 #3
0
def process_sample(_type, _file):

    # Create ana_processor instance
    my_proc = larlite.ana_processor()

    # Set input root file
    # for _f in f:
    # my_proc.add_input_file(_f)

    my_proc.add_input_file(_file)

    # Specify IO mode
    my_proc.set_io_mode(larlite.storage_manager.kREAD)

    # Specify output root file name
    my_proc.set_ana_output_file(_file.replace('.root', '') + "_ana.root")
    # my_proc.set_output_file("")

    filterModule = argoana.Stage1Efficiency()
    filterModule.setTrackProducer("pmtrack")
    filterModule.setClusterProducer("trajcluster")
    filterModule.setMinTrackLength(15)

    # Attach an analysis unit ... here we use a base class which do
    my_proc.add_process(filterModule)

    my_proc.run(0)
コード例 #4
0
ファイル: get_all.py プロジェクト: rmurrells/filters
def run(delta_pdgs, is_not, output_name, ccnc = 0):

    if os.path.exists(output_name):
        shutil.rmtree(output_name)
        
    os.mkdir(output_name)
    
    file_increment = 10
    increment_counter = 0
    file_counter = 1

    number_of_arguments = len(sys.argv) - 1

    loop_range = 1
    
    if(number_of_arguments > file_increment):
        loop_range = number_of_arguments / file_increment
        if(number_of_arguments % file_increment):
            loop_range += 1

    my_proc = fmwk.ana_processor()
            
    for i in xrange(0, loop_range):

        my_proc.reset()
        increment_counter += file_increment
        
        while(file_counter <= increment_counter):
            
            if file_counter >= len(sys.argv):
                break
            
            my_proc.add_input_file(sys.argv[file_counter])
            file_counter += 1
        
        my_proc.set_io_mode(fmwk.storage_manager.kBOTH)
        my_proc.set_output_file(output_name + "/" + output_name + "_" + str(i) + ".root")
        my_proc.enable_filter()

        if(ccnc == 1):
            my_proc.add_process(fmwk.ccnc(True))
        elif(ccnc == 2):
            my_proc.add_process(fmwk.ccnc(False))
            
        idrs = fmwk.is_delta_rad_spec(is_not)
        
        for i in xrange(0, len(delta_pdgs)):
            idrs.add_delta_parents(delta_pdgs[i])
        
        my_proc.add_process(idrs)
    
        my_proc.run()
コード例 #5
0
def processMC(f):

    larutil.LArUtilManager.Reconfigure(larlite.geo.kArgoNeuT)

    # Make an instance of the larlite processing framework:
    my_proc = larlite.ana_processor()

    # Set input root file
    my_proc.add_input_file(f)

    # Specify IO mode
    my_proc.set_io_mode(larlite.storage_manager.kREAD)

    proc = larlite.MCElectronEstimate()

    # Attach an analysis unit ... here we use a base class which do
    my_proc.add_process(proc)

    # Let's run it.
    my_proc.run()

    return proc
コード例 #6
0
    msg += "Usage 1: %s $INPUT_ROOT_FILE\n" % sys.argv[0]
    msg += '\n'
    sys.stderr.write(msg)
    sys.exit(1)

from ROOT import gSystem, TMath
from ROOT import larlite as fmwk
from ROOT import larutil
#from larlite import larlite as fmwk
#from larlite import larutil

# Set input root file
for x in xrange(len(sys.argv) - 1):

    # Create ana_processor instance
    my_proc = fmwk.ana_processor()

    my_proc.add_input_file(sys.argv[x + 1])

    fname = sys.argv[x + 1]

    run = int(fname[fname.find('_run_') + 5:fname.find('_subrun_')])
    subrun = int(fname[fname.find('_subrun_') + 8:fname.find('.root')])

    if (run <= 1236):
        continue

    print str(run) + ' ' + str(subrun)

    outfile = "rawdigit_laser_%05d_%04d.root" % (run, subrun)
コード例 #7
0
ファイル: simplewfana.py プロジェクト: davidc1/Commissioning
import sys,os

if len(sys.argv) < 2:
    msg  = '\n'
    msg += "Usage 1: %s $INPUT_ROOT_FILE\n" % sys.argv[0]
    msg += '\n'
    sys.stderr.write(msg)
    sys.exit(1)

from ROOT import gSystem
#gSystem.Load("libSimpleWFAna")
from ROOT import larlite as fmwk

# Create ana_processor instance
my_proc = fmwk.ana_processor()

# add input files
my_proc.add_input_file(sys.argv[1])

# Specify IO mode
my_proc.set_io_mode(fmwk.storage_manager.kREAD)

# Specify output root file name
my_proc.set_ana_output_file("SimpleWFAna_output.root");

ana_unit = fmwk.SimpleWFAna()
#corr_unit.setVerbose(True)

my_proc.add_process(ana_unit)

print
コード例 #8
0
ファイル: get_all_2.py プロジェクト: rmurrells/filters
if len(sys.argv) < 2:
    msg  = '\n'
    msg += "Usage 1: %s $INPUT_ROOT_FILE\n" % sys.argv[0]
    msg += '\n'
    sys.stderr.write(msg)
    sys.exit(1)

    
from ROOT import larlite as fmwk

is_not = True

#ALL
################################################################################

my_proc = fmwk.ana_processor()

for i in xrange(1,len(sys.argv)):
    my_proc.add_input_file(sys.argv[i])

my_proc.set_io_mode(fmwk.storage_manager.kBOTH)
out_name = "not_delta_rad_1delta_1gamma.root"
my_proc.set_output_file(out_name)
my_proc.enable_filter()

idrs = fmwk.is_delta_rad_spec(is_not)
idrs.add_delta_parents(2214)
idrs.add_delta_parents(2114)
my_proc.add_process(idrs)

my_proc.run()
コード例 #9
0
ファイル: pi0_reco.py プロジェクト: yeonjaej/nnbar
def main():

    if len(sys.argv) < 2:
        msg  = '\n'
        msg += "Usage: %s $INPUT_ROOT_FILE\n" % sys.argv[0]
        msg += '\n'
        sys.stderr.write(msg)
        sys.exit(1)

    # Create Pi0 Filter
    pi0_filter = fmwk.Pi0ContainmentFilter();

    # Create ana_processor instance
    my_proc = fmwk.ana_processor()
    my_proc.enable_filter(True)
    # Create algorithm
    my_algo = ertool.AlgoPi0()
    my_algo.setVerbose(True)
    my_algo.setMinShrEnergy(10)
    my_algo.setMaxShrEnergy(1000)
    my_algo.setIPMax(10)
    my_algo.setMinFitMass(50)
    my_algo.setMaxFitMass(200)
    my_algo.setAngleMax(3.14)
    # Create filter
    my_filter = ertool.FilterECut()
    my_filter.SetECut(10) #cut on 10 MeV
    # Create analysis unit
    my_ana = fmwk.ExampleERSelection()

    # Set Producers
    # First Argument: True = MC, False = Reco
    my_ana.SetShowerProducer(True,"mcreco");
    my_ana.SetTrackProducer(True,"mcreco");
    my_ana.SetVtxProducer(True,"generator");
    
    #my_ana.SetShowerProducer(False,"showerreco");
    #my_ana.SetTrackProducer(False,"");
    #my_ana.SetVtxProducer(False,"");

    my_ana._mgr.SetFilter(my_filter)
    my_ana._mgr.SetAlgo(my_algo)
    my_ana._mgr._training_mode =False

    # Obtain input root files
    files = []
    for x in xrange(len(sys.argv)-1):
        fname = sys.argv[x+1]
        if fname.endswith('.root'):
            files.append(fname)

    print
    print '  Running AlgoPi0 training script...'
    print
    print '  Identified %2d input files' % len(files)
    if not ask_binary('  Proceed? [y/n]:'): return False
    print
    if ask_binary('  Load previously extracted fit parameters? [y/n]:'):
        my_algo.LoadParams()    

    my_proc.set_io_mode(fmwk.storage_manager.kREAD)
    #my_proc.add_process(pi0_filter);
    my_proc.add_process(my_ana)
    for f in files:
        my_proc.add_input_file(f)

    my_ana._mgr.Reset()
    my_proc.set_ana_output_file("pi0_reco.root")
    print '    Start running pi0 reco...'

    my_proc.run()

    print
    print '    Finished running pi0 reco...'
    print

    return True
コード例 #10
0
ファイル: run_prelim_merger.py プロジェクト: uboone/larlite
import ROOT,sys,os
from recotool.mergeDef import *
from ROOT import larlite as fmwk

mgr = fmwk.ana_processor()

#args should be input file name
for x in xrange(len(sys.argv)-2):

    mgr.add_input_file(sys.argv[x+1])

#last arg should be output file name
out_file = sys.argv[-1]
if os.path.isfile(out_file):
    print
    print 'ERROR: output file already exists...'
    print
    sys.exit(0)

mgr.set_output_file(out_file)

mgr.set_io_mode(fmwk.storage_manager.kBOTH)

mgr.set_ana_output_file("")

prelimMerger = GetPrelimMergerInstance()
# prelimMerger = GetPrelimMergerInstance(producer="fuzzycluster",saveOutput=True)

mgr.add_process(prelimMerger)

mgr.run()
コード例 #11
0
ファイル: pi0_viewer.py プロジェクト: uboone/larlite
def main():

    if len(sys.argv) < 2:
        msg = '\n'
        msg += "Usage: %s $INPUT_ROOT_FILE\n" % sys.argv[0]
        msg += '\n'
        sys.stderr.write(msg)
        sys.exit(1)

    ertool.Manager()
    print "manager"
    #viewer
    plt.ion()
    display_reco = ERViewer()
    print "display"
    display_mc = ERViewer()
    print "display"
    display_reco.show()
    print "show"
    display_mc.show()
    print "show"

    # Create ana_processor instance
    my_proc = fmwk.ana_processor()
    # Create algorithm
    my_algo = ertool.AlgoPi0()
    my_algo.setVerbose(True)
    my_algo.setMinShrEnergy(10)
    my_algo.setMaxShrEnergy(1000)
    my_algo.setIPMax(10)
    my_algo.setMinFitMass(50)
    my_algo.setMaxFitMass(200)
    my_algo.setAngleMax(3.14)

    # Create analysis unit
    my_ana = fmwk.Pi0Reco()

    # ************Set Producers**************
    # First Argument: True = MC, False = Reco
    #my_ana.SetShowerProducer(True,"mcreco");
    #my_ana.SetTrackProducer(True,"mcreco");
    my_ana.SetVtxProducer(False, "")
    #my_ana.SetShowerProducer(False,"pandoraNuShower")
    #my_ana.SetTrackProducer(False,"");
    #my_ana.SetVtxProducer(False,"");
    my_ana.SetShowerProducer(True, "showerreco")
    #my_ana.SetTrackProducer(True,"mcreco");
    #my_ana.SetVtxProducer(False,"");
    # ************Set Producers**************

    #help(my_ana._mgr)
    my_ana._mgr.SetAlgo(my_algo)
    my_ana._mgr._training_mode = True

    # Obtain input root files
    files = []
    for x in xrange(len(sys.argv) - 1):
        fname = sys.argv[x + 1]
        if fname.endswith('.root'):
            files.append(fname)

    print
    print '  Running AlgoPi0 training script...'
    print
    print '  Identified %2d input files' % len(files)
    if not ask_binary('  Proceed? [y/n]:'): return False
    print
    if ask_binary('  Load previously extracted fit parameters? [y/n]:'):
        my_algo.LoadParams()

    my_proc.set_io_mode(fmwk.storage_manager.kREAD)
    my_proc.add_process(my_ana)
    for f in files:
        my_proc.add_input_file(f)

    my_ana._mgr.Reset()
    my_proc.set_ana_output_file("pi0_viewing.root")
    print '    Start running pi0 training...'

    # Start event-by-event loop
    counter = 0
    while (counter < 1000):
        try:
            counter = input(
                'Hit Enter to continue to next evt, or type in an event number to jump to that event:'
            )
        except SyntaxError:
            counter = counter + 1
        my_proc.process_event(counter)
        # get objets and display
        display_reco.clear()
        display_mc.clear()

        data_reco = my_ana.GetData()
        part_reco = my_ana.GetParticles()
        data_mc = my_ana.GetData(True)
        part_mc = my_ana.GetParticles(True)

        #display_reco.add(part_reco, data_reco, False)
        display_mc.add(part_mc, data_mc, False)
        display_reco.add(part_reco, data_reco, False)

        for x in xrange(part_mc.size()):
            print part_mc[x].Diagram()
        #for x in xrange(part_reco.size()):
        #    print part_reco[x].Diagram()
        #Last argument decides if un-taggeg showers/tracks should have random color (True) or grey (False)

        display_reco.show()
        display_mc.show()

    #my_proc.run()

    print
    print '    Finished running pi0 training...'
    print

    #
    # Store trained parameters
    #
    if ask_binary('  Store train result parameters? [y/n]:'):
        my_algo.StoreParams()
        print '  Parameter stored...'
        print

    return True
コード例 #12
0
        tname1 = "numi10.txt"
    if x == 4:
        T = 12
        fname = "HitWire-nnbar12.root"
        fname1 = "HitWire-numi12.root"
        tname = "nnbar12.txt"
        tname1 = "numi12.txt"
    if x == 5:
        T = 14
        fname = "HitWire-nnbar14.root"
        fname1 = "HitWire-numi14.root"
        tname = "nnbar14.txt"
        tname1 = "numi14.txt"

    # Create ana_processor instance
    my_proc = fmwk.ana_processor()

    # add input files - nnbar rawdigit file
    my_proc.add_input_file(sys.argv[1])

    # Specify IO mode
    my_proc.set_io_mode(fmwk.storage_manager.kREAD)

    ana_unit = fmwk.SimpleWFAna(T, fname, tname, option)

    my_proc.add_process(ana_unit)

    print
    print "Finished configuring ana_processor. Start event loop!"
    print
コード例 #13
0
ファイル: pi0_training.py プロジェクト: a-d-smith/nnbar
def main():

    if len(sys.argv) < 2:
        msg  = '\n'
        msg += "Usage: %s $INPUT_ROOT_FILE\n" % sys.argv[0]
        msg += '\n'
        sys.stderr.write(msg)
        sys.exit(1)

    # Create Pi0 Filter
    pi0_filter = fmwk.Pi0ContainmentFilter();

    # Create ana_processor instance
    my_proc = fmwk.ana_processor()
    my_proc.enable_filter(True)
    # Create algorithm
    my_algo = ertool.AlgoPi0()
    my_algo.setVerbose(True)
    my_algo.setMinShrEnergy(10)
    my_algo.setMaxShrEnergy(1000)
    my_algo.setIPMax(10)
    my_algo.setMinFitMass(50)
    my_algo.setMaxFitMass(200)
    my_algo.setAngleMax(3.14)
    # Create filter
    my_filter = ertool.FilterECut()
    my_filter.SetECut(10) #cut on 10 MeV
    # Create analysis unit
    my_ana = fmwk.Pi0Quality()#ExampleERSelection()

    # Set Producers
    # First Argument: True = MC, False = Reco
    my_ana.SetShowerProducer(True,"mcreco");
    my_ana.SetTrackProducer(True,"mcreco");
    my_ana.SetVtxProducer(True,"generator");
    
    #my_ana.SetShowerProducer(False,"showerreco");
    #my_ana.SetTrackProducer(False,"");
    #my_ana.SetVtxProducer(False,"");

    my_ana._mgr.SetFilter(my_filter)
    my_ana._mgr.SetAlgo(my_algo)
    my_ana._mgr._training_mode =True

    # Obtain input root files
    files = []
    for x in xrange(len(sys.argv)-1):
        fname = sys.argv[x+1]
        if fname.endswith('.root'):
            files.append(fname)

    print
    print '  Running AlgoPi0 training script...'
    print
    print '  Identified %2d input files' % len(files)
    if not ask_binary('  Proceed? [y/n]:'): return False
    print
    if ask_binary('  Load previously extracted fit parameters? [y/n]:'):
        my_algo.LoadParams()    

    my_proc.set_io_mode(fmwk.storage_manager.kREAD)
    #my_proc.add_process(pi0_filter);
    my_proc.add_process(my_ana)
    for f in files:
        my_proc.add_input_file(f)

    my_ana._mgr.Reset()
    my_proc.set_ana_output_file("pi0_training.root")
    print '    Start running pi0 training...'

    my_proc.run()

    print
    print '    Finished running pi0 training...'
    print

    #
    # Store trained parameters
    #
    if ask_binary('  Store train result parameters? [y/n]:'):
        my_algo.StoreParams()
        print '  Parameter stored...'
        print

    return True
コード例 #14
0
def main(**args):

    my_proc = larlite.ana_processor()

    my_proc.enable_event_alignment(False)

    if args['verbose']:
        print "Verbose mode turned on."
        if args['source'] != None:
            print "\tSource file is " + args['source']
        if args['data_output'] != None:
            print "\tData output file is " + args['data_output']
        if args['ana_output'] != None:
            print "\tAna output file is " + args['ana_output']
        # my_proc.set_verbosity(larlite.msg.kDEBUG)
    # else:
    my_proc.set_verbosity(larlite.msg.kERROR)

    if args['source'] == None:
        print "Error: please specificy an input file with -s or --source."
        quit()

    if args['data_output'] == None:
        args['data_output'] = "default_merge_output.root"
        if args['verbose']:
            print "No event output file selected.  If necessary, output will go to: "
            print "\t" + args['data_output']

    if args['ana_output'] == None:
        args['ana_output'] = "default_ana_output.root"
        if args['verbose']:
            print "No ana output file selected.  If necessary, output will go to:"
            print "\t" + args['ana_output']

    if args['num_events'] != None:
        nevents = int(args['num_events'])

    my_proc.set_io_mode(larlite.storage_manager.kBOTH)

    for x in args['source']:
        my_proc.add_input_file(x)

    my_proc.set_output_file(args['data_output'])
    larutil.LArUtilManager.Reconfigure(larlite.geo.kArgoNeuT)

    # Get the list of processes from argotool
    procs = merge.argoMergeProcList()
    # procs = merge.argoJointrackProcList()

    for proc in procs:
        my_proc.add_process(proc)

    # my_proc.process_event(0)\
    if args['num_events'] != None:
        start = time.clock()
        my_proc.run(0, nevents)
        end = time.clock()
        print "Processed ", nevents, " events in ", end - start, "seconds."
        print "Average per event: ", (end - start) / nevents, "seconds."
    else:
        my_proc.run()
コード例 #15
0
ファイル: simplewfana.py プロジェクト: tgrbrooks/WFAnalysis
			tname1 = op_name+"-numi12.txt"
                        print
                        print(op_name+", T = "+str(T))
                        print
		if x == 5:
			T = 14
			fname = op_name+"-nnbar14.root"
			fname1 = op_name+"-numi14.root"
			tname = op_name+"-nnbar14.txt"
			tname1 = op_name+"-numi14.txt"
                        print
                        print(op_name+", T = "+str(T))
                        print

		# Create ana_processor instance
		my_proc = fmwk.ana_processor()
	
		# add input files - nnbar rawdigit file
		my_proc.add_input_file(sys.argv[1])
	
		# Specify IO mode
		my_proc.set_io_mode(fmwk.storage_manager.kREAD)
	
		ana_unit = fmwk.SimpleWFAna(T,fname,tname,option,plane)
	
		my_proc.add_process(ana_unit)
	
		print
		print  "Finished configuring ana_processor. Start event loop!"
		print
		
コード例 #16
0
ファイル: pi0_viewer.py プロジェクト: a-d-smith/nnbar
def main():

    if len(sys.argv) < 2:
        msg  = '\n'
        msg += "Usage: %s $INPUT_ROOT_FILE\n" % sys.argv[0]
        msg += '\n'
        sys.stderr.write(msg)
        sys.exit(1)

    ertool.Manager()
    print "manager"
    #viewer
    plt.ion()
    display_reco = ERViewer()
    print "display"
    display_mc   = ERViewer()
    print "display"
    display_reco.show()
    print "show"
    display_mc.show()
    print "show"

    # Create ana_processor instance
    my_proc = fmwk.ana_processor()
    # Create algorithm
    my_algo = ertool.AlgoPi0()
    my_algo.setVerbose(True)
    my_algo.setMinShrEnergy(10)
    my_algo.setMaxShrEnergy(1000)
    my_algo.setIPMax(10)
    my_algo.setMinFitMass(50)
    my_algo.setMaxFitMass(200)
    my_algo.setAngleMax(3.14)

    # Create analysis unit
    my_ana = fmwk.Pi0Reco()

    # ************Set Producers**************
    # First Argument: True = MC, False = Reco
    #my_ana.SetShowerProducer(True,"mcreco");
    #my_ana.SetTrackProducer(True,"mcreco");
    my_ana.SetVtxProducer(False,"");
    #my_ana.SetShowerProducer(False,"pandoraNuShower")
    #my_ana.SetTrackProducer(False,"");
    #my_ana.SetVtxProducer(False,"");
    my_ana.SetShowerProducer(True,"showerreco");
    #my_ana.SetTrackProducer(True,"mcreco");
    #my_ana.SetVtxProducer(False,"");
    # ************Set Producers**************

    #help(my_ana._mgr)
    my_ana._mgr.SetAlgo(my_algo)
    my_ana._mgr._training_mode =True

    # Obtain input root files
    files = []
    for x in xrange(len(sys.argv)-1):
        fname = sys.argv[x+1]
        if fname.endswith('.root'):
            files.append(fname)

    print
    print '  Running AlgoPi0 training script...'
    print
    print '  Identified %2d input files' % len(files)
    if not ask_binary('  Proceed? [y/n]:'): return False
    print
    if ask_binary('  Load previously extracted fit parameters? [y/n]:'):
        my_algo.LoadParams()    

    my_proc.set_io_mode(fmwk.storage_manager.kREAD)
    my_proc.add_process(my_ana)
    for f in files:
        my_proc.add_input_file(f)

    my_ana._mgr.Reset()
    my_proc.set_ana_output_file("pi0_viewing.root")
    print '    Start running pi0 training...'

    # Start event-by-event loop
    counter = 0
    while (counter < 1000):
        try:
            counter = input('Hit Enter to continue to next evt, or type in an event number to jump to that event:')
        except SyntaxError:
            counter = counter + 1
        my_proc.process_event(counter)
        # get objets and display
        display_reco.clear()
        display_mc.clear()

        data_reco = my_ana.GetData()
        part_reco = my_ana.GetParticles()
        data_mc   = my_ana.GetData(True)
        part_mc   = my_ana.GetParticles(True)
        
        #display_reco.add(part_reco, data_reco, False)
        display_mc.add(part_mc, data_mc, False)
        display_reco.add(part_reco, data_reco, False)

        for x in xrange(part_mc.size()):
            print part_mc[x].Diagram()
        #for x in xrange(part_reco.size()):
        #    print part_reco[x].Diagram()
        #Last argument decides if un-taggeg showers/tracks should have random color (True) or grey (False)

        display_reco.show()
        display_mc.show()

    #my_proc.run()

    print
    print '    Finished running pi0 training...'
    print

    #
    # Store trained parameters
    #
    if ask_binary('  Store train result parameters? [y/n]:'):
        my_algo.StoreParams()
        print '  Parameter stored...'
        print

    return True