diff --git a/Detector/Rich/include/Detector/Rich/DeRich.h b/Detector/Rich/include/Detector/Rich/DeRich.h index 5dca0737be4d18f154887577419c361f47aa1019..906d2c95da6a0536ee0b017665e53c3b7c462211 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/DeRichMapmt.h b/Detector/Rich/include/Detector/Rich/DeRichMapmt.h index e87a3cf22f7d4877d7ada2a9c82bc00f0e02e113..69987c96d439b966ed16de832dd445de489b5f75 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; } }; diff --git a/Detector/Rich/include/Detector/Rich/DeRichPhDetPanel.h b/Detector/Rich/include/Detector/Rich/DeRichPhDetPanel.h index fd402c083107e7cbb837f3ac35a86fba41442294..28e24ce93bc2b7e5d52c0dab0f184f6c17bdcd03 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 a0f9a4436127c002d0d1f29c44bb20239328991a..a912e18efaabcfcd8a6eca14463bfa31f7bd3c0c 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,99 @@ 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"}, + {"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; } // 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; + 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() ) ); + } + 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() ); } diff --git a/examples/runtestRich1.sh b/examples/runtestRich1.sh index f00216603cb3a2ba26a740326462a8623d058569..d02327f99dda439ed6f40297acece88c908387bd 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 c0c9a8e237827b900bfec3b9a80d2188a9f31a90..1633538a044f7e4164bb77f9bdef129ea8c439de 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}