ATLAS Offline Software
Loading...
Searching...
No Matches
CP::IsoVariableHelper Class Reference

#include <IsoVariableHelper.h>

Inheritance diagram for CP::IsoVariableHelper:
Collaboration diagram for CP::IsoVariableHelper:

Public Member Functions

CorrectionCode getOriginalIsolation (const xAOD::IParticle *particle, float &value) const
CorrectionCode getIsolation (const xAOD::IParticle *particle, float &value) const
CorrectionCode backupIsolation (const xAOD::IParticle *particle) const
CorrectionCode setIsolation (const xAOD::IParticle *P, float value) const
IsoType isotype () const
std::string name () const
 IsoVariableHelper (IsoType type, const std::string &backupPreFix, const std::string &isoDecSuffix="")
void lockDecorations (const SG::AuxVectorData &parts) 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.

Private Member Functions

CorrectionCode getIsolationFromOriginal (const xAOD::IParticle *particle, float &value) const
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

IsoType m_isoType
bool m_BackupIso
CharDecorator m_dec_IsoIsBackup
CharAccessor m_acc_IsoIsBackup
FloatAccessor m_acc_iso_variable
FloatDecorator m_dec_iso_variable
FloatAccessor m_acc_iso_backup
FloatDecorator m_dec_iso_backup
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 20 of file IsoVariableHelper.h.

Constructor & Destructor Documentation

◆ IsoVariableHelper()

CP::IsoVariableHelper::IsoVariableHelper ( IsoType type,
const std::string & backupPreFix,
const std::string & isoDecSuffix = "" )

Definition at line 14 of file IsoVariableHelper.cxx.

14 :
15 asg::AsgMessaging{"IsoVariableHelper_ "+ std::string(xAOD::Iso::toString(type))},
16 m_isoType(type),
17 m_BackupIso(!backupPreFix.empty()),
18 m_dec_IsoIsBackup("IsBackup_" + std::string(xAOD::Iso::toString(type)) + (backupPreFix.empty() ? "" : "_") + backupPreFix),
19 m_acc_IsoIsBackup("IsBackup_" + std::string(xAOD::Iso::toString(type)) + (backupPreFix.empty() ? "" : "_") + backupPreFix),
21 m_dec_iso_variable(xAOD::Iso::toString(type) + (isoDecSuffix.empty() ? "" : "_") + isoDecSuffix),
22 m_acc_iso_backup(std::string(xAOD::Iso::toString(type)) + (backupPreFix.empty() ? "" : "_") + backupPreFix),
23 m_dec_iso_backup(std::string(xAOD::Iso::toString(type)) + (backupPreFix.empty() ? "" : "_") + backupPreFix) {}
FloatAccessor m_acc_iso_backup
CharDecorator m_dec_IsoIsBackup
FloatDecorator m_dec_iso_backup
FloatAccessor m_acc_iso_variable
FloatDecorator m_dec_iso_variable
std::string toString(const IsoType &iso)

Member Function Documentation

◆ backupIsolation()

CorrectionCode CP::IsoVariableHelper::backupIsolation ( const xAOD::IParticle * particle) const

Definition at line 64 of file IsoVariableHelper.cxx.

64 {
65 if (!particle) {
66 ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": no particle given");
68 }
69 if (m_BackupIso && (!m_acc_IsoIsBackup.isAvailable(*particle) || !m_acc_IsoIsBackup(*particle))) {
70 float Isovalue = 0;
71 if (getIsolation(particle, Isovalue) == CorrectionCode::Error) {
73 }
74 m_dec_IsoIsBackup(*particle) = true;
75 m_dec_iso_backup(*particle) = Isovalue;
76 }
77 return CorrectionCode::Ok;
78 }
#define ATH_MSG_ERROR(x)
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
CorrectionCode getIsolation(const xAOD::IParticle *particle, float &value) const

◆ getIsolation()

CorrectionCode CP::IsoVariableHelper::getIsolation ( const xAOD::IParticle * particle,
float & value ) const

Definition at line 55 of file IsoVariableHelper.cxx.

55 {
56 if (!particle || !m_acc_iso_variable.isAvailable(*particle)) {
57 ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": Failed to retrieve isolation "<<
60 }
61 value = m_acc_iso_variable(*particle);
62 return CorrectionCode::Ok;
63 }
static AuxTypeRegistry & instance()
Return the singleton registry instance.

◆ getIsolationFromOriginal()

CorrectionCode CP::IsoVariableHelper::getIsolationFromOriginal ( const xAOD::IParticle * particle,
float & value ) const
private

Definition at line 45 of file IsoVariableHelper.cxx.

