From d8165f304eb7faa55dcde39055a5b4b7270c5b43 Mon Sep 17 00:00:00 2001
From: Liaoshan Shi <Liaoshan.Shi@cern.ch>
Date: Fri, 18 Aug 2023 15:08:47 +0200
Subject: [PATCH] add an option to switch off the retrieval of MBTS cell
 details

---
 .../share/CaloJiveXML_DataTypes.py            |  1 +
 .../CaloJiveXML/src/CaloMBTSRetriever.cxx     | 28 +++++++++++--------
 .../CaloJiveXML/src/CaloMBTSRetriever.h       |  1 +
 .../share/jobOptions_TileCalibRec.py          |  1 +
 .../share/TileRec_topOptions.py               |  1 +
 .../share/Atlantis_jobOptions.py              |  1 +
 .../share/JiveXML_jobOptions_PhysicsESD.py    |  1 +
 7 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/Calorimeter/CaloCnv/CaloJiveXML/share/CaloJiveXML_DataTypes.py b/Calorimeter/CaloCnv/CaloJiveXML/share/CaloJiveXML_DataTypes.py
index 60d93d243006..cad785ddbd00 100644
--- a/Calorimeter/CaloCnv/CaloJiveXML/share/CaloJiveXML_DataTypes.py
+++ b/Calorimeter/CaloCnv/CaloJiveXML/share/CaloJiveXML_DataTypes.py
@@ -72,6 +72,7 @@ from CaloJiveXML.CaloJiveXMLConf import JiveXML__CaloMBTSRetriever
 theCaloMBTSRetriever = JiveXML__CaloMBTSRetriever (name = "CaloMBTSRetriever")
 theCaloMBTSRetriever.TileDigitsContainer = tileDigitsContainer
 theCaloMBTSRetriever.TileRawChannelContainer = tileRawChannelContainer
+theCaloMBTSRetriever.DoMBTSCellDetails = False
 theCaloMBTSRetriever.DoMBTSDigits = False
 
 from CaloJiveXML.CaloJiveXMLConf import JiveXML__CaloFCalRetriever
