diff --git a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellMBAverageCorr.h b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellMBAverageCorr.h index 96745584839d9152d337c11b5f3135818438a49f..13b738e13067c322addb0f634b82f6b2ad484410 100755 --- a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellMBAverageCorr.h +++ b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellMBAverageCorr.h @@ -24,9 +24,10 @@ public: virtual ~CaloCellMBAverageCorr() {}; - virtual StatusCode initialize(); + virtual StatusCode initialize() override; - void MakeCorrection(CaloCell* theCell); + void MakeCorrection (CaloCell* theCell, + const EventContext& ctx) const override; private: diff --git a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellPedestalCorr.h b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellPedestalCorr.h index c7dff91fe1be2f51dd91eb5c919338f6f2fc815e..c77eedecb3a7344793362ac08fa07cebdda7f0e2 100755 --- a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellPedestalCorr.h +++ b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellPedestalCorr.h @@ -13,6 +13,7 @@ #include "CaloInterface/ICaloLumiBCIDTool.h" #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "GaudiKernel/ToolHandle.h" +#include <unordered_map> class CaloCondBlobFlt; class CaloCell; @@ -30,9 +31,10 @@ public: virtual ~CaloCellPedestalCorr() {}; - virtual StatusCode initialize(); + virtual StatusCode initialize() override; - void MakeCorrection(CaloCell* theCell); + void MakeCorrection (CaloCell* theCell, + const EventContext& ctx) const override; private: @@ -42,8 +44,8 @@ private: virtual StatusCode updateMap(IOVSVC_CALLBACK_ARGS); //=== blob storage const DataHandle<CondAttrListCollection> m_noiseAttrListColl; - std::map<unsigned int, const CaloCondBlobFlt*> m_noiseBlobMap; - std::map<unsigned int, const CaloCondBlobFlt*>::const_iterator m_lastIt; + typedef std::unordered_map<unsigned int, const CaloCondBlobFlt*> NoiseBlobMap_t; + NoiseBlobMap_t m_noiseBlobMap; ToolHandle<ICaloCoolIdTool> m_caloCoolIdTool; float m_lumi0; diff --git a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellRandomizer.h b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellRandomizer.h index 6c9ee72b78266b8c9223dd9adc41c98200306cde..36e0541c8de450f676a475a474137ca306c4595d 100644 --- a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellRandomizer.h +++ b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellRandomizer.h @@ -29,7 +29,8 @@ public: virtual StatusCode initialize() override; - virtual void MakeCorrection (CaloCell* theCell) override; + virtual void MakeCorrection (CaloCell* theCell, + const EventContext& ctx) const override; private: diff --git a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellRescaler.h b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellRescaler.h index a8e1ab8b536aaef15f44758e1964fab7edca0472..2daaeeca2649b8fb2771d7bb0f6132fac42dc6da 100755 --- a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellRescaler.h +++ b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellRescaler.h @@ -35,9 +35,10 @@ public: const IInterface* parent); ~CaloCellRescaler(); - virtual StatusCode initialize(); + virtual StatusCode initialize() override; - void MakeCorrection(CaloCell* theCell); + virtual void MakeCorrection (CaloCell* theCell, + const EventContext& ctx) const override; private: diff --git a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellTimeCorrTool.h b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellTimeCorrTool.h index 197b69fd84d0c75fa572a03f134a17946ee932c2..c5f762067935b9632d6e5737995cd68ae4066c43 100644 --- a/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellTimeCorrTool.h +++ b/Calorimeter/CaloCellCorrection/CaloCellCorrection/CaloCellTimeCorrTool.h @@ -27,9 +27,10 @@ public: const IInterface* parent); ~CaloCellTimeCorrTool(); - virtual StatusCode initialize(); + virtual StatusCode initialize() override; - void MakeCorrection(CaloCell* theCell); + virtual void MakeCorrection (CaloCell* theCell, + const EventContext& ctx) const override; private: /// IOV callback method diff --git a/Calorimeter/CaloCellCorrection/python/CaloCellPedestalCorrDefault.py b/Calorimeter/CaloCellCorrection/python/CaloCellPedestalCorrDefault.py index 77f6f90e9db9c5f2048cbc40b9a219e03ff0ea38..3d8fdd134687f42b00930ccb6c6904e4a688c163 100644 --- a/Calorimeter/CaloCellCorrection/python/CaloCellPedestalCorrDefault.py +++ b/Calorimeter/CaloCellCorrection/python/CaloCellPedestalCorrDefault.py @@ -49,6 +49,10 @@ def CaloCellPedestalCorrDefault(name='CaloCellPedestalCorr'): theCaloCellPedestalCorr.LumiFolderName = lumiFolder if jobproperties.CaloCellFlags.doPileupOffsetBCIDCorr() and (not athenaCommonFlags.isOnline()): + import AthenaCommon.ConcurrencyFlags + if jobproperties.ConcurrencyFlags.NumThreads() >= 1: + mlog.error ("FIXME: CaloLumiBCIDTool does not work in MT") + raise RunTimeError ("FIXME: CaloLumiBCIDTool does not work in MT") from CaloTools.CaloLumiBCIDToolDefault import CaloLumiBCIDToolDefault theCaloLumiBCIDTool = CaloLumiBCIDToolDefault() ToolSvc += theCaloLumiBCIDTool diff --git a/Calorimeter/CaloCellCorrection/src/CaloCellMBAverageCorr.cxx b/Calorimeter/CaloCellCorrection/src/CaloCellMBAverageCorr.cxx index 2155d9a6c8d309215aa3a13435d342fa1a228e83..9b0f43fd0f95d0fa9f991202da133eedabad6456 100755 --- a/Calorimeter/CaloCellCorrection/src/CaloCellMBAverageCorr.cxx +++ b/Calorimeter/CaloCellCorrection/src/CaloCellMBAverageCorr.cxx @@ -44,7 +44,8 @@ StatusCode CaloCellMBAverageCorr::initialize() // ============================================================================ -void CaloCellMBAverageCorr::MakeCorrection(CaloCell* theCell) +void CaloCellMBAverageCorr::MakeCorrection (CaloCell* theCell, + const EventContext& /*ctx*/) const { float pedestal = m_caloMBAverageTool->average(theCell); theCell->addEnergy(-pedestal); diff --git a/Calorimeter/CaloCellCorrection/src/CaloCellPedestalCorr.cxx b/Calorimeter/CaloCellCorrection/src/CaloCellPedestalCorr.cxx index fb7500c582d2f0adea58043f4e4c948101e6da60..32de6d8292c370d3a4c044c9233754c6b375ac25 100755 --- a/Calorimeter/CaloCellCorrection/src/CaloCellPedestalCorr.cxx +++ b/Calorimeter/CaloCellCorrection/src/CaloCellPedestalCorr.cxx @@ -49,7 +49,6 @@ CaloCellPedestalCorr::CaloCellPedestalCorr( declareProperty("LumiFolderName",m_lumiFolderName="/TRIGGER/LUMI/LBLESTONL"); declareProperty("LumiBCIDTool",m_caloLumiBCIDTool,"Tool for BCID pileup offset average correction"); declareProperty("isMC",m_isMC,"Data/MC flag"); - m_lastIt=m_noiseBlobMap.begin(); } //======================================================== @@ -147,7 +146,7 @@ StatusCode CaloCellPedestalCorr::updateMap(IOVSVC_CALLBACK_ARGS_K(keys) ) unsigned int sysId = static_cast<unsigned int>(iColl->first); //=== delete old CaloCondBlobFlt (which does not own the blob) - std::map<unsigned int, const CaloCondBlobFlt*>::iterator iOld = m_noiseBlobMap.find(sysId); + NoiseBlobMap_t::iterator iOld = m_noiseBlobMap.find(sysId); if(iOld != m_noiseBlobMap.end()){ delete iOld->second; } @@ -160,13 +159,13 @@ StatusCode CaloCellPedestalCorr::updateMap(IOVSVC_CALLBACK_ARGS_K(keys) ) m_noiseBlobMap[sysId] = flt; }//end iColl - m_lastIt=m_noiseBlobMap.begin(); return StatusCode::SUCCESS; } // ============================================================================ -void CaloCellPedestalCorr::MakeCorrection(CaloCell* theCell) +void CaloCellPedestalCorr::MakeCorrection (CaloCell* theCell, + const EventContext& ctx) const { float pedestal=0.; @@ -176,19 +175,22 @@ void CaloCellPedestalCorr::MakeCorrection(CaloCell* theCell) unsigned int subHash; const unsigned int iCool = m_caloCoolIdTool->getCoolChannelId(cellHash,subHash); //std::cout << "Got iCool=" << iCool << " subhash=" << subHash << std::endl; - if (m_lastIt->first!=iCool) { - m_lastIt=m_noiseBlobMap.find(iCool); - } - //The following checks would make sense but were obmitted to speed up execution: - //1. m_lastIt!=m_noiseBlobMap.end() eg, if iCool exists + NoiseBlobMap_t::const_iterator it = m_noiseBlobMap.find (iCool); + //The following checks would make sense but were omitted to speed up execution: + //1. it!=m_noiseBlobMap.end() eg, if iCool exists //2. subHash < flt->getNChans() - const CaloCondBlobFlt* const flt = m_lastIt->second; + const CaloCondBlobFlt* const flt = it->second; const unsigned int dbGain = CaloCondUtils::getDbCaloGain(theCell->gain()); pedestal = flt->getCalib(subHash, dbGain, m_lumi0); } if (!m_caloLumiBCIDTool.empty() ) { - pedestal = pedestal + m_caloLumiBCIDTool->average(theCell,0); + // FIXME: CaloLumiBCIDTool has threading issues. + // Refuse to proceed if we're running with multiple threads. + if (ctx.slot() > 1) { + std::abort(); + } + pedestal = pedestal + m_caloLumiBCIDTool->average(theCell,0); } theCell->addEnergy(-pedestal); diff --git a/Calorimeter/CaloCellCorrection/src/CaloCellRandomizer.cxx b/Calorimeter/CaloCellCorrection/src/CaloCellRandomizer.cxx index f4d49f600c3bf07cd1563e81a3e8c8863d00d206..80355e2805a8bc26406908a2d38fffb0474a9037 100644 --- a/Calorimeter/CaloCellCorrection/src/CaloCellRandomizer.cxx +++ b/Calorimeter/CaloCellCorrection/src/CaloCellRandomizer.cxx @@ -75,9 +75,9 @@ StatusCode CaloCellRandomizer::initialize() // ============================================================================ -void CaloCellRandomizer::MakeCorrection (CaloCell* theCell) +void CaloCellRandomizer::MakeCorrection (CaloCell* theCell, + const EventContext& ctx) const { - const EventContext& ctx = Gaudi::Hive::currentContext(); CLHEP::HepRandomEngine* engine = m_randomEngine->getEngine (ctx); int sampl = 0; diff --git a/Calorimeter/CaloCellCorrection/src/CaloCellRescaler.cxx b/Calorimeter/CaloCellCorrection/src/CaloCellRescaler.cxx index f378a92feb3f95df702e91f2339181433b67b099..588babd92936cd67914bb10f2b184c675cea1967 100755 --- a/Calorimeter/CaloCellCorrection/src/CaloCellRescaler.cxx +++ b/Calorimeter/CaloCellCorrection/src/CaloCellRescaler.cxx @@ -49,8 +49,9 @@ StatusCode CaloCellRescaler::initialize() { } -void CaloCellRescaler::MakeCorrection(CaloCell* theCell) { - +void CaloCellRescaler::MakeCorrection (CaloCell* theCell, + const EventContext& /*ctx*/) const +{ const CaloDetDescrElement* caloDDE = theCell->caloDDE(); if (caloDDE) { theCell->scaleEnergy( m_factorToCells[caloDDE->getSampling()] ); diff --git a/Calorimeter/CaloCellCorrection/src/CaloCellTimeCorrTool.cxx b/Calorimeter/CaloCellCorrection/src/CaloCellTimeCorrTool.cxx index c90c10c5af73bc8e4da229e8b0274745f4b401e3..fee98be0c19112ee9ec45c6b8f3075a12f0f6554 100644 --- a/Calorimeter/CaloCellCorrection/src/CaloCellTimeCorrTool.cxx +++ b/Calorimeter/CaloCellCorrection/src/CaloCellTimeCorrTool.cxx @@ -51,7 +51,9 @@ StatusCode CaloCellTimeCorrTool::load(IOVSVC_CALLBACK_ARGS) { } -void CaloCellTimeCorrTool::MakeCorrection(CaloCell* theCell) { +void CaloCellTimeCorrTool::MakeCorrection (CaloCell* theCell, + const EventContext& /*ctx*/) const +{ if (m_corrValues) { const IdentifierHash& hash_id=theCell->caloDDE()->calo_hash(); if (hash_id<m_corrValues->getNChans()) {