def start_app_mgr() :
    gaudi = AppMgr()

    global started
    if not started :
        gaudi.initialize()
        started = True

    ppsvc   = gaudi.ppSvc()
    toolsvc = gaudi.toolSvc()
    evtsvc = tes = TES = gaudi.evtSvc()
    return locals()
Exemple #2
0
def start_app_mgr():
    gaudi = AppMgr()

    global started
    if not started:
        gaudi.initialize()
        started = True

    ppsvc = gaudi.ppSvc()
    toolsvc = gaudi.toolSvc()
    evtsvc = tes = TES = gaudi.evtSvc()
    return locals()
Exemple #3
0
def initialise(dddbtag = '', datatype = '') :
    global pps
    if pps :
        return
    import PartProp.PartPropAlg
    import PartProp.Service
    from   GaudiPython.Bindings import AppMgr
    import sys
    from Configurables import LHCbApp

    if dddbtag :
        LHCbApp().DDDBtag = dddbtag
    elif datatype:
        from Configurables import CondDB
        CondDB().LatestGlobalTagByDataType = datatype
    gaudi = AppMgr()

    # Annoyingly have to initialise the AppMgr to initialise the ppSvc
    gaudi.initialize()

    pps   = gaudi.ppSvc()
Exemple #4
0
import PartProp.PartPropSvc
from GaudiPython.Bindings import AppMgr

gaudi = AppMgr()
# get the service from Gaudi:
ppSvc = gaudi.ppSvc()
# loop over all particle properties:
for pp in ppSvc:
    print pp.particle()
# print them as table:
print ppSvc.all()
# Sim05 (MC11a)
#app.DDDBtag = 'MC11-20111102'
#app.CondDBtag = 'sim-20111111-vc-md100'
# Sim08e (MC2012)
app.DDDBtag = 'dddb-20130929-1'
app.CondDBtag = 'sim-20130522-1-vc-md100'

ApplicationMgr().ExtSvc += [LHCb__ParticlePropertySvc()]

from GaudiPython.Bindings import AppMgr
import PartProp.Service

appMgr = AppMgr()
appMgr.initialize()

ppSvc = appMgr.ppSvc()
B_s0H = ppSvc.find("B_s0H")
B_s0L = ppSvc.find("B_s0L")

GH = 1./B_s0H.lifetime()/1000
GL = 1./B_s0L.lifetime()/1000

G  = (GL + GH)/2.
DG = (GL - GH)
y = DG/(2*G)