diff --git a/Calorimeter/CaloCnv/CaloJiveXML/src/CaloMBTSRetriever.cxx b/Calorimeter/CaloCnv/CaloJiveXML/src/CaloMBTSRetriever.cxx
index 6db43e41a408..91488de26e45 100644
--- a/Calorimeter/CaloCnv/CaloJiveXML/src/CaloMBTSRetriever.cxx
+++ b/Calorimeter/CaloCnv/CaloJiveXML/src/CaloMBTSRetriever.cxx
@@ -37,6 +37,7 @@ namespace JiveXML {
     declareProperty("MBTSThreshold", m_mbtsThreshold = 0.05);
     declareProperty("RetrieveMBTS" , m_mbts = true);
     declareProperty("DoMBTSDigits",  m_mbtsdigit=false);
+    declareProperty("DoMBTSCellDetails",  m_mbtsCellDetails = false);
 
     // TileDigitsContainer names: {"TileDigitsCnt","TileDigitsFlt"};
     declareProperty("TileDigitsContainer" ,m_sgKeyTileDigits = "",
@@ -46,7 +47,7 @@ namespace JiveXML {
     //                                 "TileRawChannelFitCool","TileRawChannelFit",
     //                                 "TileRawChannelCnt","TileRawChannelFlt"};
     declareProperty("TileRawChannelContainer" ,m_sgKeyTileRawChannel = "",
-        "Input collection to retrieve Tile raw channels, used when doTileCellDetails is True.");
+        "Input collection to retrieve Tile raw channels, used when DoMBTSCellDetails is True.");
   }
 
   /**
@@ -67,7 +68,7 @@ namespace JiveXML {
 
     ATH_CHECK( m_sgKeyTileDigits.initialize(m_mbtsdigit) );
 
-    ATH_CHECK( m_sgKeyTileRawChannel.initialize() );
+    ATH_CHECK( m_sgKeyTileRawChannel.initialize(m_mbtsCellDetails) );
 
     return StatusCode::SUCCESS;
   }
@@ -141,14 +142,17 @@ namespace JiveXML {
       ATH_MSG_ERROR( "in getMBTSData(), Could not retrieve TileInfo" );
     }
 
-    SG::ReadHandle<TileRawChannelContainer> RawChannelCnt(m_sgKeyTileRawChannel);
-    if (!RawChannelCnt.isValid()){
-        ATH_MSG_WARNING( "Could not retrieve TileRawChannel "  );
-    }
-    else{
-        RChUnit = RawChannelCnt->get_unit();
-        offlineRch = (RChUnit<TileRawChannelUnit::OnlineADCcounts &&
-                      RawChannelCnt->get_type() != TileFragHash::OptFilterDsp);
+    SG::ReadHandle<TileRawChannelContainer> RawChannelCnt;
+    if (m_mbtsCellDetails) {
+      RawChannelCnt = SG::makeHandle(m_sgKeyTileRawChannel);
+      if (!RawChannelCnt.isValid()){
+          ATH_MSG_WARNING( "Could not retrieve TileRawChannel "  );
+      }
+      else{
+          RChUnit = RawChannelCnt->get_unit();
+          offlineRch = (RChUnit<TileRawChannelUnit::OnlineADCcounts &&
+                        RawChannelCnt->get_type() != TileFragHash::OptFilterDsp);
+      }
     }
 
     SG::ReadHandle<TileDigitsContainer> tileDigits;
@@ -177,7 +181,7 @@ namespace JiveXML {
 
     //Loop over TileRawChannel to get Pedestal and raw amplitude and time
 
-    if (RawChannelCnt.isValid()) {
+    if (m_mbtsCellDetails && RawChannelCnt.isValid()) {
       if (offlineRch) {
 
         for (const auto rawChannel : *RawChannelCnt) {
@@ -279,7 +283,7 @@ namespace JiveXML {
       phi.push_back(DataType( phiMBTS ));
       sampling.push_back(DataType( m_tileTBID->channel(id) ));
 
-      if (RawChannelCnt.isValid()) {
+      if (m_mbtsCellDetails && RawChannelCnt.isValid()) {
 
         cellPedestal.push_back(DataType( theMbtspedestal[id.get_identifier32().get_compact()] ));
         cellRawAmplitude.push_back(DataType( theMbtsrawamp[id.get_identifier32().get_compact()] ));
diff --git a/Calorimeter/CaloCnv/CaloJiveXML/src/CaloMBTSRetriever.h b/Calorimeter/CaloCnv/CaloJiveXML/src/CaloMBTSRetriever.h
index 4ae3f493f940..fb894fbb42fb 100644
--- a/Calorimeter/CaloCnv/CaloJiveXML/src/CaloMBTSRetriever.h
+++ b/Calorimeter/CaloCnv/CaloJiveXML/src/CaloMBTSRetriever.h
@@ -77,6 +77,7 @@ namespace JiveXML{
       double m_mbtsThreshold;
       bool m_mbts;
       bool m_mbtsdigit;
+      bool m_mbtsCellDetails;
   };
 }
 #endif
diff --git a/TileCalorimeter/TileExample/TileRecEx/share/jobOptions_TileCalibRec.py b/TileCalorimeter/TileExample/TileRecEx/share/jobOptions_TileCalibRec.py
index 5fe01daa8f38..ebddf1b2a079 100644
--- a/TileCalorimeter/TileExample/TileRecEx/share/jobOptions_TileCalibRec.py
+++ b/TileCalorimeter/TileExample/TileRecEx/share/jobOptions_TileCalibRec.py
@@ -1640,6 +1640,7 @@ if doAtlantis:
 
         from CaloJiveXML.CaloJiveXMLConf import JiveXML__CaloMBTSRetriever
         theCaloMBTSRetriever = JiveXML__CaloMBTSRetriever (name = "CaloMBTSRetriever")
+        theCaloMBTSRetriever.DoMBTSCellDetails = True
         theCaloMBTSRetriever.DoMBTSDigits = ReadDigits or ('ReadESD' in dir() and ReadESD)
         theCaloMBTSRetriever.MBTSThreshold = 0.05
         ToolSvc += theCaloMBTSRetriever
diff --git a/TileCalorimeter/TileMonitoring/share/TileRec_topOptions.py b/TileCalorimeter/TileMonitoring/share/TileRec_topOptions.py
index 2e3b03765fbc..fa7159e6e6ef 100644
--- a/TileCalorimeter/TileMonitoring/share/TileRec_topOptions.py
+++ b/TileCalorimeter/TileMonitoring/share/TileRec_topOptions.py
@@ -343,6 +343,7 @@ if doAtlantis:
 
     from CaloJiveXML.CaloJiveXMLConf import JiveXML__CaloMBTSRetriever
     theCaloMBTSRetriever = JiveXML__CaloMBTSRetriever (name = 'CaloMBTSRetriever')
+    theCaloMBTSRetriever.DoMBTSCellDetails = True
     theCaloMBTSRetriever.DoMBTSDigits = True
     ToolSvc += theCaloMBTSRetriever
     theEventData2XML.DataTypes += ['JiveXML::CaloMBTSRetriever/CaloMBTSRetriever']
diff --git a/graphics/EventDisplaysOnline/share/Atlantis_jobOptions.py b/graphics/EventDisplaysOnline/share/Atlantis_jobOptions.py
index 9958f773a930..50e8c6009d49 100644
--- a/graphics/EventDisplaysOnline/share/Atlantis_jobOptions.py
+++ b/graphics/EventDisplaysOnline/share/Atlantis_jobOptions.py
@@ -90,6 +90,7 @@ if DetFlags.detdescr.Calo_on():
     ToolSvc.CaloTileRetriever.DoTileCellDetails = True
     #Switch on pulse shapes for MBTS
     ToolSvc.CaloMBTSRetriever.DoMBTSDigits = True
+    ToolSvc.CaloMBTSRetriever.DoMBTSCellDetails = True
     #Also switch on LAR digits, but only for Calo streams
 
 if DetFlags.detdescr.Muon_on() :
diff --git a/graphics/JiveXML/share/JiveXML_jobOptions_PhysicsESD.py b/graphics/JiveXML/share/JiveXML_jobOptions_PhysicsESD.py
index 03cbaac71c2d..3d3a624c57e8 100755
--- a/graphics/JiveXML/share/JiveXML_jobOptions_PhysicsESD.py
+++ b/graphics/JiveXML/share/JiveXML_jobOptions_PhysicsESD.py
@@ -50,6 +50,7 @@ include ("RecExCommission/readesd.py")
 ## Calo details:
 theCaloTileRetriever.DoTileCellDetails = True
 theCaloTileRetriever.DoTileDigit = True
+theCaloMBTSRetriever.DoMBTSCellDetails = True
 theCaloMBTSRetriever.DoMBTSDigits = True
 theCaloFCalRetriever.DoFCalCellDetails = True
 theCaloLArRetriever.DoLArCellDetails = True
-- 
GitLab