From ea476df0e64184e033c968d468b6d6d1b199acdd Mon Sep 17 00:00:00 2001
From: John Derek Chapman <chapman@hep.phy.cam.ac.uk>
Date: Mon, 14 Jan 2019 16:50:05 +0000
Subject: [PATCH] Merge branch 'testBCID.20190110' into '21.3'

test new BCID procedure

See merge request atlas/athena!20301

(cherry picked from commit 8ce7e90511787b96a4609335fea7b1eabf31dd8d)

f00671d5 Modification to include new BCID.
5ade43a3 little fix for bitmask
8cae7441 remove couts
---
 .../LArROD/LArROD/LArSuperCellBuilderDriver.h     |  3 +++
 .../LArROD/src/LArSuperCellBuilderDriver.cxx      | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/LArCalorimeter/LArROD/LArROD/LArSuperCellBuilderDriver.h b/LArCalorimeter/LArROD/LArROD/LArSuperCellBuilderDriver.h
index 0f7249bc896e..bb64aff962cc 100755
--- a/LArCalorimeter/LArROD/LArROD/LArSuperCellBuilderDriver.h
+++ b/LArCalorimeter/LArROD/LArROD/LArSuperCellBuilderDriver.h
@@ -105,6 +105,9 @@ class LArSuperCellBuilderDriver : public AthAlgorithm
   int			      m_defaultShiftTimeSamples;
   int			      m_bcs;
   int			      m_counter;
+  std::vector<float>	      m_bcidLowLim;
+  std::vector<float>	      m_bcidUpLim;
+  std::vector<float>	      m_bcidBands;
 };
 
 #include "LArROD/LArSuperCellBuilderDriver.icc"
diff --git a/LArCalorimeter/LArROD/src/LArSuperCellBuilderDriver.cxx b/LArCalorimeter/LArROD/src/LArSuperCellBuilderDriver.cxx
index c9b57dffb661..6998c94aa855 100755
--- a/LArCalorimeter/LArROD/src/LArSuperCellBuilderDriver.cxx
+++ b/LArCalorimeter/LArROD/src/LArSuperCellBuilderDriver.cxx
@@ -52,6 +52,9 @@ LArSuperCellBuilderDriver::LArSuperCellBuilderDriver (const std::string& name,
   declareProperty("BuildDiscChannel",             m_buildDiscChannel=false);
   declareProperty("DefaultShiftTimeSample",       m_defaultShiftTimeSamples=0);
   declareProperty("BCID_Iter",                    m_bcs=2);
+  declareProperty("bCIDLowLim",                   m_bcidLowLim={8,-2,-8});
+  declareProperty("bCIDUpLim",                    m_bcidUpLim={-8,2,8});
+  declareProperty("bCIDbands",                    m_bcidBands={-1e4,0,10,1e4});
 }
 
 LArSuperCellBuilderDriver::~LArSuperCellBuilderDriver()
@@ -190,6 +193,18 @@ StatusCode LArSuperCellBuilderDriver::execute() {
 	   Identifier id = cabling->cnvToIdentifier((*cont_it)->channelID());
 	   IdentifierHash idhash = sem_mgr->getCaloCell_ID()->calo_cell_hash(id);
 	   const CaloDetDescrElement* dde = sem_mgr->get_element (idhash);
+           float et_calc = energy*dde->sinTh()*1e-3; // in GeV
+           float et_calc_t = et_calc * time;
+           bool passBCID=false;
+           for(unsigned int i=0;i<m_bcidBands.size()-1;i++){
+                if ( (et_calc > m_bcidBands[i]) && (et_calc< m_bcidBands[i+1]) ){
+                if ( (et_calc_t > m_bcidLowLim[i]*et_calc) && (et_calc_t < m_bcidUpLim[i]*et_calc) ) passBCID=true;
+		  break;
+                }
+           }
+
+           prov = prov & (~0x200);
+           if ( passBCID ) prov |= 0x200;
            CaloCell* cell = new CaloCell( dde, (float)energy, (float)time, (uint16_t)0, (uint16_t)prov, gain );
 	   caloCell->push_back( cell );
        }
-- 
GitLab