Esempio n. 1
0
def jobtrackrecover():
    """ Job to recover ntracks and fill some histograms
    """

    # confifure aplication
    alex = Alex('alex')
    alex.nevts = 400

    root = ROOTSvc(name='root', fname='atrackrecover.root')
    alex.addsvc(root)

    # configure flow
    RR = lambda fname: TreeReader(fname, tname='trackgen')
    reader = Reader(name='reader', freader=RR)
    #read.fnames = ['trackgen1.root','trackgen2.root','trackgen3.root']
    reader.fnames = ['atrackgen.root']
    alex.addalg(reader)

    recover = TrackRecover('recover')
    alex.addalg(recover)

    histos = TrackHistos('histos')
    histos.imports.append('root')
    histos.path = 'recover'
    alex.addalg(histos)

    root.h2d('hxz', 100, 0., 40., 100, -30., 30.)
    root.h2d('hyz', 100, 0., 40., 100, -30., 30.)
    root.h2d('huxz', 100, 0., 40., 100, -1.1, 1.1)
    root.h2d('huyz', 100, 0., 40., 100, -1.1, 1.1)
    root.h2d('hez', 100, 0., 40., 100, 0., 3.)

    # run!
    alex.run()
    return
Esempio n. 2
0
def jobtrackrecover():
    """ Job to recover ntracks and fill some histograms
    """    
    
    # confifure aplication 
    alex = Alex('alex')
    alex.nevts = 400
    
    root = ROOTSvc(name='root',fname='atrackrecover.root')
    alex.addsvc(root)

    # configure flow
    RR = lambda fname : TreeReader(fname,tname='trackgen')
    reader = Reader(name='reader',freader=RR)
    #read.fnames = ['trackgen1.root','trackgen2.root','trackgen3.root']
    reader.fnames = ['atrackgen.root']
    alex.addalg(reader)

    recover = TrackRecover('recover')
    alex.addalg(recover)
        
    histos = TrackHistos('histos')
    histos.imports.append('root')
    histos.path = 'recover'
    alex.addalg(histos)

    root.h2d('hxz',100,0.,40.,100,-30.,30.)
    root.h2d('hyz',100,0.,40.,100,-30.,30.)
    root.h2d('huxz',100,0.,40.,100,-1.1,1.1)
    root.h2d('huyz',100,0.,40.,100,-1.1,1.1)
    root.h2d('hez',100,0.,40.,100,0.,3.)

    # run!
    alex.run()
    return
Esempio n. 3
0
def jobtrackgen():
    """ Job to generate ntracks and store them into a ntuple
    """

    # confifure aplication
    alex = Alex('alex')
    alex.nevts = 100

    root = ROOTSvc('root', fname='atrackgen.root')
    alex.addsvc(root)

    # configure flow
    gen = TrackGen('trackgen')
    gen.imports.append('root')
    alex.addalg(gen)

    histos = TrackHistos('histos')
    histos.imports.append('root')
    histos.path = 'trackgen'
    alex.addalg(histos)

    root.h2d('hxz', 100, 0., 40., 100, -30., 30.)
    root.h2d('hyz', 100, 0., 40., 100, -30., 30.)
    root.h2d('huxz', 100, 0., 40., 100, -1.2, 1.2)
    root.h2d('huyz', 100, 0., 40., 100, -1.2, 1.2)
    root.h2d('hez', 100, 0., 40., 100, 0., 2.6)

    # run!
    alex.run()
    return
Esempio n. 4
0
def jobtrackgen():
    """ Job to generate ntracks and store them into a ntuple
    """
    
    # confifure aplication 
    alex = Alex('alex')
    alex.nevts = 100
    
    root = ROOTSvc('root',fname='atrackgen.root')
    alex.addsvc(root)
    
    # configure flow
    gen = TrackGen('trackgen')
    gen.imports.append('root')
    alex.addalg(gen)
    
    histos = TrackHistos('histos')
    histos.imports.append('root')
    histos.path = 'trackgen'
    alex.addalg(histos)

    root.h2d('hxz',100,0.,40.,100,-30.,30.)
    root.h2d('hyz',100,0.,40.,100,-30.,30.)
    root.h2d('huxz',100,0.,40.,100,-1.2,1.2)
    root.h2d('huyz',100,0.,40.,100,-1.2,1.2)
    root.h2d('hez',100,0.,40.,100,0.,2.6)

    # run!
    alex.run()
    return