45 {
46 const xAOD::IParticle* originalParticle = xAOD::getOriginalObject(*particle);
47 if (originalParticle && getIsolation(originalParticle, value) == CorrectionCode::Error)
49 else if (!originalParticle) {
50 ATH_MSG_DEBUG(__func__<<"() -- "<<__LINE__<<": No orignal object was found");
51 return getIsolation(particle, value);
52 }
53 return CorrectionCode::Ok;
54 }
#define ATH_MSG_DEBUG(x)
const IParticle * getOriginalObject(const IParticle &copy)
This function can be used to conveniently get a pointer back to the original object from which a copy...

◆ getOriginalIsolation()

CorrectionCode CP::IsoVariableHelper::getOriginalIsolation ( const xAOD::IParticle * particle,
float & value ) const

Definition at line 25 of file IsoVariableHelper.cxx.

25 {
26 if (!particle) {
27 ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": no particle given");
29 }
30 if (!m_BackupIso) {
31 return getIsolationFromOriginal(particle, value);
32 } else {
33 if (!m_acc_IsoIsBackup.isAvailable(*particle) || !m_acc_IsoIsBackup(*particle)) {
34 ATH_MSG_WARNING(__func__<<"() -- "<<__LINE__<<":"
35 <<" No isolation value was backuped thus far. "
36 <<"Did you call the BackupIsolation before for "
39 } else {
40 value = m_acc_iso_backup(*particle);
41 }
42 }
43 return CorrectionCode::Ok;
44 }
#define ATH_MSG_WARNING(x)
CorrectionCode getIsolationFromOriginal(const xAOD::IParticle *particle, float &value) const

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

◆ isotype()

IsoType CP::IsoVariableHelper::isotype ( ) const

Definition at line 91 of file IsoVariableHelper.cxx.

91{ return m_isoType; }

◆ lockDecorations()

void CP::IsoVariableHelper::lockDecorations ( const SG::AuxVectorData & parts) const

Definition at line 94 of file IsoVariableHelper.cxx.

95 {
96 SG::AuxVectorData& parts_nc ATLAS_THREAD_SAFE =
97 const_cast<SG::AuxVectorData&> (parts);
98 parts_nc.lockDecoration (m_dec_IsoIsBackup.auxid());
99 parts_nc.lockDecoration (m_dec_iso_variable.auxid());
100 parts_nc.lockDecoration (m_dec_iso_backup.auxid());
101 }
std::atomic_flag m_initialized ATLAS_THREAD_SAFE
Messaging initialized (initMessaging)

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

◆ name()

std::string CP::IsoVariableHelper::name ( ) const

Definition at line 92 of file IsoVariableHelper.cxx.

92{ return std::string(xAOD::Iso::toCString(isotype())); }
static const char * toCString(IsolationConeSize conesize)

◆ setIsolation()

CorrectionCode CP::IsoVariableHelper::setIsolation ( const xAOD::IParticle * P,
float value ) const

Definition at line 79 of file IsoVariableHelper.cxx.

79 {
80 if (!particle) {
81 ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": no particle given");
83 }
84 if (std::isnan(value) || std::isinf(value)) {
85 ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": the value is not a number");
87 }
88 m_dec_iso_variable(*particle) = value;
89 return CorrectionCode::Ok;
90 }

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

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_acc_iso_backup

FloatAccessor CP::IsoVariableHelper::m_acc_iso_backup
private

Definition at line 44 of file IsoVariableHelper.h.

◆ m_acc_iso_variable

FloatAccessor CP::IsoVariableHelper::m_acc_iso_variable
private

Definition at line 41 of file IsoVariableHelper.h.

◆ m_acc_IsoIsBackup

CharAccessor CP::IsoVariableHelper::m_acc_IsoIsBackup
private

Definition at line 39 of file IsoVariableHelper.h.

◆ m_BackupIso

bool CP::IsoVariableHelper::m_BackupIso
private

Definition at line 37 of file IsoVariableHelper.h.

◆ m_dec_iso_backup

FloatDecorator CP::IsoVariableHelper::m_dec_iso_backup
private

Definition at line 45 of file IsoVariableHelper.h.

◆ m_dec_iso_variable

FloatDecorator CP::IsoVariableHelper::m_dec_iso_variable
private

Definition at line 42 of file IsoVariableHelper.h.

◆ m_dec_IsoIsBackup

CharDecorator CP::IsoVariableHelper::m_dec_IsoIsBackup
private

Definition at line 38 of file IsoVariableHelper.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_isoType

IsoType CP::IsoVariableHelper::m_isoType
private

Definition at line 36 of file IsoVariableHelper.h.

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