ATLAS Offline Software
Loading...
Searching...
No Matches
ToolBox.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Local includes
7
8namespace ORUtils
9{
10
11 //-------------------------------------------------------------------------
12 // Constructor
13 //-------------------------------------------------------------------------
14 ToolBox::ToolBox(const std::string& name, parentType_t* theParent)
15 : asg::AsgMessaging(name),
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 {}
31
32 //-------------------------------------------------------------------------
33 // Attach and initialize the tools
34 //-------------------------------------------------------------------------
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
64
65 return StatusCode::SUCCESS;
66 }
67
68 //-------------------------------------------------------------------------
69 // Get a list of all overlap tool handles
70 //-------------------------------------------------------------------------
71 std::vector<ToolBox::OverlapHandle_t*> ToolBox::getOverlapTools()
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 }
90
91 //-------------------------------------------------------------------------
92 // Initialize one overlap tool
93 //-------------------------------------------------------------------------
94 StatusCode ToolBox::initTool(OverlapHandle_t& handle, const std::string& key)
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 }
116
117 //-------------------------------------------------------------------------
118 // Initialize master tool
119 //-------------------------------------------------------------------------
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()) {
128 ATH_CHECK( masterTool.initialize() );
129 }
130 }
131 return StatusCode::SUCCESS;
132 }
133
134} // namespace ORUtils
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
std::vector< OverlapHandle_t * > getOverlapTools()
Get a list of all handles to loop over.
Definition ToolBox.cxx:71
OverlapHandle_t phoEleORT
Definition ToolBox.h:76
OverlapHandle_t eleJetORT
Definition ToolBox.h:71
OverlapHandle_t eleFatJetORT
Definition ToolBox.h:79
StatusCode initMaster()
Initialize master tool.
Definition ToolBox.cxx:120
OverlapHandle_t phoJetORT
Definition ToolBox.h:78
OverlapHandle_t jetFatJetORT
Definition ToolBox.h:80
MasterHandle_t masterTool
Master overlap removal tool handle.
Definition ToolBox.h:64
StatusCode initTool(OverlapHandle_t &handle, const std::string &key)
Initialize and attach one overlap tool.
Definition ToolBox.cxx:94
OverlapHandle_t eleEleORT
Definition ToolBox.h:69
ToolBox(const std::string &name="ORToolBox", parentType_t *theParent=nullptr)
Basic constructor with name and parent.
Definition ToolBox.cxx:14
OverlapHandle_t muJetORT
Definition ToolBox.h:72
OverlapHandle_t eleMuORT
Definition ToolBox.h:70
INamedInterface parentType_t
Aliases.
Definition ToolBox.h:44
asg::AnaToolHandle< IOverlapTool > OverlapHandle_t
Definition ToolBox.h:46
OverlapHandle_t phoMuORT
Definition ToolBox.h:77
OverlapHandle_t tauMuORT
Definition ToolBox.h:74
OverlapHandle_t tauJetORT
Definition ToolBox.h:75
OverlapHandle_t tauEleORT
Definition ToolBox.h:73
StatusCode initialize()
Attach and initialize all tools.
Definition ToolBox.cxx:35
parentType_t * m_parent
Pointer to the parent component for the tool handles.
Definition ToolBox.h:95
AsgMessaging(const std::string &name)
Constructor with a name.