Exemple #1
0
# Possible filter to select true events
#my_proc.enable_filter(True)
#pdgsel = fmwk.PDGSelection()
#pdgsel.Select(11,pdgsel.kGENERATOR,1)
#my_proc.add_process(pdgsel)

my_algo = ertool.AlgoLonelyE()
my_algo.LoadParams()
my_algo.Reset()
my_algo.setDebug(True)

my_filter = ertool.FilterECut()
my_filter.SetECut(30.)  # MeV

my_ana = fmwk.ExampleERSelection()
# OPTIONAL:
my_ana.SetShowerProducer(False, "showerreco")
my_ana.SetTrackProducer(False, "stitchkalmanhit")
#my_ana.SetShowerProducer(True,"mcreco");
#my_ana.SetTrackProducer(True,"mcreco");
my_ana.SetVtxProducer(False, "")
#my_ana.RecoProducer("","showerreco") # call if using Reco objects
#my_ana.AddGeneratorProducer("generator") # call if MC vertex info should be used (for rad-length to be used w/ Reco, for example)
my_ana._mgr.SetAlgo(my_algo)
my_ana._mgr.SetFilter(my_filter)
my_ana._mode = True  # True = Select. False = Fill mode
my_proc.add_process(my_ana)

counter = 0
while (counter < 1000):
Exemple #2
0
from ROOT import ertool
ertool.Manager

# Create ana_processor instance
my_proc = fmwk.ana_processor()

# Set input root file
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("from_test_ana_you_can_remove_me.root")

ana_unit = fmwk.ExampleERSelection()
ana_unit._mgr.SetAlgo(ertool.AlgoPi0())

# Attach a template process
my_proc.add_process(ana_unit)

print
print "Finished configuring ana_processor. Start event loop!"
print

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

# done!
print
print "Finished running ana_processor event loop!"
Exemple #3
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)

    # 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
Exemple #4
0
fmatch = ertool.ERAlgoFlashMatch()
# 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("cosmic_trees.root")

Ecut = 20  # in MeV

my_ana = ertool.ERAnaCRTagger()

my_anaunit = fmwk.ExampleERSelection()
#my_anaunit._mgr.AddAlgo(pid_algo)
my_anaunit._mgr.AddAlgo(crprimary_algo)
my_anaunit._mgr.AddAlgo(crsecondary_algo)
my_anaunit._mgr.AddAlgo(crorphan)
#my_anaunit._mgr.AddAlgo(primary)
my_anaunit._mgr.AddAlgo(fmatch)
my_anaunit._mgr.AddAna(my_ana)
my_anaunit._mgr._verbosity = 0
#my_anaunit._mgr.AddCfgFile('new_empart.txt')
my_anaunit.SetMinEDep(Ecut)
my_anaunit._mgr._mc_for_ana = False

# ***************  Set Producers  ****************
# First Argument: True = MC, False = Reco
#my_anaunit.SetShowerProducer(True,"")
Exemple #5
0
def GetERSelectionInstance():

    # Make an instance of ERAlgoFlashMatch using defaults defined in ertool_default(_mc).cfg
    flashmatch_algo = ertool.ERAlgoFlashMatch()
    flashmatch_algo.SetIgnoreShowers(False)
    flashmatch_algo.SetIgnoreCosmics(True)

    # Get Default CCSingleE Algorithm instance
    # this information is loaded from:
    # $LARLITE_BASEDIR/python/seltool/GetCCSingleEInstance
    ccsinglee_algo = GetCCSingleEInstance()
    #ccsinglee_algo.SetVerbosity(0)
    #ccsinglee_algo.setVerbose(False)

    # primary finder algorithm
    # this information is loaded from:
    # $LARLITE_BASEDIR/python/seltool/GetPrimaryFinderInstance
    primary_algo = GetPrimaryFinderInstance()

    # primary cosmic algoithm
    # this information is loaded from:
    # $LARLITE_BASEDIR/python/seltool/primarycosmicDef.py
    cosmicprimary_algo = GetPrimaryCosmicFinderInstance()
    cosmicsecondary_algo = ertool.ERAlgoCRSecondary()
    cosmicorphanalgo = ertool.ERAlgoCROrphan()
    # track PID algorithm
    # this information is loaded from:
    # $LARLITE_BASEDIR/python/seltool/GetTrackPidInstance
    pid_algo = GetTrackPidInstance()
    #pid_algo.setVerbose(False)

    # cosmic tagger algo
    #cos_algo = GetCosmicTaggerInstance()
    cos_algo = GetTrackDresserInstance()
    #cos_algo.setVerbose(False)

    pi0_algo = GetERAlgoPi0Instance()
    # here set E-cut for Helper & Ana modules
    #This cut is applied in helper... ertool showers are not made if the energy of mcshower or reco shower
    #is below this threshold. This has to be above 0 or else the code may segfault. This is not a "physics cut".
    #Do not change this value unless you know what you are doing.
    #Ecut = 50 # in MeV
    Ecut = 10  #temporary trying this to see if it helps pi0 mids at low energy

    #anaunit = fmwk.ERSelSaveSingleEEvents()
    anaunit = fmwk.ExampleERSelection()
    anaunit.SetShowerProducer(True, 'mcreco')
    anaunit.SetTrackProducer(True, 'mcreco')

    anaunit.SetFlashProducer('opflashSat')

    anaunit.setDisableXShift(False)

    anaunit._mgr.AddAlgo(ertool.ERAlgoTagEmulatedDeletionsCosmic())

    # pi0 algo takes a long time on cosmics files (may showers)...
    # first run track dresser to gobble up most of the showers and
    # pi0 algo will run much faster (I hope!)
    anaunit._mgr.AddAlgo(cos_algo)
    anaunit._mgr.AddAlgo(pi0_algo)

    anaunit._mgr.AddAlgo(cosmicprimary_algo)
    anaunit._mgr.AddAlgo(cosmicsecondary_algo)
    anaunit._mgr.AddAlgo(cosmicorphanalgo)
    anaunit._mgr.AddAlgo(primary_algo)
    # anaunit._mgr.AddAlgo(pid_algo)
    anaunit._mgr.AddAlgo(ccsinglee_algo)
    # Is this where flashmatch_algo should go?
    # First we reconstruct nues and all that, then say if the electron's associated flash
    # is outside of the BGW we throw it out?
    # IE that's an analysis cut later by asking about flash_time?
    # Or maybe it should go right before ccsinglee_algo?
    # That way when it tags something as kcosmic, algosingleE auto-ignores it?
    # However, right now all solo shower particles are tagged as cosmic by the flash-matcher
    # Because it only works for tracks! For now, flashmatch_algo has to live after
    # and it has to be an analysis cut. This will be changed ASAP.
    anaunit._mgr.AddAlgo(flashmatch_algo)

    # Testing adding this... it looks for flashes shared b/t the neutrino and others
    # and potentially adds the "others" as children of the neutrino, or tags
    # the neutrino as a pi0 MID
    #anaunit._mgr.AddAlgo(ertool.ERAlgoNueSharedFlashMerger())
    anaunit._mgr._profile_mode = True

    anaunit.SetMinEDep(Ecut)
    anaunit._mgr._mc_for_ana = True

    return anaunit