コード例 #1
0
def run(input_files, output_file):

    ## Bit of extra configuration
    from GaudiConf import IOHelper
    IOHelper().inputFiles(input_files)
    HistogramPersistencySvc().OutputFile = output_file.replace('.root', '_histos.root')

    ## GaudiPython
    import GaudiPython
    import cppyy
    cppyy.load_reflection_info('libLinkerEvent')
    cppyy.load_reflection_info('libLinkerInstancesDict')

    from GaudiPython.Bindings import AppMgr
    appMgr = AppMgr(outputlevel = 3)
    appMgr.config()

    appMgr.HistogramPersistency = 'ROOT'
    ntSvc = GaudiPython.iService('NTupleSvc')
    ntSvc.Output = ["MATCHZERRLUN DATAFILE='{0}' OPT='NEW'".format(output_file)]

    from Hlt1Muons.MatchAlgo import MatchResidualAlgo
    match_algo = MatchResidualAlgo("MatchResidualAlgo", MatchVeloMuon = mvm.getFullName())
    match_algo.NTupleLUN = 'MATCHZERRLUN'
    appMgr.addAlgorithm(match_algo)

    from Hlt1Muons.MatchAlgo import MatchChi2Algo
    chi2_algo = MatchChi2Algo("MatchChi2Algo", MatchVeloMuon = mvm_chi2.getFullName())
    chi2_algo.NTupleLUN = 'MATCHZERRLUN'
    appMgr.addAlgorithm(chi2_algo)

    if mvm_old:
        chi2_algo_old = MatchChi2Algo("MatchChi2AlgoOld", MatchVeloMuon = mvm_old.getFullName())
        chi2_algo_old.NTupleLUN = 'MATCHZERRLUN'
        appMgr.addAlgorithm(chi2_algo_old)

    appMgr.initialize()
    appMgr.run(options.nevents)
    appMgr.stop()
    appMgr.finalize()
    appMgr.exit()
コード例 #2
0
    def run(self):
        if lambdas == 'None':
            kali = firstPass(
                ##-- cuts and filters
                PtGamma=250 * MeV,  ## selection cuts
                ## event multiplicity filter
                Filter=
                "(650. > CONTAINS('Raw/Spd/Digits')) & ( CONTAINS('Rec/Vertex/Primary') > 0.) & ( CONTAINS('Rec/Vertex/Primary') < 5.)",

                ##-- output
                NTupleProduce=True,  # produce NTuples
                NTuple=self.__dsname + '.root',  # NTuple name
                Histograms=False,  # do not produce Histograms
                FemtoDST=self.__dsname + '.fmDST',  # output fmDST name

                ##-- general (configuring DaVinci)
                DataType='2015',  # data type
                EvtMax=self.__nevt,  # number of events to run
                OutputLevel=ERROR)
        else:
            kali = secondPass(
                ##
                DestroyTES=False,
                ## ``Physics''
                PtGamma=250 * MeV,
                Pi0Cut="PT > 550 * MeV",
                ## IO
                NTupleProduce=True,  # produce NTuples
                NTuple=self.__dsname + '.root',  # NTuple name
                Histograms=False,  # do not produce Histograms
                FemtoDST="",
                ## Calibration
                KaliDB={
                    'name': lambdas,
                    'ecal': 'ecal'
                },
                ## general
                DataType='2015',
                EvtMax=self.__nevt,
                OutputLevel=ERROR)

        from Configurables import CondDB
        CondDB().Simulation = False
        CondDB().UseDBSnapshot = True
        CondDB().DBSnapshotDirectory = "/group/online/hlt/conditions"
        CondDB().EnableRunChangeHandler = True
        CondDB().Tags["ONLINE"] = 'fake'
        CondDB().setProp("IgnoreHeartBeat", True)
        CondDB().Online = True

        try:
            import AllHlt1
        except ImportError:
            rd = '/group/online/hlt/conditions/RunChangeHandler'
            sys.path.append(rd)
            import AllHlt1

        import AllHlt1
        CondDB().RunChangeHandlerConditions = AllHlt1.ConditionMap

        Online = importOnline()

        ## ======== input data type - 'SDST' ============
        from Configurables import DaVinci
        DaVinci().InputType = 'DST'  # use SDSTs as an input
        DaVinci().CondDBtag = Online.CondDBTag
        DaVinci().DDDBtag = Online.DDDBTag

        from GaudiConf import IOHelper
        IOHelper('ROOT').inputFiles(self.__inputs)

        from GaudiPython.Bindings import AppMgr
        gaudi = AppMgr()
        gaudi.initialize()
        gaudi.run(self.__nevt)
        gaudi.stop()
        gaudi.finalize()
        gaudi.exit()
コード例 #3
0
ファイル: DBXfer.py プロジェクト: marromlam/lhcb-software
  sys.exit(44)
print "============= Gaudi.ReturnCode :",Gaudi.ReturnCode
if Gaudi.ReturnCode != 0:
  sys.exit(44)
print "===================== Stopping the XML conversion ========================"
stat = Gaudi.stop()
print "============= Status :",stat
if stat.isFailure():
  sys.exit(44)
print "===================== Finalizing the XML conversion ========================"
stat = Gaudi.finalize()
print "============= Status :",stat
if stat.isFailure():
  sys.exit(44)
print "===================== Exiting the XML conversion ========================"
stat = Gaudi.exit()
print "============= Status :",stat
if stat.isFailure():
  sys.exit(44)