Esempio n. 5
0
def dotracks():
    """ Alex program to generate a single electron or doble beta event with toy-MC.
    and fit in forward and reverse mode. Histograms are produced.
    """

    # create aplication
    alex = Alex()
    alex.msg.level = Message.Info
    alex.nevts = 1000
    root = ROOTSvc('root','akfbeta.root')
    alex.addsvc(root)

    # simulate states
    #--------------------------
    #agenstates = GenerateDoubleBeta('agenstates') # uncoment to generate doble-beta
    agenstates = GenerateBeta('agenstates')
    agenstates.E0 = 2.5
    alex.addalg(agenstates)

    # histogram simulated states
    hisgenstates = HistosGenerateStates('hisgenstates')  
    hisgenstates.imports.append('root')
    alex.addalg(hisgenstates)

    # generate hits
    agendigits = CreateDigits('agendigits')
    agendigits.dz = 0.5
    alex.addalg(agendigits)  

    # create nodes
    agennodes = CreateNodes('agennodes')
    alex.addalg(agennodes)

    # uncoment to generetate doble-beta nodes in one track
    #betanodes = DoubleBetaNodes('betanodes')
    #alex.addalg(betanodes)

    # fit
    #-----------------

    # fit in the forward direction
    akf = FitNodes('akf')
    akf.path = 'rec/nodes'
    akf.opath = 'rec/kfs'
    alex.addalg(akf)

    # histogram the forward fit
    hisakf = HistosKFFit('hisakf')
    hisakf.imports.append('root')
    hisakf.prefix='kf_'
    hisakf.path='rec/kfs'
    alex.addalg(hisakf)

    # histogram the chi2-scan of the forward fit
    hischiscan = HistosKFChiScan('hischiscan')
    hischiscan.imports.append('root')
    hischiscan.path = 'rec/kfs'
    alex.addalg(hischiscan)

    # reverse the nodes to do a reverse fit
    arevnodes = ReverseNodes('arevnodes')
    arevnodes.path = 'rec/nodes'
    arevnodes.opath = 'rec/nodes/rev'
    alex.addalg(arevnodes)

    # do reverse fit
    akfrev = FitNodes('akfrev')
    akfrev.path = 'rec/nodes/rev'
    akfrev.opath = 'rec/kfs/rev'
    alex.addalg(akfrev)

    # histogram the reverse fit
    hisakfrev = HistosKFFit('hisakfrev')
    hisakfrev.imports.append('root')
    hisakfrev.prefix='kfrev_'
    hisakfrev.path='rec/kfs/rev'
    alex.addalg(hisakfrev)

    # histogram the chi2-scan of the reverse fit
    hischiscanrev = HistosKFChiScan('hischiscanrev')
    hischiscanrev.imports.append('root')
    hischiscanrev.path='rec/kfs/rev'
    hischiscanrev.prefix='chiscanrev_trk'
    alex.addalg(hischiscanrev)

    # Compare forward/reverse fit
    #-----------------------------

    # do the analysis of the forward/reverse fit
    anarev = HistosAnaReverse('anrev')
    anarev.imports.append('root')
    alex.addalg(anarev)

    alex.run()    
