From c252234dfc098a78db4488897a8976163e1c8e0c Mon Sep 17 00:00:00 2001 From: cantel <claire.antel@gmail.com> Date: Tue, 16 Apr 2019 13:55:13 +0200 Subject: [PATCH] adding LC chains, which needed modifictions in JetRecTools, no longer use JetRecConfig's resolvedependencies, configure all in jetDefs --- .../Root/JetConstituentModSequence.cxx | 3 +- .../TrigUpgradeTest/python/jetDefs.py | 245 +++++++++++------- .../TrigUpgradeTest/python/jetMenuDefs.py | 4 +- .../TrigUpgradeTest/share/full_menu.py | 17 +- 4 files changed, 159 insertions(+), 110 deletions(-) diff --git a/Reconstruction/Jet/JetRecTools/Root/JetConstituentModSequence.cxx b/Reconstruction/Jet/JetRecTools/Root/JetConstituentModSequence.cxx index e2e17de28ffb..dcf5a13bccf8 100644 --- a/Reconstruction/Jet/JetRecTools/Root/JetConstituentModSequence.cxx +++ b/Reconstruction/Jet/JetRecTools/Root/JetConstituentModSequence.cxx @@ -31,10 +31,11 @@ StatusCode JetConstituentModSequence::initialize() { ATH_CHECK( m_modifiers.retrieve() ); - if( m_modifiers.empty() ) { + /*if( m_modifiers.empty() ) { ATH_MSG_ERROR(" empty container !!" ); return StatusCode::FAILURE; } + */ // Set and initialise DataHandleKeys only for the correct input type // Die if the input type is unsupported diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py index ccf34e94f0bf..52b37bfe3d47 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py @@ -6,6 +6,7 @@ from AthenaCommon.AppMgr import ServiceMgr as svcMgr from AthenaCommon.Constants import VERBOSE,DEBUG,INFO from AthenaCommon.CFElements import parOR, seqAND, seqOR, stepSeq +from AthenaCommon.Constants import ERROR, DEBUG def jetAthSequence(ConfigFlags): @@ -34,157 +35,165 @@ def jetAthSequence(ConfigFlags): def jetRecoSequenceEMTopo(calibString, RoIs = 'FSJETRoI'): - from TrigT2CaloCommon.CaloDef import HLTFSTopoRecoSequence - #(caloMakerSequence, caloclusters) = HLTFSTopoRecoSequence(RoIs) - (jetRecoSequence, caloclusters) = HLTFSTopoRecoSequence(RoIs) - - from JetRecConfig.JetDefinition import JetConstit, JetDefinition, xAODType - - #hardcoded jet collection for now - # chosen jet collection calibSeq = "" + dataType = "data" if calibString: calibSeq = calibString.split(":")[1] + dataType = calibString.split(":")[2] + + cellMakerAlgo = _getHLTCellMakerAlgoForJets("cellMaker", RoIs, OutputLevel=ERROR) + topoClusterMakerAlgo = _getHLTTopoClusterMakerAlgoForJets( "topoClusterMaker", inputEDM=cellMakerAlgo.CellsName, OutputLevel=ERROR) - #caloMakerSequence.name = "TrigCaloClusterMakerMT_topo_"+calibSeq + caloMakerSequence = parOR("TopoClusterRecoSequence"+calibSeq, [cellMakerAlgo, topoClusterMakerAlgo]) + caloclusters = topoClusterMakerAlgo.CaloClusters + + from JetRecConfig.JetDefinition import JetConstit, JetDefinition, xAODType, JetModifier + + #hardcoded jet collection for now + # chosen jet collection jetsFullName = "TrigAntiKt4EMTopo"+calibSeq - #clustermods = ["ECPSFrac","ClusterMoments"] - clustermods = [] - trigMinPt = 7e3 + trigMinPt = 7e3 # FIXME : two different values for ptminfilter? TrigEMTopo = JetConstit( xAODType.CaloCluster, ["EM"]) TrigEMTopo.ptmin = 2e3 - TrigEMTopo.ptminfilter = 15e3 + #TrigEMTopo.ptminfilter = 15e3 + TrigEMTopo.ptminfilter = trigMinPt TrigAntiKt4EMTopo = JetDefinition( "AntiKt", 0.4, TrigEMTopo, ptmin=trigMinPt,ptminfilter=trigMinPt) - TrigAntiKt4EMTopo.modifiers = ["Sort"] + clustermods - if calibString: - TrigAntiKt4EMTopo.modifiers= [calibString] + TrigAntiKt4EMTopo.modifiers - TrigAntiKt4EMTopo.isTrigger = True + #TrigAntiKt4EMTopo.modifiers = ["Sort"] + clustermods + #if calibString: + # TrigAntiKt4EMTopo.modifiers= [calibString] + TrigAntiKt4EMTopo.modifiers + TrigAntiKt4EMTopo.isTrigger = True #FIXME : no longer needed since confire CalubTool here? jetDefinition = TrigAntiKt4EMTopo - print("printing jet definition info ") - print(" jet basename = ", jetDefinition.basename) - print(" jet modifiers = ", jetDefinition.modifiers) - print(" calibString = ", calibString) - print(" jets full name = ", jetsFullName) - - from JetRecConfig import JetRecConfig - deps = JetRecConfig.resolveDependencies( jetDefinition ) + #deps = JetRecConfig.resolveDependencies( jetDefinition ) + + modList = [ (JetModifier("JetCaloEnergies", "jetens"), '') ] + modList += [ (JetModifier("JetSorter","jetsort"), '') ] + #deps_mod_tmp = [ modpair for modpair in deps["mods"] if not calibSeq in modpair[1] ] + #deps["mods"] = deps_mod_tmp + if calibString: + from JetCalibTools import JetCalibToolsConfig + jetCalibTool = JetCalibToolsConfig.getJetCalibTool( jetDefinition.basename, calibSeq, dataType ) + modList += [(JetModifier("JetCalibrationTool", jetCalibTool.name()), calibSeq+':'+dataType)] + #jetFilterTool = _getJetFilterTool(TrigEMTopo.ptminfilter) + modList += [ ( JetModifier("JetFilterTool","jetptfilter"), str(int(TrigEMTopo.ptminfilter))) ] - print("TrigAntiKt4EMTopo.modifiers = ", TrigAntiKt4EMTopo.modifiers ) - print("resolved dependencies: ", deps) + print("modList: ", modList) - inputdeps = deps["inputs"] - constit = inputdeps[0] + constit = TrigEMTopo constit.rawname = caloclusters - #constit.inputname = caloclusters print("constit.rawname = ", constit.rawname ) print("constit.inputname = ", constit.inputname ) - constitAlg = getConstitAlg( constit ) - #jetRecoSequence = parOR( "JetRecSeq_"+jetsFullName, [constitAlg]) - jetRecoSequence+= constitAlg + constitAlg = _getConstitAlg( constit ) + jetRecoSequence = parOR( "JetRecSeq_"+jetsFullName, [constitAlg]) - constitPJAlg = getConstitPJGAlg( constit ) + constitPJAlg = _getConstitPJGAlg( constit ) constitPJKey = constitPJAlg.PJGetter.OutputContainer pjs = [constitPJKey] jetRecoSequence += constitPJAlg - if "JetSelectedTracks" in inputdeps or "JetTrackVtxAssoc" in inputdeps: - jetTrkPrepAlg = getTrackPrepAlg( "trigjetalg_TrackPrep") - jetRecoSequence += jetTrkPrepAlg - - eventShapeAlg = getEventShapeAlg( constit, constitPJKey ) + eventShapeAlg = _getEventShapeAlg( constit, constitPJKey ) jetRecoSequence += eventShapeAlg - # Schedule the ghost PseudoJetGetterAlgs - for ghostdef in deps["ghosts"]: + # Schedule the ghost PseudoJetGetterAlgs # FIXME : not needed. + ghostList = [] + for ghostdef in ghostList: print("ghostdef = ", ghostdef) - ghostPJAlg = getGhostPJGAlg( ghostdef ) + ghostPJAlg = _getGhostPJGAlg( ghostdef ) jetRecoSequence += ghostPJAlg ghostPJKey = ghostPJAlg.PJGetter.OutputContainer pjs.append( ghostPJKey ) # Generate a JetAlgorithm to run the jet finding and modifiers # (via a JetRecTool instance). - jetRecAlg = JetRecConfig.getJetAlgorithm(jetsFullName, jetDefinition, pjs, deps["mods"]) + jetRecAlg = JetRecConfig.getJetAlgorithm(jetsFullName, jetDefinition, pjs, modList) jetRecoSequence += jetRecAlg sequenceOut = jetsFullName - #caloMakerSequence += jetRecoSequence + caloMakerSequence += jetRecoSequence + #jetRecoSequence += caloMakerSequence - #jetRecoFullSequence = seqAND("fullJetRecoSequence", [caloMakerSequence, jetRecoSequence]) - #jetRecoFullSequence = caloMakerSequence - jetRecoFullSequence = jetRecoSequence + #jetRecoFullSequence = seqAND("fullJetSeq_"+jetsFullName, [caloMakerSequence, jetRecoSequence]) + jetRecoFullSequence = caloMakerSequence + #jetRecoFullSequence = jetRecoSequence return (jetRecoFullSequence,sequenceOut) def jetRecoSequenceLCW(calibString, RoIs = 'FSJETRoI'): - from TrigT2CaloCommon.CaloDef import HLTLCTopoRecoSequence - (caloMakerSequence, caloclusters) = HLTLCTopoRecoSequence(RoIs) + calibSeq = "" + dataType = "data" + if calibString: + calibSeq = calibString.split(":")[1] + dataType = calibString.split(":")[2] + + cellMakerAlgo = _getHLTCellMakerAlgoForJets("cellMakerLC", RoIs, outputEDM='CaloCellsLC', OutputLevel=ERROR) + topoClusterMakerAlgo = _getHLTTopoClusterMakerAlgoForJets( "topoClusterMakerLC", inputEDM=cellMakerAlgo.CellsName, doLC=True, OutputLevel=ERROR) + + caloMakerSequence = parOR("TopoClusterRecoSequenceLC"+calibSeq, [cellMakerAlgo, topoClusterMakerAlgo]) + caloclusters = topoClusterMakerAlgo.CaloClusters - from JetRecConfig.JetDefinition import JetConstit, JetDefinition, xAODType + from JetRecConfig.JetDefinition import JetConstit, JetDefinition, xAODType, JetModifier #hardcoded jet collection for now # chosen jet collection - calibSeq = "" - if calibString: - calibSeq = calibString.split(":")[1] - jetsFullName = "TrigAntiKt4LCW_"+calibSeq - #clustermods = ["ECPSFrac","ClusterMoments"] - clustermods = [] + jetsFullName = "TrigAntiKt4LCW"+calibSeq trigMinPt = 7e3 TrigLCW = JetConstit( xAODType.CaloCluster, ["LC"]) TrigLCW.ptmin = 2e3 - TrigLCW.ptminfilter = 15e3 + #TrigLCW.ptminfilter = 15e3 + TrigLCW.ptminfilter = trigMinPt TrigAntiKt4LCW = JetDefinition( "AntiKt", 0.4, TrigLCW, ptmin=trigMinPt,ptminfilter=trigMinPt) - TrigAntiKt4LCW.modifiers = ["Sort"] + clustermods - if calibString: - TrigAntiKt4LCW.modifiers+= [calibString] + #TrigAntiKt4LCW.modifiers = ["Sort"] + clustermods TrigAntiKt4LCW.isTrigger = True jetDefinition = TrigAntiKt4LCW from JetRecConfig import JetRecConfig - deps = JetRecConfig.resolveDependencies( jetDefinition ) - inputdeps = deps["inputs"] - constit = inputdeps[0] + modList = [ (JetModifier("JetCaloEnergies", "jetens"), '') ] + modList += [ (JetModifier("JetSorter","jetsort"), '') ] + if calibString: + from JetCalibTools import JetCalibToolsConfig + jetCalibTool = JetCalibToolsConfig.getJetCalibTool( jetDefinition.basename, calibSeq, dataType ) + modList += [(JetModifier("JetCalibrationTool", jetCalibTool.name()), calibSeq+':'+dataType)] + #jetFilterTool = _getJetFilterTool(TrigLCW.ptminfilter) + modList += [ ( JetModifier("JetFilterTool","jetptfilter"), str(int(TrigLCW.ptminfilter))) ] + + print("modList: ", modList) + + constit = TrigLCW constit.rawname = caloclusters - #constit.inputname = caloclusters print("constit.rawname = ", constit.rawname ) print("constit.inputname = ", constit.inputname ) - constitAlg = getConstitAlg( constit ) + constitAlg = _getConstitAlg( constit ) jetRecoSequence = parOR( "JetRecSeq_"+jetsFullName, [constitAlg]) - constitPJAlg = getConstitPJGAlg( constit ) + constitPJAlg = _getConstitPJGAlg( constit ) constitPJKey = constitPJAlg.PJGetter.OutputContainer pjs = [constitPJKey] jetRecoSequence += constitPJAlg - if "JetSelectedTracks" in inputdeps or "JetTrackVtxAssoc" in inputdeps: - jetTrkPrepAlg = getTrackPrepAlg( "trigjetalg_TrackPrep") - jetRecoSequence += jetTrkPrepAlg - - eventShapeAlg = getEventShapeAlg( constit, constitPJKey ) + eventShapeAlg = _getEventShapeAlg( constit, constitPJKey ) jetRecoSequence += eventShapeAlg # Schedule the ghost PseudoJetGetterAlgs - for ghostdef in deps["ghosts"]: + ghostList = [] + for ghostdef in ghostList: print("ghostdef = ", ghostdef) - ghostPJAlg = getGhostPJGAlg( ghostdef ) + ghostPJAlg = _getGhostPJGAlg( ghostdef ) jetRecoSequence += ghostPJAlg ghostPJKey = ghostPJAlg.PJGetter.OutputContainer pjs.append( ghostPJKey ) # Generate a JetAlgorithm to run the jet finding and modifiers # (via a JetRecTool instance). - jetRecAlg = JetRecConfig.getJetAlgorithm(jetsFullName, jetDefinition, pjs, deps["mods"]) + jetRecAlg = JetRecConfig.getJetAlgorithm(jetsFullName, jetDefinition, pjs, modList) jetRecoSequence += jetRecAlg @@ -192,18 +201,17 @@ def jetRecoSequenceLCW(calibString, RoIs = 'FSJETRoI'): caloMakerSequence += jetRecoSequence - #jetRecoFullSequence = seqAND("fullJetRecoSequence", [caloMakerSequence, jetRecoSequence]) jetRecoFullSequence = caloMakerSequence return (jetRecoFullSequence,sequenceOut) -def getConstitAlg( constit ): +def _getConstitAlg( constit ): from JetRecConfig import ConstModHelpers constitalg = ConstModHelpers.getConstitModAlg(constit) return constitalg -def getConstitPJGAlg(basedef): +def _getConstitPJGAlg(basedef): from JetRec import JetRecConf getter = JetRecConf.PseudoJetGetter("pjg_"+basedef.label, @@ -220,7 +228,7 @@ def getConstitPJGAlg(basedef): ) return pjgalg -def getGhostPJGAlg(ghostdef): +def _getGhostPJGAlg(ghostdef): label = "Ghost"+ghostdef.inputtype kwargs = { @@ -259,31 +267,70 @@ def getGhostPJGAlg(ghostdef): ) return pjgalg -def getTrackPrepAlg( trackPrepAlgName ): +def _getTrackPrepAlg( trackPrepAlgName ): - from JetRecTools import JetRecToolsConfig - from JetRec import JetRecConf - # Jet track selection - jettrackselloose = JetRecToolsConfig.getTrackSelTool() - jettvassoc = JetRecToolsConfig.getTrackVertexAssocTool() + from JetRecTools import JetRecToolsConfig + from JetRec import JetRecConf + # Jet track selection + jettrackselloose = JetRecToolsConfig.getTrackSelTool() + jettvassoc = JetRecToolsConfig.getTrackVertexAssocTool() - jettrkprepalg = JetRecConf.JetAlgorithm(trackPrepAlgName) - jettrkprepalg.Tools = [ jettrackselloose, jettvassoc ] + jettrkprepalg = JetRecConf.JetAlgorithm(trackPrepAlgName) + jettrkprepalg.Tools = [ jettrackselloose, jettvassoc ] - return jettrkprepalg + return jettrkprepalg -def getEventShapeAlg( constit, constitpjkey ): +def _getEventShapeAlg( constit, constitpjkey ): - rhokey = "Kt4"+constit.label+"EventShape" - rhotoolname = "EventDensity_Kt4"+constit.label - - from EventShapeTools import EventShapeToolsConf - rhotool = EventShapeToolsConf.EventDensityTool(rhotoolname) - rhotool.InputContainer = constitpjkey - rhotool.OutputContainer = rhokey - - eventshapealg = EventShapeToolsConf.EventDensityAthAlg("{0}Alg".format(rhotoolname)) - eventshapealg.EventDensityTool = rhotool + rhokey = "Kt4"+constit.label+"EventShape" + rhotoolname = "EventDensity_Kt4"+constit.label + + from EventShapeTools import EventShapeToolsConf + rhotool = EventShapeToolsConf.EventDensityTool(rhotoolname) + rhotool.InputContainer = constitpjkey + rhotool.OutputContainer = rhokey + + eventshapealg = EventShapeToolsConf.EventDensityAthAlg("{0}Alg".format(rhotoolname)) + eventshapealg.EventDensityTool = rhotool + + return eventshapealg + +def _getHLTCellMakerAlgoForJets( name, RoIs, outputEDM='CaloCells', OutputLevel=ERROR ): + + from AthenaCommon.AppMgr import ServiceMgr as svcMgr + if not hasattr(svcMgr,'TrigCaloDataAccessSvc'): + from TrigT2CaloCommon.TrigT2CaloCommonConf import TrigCaloDataAccessSvc + svcMgr+=TrigCaloDataAccessSvc() + svcMgr.TrigCaloDataAccessSvc.OutputLevel=ERROR + from AthenaCommon.AppMgr import ServiceMgr as svcMgr + from TrigCaloRec.TrigCaloRecConfig import HLTCaloCellMaker + + inputEDM = RoIs + algo=HLTCaloCellMaker(name) + algo.RoIs=inputEDM + algo.TrigDataAccessMT=svcMgr.TrigCaloDataAccessSvc + algo.OutputLevel=OutputLevel + algo.CellsName=outputEDM + + return algo + +def _getHLTTopoClusterMakerAlgoForJets(name, inputEDM, doLC=False, OutputLevel=ERROR): + + from TrigCaloRec.TrigCaloRecConfig import TrigCaloClusterMakerMT_topo + + algo = TrigCaloClusterMakerMT_topo(name, doMoments=True, doLC=doLC, cells=inputEDM) + algo.CaloClusters="caloclusters" + if doLC: + algo.CaloClusters+="LC" + algo.OutputLevel=OutputLevel + return algo + +def _getJetFilterTool( threshold ): + + from JetRec import JetRecConf + threshold = int(threshold) + jetptfilter = JetRecConf.JetFilterTool("jetptfilter_{0}mev".format(threshold)) + jetptfilter.PtMin = threshold + return jetptfilter - return eventshapealg diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/jetMenuDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/jetMenuDefs.py index 9934ff19fb1f..d40992fbe0fa 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/jetMenuDefs.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/jetMenuDefs.py @@ -4,7 +4,7 @@ from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import RecoFragmentsPool, MenuSequence from AthenaConfiguration.AllConfigFlags import ConfigFlags -def jetMenuSequence(jetdef): +def jetMenuSequence(jetdef, hypoName): """ Function to create the jet Menu Sequence""" ConfigFlags.jetdefinition=jetdef @@ -17,7 +17,7 @@ def jetMenuSequence(jetdef): #hypo from TrigHLTJetHypo.TrigHLTJetHypoConf import TrigJetHypoAlgMT from TrigHLTJetHypo.TrigJetHypoToolConfig import trigJetHypoToolFromDict - hypo = TrigJetHypoAlgMT("TrigJetHypoAlgMT") + hypo = TrigJetHypoAlgMT(hypoName) hypo.Jets = sequenceOut diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu.py b/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu.py index 2c2986ab7050..a4fb1869e6b6 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/full_menu.py @@ -125,24 +125,25 @@ if opt.doMuonSlice == True: if opt.doJetSlice == True: from TrigUpgradeTest.jetMenuDefs import jetMenuSequence - jetSeq1 = jetMenuSequence("EMTopoSubJES") + jetSeq1 = jetMenuSequence("EMTopoSubJES", "TrigJetHypoAlgMT1") step1=ChainStep("Step1_jet", [jetSeq1]) - jetSeq2 = jetMenuSequence("EMTopoSubJESIS") - step2=ChainStep("Step1_jet", [jetSeq2]) - jetSeq3 = jetMenuSequence("EMTopoNoCalib") - step3=ChainStep("Step1_jet", [jetSeq3]) - #jetSeq4 = jetMenuSequence("LCWSubJESIS") - #step4=ChainStep("Step4_jet", [jetSeq4]) + jetSeq2 = jetMenuSequence("EMTopoSubJESIS", "TrigJetHypoAlgMT2") + step2=ChainStep("Step2_jet", [jetSeq2]) + jetSeq3 = jetMenuSequence("EMTopoNoCalib", "TrigJetHypoAlgMT3") + step3=ChainStep("Step3_jet", [jetSeq3]) + jetSeq4 = jetMenuSequence("LCWSubJESIS", "TrigJetHypoAlgMT4") + step4=ChainStep("Step4_jet", [jetSeq4]) # don't forget the commas -.- # damn commas + # raaaargh jetChains = [ Chain(name='HLT_j85', Seed="L1_J20", ChainSteps=[step1] ), Chain(name='HLT_j45', Seed="L1_J20", ChainSteps=[step1] ), Chain(name='HLT_j45_subjes', Seed="L1_J20", ChainSteps=[step2] ), Chain(name='HLT_j45_nojcalib', Seed="L1_J20", ChainSteps=[step3] ), - #Chain(name='HLT_j45_lcw', Seed="L1_J20", ChainSteps=[step4] ) + Chain(name='HLT_j45_lcw', Seed="L1_J20", ChainSteps=[step4] ) ] testChains += jetChains -- GitLab