Skip to content
Snippets Groups Projects

Rich update with additional detector element access classes

Merged Sajan Easo requested to merge dd4hep-RichDetectorSystem-FromFebruary15-2022 into master
Compare and
70 files
+ 3777
2216
Compare changes
  • Side-by-side
  • Inline
Files
70
+ 142
0
/*****************************************************************************\
* (c) Copyright 2000-2019 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*******************************************************************************/
#pragma once
#include "Core/DeIOV.h"
#include "Detector/Rich/Types.h"
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
namespace LHCb::Detector {
namespace detail {
struct DeRichObject : DeIOVObject {
Rich::DetectorType m_rich = Rich::InvalidDetector;
int m_NumSides = -1;
int m_nSphMirrorSegRows = -1;
int m_nSphMirrorSegCols = -1;
int m_nSecMirrorSegRows = -1;
int m_nSecMirrorSegCols = -1;
XYTable m_NominalPmtQE;
XYTable m_SphMNominalRefl;
XYTable m_SecMNominalRefl;
XYTable m_QWNominalAbsLen;
double m_sphMirrorNominalROC = 0;
Rich::PanelArray<dd4hep::Position> m_NominalPanelCoC;
// using DeIOVObject::DeIOVObject;
DeRichObject( const Rich::DetectorType rich, //
const dd4hep::DetElement& de, //
dd4hep::cond::ConditionUpdateContext& ctxt );
// mimic 'param' method from DetDesc
template <typename TYPE>
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<std::string, std::string>;
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...
if constexpr ( std::is_arithmetic_v<TYPE> ) {
// 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<std::string, TYPE>;
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<TYPE> ) { return F * dd4hep::_toInt( name.c_str() ); }
if constexpr ( std::is_same_v<double, TYPE> ) { return F * dd4hep::_toDouble( name.c_str() ); }
if constexpr ( std::is_same_v<float, TYPE> ) { return F * dd4hep::_toFloat( name.c_str() ); }
}
if constexpr ( std::is_same_v<std::string, TYPE> ) { return dd4hep::_toString( name.c_str() ); }
// compiler error if we get here ...
}
};
} // namespace detail
template <typename ObjectType>
struct DeRichElement : DeIOVElement<ObjectType> {
using DeIOVElement<ObjectType>::DeIOVElement;
/// RICH type enum
inline auto rich() const noexcept { return this->access()->m_rich; }
// Number of Sides
inline auto NumSides() const noexcept { return ( this->access()->m_NumSides ); }
/// number of primary mirror rows
inline auto nSphMirrorSegRows() const noexcept { return this->access()->m_nSphMirrorSegRows; }
/// number of primary mirror columns
inline auto nSphMirrorSegCols() const noexcept { return this->access()->m_nSphMirrorSegCols; }
/// number of primary mirror rows
inline auto nSecMirrorSegRows() const noexcept { return this->access()->m_nSecMirrorSegRows; }
/// number of primary mirror columns
inline auto nSecMirrorSegCols() const noexcept { return this->access()->m_nSecMirrorSegCols; }
/// table of (x,y) values for the nominal PD QE curve
inline const auto& nominalPDQuantumEff() const noexcept { return ( this->access()->m_NominalPmtQE ); }
/// table of (x,y) values for the nominal primary mirror reflectivity
inline const auto& nominalSphMirrorRefl() const noexcept { return ( this->access()->m_SphMNominalRefl ); }
/// table of (x,y) values for the nominal secondary mirror reflectivity
inline const auto& nominalSecMirrorRefl() const noexcept { return ( this->access()->m_SecMNominalRefl ); }
/// table of (x,y) values for the nominal gas quartz window absorption length
inline const auto& gasWinAbsLength() const noexcept { return ( this->access()->m_QWNominalAbsLen ); }
/// 'Nominal' radius of curvature of primary mirror
inline auto sphMirrorRadius() const noexcept { return ( this->access()->m_sphMirrorNominalROC ); }
/// 'nominal' centre of curvature of the spherical mirror for given side
inline const auto& nominalCentreOfCurvature( const Rich::Side side ) const noexcept {
return this->access()->m_NominalPanelCoC[side];
}
/// Access parameters
template <typename TYPE>
inline auto param( std::string name ) const {
return this->access()->template param<TYPE>( std::move( name ) );
}
};
using DeRich = detail::DeRichObject;
} // namespace LHCb::Detector
Loading