diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData/src/MdtTubeCalibContainer.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData/src/MdtTubeCalibContainer.cxx index 08cc784ed705520fe7631f9717c274081f20569f..809afb28b54ccb37019d68ec101985b6d3e7ac67 100644 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData/src/MdtTubeCalibContainer.cxx +++ b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData/src/MdtTubeCalibContainer.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #include <MdtCalibData/MdtTubeCalibContainer.h> namespace MuonCalib { @@ -37,13 +37,15 @@ bool MdtTubeCalibContainer::setCalib(SingleTubeCalib&& val, const Identifier& tu } SingleTubeCalib& store = m_data[index]; if (store) { - msg << MSG::ERROR<< __FILE__ << __LINE__<< " Data has already been stored for channel " - << m_idHelperSvc->toString(tubeId) << endmsg; + msg << MSG::ERROR<< __FILE__ <<":"<< __LINE__<< " Data has already been stored for channel " + << m_idHelperSvc->toString(tubeId) + <<", layer max: "<<m_nLayers<<", tube max: "<<m_nTubes + << endmsg; return false; } store = std::move(val); - if (msg.level() <= MSG::DEBUG) { - msg << MSG::DEBUG<<" Succesfully stored calibration data for channel "<<m_idHelperSvc->toString(tubeId) << endmsg; + if (msg.level() <= MSG::VERBOSE) { + msg << MSG::VERBOSE<<" Succesfully stored calibration data for channel "<<m_idHelperSvc->toString(tubeId) << endmsg; } return true; } diff --git a/MuonSpectrometer/MuonPhaseII/MuonConditions/MuonCondAlgR4/src/MdtCalibDbAlg.cxx b/MuonSpectrometer/MuonPhaseII/MuonConditions/MuonCondAlgR4/src/MdtCalibDbAlg.cxx index c1f622a5d49b605e1235ecbda15b93a9c1446d09..88b91cf9103d7c0d405702b29d95ef579c0de663 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonConditions/MuonCondAlgR4/src/MdtCalibDbAlg.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonConditions/MuonCondAlgR4/src/MdtCalibDbAlg.cxx @@ -19,7 +19,7 @@ MdtCalibDbAlg::MdtCalibDbAlg(const std::string& name, ISvcLocator* pSvcLocator) AthReentrantAlgorithm(name, pSvcLocator) {} StatusCode MdtCalibDbAlg::initialize() { - ATH_MSG_ALWAYS("Initializing MdtCalibDbAlgR4"); + ATH_MSG_VERBOSE("Initialize..."); ATH_CHECK(m_idHelperSvc.retrieve()); ATH_CHECK(m_writeKey.initialize()); ATH_CHECK(detStore()->retrieve(m_r4detMgr)); @@ -27,7 +27,7 @@ StatusCode MdtCalibDbAlg::initialize() { } StatusCode MdtCalibDbAlg::execute(const EventContext& ctx) const { - ATH_MSG_ALWAYS("Executing MdtCalibDbAlgR4"); + ATH_MSG_VERBOSE("Executing MdtCalibDbAlgR4"); SG::WriteCondHandle<MuonCalib::MdtCalibDataContainer> writeHandle{m_writeKey, ctx}; if(writeHandle.isValid()) { ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."); @@ -35,7 +35,7 @@ StatusCode MdtCalibDbAlg::execute(const EventContext& ctx) const { } writeHandle.addDependency(EventIDRange(IOVInfiniteRange::infiniteRunLB())); RegionGranularity gran{RegionGranularity::OnePerMultiLayer}; - std::unique_ptr<MuonCalib::MdtCalibDataContainer> writeCdo = std::make_unique<MuonCalib::MdtCalibDataContainer>(m_idHelperSvc.get(), gran); + auto writeCdo = std::make_unique<MuonCalib::MdtCalibDataContainer>(m_idHelperSvc.get(), gran); ATH_CHECK(loadRt(*writeCdo)); ATH_CHECK(loadTube(*writeCdo)); @@ -48,39 +48,19 @@ StatusCode MdtCalibDbAlg::execute(const EventContext& ctx) const { StatusCode MdtCalibDbAlg::loadRt(MuonCalib::MdtCalibDataContainer& writeHandle) const { ATH_MSG_DEBUG("loadRt " << name()); - - std::vector<double> radii{}; - std::vector<double> res{}; - - MuonCalib::CalibFunc::ParVec rtPars{}; - rtPars.push_back(-10000);// Corresponds to tLower, what is it? - rtPars.push_back(10000.);// Corresponds to tUpper, what is it? - rtPars.insert(rtPars.end(), radii.begin(), radii.end()); + MuonCalib::CalibFunc::ParVec rtPars{-10000, 10000}; MuonCalib::CalibFunc::ParVec resoPars{-10000, 10000.}; - resoPars.insert(resoPars.end(), res.begin(), res.end()); //Create an RtSqrt - std::unique_ptr<MuonCalib::IRtRelation> rtRel{std::make_unique<MuonCalibR4::RtSqrt>(rtPars)}; - if(!rtRel) { - ATH_MSG_ERROR("Failed to create RtSqrt"); - return StatusCode::FAILURE; - } - std::unique_ptr<MuonCalib::IRtResolution> rtRes{std::make_unique<MuonCalibR4::RtResolutionSqrt>(resoPars)}; - if(!rtRes) { - ATH_MSG_ERROR("Failed to create RtResolutionSqrt"); - return StatusCode::FAILURE; - } - std::unique_ptr<MuonCalib::TrRelation> trRel{std::make_unique<MuonCalibR4::TrSqrt>(MuonCalibR4::RtSqrt(rtPars))}; - if(!trRel) { - ATH_MSG_ERROR("Failed to create TrSqrt"); - return StatusCode::FAILURE; - } - + auto rtRel{std::make_unique<MuonCalibR4::RtSqrt>(rtPars)}; + auto rtRes{std::make_unique<MuonCalibR4::RtResolutionSqrt>(resoPars)}; + auto trRel{std::make_unique<MuonCalibR4::TrSqrt>(MuonCalibR4::RtSqrt(rtPars))}; + //Loop over RT regions and store the RT in each - std::unique_ptr<MuonCalib::IRtRelation> rtRelRegion{std::make_unique<MuonCalibR4::RtSqrt>(rtPars)}; - std::unique_ptr<MuonCalib::IRtResolution> rtResRegion{std::make_unique<MuonCalibR4::RtResolutionSqrt>(resoPars)}; - std::unique_ptr<MuonCalib::TrRelation> trRelRegion{std::make_unique<MuonCalibR4::TrSqrt>(MuonCalibR4::RtSqrt(rtPars))}; + auto rtRelRegion{std::make_unique<MuonCalibR4::RtSqrt>(rtPars)}; + auto rtResRegion{std::make_unique<MuonCalibR4::RtResolutionSqrt>(resoPars)}; + auto trRelRegion{std::make_unique<MuonCalibR4::TrSqrt>(MuonCalibR4::RtSqrt(rtPars))}; RtRelationPtr MdtRt = std::make_unique<MuonCalib::MdtRtRelation>(std::move(rtRelRegion), std::move(rtResRegion), std::move(trRelRegion), 0.); std::vector<const MuonGMR4::MdtReadoutElement*> detEls = m_r4detMgr->getAllMdtReadoutElements(); for(const MuonGMR4::MuonReadoutElement* mdtDetEl : detEls) { @@ -116,8 +96,10 @@ StatusCode MdtCalibDbAlg::loadTube(MuonCalib::MdtCalibDataContainer& writeCdo) c } } TubeContainerPtr tubes = std::make_unique<MuonCalib::MdtTubeCalibContainer>(m_idHelperSvc.get(), chamberId); - if (!writeCdo.storeData(chamberId, tubes, msgStream())) return StatusCode::FAILURE; - + if (!writeCdo.storeData(chamberId, tubes, msgStream())) { + ATH_MSG_FATAL("Failed to store chamber data"); + return StatusCode::FAILURE; + } for(size_t layer = 1; layer <= mdtDetEl->numLayers(); ++layer){ for(size_t tube = 1; tube <= mdtDetEl->numTubesInLay(); ++tube){ MuonCalib::MdtTubeCalibContainer::SingleTubeCalib tubeCalib; @@ -125,7 +107,11 @@ StatusCode MdtCalibDbAlg::loadTube(MuonCalib::MdtCalibDataContainer& writeCdo) c tubeCalib.t0 = m_defaultT0; tubeCalib.adcCal = 1.; tubeCalib.inversePropSpeed = inversePropSpeed; - tubes->setCalib(std::move(tubeCalib), tubeId, msgStream()); + if (!tubes->setCalib(std::move(tubeCalib), tubeId, msgStream())) { + ATH_MSG_FATAL("Failed to store tube constants..."); + return StatusCode::FAILURE; + + } } } } diff --git a/MuonSpectrometer/MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.cxx b/MuonSpectrometer/MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.cxx index b1f9ef7119b369c5718d8e3d039a10df012a4d29..43689c8000bdb360fc791a953ae2805d9c987e71 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.cxx @@ -76,6 +76,10 @@ namespace MuonR4 { const double arrivalTime{simHit->globalTime()}; const MuonCalib::MdtFullCalibData* tubeConstants = calibData->getCalibData(hitId, msgStream()); + assert(tubeConstants != nullptr); + assert(tubeConstants->tubeCalib != nullptr); + assert(tubeConstants->tubeCalib->getCalib(hitId) != nullptr); + const MuonCalib::MdtTubeCalibContainer::SingleTubeCalib& tubeCalib{*tubeConstants->tubeCalib->getCalib(hitId)}; const double sigPropTime = tubeCalib.inversePropSpeed*distRO;