def postConfigServices(self): '''Services: append a Post Config action to change the services, input and output this is a helper function for patching old software ''' from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(self.changeServices)
def patchEscher(true_online_version, alignment_module, n=-1): import GaudiConf.DstConf import Escher.Configuration from Configurables import MagneticFieldSvc from Configurables import TAlignment from TAlignment.VertexSelections import configuredPVSelection Online = importOnline() from Configurables import EventClockSvc initialTime = long(time.time() * 1e9) clkSvc = EventClockSvc() clkSvc.InitialTime = initialTime from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(fakeEventTime(initialTime)) TAlignment().RunList = Online.DeferredRuns if hasattr( Online, "DeferredRuns") else [] sys.stdout.flush() sys.stderr.flush() escher = EscherCommon(true_online_version, alignment_module) hostname = HostName() escher.InputType = "MDF" escher.PrintFreq = 10000 # escher.EvtMax=300 # asddir = Online.ASDDir + "/" if hasattr(Online, "ASDDir") else "/group/online/alignment/EscherOut/" asddir = Online.ASDDir + "/" if hasattr( Online, "ASDDir") else "/calib/align/EscherOut/" if n == -1: suffix = "_Escher.out" else: suffix = ("_%02d_Escher.out" % n) TAlignment().OutputDataFile = asddir + hostname + suffix TAlignment().UpdateInFinalize = False return escher
def __init__(self, name="TrackRefitting", fitAsIn="2015", RootInTES="", Stripping23=False, EnergyLossFactor=1.0, *args, **kwargs): ''' Keyword arguments: name -- the standard name of an Algorithm in Gaudi fitAsIn -- which reconstruction should be mimiced, possible values ['2015','EM2015','Reco14'] RootInTES -- the usual RootInTES (cannot be caught from DaVinci since Stripping23) EnergyLossFactor -- to study the impact of the material uncertainty, tune the energy loss when propagating through material Stripping23 -- since stripping23, the hit managers need to know about the stream (RootInTES) also on fullDST args,kwargs -- arguments to be forwarded to TrackRefitting ''' self._refitter = RefitParticleTracks(name, *args, **kwargs) self._fitAsIn = fitAsIn self._EnergyLossFactor = EnergyLossFactor ConfigureFitter(self._refitter, fitAsIn=fitAsIn, EnergyLossFactor=EnergyLossFactor) self.Stripping23 = Stripping23 self.RootInTES = RootInTES def postconfig(): self.__apply_configuration() appendPostConfigAction(postconfig)
def resetDaVinci(): """ Reset all DaVinci sequences """ def _action(): """ Reset all DaVinci sequences """ from Gaudi.Configuration import allConfigurables from Gaudi.Configuration import getConfigurable for seq in ('DaVinciInitSeq', 'DaVinciMainSequence', 'DaVinciSequence', 'MonitoringSequence', 'FilteredEventSeq'): if not seq in allConfigurables: continue cSeq = getConfigurable(seq) if cSeq and hasattr(cSeq, 'Members'): logger.info('Reset the sequence %s' % cSeq.name()) cSeq.Members = [] ## reset the list of top-level algorithms from Configurables import ApplicationMgr a = ApplicationMgr() a.TopAlg = [] a.OutputLevel = options.OutputLevel from Configurables import MessageSvc m = MessageSvc(OutputLevel=options.OutputLevel) from GaudiConf import IOHelper ioh = IOHelper() ioh.setupServices() ## comment it out... Hm... from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(_action)
def configureAlignment(): from Configurables import TAlignment from TAlignment.TrackSelections import GoodLongTracks, VeloOverlapTracks, VeloBackwardTracks, GoodLongRefittedVeloTracks from TAlignment.VertexSelections import configuredLoosePVSelection, configuredPVSelection # specify what we actually align for TAlignment().TrackSelections = [ GoodLongRefittedVeloTracks('TrackRefitSeq'), VeloOverlapTracks(), VeloBackwardTracks() ] # add the default PV selection TAlignment().PVSelection = configuredPVSelection() from TAlignment.AlignmentScenarios import configureVeloHalfAlignment, configureVeloAlignment configureVeloHalfAlignment() # configureVeloAlignment() # Prescale Beam Beam interactions def prescaleBB(BBfraction=1): from Configurables import LoKi__ODINFilter as ODINFilter from Configurables import DeterministicPrescaler, GaudiSequencer odinFiltNonBB = ODINFilter('ODINBXTypeFilterNonBB', Code='ODIN_BXTYP < 3') odinFiltBB = ODINFilter('ODINBXTypeFilterBB', Code='ODIN_BXTYP == 3') prescBB = DeterministicPrescaler("DetPrescBB", AcceptFraction=BBfraction) prescBB_seq = GaudiSequencer("PrescBB") prescBB_seq.Members = [odinFiltBB, prescBB] collTypeSeq = GaudiSequencer('CollTypeSelector', ModeOR=True) collTypeSeq.Members = [odinFiltNonBB, prescBB_seq] GaudiSequencer('HltFilterSeq').Members.append(collTypeSeq) # Prescale Beam Beam interactions using routing bits def prescaleBB2(BBfraction=1): from Configurables import LoKi__Hybrid__HltFactory as HltFactory HltFactory().Modules.append("LoKiHlt.functions") from Configurables import LoKi__HDRFilter as HLTFilter from Configurables import DeterministicPrescaler, GaudiSequencer odinFiltNonBB = HLTFilter('Hlt1FilterNonBB', Code="HLT_PASS_SUBSTR('Hlt1BeamGas')") odinFiltBB = HLTFilter( 'Hlt1FilterBB', Code= "HLT_PASS_RE('Hlt1(?!ODIN)(?!L0)(?!Lumi)(?!Tell1)(?!MB)(?!NZS)(?!Velo)(?!BeamGas)(?!Incident).*Decision')" ) prescBB = DeterministicPrescaler("DetPrescBB", AcceptFraction=BBfraction) prescBB_seq = GaudiSequencer("PrescBB") prescBB_seq.Members = [odinFiltBB, prescBB] collTypeSeq = GaudiSequencer('CollTypeSelector', ModeOR=True) collTypeSeq.Members = [odinFiltNonBB, prescBB_seq] GaudiSequencer('HltFilterSeq').Members.append(collTypeSeq) from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(prescaleBB)
def genAction(extension='gen'): """ Define prooer action for processing of (x)gen files """ ## ext = extension.upper() ## if not ext in ('GEN', 'XGEN'): logger.warning('No action is needed for extension =%s' % ext) return ## specific post-config action for (x)GEN-files def _gen_postconfig_(): """ specific post-config action for (x)GEN-files """ logger.info('Start post-config action for (x)gen-files') from Configurables import DataOnDemandSvc dod = DataOnDemandSvc() from copy import deepcopy algs = deepcopy(dod.AlgMap) bad = set() for key in algs: if 0 <= key.find('Rec'): bad.add(key) elif 0 <= key.find('Raw'): bad.add(key) elif 0 <= key.find('DAQ'): bad.add(key) elif 0 <= key.find('Trigger'): bad.add(key) elif 0 <= key.find('Phys'): bad.add(key) elif 0 <= key.find('Prev/'): bad.add(key) elif 0 <= key.find('Next/'): bad.add(key) elif 0 <= key.find('/MC/') and 'GEN' == ext: bad.add(key) for b in bad: logger.debug('Remove key from DataOnDemand actions %s' % key) del algs[b] logger.info('Remove %d keys from DataOnDemand actions ' % len(bad)) dod.AlgMap = algs from Configurables import EventClockSvc, CondDB EventClockSvc(EventTimeDecoder="FakeEventTime") logger.info('Use fake event time decoder for (x)gen-files') CondDB(IgnoreHeartBeat=True) logger.info('Ignore Heart-beat for (x)gen-files') ## Important: use Post Config action! from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(_gen_postconfig_) logger.info('Define post-config action for (x)gen-files')
def __apply_configuration__(self): veloSeq = self.getProp("RecoVELOSeq") if veloSeq == None: raise RuntimeError("ERROR : RecoVELOSeq not set") vertexSeq = self.getProp("RecoVertexSeq") if vertexSeq == None: raise RuntimeError("ERROR : RecoVertexSeq not set") def action(): alreadyModified = any([isinstance(alg, PVSplit) for alg in vertexSeq.Members]) if not alreadyModified: self._modify_velo_seq(veloSeq) self._modify_vertex_seq(vertexSeq, alreadyModified) appendPostConfigAction(action)
def _configureDataOnDemand(self): if not self.getProp("EnableDataOnDemand"): if 'DataOnDemandSvc' in ApplicationMgr().ExtSvc: ApplicationMgr().ExtSvc.pop('DataOnDemandSvc') from Gaudi.Configuration import appendPostConfigAction def disableFaultHandler(): from Configurables import EventDataSvc EventDataSvc().EnableFaultHandler = False appendPostConfigAction(disableFaultHandler) else: from Configurables import DataOnDemandSvc dod = DataOnDemandSvc() if dod not in ApplicationMgr().ExtSvc: ApplicationMgr().ExtSvc.append(dod)
def __apply_configuration__(self): veloSeq = self.getProp("RecoVELOSeq") if veloSeq == None: raise RuntimeError("ERROR : RecoVELOSeq not set") vertexSeq = self.getProp("RecoVertexSeq") if vertexSeq == None: raise RuntimeError("ERROR : RecoVertexSeq not set") def action(): alreadyModified = any( [isinstance(alg, PVSplit) for alg in vertexSeq.Members]) if not alreadyModified: self._modify_velo_seq(veloSeq) self._modify_vertex_seq(vertexSeq, alreadyModified) appendPostConfigAction(action)
def silence ( lst = [ 'HcalDet.Quality' , 'EcalDet.Quality' , 'MagneticFieldSvc' , 'PropertyConfigSvc' , 'IntegrateBeamCrossing' , 'ToolSvc.L0DUConfig' , 'ConfigCDBAccessSvc' , 'ToolSvc.L0CondDBProvider' , 'L0MuonFromRaw' ] ) : """ Suppress some unnesessary printout from Gaudi """ # logger.info ( 'Suppress some unnesessary Gaudi prints' ) if isinstance ( lst , str ) : lst = [ lst ] if not isinstance ( lst , list ) : lst = list ( lst ) # def _silent_action_ () : from Gaudi.Configuration import allConfigurables from Gaudi.Configuration import getConfigurable keys = allConfigurables.keys() s1 = set( keys ) s2 = set( lst ) s = s1.intersection() for i in s : c = getConfigurable( i ) if c and hasattr ( c , 'OutputLevel' ) : c.OutputLevel = 4 from GaudiPython.Bindings import _gaudi if not _gaudi : ## use configurables from Configurables import MessageSvc msg = MessageSvc() from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction ( _silent_action_ ) else : ## use GaudiPython msg = _gaudi.service('MessageSvc') # msg.setWarning += lst
def __apply_configuration__(self): """ L0Conf configuration. """ log.info("Applying L0Conf") self.checkOptions() if self.isPropertySet("L0Sequencer"): self._defineL0Sequencer() if self.isPropertySet("LinkSequencer"): self._defineL0LinkSequencer() if self.isPropertySet("MoniSequencer"): self._defineL0MoniSequence() if self.isPropertySet("FilterSequencer"): self._defineL0FilterSequence() if self.isPropertySet("ETCSequencer"): self._defineETC() if self.getProp("EnableTAEOnDemand"): self._enableTAEOnDemand() if self.getProp("EnableL0DecodingOnDemand"): for _rootintes in self.getProp("RootInTESOnDemand"): self._setSpecificDecodingOptions(_rootintes) self._dataOnDemand(_rootintes) else: self._setSpecificDecodingOptions() self._setSpecificEmulationOptions() # TCK definitions importOptions("$L0TCK/L0DUConfig.opts") # Force all L0 components to use the single config provider (for Moore) if self.getProp("ForceSingleL0Configuration"): from Configurables import L0DUMultiConfigProvider, L0DUConfigProvider L0TCK = self.getProp("TCK") if L0TCK not in L0DUMultiConfigProvider('L0DUConfig').registerTCK: raise KeyError('requested L0 TCK %s is not known' % L0TCK) if 'ToolSvc.L0DUConfig.TCK_%s' % L0TCK not in allConfigurables: raise KeyError( 'requested L0DUConfigProvider for TCK %s is not known' % L0TCK) orig = L0DUConfigProvider('ToolSvc.L0DUConfig.TCK_' + L0TCK) del allConfigurables['ToolSvc.L0DUConfig'] single = L0DUConfigProvider('ToolSvc.L0DUConfig') for p, v in orig.getValuedProperties().items(): setattr(single, p, v) single.TCK = L0TCK from Configurables import L0DUFromRawTool, L0DUFromRawAlg l0du = L0DUFromRawAlg("L0DUFromRaw") l0du.addTool(L0DUFromRawTool, name="L0DUFromRawTool") getattr(l0du, 'L0DUFromRawTool' ).L0DUConfigProviderType = 'L0DUConfigProvider' from Configurables import L0DUAlg L0DUAlg('L0DU').L0DUConfigProviderType = 'L0DUConfigProvider' def _fixL0DUConfigProviderTypes(): from Gaudi.Configuration import allConfigurables for c in allConfigurables.values(): if hasattr(c, 'L0DUConfigProviderType'): c.L0DUConfigProviderType = 'L0DUConfigProvider' from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(_fixL0DUConfigProviderTypes)
# suppress printout of various summaries from algorithms. from Gaudi.Configuration import allConfigurables for conf in allConfigurables.itervalues(): for opt in ('StatPrint', 'ErrorsPrint', 'HistoPrint'): if opt in conf.__slots__: setattr(conf, opt, False) # ensure that prints from the main tools/factories are not suppressed import Configurables for factory in ('Tool', 'CoreFactory', 'TrackFunctorFactory', 'HltFactory', 'Hlt1HltFactory', 'Hlt2HltFactory'): factory = 'LoKi__Hybrid__%s' % factory try: factory = getattr(Configurables, factory) factory(OutputLevel=2, StatPrint=True) except AttributeError: # ignore unknown factories pass # ## use this action! # from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(post_action_for_cpp) # ============================================================================= # The END # =============================================================================
# New NoSPDPRS switches noSPDPRS = False if [det for det in ['Spd', 'Prs'] if det not in detectors]: noSPDPRS = True CaloProcessor().setProp("NoSpdPrs", noSPDPRS) GlobalRecoConf().setProp("NoSpdPrs", noSPDPRS) import os, sys #indir = '/afs/cern.ch/work/c/chombach/public/VP/BooleOutput/' inputdata = [] #files = os.listdir(indir) #for file in files: # inputdata.append("DATAFILE='PFN:"+indir+file+"'") for i in range(209): inputdata.append( "root://eoslhcb.cern.ch//eos/lhcb/user/c/chombach/ganga/2745/%i/BooleOutput.digi-Extended.digi" % i) inputFiles = inputdata #inputFiles = ['/eos/lhcb/user/c/chombach/ganga/2744/0/BrunelTest.xdst'] def doMyChanges(): GaudiSequencer("HltFilterSeq").Members = [] from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(doMyChanges) from GaudiConf import IOHelper IOHelper('ROOT').inputFiles(inputFiles)
def _generateConfig(self): from HltConf.ThresholdUtils import Name2Threshold settings = Name2Threshold(HltConf().getProp('ThresholdSettings')) svcs = MooreExpert().getProp("configServices") algs = MooreExpert().getProp("configAlgorithms") if MooreExpert().getProp('TCKpersistency').lower() in [ 'tarfile', 'zipfile', 'cdb' ]: self.getConfigAccessSvc().Mode = 'ReadWrite' #self.getConfigAccessSvc().OutputLevel = 1 from Configurables import HltGenConfig print 'requesting following svcs: %s ' % svcs gen = HltGenConfig(ConfigTop=[i.rsplit('/')[-1] for i in algs], ConfigSvc=[i.rsplit('/')[-1] for i in svcs], ConfigAccessSvc=self.getConfigAccessSvc().getName(), HltType=settings.HltType(), MooreRelease=self.getRelease(), Label=self.getProp('configLabel')) # make sure gen is the very first Top algorithm... from HltLine.HltDecodeRaw import DecodeODIN ApplicationMgr().TopAlg = DecodeODIN.members() + [ gen.getFullName() ] + ApplicationMgr().TopAlg def genConfigAction(): def gather(c, overrule): def check(config, prop, value): if prop not in config.getDefaultProperties(): return False if hasattr(config, prop): return getattr(config, prop) == value return config.getDefaultProperties()[prop] == value def addOverrule(config, rule): if c.name() not in overrule.keys(): overrule[c.name()] = [] if rule not in overrule[c.name()]: overrule[c.name()] += [rule] if check(c, 'HistoProduce', False): addOverrule(c, 'HistoProduce:@OnlineEnv.Monitor@False') if c.getType() in ['FilterDesktop', 'CombineParticles' ] and check(c, 'Monitor', False): addOverrule(c, 'Monitor:@OnlineEnv.Monitor@False') if check(c, 'Enable', False): addOverrule(c, 'OutputLevel:3') for p in ['Members', 'Filter0', 'Filter1']: if not hasattr(c, p): continue x = getattr(c, p) if list is not type(x): x = [x] for i in x: gather(i, overrule) from Configurables import HltGenConfig, GaudiSequencer HltGenConfig().Overrule = { 'Hlt1ODINTechnicalPreScaler': ['AcceptFraction:@OnlineEnv.AcceptRate@0'] } gather(GaudiSequencer('Hlt'), HltGenConfig().Overrule) print HltGenConfig() from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(genConfigAction)
def _outputLevel(self): """ Set the print out of various tools, services, all algorithms, and properties of all things like algorithms Sensitive to the OutputLevel of Moore a) configure things independently of level b) configure things depending on level - ThresholdSettings via postConfigActions - TCKs via transforms defaults are now WARNING printouts only, so I need to handle the case the user wishes to switch back if a TCK has been generated with a warning """ #firstly explicitly configure things not seen by TCK #firstly configure things which are level-independent # Usual output levels for services from Configurables import XmlParserSvc XmlParserSvc().OutputLevel = WARNING ApplicationMgr( ).OutputLevel = INFO #I still want the Application Manager Finalized Sucessfully printout # Print algorithm name with 40 characters if not self.getProp("RunOnline"): if not MessageSvc().isPropertySet("Format"): MessageSvc().Format = '% F%40W%S%7W%R%T %0W%M' #this should be OK to do here... from Funcs import _minSetFileTypes #postconfig away common warnings def suppresswarningifneeded(): #histogram warning isn't needed if I didn't want histograms from Configurables import RootHistCnv__PersSvc if RootHistCnv__PersSvc().getProp( "OutputFile") == "UndefinedROOTOutputFileName" or not len( RootHistCnv__PersSvc().getProp("OutputFile")): RootHistCnv__PersSvc().OutputEnabled = False if HistogramPersistencySvc().getProp( "OutputFile") == '' or not HistogramPersistencySvc( ).isPropertySet("OutputFile"): HistogramPersistencySvc().Warnings = False #error from IODataManager is pointless when I have MDFs from Funcs import _minSetFileTypes if Moore().getProp("RunOnline") or _minSetFileTypes() in [ "MDF", "RAW" ]: from Configurables import IODataManager IODataManager().DisablePFNWarning = True appendPostConfigAction(suppresswarningifneeded) #then configure things that depend on the level level = self.getProp("OutputLevel") from Configurables import LHCbSequencerTimerTool, SequencerTimerTool if level >= INFO: LHCbSequencerTimerTool().OutputLevel = WARNING if level >= INFO: SequencerTimerTool().OutputLevel = WARNING if level > DEBUG: from Configurables import LoKi__DistanceCalculator LoKi__DistanceCalculator().MaxPrints = 0 if level > VERBOSE: from Configurables import LoKiSvc LoKiSvc().Welcome = False from Configurables import Hlt__Service if not Hlt__Service().isPropertySet('Pedantic'): Hlt__Service().Pedantic = (level < DEBUG) ############################################################### #if level is less than INFO, I don't need to edit anything else #it's up to the users to do that themselves! ############################################################### if level < INFO: return if level > INFO: if not self.getProp("RunOnline"): MessageSvc().OutputLevel = level ToolSvc().OutputLevel = level if level > INFO and hasattr( self, "EnableTimer") and self.getProp("EnableTimer") and type( self.getProp("EnableTimer")) is not str: print "# WARNING: Timing table is too verbose for printing, consider outputting to a file instead please, Moore().EnableTimer='timing.csv', for example." ################################################# # If the OutputLevel is set I need # Either a postConfigAction or a transform # to suppress the outputs properly ################################################# ################################################# # Running from thresholds, use post config action ################################################# if not self.getProp("UseTCK") and level > INFO: #post config to really reset all the output to null from DAQSys.Decoders import DecoderDB from GaudiConf.Manipulations import recurseConfigurables, setPropertiesAndAddTools props = {} props["OutputLevel"] = level props["StatPrint"] = (level < WARNING) props["ErrorsPrint"] = (level < WARNING) props["PropertiesPrint"] = (level < WARNING) from DAQSys.Decoders import DecoderDB for k, v in DecoderDB.iteritems(): for pk, pv in props.iteritems(): v.Properties[pk] = pv props["HistoCountersPrint"] = (level < WARNING) calo_tools = [ "CaloECorrection/ECorrection", "CaloSCorrection/SCorrection", "CaloLCorrection/LCorrection", "CaloHypoEstimator", "CaloExtraDigits/SpdPrsExtraE", "CaloExtraDigits/SpdPrsExtraG", "CaloExtraDigits/SpdPrsExtraM", "CaloExtraDigits/SpdPrsExtraS", "CaloSelectCluster/PhotonCluster", "CaloSelectCluster/ElectronCluster", "CaloSelectChargedClusterWithSpd/ChargedClusterWithSpd", "CaloSelectClusterWithPrs/ClusterWithPrs", "CaloSelectNeutralClusterWithTracks/NeutralCluster", "CaloSelectNeutralClusterWithTracks/NotNeutralCluster", "CaloSelectorNOT/ChargedCluster", "CaloSelectNeutralClusterWithTracks/ChargedCluster.NeutralCluster", ] tools_per_type = { # turn off the calo tool finalize printout, there are *a lot* of tools here "CaloSinglePhotonAlg": calo_tools, "CaloElectronAlg": calo_tools, "CaloMergedPi0Alg": calo_tools, "NeutralProtoPAlg": calo_tools, # three extras for merged pi0 "CaloMergedPi0Alg": [ "CaloCorrectionBase/ShowerProfile", "CaloCorrectionBase/Pi0SCorrection", "CaloCorrectionBase/Pi0LCorrection" ], # and one calo clustering "CellularAutomatonAlg": ["CaloClusterizationTool"], } func = partial(setPropertiesAndAddTools, properties=props, tools_per_type=tools_per_type, force=True) # Instantiate a few public tools (members of the ToolService), # which means their output properties will also be set in the post config action from Configurables import LoKi__LifetimeFitter, CaloDigitFilterTool, CaloGetterTool, OTChannelMapTool, CaloClusterizationTool LoKi__LifetimeFitter("ToolSvc.lifetime") CaloDigitFilterTool("ToolSvc.FilterTool") CaloGetterTool("ToolSvc.CaloGetter") OTChannelMapTool("ToolSvc.OTChannelMapTool") CaloClusterizationTool("ToolSvc.CaloClusterizationTool") # visit_properties = ['Members', 'Filter0', 'Filter1', 'TopAlg'] descend_properties = [ 'Members', 'Prescale', 'ODIN', 'L0DU', 'HLT', 'HLT1', 'HLT2', 'Filter0', 'Filter1', 'Postscale' ] appendPostConfigAction( partial(recurseConfigurables, func, descend_properties=descend_properties, descend_tools=True)) #I still want to print "Application Manager Finalized Successfully" #and "End of event input reached" no matter what def AppMrgOP(): if ApplicationMgr().getProp("OutputLevel") > INFO: ApplicationMgr().OutputLevel = INFO if EventSelector().getProp("OutputLevel") > INFO: EventSelector().OutputLevel = INFO appendPostConfigAction(AppMrgOP) def RestoreGenConfig(): Moore().getConfigAccessSvc().OutputLevel = INFO from Configurables import HltGenConfig HltGenConfig().OutputLevel = INFO if self.getProp("generateConfig"): appendPostConfigAction(RestoreGenConfig) ################################################# # Running from TCK define a similar transform ################################################# elif self.getProp("UseTCK"): trans = {".*": {"OutputLevel": {"^.*$": str(level)}}} #turn certain things back on if INFO is set again... trans[".*"]["StatPrint"] = {"^.*$": str(level < WARNING)} trans[".*"]["ErrorsPrint"] = {"^.*$": str(level < WARNING)} trans[".*"]["PropertiesPrint"] = {"^.*$": str(level < WARNING)} trans[".*"]["HistoCountersPrint"] = {"^.*$": str(level < WARNING)} Funcs._mergeTransform(trans) #kill LoKi warnings set = 0 if level < WARNING: set = 3 trans = { ".*DistanceCalculator.*": { "MaxPrints": { "^.*$": str(set) } } } Funcs._mergeTransform(trans) #kill one extra loki print in tool service from GaudiConf.Manipulations import recurseConfigurables, setPropertiesAndAddTools props = {} props["OutputLevel"] = level props["StatPrint"] = (level < WARNING) props["ErrorsPrint"] = (level < WARNING) props["PropertiesPrint"] = (level < WARNING) # postConfForAll(head=["LoKi::LifetimeFitter/ToolSvc.lifetime"],force=True,prop_value_dict=props) func = partial(setPropertiesAndAddTools, properties=props, force=True) appendPostConfigAction( partial(recurseConfigurables, func, head="LoKi::LifetimeFitter/ToolSvc.lifetime")) from Configurables import HltConfigSvc cfg = HltConfigSvc() #self-defeating warnings! cfg.OutputLevel = ERROR
def postConfigDebug(self): '''Print debug information as a post-config action''' from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(self.debugIO)
def dataOnDemand(self): """ dataOnDemand service """ dataOnDemand = DataOnDemandSvc() dataOnDemand.NodeMap['/Event/Rec'] = 'DataObject' dataOnDemand.NodeMap['/Event/Rec/Muon'] = 'DataObject' dataOnDemand.NodeMap['/Event/Rec/Rich'] = 'DataObject' dataOnDemand.NodeMap['/Event/Phys'] = 'DataObject' dataOnDemand.NodeMap['/Event/Relations/Phys'] = 'DataObject' # raw event DecodeRawEvent().DataOnDemand = True #require L0 just in case I need to do L0 decoding importOptions("$L0TCK/L0DUConfig.opts") # ANN PID recalibration if self.getProp("AllowPIDRecalib"): from Gaudi.Configuration import appendPostConfigAction datatype = self.getProp("DataType") # Default settings for calibration is off recoRegex = "v43r2(.*)" # If Run I data, perform Reco14 recalibration on the fly if (datatype == '2009' or datatype == '2010' or datatype == '2011' or datatype == '2012' or datatype == '2013' or datatype == '2015'): def _ANNPIDReCalib_(): from Configurables import (DstConf, DataOnDemandSvc, ChargedProtoANNPIDConf, ChargedProtoParticleMapper, ApplicationVersionFilter) # Sequence to fill annPIDSeq = GaudiSequencer("ANNPIDSeq") # Only rerun on Reco14 (Run1) and Reco15 (2015) samples recoRegex = "(v43r2|v47r9|v48r2)(.*)" annPIDSeq.Members += [ ApplicationVersionFilter( name="ANNPIDRecoVersionFilter", HeaderLocation="Rec/Header", VersionRegex=recoRegex) ] # ANN PID Configurable annPIDConf = ChargedProtoANNPIDConf("ReDoANNPID") # Configure Configurable for recalibration of the DST charged protos annPIDConf.DataType = self.getProp("DataType") annPIDConf.RecoSequencer = annPIDSeq annPIDConf.applyConf() # Update the DoD sequence to run this at the end chargedLoc = "/Event/Rec/ProtoP/Charged" if chargedLoc in DataOnDemandSvc().AlgMap.keys(): chargedSeq = DataOnDemandSvc().AlgMap[chargedLoc] chargedSeq.Members += [annPIDSeq] # Now for uDSTs. Update the DoD mappers to run a custom one # for charged Protos, and includes the recalibration cppmapper = ChargedProtoParticleMapper( "UnpackChargedPPsMapper") # Clone the settings from the DST configurable cppmapper.ANNPIDTune = annPIDConf.tune(annPIDConf.DataType) cppmapper.TrackTypes = annPIDConf.TrackTypes cppmapper.PIDTypes = annPIDConf.PIDTypes # Again, only rerun the ANNPID on Reco14 data cppmapper.VersionRegex = recoRegex # Update the DoD mapper lists DataOnDemandSvc().NodeMappingTools = [ cppmapper ] + DataOnDemandSvc().NodeMappingTools DataOnDemandSvc().AlgMappingTools = [ cppmapper ] + DataOnDemandSvc().AlgMappingTools # Append post config action appendPostConfigAction(_ANNPIDReCalib_)
class ParticleFlowConf: def __init__(self, _name, _InputParticles=[ 'Photons', 'NeutralHadrons', 'Charged', 'Pi0s', 'V0s', 'PFNeutrals' ], _MCCor=False, _MCSeq=False, _params={}): # _MCCor is kept in config to not break anything but not used, it is # fixed now in a postconfiguration based on DaVinci Simulation status # or not. self.name = _name self.InputParticles = _InputParticles self.MC = _MCSeq ## Default parameters: self.paramDef = { ### Location "PFOutputLocation": "Phys/PFParticles/Particles", "PFProtoParticlesOutputLocation": "Rec/ProtoP/PF", "PFCaloHypoOutputLocation": "Rec/Calo/Hadrons", "ParticleLocations": [], "CompositeParticleLocations": [], "CandidateToBanLocation": [], "CandidatesToKeepLocation": [], "VerticesLocation": "Rec/Vertex/Primary", ### Tracks selection # For track selector "LongProbNNghostCut": 0.5, "DownProbNNghostCut": 0.5, "UpProbNNghostCut": 0.5, 'TrackSelector': { 'Downstream': { 'Chi2Max': 1.5, 'PtMin': 0., 'MaxGhostProb': 10. }, 'Long': { 'Chi2Max': 5., 'PtMin': 0., 'MaxGhostProb': 10. }, 'Upstream': { 'Chi2Max': 1.5, 'PtMin': 100. } }, 'TrackVelo': { 'Chi2Max': 10. }, #"UseTTHits" : False , "MinInfMomentumCut": 10., "MinInfMomentumCutDown": 10., "MinInfMomentumCutUp": 2., ##"MaxChi2NoTT": 5. , "UseVelo": True, ## Neutral selection "MinPhotonID4Photon": -1., "MinPhotonID4PhotonTtrack": -2., "MinPhotonIDMax4ResolvedPi0": -4., "MinPhotonIDMin4ResolvedPi0": -2., "MinIsoPhotonEt": 200., "MinPhotonEt": 200., "MinBadPhotonEt": 2000., "MinBadPhotonMatchingTEt": 2000., "UseHCAL": True, "MinHCALE": 0., "MinHCALEt": 500., "MinHCALEt4Eta4": 1000., "UseTTrackBanning": True, ### Neutral recovery "MaxMatchECALTr": 25., "MaxMatchECALTr_T": 16., "MaxMatchHCALLowEValue": 5000., "MaxMatchHCALHighEValue": 10000., "MaxMatchHCALTrSmallE": 25., "MaxMatchHCALTrMediumE": 16., "MaxMatchHCALTrLargeE": 16., "NeutralRecovery": True, "MinE": 0., "MinEt": 500., "MC_recovery": True, "MaximumFracNeutrReco": 1.8, "BanInfMomentumFromNR": False, "OnlyBestCaloMatchForNR": True, "scalingANDsmearing": False } # set the datafile ### Get all the name coherantly self.MCCor = _MCCor self.PFSeq = GaudiSequencer(_name + "Particles", IgnoreFilterPassed=True) self.algorithms = [] self.setupParam(_params) self.setupPF() def setupTypeTrackSelector(self, tsname, selector, trackCuts): selector.addTool(TrackSelector, name=tsname) ts = getattr(selector, tsname) # Set Cuts ts.TrackTypes = [tsname] if tsname in trackCuts: for name, cut in trackCuts[tsname].iteritems(): if name.find("Min") > -0.5 or name.find( "Max") > -0.5 or name.find("AcceptClones") > -0.5: ts.setProp(name, cut) else: ts.setProp("Min" + name, cut[0]) ts.setProp("Max" + name, cut[1]) def setupParam(self, params): self.paramDef.update(params) ## Configure the jet maker def setupPF(self): ## set the algorithm alg = ParticleFlow(self.name) if "Velo" in self.paramDef['TrackSelector'].keys( ) and not self.paramDef['UseVelo']: self.paramDef['UseVelo'] = True # set all params for prop, value in self.paramDef.items(): if prop != 'TrackSelector' and prop != 'TrackVelo' and prop != "scalingANDsmearing": setattr(alg, prop, value) else: self.__dict__[prop] = value if (self.name != "PF"): alg.PFOutputLocation = "Phys/" + self.name + "/Particles" ## List of algorithms to put in the sequencer if self.scalingANDsmearing: from Configurables import TrackScaleState as SCALER scaler = SCALER('PFStateScale') self.PFSeq.Members += [scaler] if self.MCCor: from Configurables import TrackSmearState as SMEAR smear = SMEAR('PFStateSmear') self.PFSeq.Members += [smear] ## Definition of cuts to apply to input tracks for inputselection TrackCuts = {} if self.paramDef['UseVelo'] and not "Velo" in self.TrackSelector.keys( ): self.TrackSelector["Velo"] = self.TrackVelo for trtype in self.TrackSelector.keys(): if trtype == "Long": TrackCuts[trtype] = { "Chi2Cut": [0, self.TrackSelector[trtype]['Chi2Max']], "MinPtCut": self.TrackSelector[trtype]['PtMin'], "MaxGhostProbCut": self.TrackSelector[trtype]['MaxGhostProb'] } if trtype == "Downstream": TrackCuts[trtype] = { "Chi2Cut": [0, self.TrackSelector[trtype]['Chi2Max']], "MinPtCut": self.TrackSelector[trtype]['PtMin'], "MaxGhostProbCut": self.TrackSelector[trtype]['MaxGhostProb'] } if trtype == "Upstream": TrackCuts[trtype] = { "Chi2Cut": [0, self.TrackSelector[trtype]['Chi2Max']], "MinPtCut": self.TrackSelector[trtype]['PtMin'] } if trtype == "Velo": TrackCuts[trtype] = { "Chi2Cut": [0, self.TrackSelector[trtype]['Chi2Max']] } protos = ChargedProtoParticleMaker("VeloProtoPMaker") protos.Inputs = ["Rec/Track/Best"] protos.Output = "Rec/ProtoP/VeloProtoPMaker" protos.addTool(DelegatingTrackSelector, name="TrackSelector") protos.TrackSelector.TrackTypes = ["Velo"] self.setupTypeTrackSelector("Velo", protos.TrackSelector, TrackCuts["Velo"]) self.PFSeq.Members += [protos] pLocations = [] pCompLocations = [] alg.MC_recovery = self.MCCor #re set default to false alg.UseHCAL = False alg.NeutralRecovery = False for t in self.InputParticles: if t == 'Photons': pLocations.append('Phys/StdLooseAllPhotons/Particles') elif t == 'NeutralHadrons': ## Set the HCAL uses alg.UseHCAL = True self.setupHCAL() elif t == 'Charged': ## Track selector alg.TrackSelectorType = "DelegatingTrackSelector" alg.addTool(DelegatingTrackSelector, name="TrackSelector") tracktypes = TrackCuts.keys() alg.TrackSelector.TrackTypes = self.TrackSelector.keys() for type in tracktypes: self.setupTypeTrackSelector(type, alg.TrackSelector, TrackCuts) elif t == 'Pi0s': pLocations.append('Phys/StdLooseResolvedPi0/Particles') pLocations.append('Phys/StdLooseMergedPi0/Particles') elif t == 'V0s': pCompLocations.append("Phys/StdKs2PiPiLL/Particles") pCompLocations.append("Phys/StdKs2PiPiDD/Particles") pCompLocations.append("Phys/StdLambda2PPiLL/Particles") pCompLocations.append("Phys/StdLambda2PPiDD/Particles") elif t == 'PFNeutrals': alg.NeutralRecovery = True else: print t, "are not supported!" exit(1) if len(self.paramDef['CompositeParticleLocations']) > 0.5: for t in self.paramDef['CompositeParticleLocations']: pCompLocations.append(t) alg.ParticleLocations = pLocations alg.CompositeParticleLocations = pCompLocations self.PFSeq.Members += [alg] self.algorithms.append(self.PFSeq) def setupHCAL(self): ## Create Sequencer ## Call the cluster creation hcalClus = CellularAutomatonAlg( 'HcalClusterization') # name is enough to setup I/O self.PFSeq.Members += [hcalClus] ## Get the covariance matrix clustCov = CaloClusterCovarianceAlg('HcalCov') clustCov.EnergyTags = ['2x2'] clustCov.CovarianceParameters["Stochastic"] = [0.7] clustCov.CovarianceParameters["GainError"] = [0.1] self.PFSeq.Members += [clustCov] ## Get Association to tracks hcal2Track = PhotonMatchAlg("Hcal2TrackMatching") hcal2Track.Calos = ["Rec/Calo/HcalClusters"] hcal2Track.Output = "Rec/Calo/HcalClusterMatch" hcal2Track.Filter = "Rec/Calo/InAccHcal" hcal2Track.addTool(CaloPhotonMatch, "HcalMatch") hcal2Track.Tool = "CaloPhotonMatch/HcalMatch" hcal2Track.Threshold = "1000" hcal2Track.HcalMatch.Calorimeter = "/dd/Structure/LHCb/DownstreamRegion/Hcal" hcal2Track.HcalMatch.Tolerance = "60" hcal2Track.HcalMatch.Extrapolator = "TrackRungeKuttaExtrapolator/Regular" self.PFSeq.Members += [hcal2Track] def _fixMCDATAConfig(): #from Configurables import DaVinci from Configurables import PhysConf #if (DaVinci().getProp("Simulation")): if (PhysConf().getProp("Simulation")): from Gaudi.Configuration import allConfigurables for c in allConfigurables.values(): if hasattr(c, "MC_recovery"): c.MC_recovery = True from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(_fixMCDATAConfig)
def __init__(self, name="", TESPrefix='Strip', HDRLocation='Phys/DecReports', Streams=[], DSTStreams=[], MicroDSTStreams=[], GlobalFlavourTagging=True, BadEventSelection=None, AcceptBadEvents=True, MaxCandidates=None, MaxCombinations=None, ActiveMDSTStream=False, Verbose=False): log.info("Initialising StrippingConf " + name) if name == "": self._name = "StrippingGlobal" else: self._name = name self._verbose = Verbose self._activeMDST = ActiveMDSTStream self._streams = [] self._streamSequencers = [] self._sequence = None self._tesPrefix = TESPrefix self._hdrLocation = HDRLocation self.DSTStreams = DSTStreams self.MicroDSTStreams = MicroDSTStreams self._GlobalFlavourTagging = GlobalFlavourTagging self._taggingLocations = [] self._taggingSeq = None self.BadEventSelection = BadEventSelection self.AcceptBadEvents = AcceptBadEvents self.MaxCandidates = MaxCandidates self.MaxCombinations = MaxCombinations ## To be uncommented to limit combinatorics for StandardParticles if self.MaxCandidates != None or self.MaxCombinations != None: self.limitCombForStdParticles() ## Forces the limits on all configurables that implement the option... if self.MaxCandidates != None or self.MaxCombinations != None: self.checkAllForCombLimit() self.checkFlavourTagging(Streams) linesForFT = [] if self._GlobalFlavourTagging: for stream in Streams: for line in stream.lines: if line._EnableFlavourTagging: line._EnableFlavourTagging = False linesForFT += [line] for stream in Streams: self.appendStream(stream) # Global FT locations have to be filled after appending streams, # because outputLocations of lines can be redefined if self._GlobalFlavourTagging: for line in linesForFT: self._taggingLocations += [ line.outputLocation().replace("/Particles", "") ] if self._GlobalFlavourTagging and self._taggingLocations != []: self.appendFlavourTagging() self.checkAppendedLines() self.checkUniqueOutputLocations() if self._verbose: self.checkRawEventRequests() self.checkMDSTFlag() if self._activeMDST: mdstLines = [ line for line in self.activeLines(self.MicroDSTStreams) if line.MDSTFlag ] if self._verbose: mdstLinesNames = [line.name() for line in mdstLines] log.warning("The lines going to MDST.DST are") print mdstLinesNames if mdstLines != []: mdstStream = StrippingStream("MDST", Lines=mdstLines) self.appendStream(mdstStream) else: log.warning( "No line has been selected to go to the MDST stream, thus it will be skipped" ) from Gaudi.Configuration import appendPostConfigAction appendPostConfigAction(defaultToolConfigCheck)
# new feature Liang cdb.UseOracle = True cdb.Online = True else: pass #''' # Marco's workaround from Gaudi.Configuration import appendPostConfigAction from Configurables import CondDBDispatcherSvc, CondDBAccessSvc def oracle_online(): oo = CondDBAccessSvc('ONLINE_ORACLE') oo.ConnectionString = 'CondDBOnline/ONLINE' CondDBDispatcherSvc('MainCondDBReader').Alternatives['/Conditions/Online'] = oo appendPostConfigAction(oracle_online) os.environ['CORAL_DBLOOKUP_PATH'] = os.environ['CORAL_AUTH_PATH'] = '/group/online/condb_viewer' #''' from Configurables import DumpConditions, GaudiSequencer dumpSeq = GaudiSequencer("DumpSequence", Members = [DumpConditions()]) ApplicationMgr().TopAlg = [dumpSeq] ApplicationMgr().ExtSvc += ["IncidentSvc"] ApplicationMgr().EvtSel = "NONE" # Run from GaudiPython.Bindings import AppMgr gaudi = AppMgr() for meth, args in (('initialize' , None), ('run' , [1]), ('stop' , None), ('finalize' , None), ('exit', None)): m = getattr(gaudi, meth)