ATLAS Offline Software
Loading...
Searching...
No Matches
METAssociationTool.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7// METAssociationTool.cxx
8// Implementation file for class METAssociationTool
9//
10// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
11//
12// Author: P Loch, S Resconi, TJ Khoo
14
15// METReconstruction includes
17
18// MET EDM
24
27
28#include <iomanip>
29
30namespace met {
31
32 using namespace xAOD;
33 //
34 using std::string;
35 using std::setw;
36 using std::setprecision;
37 using std::fixed;
38
40 // Public methods:
42
43 // Constructors
47 {
48 }
49
50 // Athena algtool's Hooks
53 {
54 ATH_MSG_INFO ("Initializing " << name() << "...");
55
56 if( m_metSuffix.size()==0 ) {
57 ATH_MSG_ERROR("Output suffix for MET names must be provided.");
58 return StatusCode::FAILURE;
59 } else {
60 std::string coreName = "MET_Core_" + m_metSuffix;
61 std::string mapName = "METAssoc_" + m_metSuffix;
62 ATH_MSG_INFO("Tool configured to build MET with names:");
63 ATH_MSG_INFO(" Core container ==> " << coreName);
64 ATH_MSG_INFO(" Association map ==> " << mapName);
65 ATH_CHECK( m_coreKey.assign(coreName) ); // FIXME properties should be properly assigned during the configuration
66 ATH_CHECK( m_coreKey.initialize() );
67 ATH_CHECK( m_mapKey.assign(mapName) ); // FIXME properties should be properly assigned during the configuration
68 ATH_CHECK( m_mapKey.initialize() );
69 }
70
71 // retrieve associators
72 ATH_CHECK(m_metAssociators.retrieve());
73 return StatusCode::SUCCESS;
74 }
75
76 StatusCode METAssociationTool::execute(const EventContext& ctx) const
77 {
78 //this section has had a very big re-write, after discussions with TJK...
79 ATH_MSG_DEBUG ("In execute: " << name() << "...");
80
81 //Create map and core containers
82
83 auto metHandle = SG::makeHandle (m_coreKey, ctx);
84 ATH_CHECK( metHandle.record (std::make_unique<xAOD::MissingETContainer>(), std::make_unique<xAOD::MissingETAuxContainer>()) );
85 xAOD::MissingETContainer* metCont=metHandle.ptr();
86
87 auto metMapHandle = SG::makeHandle (m_mapKey, ctx);
88 ATH_CHECK( metMapHandle.record (std::make_unique<xAOD::MissingETAssociationMap>(), std::make_unique<xAOD::MissingETAuxAssociationMap>()) );
89 xAOD::MissingETAssociationMap* metMap=metMapHandle.ptr();
90
91
92 if( buildMET(metCont, metMap, ctx).isFailure() ) {
93 ATH_MSG_DEBUG("Failed in MissingET reconstruction");
94 return StatusCode::SUCCESS;
95 }
96
97 // Lock the containers in SG
98 //ATH_CHECK( evtStore()->setConst(metMap) );
99 //ATH_CHECK( evtStore()->setConst(metCont) );
100
101 return StatusCode::SUCCESS;
102 }
103
105 {
106 ATH_MSG_INFO ("Finalizing " << name() << "...");
107
108 return StatusCode::SUCCESS;
109 }
110
112 // Protected methods:
114
115 StatusCode METAssociationTool::buildMET(xAOD::MissingETContainer* metCont, xAOD::MissingETAssociationMap* metMap, const EventContext& ctx) const
116 {
117
118
119 // Run the MET reconstruction tools in sequence
120 for(auto tool : m_metAssociators) {
121 if (tool->execute(metCont,metMap,ctx).isFailure()){
122 ATH_MSG_WARNING("Failed to execute tool: " << tool->name());
123 return StatusCode::FAILURE;
124 }
125 }
126 bool foundOverlaps = metMap->identifyOverlaps();
127 ATH_MSG_DEBUG( (foundOverlaps ? "Overlaps" : "No overlaps") << " identified!");
128 ++m_nevt;
129 return StatusCode::SUCCESS;
130 }
131}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
SG::WriteHandleKey< xAOD::MissingETContainer > m_coreKey
METAssociationTool()
Default constructor:
ToolHandleArray< IMETAssocToolBase > m_metAssociators
virtual StatusCode execute(const EventContext &ctx) const override
StatusCode buildMET(xAOD::MissingETContainer *metCont, xAOD::MissingETAssociationMap *metMap, const EventContext &ctx) const
virtual StatusCode finalize() override
std::atomic< unsigned int > m_nevt
SG::WriteHandleKey< xAOD::MissingETAssociationMap > m_mapKey
Gaudi::Property< std::string > m_metSuffix
bool identifyOverlaps()
Do overlap-finding in all associations.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
MissingETAssociationMap_v1 MissingETAssociationMap
Version control by type defintion.