6#include "GeoModelKernel/throwExcept.h"
11 inline double evalPoly(
const double val,
const std::vector<double>& pars) {
13 for (
size_t c = 0 ; c < pars.size(); ++c) {
14 result+=pars[c] * std::pow(val, c);
18 inline double scaleErrorAndAddSyst(
const double val,
const std::vector<double>& pars) {
19 return std::hypot(pars[0], pars[1]*val);
32 if (funcName ==
"tanThetaPolynomial") {
33 return [](
const Input & input,
const std::vector<double>& pars){
34 return evalPoly(std::tan(input.locTheta), pars);
36 }
else if (funcName ==
"thetaPolynomial") {
37 return [](
const Input & input,
const std::vector<double>& pars){
38 return evalPoly(input.locTheta, pars);
40 }
else if (funcName ==
"scaleErrorAndAddSyst"){
41 return [](
const Input& input,
const std::vector<double>& pars){
42 return scaleErrorAndAddSyst(input.clusterError, pars);
46 std::stringstream except_str;
47 except_str <<
"NswErrorCalibData::getParametrizer() - The function '"
48 << funcName <<
"' is unknown. "
49 <<
"Please check " << __FILE__
50 <<
" for the set of valid function names.";
56 if (
a.author() != b.clusAlgAuthor)
return a.author() < b.clusAlgAuthor;
57 return a.maxStrip() < b.strip;
60 if (
a.clusAlgAuthor != b.author())
return a.clusAlgAuthor < b.author();
61 return a.strip < b.minStrip();
72 std::vector<double>&&
pars):
113 const ErrorConstantsSet::const_iterator layConstItr = errorsInLay.find(errorId);
114 if (layConstItr != errorsInLay.end()) {
115 const double uncert = layConstItr->clusterUncertainty(clustInfo);
118 <<
" is smaller than zero ("<<uncert<<
"). theta: "<<clustInfo.
locTheta
119 <<
", eta: "<<(-std::log(std::tan(clustInfo.
locTheta/2)))
122 <<
", pars " << layConstItr->pars());
127 <<
", cluster Author: "<<
static_cast<int>(clustInfo.
clusterAuthor));
133 if (newConstants.minStrip() > newConstants.maxStrip()) {
135 <<
" have an invalid strip range"<<newConstants.minStrip()<<
" to "<<newConstants.maxStrip());
136 return StatusCode::FAILURE;
139 if (!
constants.insert(std::move(newConstants)).second) {
141 return StatusCode::FAILURE;
143 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)