ATLAS Offline Software
Loading...
Searching...
No Matches
NswErrorCalibData Class Reference

#include <NswErrorCalibData.h>

Inheritance diagram for NswErrorCalibData:
Collaboration diagram for NswErrorCalibData:

Classes

class  ErrorConstants
 Helper struct to store different error calibrations for a certain channel range & also for seperate ClusterBuilders (ROT & Prd making stage) More...
struct  ErrorIdentifier
struct  Input
 Helper struct to be parsed to the object to derive the specific error of the cluster. More...

Public Types

using errorParametrizer
using ErrorConstantsSet = std::set<ErrorConstants, std::less<>>
 Share the same error constants amongst several gasGaps.

Public Member Functions

 NswErrorCalibData (const Muon::IMuonIdHelperSvc *idHelperSvc)
 ~NswErrorCalibData ()=default
StatusCode storeConstants (const Identifier &gasGapId, ErrorConstants &&newConstants)
double clusterUncertainty (const Input &clustInfo) const
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

static errorParametrizer getParametrizer (const std::string &funcName)

Private Types

using ErrorMap = std::unordered_map<Identifier, ErrorConstantsSet>

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

const Muon::IMuonIdHelperSvcm_idHelperSvc {nullptr}
ErrorMap m_database {}
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Definition at line 19 of file NswErrorCalibData.h.

Member Typedef Documentation

◆ ErrorConstantsSet

using NswErrorCalibData::ErrorConstantsSet = std::set<ErrorConstants, std::less<>>

Share the same error constants amongst several gasGaps.

Definition at line 83 of file NswErrorCalibData.h.

◆ ErrorMap

using NswErrorCalibData::ErrorMap = std::unordered_map<Identifier, ErrorConstantsSet>
private

Definition at line 96 of file NswErrorCalibData.h.

◆ errorParametrizer

Initial value:
std::function<double(const Input& input,
const std::vector<double>& pars)>
Helper struct to be parsed to the object to derive the specific error of the cluster.

Definition at line 42 of file NswErrorCalibData.h.

Constructor & Destructor Documentation

◆ NswErrorCalibData()

NswErrorCalibData::NswErrorCalibData ( const Muon::IMuonIdHelperSvc * idHelperSvc)

Definition at line 93 of file NswErrorCalibData.cxx.

93 :
94 AthMessaging{"NswErrorCalibData"},
95 m_idHelperSvc{idHelperSvc} {
96
97}
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
const Muon::IMuonIdHelperSvc * m_idHelperSvc

◆ ~NswErrorCalibData()

NswErrorCalibData::~NswErrorCalibData ( )
default

Member Function Documentation

◆ clusterUncertainty()

double NswErrorCalibData::clusterUncertainty ( const Input & clustInfo) const

Definition at line 98 of file NswErrorCalibData.cxx.

