From 1258c7c884d07d677cb3eaf1b21029036f6ff7b3 Mon Sep 17 00:00:00 2001
From: Edson Carquin Lopez <edson.carquin.lopez@cern.ch>
Date: Fri, 19 Mar 2021 16:30:39 +0000
Subject: [PATCH] Make ptonly a single step chain

---
 .../src/TrigTauMonitorAlgorithm.cxx           |  4 +-
 .../share/ref_RDOtoRDOTrig_v1Dev_build.ref    | 32 ++---------
 .../share/ref_data_v1Dev_build.ref            | 20 +------
 .../Tau/TauChainConfiguration.py              | 46 ++++++----------
 .../HLTMenuConfig/Tau/TauMenuSequences.py     | 54 ++++---------------
 .../HLTMenuConfig/Tau/TauRecoSequences.py     | 32 +----------
 6 files changed, 36 insertions(+), 152 deletions(-)

diff --git a/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.cxx b/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.cxx
index 19b62ba09ead..d72ca78de80b 100644
--- a/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.cxx
+++ b/Trigger/TrigMonitoring/TrigTauMonitoring/src/TrigTauMonitorAlgorithm.cxx
@@ -111,7 +111,7 @@ StatusCode TrigTauMonitorAlgorithm::executeNavigation( const EventContext& ctx,
   std::string tauContainerName = "HLT_TrigTauRecMerged_Precision";
   if(trigItem.find("EF_")!=std::string::npos || trigItem.find("MVA_")!=std::string::npos || trigItem.find("MVABDT_")!=std::string::npos) {
      tauContainerName="HLT_TrigTauRecMerged_MVA";
-  }
+  }else if(trigItem.find("ptonly") != std::string::npos) tauContainerName="HLT_TrigTauRecMerged_CaloOnly";
 
   for(const auto Tau : *offTaus ){
 
@@ -186,7 +186,7 @@ void TrigTauMonitorAlgorithm::fillDistributions(const EventContext& ctx, std::ve
   std::string tauContainerName = "HLT_TrigTauRecMerged_Precision";
   if(trigger.find("EF_")!=std::string::npos || trigger.find("MVA_")!=std::string::npos || trigger.find("MVABDT_")!=std::string::npos){ 
       tauContainerName="HLT_TrigTauRecMerged_MVA";
-  }
+  }else if(trigger.find("ptonly") != std::string::npos) tauContainerName="HLT_TrigTauRecMerged_CaloOnly";
 
   ATH_MSG_DEBUG("Tau ContainerName is: " << tauContainerName);
 
diff --git a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
index 64b7fc2f5a8b..f2c3002970e4 100644
--- a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
+++ b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
@@ -3763,29 +3763,17 @@ HLT_noalg_mb_L1RD2_EMPTY:
 HLT_noalg_zb_L1ZB:
   eventCount: 0
 HLT_tau0_perf_ptonly_L1TAU12:
-  eventCount: 15
+  eventCount: 18
   stepCounts:
     0: 18
-    1: 16
-    2: 16
-    3: 15
   stepFeatures:
     0: 42
-    1: 24
-    2: 24
-    3: 21
 HLT_tau0_perf_ptonly_L1TAU60:
-  eventCount: 2
+  eventCount: 5
   stepCounts:
     0: 5
-    1: 3
-    2: 3
-    3: 2
   stepFeatures:
     0: 6
-    1: 3
-    2: 3
-    3: 2
 HLT_tau160_idperf_ptonly_L1TAU100:
   eventCount: 0
 HLT_tau160_idperf_track_L1TAU100:
@@ -3851,17 +3839,11 @@ HLT_tau200_mediumRNN_tracktwoMVA_L1TAU100:
 HLT_tau200_mediumRNN_tracktwo_L1TAU100:
   eventCount: 0
 HLT_tau25_idperf_ptonly_L1TAU12IM:
-  eventCount: 11
+  eventCount: 14
   stepCounts:
     0: 14
-    1: 11
-    2: 11
-    3: 11
   stepFeatures:
     0: 24
-    1: 15
-    2: 15
-    3: 15
 HLT_tau25_idperf_track_L1TAU12IM:
   eventCount: 11
   stepCounts:
@@ -4241,17 +4223,11 @@ HLT_tau25_tightRNN_tracktwo_L1TAU12IM:
     1: 14
     2: 8
 HLT_tau35_idperf_ptonly_L1TAU12IM:
-  eventCount: 11
+  eventCount: 14
   stepCounts:
     0: 14
-    1: 11
-    2: 11
-    3: 11
   stepFeatures:
     0: 24
-    1: 15
-    2: 15
-    3: 15
 HLT_tau35_idperf_track_L1TAU12IM:
   eventCount: 11
   stepCounts:
diff --git a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
index d13ee9100c26..91eb2c163a7c 100644
--- a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
+++ b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
@@ -2239,17 +2239,11 @@ HLT_noalg_mb_L1RD2_EMPTY:
 HLT_noalg_zb_L1ZB:
   eventCount: 20
 HLT_tau0_perf_ptonly_L1TAU12:
-  eventCount: 3
+  eventCount: 4
   stepCounts:
     0: 4
-    1: 4
-    2: 4
-    3: 3
   stepFeatures:
     0: 5
-    1: 4
-    2: 4
-    3: 3
 HLT_tau0_perf_ptonly_L1TAU60:
   eventCount: 0
 HLT_tau160_idperf_ptonly_L1TAU100:
@@ -2320,14 +2314,8 @@ HLT_tau25_idperf_ptonly_L1TAU12IM:
   eventCount: 3
   stepCounts:
     0: 3
-    1: 3
-    2: 3
-    3: 3
   stepFeatures:
     0: 4
-    1: 3
-    2: 3
-    3: 3
 HLT_tau25_idperf_track_L1TAU12IM:
   eventCount: 3
   stepCounts:
@@ -2710,14 +2698,8 @@ HLT_tau35_idperf_ptonly_L1TAU12IM:
   eventCount: 3
   stepCounts:
     0: 3
-    1: 3
-    2: 3
-    3: 3
   stepFeatures:
     0: 4
-    1: 3
-    2: 3
-    3: 3
 HLT_tau35_idperf_track_L1TAU12IM:
   eventCount: 3
   stepCounts:
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauChainConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauChainConfiguration.py
index 2978c2b5fa27..cd6a1eee4893 100755
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauChainConfiguration.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauChainConfiguration.py
@@ -11,9 +11,7 @@ log = logging.getLogger("TriggerMenuMT.HLTMenuConfig.Tau.TauChainConfiguration")
 
 from TriggerMenuMT.HLTMenuConfig.Menu.ChainConfigurationBase import ChainConfigurationBase
 
-from TriggerMenuMT.HLTMenuConfig.Tau.TauMenuSequences import tauCaloMenuSeq, tauCaloMVAMenuSeq, tauFTFTauSeq, tauFTFTauCoreSeq, tauFTFTauIsoSeq, tauFTFTauIsoBDTSeq, tauIDPrecSeq, tauTrackPrecSeq, tauTrackTwoPrecSeq, tauTrackTwoEFSeq, tauTrackTwoMVASeq, tauPreSelSeq, tauPreSelTTSeq, tauPrecTrackSeq, tauPrecTrackIsoSeq
-
-from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool, defineHistogram
+from TriggerMenuMT.HLTMenuConfig.Tau.TauMenuSequences import tauCaloMenuSeq, tauCaloMVAMenuSeq, tauFTFTauSeq, tauFTFTauCoreSeq, tauFTFTauIsoSeq, tauFTFTauIsoBDTSeq, tauTrackPrecSeq, tauTrackTwoPrecSeq, tauTrackTwoEFSeq, tauTrackTwoMVASeq, tauPreSelSeq, tauPreSelTTSeq, tauPrecTrackSeq, tauPrecTrackIsoSeq
 
 #--------------------------------------------------------
 # fragments generating config will be functions in new JO
@@ -36,9 +34,6 @@ def getFTFIsoCfg(flags):
 def getFTFIsoBDTCfg(flags):
     return tauFTFTauIsoBDTSeq()
 
-def getIDPrecCfg(flags):
-    return tauIDPrecSeq()
-
 def getTrackPrecCfg(flags):
     return tauTrackPrecSeq()
 
@@ -63,18 +58,6 @@ def getPrecTrackCfg(flags):
 def getPrecTrackIsoCfg(flags):
     return tauPrecTrackIsoSeq()
 
-# this must be moved to the HypoTool file:                                                                                                 
-def TrigTauXComboHypoToolFromDict(chainDict):
-    from TrigTauHypo.TrigTauHypoConf import TrigTauXComboHypoTool
-    name = chainDict['chainName']
-    monTool = GenericMonitoringTool("MonTool_"+name)
-    monTool.Histograms = [defineHistogram('dROfAccepted', type='TH1F', path='EXPERT', title="dR in accepted combinations [MeV]", xbins=50, xmin=0, xmax=5.)]
-    monTool.Histograms = [defineHistogram('dROfProcessed', type='TH1F', path='EXPERT', title="dR in accepted combinations [MeV]", xbins=50, xmin=0, xmax=5.)]
-    tool= TrigTauXComboHypoTool(name)
-    monTool.HistPath = 'EgammaMassHypo/'+tool.getName()
-    tool.MonTool = monTool
-    return tool
-
 ############################################# 
 ###  Class/function to configure muon chains 
 #############################################
@@ -95,7 +78,7 @@ class TauChainConfiguration(ChainConfigurationBase):
         # define here the names of the steps and obtain the chainStep configuration 
         # --------------------
         stepDictionary = {
-            "ptonly"        :['getCaloSeq'   , 'getFTFTau'  , 'getTrkEmpty' , 'getTauEmpty'  , 'getPrecTrack'    , 'getIDPrec'      ], 
+            "ptonly"        :['getCaloSeq'   , 'getFTFEmpty', 'getTrkEmpty' , 'getTauEmpty'  , 'getPTEmpty'      , 'getIDEmpty'      ], 
             "track"         :['getCaloSeq'   , 'getFTFTau'  , 'getTrkEmpty' , 'getPreSel'    , 'getPrecTrack'    , 'getTrackPrec'   ], 
             "tracktwo"      :['getCaloSeq'   , 'getFTFCore' , 'getFTFIso'   , 'getPreSelTT'  , 'getPrecTrackIso' , 'getTrackTwoPrec'],
             "tracktwoEF"    :['getCaloSeq'   , 'getFTFCore' , 'getFTFIso'   , 'getTauEmpty'  , 'getPrecTrackIso' , 'getTrackTwoEF'  ],
@@ -134,6 +117,11 @@ class TauChainConfiguration(ChainConfigurationBase):
         stepName = 'FTFCore_tau'
         return self.getStep(2,stepName, [getFTFCoreCfg])
 
+    # --------------------                                                                                                                                   
+    def getFTFEmpty(self):
+        stepName = 'FTFEmpty_tau'
+        return self.getEmptyStep(2,stepName)
+
     # --------------------                                                                                                      
     def getFTFIso(self):
         stepName = 'FTFIso_tau'
@@ -174,10 +162,10 @@ class TauChainConfiguration(ChainConfigurationBase):
         stepName = 'PrecTrkIso_tau'
         return self.getStep(5,stepName,[getPrecTrackIsoCfg])
 
-    # --------------------                                                                                                       
-    def getIDPrec(self):
-        stepName = 'IDPrec_tau'
-        return self.getStep(6,stepName, [getIDPrecCfg])
+    # --------------------                                                                                                                                   
+    def getPTEmpty(self):
+        stepName = 'PTEmpty_tau'
+        return self.getEmptyStep(5,stepName)
 
     # --------------------                                                                                                       
     def getTrackPrec(self):
@@ -196,10 +184,10 @@ class TauChainConfiguration(ChainConfigurationBase):
 
     # --------------------                                                                                                      
     def getTrackTwoMVA(self):
+        stepName = "TrkTwoMVA_tau"
+        return self.getStep(6,stepName,[getTrackTwoMVACfg])
 
-        #if "03dRtt" in self.chainName:
-        #    stepName = "TauLep_Combo"
-        #    return self.getStep(6,stepName,sequenceCfgArray=[getTrackTwoMVACfg], comboTools=[TrigTauXComboHypoToolFromDict])
-        #else:
-            stepName = "TrkTwoMVA_tau"
-            return self.getStep(6,stepName,[getTrackTwoMVACfg])
+    # --------------------                                                                                                                                   
+    def getIDEmpty(self):
+        stepName = 'IDEmpty_tau'
+        return self.getEmptyStep(6,stepName)
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauMenuSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauMenuSequences.py
index c53fce12f241..813f012f5ebc 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauMenuSequences.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauMenuSequences.py
@@ -1,5 +1,5 @@
 #
-#  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+#  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 #
 
 from AthenaConfiguration.AllConfigFlags import ConfigFlags
@@ -7,22 +7,7 @@ from AthenaConfiguration.AllConfigFlags import ConfigFlags
 # menu components   
 from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import MenuSequence, RecoFragmentsPool
 
-from TriggerMenuMT.HLTMenuConfig.Tau.TauRecoSequences import tauCaloSequence, tauCaloMVASequence, tauFTFCoreSequence, tauFTFTauSequence, tauFTFIsoSequence, tauFTFIsoBDTSequence, tauIDSequence, tauTrackSequence, tauTrackTwoSequence, tauEFSequence, tauMVASequence, tauPreSelSequence, tauPreSelTTSequence, tauPrecTrackSequence, tauPrecIsoTrackSequence
-
-# ====================================================================================================  
-#    Get MenuSequences
-# ==================================================================================================== 
-
-"""def getTauSequence( step ):
-    if step == "calo":
-        return tauCaloMenuSequence("Tau")
-    if step == "calo_mva":
-        return tauCaloMVAMenuSequence("Tau")
-    if step == "track_twostep_core":
-        return tauTwoStepTrackSeqCore()
-    if step == "track_twostep_iso":
-        return tauTwoStepTrackSeqIso()
-    return None"""
+from TriggerMenuMT.HLTMenuConfig.Tau.TauRecoSequences import tauCaloSequence, tauCaloMVASequence, tauFTFCoreSequence, tauFTFTauSequence, tauFTFIsoSequence, tauFTFIsoBDTSequence, tauTrackSequence, tauTrackTwoSequence, tauEFSequence, tauMVASequence, tauPreSelSequence, tauPreSelTTSequence, tauPrecTrackSequence, tauPrecIsoTrackSequence
 
 # ===============================================================================================
 #      Calo step
@@ -82,7 +67,7 @@ def tauFTFTauCoreSeq():
 
 
 # ===============================================================================================                                                     
-#    Fast track finder (tau) + Dummy Hypo step (ptOnly, track)                                                                            
+#    Fast track finder (tau) + Dummy Hypo step (track)                                                                            
 # ===============================================================================================                                                          
   
 def tauFTFTauSeq():
@@ -120,9 +105,9 @@ def tauFTFTauIsoSeq():
                           Hypo        = fastTrkHypo,
                           HypoToolGen = TrigTauTrackHypoToolFromDict )
 
-# ===============================================================================================                                                                                                  
-#   Fast track finder (iso bdt) + Dummy Hypo step (tracktwoMVABDT)                                                                                                                                 
-# ===============================================================================================                                                                                                  
+# ===============================================================================================                                                            
+#   Fast track finder (iso bdt) + Dummy Hypo step (tracktwoMVABDT)                                                                                           
+# ===============================================================================================                                 
 
 def tauFTFTauIsoBDTSeq():
     (sequence, ftfIsoBDTViewsMaker, sequenceOut) = RecoFragmentsPool.retrieve(tauFTFIsoBDTSequence,ConfigFlags )
@@ -140,25 +125,6 @@ def tauFTFTauIsoBDTSeq():
                           HypoToolGen = TrigTauTrackHypoToolFromDict )
 
 
