ATLAS Offline Software
Loading...
Searching...
No Matches
PanTau::HelperFunctions Class Reference

#include <HelperFunctions.h>

Inheritance diagram for PanTau::HelperFunctions:
Collaboration diagram for PanTau::HelperFunctions:

Public Member Functions

 HelperFunctions (const std::string &name="")
virtual ~HelperFunctions ()
virtual std::string convertNumberToString (double x) const
virtual int getBinIndex (const std::vector< double > &binEdges, double value) const
virtual double stddev (double sumOfSquares, double sumOfValues, int numConsts) const
const std::string & getName () const
void setLevel (MSG::Level lvl)
 Change the current logging level.
Functions providing the same interface as AthMessaging
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.

Static Public Member Functions

template<class T>
static StatusCode bindToolHandle (ToolHandle< T > &, std::string)

Private Member Functions

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

Private Attributes

std::string m_name
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

Constructor & Destructor Documentation

◆ HelperFunctions()

PanTau::HelperFunctions::HelperFunctions ( const std::string & name = "")
inline

Definition at line 31 of file Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h.

31 :
32 AsgMessaging(name),
33 m_name(name)
34 {}
AsgMessaging(const std::string &name)
Constructor with a name.

◆ ~HelperFunctions()

virtual PanTau::HelperFunctions::~HelperFunctions ( )
inlinevirtual

Member Function Documentation

◆ bindToolHandle()

template<class T>
StatusCode PanTau::HelperFunctions::bindToolHandle ( ToolHandle< T > & ,
std::string  )
inlinestatic

Definition at line 56 of file Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h.

56{return StatusCode::SUCCESS;}

◆ convertNumberToString()

std::string PanTau::HelperFunctions::convertNumberToString ( double x) const
virtual

Definition at line 8 of file Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx.

8 {
9 std::stringstream tmpStream;
10 tmpStream << x;
11 return tmpStream.str();
12}
#define x

◆ getBinIndex()

int PanTau::HelperFunctions::getBinIndex ( const std::vector< double > & binEdges,
double value ) const
virtual

Definition at line 15 of file Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx.

15 {
16 int resBin = -1;
17 for(unsigned int i=0; i<binEdges.size()-1; i++) {
18 double lowerEdge = binEdges[i];
19 double upperEdge = binEdges[i+1];
20 if(lowerEdge <= value && value < upperEdge) resBin = i;
21 }
22 if(resBin == -1) {
23 ATH_MSG_WARNING("Could not find matching bin for value " << value << " in these bin edges:");
24 for(unsigned int i=0; i<binEdges.size(); i++) ATH_MSG_WARNING("\tbin edge " << i << ": " << binEdges[i]);
25 }
26 return resBin;
27}
#define ATH_MSG_WARNING(x)

◆ getName()

const std::string & PanTau::HelperFunctions::getName ( ) const
inline

Definition at line 59 of file Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h.

60 {
61 return m_name;
62 }

◆ 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 & asg::AsgMessaging::msg ( ) const
inherited

The standard message stream.

Returns
A reference to the default message stream of this object.

Definition at line 49 of file AsgMessaging.cxx.

49 {
50#ifndef XAOD_STANDALONE
51 return ::AthMessaging::msg();
52#else // not XAOD_STANDALONE
53 return m_msg;
54#endif // not XAOD_STANDALONE
55 }

◆ msg() [2/2]

MsgStream & asg::AsgMessaging::msg ( const MSG::Level lvl) const
inherited

The standard message stream.

Parameters
lvlThe message level to set the stream to
Returns
A reference to the default message stream, set to level "lvl"

Definition at line 57 of file AsgMessaging.cxx.

57 {
58#ifndef XAOD_STANDALONE
59 return ::AthMessaging::msg( lvl );
60#else // not XAOD_STANDALONE
61 m_msg << lvl;
62 return m_msg;
63#endif // not XAOD_STANDALONE
64 }

◆ msgLvl()

bool asg::AsgMessaging::msgLvl ( const MSG::Level lvl) const
inherited

Test the output level of the object.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
true If messages at level "lvl" will be printed

Definition at line 41 of file AsgMessaging.cxx.

41 {
42#ifndef XAOD_STANDALONE
43 return ::AthMessaging::msgLvl( lvl );
44#else // not XAOD_STANDALONE
45 return m_msg.msgLevel( lvl );
46#endif // not XAOD_STANDALONE
47 }

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

◆ stddev()

double PanTau::HelperFunctions::stddev ( double sumOfSquares,
double sumOfValues,
int numConsts ) const
virtual

Definition at line 30 of file Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx.

30 {
31 // calculate standard deviations according to:
32 // sigma^2 = (sum_i x_i^2) / N - ((sum_i x_i)/N)^2 (biased maximum-likelihood estimate)
33 // directly set sigma^2 to 0 in case of N=1, otherwise numerical effects may yield very small negative sigma^2
34 if(numConsts == 1) return 0;
35 double a = sumOfSquares / (static_cast<double>(numConsts));
36 double b = sumOfValues / (static_cast<double>(numConsts));
37 double stdDev = a - b*b;
38 if(stdDev < 0.) stdDev = 0;
39 return std::sqrt(stdDev);
40}
static Double_t a

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_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_name

std::string PanTau::HelperFunctions::m_name
private

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