ATLAS Offline Software
METAssociationTool.cxx
Go to the documentation of this file.
1 
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 
30 namespace 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
46  AsgTool(name)
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 
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 }
met::METAssociationTool::execute
virtual StatusCode execute() const override
Definition: METAssociationTool.cxx:76
met::METAssociationTool::finalize
virtual StatusCode finalize() override
Definition: METAssociationTool.cxx:105
met::METAssociationTool::m_metAssociators
ToolHandleArray< IMETAssocToolBase > m_metAssociators
Definition: METAssociationTool.h:99
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
METAssociationTool.h
MissingETAuxComponentMap.h
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
met::METAssociationTool::buildMET
StatusCode buildMET(xAOD::MissingETContainer *metCont, xAOD::MissingETAssociationMap *metMap) const
Definition: METAssociationTool.cxx:116
xAOD::MissingETAssociationMap_v1
Definition: MissingETAssociationMap_v1.h:29
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
met::METAssociationTool::m_nevt
std::atomic< unsigned int > m_nevt
Definition: METAssociationTool.h:101
met
Definition: IMETSignificance.h:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MissingETAuxContainer.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
MissingET.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
xAOD::MissingETAssociationMap_v1::identifyOverlaps
bool identifyOverlaps()
Do overlap-finding in all associations.
Definition: MissingETAssociationMap_v1.cxx:202
CaloClusterChangeSignalState.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
met::METAssociationTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: METAssociationTool.cxx:52
CaloClusterContainer.h
met::METAssociationTool::METAssociationTool
METAssociationTool()
Default constructor:
met::METAssociationTool::m_coreKey
SG::WriteHandleKey< xAOD::MissingETContainer > m_coreKey
Definition: METAssociationTool.h:96
met::METAssociationTool::m_metSuffix
Gaudi::Property< std::string > m_metSuffix
Definition: METAssociationTool.h:95
MissingETComposition.h
MissingETContainer.h
met::METAssociationTool::m_mapKey
SG::WriteHandleKey< xAOD::MissingETAssociationMap > m_mapKey
Definition: METAssociationTool.h:97