-# ===============================================================================================
-#     Precision tracking + Tau Precision Alg + EFMVHypo step   (pTonly)
-# ===============================================================================================
-
-def tauIDPrecSeq():
-    (sequence, tauIDViewsMaker, sequenceOut) = RecoFragmentsPool.retrieve(tauIDSequence,ConfigFlags )
-
-    from TrigTauHypo.TrigTauHypoConf import  TrigEFTauMVHypoAlgMT
-    precisionHypo = TrigEFTauMVHypoAlgMT("EFTauMVHypoId")
-    precisionHypo.taujetcontainer = sequenceOut
-
-    from TrigTauHypo.TrigTauHypoTool import TrigEFTauMVHypoToolFromDict
-
-    return  MenuSequence( Sequence    = sequence,
-                          Maker       = tauIDViewsMaker,
-                          Hypo        = precisionHypo,
-                          HypoToolGen = TrigEFTauMVHypoToolFromDict )
-
-
 # ===============================================================================================                                
 #     Tau Preselection Alg + Precision Tracking + Tau Precision Alg + EFMVHypo step  (track)                                                                 
 # ===============================================================================================
@@ -232,7 +198,7 @@ def tauTrackTwoMVASeq():
                           HypoToolGen = TrigEFTauMVHypoToolFromDict )
 
 # ===============================================================================================                                                            
