ATLAS Offline Software
xAODMuonRetriever.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "AthenaKernel/Units.h"
8 
10 
11 namespace JiveXML {
12 
19  xAODMuonRetriever::xAODMuonRetriever(const std::string& type,const std::string& name,const IInterface* parent):
21 
22 
24  ATH_CHECK(m_keys.initialize());
25  return StatusCode::SUCCESS;
26  }
27 
28 
33  StatusCode xAODMuonRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
34 
35  ATH_MSG_DEBUG("In retrieve()");
36 
37  // Loop through the keys and retrieve the corresponding data
38  for (const auto& key : m_keys) {
40  if (cont.isValid()) {
41  DataMap data = getData(&(*cont));
42  if (FormatTool->AddToEvent(dataTypeName(), key.key() + "_xAOD", &data).isFailure()) {
43  ATH_MSG_WARNING("Failed to add collection " << key.key());
44  } else {
45  ATH_MSG_DEBUG(" (" << key.key() << ") retrieved");
46  }
47  } else {
48  ATH_MSG_WARNING("Collection " << key.key() << " not found in SG");
49  }
50  }
51  return StatusCode::SUCCESS;
52  }
53 
54 
60 
61  ATH_MSG_DEBUG("in getData()");
62 
64 
65  DataVect pt; pt.reserve(muCont->size());
66  DataVect phi; phi.reserve(muCont->size());
67  DataVect eta; eta.reserve(muCont->size());
68  DataVect mass; mass.reserve(muCont->size());
69  DataVect energy; energy.reserve(muCont->size());
70  DataVect chi2; chi2.reserve(muCont->size());
71  DataVect pdgId; pdgId.reserve(muCont->size());
72 
74  xAOD::MuonContainer::const_iterator muItrE = muCont->end();
75 
76  int counter = 0;
77 
78  for (; muItr != muItrE; ++muItr) {
79 
80  ATH_MSG_DEBUG(" Muon #" << counter++ << " : eta = " << (*muItr)->eta()
81  << ", phi = " << (*muItr)->phi() << ", pt = " << (*muItr)->pt()
82  << ", pdgId = " << -13.*(*muItr)->primaryTrackParticle()->charge());
83 
84  phi.emplace_back(DataType((*muItr)->phi()));
85  eta.emplace_back(DataType((*muItr)->eta()));
86  pt.emplace_back(DataType((*muItr)->pt()/GeV));
87 
88  mass.emplace_back(DataType((*muItr)->m()/GeV));
89  energy.emplace_back( DataType((*muItr)->e()/GeV ) );
90  chi2.emplace_back( 1.0 ); //placeholder
91  pdgId.emplace_back(DataType( -13.*(*muItr)->primaryTrackParticle()->charge() )); // pdgId not available anymore in xAOD
92  } // end MuonIterator
93 
94  // four-vectors
95  DataMap["phi"] = phi;
96  DataMap["eta"] = eta;
97  DataMap["pt"] = pt;
98  DataMap["energy"] = energy;
99  DataMap["mass"] = mass;
100  DataMap["chi2"] = chi2;
101  DataMap["pdgId"] = pdgId;
102 
103  ATH_MSG_DEBUG(" retrieved with " << phi.size() << " entries");
104  return DataMap;
105  }
106 } // JiveXML namespace
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
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
JiveXML::xAODMuonRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type that is generated by this retriever.
Definition: xAODMuonRetriever.h:42
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
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
test_pyathena.pt
pt
Definition: test_pyathena.py:11
JiveXML::xAODMuonRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
For each muon collections retrieve basic parameters.
Definition: xAODMuonRetriever.cxx:33
JiveXML::xAODMuonRetriever::m_keys
SG::ReadHandleKeyArray< xAOD::MuonContainer > m_keys
Definition: xAODMuonRetriever.h:49
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
JiveXML::xAODMuonRetriever::xAODMuonRetriever
xAODMuonRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: xAODMuonRetriever.cxx:19
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
JiveXML::xAODMuonRetriever::getData
const DataMap getData(const xAOD::MuonContainer *)
Puts the variables into a DataMap.
Definition: xAODMuonRetriever.cxx:59
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
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
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:525
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
JiveXML::xAODMuonRetriever::initialize
virtual StatusCode initialize()
Definition: xAODMuonRetriever.cxx:23
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAODMuonRetriever.h
runIDPVM.pdgId
pdgId
Definition: runIDPVM.py:91
Units.h
Wrapper to avoid constant divisions when using units.
MuonContainer.h
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
test_pyathena.counter
counter
Definition: test_pyathena.py:15
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