From 2d9331ab8d7eee895ef24a3673f6e18f34464c90 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 10 Mar 2022 15:52:43 +0000 Subject: [PATCH 1/4] Move Rich param(name) method to Utilities.h --- Detector/Rich/include/Detector/Rich/DeRich.h | 47 +------- .../include/Detector/Rich/DeRichPhDetPanel.h | 1 - .../Rich/include/Detector/Rich/Utilities.h | 113 +++++++++++++----- 3 files changed, 85 insertions(+), 76 deletions(-) diff --git a/Detector/Rich/include/Detector/Rich/DeRich.h b/Detector/Rich/include/Detector/Rich/DeRich.h index 5dca0737be..906d2c95da 100644 --- a/Detector/Rich/include/Detector/Rich/DeRich.h +++ b/Detector/Rich/include/Detector/Rich/DeRich.h @@ -17,7 +17,6 @@ #include #include #include -#include #include namespace LHCb::Detector { @@ -51,51 +50,7 @@ namespace LHCb::Detector { // mimic 'param' method from DetDesc template inline auto param( std::string name ) const { - // temporary work around for different parameter names between DetDesc and dd4hep. - // To be removed once DetDesc is gone, and then the names passed should be updated - // to be the dd4hep ones. - using NameMap = std::unordered_map; - const NameMap name_map = // - {{"Rich1GasQuartzWindowThickness", "Rh1QuartzWindowZSize"}, - {"Rich2GasQuartzWindowThickness", "Rh2QuartzWindowSizeZ"}, - {"SellC4F10F1Param", "SellC4F10F1"}, - {"SellC4F10F2Param", "SellC4F10F2"}, - {"SellC4F10E1Param", "SellC4F10E1"}, - {"SellC4F10E2Param", "SellC4F10E2"}, - {"SellCF4F1Param", "SellCF4F1"}, - {"SellCF4F2Param", "SellCF4F2"}, - {"SellCF4E1Param", "SellCF4E1"}, - {"SellCF4E2Param", "SellCF4E2"}, - {"GasMolWeightC4F10Param", "GasMolWeightC4F10"}, - {"GasMolWeightCF4Param", "GasMolWeightCF4"}, - {"RhoEffectiveSellC4F10Param", "RhoEffectiveSellC4F10"}, - {"RhoEffectiveSellCF4Param", "GasRhoCF4atSTP"}, // double check this one - {"SellLorGasFacParam", "SellLorGasFac"}}; - const auto mapped_name = name_map.find( name ); - if ( mapped_name != name_map.end() ) { name = mapped_name->second; } - // convert template type to irritating dd4hep syntax... - try { - if constexpr ( std::is_arithmetic_v ) { - // deal with really (really) annoying units mis-match between dd4hep and everyone else - // to be removed once the units are corrected 'at source' to be the expected Gaudi ones. - using ScaleMap = std::unordered_map; - const ScaleMap scale_map = { - {"Rh1QuartzWindowZSize", TYPE( 10 )}, // cm -> mm - {"Rh2QuartzWindowSizeZ", TYPE( 10 )}, // cm -> mm - }; - const auto scale = scale_map.find( name ); - const auto F = ( scale == scale_map.end() ? TYPE( 1 ) : scale->second ); - if constexpr ( std::is_integral_v ) { return F * dd4hep::_toInt( name.c_str() ); } - if constexpr ( std::is_same_v ) { return F * dd4hep::_toDouble( name.c_str() ); } - if constexpr ( std::is_same_v ) { return F * dd4hep::_toFloat( name.c_str() ); } - } - if constexpr ( std::is_same_v ) { return dd4hep::_toString( name.c_str() ); } - // compiler error if we get here ... - } catch ( const std::exception& e ) { - std::cerr << "ERROR : Cannot load parameter '" << name << "' as type '" << dd4hep::typeName( typeid( TYPE ) ) - << "' : " << e.what() << std::endl; - throw e; - } + return dd4hep_param( std::move( name ) ); } }; diff --git a/Detector/Rich/include/Detector/Rich/DeRichPhDetPanel.h b/Detector/Rich/include/Detector/Rich/DeRichPhDetPanel.h index fd402c0831..28e24ce93b 100644 --- a/Detector/Rich/include/Detector/Rich/DeRichPhDetPanel.h +++ b/Detector/Rich/include/Detector/Rich/DeRichPhDetPanel.h @@ -32,7 +32,6 @@ namespace LHCb::Detector::detail { auto PhDetPanelCopyIdRef() const noexcept { return this->access()->m_PhDetPanelCopyIdRef; } auto NumMapmtStdModulesInAPanel() const noexcept { return this->access()->m_NumMapmtStdModulesInAPanel; } auto NumMapmtModulesInAPanel() const noexcept { return this->access()->m_NumMapmtModulesInAPanel; } - auto localToGlobalMatrix() const noexcept { return this->toGlobalMatrix(); } }; } // namespace LHCb::Detector::detail diff --git a/Detector/Rich/include/Detector/Rich/Utilities.h b/Detector/Rich/include/Detector/Rich/Utilities.h index a0f9a44361..55bff6b362 100644 --- a/Detector/Rich/include/Detector/Rich/Utilities.h +++ b/Detector/Rich/include/Detector/Rich/Utilities.h @@ -17,6 +17,7 @@ #include #include #include +#include #include namespace LHCb::Detector::detail { @@ -33,37 +34,91 @@ namespace LHCb::Detector::detail { /// More flexible API to access DD4HEP parameters template - inline TYPE dd4hep_param( const std::string& name ) { + inline TYPE dd4hep_param( std::string name ) { + // temporary work around for different parameter names between DetDesc and dd4hep. + // To be removed once DetDesc is gone, and then the names passed should be updated + // to be the dd4hep ones. + using NameMap = std::unordered_map; + static const NameMap name_map = // + {{"Rich1GasQuartzWindowThickness", "Rh1QuartzWindowZSize"}, + {"Rich2GasQuartzWindowThickness", "Rh2QuartzWindowSizeZ"}, + {"SellC4F10F1Param", "SellC4F10F1"}, + {"SellC4F10F2Param", "SellC4F10F2"}, + {"SellC4F10E1Param", "SellC4F10E1"}, + {"SellC4F10E2Param", "SellC4F10E2"}, + {"SellCF4F1Param", "SellCF4F1"}, + {"SellCF4F2Param", "SellCF4F2"}, + {"SellCF4E1Param", "SellCF4E1"}, + {"SellCF4E2Param", "SellCF4E2"}, + {"GasMolWeightC4F10Param", "GasMolWeightC4F10"}, + {"GasMolWeightCF4Param", "GasMolWeightCF4"}, + {"RhoEffectiveSellC4F10Param", "RhoEffectiveSellC4F10"}, + {"RhoEffectiveSellCF4Param", "GasRhoCF4atSTP"}, // double check this one + {"SellLorGasFacParam", "SellLorGasFac"}, + {"RichPmtNumPixelCol", "RhPMTNumPixelsInCol"}, + {"RichPmtNumPixelRow", "RhPMTNumPixelsInRow"}, + {"RichPmtPixelXSize", "RhPMTPixelXSize"}, + {"RichPmtPixelYSize", "RhPMTPixelYSize"}, + {"RichGrandPmtPixelXSize", "RhGrandPMTPixelXSize"}, + {"RichGrandPmtPixelYSize", "RhGrandPMTPixelYSize"}}; + const auto mapped_name = name_map.find( name ); + if ( mapped_name != name_map.end() ) { name = mapped_name->second; } + // // Another work around for DetDesc parameters I have not yet located the + // // equivalent of in dd4hep. So for now document them here with their values. + // using MissingMap = std::unordered_map; + // static const MissingMap missing_map = {{"RichPmtQWToSiMaxDist", TYPE( 10 )}, + // {"'RichPmtSiliconDetectorLocalZlocation", TYPE( -4.05 )}}; + // const auto missing_name = missing_map.find( name ); + // if ( missing_name != missing_map.end() ) { return missing_name->second; } // Convert inconvenient DD4HEP API to dispatch via template type try { - // floating point types - if constexpr ( std::is_same_v ) { return static_cast( dd4hep::_toDouble( name.c_str() ) ); } - if constexpr ( std::is_same_v ) { return static_cast( dd4hep::_toFloat( name.c_str() ) ); } - // signed ints - if constexpr ( std::is_same_v ) { - return static_cast( dd4hep::_toShort( name.c_str() ) ); - } - if constexpr ( std::is_same_v ) { - return static_cast( dd4hep::_toShort( name.c_str() ) ); - } - if constexpr ( std::is_same_v ) { - return static_cast( dd4hep::_toInt( name.c_str() ) ); - } - if constexpr ( std::is_same_v ) { - return static_cast( dd4hep::_toLong( name.c_str() ) ); - } - // unsigned ints - if constexpr ( std::is_same_v ) { - return static_cast( dd4hep::_toShort( name.c_str() ) ); - } - if constexpr ( std::is_same_v ) { - return static_cast( dd4hep::_toShort( name.c_str() ) ); - } - if constexpr ( std::is_same_v ) { - return static_cast( dd4hep::_toInt( name.c_str() ) ); - } - if constexpr ( std::is_same_v ) { - return static_cast( dd4hep::_toLong( name.c_str() ) ); + if constexpr ( std::is_arithmetic_v ) { + // deal with really (really) annoying units mis-match between dd4hep and everyone else. + // To be removed once the units are corrected 'at source' to be the expected Gaudi ones. + using ScaleMap = std::unordered_map; + static const ScaleMap scale_map = { + {"Rh1QuartzWindowZSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm + {"Rh2QuartzWindowSizeZ", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm + {"RhPMTPixelXSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm + {"RhPMTPixelYSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm + {"RhGrandPMTPixelXSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm + {"RhGrandPMTPixelYSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm + }; + const auto scale = scale_map.find( name ); + const auto F = ( scale == scale_map.end() ? TYPE( 1 ) : scale->second ); + // floating point types + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toDouble( name.c_str() ) ); + } + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toFloat( name.c_str() ) ); + } + // signed ints + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toShort( name.c_str() ) ); + } + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toShort( name.c_str() ) ); + } + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toInt( name.c_str() ) ); + } + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toLong( name.c_str() ) ); + } + // unsigned ints + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toShort( name.c_str() ) ); + } + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toShort( name.c_str() ) ); + } + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toInt( name.c_str() ) ); + } + if constexpr ( std::is_same_v ) { + return F * static_cast( dd4hep::_toLong( name.c_str() ) ); + } } // strings if constexpr ( std::is_same_v ) { return dd4hep::_toString( name.c_str() ); } -- GitLab From 878cfbaf1d1187ee186ffcc0dd6cda044f92c556 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 16 Mar 2022 13:40:13 +0000 Subject: [PATCH 2/4] Add more parameter mappings to Rich/Utilities.h --- .../Rich/include/Detector/Rich/Utilities.h | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/Detector/Rich/include/Detector/Rich/Utilities.h b/Detector/Rich/include/Detector/Rich/Utilities.h index 55bff6b362..a912e18efa 100644 --- a/Detector/Rich/include/Detector/Rich/Utilities.h +++ b/Detector/Rich/include/Detector/Rich/Utilities.h @@ -60,32 +60,40 @@ namespace LHCb::Detector::detail { {"RichPmtPixelXSize", "RhPMTPixelXSize"}, {"RichPmtPixelYSize", "RhPMTPixelYSize"}, {"RichGrandPmtPixelXSize", "RhGrandPMTPixelXSize"}, - {"RichGrandPmtPixelYSize", "RhGrandPMTPixelYSize"}}; + {"RichGrandPmtPixelYSize", "RhGrandPMTPixelYSize"}, + {"RichPmtAnodeXSize", "RhPMTAnodeXSize"}, + {"RichPmtAnodeYSize", "RhPMTAnodeYSize"}, + {"RichGrandPmtAnodeXSize", "RhGrandPMTAnodeXSize"}, + {"RichGrandPmtAnodeYSize", "RhGrandPMTAnodeYSize"}, + {"Rich1PmtDetPlaneZInPmtPanel", "Rh1PMTDetPlaneZLocationInPhDetSupFrame"}, + {"Rich2PmtDetPlaneZInPmtPanel", "Rh2MixedPMTDetPlaneZLocationInPMTPanel"}}; const auto mapped_name = name_map.find( name ); if ( mapped_name != name_map.end() ) { name = mapped_name->second; } - // // Another work around for DetDesc parameters I have not yet located the - // // equivalent of in dd4hep. So for now document them here with their values. - // using MissingMap = std::unordered_map; - // static const MissingMap missing_map = {{"RichPmtQWToSiMaxDist", TYPE( 10 )}, - // {"'RichPmtSiliconDetectorLocalZlocation", TYPE( -4.05 )}}; - // const auto missing_name = missing_map.find( name ); - // if ( missing_name != missing_map.end() ) { return missing_name->second; } // Convert inconvenient DD4HEP API to dispatch via template type try { if constexpr ( std::is_arithmetic_v ) { // deal with really (really) annoying units mis-match between dd4hep and everyone else. // To be removed once the units are corrected 'at source' to be the expected Gaudi ones. using ScaleMap = std::unordered_map; - static const ScaleMap scale_map = { - {"Rh1QuartzWindowZSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm - {"Rh2QuartzWindowSizeZ", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm - {"RhPMTPixelXSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm - {"RhPMTPixelYSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm - {"RhGrandPMTPixelXSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm - {"RhGrandPMTPixelYSize", TYPE( LHCb::Detector::detail::DD4hepToLHCbCm )}, // cm -> mm - }; - const auto scale = scale_map.find( name ); - const auto F = ( scale == scale_map.end() ? TYPE( 1 ) : scale->second ); + const TYPE cmTOmm = LHCb::Detector::detail::DD4hepToLHCbCm; // cm -> mm + static const ScaleMap scale_map = {{"Rh1QuartzWindowZSize", cmTOmm}, + {"Rh2QuartzWindowSizeZ", cmTOmm}, + {"RhPMTPixelXSize", cmTOmm}, + {"RhPMTPixelYSize", cmTOmm}, + {"RhGrandPMTPixelXSize", cmTOmm}, + {"RhGrandPMTPixelYSize", cmTOmm}, + {"RhPMTAnodeXSize", cmTOmm}, + {"RhPMTAnodeYSize", cmTOmm}, + {"RhGrandPMTAnodeXSize", cmTOmm}, + {"RhGrandPMTAnodeYSize", cmTOmm}, + {"Rh1PMTDetPlaneZLocationInPhDetSupFrame", cmTOmm}, + {"Rh2MixedPMTDetPlaneZLocationInPMTPanel", cmTOmm}, + {"Rh1PhDetSupXSize", cmTOmm}, + {"Rh1PhDetSupYSize", cmTOmm}, + {"Rh2PDPanelSizeX", cmTOmm}, + {"Rh2PDPanelSizeY", cmTOmm}}; + const auto scale = scale_map.find( name ); + const auto F = ( scale == scale_map.end() ? TYPE( 1 ) : scale->second ); // floating point types if constexpr ( std::is_same_v ) { return F * static_cast( dd4hep::_toDouble( name.c_str() ) ); -- GitLab From 3e17bedf3b302cb87edb9e729b22ff4dea49839f Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 21 Mar 2022 11:53:45 +0000 Subject: [PATCH 3/4] Echo test command from RICH example scripts --- examples/runtestRich1.sh | 1 + examples/runtestRich2.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/runtestRich1.sh b/examples/runtestRich1.sh index f00216603c..d02327f99d 100755 --- a/examples/runtestRich1.sh +++ b/examples/runtestRich1.sh @@ -26,4 +26,5 @@ if [ "$TEST_NAME" == "LHCb_TEST_load_derich1" ]; then fi # run the test ... +echo ${ARGS} ../build.${BINARY_TAG}/bin/run ${ARGS} diff --git a/examples/runtestRich2.sh b/examples/runtestRich2.sh index c0c9a8e237..1633538a04 100755 --- a/examples/runtestRich2.sh +++ b/examples/runtestRich2.sh @@ -26,4 +26,5 @@ if [ "$TEST_NAME" == "LHCb_TEST_load_derich2" ]; then fi # run the test ... +echo ${ARGS} ../build.${BINARY_TAG}/bin/run ${ARGS} -- GitLab From 6216bb438a9519798570d70fb8fa952c99ad833b Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 23 Mar 2022 17:21:05 +0000 Subject: [PATCH 4/4] Fix double application of cm^2->mm^2 scale factor with m_effPixelArea --- Detector/Rich/include/Detector/Rich/DeRichMapmt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detector/Rich/include/Detector/Rich/DeRichMapmt.h b/Detector/Rich/include/Detector/Rich/DeRichMapmt.h index e87a3cf22f..69987c96d4 100644 --- a/Detector/Rich/include/Detector/Rich/DeRichMapmt.h +++ b/Detector/Rich/include/Detector/Rich/DeRichMapmt.h @@ -47,7 +47,7 @@ namespace LHCb::Detector::detail { auto moduleCopyNum() const noexcept { return this->access()->m_MapmtModuleCopyNum; } auto isHType() const noexcept { return this->access()->m_isHType; } auto QE() const noexcept { return scalePhotonEnergies( this->access()->m_PmtQE ); } - auto effPixelArea() const noexcept { return toLHCbAreaUnits( this->access()->m_effPixelArea ); } + auto effPixelArea() const noexcept { return this->access()->m_effPixelArea; } auto numPixels() const noexcept { return this->access()->m_numPixels; } }; -- GitLab