98 {
99 ErrorMap::const_iterator nswLayerItr = m_database.find(m_idHelperSvc->gasGapId(clustInfo.stripId));
100 if (nswLayerItr == m_database.end()) {
101 ATH_MSG_WARNING("There's no error calibration available for gasGap "
102 << m_idHelperSvc->toStringGasGap(clustInfo.stripId)<<".");
103 return -1.;
104 }
105 ErrorIdentifier errorId{};
106 if (m_idHelperSvc->isMM(clustInfo.stripId)) {
107 errorId.strip = m_idHelperSvc->mmIdHelper().channel(clustInfo.stripId);
108 } else if (m_idHelperSvc->issTgc(clustInfo.stripId)) {
109 errorId.strip = m_idHelperSvc->stgcIdHelper().channel(clustInfo.stripId);
110 }
111 errorId.clusAlgAuthor = clustInfo.clusterAuthor;
112 const ErrorConstantsSet& errorsInLay{nswLayerItr->second};
113 const ErrorConstantsSet::const_iterator layConstItr = errorsInLay.find(errorId);
114 if (layConstItr != errorsInLay.end()) {
115 const double uncert = layConstItr->clusterUncertainty(clustInfo);
116 if (uncert <= 0.) {
117 ATH_MSG_WARNING("Uncertainty of channel "<<m_idHelperSvc->toString(clustInfo.stripId)
118 <<" is smaller than zero ("<<uncert<<"). theta: "<<clustInfo.locTheta
119 <<", eta: "<<(-std::log(std::tan(clustInfo.locTheta/2)))
120 <<", phi: "<<clustInfo.locPhi<<", cluster size: "<<clustInfo.clusterSize
121 << ", author " << static_cast<uint>(clustInfo.clusterAuthor)
122 << ", pars " << layConstItr->pars());
123 }
124 return uncert;
125 }
126 ATH_MSG_WARNING("No calibration constants were stored for channel "<<m_idHelperSvc->toString(clustInfo.stripId)
127 <<", cluster Author: "<<static_cast<int>(clustInfo.clusterAuthor));
128 return 0.;
129}
#define ATH_MSG_WARNING(x)
unsigned int uint
std::set< ErrorConstants, std::less<> > ErrorConstantsSet
Share the same error constants amongst several gasGaps.
unsigned int clusterSize
Cluster size.
double locTheta
Direction of the muon in the local coordinate frame.
Identifier stripId
Identifier of the strip.
uint8_t clusterAuthor
Author of the cluster.
double locPhi
Azimuthal angle in the local frame.

◆ getParametrizer()

errorParametrizer NswErrorCalibData::getParametrizer ( const std::string & funcName)
static

Return a surprise box if the function is unknown

Definition at line 31 of file NswErrorCalibData.cxx.

31 {
32 if (funcName == "tanThetaPolynomial") {
33 return [](const Input & input, const std::vector<double>& pars){
34 return evalPoly(std::tan(input.locTheta), pars);
35 };
36 } else if (funcName == "thetaPolynomial") {
37 return [](const Input & input, const std::vector<double>& pars){
38 return evalPoly(input.locTheta, pars);
39 };
40 } else if (funcName == "scaleErrorAndAddSyst"){
41 return [](const Input& input, const std::vector<double>& pars){
42 return scaleErrorAndAddSyst(input.clusterError, pars);
43 };
44 }
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.";
51 THROW_EXCEPTION(except_str.str());
52}
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 182 of file AthMessaging.h.

183{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 // If user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ storeConstants()

StatusCode NswErrorCalibData::storeConstants ( const Identifier & gasGapId,
ErrorConstants && newConstants )

Check that min strip is actually smaller than max strip

Definition at line 130 of file NswErrorCalibData.cxx.

131 {
133 if (newConstants.minStrip() > newConstants.maxStrip()) {
134 ATH_MSG_ERROR("The constants for gas gap"<<m_idHelperSvc->toStringGasGap(gasGapId)
135 <<" have an invalid strip range"<<newConstants.minStrip()<<" to "<<newConstants.maxStrip());
136 return StatusCode::FAILURE;
137 }
138 ErrorConstantsSet& constants{m_database[gasGapId]};
139 if (!constants.insert(std::move(newConstants)).second) {
140 ATH_MSG_ERROR("Failed to save error calibration constants for "<<m_idHelperSvc->toStringGasGap(gasGapId));
141 return StatusCode::FAILURE;
142 }
143 return StatusCode::SUCCESS;
144}
#define ATH_MSG_ERROR(x)

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_database

ErrorMap NswErrorCalibData::m_database {}
private

Definition at line 97 of file NswErrorCalibData.h.

97{};

◆ m_idHelperSvc

const Muon::IMuonIdHelperSvc* NswErrorCalibData::m_idHelperSvc {nullptr}
private

Definition at line 95 of file NswErrorCalibData.h.

95{nullptr};

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.


The documentation for this class was generated from the following files: