def init_proc(self): self.my_proc = fmwk.ana_processor() # Set input root file for x in xrange(len(sys.argv) - 1): self.my_proc.add_input_file(sys.argv[x + 1]) # Specify IO mode self.my_proc.set_io_mode(fmwk.storage_manager.kREAD) self.my_proc.add_process(fmwk.DrawRaw())
def init_proc(self): self.my_proc = fmwk.ana_processor() # Set input root file for x in xrange(len(sys.argv)-1): self.my_proc.add_input_file(sys.argv[x+1]) # Specify IO mode self.my_proc.set_io_mode(fmwk.storage_manager.kREAD) self.my_proc.add_process(fmwk.DrawRaw())
import sys 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 seltool import ertool from larlite import larlite as fmwk import empartDef # Create ana_processor instance my_proc = fmwk.ana_processor() # Set input root file for x in xrange(len(sys.argv) - 1): my_proc.add_input_file(sys.argv[x + 1]) # Specify IO mode my_proc.set_io_mode(fmwk.storage_manager.kREAD) # Specify output root file name my_proc.set_ana_output_file("EMPartSelection.root") my_algo = empartDef.EMPartAlgo() my_ana = empartDef.EMPartAna() my_anaunit = empartDef.AnaUnit() my_anaunit._mgr.AddAlgo(my_algo) my_anaunit._mgr.AddAna(my_ana)
msg = '\n' msg += "Usage 1: %s track_producer vtx_producer calo_producer mcc71_ext2_bnb3 $OUTPUT_DIR $INPUT_ROOT_FILE(s)\n" % sys.argv[0] msg += '\n' sys.stderr.write(msg) sys.exit(1) from larlite import larlite as fmwk track_producer = sys.argv[1] vtx_producer = sys.argv[2] calo_producer = sys.argv[3] mcc71_ext2_bnb3 = int(sys.argv[4]) outdir = sys.argv[5] # Create ana_processor instance my_proc = fmwk.ana_processor() # Set input root file for x in xrange(len(sys.argv) - 6): my_proc.add_input_file(sys.argv[x + 6]) # Specify IO mode my_proc.set_io_mode(fmwk.storage_manager.kREAD) my_proc.enable_filter(True) # Specify output root file name anaoutname = 'ana_out_trk%s_vtx%s_mcc71ext2bnb3_%d_THESIS.root'%(track_producer,vtx_producer,mcc71_ext2_bnb3) #anaoutname = 'f**k.root' my_proc.set_ana_output_file(outdir+'/'+anaoutname) myxiao = fmwk.XiaoEventAna()
import sys,os from larlite import larlite as fmwk from recotool.matchDef import * mgr = fmwk.ana_processor() #args should be input file name for x in xrange(len(sys.argv)-1): mgr.add_input_file(sys.argv[x+1]) mgr.set_io_mode(fmwk.storage_manager.kREAD) mgr.set_ana_output_file("dedx_ana.root") dedx_module = fmwk.TunedEdX() mgr.add_process(dedx_module) mgr.run()
import sys if len(sys.argv) < 2: msg = '\n' msg += "Usage 1: %s $INPUT_ROOT_FILE(s)\n" % sys.argv[0] msg += '\n' sys.stderr.write(msg) sys.exit(1) from larlite import larlite from ROOT import larutil, argoutils # Create ana_processor instance my_proc = larlite.ana_processor() larutil.LArUtilManager.Reconfigure(larlite.geo.kArgoNeuT) # Set input root file for x in xrange(len(sys.argv) - 1): my_proc.add_input_file(sys.argv[x + 1]) # Specify IO mode my_proc.set_io_mode(larlite.storage_manager.kREAD) # Specify output root file name my_proc.set_ana_output_file("trainingParameters.root") # Attach an analysis unit ... here we use a base class which does nothing. # Replace with your analysis unit if you wish. # Configure the process: proc = argoutils.GenFANNTrainingData()
#main_algo = cmtool.CFAlgoZOverlap() #main_algo = cmtool.CFAlgoChargeDistrib() #main_algo = cmtool.CFAlgoShowerCompat() #main_algo = cmtool.CFAlgoStartTimeCompat() #main_algo = cmtool.CFAlgoVolumeOverlap() #main_algo.RequireThreePlanes(False) algo_array.AddAlgo(main_algo) #algo_array.AddAlgo(cmtool.CFAlgoTimeProf()) #algo_array.AddAlgo(cmtool.CFAlgo3DAngle()) #algo_array.AddAlgo(cmtool.CFAlgoStartPointMatch()) return palgo_array, algo_array mgr = fmwk.ana_processor() #args should be input file name for x in xrange(len(sys.argv) - 3): mgr.add_input_file(sys.argv[x + 1]) # second to last argument is output pfpart producer match_producer = sys.argv[-2] #last arg should be output file name out_file = sys.argv[-1] if os.path.isfile(out_file): print print 'ERROR: output file already exist...'
import sys, os import ROOT from larlite import larlite as ll from ROOT import cluster, cmtool mgr = ll.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 exist...' print sys.exit(0) mgr.set_output_file(out_file) mgr.set_io_mode(ll.storage_manager.kBOTH) mgr.set_ana_output_file("") merger_instance = ll.ClusterMerger() merger_instance.SaveOutputCluster(True) polar = cmtool.CBAlgoPolar() polar.SetBufferAngle(0.0)
def main(): if len(sys.argv) < 2: msg = '\n' msg += "Usage: %s $INPUT_ROOT_FILE\n" % sys.argv[0] msg += "$INPUT_ROOT_FILE containing 'gamma' ('electron') is used for training AlgoEMPart gamma (electron) mode.\n" msg += '\n' sys.stderr.write(msg) sys.exit(1) # Create ana_processor instance my_proc = fmwk.ana_processor() # Create algorithm my_algo = ertool.AlgoEMPart() # ******* Set Fit ranges ********** # Fit ranges for Reconstructed Info #my_algo.SetFitRange_dEdx(1.2,2,False); # False = e- / True = gamma #my_algo.SetFitRange_dEdx(3.0,4.5,True); #my_algo.SetFitRange_RadLen(5.,25.,True); #my_algo.SetFitRange_RadLen(0.,10.,False); # Fit ranges for MC Info: my_algo.SetFitRange_dEdx(0.5,6,False); # False = e- / True = gamma my_algo.SetFitRange_dEdx(0.5,6,True); my_algo.SetFitRange_RadLen(5.,25.,True); my_algo.SetFitRange_RadLen(0.,5.,False); # ******* End Set Fit Ranges ******* my_algo.setVerbose(True) # Create analysis unit my_ana = fmwk.ExampleERSelection() my_ana.SetMinEDep(10) # 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,"pandoraNuShower"); #my_ana.SetShowerProducer(False,"showerreco"); my_ana.SetTrackProducer(False,""); #my_ana.SetVtxProducer(False,""); my_ana._mgr.SetAlgo(my_algo) my_ana._mgr._training_mode =True # Check if gamma/electron files are provided: gamma_files = [] electron_files = [] for x in xrange(len(sys.argv)-1): fname = sys.argv[x+1] if fname.find('gamma')>=0: gamma_files.append(fname) else: electron_files.append(fname) print print ' Running AlgoEMPart training script...' print print ' Identified %2d input files for gamma' % len(gamma_files) print ' Identified %2d input files for electron' % len(electron_files) if not ask_binary(' Proceed? [y/n]:'): return False print if ask_binary(' Load previously extracted fit parameters? [y/n]:'): my_algo.LoadParams() # # Training for gamma mode # gamma_trained = False if len(gamma_files) and ask_binary(' Run training for gamma? [y/n]:'): my_proc.set_io_mode(fmwk.storage_manager.kREAD) my_proc.add_process(my_ana) for f in gamma_files: my_proc.add_input_file(f) my_algo.SetMode(True) my_ana._mgr.Reset() my_proc.set_ana_output_file("gamma_training.root") print ' Start running gamma training...' my_proc.run() print print ' Finished running gamma training...' print # Re-set my_proc.reset() gamma_trained = True # # Training for electron mode # electron_trained = False if len(electron_files) and ask_binary(' Run training for electron? [y/n]:'): my_proc.set_io_mode(fmwk.storage_manager.kREAD) my_proc.add_process(my_ana) for f in electron_files: my_proc.add_input_file(f) my_algo.SetMode(False) my_ana._mgr.Reset() my_proc.set_ana_output_file("electron_training.root") print ' Start running electron training...' my_proc.run() print print ' Finished running electron training...' print # Re-set my_proc.reset() electron_trained = True # # Store trained parameters # if (gamma_trained or electron_trained) and ask_binary(' Store train result parameters? [y/n]:'): my_algo.StoreParams() print ' Parameter stored...' print return True
def main(): if len(sys.argv) < 2: msg = '\n' msg += "Usage: %s $INPUT_ROOT_FILE\n" % sys.argv[0] msg += "$INPUT_ROOT_FILE containing 'gamma' ('electron') is used for training AlgoEMPart gamma (electron) mode.\n" msg += '\n' sys.stderr.write(msg) sys.exit(1) # Create ana_processor instance my_proc = fmwk.ana_processor() # Create algorithm my_algo = ertool.AlgoEMPart() # ******* Set Fit ranges ********** # Fit ranges for Reconstructed Info my_algo.SetFitRange_dEdx(0.5, 8, False) # False = e- / True = gamma my_algo.SetFitRange_dEdx(0.5, 9, True) my_algo.SetFitRange_RadLen(1., 4., False) my_algo.SetFitRange_RadLen(5., 35., True) # Fit ranges for MC Info: #my_algo.SetFitRange_dEdx(0.5,8,False); # False = e- / True = gamma #my_algo.SetFitRange_dEdx(0.5,9,True); #my_algo.SetFitRange_RadLen(5.,25.,True); #my_algo.SetFitRange_RadLen(0.,5.,False); # ******* End Set Fit Ranges ******* #my_algo.setVerbose(False) my_algo.setPlot(True) # Create analysis unit my_ana = fmwk.ExampleERSelection() my_ana.SetMinEDep(10) my_ana.SetCheater(True) # Set Producers # First Argument: True = MC, False = Reco #my_ana.SetShowerProducer(True,"mcreco"); #my_ana.SetTrackProducer(True,"mcreco"); #my_ana.SetShowerProducer(False,"pandoraNuShower"); my_ana.SetShowerProducer(False, "showerreco") my_ana.SetTrackProducer(False, "") #my_ana._mgr.SetAlgo(my_algo) my_ana._mgr.AddAlgo(my_algo) my_ana._mgr._training_mode = True # Check if gamma/electron files are provided: gamma_files = [] electron_files = [] for x in xrange(len(sys.argv) - 1): fname = sys.argv[x + 1] if fname.find('gamma') >= 0: gamma_files.append(fname) else: electron_files.append(fname) print print ' Running AlgoEMPart training script...' print print ' Identified %2d input files for gamma' % len(gamma_files) print ' Identified %2d input files for electron' % len(electron_files) if not ask_binary(' Proceed? [y/n]:'): return False print if ask_binary(' Load previously extracted fit parameters? [y/n]:'): my_algo.setLoadParams(True) else: my_algo.setLoadParams(False) # # Training for gamma mode # gamma_trained = False if len(gamma_files) and ask_binary(' Run training for gamma? [y/n]:'): my_proc.set_io_mode(fmwk.storage_manager.kREAD) my_proc.add_process(my_ana) for f in gamma_files: my_proc.add_input_file(f) my_algo.SetMode(True) my_ana._mgr.Reset() my_proc.set_ana_output_file("gamma_training.root") print ' Start running gamma training...' my_proc.run() print print ' Finished running gamma training...' print # Re-set my_proc.reset() gamma_trained = True # # Training for electron mode # electron_trained = False if len(electron_files) and ask_binary( ' Run training for electron? [y/n]:'): my_proc.set_io_mode(fmwk.storage_manager.kREAD) my_proc.add_process(my_ana) for f in electron_files: my_proc.add_input_file(f) my_algo.SetMode(False) my_ana._mgr.Reset() my_proc.set_ana_output_file("electron_training.root") print ' Start running electron training...' my_proc.run() print print ' Finished running electron training...' print # Re-set my_proc.reset() electron_trained = True # # Store trained parameters # if (gamma_trained or electron_trained ) and ask_binary(' Store train result parameters? [y/n]:'): my_ana._mgr.StorePSet("new_empart.txt") #my_algo.StoreParams() print ' Parameter stored...' print return True
import sys,os import ROOT from larlite import larlite as ll from ROOT import cluster, cmtool mgr = ll.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 exist...' print sys.exit(0) mgr.set_output_file(out_file) mgr.set_io_mode(ll.storage_manager.kBOTH) mgr.set_ana_output_file("") merger_instance = ll.ClusterMerger() merger_instance.SaveOutputCluster(True) polar = cmtool.CBAlgoPolar() polar.SetBufferAngle(0.0)
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() #viewer plt.ion() display_reco = ERViewer() display_mc = ERViewer() display_reco.show() display_mc.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.ExampleERSelection() # ************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, "showerreco") my_ana.SetTrackProducer(False, "") my_ana.SetVtxProducer(False, "") #my_ana.SetShowerProducer(True,"mcreco"); #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
import larlite import ROOT from ROOT import larlite if len(sys.argv) < 2: msg = '\n' msg += "Usage 1: %s $INPUT_ROOT_FILE(s)\n" % sys.argv[0] msg += '\n' sys.stderr.write(msg) sys.exit(1) # from larlite import larlite as fmwk from ROOT import * # Create ana_processor instance my_proc = larlite.ana_processor() # Set input root file for x in xrange(len(sys.argv)-1): my_proc.add_input_file(sys.argv[x+1]) # Specify IO mode my_proc.set_io_mode(larlite.storage_manager.kREAD) # Specify output root file name my_proc.set_ana_output_file("from_test_ana_you_can_remove_me.root"); # Attach an analysis unit ... here we use a base class which does nothing. # Replace with your analysis unit if you wish. ana_unit = cluster.ClusterParamsAna() my_proc.add_process(ana_unit)
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() #viewer plt.ion() display_reco = ERViewer() display_mc = ERViewer() display_reco.show() display_mc.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.ExampleERSelection() # ************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,"showerreco") my_ana.SetTrackProducer(False,""); my_ana.SetVtxProducer(False,""); #my_ana.SetShowerProducer(True,"mcreco"); #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