From 63c3d2b45e959119bd3b5aa048c76cbede25cf37 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <Frank.Winklmeier@cern.ch>
Date: Wed, 11 May 2016 13:26:57 +0200
Subject: [PATCH] Ignore events in the abort gap and also check RoIB overflows
 (ATR-12285) (TrigDetCalib-01-02-16)

	* src/TrigL1CaloOverflow.cxx: Ignore events in the abort gap and also check RoIB overflows (ATR-12285)
	* TrigDetCalib-01-02-16


Former-commit-id: b8725a14bca5ff181d2f8302c1f036ff90e588b0
---
 .../TrigDetCalib/CMakeLists.txt               |  1 +
 .../TrigDetCalib/cmt/requirements             |  1 +
 .../TrigDetCalib/src/TrigL1CaloOverflow.cxx   | 38 ++++++++++++++++---
 .../TrigDetCalib/src/TrigL1CaloOverflow.h     |  3 ++
 4 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigDetCalib/CMakeLists.txt b/Trigger/TrigAlgorithms/TrigDetCalib/CMakeLists.txt
index 78db48e4f99..351e33f3c06 100644
--- a/Trigger/TrigAlgorithms/TrigDetCalib/CMakeLists.txt
+++ b/Trigger/TrigAlgorithms/TrigDetCalib/CMakeLists.txt
@@ -15,6 +15,7 @@ atlas_depends_on_subdirs( PUBLIC
                           Control/AthenaBaseComps
                           Control/AthenaKernel
                           Event/EventInfo
+                          Event/xAOD/xAODEventInfo
                           Tracking/TrkEvent/TrkTrack
                           Trigger/TrigSteer/TrigInterfaces
                           Trigger/TrigSteer/TrigSteering
diff --git a/Trigger/TrigAlgorithms/TrigDetCalib/cmt/requirements b/Trigger/TrigAlgorithms/TrigDetCalib/cmt/requirements
index eb1d4c4ee28..558d46c6379 100644
--- a/Trigger/TrigAlgorithms/TrigDetCalib/cmt/requirements
+++ b/Trigger/TrigAlgorithms/TrigDetCalib/cmt/requirements
@@ -11,6 +11,7 @@ use 	IRegionSelector      	IRegionSelector-*     DetectorDescription
 private
 use     AthenaBaseComps         AthenaBaseComps-*     Control
 use     EventInfo               EventInfo-*           Event
+use     xAODEventInfo           xAODEventInfo-*       Event/xAOD
 use     AthenaKernel            AthenaKernel-*        Control
 use     TrkTrack                TrkTrack-*            Tracking/TrkEvent
 use     TrigSteering            TrigSteering*         Trigger/TrigSteer
diff --git a/Trigger/TrigAlgorithms/TrigDetCalib/src/TrigL1CaloOverflow.cxx b/Trigger/TrigAlgorithms/TrigDetCalib/src/TrigL1CaloOverflow.cxx
index eec37c738f1..14c2a7964bf 100644
--- a/Trigger/TrigAlgorithms/TrigDetCalib/src/TrigL1CaloOverflow.cxx
+++ b/Trigger/TrigAlgorithms/TrigDetCalib/src/TrigL1CaloOverflow.cxx
@@ -3,14 +3,23 @@
 */
 
 #include "TrigL1CaloOverflow.h"
+
 #include "TrigT1Result/RoIBResult.h"
+#include "xAODEventInfo/EventInfo.h"
 
 #include <bitset>
 
+// BCIDs of the abort gap
+const int ABORT_GAP_START = 3446;
+const int ABORT_GAP_END   = 3563;
+
 TrigL1CaloOverflow::TrigL1CaloOverflow(const std::string& name, ISvcLocator* pSvcLocator):
   HLT::AllTEAlgo(name, pSvcLocator),
   m_lvl1Tool("HLT::Lvl1ResultAccessTool/Lvl1ResultAccessTool",this)
 {
+  declareProperty("ignoreAbortGap", m_ignoreAbortGap = true, "Ignore overflows in abort gap");
+  declareProperty("acceptCMXOverflows", m_acceptCMXOverflows = true, "Accept CMX overflows");
+  declareProperty("acceptCaloRoIBOverflows", m_acceptCaloRoIBOverflows = true, "Accept Calo RoIB overflows");
 }
 
 HLT::ErrorCode TrigL1CaloOverflow::hltInitialize()
@@ -26,14 +35,33 @@ HLT::ErrorCode TrigL1CaloOverflow::hltExecute(std::vector<std::vector<HLT::Trigg
 {
   beforeExecMonitors().ignore();
 
+  // Do nothing for events in the abort gap (tile laser causes overflows)
+  if (m_ignoreAbortGap) {
+    const xAOD::EventInfo* evt(0);
+    if (evtStore()->retrieve(evt).isSuccess() &&
+        evt->bcid() >= ABORT_GAP_START && evt->bcid() <= ABORT_GAP_END) {
+      return HLT::OK;
+    }
+  }
+
   const ROIB::RoIBResult* result;
   if (evtStore()->retrieve(result).isFailure()) return HLT::OK;
 
-  std::bitset<3> overflow = m_lvl1Tool->lvl1EMTauJetOverflow(*result);
-  if (overflow.any()) {
-    HLT::TriggerElement* te = addRoI(output);
-    te->setActiveState(true);
-    ATH_MSG_DEBUG("Event was force accepted by L1Calo due to TOB overflows in CMX transmission");
+  // Overflows in the TOB transmission to CMX
+  if (m_acceptCMXOverflows) {
+    std::bitset<3> overflow = m_lvl1Tool->lvl1EMTauJetOverflow(*result);
+    if (overflow.any()) {
+      addRoI(output)->setActiveState(true);
+      ATH_MSG_DEBUG("Event was force accepted by L1Calo due to TOB overflows in CMX transmission");
+    }
+  }
+
+  // Overflows on the RoI link to the RoIB
+  if (m_acceptCaloRoIBOverflows) {
+    if (result->CheckEMOverflow() || result->CheckJOverflow()) {
+      addRoI(output)->setActiveState(true);
+      ATH_MSG_DEBUG("Event has overflows in the EM or JET RoI transmission to the RoIB");
+    }
   }
   
   afterExecMonitors().ignore();
diff --git a/Trigger/TrigAlgorithms/TrigDetCalib/src/TrigL1CaloOverflow.h b/Trigger/TrigAlgorithms/TrigDetCalib/src/TrigL1CaloOverflow.h
index 6d7d611d676..f66de6c1284 100644
--- a/Trigger/TrigAlgorithms/TrigDetCalib/src/TrigL1CaloOverflow.h
+++ b/Trigger/TrigAlgorithms/TrigDetCalib/src/TrigL1CaloOverflow.h
@@ -29,6 +29,9 @@ public:
   
 private:
   ToolHandle<HLT::ILvl1ResultAccessTool> m_lvl1Tool;
+  bool m_ignoreAbortGap;
+  bool m_acceptCMXOverflows;
+  bool m_acceptCaloRoIBOverflows;
 };
 
 
-- 
GitLab