def findAlg(alg_name, search_outputstream_otherwise=True): ''' Find the algorithm alg_name in the top sequence and return its index. if no algorithm of the given name is found the index just before the AhtenaOutputStream is returned. if all that fails None is returned. ''' if not isinstance(alg_name, (list, tuple)): raise Exception( 'logic error findAlg called with a non list argument %s / %s' % (alg_name, type(alg_name))) from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() count = 0 mon_man_index = None for child in topSequence.getChildren(): # if child.getName() in alg_name : if child.getName() in alg_name: # print ('DEBUG findAlg %s =?= %s ' %(child.getName(),alg_name)) mon_man_index = count if len(alg_name) == 1: break count += 1 if mon_man_index is None and search_outputstream_otherwise: count = 0 exclude_streams = ['StreamBS'] for child in topSequence.getChildren(): if child.getType() == 'AthenaOutputStream' and child.getName( ) not in exclude_streams: # print ('DEBUG found %s at postion %i/%i' % (child.getFullName(),count,len(topSequence.getChildren() ) )) mon_man_index = count break count += 1 return mon_man_index
def removePhysValExample(): print 'DEBUG no AntiKt4EMTopoJets in input file.' from InDetPhysValDecoration import findMonMan mon_index = findMonMan() if mon_index != None: import re pattern = re.compile('.*PhysValExample') from AthenaCommon.AlgSequence import AlgSequence, AthSequencer topSequence = AlgSequence() mon_manager = topSequence.getChildren()[mon_index] print 'DEBUG Found mon_manager %s with the following tools: %s ' % ( mon_manager.getName(), mon_manager.AthenaMonTools.toStringProperty()) for idx in range(0, len(mon_manager.AthenaMonTools)): tool_name = mon_manager.AthenaMonTools[idx].getName() # print 'DEBUG %s AthenaMonTools %s' % (mon_manager.getName(),tool_name) if pattern.match(tool_name) != None: print 'DEBUG removing %s from %s .' % (tool_name, mon_manager.getName()) del mon_manager.AthenaMonTools[idx] break else: for child in topSequence.getChildren(): print 'DEBUG top sequence has %s' % (child.getName())
def canAddDecorator(): ''' check whether the decorator can be added. A decorator can be added if a track particle converter alg is in the sequence or if ESDs or AODs are read. ''' from RecExConfig.RecFlags import rec if not rec.doInDet: return False if rec.readAOD: return True if rec.readESD: return True if rec.readTAG: return False if rec.readRDO: try: from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() import re pat = re.compile('.*(TrackParticleCnvAlg).*') for alg in topSequence.getChildren(): if pat.match(alg.getFullName()) is not None: return True except: pass return False
def addExtraMonitoring(): ''' IF monitoring is wished for GSF or DBM TrackParticles find the monitoring manager and add the corresponding monitoring tools. ''' # hack to add monitors for DBM and GSF # the job option fragment which adds the InDetPhysValMonitoringTool for the default tracks # will call this method, so can abuse this method to also add the monitoring tools for DBM and GSF tracks try: from InDetPhysValMonitoring.InDetPhysValJobProperties import InDetPhysValFlags # flags are at this stage already initialised, so do not need to InDetPhysValFlags.init() if InDetPhysValFlags.doValidateGSFTracks( ) or InDetPhysValFlags.doValidateDBMTracks( ) or InDetPhysValFlags.doValidateTightPrimaryTracks(): mon_index = findMonMan() if mon_index != None: from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() mon_manager = topSequence.getChildren()[mon_index] from InDetPhysValMonitoring.InDetPhysValMonitoringTool import InDetPhysValMonitoringTool except ImportError: import sys, traceback exc_type, exc_value, exc_traceback = sys.exc_info() print "*** print_tb:" traceback.print_tb(exc_traceback, limit=1, file=sys.stdout) print "*** print_exception:" traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stdout) print "*** print_exc:" traceback.print_exc() raise
def checkCosmicAlgPosition(beamAlg, cosmicAlg): topSeq = AlgSequence() if cosmicAlg in topSeq: cosmicInd = topSeq.getChildren().index(cosmicAlg) if beamAlg in topSeq: index = topSeq.getChildren().index(beamAlg) # make sure cosmicAlg is before index if cosmicInd > index: moveAlgInSequence(cosmicAlg, topSeq, index) cosmicInd = index #ensure that timinAlg is before cosmicAlg timingAlg=None if hasattr(topSeq,"SimTimerBegin"): timingAlg = topSeq.SimTimerBegin if timingAlg is not None and timingAlg in topSeq: index = topSeq.getChildren().index(timingAlg) if index > cosmicInd: moveAlgInSequence(timinAlg, topSeq, cosmicInd)
def checkRequiredAlgPosition(seq, momAlg, requiredAlg): topSeq = AlgSequence() if requiredAlg in topSeq: truthInd = topSeq.getChildren().index(requiredAlg) if momAlg in topSeq: index = topSeq.getChildren().index(momAlg) else: # then it is in seq, and seq must be in topSeq index = topSeq.getChildren().index(seq) # make sure requiredAlg is before index if truthInd > index: moveAlgInSequence(requiredAlg, topSeq, index) else: # will move requiredAlg in topSeq before seq and momAlg # where is momAlg ? seqInd = topSeq.getChildren().index(seq) if momAlg in topSeq: index = topSeq.getChildren().index(momAlg) else: index = seqInd delattr(seq, requiredAlg.getName()) topSeq.insert(index, requiredAlg)
def _domain_algs(self, name, registry, alg_names=None): """ returns the list of algorithms which are part of a given domain `name` """ from AthenaCommon.AlgSequence import AlgSequence job = AlgSequence() if alg_names is None: alg_names = [c.getName() for c in job.getChildren()] domain_idx,start_alg = self.domain_start(name,registry=registry) try: if start_alg is self.top_stack: start_idx = 0 ## elif start_alg is None: else: start_idx = alg_names.index(start_alg) + 1 except ValueError: raise ValueError('no algorithm [%s] in list of algorithms' % (start_alg,)) # get the start of the domain *after* the current one (to get the end # of the domain slice) next_domain_idx = domain_idx + 1 if next_domain_idx >= len(registry): # there is no next domain stop_idx = None stop_alg = None else: next_domain_name = registry[next_domain_idx] _,stop_alg = self.domain_start(next_domain_name[0], registry=registry[next_domain_idx:]) #print("----->",stop_alg,domain_idx,next_domain_idx) if stop_alg is None: # bottom of the stack: take rest of the slice stop_idx = None else: try: stop_idx = alg_names.index(stop_alg)+1 except ValueError: raise ValueError( 'no algorithm [%s] in list of algorithms' % stop_alg ) pass pass # we know the whole slice information return start_idx,stop_idx,registry[domain_idx+1:]
def domain_algs(self, name): """ returns the list of algorithms which are part of a given domain `name` """ if not self.has_domain(name): raise RuntimeError("no such domain [%s]" % name) #print(":"*40) #print("::: domain_algs(%s)..." % (name,)) from AthenaCommon.AlgSequence import AlgSequence job = AlgSequence() alg_names = [c.getName() for c in job.getChildren()] # the list of slices to pick-up from the alg_names slices = [] # sliding windows over the alg-names, collecting slices as we go start_idx = 0 stop_idx = None w_start = 0 w_stop = None w_alg_names = alg_names[:] w_registry = self._registry[:] itr = 0 while len(w_alg_names)>0 and w_start is not None: #print("== %s: itr [%i]==\nw_names: %s \nreg: %s" % ( # name, itr, w_alg_names, w_registry)) w_slice = slice(w_start, w_stop) w_alg_names = alg_names[w_slice][:] start_idx,stop_idx,w_registry = self._domain_algs( name, registry=w_registry, alg_names=w_alg_names) #print("slice: [%s:%s]" % (start_idx,stop_idx)) slices.extend(w_alg_names[slice(start_idx,stop_idx)]) w_start = stop_idx itr +=1 if not self.has_domain(name, registry=w_registry): # this means we exhausted all possible 'sparse blocks' break # we know the whole slice information # return a copy of the slice return slices[:]
def flag_domain(self, name): """function to declare that the upcoming algorithms which will be added to the job sequence will be part of the domain `name` ex: - alg1 - alg2 <-+- flag_domain('core') - alg3 | - alg4 | - alg5 <-+- flag_domain('id') """ self._dirty_db = True if self.verbose: print(":::flag_domain(%s)..." % (name,)) ## if has_domain(name): ## raise RuntimeError( ## 'declaring nested domains or non-contiguous domains is not '+ ## 'supported (yet?)' ## ) # get the current alg name from AthenaCommon.AlgSequence import AlgSequence job = AlgSequence() alg_names = [c.getName() for c in job.getChildren()] n_algs = len(alg_names) if len(self._registry) > 0: last_entry = self._registry[-1] if n_algs == last_entry[2]: # no new alg. remove last entry. self._registry = self._registry[:-1] pass if alg_names: self._registry.append((name, alg_names[-1], n_algs)) else: self._registry.append((name, self.top_stack, n_algs)) if self.verbose: print(":::flag_domain(%s)... => registry: %r (#algs: %s)" % ( name, self._registry, len(alg_names))) return
##################################################### # # LVL1 simulation # ##################################################### from TrigConfigSvc.TrigConfigSvcConfig import LVL1ConfigSvc LVL1ConfigSvc = LVL1ConfigSvc("LVL1ConfigSvc") LVL1ConfigSvc.XMLFile = TriggerFlags.inputLVL1configFile() #LVL1ConfigSvc.CreateLegacyObjects=True include("TrigT1CaloByteStream/ReadLVL1CaloBS_jobOptions.py") include("TrigT1CaloSim/TrigT1CaloSimJobOptions.py") print "JOERG after including T1Calo simulation" print topSequence.getChildren() toRemove = [ c for c in topSequence.getChildren() if c.name() == 'TriggerTowerMaker' ] for x in toRemove: topSequence.remove(x) print "JOERG after removing TriggerTowerMaker" print topSequence.getChildren() from TrigT1MBTS.TrigT1MBTSConf import LVL1__TrigT1MBTS topSequence += LVL1__TrigT1MBTS() from TrigT1BCM.TrigT1BCMConf import LVL1__TrigT1BCM topSequence += LVL1__TrigT1BCM()
from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() # Add simulation algorithm which provided input to monitoring: # new instance with non-default output location and prescale from L1TopoSimulation.L1TopoSimulationConfig import L1TopoSimulation # Check topsequence and add L1TopoSimulation only if it has not already been added. if 'doL1TopoSimMon' not in dir(): doL1TopoSimMon = True # default True log.info('doL1TopoSimMon=%s' % doL1TopoSimMon) if doL1TopoSimMon: topSequenceAlgNames = [alg.getName() for alg in topSequence.getChildren()] steerIndex = topSequenceAlgNames.index('TrigSteer_HLT') if 'L1TopoSimulation' not in topSequenceAlgNames: from L1TopoSimulation.L1TopoSimulationConfig import L1TopoSimulation topSequence.insert(steerIndex, L1TopoSimulation()) #topSequence += L1TopoSimulation() log.info("adding L1TopoSimulation() to topSequence") from TrigT1Muctpi.TrigT1MuctpiConfig import L1MuctpiTool from AthenaCommon.AppMgr import ToolSvc ToolSvc += L1MuctpiTool() topSequence.L1TopoSimulation.MuonInputProvider.MuctpiSimTool = L1MuctpiTool( ) # enable the reduced (coarse) granularity topo simulation
def _test_main(): import AthenaCommon.CfgMgr as CfgMgr from AthenaCommon.AlgSequence import AlgSequence job = AlgSequence() import PerfMonComps.DomainsRegistry as pdr pdr.flag_domain('core') job += CfgMgr.AthSequencer('alg1') job += CfgMgr.AthSequencer('alg2') job += CfgMgr.AthSequencer('alg3') pdr.flag_domain('id') job += CfgMgr.AthSequencer('alg4') job += CfgMgr.AthSequencer('alg5') pdr.flag_domain('empty') pdr.flag_domain('muons') job += CfgMgr.AthSequencer('alg6') job += CfgMgr.AthSequencer('alg7') pdr.flag_domain('empty') pdr.flag_domain('id') job += CfgMgr.AthSequencer('alg4_0') job += CfgMgr.AthSequencer('alg5_0') pdr.flag_domain('empty') pdr.flag_domain('jets') job += CfgMgr.AthSequencer('alg8') job += CfgMgr.AthSequencer('alg9') pdr.flag_domain('empty1') pdr.flag_domain('empty2') pdr.flag_domain('sub-algs-1') job += CfgMgr.AthSequencer('subseq_1') job.subseq_1 += CfgMgr.AthSequencer('subseq1_alg1') pdr.flag_domain('empty3') pdr.flag_domain('sub-algs-1') job.subseq_1 += CfgMgr.AthSequencer('subseq1_alg2') pdr.flag_domain('sub-algs-2') job += CfgMgr.AthSequencer('subseq_2') pdr.flag_domain('empty3') pdr.flag_domain('sub-algs-2') job.subseq_2 += CfgMgr.AthSequencer('subseq2_alg1') pdr.flag_domain('sub-algs-2') job.subseq_2 += CfgMgr.AthSequencer('subseq2_alg2') pdr.flag_domain('sub-algs-1') job.subseq_1 += CfgMgr.AthSequencer('subseq1_alg3') # dummy: pdr.set_domain(domain_name='sub-algs-2', alg_name='subseq2_alg2') ref = { 'core' : ['alg1','alg2','alg3'], 'id': ['alg4','alg5','alg4_0','alg5_0'], 'muons': ['alg6','alg7'], 'empty': [], 'empty1': [], 'empty2': [], 'jets': ['alg8','alg9'], 'sub-algs-1': ['subseq_1'], 'sub-algs-2': ['subseq_2'], } print("=== algs:",[c.getName() for c in job.getChildren()]) print("=== domains:",pdr.domain_names()) assert sorted(pdr.domain_names()) == \ sorted(['core', 'id', 'muons', #'empty', 'empty1', 'empty2', 'jets', 'sub-algs-1', 'sub-algs-2', ]) for d in pdr.domain_names(): print("::: domain [%s]..." % d) #print(" ->",pdr.domain_start(d)) algs = pdr.domain_algs(d) print(" algs:",algs) print(" ref: ",ref[d]) assert algs == ref[d] db = pdr.a2d_db() db = pdr.d2a_db() print("OK") return 0
def runTest( self ): topSequence = AlgSequence() evca1 = CfgMgr.EventViewCreatorAlgorithm("evca1") evca2 = CfgMgr.EventViewCreatorAlgorithm("evca2") vdv1 = CfgMgr.AthViews__ViewDataVerifier("vdv1") vdv2 = CfgMgr.AthViews__ViewDataVerifier("vdv2") # Test error for empty sequence topSequence += seqOR( "makeViewSequence" ) with self.assertRaisesRegex( RuntimeError, "Please remove makeViewSequence" ): findViewAlgs( topSequence.getChildren(), {} ) # Add an algorithm to the sequence topSequence.makeViewSequence += evca1 #topSequence.makeViewSequence += evca2 # Return the algorithm assuming it's in a view, or not self.assertEqual( findViewAlgs( topSequence.getChildren(), {} ), ( [ "evca1" ], [] ) ) self.assertEqual( findViewAlgs( topSequence.getChildren(), {"makeViewSequence":False} ), ( [], [ "evca1" ] ) ) # Add a nested sequence topSequence.makeViewSequence += seqOR( "viewSequence" ) topSequence.makeViewSequence.viewSequence += vdv1 # Return the algorithms depending on where the view is entered self.assertEqual( findViewAlgs( topSequence.getChildren(), {} ), ( [ "evca1", "vdv1" ], [] ) ) self.assertEqual( findViewAlgs( topSequence.getChildren(), {"makeViewSequence":False} ), ( [], [ "evca1", "vdv1" ] ) ) self.assertEqual( findViewAlgs( topSequence.getChildren(), {"viewSequence":False} ), ( [ "evca1" ], [ "vdv1" ] ) ) # Check that the test finds view nodes by name viewNodeDict = {"makeViewSequence":False, "aFakeNode":False} findViewAlgs( topSequence.getChildren(), viewNodeDict ) self.assertEqual( viewNodeDict, {"makeViewSequence":True, "aFakeNode":False} ) # Check misconfigured EVCA evca1.ViewNodeName = "aFakeNode" with self.assertRaisesRegex( RuntimeError, "no corresponding upstream EventViewCreatorAlgorithm" ): checkVDV( topSequence, [topSequence.name()], {} ) evca1.ViewNodeName = "viewSequence" with self.assertRaisesRegex( RuntimeError, "no external data" ): checkVDV( topSequence, [topSequence.name()], {} ) evca1.RequireParentView = True checkVDV( topSequence, [topSequence.name()], {} ) # Check for nested view CF working topSequence.makeViewSequence.viewSequence += seqOR( "nestedSequence" ) topSequence.makeViewSequence.viewSequence.nestedSequence += vdv2 checkVDV( topSequence, [topSequence.name()], {} ) # Check duplicate EVCA config evca2.ViewNodeName = "aFakeNode" topSequence.makeViewSequence += evca2 checkVDV( topSequence, [topSequence.name()], {} ) evca2.ViewNodeName = "viewSequence" with self.assertRaisesRegex( RuntimeError, "Found duplicate view node name" ): checkVDV( topSequence, [topSequence.name()], {} )
StreamBSFileOutput.ItemList += ["HLT::HLTResult#HLTResult_EF"] StreamBSFileOutput.ItemList += ["CTP_RDO#CTP_RDO"] StreamBSFileOutput.ItemList += ["MuCTPI_RDO#MUCTPI_RDO+"] #------------------------------------------------------------------------------- ################### ### POST CONFIG ### ################### svcMgr.RPCcablingServerSvc.Atlas = True svcMgr.RPCcablingServerSvc.useMuonRPC_CablingSvc = True svcMgr.TGCcablingServerSvc.forcedUse = True for i in topSequence.getChildren(): #print "child type ",i.getName(), '\n' if "TrigSteer_L2" in i.getName(): for j in i.getAllChildren(): #print "TrigSteer_L2 child ", j.getName(), "\n" if "muFast" in j.getType(): #print "muFast algo ",j.getName(), " ",j.getFullName(), "\n" j.DomuFastESD = False j.DetMaskCheck = False theApp.EvtMax = runArgs.maxEvents print '######################## Storegate dump ########################' svcMgr.StoreGateSvc.Dump = True print '######################## End of Storegate dump ########################'
'jobOptions_TileDigitsThresholdFilter.py') import AthenaCommon.CfgMgr as CfgMgr from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() from TileRecUtils.TileRecFlags import jobproperties from TileConditions.TileInfoConfigurator import TileInfoConfigurator tileInfoConfigurator = TileInfoConfigurator() if tileInfoConfigurator.setupCOOLDspThreshold(): tileDigitsThresholdFilter = CfgMgr.TileDigitsThresholdFilter() jobproperties.TileRecFlags.TileDigitsContainer = 'TileDigitsFiltered' indices = [ i for i, alg in enumerate(topSequence.getChildren()) if alg.getType() == 'TileRawChannelMaker' ] if len(indices): topSequence.insert(indices[0], tileDigitsThresholdFilter) if hasattr(topSequence, 'TileRChMaker'): topSequence.TileRChMaker.TileDigitsContainer = jobproperties.TileRecFlags.TileDigitsContainer( ) else: topSequence += tileDigitsThresholdFilter tileDigitsFilterLogger.info( "Added TileDigitsThresholdFilter algorithm to filter Tile Digits over threshold" ) else: tileDigitsFilterLogger.warn( "It is impossible to get Tile DSP thresholds from COOL; No Tile Digits filtering!"
# ##################################################### from TrigConfigSvc.TrigConfigSvcConfig import LVL1ConfigSvc LVL1ConfigSvc = LVL1ConfigSvc("LVL1ConfigSvc") LVL1ConfigSvc.XMLFile = TriggerFlags.inputLVL1configFile() #LVL1ConfigSvc.CreateLegacyObjects=True include ("TrigT1CaloByteStream/ReadLVL1CaloBS_jobOptions.py") include ("TrigT1CaloSim/TrigT1CaloSimJobOptions.py" ) print "JOERG after including T1Calo simulation" print topSequence.getChildren() toRemove = [c for c in topSequence.getChildren() if c.name()=='TriggerTowerMaker'] for x in toRemove: topSequence.remove(x) print "JOERG after removing TriggerTowerMaker" print topSequence.getChildren() from TrigT1MBTS.TrigT1MBTSConf import LVL1__TrigT1MBTS topSequence += LVL1__TrigT1MBTS() from TrigT1BCM.TrigT1BCMConf import LVL1__TrigT1BCM topSequence += LVL1__TrigT1BCM() from TrigT1Lucid.TrigT1LucidConf import LVL1__TrigT1Lucid