Пример #1
0
from Gaudi.Configuration import *
from Configurables import LHCbApp, LHCb__ParticlePropertySvc

app = LHCbApp()
# Sim08a (MC2012)
#app.DDDBtag = 'Sim08-20130503-1'
#app.CondDBtag = 'Sim08-20130503-vc-md100'
# 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)
Пример #2
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)
Пример #3
0
    verbose = options.verbose
    nevents = options.nevents
    gecLoc = options.branch + '/GlobalEventCounters'
    gecLoc.replace('//', '/')
    # Configuration

    from Configurables import LHCbApp
    from Configurables import MessageSvc
 
    MessageSvc().Format = "% F%60W%S%7W%R%T %0W%M"
    
    from Gaudi.Configuration import EventSelector
    EventSelector().PrintFreq=100

    lhcbApp = LHCbApp()
    lhcbApp.DDDBtag = 'default'
    lhcbApp.CondDBtag = 'default'

    # GaudiPython

    from GaudiPython.Bindings import AppMgr
    import GaudiPython
    appMgr = AppMgr(outputlevel=3)
    appMgr.config( files = ['$GAUDIPOOLDBROOT/options/GaudiPoolDbRoot.opts'])
    appMgr.ExtSvc += ['DataOnDemandSvc']
    appMgr.initialize()

    evtSvc = appMgr.evtSvc()
    evtSel = appMgr.evtSel()
    tsvc= appMgr.toolsvc()
Пример #4
0
from Gaudi.Configuration import *
import os

#Use Oliver's XML DDDB describing the FT detector
#DDDBConf().DbRoot = "/afs/cern.ch/user/o/ogruenbe/public/FT_upgrade/myDDDB-LHCb-Feb2012/lhcb.xml"
#-- the above is a running target, therefore use the following snaphot:
DDDBConf().DbRoot = "/afs/cern.ch/user/p/phopchev/public/FT/DDDBSlice_FT_v3/lhcb.xml"

CondDB().Tags['DDDB'] = 'HEAD'


lhcbApp = LHCbApp()
lhcbApp.Simulation = True

'''
lhcbApp.DataType = '2011'
lhcbApp.DDDBtag = "head-20110914"
lhcbApp.CondDBtag = "sim-20111020-vc-md100"
#dataDir = os.environ['PANORAMIXDATA']
#EventSelector().Input = ["DATAFILE='PFN:"+dataDir+"/2011_Bs2DsmuX.dst' TYP='POOL_ROOTTREE'"]
'''

lhcbApp.DataType = "2011"
lhcbApp.DDDBtag = "MC11-20111102"
lhcbApp.CondDBtag = "sim-20111111-vc-md100"
EventSelector().Input = ["DATAFILE='/castor/cern.ch/user/o/ogruenbe/Bs_mumu_v3.sim' TYP='POOL_ROOTTREE'"]

### Set fake event time to avoid useless ERROR messages from the EventClockSvc (no DAQ/RawEvent as it is MC)
from Configurables import EventClockSvc
EventClockSvc().EventTimeDecoder = 'FakeEventTime'
Пример #5
0
# Get list conditions
try:
    from CondMap import ConditionMap
except ImportError:
    from All import ConditionMap
list_conditions = sum(ConditionMap.values(),[])

# Configure Brunel
from Configurables import LHCbApp
app = LHCbApp()
app.DataType = '2015'
app.Simulation = False
app.EvtMax = 1

import HLT2Params
app.DDDBtag = HLT2Params.DDDBTag
app.CondDBtag = HLT2Params.CondDBTag


from Configurables import EventClockSvc, FakeEventTime, EventDataSvc
ecs = EventClockSvc()
ecs.InitialTime = arguments.start[0]
ecs.addTool(FakeEventTime, "EventTimeDecoder")
ecs.EventTimeDecoder.TimeStep = 10
ecs.EventTimeDecoder.StartTime = arguments.start[0]

from Configurables import DumpConditions
DumpConditions().RunStartTime = arguments.start[0]
DumpConditions().RunNumber = arguments.run[0]
DumpConditions().OutFile= arguments.output[0]
DumpConditions().Conditions = list_conditions