Skip to content
Snippets Groups Projects
Commit 34592eea authored by scott snyder's avatar scott snyder
Browse files

CaloCellCorrection: Make CaloCellCorrection methods const.

Change CaloCellCorrection::MakeCorrection and execute to be const,
and to take an EventContext argument.
Working to make more of the calorimeter reconstruction reentrant.
parent 607d797e
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 28 deletions
......@@ -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:
......
......@@ -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;
......
......@@ -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:
......
......@@ -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:
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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()] );
......
......@@ -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()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment