diff --git a/Reconstruction/Jet/JetMonitoring/python/JetMonitoringConfig.py b/Reconstruction/Jet/JetMonitoring/python/JetMonitoringConfig.py index 0928e8fa6e067de157111b98db40c3651941b0df..8cedc71a23f3c041af828fb435147d6fa7ee23c8 100644 --- a/Reconstruction/Jet/JetMonitoring/python/JetMonitoringConfig.py +++ b/Reconstruction/Jet/JetMonitoring/python/JetMonitoringConfig.py @@ -165,10 +165,12 @@ class ToolSpec(ConfigDict): klass = getattr(CompFactory,conf.pop('klass')) # remove 'klass' conf.pop('name') conf.pop('topLevelDir',None) + conf.pop('bottomLevelDir',None) conf.pop('defineHistoFunc',None) # not used here. for k, v in six.iteritems (conf): if isinstance(v,ToolSpec): v.topLevelDir = self.topLevelDir + v.bottomLevelDir = self.bottomLevelDir conf[k] = v.toTool() if isinstance(v,list): if v == []: continue @@ -177,6 +179,7 @@ class ToolSpec(ConfigDict): toolInstances = [] for toolSpec in v: toolSpec.topLevelDir=self.topLevelDir + toolSpec.bottomLevelDir=self.bottomLevelDir toolInstances.append( toolSpec.toTool() ) conf[k] = toolInstances return klass(**conf) @@ -214,6 +217,7 @@ class VarSpec(ToolSpec): def toTool(self): from AthenaConfiguration.ComponentFactory import CompFactory self.pop('topLevelDir', None) + self.pop('bottomLevelDir', None) return CompFactory.JetHistoVarTool(self.Name, **self) def vname(self): @@ -344,7 +348,8 @@ class HistoSpec(ToolSpec): hargs.update( **self.hargs) # overwrite by user-given args if any # we create one group for each histoFiller : self.groupName() are unique within a JetMonitoringAlg - group = monhelper.addGroup(parentAlg, self.groupName(), self.topLevelDir+parentAlg.JetContainerName) + bottomLevelDir = self.bottomLevelDir if self.bottomLevelDir != '' else parentAlg.JetContainerName + group = monhelper.addGroup(parentAlg, self.groupName(), self.topLevelDir+bottomLevelDir) # define the variables used by this tool # we encode as 'varx,vary;alias' as requested ny standard monitoring config, see @@ -420,12 +425,14 @@ class SelectSpec(ToolSpec): selTool = CompFactory.JetHistoSelectSort(self.name, SelectedIndex=self.get('SelectedIndex',-1)) if hasattr(self,'Selector'): self.Selector.topLevelDir = self.topLevelDir + self.Selector.bottomLevelDir = self.bottomLevelDir selTool.Selector = self.Selector.toTool() if hasattr(self, 'SortVariable'): selTool.SortVariable = retrieveVarToolConf(self.SortVariable) suffix = '_'+self.name for i,tconf in enumerate(self.FillerTools): tconf.topLevelDir = self.topLevelDir + tconf.bottomLevelDir = self.bottomLevelDir tconf = tconf.clone(newname=tconf.name+suffix) self.FillerTools[i] = tconf # re-assign the modified conf so it's consistently re-used elsewhere selTool.FillerTools += [ tconf.toTool() ] # assign a configured tool to the JetHistoSelectSort instance @@ -460,6 +467,7 @@ class JetMonAlgSpec(ConfigDict): self.name = name args.setdefault('FillerTools',[]) args.setdefault('topLevelDir', 'Jets/') + args.setdefault('bottomLevelDir', '') ConfigDict.__init__(self, defaultPath=defaultPath, TriggerChain=TriggerChain, **args) tmpL = self.FillerTools self.FillerTools = [] @@ -479,6 +487,7 @@ class JetMonAlgSpec(ConfigDict): tools = [] for tconf in self.FillerTools: tconf.topLevelDir = self.topLevelDir + tconf.bottomLevelDir = self.bottomLevelDir tools.append( tconf.toTool( )) tconf.defineHisto(alg, monhelper, path) alg.FillerTools = tools diff --git a/Trigger/TrigMonitoring/TrigHLTMonitoring/python/TrigHLTMonitorAlgorithm.py b/Trigger/TrigMonitoring/TrigHLTMonitoring/python/TrigHLTMonitorAlgorithm.py index 3aea8ce783c1b7d4eaa850d7fb73fcf4a7640141..07cc2d9efa69bc8f5faec9fe176935f9d1b1e172 100644 --- a/Trigger/TrigMonitoring/TrigHLTMonitoring/python/TrigHLTMonitorAlgorithm.py +++ b/Trigger/TrigMonitoring/TrigHLTMonitoring/python/TrigHLTMonitorAlgorithm.py @@ -16,6 +16,7 @@ def createHLTDQConfigFlags(): acf.addFlag('DQ.Steering.HLT.doGeneral', True) acf.addFlag('DQ.Steering.HLT.doEgamma', True) acf.addFlag('DQ.Steering.HLT.doMET', True) + acf.addFlag('DQ.Steering.HLT.doJet', True) acf.addFlag('DQ.Steering.HLT.doBjet', True) acf.addFlag('DQ.Steering.HLT.doCalo', True) acf.addFlag('DQ.Steering.HLT.doMuon', True) @@ -49,6 +50,10 @@ def TrigHLTMonTopConfig(inputFlags): from TrigMETMonitoring.TrigMETMonitorAlgorithm import TrigMETMonConfig result.merge(TrigMETMonConfig(inputFlags)) + if inputFlags.DQ.Steering.HLT.doJet: + from TrigJetMonitoring.TrigJetMonitorAlgorithm import TrigJetMonConfig + result.merge(TrigJetMonConfig(inputFlags)) + if inputFlags.DQ.Steering.HLT.doBjet: from TrigBjetMonitoring.TrigBjetMonitorAlgorithm import TrigBjetMonConfig result.merge(TrigBjetMonConfig(inputFlags)) diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetCollRemapping.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetCollRemapping.py new file mode 100644 index 0000000000000000000000000000000000000000..cd67696182a74692f7f2379f9ef0ad1b3b1685fd --- /dev/null +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetCollRemapping.py @@ -0,0 +1,7 @@ +# Corresponding Run 3 jet collection name for each Run 2 jet collection +JetCollRun2ToRun3 = { + 'HLT_xAOD__JetContainer_a4tcemsubjesISFS' : 'HLT_AntiKt4EMTopoJets_subjesIS', # default small-R + 'HLT_xAOD__JetContainer_a10r_tcemsubjesISFS': 'HLT_AntiKt10JetRCJets_subjesIS', # a10r + 'HLT_xAOD__JetContainer_a10tclcwsubjesFS' : 'HLT_AntiKt10LCTopoJets_subjes', # a10 + 'HLT_xAOD__JetContainer_a10ttclcwjesFS' : 'HLT_AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets_jes', # a10t +} diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py index 452d3ae677f9f41efcb691de8cc6fcc5db653e19..d65f8119528e814ddfb3b724ea715833202a170b 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py @@ -56,12 +56,53 @@ Chain2JetCollDict['Legacy'] = { } from JetMonitoring.JetMonitoringConfig import JetMonAlgSpec, HistoSpec, SelectSpec, ToolSpec +from AthenaConfiguration.AllConfigFlags import ConfigFlags + +def TrigJetMonConfig(inputFlags): + + # The following class will make a sequence, configure algorithms, and link + # them to GenericMonitoringTools + from AthenaMonitoring import AthMonitorCfgHelper + helper = AthMonitorCfgHelper(inputFlags,'TrigJetMonitorAlgorithm') + + # This is the right place to get the info, but the autoconfig of the flag + # is not yet implemented + AthenaMT = ConfigFlags.Trigger.EDMDecodingVersion==3 + + # AthenaMT or Legacy + InputType = 'MT' if AthenaMT else 'Legacy' + + # Loop over offline jet collections + for jetcoll in OfflineJetCollections: + offlineMonitorConf = jetMonitoringConfig(inputFlags,jetcoll,AthenaMT) + offlineMonitorConf.toAlg(helper) + + # Loop over HLT jet collections + for jetcoll in JetCollections[InputType]: + monitorConf = jetMonitoringConfig(inputFlags,jetcoll,AthenaMT) + # then we turn the full specification into properly configured algorithm and tools. + # we use the method 'toAlg()' defined for the specialized dictionnary 'JetMonAlgSpec' + monitorConf.toAlg(helper) + + # Loop over HLT jet chains + for chain,jetcoll in Chain2JetCollDict[InputType].iteritems(): + chainMonitorConf = jetChainMonitoringConfig(inputFlags,jetcoll,chain,AthenaMT) + chainMonitorConf.toAlg(helper) + + # the AthMonitorCfgHelper returns an accumulator to be used by the general configuration system. + return helper.result() # Basic selection of histograms common for online and offline jets -def basicJetMonAlgSpec(jetcoll,isOnline): +def basicJetMonAlgSpec(jetcoll,isOnline,athenaMT): # we use a specialized dictionnary (JetMonAlgSpec) which will be translated into the final C++ tool path = 'NoTriggerSelection' if isOnline else 'standardHistos/' - Conf = JetMonAlgSpec(jetcoll+"Mon",JetContainerName = jetcoll, defaultPath = path) + + # Remap online Run 2 jet collections + from TrigJetMonitoring import JetCollRemapping + jetcollFolder = jetcoll + if jetcoll in JetCollRemapping.JetCollRun2ToRun3 and not athenaMT: + jetcollFolder = JetCollRemapping.JetCollRun2ToRun3[jetcoll] + Conf = JetMonAlgSpec(jetcoll+"Mon",JetContainerName = jetcoll, defaultPath = path, topLevelDir="HLT/JetMon/", bottomLevelDir=jetcollFolder) # Now start filling the histo spec list Conf.appendHistos( @@ -112,6 +153,7 @@ def basicJetMonAlgSpec(jetcoll,isOnline): # "pt", # ] ), ) + return Conf # Additional histograms for offline jets @@ -132,19 +174,12 @@ ExtraSmallROnlineHists = [ ExtraLargeROnlineHists = [ ] -def jetMonitoringConfig(inputFlags,jetcoll): +def jetMonitoringConfig(inputFlags,jetcoll,athenaMT): '''Function to configures some algorithms in the monitoring system.''' - ### STEP 1 ### - # The following class will make a sequence, configure algorithms, and link - # them to GenericMonitoringTools - from AthenaMonitoring import AthMonitorCfgHelper - helper = AthMonitorCfgHelper(inputFlags,jetcoll+'AthMonitorCfg') - - ### STEP 2 ### # Declare a configuration dictionnary for a JetContainer isOnline = True if 'HLT' in jetcoll else False - conf = basicJetMonAlgSpec(jetcoll,isOnline) + conf = basicJetMonAlgSpec(jetcoll,isOnline,athenaMT) if isOnline: if 'AntiKt4' in jetcoll: for hist in ExtraSmallROnlineHists: conf.appendHistos(hist) @@ -153,24 +188,16 @@ def jetMonitoringConfig(inputFlags,jetcoll): else: # offline for hist in ExtraOfflineHists: conf.appendHistos(hist) - # then we turn the full specification into properly configured algorithm and tools. - # we use the method 'toAlg()' defined for the specialized dictionnary 'JetMonAlgSpec' - conf.toAlg(helper) + return conf - return helper.result() # the AthMonitorCfgHelper returns an accumulator to be used by the general configuration system. - -def jetChainMonitoringConfig(inputFlags,jetcoll,chain): +def jetChainMonitoringConfig(inputFlags,jetcoll,chain,athenaMT): '''Function to configures some algorithms in the monitoring system.''' - ### STEP 1 ### - # The following class will make a sequence, configure algorithms, and link - # them to GenericMonitoringTools - from AthenaMonitoring import AthMonitorCfgHelper - helper = AthMonitorCfgHelper(inputFlags,chain+'AthMonitorCfg') - - ### STEP 2 ### - # Declare a configuration dictionnary for a JetContainer - #from JetMonitoring.JetMonitoringConfig import JetMonAlgSpec, HistoSpec, SelectSpec, ToolSpec + # Remap online Run 2 jet collections + from TrigJetMonitoring import JetCollRemapping + jetcollFolder = jetcoll + if jetcoll in JetCollRemapping.JetCollRun2ToRun3 and not athenaMT: + jetcollFolder = JetCollRemapping.JetCollRun2ToRun3[jetcoll] # We schedule a new JetAlg which will be acting only when a TriggerChain fired (using the TriggerChain from the base classes). # We'll plot 1 histo build by a dedicated JetHistoTriggEfficiency tool. @@ -179,7 +206,7 @@ def jetChainMonitoringConfig(inputFlags,jetcoll,chain): # this is done here. def defineHistoForJetTrigg(conf, parentAlg, monhelper , path): # create a monitoring group with the histo path starting from the parentAlg - group = monhelper.addGroup(parentAlg, conf.Group, 'Jets/'+jetcoll+'/') + group = monhelper.addGroup(parentAlg, conf.Group, conf.topLevelDir+jetcollFolder+'/') # define the histogram group.defineHistogram('trigPassed,jetVar',title='titletrig', type="TEfficiency", path=chain, xbins=100 , xmin=0, xmax=500000. ,) @@ -189,6 +216,8 @@ def jetChainMonitoringConfig(inputFlags,jetcoll,chain): JetContainerName = jetcoll, TriggerChain = chain, defaultPath = chain, + topLevelDir="HLT/JetMon/", + bottomLevelDir=jetcollFolder, ) trigConf.appendHistos( "pt", @@ -222,9 +251,7 @@ def jetChainMonitoringConfig(inputFlags,jetcoll,chain): ] ), ) - trigConf.toAlg(helper) - - return helper.result() # the AthMonitorCfgHelper returns an accumulator to be used by the general configuration system. + return trigConf if __name__=='__main__': @@ -260,7 +287,6 @@ if __name__=='__main__': log.setLevel(INFO) # Set the Athena configuration flags - from AthenaConfiguration.AllConfigFlags import ConfigFlags ConfigFlags.Input.Files = [inputFile] ConfigFlags.Input.isMC = True ConfigFlags.Output.HISTFileName = 'AthenaMTMonitorOutput.root' if AthenaMT else 'LegacyMonitoringOutput.root' @@ -272,22 +298,31 @@ if __name__=='__main__': cfg = MainServicesSerialCfg() cfg.merge(PoolReadCfg(ConfigFlags)) - # Loop over offline jet collections - for jetcoll in OfflineJetCollections: - offlineMonitorAcc = jetMonitoringConfig(ConfigFlags,jetcoll) - cfg.merge(offlineMonitorAcc) - + # The following class will make a sequence, configure algorithms, and link + # them to GenericMonitoringTools + from AthenaMonitoring import AthMonitorCfgHelper + helper = AthMonitorCfgHelper(ConfigFlags,'TrigJetMonitorAlgorithm') + # AthenaMT or Legacy InputType = 'MT' if AthenaMT else 'Legacy' + # Loop over offline jet collections + for jetcoll in OfflineJetCollections: + offlineMonitorConf = jetMonitoringConfig(ConfigFlags,jetcoll,AthenaMT) + offlineMonitorConf.toAlg(helper) + # Loop over HLT jet collections for jetcoll in JetCollections[InputType]: - monitorAcc = jetMonitoringConfig(ConfigFlags,jetcoll) - cfg.merge(monitorAcc) + monitorConf = jetMonitoringConfig(ConfigFlags,jetcoll,AthenaMT) + # then we turn the full specification into properly configured algorithm and tools. + # we use the method 'toAlg()' defined for the specialized dictionnary 'JetMonAlgSpec' + monitorConf.toAlg(helper) # Loop over HLT jet chains for chain,jetcoll in Chain2JetCollDict[InputType].iteritems(): - monitorAcc = jetChainMonitoringConfig(ConfigFlags,jetcoll,chain) - cfg.merge(monitorAcc) + chainMonitorConf = jetChainMonitoringConfig(ConfigFlags,jetcoll,chain,AthenaMT) + chainMonitorConf.toAlg(helper) + + cfg.merge(helper.result()) cfg.run()