ATLAS Offline Software
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
ORUtils::ToolBox Class Reference

A container and helper class for overlap removal tools. More...

#include <ToolBox.h>

Inheritance diagram for ORUtils::ToolBox:
Collaboration diagram for ORUtils::ToolBox:

Public Types

using parentType_t = INamedInterface
 Aliases. More...
 
using MasterHandle_t = asg::AnaToolHandle< IOverlapRemovalTool >
 
using OverlapHandle_t = asg::AnaToolHandle< IOverlapTool >
 

Public Member Functions

 ToolBox (const std::string &name="ORToolBox", parentType_t *theParent=nullptr)
 Basic constructor with name and parent. More...
 
StatusCode initialize ()
 Attach and initialize all tools. More...
 
std::vector< OverlapHandle_t * > getOverlapTools ()
 Get a list of all handles to loop over. More...
 
template<class T >
StatusCode setGlobalProperty (const std::string &property, const T &value)
 Apply a global property to all tools. More...
 
parentType_tparent ()
 Pointer to the parent component for the tool handles. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Public Attributes

MasterHandle_t masterTool
 Master overlap removal tool handle. More...
 
overlap tool handles
OverlapHandle_t muPFJetORT
 
OverlapHandle_t eleEleORT
 
OverlapHandle_t eleMuORT
 
OverlapHandle_t eleJetORT
 
OverlapHandle_t muJetORT
 
OverlapHandle_t tauEleORT
 
OverlapHandle_t tauMuORT
 
OverlapHandle_t tauJetORT
 
OverlapHandle_t phoEleORT
 
OverlapHandle_t phoMuORT
 
OverlapHandle_t phoJetORT
 
OverlapHandle_t eleFatJetORT
 
OverlapHandle_t jetFatJetORT
 

Private Member Functions

StatusCode initTool (OverlapHandle_t &handle, const std::string &key)
 Initialize and attach one overlap tool. More...
 
StatusCode initMaster ()
 Initialize master tool. More...
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

parentType_tm_parent
 Pointer to the parent component for the tool handles. More...
 
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

A container and helper class for overlap removal tools.

This implementation uses AnaToolHandles to setup, manage, and configure the overlap tools and a master overlap removal tool.

Todo:
Add some more usage details.
Author
Steve Farrell Steve.nosp@m.n.Fa.nosp@m.rrell.nosp@m.@cer.nosp@m.n.ch

Definition at line 38 of file ToolBox.h.

Member Typedef Documentation

◆ MasterHandle_t

Definition at line 45 of file ToolBox.h.

◆ OverlapHandle_t

Definition at line 46 of file ToolBox.h.

◆ parentType_t

using ORUtils::ToolBox::parentType_t = INamedInterface

Aliases.

Definition at line 44 of file ToolBox.h.

Constructor & Destructor Documentation

◆ ToolBox()

ORUtils::ToolBox::ToolBox ( const std::string &  name = "ORToolBox",
parentType_t theParent = nullptr 
)

Basic constructor with name and parent.

Definition at line 14 of file ToolBox.cxx.

16  masterTool("", theParent),
17  eleEleORT("", theParent),
18  eleMuORT("", theParent),
19  eleJetORT("", theParent),
20  muJetORT("", theParent),
21  tauEleORT("", theParent),
22  tauMuORT("", theParent),
23  tauJetORT("", theParent),
24  phoEleORT("", theParent),
25  phoMuORT("", theParent),
26  phoJetORT("", theParent),
27  eleFatJetORT("", theParent),
28  jetFatJetORT("", theParent),
29  m_parent(theParent)
30  {}

Member Function Documentation

◆ getOverlapTools()

std::vector< ToolBox::OverlapHandle_t * > ORUtils::ToolBox::getOverlapTools ( )

Get a list of all handles to loop over.

Definition at line 71 of file ToolBox.cxx.

72  {
73  // This is somewhat error prone, but better than not having it.
74  std::vector<OverlapHandle_t*> tools;
75  tools.reserve(13);
76  if(!eleEleORT.empty()) tools.push_back(&eleEleORT);
77  if(!eleMuORT.empty()) tools.push_back(&eleMuORT);
78  if(!eleJetORT.empty()) tools.push_back(&eleJetORT);
79  if(!muJetORT.empty()) tools.push_back(&muJetORT);
80  if(!tauEleORT.empty()) tools.push_back(&tauEleORT);
81  if(!tauMuORT.empty()) tools.push_back(&tauMuORT);
82  if(!tauJetORT.empty()) tools.push_back(&tauJetORT);
83  if(!phoEleORT.empty()) tools.push_back(&phoEleORT);
84  if(!phoMuORT.empty()) tools.push_back(&phoMuORT);
85  if(!phoJetORT.empty()) tools.push_back(&phoJetORT);
86  if(!eleFatJetORT.empty()) tools.push_back(&eleFatJetORT);
87  if(!jetFatJetORT.empty()) tools.push_back(&jetFatJetORT);
88  return tools;
89  }