-#     Tau Preselection + EFMVHypo step   (track, tracktwo)                                                                             
+#     Tau Preselection + EFMVHypo step   (track)                                                                             
 # =============================================================================================== 
 
 
@@ -251,7 +217,7 @@ def tauPreSelSeq():
                           HypoToolGen = TrigEFTauMVHypoToolFromDict )
 
 # ===============================================================================================                                                            
-#     Tau Preselection + EFMVHypo step   (track, tracktwo)                                                                                                   
+#     Tau Preselection + EFMVHypo step   (tracktwo)                                                                                                   
 # ===============================================================================================                                                            
 
 
@@ -289,8 +255,8 @@ def tauPrecTrackSeq():
                           HypoToolGen = TrigTrkPrecHypoToolFromDict )
 
 # ===============================================================================================                                                            
-#     Precision Tracking + TrkPrecHypo step   (tracktwoMVA)                                                                                                  
-# ===============================================================================================                                                             
+#     Precision Tracking + TrkPrecHypo step   (tracktwoMVABDT)                                                                                               
+# ===============================================================================================                                                           
 
 def tauPrecTrackIsoSeq():
     (sequence, precTrackViewsMaker, sequenceOut) = RecoFragmentsPool.retrieve(tauPrecIsoTrackSequence,ConfigFlags )
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauRecoSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauRecoSequences.py
index bb147908ca16..8a088f6653cf 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauRecoSequences.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Tau/TauRecoSequences.py
@@ -1,5 +1,5 @@
 #
