############################################################################### # (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # # # # In applying this licence, CERN does not waive the privileges and immunities # # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### from DAQSys.Decoders import DecoderDB l0du = DecoderDB["L0DUDecoder/L0DUFromRaw"] l0du.Properties["SpammySpamSpam"] = False wasset = [] for k, d in DecoderDB.iteritems(): if d == l0du: continue if "SpammySpamSpam" in d.Properties: wasset.append(k) if len(wasset): raise KeyError("Setting a property also accidentally set a property for" + wasset.__str__()) print "Pass"
from Gaudi.Configuration import * from Configurables import DecodeRawEvent from DAQSys.Decoders import DecoderDB for i,v in DecoderDB.iteritems(): v.Properties["OutputLevel"]=VERBOSE if "Hlt" in i and "ReportsDecoder" in i: v.Active=False #v.Inputs={"InputRawEventLocation":"DAQ/RawEvent"} for b in ["UT","FT","FTCluster","VP","VL"]: if b in v.Banks: v.Active=False DecoderDB["MuonRec"].Active=False DecodeRawEvent().OverrideInputs=999 from Configurables import GaudiSequencer #DecodeRawEvent().Sequencer=GaudiSequencer("SPAM") for i,v in DecoderDB.iteritems(): if v.Active: GaudiSequencer("SPAM").Members.append(v.setup()) from Configurables import StoreExplorerAlg StoreExplorerAlg().Load=True ApplicationMgr().TopAlg=[GaudiSequencer("SPAM"),StoreExplorerAlg()]
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
from Gaudi.Configuration import * from Configurables import DecodeRawEvent, LHCbApp from Configurables import GaudiSequencer LHCbApp() mySeq = GaudiSequencer("Decoding") mySeq.OutputLevel = VERBOSE DecodeRawEvent().Sequencer = mySeq ApplicationMgr().TopAlg = [mySeq] from DAQSys.DecoderClass import decodersForBank from DAQSys.Decoders import DecoderDB as ddb #only calo banks for k, v in ddb.iteritems(): v.Active = False flagged = [] for b in ["PrsE", "EcalE", "HcalE", "ODIN"]: for d in decodersForBank(ddb, b, ignoreActive=True, addRequired=True): flagged.append(d) for k, v in ddb.iteritems(): if v not in flagged: v.Active = False #configure L0TCKs importOptions('$L0TCK/L0DUConfig.opts')
import DAQSys from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import validate validate(DecoderDB) for k, v in DecoderDB.items(): if v.Active: if len(v.listInputs()) == 0: raise ValueError("Decoder " + v.FullName + " input location unknown.") for l in v.listInputs(): if not len(l): raise ValueError("Zero length default for input " + v.FullName) if len(v.listOutputs()) == 0: raise ValueError("Decoder " + v.FullName + " output location unknown.") for l in v.listOutputs(): if not len(l): raise ValueError("Zero length default for output " + v.FullName) if len(v.Banks) == 0: raise ValueError("Decoder " + v.FullName + " banks unknown.") #check the setup for k, decoder in DecoderDB.items(): if decoder.Active: decoder.setup() #add an alg already into the DoD with the default name dec = None
def configureSequences(self): # Check for special data options for option in self.getProp('SpecialData'): if option not in self.KnownSpecialData: raise RunTimeError("Unknown SpecialData option '%s'" % option) escherSeq = GaudiSequencer("EscherSequencer") #escherSeq.Context = self.getProp("Context") ApplicationMgr().TopAlg = [escherSeq] mainSeq = self.getProp("MainSequence") if len(mainSeq) == 0: self.MainSequence = self.DefaultSequence mainSeq = self.MainSequence escherSeq.Members += mainSeq ProcessPhase("Init").DetectorList += self.getProp("InitSequence") ProcessPhase("Init").Context = self.getProp("Context") from Configurables import RecInit, TrackSys log.info("Setting up alignment sequence") recInit = RecInit(name="EscherInit", PrintFreq=self.getProp("PrintFreq")) GaudiSequencer("InitEscherSeq").Members += [recInit] # set up the HltFilterSeq from Configurables import HltCompositionMonitor from Configurables import LoKi__HDRFilter as HDRFilter hltFilterSeq = GaudiSequencer("HltFilterSeq") from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank from itertools import chain hltdecs = [DecoderDB.get("HltDecReportsDecoder/Hlt1DecReportsDecoder")] if not self.getProp("OnlineMode"): ## HLT2 decreports are only used offline. hltdecs += [ DecoderDB.get("HltDecReportsDecoder/Hlt2DecReportsDecoder") ] hltFilterSeq.Members = [d.setup() for d in hltdecs] ## FIXME: These lines should go back in as soon as an easy to use filter ## FIXME: is available that works for HLT1 and HLT2 decreports at the same time. ## identifies events that are not of type Hlt1ErrorEvent or Hlt2ErrorEvent ## hltErrCode = "HLT_PASS_RE('Hlt1(?!ErrorEvent).*Decision') & HLT_PASS_RE('Hlt2(?!ErrorEvent).*Decision')" ## hltErrorFilter = HDRFilter('HltErrorFilter', Code = hltErrCode ) # the filter ## hltFilterSeq.Members += [ HltCompositionMonitor(), hltErrorFilter ] ## add more hlt filters, if requested ## if hasattr(self,"HltFilterCode") and len(self.getProp("HltFilterCode"))>0: ## hltfilter = HDRFilter ( 'HLTFilter', ## Code = self.getProp("HltFilterCode")) ## hltfilter.Preambulo += [ "from LoKiCore.functions import *" ] ## hltFilterSeq.Members += [ hltfilter ] # in Escher we'll always use the DOD ApplicationMgr().ExtSvc += ["DataOnDemandSvc"] alignSeq = GaudiSequencer("AlignSequence") # if the patter reco is not run, we need the DataOnDemand svc # so that e.g. the track container(s) is unpacked: if not GaudiSequencer("RecoTrSeq").getProp("Enable"): DstConf(EnableUnpack=True) # Setup tracking sequence trackConf = TrackSys() self.setOtherProps(trackConf, [ "SpecialData", "OutputType", "DataType", "Simulation", "GlobalCuts" ]) trackConf.ExpertTracking = self.getProp("ExpertTracking") ta = TAlignment() ta.Upgrade = self.getProp("Upgrade") self.setOtherProps(ta, ["DatasetName", "OnlineMode", "OnlineAligWorkDir"]) ta.Sequencer = alignSeq if self.getProp("Millepede"): log.info("Using Millepede type alignment!") self.setProp("Incident", "GlobalMPedeFit") ta.Method = "Millepede" ta.Sequencer = GaudiSequencer("MpedeAlignSeq")