◆ initialize()

StatusCode ORUtils::ToolBox::initialize ( )

Attach and initialize all tools.

Definition at line 35 of file ToolBox.cxx.

36  {
37 
38 #ifndef XAOD_STANDALONE
39  // For now, in Athena, things only work with private tools.
40  // See ATLASG-957 for more details.
41  if(!m_parent) {
42  ATH_MSG_ERROR("For now, if you want to use the ToolBox in Athena, " <<
43  "the tools must be private to some algorithm, tool, etc.");
44  return StatusCode::FAILURE;
45  }
46 #endif
47 
48  // Initialize the overlap tools
49  ATH_CHECK( initTool(eleEleORT, "EleEleORT") );
50  ATH_CHECK( initTool(eleMuORT, "EleMuORT") );
51  ATH_CHECK( initTool(eleJetORT, "EleJetORT") );
52  ATH_CHECK( initTool(muJetORT, "MuJetORT") );
53  ATH_CHECK( initTool(tauEleORT, "TauEleORT") );
54  ATH_CHECK( initTool(tauMuORT, "TauMuORT") );
55  ATH_CHECK( initTool(tauJetORT, "TauJetORT") );
56  ATH_CHECK( initTool(phoEleORT, "PhoEleORT") );
57  ATH_CHECK( initTool(phoMuORT, "PhoMuORT") );
58  ATH_CHECK( initTool(phoJetORT, "PhoJetORT") );
59  ATH_CHECK( initTool(eleFatJetORT, "EleFatJetORT") );
60  ATH_CHECK( initTool(jetFatJetORT, "JetFatJetORT") );
61 
62  // Initialize the master tool
63  ATH_CHECK( initMaster() );
64 
65  return StatusCode::SUCCESS;
66  }

◆ initMaster()

StatusCode ORUtils::ToolBox::initMaster ( )
private

Initialize master tool.

Definition at line 120 of file ToolBox.cxx.

121  {
122  // For now, we look for a non-empty "type"
123  if(!masterTool.empty()) {
124  ATH_MSG_DEBUG("Initializing master " << masterTool.name());
125  ATH_MSG_DEBUG(" type " << masterTool.type());
126  ATH_MSG_DEBUG(" isInitialized " << masterTool.isInitialized());
127  if(!masterTool.isInitialized()) {
129  }
130  }
131  return StatusCode::SUCCESS;
132  }

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

◆ initTool()

StatusCode ORUtils::ToolBox::initTool ( OverlapHandle_t handle,
const std::string &  key 
)
private

Initialize and attach one overlap tool.

Definition at line 94 of file ToolBox.cxx.

95  {
96  // Handle must be non-empty
97  if(!handle.empty()) {
98  ATH_MSG_DEBUG("Initializing " << handle.name());
99  ATH_MSG_DEBUG(" type " << handle.type());
100  ATH_MSG_DEBUG(" isInitialized " << handle.isInitialized());
101 
102  // Initialize the handle - WB: NO DON'T DO THIS ...
103  // the naming of the tool implies it's a subtool, so it mustn't be created before
104  // the parent tool is, because otherwise the parent tool doesn't get configured properly
105  // if the configuration has been done on the C++ side (the state of the joboptionsvc hasn't
106  // been updated yet) ... triggering the initialization would trigger the creation of the master tool
107  // because it's deemed to be a parent by the naming convention parent.child
108 
109  // Add it to the master tool
110  if(!masterTool.empty()) {
111  ATH_CHECK( masterTool.setProperty(key, handle) );
112  }
113  }
114  return StatusCode::SUCCESS;
115  }

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

◆ parent()

parentType_t* ORUtils::ToolBox::parent ( )
inline

Pointer to the parent component for the tool handles.

Definition at line 84 of file ToolBox.h.

84 { return m_parent; }

◆ setGlobalProperty()

template<class T >
StatusCode ORUtils::ToolBox::setGlobalProperty ( const std::string &  property,
const T &  value 
)

Apply a global property to all tools.

Definition at line 104 of file ToolBox.h.

105  {
106  // Handle the overlap tools
107  for(auto handlePtr : getOverlapTools()) {
108  ATH_CHECK( handlePtr->setProperty(property, value) );
109  }
110  // Handle the master tool
111  if(!masterTool.empty()) ATH_CHECK( masterTool.setProperty(property, value) );
112  return StatusCode::SUCCESS;
113  }

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

◆ eleEleORT

OverlapHandle_t ORUtils::ToolBox::eleEleORT

Definition at line 69 of file ToolBox.h.

◆ eleFatJetORT

OverlapHandle_t ORUtils::ToolBox::eleFatJetORT

Definition at line 79 of file ToolBox.h.

◆ eleJetORT

OverlapHandle_t ORUtils::ToolBox::eleJetORT

Definition at line 71 of file ToolBox.h.

◆ eleMuORT

