From 4389c932ff007041ed5cb4409f408f2734d05e85 Mon Sep 17 00:00:00 2001
From: Walter Lampl <Walter.Lampl@cern.ch>
Date: Tue, 5 Jan 2021 17:19:06 +0100
Subject: [PATCH] add FT preselection option to LArRawCalibDataReadingAlg

---
 .../src/LArRawCalibDataReadingAlg.cxx         | 28 +++++++++++++++++++
 .../src/LArRawCalibDataReadingAlg.h           |  6 ++++
 2 files changed, 34 insertions(+)

diff --git a/LArCalorimeter/LArCnv/LArByteStream/src/LArRawCalibDataReadingAlg.cxx b/LArCalorimeter/LArCnv/LArByteStream/src/LArRawCalibDataReadingAlg.cxx
index b46998e7653..b738e3c0070 100644
--- a/LArCalorimeter/LArCnv/LArByteStream/src/LArRawCalibDataReadingAlg.cxx
+++ b/LArCalorimeter/LArCnv/LArByteStream/src/LArRawCalibDataReadingAlg.cxx
@@ -71,6 +71,24 @@ LArRawCalibDataReadingAlg::LArRawCalibDataReadingAlg(const std::string& name, IS
 
   ATH_CHECK(m_robDataProviderSvc.retrieve());
   ATH_CHECK(detStore()->retrieve(m_onlineId,"LArOnlineID"));  
+
+
+  //Build list of preselected Feedthroughs
+  if (m_vBEPreselection.size() &&  m_vPosNegPreselection.size() && m_vFTPreselection.size()) {
+    ATH_MSG_INFO("Building list of selected feedthroughs");
+    for (const unsigned iBE : m_vBEPreselection) {
+      for (const unsigned iPN: m_vPosNegPreselection) {
+	for (const unsigned iFT: m_vFTPreselection) {
+	  HWIdentifier finalFTId=m_onlineId->feedthrough_Id(iBE,iPN,iFT);
+	  unsigned int finalFTId32 = finalFTId.get_identifier32().get_compact();
+	  ATH_MSG_INFO("Adding feedthrough Barrel/Endcap=" << iBE << " pos/neg=" << iPN << " FT=" << iFT 
+		       << " (0x" << std::hex << finalFTId32 << std::dec << ")");
+	  m_vFinalPreselection.insert(finalFTId32);
+	}
+      }
+    }
+  }//end if something set
+
   return StatusCode::SUCCESS;
 }     
   
@@ -190,6 +208,16 @@ StatusCode LArRawCalibDataReadingAlg::execute(const EventContext& ctx) const {
 	else
 	  continue;
       }
+
+      if (m_vFinalPreselection.size()) {
+	const unsigned int ftId=m_onlineId->feedthrough_Id(fId).get_identifier32().get_compact();
+	if (m_vFinalPreselection.find(ftId)==m_vFinalPreselection.end()) {
+	  ATH_MSG_DEBUG("Feedthrough with id 0x" << MSG::hex << ftId << MSG::dec <<" not in preselection. Ignored.");
+	  continue;
+	}
+      }
+
+
       const int NthisFebChannel=m_onlineId->channelInSlotMax(fId);
 
       //Decode LArCalibDigits (if requested)
diff --git a/LArCalorimeter/LArCnv/LArByteStream/src/LArRawCalibDataReadingAlg.h b/LArCalorimeter/LArCnv/LArByteStream/src/LArRawCalibDataReadingAlg.h
index 1c5b1121fb7..3ab9aa04c67 100644
--- a/LArCalorimeter/LArCnv/LArByteStream/src/LArRawCalibDataReadingAlg.h
+++ b/LArCalorimeter/LArCnv/LArByteStream/src/LArRawCalibDataReadingAlg.h
@@ -41,6 +41,12 @@ class LArRawCalibDataReadingAlg : public  AthReentrantAlgorithm {
   BooleanProperty m_verifyChecksum{this,"VerifyChecksum",true,"Calculate and compare checksums to detect data transmission errors"}; 
   BooleanProperty m_failOnCorruption{this,"FailOnCorruption",true,"Return FAILURE if data corruption is found"};
 
+  Gaudi::Property<std::vector<unsigned> > m_vBEPreselection{this,"BEPreselection",{},"For channel-selection: Barrel=0, Endcap=1"};
+  Gaudi::Property<std::vector<unsigned> > m_vPosNegPreselection{this,"PosNegPreselection",{}, "For channel-selection: C-Side:0, A-Side: 1"};
+  Gaudi::Property<std::vector<unsigned> > m_vFTPreselection{this,"FTPreselection",{}, "For channel-selection: Feedthrough numbers (e.g. 0 - 31 for barrel)"};
+
+  std::set<unsigned> m_vFinalPreselection;
+
   //Identifier helper
   const LArOnlineID* m_onlineId=nullptr;
 
-- 
GitLab