From d254288ed451c29ff4548fa06494c5a8547f5ebf Mon Sep 17 00:00:00 2001 From: Walter Lampl <walter.lampl@cern.ch> Date: Tue, 20 Mar 2018 19:54:40 +0000 Subject: [PATCH] Fix/improvments of the MT-safe LArRawChannelBuilderAlg --- .../src/LArBadFebCondAlg.cxx | 2 +- .../LArROD/LArROD/LArRawChannelBuilderAlg.h | 4 ++++ .../LArROD/src/LArRawChannelBuilderAlg.cxx | 22 +++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/LArCalorimeter/LArBadChannelTool/src/LArBadFebCondAlg.cxx b/LArCalorimeter/LArBadChannelTool/src/LArBadFebCondAlg.cxx index f121fd62ba4..e0faa796787 100644 --- a/LArCalorimeter/LArBadChannelTool/src/LArBadFebCondAlg.cxx +++ b/LArCalorimeter/LArBadChannelTool/src/LArBadFebCondAlg.cxx @@ -45,7 +45,7 @@ StatusCode LArBadFebCondAlg::execute() { if (writeHandle.isValid()) { writeHandle.updateStore(); //???? - msg(MSG::WARNING) << "Found valid write handle" << endmsg; + msg(MSG::DEBUG) << "Found valid write handle" << endmsg; return StatusCode::SUCCESS; } diff --git a/LArCalorimeter/LArROD/LArROD/LArRawChannelBuilderAlg.h b/LArCalorimeter/LArROD/LArROD/LArRawChannelBuilderAlg.h index d2220e76610..c184ea79e15 100644 --- a/LArCalorimeter/LArROD/LArROD/LArRawChannelBuilderAlg.h +++ b/LArCalorimeter/LArROD/LArROD/LArRawChannelBuilderAlg.h @@ -16,6 +16,7 @@ #include "LArRawConditions/LArADC2MeV.h" #include "LArElecCalib/ILArOFC.h" #include "LArElecCalib/ILArShape.h" +#include "LArCabling/LArOnOffIdMapping.h" //Event classes class LArDigitContainer; @@ -47,6 +48,9 @@ class LArRawChannelBuilderAlg : public AthReentrantAlgorithm { SG::ReadCondHandleKey<ILArOFC> m_ofcKey{this,"OFCKey","LArOFC","SG Key of OFC conditions object"}; SG::ReadCondHandleKey<ILArShape> m_shapeKey{this,"ShapeKey","LArShape","SG Key of Shape conditions object"}; + + SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; + //Other jobOptions: Gaudi::Property<float> m_eCutForQ{this,"ECutForQ",250.0,"Q will be computed only for channels with E above this value"}; Gaudi::Property<bool> m_useShapeDer{this,"useShapeDer",true,"Use shape derivative in Q-factor computation"}; diff --git a/LArCalorimeter/LArROD/src/LArRawChannelBuilderAlg.cxx b/LArCalorimeter/LArROD/src/LArRawChannelBuilderAlg.cxx index 8a6837914a5..5589d49613d 100644 --- a/LArCalorimeter/LArROD/src/LArRawChannelBuilderAlg.cxx +++ b/LArCalorimeter/LArROD/src/LArRawChannelBuilderAlg.cxx @@ -19,6 +19,7 @@ StatusCode LArRawChannelBuilderAlg::initialize() { ATH_CHECK(m_adc2MeVKey.initialize()); ATH_CHECK(m_ofcKey.initialize()); ATH_CHECK(m_shapeKey.initialize()); + ATH_CHECK( m_cablingKey.initialize() ); ATH_CHECK(detStore()->retrieve(m_onlineId,"LArOnlineID")); @@ -78,6 +79,21 @@ StatusCode LArRawChannelBuilderAlg::execute_r(const EventContext& ctx) const { return StatusCode::FAILURE; } + if(ATH_UNLIKELY(adc2mev.size()<2)) { + //Apparently we got digits for a disconnected channel. + //Check if it is really disconncted + SG::ReadCondHandle<LArOnOffIdMapping> cabling(m_cablingKey,ctx); + if ((*cabling)->isOnlineConnected(id)) { + ATH_MSG_ERROR("No valid ADC2MeV for connected channel " << m_onlineId->channel_name(id) + << " gain " << gain); + return StatusCode::FAILURE; + } + else { + //as expected, a disconnected channel + continue; //simply skip over this channl + } + } + //Apply OFCs to get amplitude and time float A=0; @@ -89,7 +105,7 @@ StatusCode LArRawChannelBuilderAlg::execute_r(const EventContext& ctx) const { if (samples[i]==4096 || samples[i]==0) saturated=true; } - const float tau=At/A; + const float tau=(std::fabs(A)>1.0) ? At/A : 0.0; //Apply Ramp const float E=adc2mev[0]+A*adc2mev[1]; @@ -141,7 +157,9 @@ StatusCode LArRawChannelBuilderAlg::execute_r(const EventContext& ctx) const { const float time=(tau-timeOffset)*(Gaudi::Units::nanosecond/ Gaudi::Units::picosecond); //Convert time to ps - outputContainer->emplace_back(id,(int)(floor(E+0.5)),(int)floor(time+0.5),iquaShort,prov,(CaloGain::CaloGain)gain); + outputContainer->emplace_back(id,static_cast<int>(std::floor(E+0.5)), + static_cast<int>(std::floor(time+0.5)), + iquaShort,prov,(CaloGain::CaloGain)gain); } return StatusCode::SUCCESS; -- GitLab