diff --git a/Calorimeter/CaloRec/src/CaloClusterMomentsMaker.cxx b/Calorimeter/CaloRec/src/CaloClusterMomentsMaker.cxx index ff4c32a6ead37eba7a16d342494af6c37f3a6eb7..7ebcf71ff79d4fda079bf6f0215ab61d3954c28d 100644 --- a/Calorimeter/CaloRec/src/CaloClusterMomentsMaker.cxx +++ b/Calorimeter/CaloRec/src/CaloClusterMomentsMaker.cxx @@ -538,11 +538,11 @@ CaloClusterMomentsMaker::execute(const EventContext& ctx, ncell++; } } //end of loop over all cells - - const auto hvFrac=m_larHVFraction->getLArHVFrac(theCluster->getCellLinks(),ctx); - eBadLArHV= hvFrac.first; - nBadLArHV=hvFrac.second; - + if (m_calculateLArHVFraction) { + const auto hvFrac=m_larHVFraction->getLArHVFrac(theCluster->getCellLinks(),ctx); + eBadLArHV= hvFrac.first; + nBadLArHV=hvFrac.second; + } if ( w > 0 ) { mass = w*w - mx*mx - my*my - mz*mz; diff --git a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx index 0e34ca3ac8f66d5b0af3f0c80334c047aaf632fe..7c4b510f4224ea32988ccf6240251ae6caa05aef 100644 --- a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.cxx @@ -5,8 +5,8 @@ #include "LArHVScaleCorrCondAlg.h" #include "AthenaKernel/errorcheck.h" #include "GaudiKernel/IIncidentSvc.h" +#include "GaudiKernel/ThreadLocalContext.h" #include "CaloDetDescr/CaloDetDescrElement.h" -#include "xAODEventInfo/EventInfo.h" #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "AthenaPoolUtilities/AthenaAttributeList.h" @@ -104,7 +104,6 @@ StatusCode LArHVScaleCorrCondAlg::initialize() { ATH_CHECK(m_cablingKey.initialize()); ATH_CHECK(m_hvKey.initialize()); - if(!m_updateIfChanged) ATH_CHECK(m_eventInfoKey.initialize()); if(m_undoOnlineHVCorr) ATH_CHECK(m_onlineHVScaleCorrKey.initialize()); ATH_CHECK(m_outputHVScaleCorrKey.initialize()); @@ -118,21 +117,22 @@ StatusCode LArHVScaleCorrCondAlg::initialize() { StatusCode LArHVScaleCorrCondAlg::execute() { + const EventContext& ctx = Gaudi::Hive::currentContext(); // test validity of write handle - SG::WriteCondHandle<ILArHVScaleCorr> writeHandle(m_outputHVScaleCorrKey); + SG::WriteCondHandle<ILArHVScaleCorr> writeHandle(m_outputHVScaleCorrKey, ctx); if (writeHandle.isValid()) { ATH_MSG_DEBUG( "Found valid " << writeHandle.fullKey() << " handle."); return StatusCode::SUCCESS; } // get DCS HVData - SG::ReadCondHandle<LArHVData> hvDataHdl(m_hvKey); + SG::ReadCondHandle<LArHVData> hvDataHdl(m_hvKey, ctx); const LArHVData *hvdata = *hvDataHdl; // Online HVScaleCorr (if needed to subtract) const ILArHVScaleCorr *onlHVCorr = nullptr; if(m_undoOnlineHVCorr) { - SG::ReadCondHandle<ILArHVScaleCorr> onlHVCorrHdl(m_onlineHVScaleCorrKey); + SG::ReadCondHandle<ILArHVScaleCorr> onlHVCorrHdl(m_onlineHVScaleCorrKey, ctx); // onlHVCorr = dynamic_cast<const LArHVScaleCorrFlat*>(*onlHVCorrHdl); onlHVCorr = *onlHVCorrHdl; if(!onlHVCorr) { @@ -142,7 +142,7 @@ StatusCode LArHVScaleCorrCondAlg::execute() { } - SG::ReadCondHandle<LArOnOffIdMapping> larCablingHdl(m_cablingKey); + SG::ReadCondHandle<LArOnOffIdMapping> larCablingHdl(m_cablingKey, ctx); const LArOnOffIdMapping* cabling=*larCablingHdl; if(!cabling) { ATH_MSG_ERROR("Could not get LArOnOffIdMapping !!"); @@ -177,18 +177,14 @@ StatusCode LArHVScaleCorrCondAlg::execute() { } }//end if updateIfChanges else { + // FIXME: statics are not MT-safe!!! static unsigned int timestamp_old = 0; static unsigned int lumiblock_old = 0; static unsigned int run_old = 0; - SG::ReadHandle<xAOD::EventInfo> eventInfo (m_eventInfoKey); - if (not eventInfo.isValid()) { - ATH_MSG_WARNING(" Cannot access to event info, will recompute on every event"); - m_updateIfChanged = true; - return StatusCode::SUCCESS; - } - const unsigned int lumiblock = eventInfo->lumiBlock(); - const unsigned int run = eventInfo->runNumber(); - const unsigned int timestamp = eventInfo->timeStamp(); + + const unsigned int lumiblock = ctx.eventID().lumi_block(); + const unsigned int run = ctx.eventID().run_number(); + const unsigned int timestamp = ctx.eventID().time_stamp(); ATH_MSG_DEBUG("run|lbn|timestamp [CURRENT][CACHED] --> [ " << run << " | " << lumiblock << " | " << timestamp << " ] [ " @@ -254,7 +250,11 @@ StatusCode LArHVScaleCorrCondAlg::finalize() // *** compute global ADC2MeV factor from subfactors *** -StatusCode LArHVScaleCorrCondAlg::getScale(const HASHRANGEVEC& hashranges, std::vector<float> &vScale, const LArHVData *hvdata, const ILArHVScaleCorr *onlHVCorr, const LArOnOffIdMapping* cabling) const { + +StatusCode LArHVScaleCorrCondAlg::getScale(const HASHRANGEVEC& hashranges, + std::vector<float> &vScale, const LArHVData *hvdata, + const ILArHVScaleCorr *onlHVCorr, const LArOnOffIdMapping* cabling) const { + unsigned nChannelsUpdates=0; @@ -437,8 +437,7 @@ StatusCode LArHVScaleCorrCondAlg::getScale(const HASHRANGEVEC& hashranges, std:: ++nChannelsUpdates; if(onlHVCorr) { // undo the online one float hvonline = onlHVCorr->HVScaleCorr(cabling->createSignalChannelID(offid)); - if (hvonline>0. && hvonline<100.) mycorr = mycorr/hvonline; - + if (hvonline>0. && hvonline<100.) mycorr = mycorr/hvonline; } vScale[idx]=mycorr; }// end loop over cells diff --git a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.h b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.h index 138ba00a4feeca995025e1a1efd5658bdf9fdd46..0e31884e91051b2ebfb37a6f41023f166ded3092 100644 --- a/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.h +++ b/LArCalorimeter/LArRecUtils/src/LArHVScaleCorrCondAlg.h @@ -27,8 +27,6 @@ #include "LArCOOLConditions/LArHVScaleCorrFlat.h" #include "LArRecConditions/LArHVCorr.h" -#include "xAODEventInfo/EventInfo.h" - class StoreGateSvc; class LArElectrodeID; @@ -60,7 +58,6 @@ class LArHVScaleCorrCondAlg: public AthAlgorithm SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey {this,"keyCabling", "LArOnOffIdMap", "Input key for Id mapping"} ; SG::ReadCondHandleKey<LArHVData> m_hvKey {this, "keyHVdata", "LArHVData", "Input key for HV data from DCS"}; - SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{this, "eventInfoKey", "EventInfo", "Key for EventInfo object"}; SG::ReadCondHandleKey<ILArHVScaleCorr> m_onlineHVScaleCorrKey{this, "keyOnlineHVCorr", "LArHVScaleCorr","Input key for HVScaleCorr from conditions database (used online)"}; SG::WriteCondHandleKey<ILArHVScaleCorr> m_outputHVScaleCorrKey{this, "keyOutputCorr", "LArHVScaleCorrRecomputed","Output key for LArHVScaleCorr"}; @@ -121,7 +118,10 @@ class LArHVScaleCorrCondAlg: public AthAlgorithm HASHRANGEVEC m_hashRanges[2];//x2 for the side HASHRANGEVEC m_completeRange; HASHRANGEVEC cellsIDsToPartition(const std::set<Identifier>& cellsIDvec) const; - StatusCode getScale(const HASHRANGEVEC& hashranges, std::vector<float> &vScale, const LArHVData* hvdata, const ILArHVScaleCorr *onlHVCorr, const LArOnOffIdMapping* cabling) const; + StatusCode getScale(const HASHRANGEVEC& hashranges, + std::vector<float> &vScale, const LArHVData* hvdata, const ILArHVScaleCorr *onlHVCorr, + const LArOnOffIdMapping* cabling) const; + }; #endif