ATLAS Offline Software
Loading...
Searching...
No Matches
METRecoTool.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// METRecoTool.cxx
8// Implementation file for class METRecoTool
9//
10// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
11//
12// Author: P Loch, S Resconi, TJ Khoo
14
15// METReconstruction includes
17
18// MET EDM
25
26#include <iomanip>
27
28namespace met {
29
30 using xAOD::MissingET;
36 //
37 using std::string;
38 using std::setw;
39 using std::setprecision;
40 using std::fixed;
41
43 // Public methods:
45
46 // Constructors
48 METRecoTool::METRecoTool(const std::string& name) :
50 {
51 }
52
53 // Athena algtool's Hooks
56 {
57 ATH_MSG_INFO ("Initializing " << name() << "...");
58
59 if( m_contname.key().empty() ) {
60 ATH_MSG_FATAL("Output MissingETContainer name must be provided.");
61 return StatusCode::FAILURE;
62 }
63
64 if( m_mapname.key().empty() ) {
65 ATH_MSG_FATAL("Output MissingETComponentMap name must be provided.");
66 return StatusCode::FAILURE;
67 }
68 ATH_CHECK( m_contname.initialize() );
69 ATH_CHECK( m_mapname.initialize() );
70
71
72 ATH_MSG_INFO ("Reconstructing MET container: " << m_contname
73 << " with composition map: " << m_mapname );
74
75 // Do we need a flag to toggle the summation?
76 // Or will we require the summation to be made
77 if( !m_metfinalname.empty() ) {
78 m_doMetSum = true;
79 ATH_MSG_INFO ("Will produce final MET sum \"" << m_metfinalname << "\"");
80 } else {
81 ATH_MSG_INFO ("Will not sum MET in this container.");
82 }
83
84 ATH_CHECK( m_metbuilders.retrieve() );
85 ATH_CHECK( m_metrefiners.retrieve() );
86 return StatusCode::SUCCESS;
87 }
88
89 StatusCode METRecoTool::execute(const EventContext& ctx) const
90 {
91 ATH_MSG_DEBUG ("In execute: " << name() << "...");
92
93 // Create a MissingETContainer with its aux store
94 auto metHandle= SG::makeHandle (m_contname, ctx);
95 //note that the method below automatically creates the MET container and its corresponding aux store (which will be named "m_contname+Aux.")
96 ATH_CHECK( metHandle.record (std::make_unique<xAOD::MissingETContainer>(), std::make_unique<xAOD::MissingETAuxContainer>()) );
97 xAOD::MissingETContainer* metCont=metHandle.ptr();
98
99
100 // Create a MissingETComponentMap with its aux store
101
102 auto metMapHandle= SG::makeHandle (m_mapname, ctx);
103 //note that the method below automatically creates the MET container and its corresponding aux store (which will be named "m_contname+Aux.")
104 ATH_CHECK( metMapHandle.record (std::make_unique<xAOD::MissingETComponentMap>(), std::make_unique<xAOD::MissingETAuxComponentMap>()) );
105 xAOD::MissingETComponentMap* metMap=metMapHandle.ptr();
106
107
108 if( buildMET(metCont, metMap).isFailure() ) {
109 ATH_MSG_WARNING("Failed in MissingET reconstruction");
110 return StatusCode::SUCCESS;
111 }
112
113 return StatusCode::SUCCESS;
114 }
115
117 {
118 ATH_MSG_INFO ("Finalizing " << name() << "...");
119 return StatusCode::SUCCESS;
120 }
121
122
124 // Protected methods:
126
128 {
129
130
131 MissingET* metFinal = nullptr;
132 if( m_doMetSum ) {
133 ATH_MSG_DEBUG("Building final MET sum: " << m_metfinalname);
134 metFinal = new MissingET(0.,0.,0., m_metfinalname, MissingETBase::Source::total());
135 }
136
137 // Run the MET reconstruction tools in sequence
138 for(auto tool : m_metbuilders) {
139 ATH_MSG_VERBOSE("Building new MET term with: " << tool->name() );
140 MissingET* metTerm = new MissingET(0.,0.,0.);
141 ATH_MSG_VERBOSE("Insert MET object into container");
142 metCont->push_back(metTerm);
143 ATH_MSG_VERBOSE("Insert MET object into ComponentMap");
144 MissingETComposition::add(metMap,metTerm);
145 ATH_MSG_VERBOSE("Execute tool");
146 if( tool->execute(metTerm, metMap).isFailure() ) {
147 ATH_MSG_WARNING("Failed to execute tool: " << tool->name());
148 // return StatusCode::SUCCESS;
149 }
151 // FIXME: Make a genuine decision about whether
152 // to include terms in the sum here.
155 ATH_MSG_DEBUG("Adding constructed term: " << metTerm->name() << " to sum" );
156 (*metFinal) += (*metTerm);
157 }
158 }
159
160 // Run the MET reconstruction tools in sequence
161 for(auto tool : m_metrefiners) {
162 ATH_MSG_VERBOSE("Refining MET with: " << tool->name() );
163 MissingET* metTerm = new MissingET(0.,0.,0.);
164 ATH_MSG_VERBOSE("Insert MET object into container");
165 metCont->push_back(metTerm);
166 ATH_MSG_VERBOSE("Insert MET object into ComponentMap");
167 MissingETComposition::add(metMap,metTerm);
168 ATH_MSG_VERBOSE("Execute tool");
169 if( tool->execute(metTerm, metMap).isFailure() ) {
170 ATH_MSG_WARNING("Failed to execute tool: " << tool->name());
171 // return StatusCode::SUCCESS;
172 }
173 }
174
175 if( m_doMetSum ) {
177 metFinal->setSource(source);
178 metCont->push_back(metFinal);
179 }
180 ++m_nevt;
181 return StatusCode::SUCCESS;
182 }
183
184}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
ToolHandleArray< IMETToolBase > m_metbuilders
Definition METRecoTool.h:97
ToolHandleArray< IMETToolBase > m_metrefiners
Definition METRecoTool.h:98
virtual StatusCode finalize()
METRecoTool()
Default constructor:
SG::WriteHandleKey< xAOD::MissingETComponentMap > m_mapname
Definition METRecoTool.h:95
Gaudi::Property< std::string > m_metfinalname
Definition METRecoTool.h:96
StatusCode buildMET(xAOD::MissingETContainer *metCont, xAOD::MissingETComponentMap *metMap) const
virtual StatusCode execute(const EventContext &ctx) const
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
std::atomic< unsigned int > m_nevt
SG::WriteHandleKey< xAOD::MissingETContainer > m_contname
Definition METRecoTool.h:94
MissingETBase::Types::bitmask_t source() const
MET object source tag.
void setSource(MissingETBase::Types::bitmask_t src)
Set the source of the MET object.
const std::string & name() const
Identifier getters.
uint64_t bitmask_t
Type for status word bit mask.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
MissingETComponentMap_v1 MissingETComponentMap
Version control by type definition.
MissingET_v1 MissingET
Version control by type defintion.
MissingETAuxComponentMap_v1 MissingETAuxComponentMap
Version control by type definition.
MissingETAuxContainer_v1 MissingETAuxContainer
static Types::bitmask_t total(Region reg=Region::FullAcceptance)
Standard full reconstructed MET.
@ Refined
Indicator for genuine reconstructed MET terms.
static bool hasCategory(Types::bitmask_t bits, Category cat)
Check if bit pattern includes a given category.
static bool add(MissingETComponentMap *pMap, const MissingET *pMET, MissingETBase::Types::bitmask_t sw=MissingETBase::Status::clearedStatus())
Adding a MissingET object to the map.
Collection of functions managing the MET composition map and association map.