Esempio n. 6
0
def doscan():
    """ Alex program to generate doble beta events and do a scan along the track
    """

    # create application
    alex = Alex()
    alex.nevts = 2000
    root = ROOTSvc('root','akfbeta.root')
    alex.addsvc(root)

    # simulation
    #----------------

    # generate double beta
    agenstates = GenerateDoubleBeta('agenstates')
    #agenstates = GenerateBeta('agenstates')
    alex.addalg(agenstates)

    # histogram simulated states
    hisgenstates = HistosGenerateStates('hisgenstates')  
    hisgenstates.imports.append('root')
    alex.addalg(hisgenstates)

    # genrate digits
    agendigits = CreateDigits('agendigits')
    agendigits.dz = 0.5
    alex.addalg(agendigits)  

    # provide a track with the two electrons
    betanodes = DoubleBetaNodes('betanodes')
    alex.addalg(betanodes)

    # fitting
    #------------

    # do forward fit
    akf = FitNodes('kfbetanodes')
    akf.path = 'rec/nodes/bb'
    akf.opath = 'rec/kfs/bb'
    alex.addalg(akf)

    # histo forward fit
    hisakf = HistosKFFit('hisakf')
    hisakf.imports.append('root')
    hisakf.prefix='kf_'
    hisakf.path='rec/kfs/bb'
    alex.addalg(hisakf)

    # histo chi2-scan of the forward fit
    hischiscan = HistosKFChiScan('hischiscan')
    hischiscan.imports.append('root')
    hischiscan.path = 'rec/kfs/bb'
    alex.addalg(hischiscan)

    # reverse the nodes to do the reverse fit
    arevnodes = ReverseNodes('arevnodes')
    arevnodes.path = 'rec/nodes/bb'
    arevnodes.opath = 'rec/nodes/bb/rev'
    alex.addalg(arevnodes)

    # do the reverse fit
    akfrev = FitNodes('akfrev')
    akfrev.path = 'rec/nodes/bb/rev'
    akfrev.opath = 'rec/kfs/bb/rev'
    alex.addalg(akfrev)

    # histotgram the reverse fit
    hisakfrev = HistosKFFit('hisakfrev')
    hisakfrev.imports.append('root')
    hisakfrev.prefix='kfrev_'
    hisakfrev.path='rec/kfs/bb/rev'
    alex.addalg(hisakfrev)

    # histogram the chi2-scan of the reverse fit
    hischiscanrev = HistosKFChiScan('hischiscanrev')
    hischiscanrev.imports.append('root')
    hischiscanrev.path='rec/kfs/bb/rev'
    hischiscanrev.prefix='chiscanrev_trk'
    alex.addalg(hischiscanrev)

    # scan along the track
    #----------------------
   
    # do the analysis of the forward/reverse fit
    anarev = HistosAnaReverse('anrev')
    anarev.imports.append('root')
    anarev.pathnor = 'rec/kfs/bb'
    anarev.pathrev = 'rec/kfs/bb/rev'
    alex.addalg(anarev)

    akf = FitScanNodes('ascan')
    akf.path = 'rec/nodes/bb'
    akf.opath = 'rec/kfs/bb/scan'
    akf.iscan = 4
    alex.addalg(akf)

    hakf = HistosScanNodes('hscan')
    hakf.imports.append('root')
    alex.addalg(hakf)

    # some event diplays
    #---------------

    #evtakf = EventDisplayScan('evtakf')
    #evtakf.imports.append('root')
    #alex.addalg(evtakf)

    #evtdisplay = EventDisplay('evtdisplay')
    #evtdisplay.imports.append('root')
    #alex.addalg(evtdisplay)

    alex.run()
Esempio n. 7
0
def ck_gen():

    alex = Alex()
    alex.nevts = 1000
    root = ROOTSvc('root','akfnext.root')
    alex.addsvc(root)

    #radlen = 1500 # if radlen>0 use simple generator and filter
    emin = 0.5 # minimum energy to stop generation

    agenstates = GenerateStates('agenstates')
    agenstates.uz = 1.
    agenstates.emin = emin
    agenstates.deltae = 0.01
    #agenstates.radlen = radlen
    alex.addalg(agenstates)

    hisgenstates = HistosGenerateStates('hisgenstates')  
    hisgenstates.imports.append('root')
    alex.addalg(hisgenstates)

    agendigits = GenerateDigits('agendigits')
    agendigits.dz = 0.5
    #agendigits.p0 = 0.25
    #agendigits.nave = 10
    alex.addalg(agendigits)  

    agennodes = GenerateNodes('agennodes')
    alex.addalg(agennodes)

    agensegments = GenerateSegments('agensegments')
    agensegments.unique = True
    agensegments.minnodes = 4
    alex.addalg(agensegments)

    #hisgennodes = HistosGenerateNodes('hisgennodes')
    #hisgennodes.imports.append('root')
    #alex.addalg(hisgennodes)

    akf = KFFit2('akf')
    #akf.radlen = radlen
    #akf.onlyfirst = True
    alex.addalg(akf)

    #hisakf = HistosKFFit('hisakf')
    #hisakf.imports.append('root')
    #hisakf.forward = True
    #hisakf.backward = True
    #hisakf.emin = .5
    #alex.addalg(hisakf)

    hisakf2 = AnaKFFit2('hisakf2')
    hisakf2.imports.append('root')
    alex.addalg(hisakf2)

    #anakffit = AnaKFFit('anakffit')
    #anakffit.imports.append('root')
    #alex.addalg(anakffit)

    #evtdis = EventDisplay('evtdis')
    #evtdis.imports.append('root')
    #evtdis.nhits = 40
    #alex.addalg(evtdis) 

    alex.run()    
