3#include "GeoModelKernel/throwExcept.h"
8 inline double evalPoly(
const double val,
const std::vector<double>& pars) {
10 for (
size_t c = 0 ; c < pars.size(); ++c) {
11 result+=pars[c] * std::pow(val, c);
15 inline double scaleErrorAndAddSyst(
const double val,
const std::vector<double>& pars) {
16 return std::hypot(pars[0], pars[1]*val);
29 if (funcName ==
"tanThetaPolynomial") {
30 return [](
const Input & input,
const std::vector<double>& pars){
31 return evalPoly(std::tan(input.locTheta), pars);
33 }
else if (funcName ==
"thetaPolynomial") {
34 return [](
const Input & input,
const std::vector<double>& pars){
35 return evalPoly(input.locTheta, pars);
37 }
else if (funcName ==
"scaleErrorAndAddSyst"){
38 return [](
const Input& input,
const std::vector<double>& pars){
39 return scaleErrorAndAddSyst(input.clusterError, pars);
43 return [funcName](
const Input&,
const std::vector<double>& ) {
44 std::stringstream except_str{};
45 except_str<<
"NswErrorCalibData::parametrizer() - The function '"<<funcName<<
"' is unknown.";
46 except_str<<
"Please check"<<__FILE__<<
" for the set of valid function names. ";
54 if (
a.author() != b.clusAlgAuthor)
return a.author() < b.clusAlgAuthor;
55 return a.maxStrip() < b.strip;
58 if (
a.clusAlgAuthor != b.author())
return a.clusAlgAuthor < b.author();
59 return a.strip < b.minStrip();
70 std::vector<double>&&
pars):
111 const ErrorConstantsSet::const_iterator layConstItr = errorsInLay.find(errorId);
112 if (layConstItr != errorsInLay.end()) {
113 const double uncert = layConstItr->clusterUncertainty(clustInfo);
116 <<
" is smaller than zero ("<<uncert<<
"). theta: "<<clustInfo.
locTheta
117 <<
", eta: "<<(-std::log(std::tan(clustInfo.
locTheta/2)))
120 <<
", pars " << layConstItr->pars());
125 <<
", cluster Author: "<<
static_cast<int>(clustInfo.
clusterAuthor));
131 if (newConstants.minStrip() > newConstants.maxStrip()) {
133 <<
" have an invalid strip range"<<newConstants.minStrip()<<
" to "<<newConstants.maxStrip());
134 return StatusCode::FAILURE;
137 if (!
constants.insert(std::move(newConstants)).second) {
139 return StatusCode::FAILURE;
141 return StatusCode::SUCCESS;
#define ATH_MSG_WARNING(x)
NswErrorCalibData::Input Input
NswErrorCalibData::errorParametrizer errorParametrizer
bool operator<(const NswErrorCalibData::ErrorConstants &a, const NswErrorCalibData::ErrorIdentifier &b)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Helper struct to store different error calibrations for a certain channel range & also for seperate C...
uint8_t m_clusAlgAuthor
Author of the cluster to apply the error.
errorParametrizer m_evalFunc
bool operator<(const ErrorConstants &other) const
const std::vector< double > & pars() const
uint16_t minStrip() const
Returns the minimal strip of validitiy.
uint16_t maxStrip() const
Returns the maximal strip of validity.
double clusterUncertainty(const Input &clustInfo) const
Calculates the cluster uncertainty.
std::vector< double > m_pars
ErrorConstants(const std::string &funcName, uint8_t author, uint16_t minStrip, uint16_t maxStrip, std::vector< double > &¶meters)
uint8_t author() const
Returns the cluster author flag.
uint16_t m_stripMin
Strip range for which the constants are valid.
static errorParametrizer getParametrizer(const std::string &funcName)
const Muon::IMuonIdHelperSvc * m_idHelperSvc
double clusterUncertainty(const Input &clustInfo) const
StatusCode storeConstants(const Identifier &gasGapId, ErrorConstants &&newConstants)
NswErrorCalibData(const Muon::IMuonIdHelperSvc *idHelperSvc)
std::set< ErrorConstants, std::less<> > ErrorConstantsSet
Share the same error constants amongst several gasGaps.
std::function< double(const Input &input, const std::vector< double > &pars)> errorParametrizer
#define THROW_EXCEPTION(MESSAGE)