def getElectronIsEMSelector(calibPath): from AthenaCommon.AppMgr import ToolSvc calibname = calibPath.split('/')[-1] configList = [ calibPath + "/ElectronIsEMTightSelectorCutDefs.conf", calibPath + "/ElectronIsEMMediumSelectorCutDefs.conf", calibPath + "/ElectronIsEMLooseSelectorCutDefs.conf", calibPath + "/ElectronIsEMVLooseSelectorCutDefs.conf" ] asgTools = [] mask = [ SelectionDefElectron.ElectronTightHLT, SelectionDefElectron.ElectronMediumHLT, SelectionDefElectron.ElectronLooseHLT, SelectionDefElectron.ElectronLooseHLT ] for idx, config in enumerate(configList): name = config.split('/')[-1].replace('.conf', '_HLT_' + calibname) asg = CfgMgr.AsgElectronIsEMSelector(name) asg.isEMMask = mask[idx] asg.ConfigFile = config ToolSvc += asg asgTools.append(asg) return asgTools
def ConfiguredAsgElectronIsEMSelector(name, quality, menu=electronPIDmenu.menuDC14, **kw): """ Configure the AsgElectronIsEMSelector with the quality cuts and allow for (re-)setting of all provided cuts. """ try: ntuple = ElectronIsEMMap(quality, menu) except KeyError: sys.stderr.write( "Electron quality not found. Please use an egammaIDQuality (ElectronPhotonSelectorTools/egammaPIDdefs.h).\n This function only supports standard electron IDs, and not photon or forward IDs\n" ) raise # Get the label for user data tmpName = (ntuple[1]).func_name labelName = "is" + ((tmpName.split("Selector")[0]).split("IsEM")[1]) # Create and instance of the tool tool = CfgMgr.AsgElectronIsEMSelector(name, **kw) # Configure it with the standard configuration ntuple[1](tool) tool.isEMMask = ntuple[0] # Get all provided properties and overwrite the default values with them SetToolProperties(tool, **kw) #print tool return tool
def TrigEgammaMonTool(): #from AthenaCommon.AppMgr import ToolSvc from AthenaCommon import CfgMgr from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronIsEMSelector from ElectronPhotonSelectorTools.ElectronIsEMSelectorMapping import ElectronIsEMMap,electronPIDmenu from TrigEgammaAnalysisTools.TrigEgammaAnalysisToolsConfig import TrigEgammaNavAnalysisTool,TrigEgammaNavTPAnalysisTool,TrigEgammaNavTPJpsieeAnalysisTool from TrigEgammaAnalysisTools.TrigEgammaProbelist import default,defaultJpsi # to import probelist #from TrigHLTMonitoring.HLTMonTriggerList import hltmonList # import MaM trigger list, not available!!!! # Import full trigger menu, requires setup of both MC and Physics # Makes available all possible triggers which can be in any dataset # Set final list from triggers available in data import TriggerMenu.menu.Physics_pp_v5 as physics_menu from TriggerJobOpts.TriggerFlags import TriggerFlags # Offline selectors -- taken from latest conf # Offline tunes for 50 ns LooseElectronSelector=CfgMgr.AsgElectronIsEMSelector("LooseElectron50nsSelector") LooseElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150429/ElectronIsEMLooseSelectorCutDefs.conf" ToolSvc+=LooseElectronSelector MediumElectronSelector=CfgMgr.AsgElectronIsEMSelector("MediumElectron50nsSelector") MediumElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150429/ElectronIsEMMediumSelectorCutDefs.conf" ToolSvc+=MediumElectronSelector TightElectronSelector=CfgMgr.AsgElectronIsEMSelector("TightElectron50nsSelector") TightElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150429/ElectronIsEMTightSelectorCutDefs.conf" ToolSvc+=TightElectronSelector LooseLHSelector=CfgMgr.AsgElectronLikelihoodTool("LooseLH50nsSelector") LooseLHSelector.ConfigFile="ElectronPhotonSelectorTools/offline/mc15_20150429/ElectronLikelihoodLooseOfflineConfig2015.conf" ToolSvc+=LooseLHSelector MediumLHSelector=CfgMgr.AsgElectronLikelihoodTool("MediumLH50nsSelector") MediumLHSelector.ConfigFile="ElectronPhotonSelectorTools/offline/mc15_20150429/ElectronLikelihoodMediumOfflineConfig2015.conf" ToolSvc+=MediumLHSelector TightLHSelector=CfgMgr.AsgElectronLikelihoodTool("TightLH50nsSelector") TightLHSelector.ConfigFile="ElectronPhotonSelectorTools/offline/mc15_20150429/ElectronLikelihoodTightOfflineConfig2015.conf" ToolSvc+=TightLHSelector physics_menu.setupMenu() egammaMenu = TriggerFlags.EgammaSlice.signatures() egammaChains = [] l1Items = [] addItems = [] for egchain in egammaMenu: egammaChains.append(egchain[0]) l1Items.append(egchain[1]) addItems.append(egchain[3]) # Set list to full menu #probelist = egammaChains probelist = default Jpsiprobelist = defaultJpsi #probelist=['e5_loose_idperf','e5_lhloose_idperf','e0_perf_L1EM15','g0_perf_L1EM15'] basePath = '/HLT/Egamma/' tagItems = ['e24_lhmedium_iloose_L1EM18VH', 'e24_lhmedium_iloose_L1EM20VH', 'e24_lhtight_iloose', 'e26_lhtight_iloose', # Primary cut-based electron triggers 'e24_medium_iloose_L1EM18VH', 'e24_medium_iloose_L1EM20VH', 'e24_tight_iloose', 'e26_tight_iloose'] JpsitagItems = ['e5_tight_e4_etcut', 'e9_tight_e4_etcut', 'e14_tight_e4_etcut', 'e9_etcut_e5_tight', 'e14_etcut_e5_tight', # Primary cut-based electron triggers 'e5_tight_e4_etcut_Jpsiee', 'e9_tight_e4_etcut_Jpsiee', 'e14_tight_e4_etcut_Jpsiee', 'e9_etcut_e5_tight_Jpsiee', 'e14_etcut_e5_tight_Jpsiee'] Analysis = TrigEgammaNavAnalysisTool(name='NavAnalysis', DirectoryPath=basePath+'Analysis', TriggerList=probelist, ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector], ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], File="", OutputLevel=0,DetailedHistograms=False) TPAnalysis = TrigEgammaNavTPAnalysisTool(name='NavTPAnalysis', DirectoryPath=basePath+'TPAnalysis', TriggerList=probelist, ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector], ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], File="", TagTriggerList=tagItems, RemoveCrack=False, OutputLevel=0,DetailedHistograms=True) JpsiTPAnalysis = TrigEgammaNavTPJpsieeAnalysisTool(name='NavTPJpsieeAnalysis', DirectoryPath=basePath+'TPJpsieeAnalysis', TriggerList=Jpsiprobelist, File="", TagTriggerList= JpsitagItems, RemoveCrack=True, ZeeLowerMass=2, ZeeUpperMass=5, OfflineTagMinEt=5, OfflineProbeMinEt=5, OutputLevel=0, DetailedHistograms=False, doJpsiee=True) from TrigEgammaAnalysisTools.TrigEgammaAnalysisToolsConf import TrigEgammaMonTool TrigEgammaMonTool = TrigEgammaMonTool( name = "TrigEgammaMonTool", histoPathBase=basePath, Tools=["TrigEgammaNavAnalysisTool/NavAnalysis", "TrigEgammaNavTPAnalysisTool/NavTPAnalysis", "TrigEgammaNavTPAnalysisTool/NavTPJpsieeAnalysis"])
def ElectronPidTools(): #from AthenaCommon.AppMgr import ToolSvc # Run1 selectors -- added directly to ToolSvc from default config via mapping #print '=========== Run1 PID ============' for key in ElectronToolName: if not ('lh' in key): if ('1' in key): tool = ConfiguredAsgElectronIsEMSelector( ElectronToolName[key], ElectronPidName[key], electronPIDmenu.menuTrig2012) addToToolSvc(tool) # Trigger specific Run1 selectors for high pt triggers #print '=========== Run1 PID trigger specific ============' for key in ElectronHypoToolName: if not ('lh' in key): if ('1' in key): tool = ConfiguredAsgElectronIsEMSelector( ElectronHypoToolName[key], ElectronPidName[key], electronPIDmenu.menuTrig2012) tool.trigEtTh = 20000 addToToolSvc(tool) # Calo only Run1 selectors #print '=========== Run1 PID Calo============' for key in ElectronCaloToolName: if not ('lh' in key): if ('1' in key): tool = ConfiguredAsgElectronIsEMSelector( ElectronCaloToolName[key], ElectronPidName[key], electronPIDmenu.menuTrig2012) tool.caloOnly = True addToToolSvc(tool) # Calo-only Trigger specific with trigEtTh property set #print '=========== Run1 PID Calo trigger specific ============' for key in ElectronCaloHypoToolName: if not ('lh' in key): if ('1' in key): tool = ConfiguredAsgElectronIsEMSelector( ElectronCaloHypoToolName[key], ElectronPidName[key], electronPIDmenu.menuTrig2012) tool.caloOnly = True tool.trigEtTh = 20000 addToToolSvc(tool) # Versioned selectors for Run2 #print '=========== Run2 PID ============' for key in ElectronToolName: if not ('lh' in key): if not ('1' in key): tool = CfgMgr.AsgElectronIsEMSelector(ElectronToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronToolConfigFile[key] tool.isEMMask = ElectronIsEMBits[key] addToToolSvc(tool) # Trigger specific Run2 selectors #print '=========== Run2 PID trigger specific ============' for key in ElectronHypoToolName: if not ('lh' in key): if not ('1' in key): tool = CfgMgr.AsgElectronIsEMSelector( ElectronHypoToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronToolConfigFile[key] tool.isEMMask = ElectronIsEMBits[key] tool.trigEtTh = 20000 addToToolSvc(tool) # Calo-only selectors #print '=========== Run2 PID Calo============' for key in ElectronCaloToolName: if not ('lh' in key): if not ('1' in key): tool = CfgMgr.AsgElectronIsEMSelector( ElectronCaloToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronCaloToolConfigFile[ key] tool.isEMMask = ElectronIsEMBits[key] tool.caloOnly = True addToToolSvc(tool) # Calo-only trigger specific selectors #print '=========== Run2 PID Calo trigger specific ============' for key in ElectronCaloHypoToolName: if not ('lh' in key): if not ('1' in key): tool = CfgMgr.AsgElectronIsEMSelector( ElectronCaloHypoToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronCaloToolConfigFile[ key] tool.isEMMask = ElectronIsEMBits[key] tool.caloOnly = True tool.trigEtTh = 20000 addToToolSvc(tool) # LH selectors #print '======== LH selectors ===========' for key in ElectronToolName: if ('lh' in key): tool = CfgMgr.AsgElectronLikelihoodTool(ElectronToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool) # Special LH triggers for alignment / commisioning for key in ElectronLHVLooseToolName: tool = CfgMgr.AsgElectronLikelihoodTool(ElectronLHVLooseToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronLHVLooseToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool) for key in ElectronLHLooseToolName: tool = CfgMgr.AsgElectronLikelihoodTool(ElectronLHLooseToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronLHLooseToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool) for key in ElectronLHMediumToolName: tool = CfgMgr.AsgElectronLikelihoodTool(ElectronLHMediumToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronLHMediumToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool) for key in ElectronLHTightToolName: tool = CfgMgr.AsgElectronLikelihoodTool(ElectronLHTightToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronLHTightToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool) # Calo-only LH selectors #print '======== LH Calo selectors ===========' for key in ElectronCaloToolName: if ('lh' in key): tool = CfgMgr.AsgElectronLikelihoodTool(ElectronCaloToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronCaloToolConfigFile[key] tool.usePVContainer = False tool.caloOnly = True addToToolSvc(tool)
def ElectronPidTools(): # Versioned selectors for Run2 #print '=========== Run2 PID ============' for key in ElectronToolName: if ('lh' in key): tool = CfgMgr.AsgElectronLikelihoodTool(ElectronToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool) elif ('bloose' in key): tool = CfgMgr.AsgElectronIsEMSelector(ElectronToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronToolConfigFile[ 'loose'] # use loose isEMconfig for all bloose settings and just change isEM bit tool.isEMMask = BLooseISEMBits[key] addToToolSvc(tool) else: tool = CfgMgr.AsgElectronIsEMSelector(ElectronToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronToolConfigFile[key] tool.isEMMask = ElectronIsEMBits[key] addToToolSvc(tool) # Calo-only selectors #print '=========== Run2 PID Calo============' for key in ElectronCaloToolName: if ('lh' in key): tool = CfgMgr.AsgElectronLikelihoodTool(ElectronCaloToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronCaloToolConfigFile[key] tool.usePVContainer = False tool.caloOnly = True addToToolSvc(tool) elif ('bloose' in key): tool = CfgMgr.AsgElectronIsEMSelector(ElectronCaloToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronCaloToolConfigFile[ 'loose'] # use loose isEMconfig for all bloose settings and just change isEM bit tool.caloOnly = True tool.isEMMask = BLooseISEMBits[key] addToToolSvc(tool) else: tool = CfgMgr.AsgElectronIsEMSelector(ElectronCaloToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronCaloToolConfigFile[key] tool.isEMMask = ElectronIsEMBits[key] tool.caloOnly = True addToToolSvc(tool) # Special LH triggers for alignment / commisioning for key in ElectronLHVLooseToolName: tool = CfgMgr.AsgElectronLikelihoodTool(ElectronLHVLooseToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronLHVLooseToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool) for key in ElectronLHLooseToolName: tool = CfgMgr.AsgElectronLikelihoodTool(ElectronLHLooseToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronLHLooseToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool) for key in ElectronLHMediumToolName: tool = CfgMgr.AsgElectronLikelihoodTool(ElectronLHMediumToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronLHMediumToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool) for key in ElectronLHTightToolName: tool = CfgMgr.AsgElectronLikelihoodTool(ElectronLHTightToolName[key]) tool.ConfigFile = ConfigFilePath + ElectronLHTightToolConfigFile[key] tool.usePVContainer = False addToToolSvc(tool)
cppyy.loadDictionary('ElectronPhotonSelectorToolsDict') from ROOT import LikeEnum from ROOT import egammaPID # Following loads the online selectors from TrigEgammaHypo.TrigEgammaPidTools import ElectronPidTools from TrigEgammaHypo.TrigEgammaPidTools import PhotonPidTools from TrigEgammaHypo.TrigEgammaPidTools import ElectronToolName ElectronPidTools() PhotonPidTools() from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronIsEMSelector, AsgElectronLikelihoodTool from ElectronPhotonSelectorTools.ElectronIsEMSelectorMapping import ElectronIsEMMap, electronPIDmenu # Offline selectors -- taken from latest conf LooseElectronSelector = CfgMgr.AsgElectronIsEMSelector( "T0HLTLooseElectronSelector") MediumElectronSelector = CfgMgr.AsgElectronIsEMSelector( "T0HLTMediumElectronSelector") TightElectronSelector = CfgMgr.AsgElectronIsEMSelector( "T0HLTTightElectronSelector") LooseLHSelector = CfgMgr.AsgElectronLikelihoodTool("T0HLTLooseLHSelector") MediumLHSelector = CfgMgr.AsgElectronLikelihoodTool("T0HLTMediumLHSelector") TightLHSelector = CfgMgr.AsgElectronLikelihoodTool("T0HLTTightLHSelector") VeryLooseLHSelector = CfgMgr.AsgElectronLikelihoodTool( "T0HLTVeryLooseLHSelector") # MediumLHHISelector = CfgMgr.AsgElectronLikelihoodTool("T0HLTMediumLHHISelector") # see the configuration calib paths below LooseElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/ElectronIsEMLooseSelectorCutDefs.conf" MediumElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/ElectronIsEMMediumSelectorCutDefs.conf" TightElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/ElectronIsEMTightSelectorCutDefs.conf"