-#  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+#  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 #
 
 from AthenaCommon.CFElements import parOR, seqAND
@@ -35,9 +35,6 @@ def _getTauSignatureShort( name ):
     elif "TrackTwo" in name:
       signature = 'tauTrkTwo'
       signatureID = 'tauIso'
-    elif "tauId" in name:
-      signature = 'tauId'
-      signatureID = 'tauTau'
     elif "EF" in name:
       signature = 'tauEF'
       signatureID = 'tauIso'
@@ -278,9 +275,7 @@ def tauIdSequence( RoIs, name):
 
     tauPrecisionAlg = ""
 
-    if "Id" in name:
-      tauPrecisionAlg = _algoTauPrecision(inputRoIs = RoIs, tracks = IDTrigConfig.PT.tracksPT(), step = "Id")
-    elif "TrackInView" in name:
+    if "TrackInView" in name:
       tauPrecisionAlg = _algoTauPrecision(inputRoIs = RoIs, tracks = IDTrigConfig.PT.tracksPT(), step = "Track")
       ViewVerifyId.DataObjects += [( 'xAOD::TauTrackContainer' , 'StoreGateSvc+HLT_tautrack_Presel'),
                                    ( 'xAOD::TauJetContainer' , 'StoreGateSvc+HLT_TrigTauRecMerged_Presel' )]
