From 8bedfe25596fbfcc526d173c77ccdb0012d0eb7a Mon Sep 17 00:00:00 2001 From: Wouter Hulsbergen Date: Wed, 4 Dec 2024 13:24:44 +0100 Subject: [PATCH 1/2] add globalModuleToLocalString; add missing 'inline' declarations --- Detector/FT/include/Detector/FT/FTUtils.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Detector/FT/include/Detector/FT/FTUtils.h b/Detector/FT/include/Detector/FT/FTUtils.h index 5e752a430a..3a4d61fb58 100644 --- a/Detector/FT/include/Detector/FT/FTUtils.h +++ b/Detector/FT/include/Detector/FT/FTUtils.h @@ -19,8 +19,8 @@ namespace FTConstants = LHCb::Detector::FT; namespace LHCb::Detector { namespace FTUtils { - /// From global module-ID, retrieve "local" coordinates in a string format useful for monitoring - std::string globalModuleToLocalString( const unsigned int globalModuleIdx ) { + /// From global module-ID, return a channel ID + inline auto globalModuleToChannelID( const unsigned int globalModuleIdx ) { unsigned int station, layer, quarter, module, temp_id, temp_station, nModules; //---LoH: Detector!442 station = globalModuleIdx / ( 5 * FTConstants::nQuarters * FTConstants::nLayers ); @@ -43,13 +43,19 @@ namespace LHCb::Detector { module = temp_id - nModules * ( quarter + FTConstants::nQuarters * ( layer + temp_station * FTConstants::nLayers ) ); station = station + 1; + return FTChannelID( FTChannelID::StationID{station}, FTChannelID::LayerID{layer}, FTChannelID::QuarterID{quarter}, + FTChannelID::ModuleID{module}, 0, 0, 0 ) ; + } + /// From global module-ID, retrieve "local" coordinates in a string format useful for monitoring + inline std::string globalModuleToLocalString( const unsigned int globalModuleIdx ) { + auto id = globalModuleToChannelID( globalModuleIdx ) ; /// Return a string - return fmt::format( "T{}L{}Q{}M{}", station, layer, quarter, module ); + return fmt::format( "T{}L{}Q{}M{}", int(id.station()), int(id.layer()), int(id.quarter()), int(id.module()) ); } /// From global quarter-ID, retrieve "local" coordinates in a string format useful for monitoring - std::string globalQuarterToLocalString( const unsigned int globalQuarterIdx ) { + inline std::string globalQuarterToLocalString( const unsigned int globalQuarterIdx ) { unsigned int station, layer, quarter; /// Retrieve the local coordinates @@ -63,7 +69,7 @@ namespace LHCb::Detector { } /// From "local" coordinates in a string format, retrieve global module ID. - unsigned int fromLocalStringToGlobalModule( const std::string local_coords ) { + inline unsigned int fromLocalStringToGlobalModule( const std::string local_coords ) { int count = 0; unsigned int temp_arr[4] = { 0 }; -- GitLab From c621b9a2eecda9f49e1aa7833dc2bedb770d0733 Mon Sep 17 00:00:00 2001 From: Wouter Hulsbergen Date: Wed, 4 Dec 2024 13:25:34 +0100 Subject: [PATCH 2/2] add test of length of matcontraction vector, and small change to speed up reading --- Detector/FT/include/Detector/FT/FTUtils.h | 9 +++++---- Detector/FT/src/DeFT.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Detector/FT/include/Detector/FT/FTUtils.h b/Detector/FT/include/Detector/FT/FTUtils.h index 3a4d61fb58..f4be099839 100644 --- a/Detector/FT/include/Detector/FT/FTUtils.h +++ b/Detector/FT/include/Detector/FT/FTUtils.h @@ -43,15 +43,16 @@ namespace LHCb::Detector { module = temp_id - nModules * ( quarter + FTConstants::nQuarters * ( layer + temp_station * FTConstants::nLayers ) ); station = station + 1; - return FTChannelID( FTChannelID::StationID{station}, FTChannelID::LayerID{layer}, FTChannelID::QuarterID{quarter}, - FTChannelID::ModuleID{module}, 0, 0, 0 ) ; + return FTChannelID( FTChannelID::StationID{ station }, FTChannelID::LayerID{ layer }, + FTChannelID::QuarterID{ quarter }, FTChannelID::ModuleID{ module }, 0, 0, 0 ); } /// From global module-ID, retrieve "local" coordinates in a string format useful for monitoring inline std::string globalModuleToLocalString( const unsigned int globalModuleIdx ) { - auto id = globalModuleToChannelID( globalModuleIdx ) ; + auto id = globalModuleToChannelID( globalModuleIdx ); /// Return a string - return fmt::format( "T{}L{}Q{}M{}", int(id.station()), int(id.layer()), int(id.quarter()), int(id.module()) ); + return fmt::format( "T{}L{}Q{}M{}", int( id.station() ), int( id.layer() ), int( id.quarter() ), + int( id.module() ) ); } /// From global quarter-ID, retrieve "local" coordinates in a string format useful for monitoring diff --git a/Detector/FT/src/DeFT.cpp b/Detector/FT/src/DeFT.cpp index dfda430d11..62fe93e4da 100644 --- a/Detector/FT/src/DeFT.cpp +++ b/Detector/FT/src/DeFT.cpp @@ -214,8 +214,12 @@ LHCb::Detector::detail::DeFTMatObject::DeFTMatObject( const dd4hep::DetElement& const std::string contractionConditionName = getContractionConditionName(); m_matContractionCondition = ctxt.condition( dd4hep::ConditionKey::KeyMaker( deFT, "matContraction" ).hash ); auto& params = m_matContractionCondition.get(); - if ( params.find( contractionConditionName ) != params.end() ) { - m_matContractionParameterVector = params[contractionConditionName].get>(); + if ( auto it = params.find( contractionConditionName ); it != params.end() ) { + m_matContractionParameterVector = it->get>(); + if ( m_matContractionParameterVector.size() != FTConstants::nChannels * FTConstants::nSiPM ) { + dd4hep::printout( dd4hep::ERROR, "Length of MatContractionParameterVector is incorrect %s", + std::to_string( m_matContractionParameterVector.size() ).c_str() ); + } } else { dd4hep::printout( dd4hep::DEBUG, "Unable to find FT condition %s. It will not be possible to correct for temperature distortions.", -- GitLab