OverlapHandle_t ORUtils::ToolBox::eleMuORT

Definition at line 70 of file ToolBox.h.

◆ jetFatJetORT

OverlapHandle_t ORUtils::ToolBox::jetFatJetORT

Definition at line 80 of file ToolBox.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.

◆ m_parent

parentType_t* ORUtils::ToolBox::m_parent
private

Pointer to the parent component for the tool handles.

Definition at line 95 of file ToolBox.h.

◆ masterTool

MasterHandle_t ORUtils::ToolBox::masterTool

Master overlap removal tool handle.

Definition at line 64 of file ToolBox.h.

◆ muJetORT

OverlapHandle_t ORUtils::ToolBox::muJetORT

Definition at line 72 of file ToolBox.h.

◆ muPFJetORT

OverlapHandle_t ORUtils::ToolBox::muPFJetORT

Definition at line 68 of file ToolBox.h.

◆ phoEleORT

OverlapHandle_t ORUtils::ToolBox::phoEleORT

Definition at line 76 of file ToolBox.h.

◆ phoJetORT

OverlapHandle_t ORUtils::ToolBox::phoJetORT

Definition at line 78 of file ToolBox.h.

◆ phoMuORT

OverlapHandle_t ORUtils::ToolBox::phoMuORT

Definition at line 77 of file ToolBox.h.

◆ tauEleORT

OverlapHandle_t ORUtils::ToolBox::tauEleORT

Definition at line 73 of file ToolBox.h.

◆ tauJetORT

OverlapHandle_t ORUtils::ToolBox::tauJetORT

Definition at line 75 of file ToolBox.h.

◆ tauMuORT

OverlapHandle_t ORUtils::ToolBox::tauMuORT

Definition at line 74 of file ToolBox.h.


The documentation for this class was generated from the following files:
asg::AnaToolHandle::initialize
StatusCode initialize()
initialize the tool
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
ORUtils::ToolBox::m_parent
parentType_t * m_parent
Pointer to the parent component for the tool handles.
Definition: ToolBox.h:95
ORUtils::ToolBox::eleMuORT
OverlapHandle_t eleMuORT
Definition: ToolBox.h:70
athena.value
value
Definition: athena.py:124
ORUtils::ToolBox::eleFatJetORT
OverlapHandle_t eleFatJetORT
Definition: ToolBox.h:79
asg::AnaToolHandle::setProperty
StatusCode setProperty(const std::string &property, const T2 &value)
set the given property of the tool.
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
ORUtils::ToolBox::muJetORT
OverlapHandle_t muJetORT
Definition: ToolBox.h:72
ORUtils::ToolBox::eleJetORT
OverlapHandle_t eleJetORT
Definition: ToolBox.h:71
asg::AnaToolHandle::type
const std::string & type() const noexcept
the type configured for this AnaToolHandle
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ORUtils::ToolBox::getOverlapTools
std::vector< OverlapHandle_t * > getOverlapTools()
Get a list of all handles to loop over.
Definition: ToolBox.cxx:71
ORUtils::ToolBox::tauEleORT
OverlapHandle_t tauEleORT
Definition: ToolBox.h:73
ORUtils::ToolBox::jetFatJetORT
OverlapHandle_t jetFatJetORT
Definition: ToolBox.h:80
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ORUtils::ToolBox::tauMuORT
OverlapHandle_t tauMuORT
Definition: ToolBox.h:74
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ORUtils::ToolBox::tauJetORT
OverlapHandle_t tauJetORT
Definition: ToolBox.h:75
ORUtils::ToolBox::initTool
StatusCode initTool(OverlapHandle_t &handle, const std::string &key)
Initialize and attach one overlap tool.
Definition: ToolBox.cxx:94
ORUtils::ToolBox::phoMuORT
OverlapHandle_t phoMuORT
Definition: ToolBox.h:77
ORUtils::ToolBox::phoEleORT
OverlapHandle_t phoEleORT
Definition: ToolBox.h:76
tools
Definition: DataQuality/ZLumiScripts/python/tools/__init__.py:1
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
asg::AnaToolHandle::name
const std::string & name() const noexcept
the name configured for this AnaToolHandle
ORUtils::ToolBox::eleEleORT
OverlapHandle_t eleEleORT
Definition: ToolBox.h:69
asg::AnaToolHandle::isInitialized
bool isInitialized() const noexcept
whether initialize has been called successfully, i.e.
ORUtils::ToolBox::masterTool
MasterHandle_t masterTool
Master overlap removal tool handle.
Definition: ToolBox.h:64
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
ORUtils::ToolBox::phoJetORT
OverlapHandle_t phoJetORT
Definition: ToolBox.h:78
asg::AnaToolHandle::empty
bool empty() const
whether this ToolHandle is completely empty, i.e.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
ORUtils::ToolBox::initMaster
StatusCode initMaster()
Initialize master tool.
Definition: ToolBox.cxx:120