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 91 of file NswErrorCalibData.cxx.

91 :
92 AthMessaging{"NswErrorCalibData"},
93 m_idHelperSvc{idHelperSvc} {
94
95}
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 96 of file NswErrorCalibData.cxx.

96 {
97 ErrorMap::const_iterator nswLayerItr = m_database.find(m_idHelperSvc->gasGapId(clustInfo.stripId));
98 if (nswLayerItr == m_database.end()) {
99 ATH_MSG_WARNING("There's no error calibration available for gasGap "
100 << m_idHelperSvc->toStringGasGap(clustInfo.stripId)<<".");
101 return -1.;
102 }
103 ErrorIdentifier errorId{};
104 if (m_idHelperSvc->isMM(clustInfo.stripId)) {
105 errorId.strip = m_idHelperSvc->mmIdHelper().channel(clustInfo.stripId);
106 } else if (m_idHelperSvc->issTgc(clustInfo.stripId)) {
107 errorId.strip = m_idHelperSvc->stgcIdHelper().channel(clustInfo.stripId);
108 }
109 errorId.clusAlgAuthor = clustInfo.clusterAuthor;
110 const ErrorConstantsSet& errorsInLay{nswLayerItr->second};
111 const ErrorConstantsSet::const_iterator layConstItr = errorsInLay.find(errorId);
112 if (layConstItr != errorsInLay.end()) {
113 const double uncert = layConstItr->clusterUncertainty(clustInfo);
114 if (uncert <= 0.) {
115 ATH_MSG_WARNING("Uncertainty of channel "<<m_idHelperSvc->toString(clustInfo.stripId)
116 <<" is smaller than zero ("<<uncert<<"). theta: "<<clustInfo.locTheta
117 <<", eta: "<<(-std::log(std::tan(clustInfo.locTheta/2)))
118 <<", phi: "<<clustInfo.locPhi<<", cluster size: "<<clustInfo.clusterSize
119 << ", author " << static_cast<uint>(clustInfo.clusterAuthor)
120 << ", pars " << layConstItr->pars());
121 }
122 return uncert;
123 }
124 ATH_MSG_WARNING("No calibration constants were stored for channel "<<m_idHelperSvc->toString(clustInfo.stripId)
125 <<", cluster Author: "<<static_cast<int>(clustInfo.clusterAuthor));
126 return 0.;
127}
#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 28 of file NswErrorCalibData.cxx.

28 {
29 if (funcName == "tanThetaPolynomial") {
30 return [](const Input & input, const std::vector<double>& pars){
31 return evalPoly(std::tan(input.locTheta), pars);
32 };
33 } else if (funcName == "thetaPolynomial") {
34 return [](const Input & input, const std::vector<double>& pars){
35 return evalPoly(input.locTheta, pars);
36 };
37 } else if (funcName == "scaleErrorAndAddSyst"){
38 return [](const Input& input, const std::vector<double>& pars){
39 return scaleErrorAndAddSyst(input.clusterError, pars);
40 };
41 }
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. ";
47 THROW_EXCEPTION(except_str.str());
48 return 0.;
49 };
50}
#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 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
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 178 of file AthMessaging.h.

179{ 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 (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ 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 128 of file NswErrorCalibData.cxx.

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