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 m_doMetSum(false),
51 m_metbuilders(this),
52 m_metrefiners(this),
53 m_nevt(0)
54 {
55 declareProperty( "METBuilders", m_metbuilders );
56 declareProperty( "METRefiners", m_metrefiners );
57 declareProperty( "METContainer", m_contname = "MET" );
58 declareProperty( "METComponentMap", m_mapname = "METMap" );
59 declareProperty( "WarnIfDuplicate", m_warnOfDupes = true );
60 declareProperty( "METFinalName", m_metfinalname = "" );
61 }
62
63 // Athena algtool's Hooks
66 {
67 ATH_MSG_INFO ("Initializing " << name() << "...");
68
69 if( m_contname.key().empty() ) {
70 ATH_MSG_FATAL("Output MissingETContainer name must be provided.");
71 return StatusCode::FAILURE;
72 }
73
74 if( m_mapname.key().empty() ) {
75 ATH_MSG_FATAL("Output MissingETComponentMap name must be provided.");
76 return StatusCode::FAILURE;
77 }
78 ATH_CHECK( m_contname.initialize() );
79 ATH_CHECK( m_mapname.initialize() );
80
81
82 ATH_MSG_INFO ("Reconstructing MET container: " << m_contname
83 << " with composition map: " << m_mapname );
84
85 // Do we need a flag to toggle the summation?
86 // Or will we require the summation to be made
87 if( !m_metfinalname.empty() ) {
88 m_doMetSum = true;
89 ATH_MSG_INFO ("Will produce final MET sum \"" << m_metfinalname << "\"");
90 } else {
91 ATH_MSG_INFO ("Will not sum MET in this container.");
92 }
93
94 ATH_CHECK( m_metbuilders.retrieve() );
95 ATH_CHECK( m_metrefiners.retrieve() );
96 return StatusCode::SUCCESS;
97 }
98
99 StatusCode METRecoTool::execute() const
100 {
101 ATH_MSG_DEBUG ("In execute: " << name() << "...");
102
103 // Create a MissingETContainer with its aux store
104 auto metHandle= SG::makeHandle (m_contname);
105 //note that the method below automatically creates the MET container and its corresponding aux store (which will be named "m_contname+Aux.")
106 ATH_CHECK( metHandle.record (std::make_unique<xAOD::MissingETContainer>(), std::make_unique<xAOD::MissingETAuxContainer>()) );
107 xAOD::MissingETContainer* metCont=metHandle.ptr();
108
109
110 // Create a MissingETComponentMap with its aux store
111
112 auto metMapHandle= SG::makeHandle (m_mapname);
113 //note that the method below automatically creates the MET container and its corresponding aux store (which will be named "m_contname+Aux.")
114 ATH_CHECK( metMapHandle.record (std::make_unique<xAOD::MissingETComponentMap>(), std::make_unique<xAOD::MissingETAuxComponentMap>()) );
115 xAOD::MissingETComponentMap* metMap=metMapHandle.ptr();
116
117
118 if( buildMET(metCont, metMap).isFailure() ) {
119 ATH_MSG_WARNING("Failed in MissingET reconstruction");
120 return StatusCode::SUCCESS;
121 }
122
123 return StatusCode::SUCCESS;
124 }
125
127 {
128 ATH_MSG_INFO ("Finalizing " << name() << "...");
129 return StatusCode::SUCCESS;
130 }
131
132
134 // Protected methods:
136
138 {
139
140
141 MissingET* metFinal = nullptr;
142 if( m_doMetSum ) {
143 ATH_MSG_DEBUG("Building final MET sum: " << m_metfinalname);
144 metFinal = new MissingET(0.,0.,0., m_metfinalname, MissingETBase::Source::total());
145 }
146
147 // Run the MET reconstruction tools in sequence
148 for(auto tool : m_metbuilders) {
149 ATH_MSG_VERBOSE("Building new MET term with: " << tool->name() );
150 MissingET* metTerm = new MissingET(0.,0.,0.);
151 ATH_MSG_VERBOSE("Insert MET object into container");
152 metCont->push_back(metTerm);
153 ATH_MSG_VERBOSE("Insert MET object into ComponentMap");
154 MissingETComposition::add(metMap,metTerm);
155 ATH_MSG_VERBOSE("Execute tool");
156 if( tool->execute(metTerm, metMap).isFailure() ) {
157 ATH_MSG_WARNING("Failed to execute tool: " << tool->name());
158 // return StatusCode::SUCCESS;
159 }
161 // FIXME: Make a genuine decision about whether
162 // to include terms in the sum here.
165 ATH_MSG_DEBUG("Adding constructed term: " << metTerm->name() << " to sum" );
166 (*metFinal) += (*metTerm);
167 }
168 }
169
170 // Run the MET reconstruction tools in sequence
171 for(auto tool : m_metrefiners) {
172 ATH_MSG_VERBOSE("Refining MET with: " << tool->name() );
173 MissingET* metTerm = new MissingET(0.,0.,0.);
174 ATH_MSG_VERBOSE("Insert MET object into container");
175 metCont->push_back(metTerm);
176 ATH_MSG_VERBOSE("Insert MET object into ComponentMap");
177 MissingETComposition::add(metMap,metTerm);
178 ATH_MSG_VERBOSE("Execute tool");
179 if( tool->execute(metTerm, metMap).isFailure() ) {
180 ATH_MSG_WARNING("Failed to execute tool: " << tool->name());
181 // return StatusCode::SUCCESS;
182 }
183 }
184
185 if( m_doMetSum ) {
187 metFinal->setSource(source);
188 metCont->push_back(metFinal);
189 }
190 ++m_nevt;
191 return StatusCode::SUCCESS;
192 }
193
194}
#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)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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:98
ToolHandleArray< IMETToolBase > m_metrefiners
Definition METRecoTool.h:99
virtual StatusCode finalize()
METRecoTool()
Default constructor:
SG::WriteHandleKey< xAOD::MissingETComponentMap > m_mapname
Definition METRecoTool.h:96
StatusCode buildMET(xAOD::MissingETContainer *metCont, xAOD::MissingETComponentMap *metMap) const
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
std::atomic< unsigned int > m_nevt
virtual StatusCode execute() const
SG::WriteHandleKey< xAOD::MissingETContainer > m_contname
Definition METRecoTool.h:95
std::string m_metfinalname
Definition METRecoTool.h:97
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.