Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
25  StatusCode xAODMissingETRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
26 
27  ATH_MSG_DEBUG( "in retrieve()" );
28 
29  std::vector<std::string> keys = getKeys();
30 
31  if(keys.empty()){
32  ATH_MSG_WARNING("No StoreGate keys found");
33  return StatusCode::SUCCESS;
34  }
35 
36  // Loop through the keys and retrieve the corresponding data
37  for (const std::string& key : keys) {
39  if (cont.isValid()) {
40  DataMap data = getData(&(*cont));
41  if (FormatTool->AddToEvent(dataTypeName(), key + "_xAOD", &data).isFailure()) {
42  ATH_MSG_WARNING("Failed to retrieve Collection " << key);
43  } else {
44  ATH_MSG_DEBUG(" (" << key << ") retrieved");
45  }
46  } else {
47  ATH_MSG_WARNING("Collection " << key << " not found in SG");
48  }
49  }
50  return StatusCode::SUCCESS;
51  }
52 
53 
59 
60  ATH_MSG_DEBUG( "in getData()" );
61 
63 
64  DataVect etx; etx.reserve(metCont->size());
65  DataVect ety; ety.reserve(metCont->size());
66  DataVect et; et.reserve(metCont->size());
67 
68  float mpx = 0.;
69  float mpy = 0.;
70  float sumet = 0.;
71 
73  xAOD::MissingETContainer::const_iterator metItrE = metCont->end();
74 
75  // current understanding is that we only need the final value
76  // out of the ~9 values within each MET container ('final')
77 
78  for (; metItr != metItrE; ++metItr) {
79  sumet = (*metItr)->sumet()/GeV;
80  mpx = (*metItr)->mpx()/GeV;
81  mpy = (*metItr)->mpy()/GeV;
82 
83  ATH_MSG_DEBUG( " Components: MissingET [GeV] mpx= " << mpx
84  << ", mpy= " << mpy
85  << ", sumet= " << sumet );
86 
87  } // end MissingETIterator
88 
89  ATH_MSG_DEBUG( " FINAL: MissingET [GeV] mpx= " << mpx
90  << ", mpy= " << mpy << ", sumet= " << sumet );
91 
92  etx.emplace_back(DataType( mpx ));
93  ety.emplace_back(DataType( mpy ));
94  et.emplace_back(DataType( sumet ));
95 
96  // four-vectors
97  DataMap["et"] = et;
98  DataMap["etx"] = etx;
99  DataMap["ety"] = ety;
100 
101  ATH_MSG_DEBUG( dataTypeName() << " retrieved with " << et.size() << " entries" );
102 
103  //All collections retrieved okay
104  return DataMap;
105  }
106  const std::vector<std::string> xAODMissingETRetriever::getKeys() {
107 
108  ATH_MSG_DEBUG("in getKeys()");
109 
110  std::vector<std::string> keys = {};
111 
112  // Remove m_priorityKey from m_otherKeys if it exists, we don't want to write it twice
113  auto it = std::find(m_otherKeys.begin(), m_otherKeys.end(), m_priorityKey);
114  if(it != m_otherKeys.end()){
115  m_otherKeys.erase(it);
116  }
117 
118  // Add m_priorityKey as the first element if it is not ""
119  if(m_priorityKey!=""){
120  keys.push_back(m_priorityKey);
121  }
122 
123  if(!m_otherKeys.empty()){
124  keys.insert(keys.end(), m_otherKeys.begin(), m_otherKeys.end());
125  }
126 
127  // If all collections are requested, obtain all available keys from StoreGate
128  std::vector<std::string> allKeys;
130  evtStore()->keys<xAOD::MissingETContainer>(allKeys);
131  // Add keys that are not the priority key and do not add containers with "HLT" in their name if requested
132  for(const std::string& key : allKeys){
133  // Don't include key if it's already in keys
134  auto it2 = std::find(keys.begin(), keys.end(), key);
135  if(it2 != keys.end())continue;
136  if(key.find("HLT") == std::string::npos || m_doWriteHLT){
137  keys.emplace_back(key);
138  }
139  }
140  }
141  return keys;
142  }
143 
144 } // 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:17
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
JiveXML::xAODMissingETRetriever::m_doWriteHLT
Gaudi::Property< bool > m_doWriteHLT
Definition: xAODMissingETRetriever.h:55
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
xAODMissingETRetriever.h
JiveXML::xAODMissingETRetriever::getData
const DataMap getData(const xAOD::MissingETContainer *)
Puts the variables into a DataMap.
Definition: xAODMissingETRetriever.cxx:58
JiveXML::xAODMissingETRetriever::m_doWriteAllCollections
Gaudi::Property< bool > m_doWriteAllCollections
Definition: xAODMissingETRetriever.h:56
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
skel.it
it
Definition: skel.GENtoEVGEN.py:407
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:25
JiveXML::xAODMissingETRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type that is generated by this retriever.
Definition: xAODMissingETRetriever.h:48
JiveXML::xAODMissingETRetriever::xAODMissingETRetriever
xAODMissingETRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: xAODMissingETRetriever.cxx:18
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
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
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:228
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
JiveXML::xAODMissingETRetriever::m_priorityKey
Gaudi::Property< std::string > m_priorityKey
Definition: xAODMissingETRetriever.h:58
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
JiveXML::xAODMissingETRetriever::getKeys
const std::vector< std::string > getKeys()
Gets the StoreGate keys for the desired containers.
Definition: xAODMissingETRetriever.cxx:106
AthAlgTool
Definition: AthAlgTool.h:26
JiveXML::xAODMissingETRetriever::m_otherKeys
Gaudi::Property< std::vector< std::string > > m_otherKeys
Definition: xAODMissingETRetriever.h:57
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