ATLAS Offline Software
xAODMissingETRetriever.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "AthenaKernel/Units.h"
9 
10 namespace JiveXML {
11 
18  xAODMissingETRetriever::xAODMissingETRetriever(const std::string& type,const std::string& name,const IInterface* parent):
20 
21 
23  ATH_CHECK(m_keys.initialize());
24  return StatusCode::SUCCESS;
25  }
26 
27 
32  StatusCode xAODMissingETRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
33 
34  ATH_MSG_DEBUG( "in retrieve()" );
35 
36  // Loop through the keys and retrieve the corresponding data
37  for (const auto& key : m_keys) {
39  if (cont.isValid()) {
40  DataMap data = getData(&(*cont));
41  if (FormatTool->AddToEvent(dataTypeName(), key.key() + "_xAOD", &data).isFailure()) {
42  ATH_MSG_WARNING("Failed to add collection " << key.key());
43  } else {
44  ATH_MSG_DEBUG(" (" << key.key() << ") retrieved");
45  }
46  } else {
47  ATH_MSG_WARNING("Collection " << key.key() << " not found in SG");
48  }
49  }
50 
51  return StatusCode::SUCCESS;
52  }
53 
54 
60 
61  ATH_MSG_DEBUG( "in getData()" );
62 
64 
65  DataVect etx; etx.reserve(metCont->size());
66  DataVect ety; ety.reserve(metCont->size());
67  DataVect et; et.reserve(metCont->size());
68 
69  float mpx = 0.;
70  float mpy = 0.;
71  float sumet = 0.;
72 
74  xAOD::MissingETContainer::const_iterator metItrE = metCont->end();
75 
76  // current understanding is that we only need the final value
77  // out of the ~9 values within each MET container ('final')
78 
79  for (; metItr != metItrE; ++metItr) {
80  sumet = (*metItr)->sumet()/GeV;
81  mpx = (*metItr)->mpx()/GeV;
82  mpy = (*metItr)->mpy()/GeV;
83 
84  ATH_MSG_DEBUG( " Components: MissingET [GeV] mpx= " << mpx
85  << ", mpy= " << mpy
86  << ", sumet= " << sumet );
87 
88  } // end MissingETIterator
89 
90  ATH_MSG_DEBUG( " FINAL: MissingET [GeV] mpx= " << mpx
91  << ", mpy= " << mpy << ", sumet= " << sumet );
92 
93  etx.emplace_back(DataType( mpx ));
94  ety.emplace_back(DataType( mpy ));
95  et.emplace_back(DataType( sumet ));
96 
97  // four-vectors
98  DataMap["et"] = et;
99  DataMap["etx"] = etx;
100  DataMap["ety"] = ety;
101 
102  ATH_MSG_DEBUG( dataTypeName() << " retrieved with " << et.size() << " entries" );
103 
104  //All collections retrieved okay
105  return DataMap;
106  }
107 
108 
109 } // JiveXML namespace
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
et
Extra patterns decribing particle interation process.
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:18
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
xAODMissingETRetriever.h
JiveXML::xAODMissingETRetriever::getData
const DataMap getData(const xAOD::MissingETContainer *)
Puts the variables into a DataMap.
Definition: xAODMissingETRetriever.cxx:59
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
JiveXML::xAODMissingETRetriever::initialize
virtual StatusCode initialize()
Definition: xAODMissingETRetriever.cxx:22
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
JiveXML::xAODMissingETRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
For each MET collection retrieve basic parameters.
Definition: xAODMissingETRetriever.cxx:32
JiveXML::xAODMissingETRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type that is generated by this retriever.
Definition: xAODMissingETRetriever.h:42
JiveXML::xAODMissingETRetriever::xAODMissingETRetriever
xAODMissingETRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: xAODMissingETRetriever.cxx:18
JiveXML::xAODMissingETRetriever::m_keys
SG::ReadHandleKeyArray< xAOD::MissingETContainer > m_keys
Definition: xAODMissingETRetriever.h:49
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:22
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Units.h
Wrapper to avoid constant divisions when using units.
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37