ATLAS Offline Software
Loading...
Searching...
No Matches
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
8
9using Athena::Units::GeV;
10
11namespace JiveXML {
12
19 xAODMuonRetriever::xAODMuonRetriever(const std::string& type,const std::string& name,const IInterface* parent):
20 AthAlgTool(type,name,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
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
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Wrapper to avoid constant divisions when using units.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
xAODMuonRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
virtual StatusCode initialize()
SG::ReadHandleKeyArray< xAOD::MuonContainer > m_keys
const DataMap getData(const xAOD::MuonContainer *)
Puts the variables into a DataMap.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
For each muon collections retrieve basic parameters.
virtual std::string dataTypeName() const
Return the name of the data type that is generated by this retriever.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
double chi2(TH1 *h0, TH1 *h1)
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".