Esempio n. 8
0
def ck_gen():

    alex = Alex()
    alex.nevts = 1000
    root = ROOTSvc('root', 'akfnext.root')
    alex.addsvc(root)

    #radlen = 1500 # if radlen>0 use simple generator and filter
    emin = 0.5  # minimum energy to stop generation

    agenstates = GenerateStates('agenstates')
    agenstates.uz = 1.
    agenstates.emin = emin
    agenstates.deltae = 0.01
    #agenstates.radlen = radlen
    alex.addalg(agenstates)

    hisgenstates = HistosGenerateStates('hisgenstates')
    hisgenstates.imports.append('root')
    alex.addalg(hisgenstates)

    agendigits = GenerateDigits('agendigits')
    agendigits.dz = 0.5
    #agendigits.p0 = 0.25
    #agendigits.nave = 10
    alex.addalg(agendigits)

    agennodes = GenerateNodes('agennodes')
    alex.addalg(agennodes)

    agensegments = GenerateSegments('agensegments')
    agensegments.unique = True
    agensegments.minnodes = 4
    alex.addalg(agensegments)

    #hisgennodes = HistosGenerateNodes('hisgennodes')
    #hisgennodes.imports.append('root')
    #alex.addalg(hisgennodes)

    akf = KFFit2('akf')
    #akf.radlen = radlen
    #akf.onlyfirst = True
    alex.addalg(akf)

    #hisakf = HistosKFFit('hisakf')
    #hisakf.imports.append('root')
    #hisakf.forward = True
    #hisakf.backward = True
    #hisakf.emin = .5
    #alex.addalg(hisakf)

    hisakf2 = AnaKFFit2('hisakf2')
    hisakf2.imports.append('root')
    alex.addalg(hisakf2)

    #anakffit = AnaKFFit('anakffit')
    #anakffit.imports.append('root')
    #alex.addalg(anakffit)

    #evtdis = EventDisplay('evtdis')
    #evtdis.imports.append('root')
    #evtdis.nhits = 40
    #alex.addalg(evtdis)

    alex.run()
Esempio n. 9
0
alex.nevts = 100 # set number of events to run

root = ROOTSvc('root',fname='alexroot.root') # create root service
alex.addsvc(root) # add root service to the application

# configure flow
#------------------

eff = EffFilter('eff') # create efficiency filter algorithm
eff.eff = 0.6 # set parameter (eff) of the efficiency algorithm to a value

histo = HistoFill('histo') # create HistoFill algorithm
histo.path='eff' 
# takes value from the evt store in this path
# it is the value of the efficiency EffFilter algorithm

dump = Dump('dump') # create Dump algorithms
dump.paths += ['eff']

filter = Filter('filter') # create a Filter algorithm
filter.addalg(eff) # add eff algorithm to filter
filter.addalg(histo) # add histo algorithm to filter
filter.addalg(dump) # add dump to filter
alex.addalg(filter) # add filter to alex to run it!

    
# run
#----------
alex.run() # run!!
    
Esempio n. 10
0
from alex.alex import Alex

from alex.messenger import Message, Messenger
from alex.reader import Reader, ConsTreeReader
from alex.algorithms import Dump

# ------- Construct Alex

alex = Alex()

# create messenger service, log output in file 'alex.log', level INFO
msg = Messenger(name="msg", fname="alex_rootread.log", level=Message.Info)
alex.addsvc(msg)

alex.nevts = 10
alex.evtfreq = 2

# ----- Flow of Alex

RR = ConsTreeReader("tgauss")  # filereader of a TTree named 'tgaus'
reader = Reader(name="reader", freader=RR)  # reader of files
reader.fnames = ["alex_rootwrite.root"]
alex.addalg(reader)

dump = Dump("dump")
dump.paths = ["reader"]
alex.addalg(dump)

# --- Run
alex.run()