ATLAS Offline Software
Loading...
Searching...
No Matches
METAssociationTool.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2023 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) );
66 ATH_CHECK( m_coreKey.initialize() );
67 ATH_CHECK( m_mapKey.assign(mapName) );
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
77 {
78
79 //this section has had a very big re-write, after discussions with TJK...
80 ATH_MSG_DEBUG ("In execute: " << name() << "...");
81
82 //Create map and core containers
83
84 auto metHandle = SG::makeHandle (m_coreKey);
85 ATH_CHECK( metHandle.record (std::make_unique<xAOD::MissingETContainer>(), std::make_unique<xAOD::MissingETAuxContainer>()) );
86 xAOD::MissingETContainer* metCont=metHandle.ptr();
87
88 auto metMapHandle = SG::makeHandle (m_mapKey);
89 ATH_CHECK( metMapHandle.record (std::make_unique<xAOD::MissingETAssociationMap>(), std::make_unique<xAOD::MissingETAuxAssociationMap>()) );
90 xAOD::MissingETAssociationMap* metMap=metMapHandle.ptr();
91
92
93 if( buildMET(metCont, metMap).isFailure() ) {
94 ATH_MSG_DEBUG("Failed in MissingET reconstruction");
95 return StatusCode::SUCCESS;
96 }
97
98 // Lock the containers in SG
99 //ATH_CHECK( evtStore()->setConst(metMap) );
100 //ATH_CHECK( evtStore()->setConst(metCont) );
101
102 return StatusCode::SUCCESS;
103 }
104
106 {
107 ATH_MSG_INFO ("Finalizing " << name() << "...");
108
109 return StatusCode::SUCCESS;
110 }
111
113 // Protected methods:
115
117 {
118
119
120 // Run the MET reconstruction tools in sequence
121 for(auto tool : m_metAssociators) {
122 if (tool->execute(metCont,metMap).isFailure()){
123 ATH_MSG_WARNING("Failed to execute tool: " << tool->name());
124 return StatusCode::FAILURE;
125 }
126 }
127 bool foundOverlaps = metMap->identifyOverlaps();
128 ATH_MSG_DEBUG( (foundOverlaps ? "Overlaps" : "No overlaps") << " identified!");
129 ++m_nevt;
130 return StatusCode::SUCCESS;
131 }
132}
#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
virtual StatusCode execute() const override
METAssociationTool()
Default constructor:
ToolHandleArray< IMETAssocToolBase > m_metAssociators
virtual StatusCode finalize() override
std::atomic< unsigned int > m_nevt
SG::WriteHandleKey< xAOD::MissingETAssociationMap > m_mapKey
Gaudi::Property< std::string > m_metSuffix
StatusCode buildMET(xAOD::MissingETContainer *metCont, xAOD::MissingETAssociationMap *metMap) const
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.