def configure( gaudi = None ) : """ Configuration of the job """ if not gaudi : from GaudiPython.Bindings import AppMgr gaudi = AppMgr() gaudi.JobOptionsType = 'NONE' gaudi.EvtSel = 'NONE' gaudi.HistogramPersistency = 'ROOT' gaudi.ExtSvc += ["NTupleSvc" ] ntSvc = gaudi.service('NTupleSvc') ntSvc.Output = [ "MYLUN DATAFILE='TupleEx.root' OPT='NEW' TYP='ROOT'" ] gaudi.config() gaudi.DLLs = [ 'GaudiAlg', 'RootHistCnv', ] alg = TupleEx( ## configure the property NTupleLUN = 'MYLUN' ) gaudi.setAlgorithms( [alg] ) return SUCCESS
def configure( gaudi = None ) : """ Configuration of the job """ if not gaudi : from GaudiPython.Bindings import AppMgr gaudi = AppMgr() gaudi.JobOptionsType = 'NONE' gaudi.EvtSel = 'NONE' gaudi.HistogramPersistency = 'ROOT' gaudi.config() gaudi.DLLs = [ 'GaudiAlg', 'RootHistCnv', ] alg = HistoEx('HistoEx') gaudi.setAlgorithms( [alg] ) alg.HistoPrint = True hsvc = gaudi.service('HistogramPersistencySvc') hsvc.OutputFile = "histo1.root" # This does not harm and tests bug #50389 getMyalgBack = gaudi.algorithm ( 'HistoEx' ) return SUCCESS
def _getAppMgr ( **kwargs ) : """ Helper private auxiliary function to get Application Manager """ gaudi = kwargs.get ( 'gaudi' , None ) if not gaudi : gaudi = AppMgr() if not gaudi : raise RuntimeError, 'Unable to get valid ApplicationMgr' state = gaudi._isvc.FSMState() if state < cpp.Gaudi.StateMachine.CONFIGURED : gaudi.config () state = gaudi._isvc.FSMState() if state < cpp.Gaudi.StateMachine.INITIALIZED : gaudi.initialize () return gaudi ## RETURN
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()
# get rid of some spam EventSelector().PrintFreq = 100 from MicroDSTExample.Selections import SeqBs2Jpsi2MuMuPhi2KK selSequence = SeqBs2Jpsi2MuMuPhi2KK.SeqBs2Jpsi2MuMuPhi2KK mainLocation = selSequence.outputLocation() # set up some useful paths of locations on the MicroDST flavTagPath = locationRoot + "/" + mainLocation + "/FlavourTags" lhcbApp = LHCbApp() lhcbApp.DDDBtag = 'default' lhcbApp.CondDBtag = 'default' appMgr = AppMgr(outputlevel=4) appMgr.config(files=['$GAUDIPOOLDBROOT/options/GaudiPoolDbRoot.opts']) appMgr.initialize() appMgr.ExtSvc += ['LHCb::ParticlePropertySvc'] appMgr.HistogramPersistency = "ROOT" evtSvc = appMgr.evtSvc() toolSvc = appMgr.toolsvc() evtSel = appMgr.evtSel() nextEvent = Functors.NextEvent(appMgr) pp = Functors.PartPropSvc(appMgr) ppSvc = pp particleNameFunc = Functors.ParticleName(ppSvc) # open a DST or MicroDST evtSel.open(microDSTFile)
EventSelector().PrintFreq = 100 # set up some useful paths of locations on the MicroDST hltPath = locationRoot + "/Hlt/DecReports" l0Path = locationRoot + "/Trig/L0/L0DUReport" selectionPath = locationRoot + '/Phys/' + selection particlePath = selectionPath + '/Particles' lhcbApp = LHCbApp() lhcbApp.DDDBtag = 'default' lhcbApp.CondDBtag = 'default' appMgr = AppMgr(outputlevel=4) appMgr.config(files=[ '$STDOPTS/LHCbApplication.opts', '$GAUDIPOOLDBROOT/options/GaudiPoolDbRoot.opts', '$DDDBROOT/options/DC06.opts' ]) appMgr.initialize() appMgr.ExtSvc += ['LHCb::ParticlePropertySvc'] appMgr.HistogramPersistency = "ROOT" evtSvc = appMgr.evtSvc() evtSel = appMgr.evtSel() nextEvent = Helpers.NextEvent(appMgr) # open a DST or MicroDST evtSel.open(microDSTFile) nEvents = 0 nMCEvents = 0
## get the application manager (create if needed) gaudi = AppMgr() import atexit atexit.register ( gaudi.exit ) gaudi.EvtSel = 'NONE' ## no external event input #gaudi.HistogramPersistency = 'HBOOK' ## define the persistency type for N-tuples gaudi.HistogramPersistency = 'ROOT' ## define the persistency type for N-tuples ## configure & initialize gaudi.config() gaudi.initialize() ## get some random numbers Rndm = cpp.Rndm IRndmGenSvc = cpp.IRndmGenSvc rndmSvc = gaudi.service('RndmGenSvc',IRndmGenSvc) if not rndmSvc : gaudi.createSvc('RndmGenSvc') rndmSvc = gaudi.service('RndmGenSvc',IRndmGenSvc) gauss = Rndm.Numbers ( cpp.SmartIF("IRndmGenSvc")(rndmSvc) , Rndm.Gauss ( 0.0 , 1.0 ) ) ## get the first N-tuple tup1 = TupleUtils.nTuple( "path" , ## the path "It is a title for my n-tuple" , ## the title LUN = 'MYLUN1' ) ## logical unit