@@ -570,29 +565,6 @@ def tauPrecIsoTrackSequence(ConfigFlags):
     tauPrecIsoTrkSequence = seqAND("tauPrecIsoTrkSequence", [tauPrecIsoViewsMaker, tauPrecIsoTrackInViewSequence ])
     return (tauPrecIsoTrkSequence, tauPrecIsoViewsMaker, sequenceOut)
 
-
-# ===============================================================================================                                                           
-#   Reco sequence for Tau Precision Alg   (pTonly) 
-# ===============================================================================================      
-
-def tauIDSequence(ConfigFlags):
-
-    RecoSequenceName                  = "tauIdInViewSequence"
-
-    ftfIdViewsMaker                   = EventViewCreatorAlgorithm("IMFTFId")
-    ftfIdViewsMaker.RoIsLink          = "roi"
-    ftfIdViewsMaker.RoITool           = ViewCreatorPreviousROITool()
-    ftfIdViewsMaker.InViewRoIs        = "RoiForTau"
-    ftfIdViewsMaker.Views             = "TAUFTFIdViews"
-    ftfIdViewsMaker.ViewFallThrough   = True
-    ftfIdViewsMaker.RequireParentView = True
-    ftfIdViewsMaker.ViewNodeName      = RecoSequenceName
-
-    (tauFTFIdInViewSequence, sequenceOut) = tauIdSequence( ftfIdViewsMaker.InViewRoIs, RecoSequenceName)
-
-    tauFastTrackIdSequence = seqAND("tauFastTrackIdSequence", [ftfIdViewsMaker, tauFTFIdInViewSequence ])
-    return (tauFastTrackIdSequence, ftfIdViewsMaker, sequenceOut)
-
 # ===============================================================================================                                                            
 #    Reco sequence for Tau Precision Alg   (track)                                                              
 # ===============================================================================================  
-- 
GitLab