ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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 = std::function< double(const Input &input, const std::vector< double > &pars)>
 
using ErrorConstantsSet = std::set< ErrorConstants, std::less<> >
 Share the same error constants amongst several gasGaps. More...
 

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. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

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. More...
 

Private Attributes

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

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

using NswErrorCalibData::errorParametrizer = std::function<double(const Input& input, const std::vector<double>& pars)>

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 }

◆ ~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 }

◆ 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 }

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ 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 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ 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 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ 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_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ 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  }
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 }

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.

◆ m_idHelperSvc

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

Definition at line 95 of file NswErrorCalibData.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
Muon::IMuonIdHelperSvc::stgcIdHelper
virtual const sTgcIdHelper & stgcIdHelper() const =0
access to TgcIdHelper
NswErrorCalibData::Input::locPhi
double locPhi
Azimuthal angle in the local frame.
Definition: NswErrorCalibData.h:33
NswErrorCalibData::m_idHelperSvc
const Muon::IMuonIdHelperSvc * m_idHelperSvc
Definition: NswErrorCalibData.h:95
NswErrorCalibData::Input::clusterSize
unsigned int clusterSize
Cluster size.
Definition: NswErrorCalibData.h:37
THROW_EXCEPTION
#define THROW_EXCEPTION(MSG)
Definition: MMReadoutElement.cxx:48
Muon::IMuonIdHelperSvc::mmIdHelper
virtual const MmIdHelper & mmIdHelper() const =0
access to CscIdHelper
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
NswErrorCalibData::Input::locTheta
double locTheta
Direction of the muon in the local coordinate frame.
Definition: NswErrorCalibData.h:31
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
sTgcIdHelper::channel
int channel(const Identifier &id) const override
Definition: sTgcIdHelper.cxx:1027
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
Muon::IMuonIdHelperSvc::toStringGasGap
virtual std::string toStringGasGap(const Identifier &id) const =0
print all fields up to gas gap to string
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
NswErrorCalibData::ErrorConstantsSet
std::set< ErrorConstants, std::less<> > ErrorConstantsSet
Share the same error constants amongst several gasGaps.
Definition: NswErrorCalibData.h:83
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
NswErrorCalibData::Input::stripId
Identifier stripId
Identifier of the strip.
Definition: NswErrorCalibData.h:27
Muon::IMuonIdHelperSvc::isMM
virtual bool isMM(const Identifier &id) const =0
returns whether this is a MM Identifier or not
Muon::IMuonIdHelperSvc::gasGapId
virtual Identifier gasGapId(const Identifier &id) const =0
create a gasGap ID (will return layer Id for MDTs)
MmIdHelper::channel
int channel(const Identifier &id) const override
Definition: MmIdHelper.cxx:800
Muon::IMuonIdHelperSvc::toString
virtual std::string toString(const Identifier &id) const =0
print all fields to string
constants
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:1
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
NswErrorCalibData::m_database
ErrorMap m_database
Definition: NswErrorCalibData.h:97
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
NswErrorCalibData::Input
Helper struct to be parsed to the object to derive the specific error of the cluster.
Definition: NswErrorCalibData.h:25
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
Muon::IMuonIdHelperSvc::issTgc
virtual bool issTgc(const Identifier &id) const =0
returns whether this is a sTGC Identifier or not
NswErrorCalibData::Input::clusterAuthor
uint8_t clusterAuthor
Author of the cluster.
Definition: NswErrorCalibData.h:29