From 6e1ceafb3410ea4fff27407fd99ad18e7bd3c49a Mon Sep 17 00:00:00 2001 From: Bertrand Martin <martindl@cern.ch> Date: Wed, 1 May 2019 11:07:08 +0200 Subject: [PATCH] Apply HLT tau thinning only when trigger collections are present Hello, This is a fix to solve the ART test failure for SUSY3 and TAUP3. The problem comes from the HLT tau thinning (!22992) which is meant to work only for post-TS1 data18 and special MC16e trigger samples. While in ART, the data file is pre-TS1 and the MC file is AODSLIM, so there are some broken element links, and the thinning fails. The implemented workaround consists in retrieving the run number for data, and the AMITag for MC, and enable the thinning only when relevant. When I have time, I will improve the robustness of DerivationFrameworkSUSY/src/TauTracksThinning.cxx, and check the validity of element links before accessing them. Cheers, Bertrand --- .../DerivationFrameworkSUSY/share/SUSY3.py | 68 ++++++++++++------- .../DerivationFrameworkTau/share/TAUP3.py | 62 +++++++++++------ 2 files changed, 85 insertions(+), 45 deletions(-) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkSUSY/share/SUSY3.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkSUSY/share/SUSY3.py index 827f573fac65..f47e00972a77 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkSUSY/share/SUSY3.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkSUSY/share/SUSY3.py @@ -89,29 +89,52 @@ SUSY3TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name ToolSvc += SUSY3TauTPThinningTool thinningTools.append(SUSY3TauTPThinningTool) + # ------------------------------------------------------------------------------------------------------------------------------------------ # For tau trigger performance studies -# no TrackParticleThinning can be applied to HLT taus, we need all tau tracks for RNN ID, not only core tracks - -# TauTracks thinning -from DerivationFrameworkSUSY.DerivationFrameworkSUSYConf import DerivationFramework__TauTracksThinning -SUSY3HLTTauTracksThinningTool = DerivationFramework__TauTracksThinning(name = "SUSY3HLTTauTracksThinningTool", - ThinningService = SUSY3ThinningHelper.ThinningSvc(), - TauKey = "HLT_xAOD__TauJetContainer_TrigTauRecMerged", - TauTracksKey = "HLT_xAOD__TauTrackContainer_TrigTauRecMergedTracks", - IDTracksKey = "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_IDTrig") -ToolSvc += SUSY3HLTTauTracksThinningTool -thinningTools.append(SUSY3HLTTauTracksThinningTool) - -# Jet Calo Cluster thinning, need all clusters from HLT tau seed jet for RNN ID -from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__JetCaloClusterThinning -SUSY3HLTTauCCThinningTool = DerivationFramework__JetCaloClusterThinning( name = "SUSY3HLTTauCCThinningTool", - ThinningService = SUSY3ThinningHelper.ThinningSvc(), - SGKey = "HLT_xAOD__JetContainer_TrigTauJet", - TopoClCollectionSGKey = "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMaker") -ToolSvc += SUSY3HLTTauCCThinningTool -thinningTools.append(SUSY3HLTTauCCThinningTool) +import sys +import PyUtils.AthFile +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +from AthenaCommon import Logging +susy3log = Logging.logging.getLogger('SUSY3') + +thinHLTTau = False +try: + fileinfo = PyUtils.AthFile.fopen(athenaCommonFlags.FilesInput()[0]) + RunNumber = fileinfo.infos['run_number'][0] + AMITag = fileinfo.infos['metadata']['/TagInfo']['AMITag'] + + if not DerivationFrameworkIsMonteCarlo and RunNumber >= 355261 or DerivationFrameworkIsMonteCarlo and 'r11364' in AMITag: + thinHLTTau = True + if DerivationFrameworkIsMonteCarlo: + susy3log.info("AMITag = {0}, HLT tau thinning = {1}".format(AMITag,thinHLTTau)) + else: + susy3log.info("RunNumber = {0}, HLT tau thinning = {1}".format(RunNumber,thinHLTTau)) +except: + susy3log.info("Encountered problem while parsing metadata") + +if thinHLTTau: + # no TrackParticleThinning can be applied to HLT taus, we need all tau tracks for RNN ID, not only core tracks + + # TauTracks thinning + from DerivationFrameworkSUSY.DerivationFrameworkSUSYConf import DerivationFramework__TauTracksThinning + SUSY3HLTTauTracksThinningTool = DerivationFramework__TauTracksThinning(name = "SUSY3HLTTauTracksThinningTool", + ThinningService = SUSY3ThinningHelper.ThinningSvc(), + TauKey = "HLT_xAOD__TauJetContainer_TrigTauRecMerged", + TauTracksKey = "HLT_xAOD__TauTrackContainer_TrigTauRecMergedTracks", + IDTracksKey = "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_IDTrig") + ToolSvc += SUSY3HLTTauTracksThinningTool + thinningTools.append(SUSY3HLTTauTracksThinningTool) + + # Jet Calo Cluster thinning, need all clusters from HLT tau seed jet for RNN ID + from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__JetCaloClusterThinning + SUSY3HLTTauCCThinningTool = DerivationFramework__JetCaloClusterThinning( name = "SUSY3HLTTauCCThinningTool", + ThinningService = SUSY3ThinningHelper.ThinningSvc(), + SGKey = "HLT_xAOD__JetContainer_TrigTauJet", + TopoClCollectionSGKey = "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMaker") + ToolSvc += SUSY3HLTTauCCThinningTool + thinningTools.append(SUSY3HLTTauCCThinningTool) # ------------------------------------------------------------------------------------------------------------------------------------------ @@ -164,11 +187,6 @@ TauBDT = '(TauJets.nTracks == 1 || TauJets.nTracks == 3) && (TauJets.DFCommonTau # prepare for RNN Tau ID, JetRNNSigLoose not available yet in DFTau, need to cut on the flattened score TauRNN = '(TauJets.nTracks == 1 && TauJets.RNNJetScoreSigTrans>0.15) || (TauJets.nTracks == 3 && TauJets.RNNJetScoreSigTrans>0.25)' -import sys -import PyUtils.AthFile -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -from AthenaCommon import Logging -susy3log = Logging.logging.getLogger('SUSY3') useRNN = False # RNN ID present in offline reconstruction for Athena-21.0.63 or higher try: diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py index 8bc26a8c1d12..2c66d3fe53e9 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py @@ -126,26 +126,48 @@ thinningTools.append(TAUP3TauTPThinningTool) # ------------------------------------------------------------------------------------------------------------------------------------------ # For tau trigger performance studies -# no TrackParticleThinning can be applied to HLT taus, we need all tau tracks for RNN ID, not only core tracks - -# TauTracks thinning -from DerivationFrameworkSUSY.DerivationFrameworkSUSYConf import DerivationFramework__TauTracksThinning -TAUP3HLTTauTracksThinningTool = DerivationFramework__TauTracksThinning(name = "TAUP3HLTTauTracksThinningTool", - ThinningService = "TAUP3ThinningSvc", - TauKey = "HLT_xAOD__TauJetContainer_TrigTauRecMerged", - TauTracksKey = "HLT_xAOD__TauTrackContainer_TrigTauRecMergedTracks", - IDTracksKey = "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_IDTrig") -ToolSvc += TAUP3HLTTauTracksThinningTool -thinningTools.append(TAUP3HLTTauTracksThinningTool) - -# Jet Calo Cluster thinning, need all clusters from HLT tau seed jet for RNN ID -from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__JetCaloClusterThinning -TAUP3HLTTauCCThinningTool = DerivationFramework__JetCaloClusterThinning( name = "TAUP3HLTTauCCThinningTool", - ThinningService = "TAUP3ThinningSvc", - SGKey = "HLT_xAOD__JetContainer_TrigTauJet", - TopoClCollectionSGKey = "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMaker") -ToolSvc += TAUP3HLTTauCCThinningTool -thinningTools.append(TAUP3HLTTauCCThinningTool) +import sys +import PyUtils.AthFile +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +from AthenaCommon import Logging +taup3log = Logging.logging.getLogger('TAUP3') + +thinHLTTau = False +try: + fileinfo = PyUtils.AthFile.fopen(athenaCommonFlags.FilesInput()[0]) + RunNumber = fileinfo.infos['run_number'][0] + AMITag = fileinfo.infos['metadata']['/TagInfo']['AMITag'] + + if not DerivationFrameworkIsMonteCarlo and RunNumber >= 355261 or DerivationFrameworkIsMonteCarlo and 'r11364' in AMITag: + thinHLTTau = True + if DerivationFrameworkIsMonteCarlo: + taup3log.info("AMITag = {0}, HLT tau thinning = {1}".format(AMITag,thinHLTTau)) + else: + taup3log.info("RunNumber = {0}, HLT tau thinning = {1}".format(RunNumber,thinHLTTau)) +except: + taup3log.info("Encountered problem while parsing metadata") + +if thinHLTTau: + # no TrackParticleThinning can be applied to HLT taus, we need all tau tracks for RNN ID, not only core tracks + + # TauTracks thinning + from DerivationFrameworkSUSY.DerivationFrameworkSUSYConf import DerivationFramework__TauTracksThinning + TAUP3HLTTauTracksThinningTool = DerivationFramework__TauTracksThinning(name = "TAUP3HLTTauTracksThinningTool", + ThinningService = "TAUP3ThinningSvc", + TauKey = "HLT_xAOD__TauJetContainer_TrigTauRecMerged", + TauTracksKey = "HLT_xAOD__TauTrackContainer_TrigTauRecMergedTracks", + IDTracksKey = "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_IDTrig") + ToolSvc += TAUP3HLTTauTracksThinningTool + thinningTools.append(TAUP3HLTTauTracksThinningTool) + + # Jet Calo Cluster thinning, need all clusters from HLT tau seed jet for RNN ID + from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__JetCaloClusterThinning + TAUP3HLTTauCCThinningTool = DerivationFramework__JetCaloClusterThinning( name = "TAUP3HLTTauCCThinningTool", + ThinningService = "TAUP3ThinningSvc", + SGKey = "HLT_xAOD__JetContainer_TrigTauJet", + TopoClCollectionSGKey = "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMaker") + ToolSvc += TAUP3HLTTauCCThinningTool + thinningTools.append(TAUP3HLTTauCCThinningTool) # ------------------------------------------------------------------------------------------------------------------------------------------ -- GitLab