print "===================== Updating the Database ========================"
import CondDBUI
import CondDBUI.Admin
DBString = "CondDBOnline(owner)/ONLINE" # use the central Oracle Database...
####DBString = "sqlite_file:./CONDDB.db/ONLINE"
db = CondDBUI.CondDB(DBString, create_new_db = False, readOnly=False)
import time
if RunEnd == None:
  etime =  HLT2Params.RunStartTime+86400*365*100
else:
  etime = RunEnd/1000000000
print "Operating on Database "+DBString
コード例 #4
0
def myActionAtExit():
    from GaudiPython.Bindings import AppMgr
    gaudi = AppMgr()
    gaudi.exit()
コード例 #5
0
ファイル: gaudiiter.py プロジェクト: marromlam/lhcb-software
    if not opts.do_not_rewind:
        mainSeq.Enable = False
        evtSel.rewind()
        mainSeq.Enable = True

    # steer the monitor sequence depending on the iteration
    appMgr.algorithm('AlignMonitorSeq').Enable = (i == 0)
    appMgr.algorithm('Moni').Enable = (i == 0)
    if opts.numiter > 1:
        appMgr.algorithm('AlignPostMonitorSeq').Enable = (i == opts.numiter -
                                                          1)

    # event loop
    appMgr.run(opts.numevents)

    # fire incident for update
    from GaudiPython import gbl
    from Configurables import Escher
    incSvc = appMgr.service('IncidentSvc', 'IIncidentSvc')
    updateConstants = gbl.Incident('Alignment', 'UpdateConstants')
    if Escher().getProp("Incident") == "GlobalMPedeFit":
        updateConstants = gbl.Incident('Alignment', 'GlobalMPedeFit')
        printUniformity = gbl.Incident('Alignment', 'PrintUniformTD')
        updateTrackSelector = gbl.Incident('Alignment', 'ResetUniformity')
        incSvc.fireIncident(printUniformity)
        incSvc.fireIncident(updateTrackSelector)
    incSvc.fireIncident(updateConstants)

#exit the appmgr for finalize
appMgr.exit()
コード例 #6
0
    def run(self):
        from Configurables import Brunel
    
        ## Brunel parameters
        Brunel().Detectors   = ['Spd', 'Prs', 'Ecal', 'Hcal' ]
        Brunel().DataType    = "2015"
        Brunel().InputType   = "MDF"
        Brunel().OutputType  = "DST"
        Brunel().EvtMax      = self.__nevt
        Brunel().WriteFSR    = False
        Brunel().Histograms  = "Online"
        Brunel().OnlineMode  = True
        Brunel().PrintFreq   = 1000
        Brunel().DatasetName = self.__dsname

        ## use the conditions database
        ## configuration for online
        from Configurables import CondDB
        CondDB().Simulation = False
        CondDB().UseDBSnapshot = True
        CondDB().DBSnapshotDirectory = "/group/online/hlt/conditions"
        CondDB().EnableRunChangeHandler = True
        CondDB().Tags["ONLINE"] = 'fake'
        CondDB().setProp("IgnoreHeartBeat", True)
        CondDB().Online = True

        try:
            import AllHlt1
        except ImportError:
            rd = '/group/online/hlt/conditions/RunChangeHandler'
            sys.path.append(rd)
            import AllHlt1

        import AllHlt1
        CondDB().RunChangeHandlerConditions = AllHlt1.ConditionMap

        Online = importOnline()
        Brunel().CondDBtag = Online.CondDBTag
        Brunel().DDDBtag   = Online.DDDBTag

        """
        Messages in the online get redirected.
        Setup here the FMC message service
    
        @author M.Frank
        """
        app=Gaudi.ApplicationMgr()
        #Configs.AuditorSvc().Auditors = []
        app.MessageSvcType = 'LHCb::FmcMessageSvc'
        if Gaudi.allConfigurables.has_key('MessageSvc'):
            del Gaudi.allConfigurables['MessageSvc']
        msg = Configs.LHCb__FmcMessageSvc('MessageSvc')
        msg.fifoPath      = os.environ['LOGFIFO']
        msg.LoggerOnly    = True
        msg.doPrintAlways = False
        msg.OutputLevel   = MSG_INFO # Online.OutputLevel

        from GaudiConf import IOHelper
        IOHelper('MDF').inputFiles(self.__inputs)

        from GaudiPython.Bindings import AppMgr    
        gaudi = AppMgr()
        gaudi.initialize()
        gaudi.run(self.__nevt)
        gaudi.stop()
        gaudi.finalize()
        gaudi.exit()
コード例 #7
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)
コード例 #8
0
ファイル: KaliPi0.py プロジェクト: marromlam/lhcb-software
    ## === OR with test fmDSTs

    evtSel = gaudi.evtSel()

    ## run over events
    gaudi.run(5000)

    from KaliCalo.FitUtils import fitPi0, getPi0Params, s2b
    import GaudiPython.GaudiAlgs
    pi0 = gaudi.algorithm('KaliPi0')
    histos = pi0.Histos()
    if histos:
        keys = histos.keys()
        keys.sort()
        for h in keys:
            histo = histos[h]
            if hasattr(histo, 'dump'):
                print histo.dump(60, 25, True)
                st = fitPi0(histo)
                print 'Fit    : ', st
                print 'N(pi0) : ', getPi0Params(histo)[0]
                print 'Mass   : ', getPi0Params(histo)[1]
                print 'Sigma  : ', getPi0Params(histo)[2]
                print 'S/B    : ', s2b(histo.toROOT())

    gaudi.exit()

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