#MC2012 values
Azero_sq = 0.5213
Apara_sq = 0.2300
Aperp_sq = 0.2490
phi_s = 0.07
Exemple #6
0
def CreateLifetimeMapCode(config=None, bRetLists=False):
    global codePreamble, codeMakePair, codePostamble, outStream, analysisName, timestampFormat, dataType, dddbTag, bUseLatestCondDB
    if not config is None:
        dataType = config[0]  #year
        dddbTag = config[1]  #DDDB tag
    lbApp = LHCbApp()
    lbApp.DDDBtag = dddbTag
    DDDBConf(DataType=dataType)
    if bUseLatestCondDB:
        CondDB().UseLatestTags = [dataType]
    gaudi = AppMgr()
    gaudi.initialize()
    pps = gaudi.ppSvc()
    if len(pps.all()) == 0:
        eprint(
            "ERROR: No particles returned from Particle Property Service!\n",
            'err')
        return False
    pmap = {}
    pids = []
    for p in pps.all():
        #if p.name().startswith('anti-'):
        #    continue
        pid = p.pid().pid()
        if pid < 0 or pmap.has_key(pid):
            apid = ((pid < 0) and (-pid) or pid)
            if pmap.has_key(apid):
                nlft = "%.8E" % (p.lifetime() / SystemOfUnits.s)
                olft = "%.8E" % (pmap[apid])
                if nlft.startswith(olft):
                    continue
                else:
                    eprint(
                        "(anti-)/Particle lifetimes differ [%d] (%s vs. %s). Use asymmetric algorithm with PID:Lifetime map."
                        % (pid, nlft, olft), 'warn')
                    if pid > 0:
                        pmap[-pid] = pmap[pid]
                        del pmap[pid]
            else:
                pid = apid
        #if len(str(pid)) > 7: #????
        #    print ("Ignored " + str(p))
        #    continue
        if pid > 79 and pid < 101:
            eprint('Ignoring generator dependent PIDs in interval [80-100].')
            eprint(str(p))
            continue
        if len(str(pid)) > 9:  #ignore nuclei
            eprint("Ignoring nucleus " + str(p))
            continue
        lft = p.lifetime()
        if lft < 0.0:
            eprint("Negative lifetime! " + str(p), 'err')
            continue
        if pmap.has_key(pid):
            eprint("Duplicate particle in list with PID " + str(pid), 'warn')
            continue
        if lft < 1.0e-32:
            if not pid in pids:
                pids.append(pid)
            continue
        #express lifetime in seconds
        lft = lft / SystemOfUnits.s
        pmap[pid] = lft
    if not bRetLists:
        if not outStream is None:
            if os.path.isfile(outStream):
                eprint("File '%s' already exists." % (outStream))
                ans = raw_input('Do you really want to overwrite (yes/no)? ')
                if ans.lower() == 'no':
                    eprint('Aborting execution. Please, rename output file.',
                           'warn')
                    exit(9)
            fp = open(outStream, "w")
        else:
            fp = sys.stdout
        fp.write(codePreamble %
                 (dddbTag, dataType,
                  datetime.datetime.utcnow().strftime(timestampFormat)))
        fp.write("  ")
        sortedKeys = pmap.keys()
        sortedKeys.sort()
        k = 2
        for pdgid in sortedKeys:
            svdbl = "%.8E" % (pmap[pdgid])
            smant = svdbl[0:svdbl.rfind('E') - 1]
            sexp = svdbl[svdbl.rfind('E'):]
            smant = smant.rstrip('0')
            svdbl = (smant + sexp)
            spair = codeMakePair % (pdgid, svdbl)
            lts = len(spair)
            k += lts
            if k > 80:
                k = lts
                fp.write("\n  ")
            fp.write(spair)
        fp.write("\n  return true;\n}\n")
        fp.flush()
        if len(pids) > 0:
            pids.sort()
            fp.write(codePreamble2 % (len(pids), analysisName, len(pids)))
            k = 0
            jj = 0
            for jj in xrange(0, len(pids)):
                ii = pids[jj]
                #ignore partons and particle ids below 100
                if ii <= 100:
                    continue
                spid = "%u" % (ii)
                if jj < len(pids) - 1:
                    spid += ","
                k += len(spid)
                fp.write(spid)
                if k > 80:
                    fp.write("\n")
                    k = 0
            fp.write("};\n")
        if not outStream is None:
            fp.flush()
            fp.close()
    gaudi.finalize()
    gaudi.exit()
    del gaudi, lbApp
    return (pmap, pids)
Exemple #7
0
import PartProp.PartPropSvc
from GaudiPython.Bindings import AppMgr 
gaudi = AppMgr()
# get the service from Gaudi:
ppSvc = gaudi.ppSvc() 
# loop over all particle properties:
for pp in ppSvc :  print pp.particle()
# print them as table:
print ppSvc.all() 
#  @date 2010-10-22
# =============================================================================
"""

Trivial script to dump the table of Particle Properties 

Last modification $Date$
               by $Author$
"""
# =============================================================================
__author__  = "Vanya BELYAEV [email protected]"
__version__ = "version $Revision: 1.3 $" 
# =============================================================================
import PartProp.PartPropAlg
import PartProp.Service
from   GaudiPython.Bindings import AppMgr
# =============================================================================

gaudi = AppMgr()

gaudi.initialize()

pps   = gaudi.ppSvc()

print pps.all()


# =============================================================================
# The END 
# =============================================================================