ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisEventDisplay
xAODJiveXML
src
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
5
#include "
xAODJiveXML/xAODMuonRetriever.h
"
6
#include "
xAODMuon/MuonContainer.h
"
7
#include "
AthenaKernel/Units.h
"
8
9
using
Athena::Units::GeV;
10
11
namespace
JiveXML
{
12
19
xAODMuonRetriever::xAODMuonRetriever
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent):
20
AthAlgTool
(
type
,name,parent){}
21
22
23
StatusCode
xAODMuonRetriever::initialize
(){
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
) {
39
SG::ReadHandle<xAOD::MuonContainer>
cont(key);
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
59
const
DataMap
xAODMuonRetriever::getData
(
const
xAOD::MuonContainer
* muCont) {
60
61
ATH_MSG_DEBUG
(
"in getData()"
);
62
63
DataMap
DataMap
;
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
73
xAOD::MuonContainer::const_iterator
muItr = muCont->
begin
();
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)->trackParticle(xAOD::Muon::TrackParticleType::Primary)->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)->trackParticle(xAOD::Muon::TrackParticleType::Primary)->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
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition
CTPResultByteStreamTool.cxx:22
MuonContainer.h
GeV
#define GeV
Definition
PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
Units.h
Wrapper to avoid constant divisions when using units.
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
DataVector< xAOD::Muon_v1 >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
JiveXML::xAODMuonRetriever::xAODMuonRetriever
xAODMuonRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition
xAODMuonRetriever.cxx:19
JiveXML::xAODMuonRetriever::initialize
virtual StatusCode initialize()
Definition
xAODMuonRetriever.cxx:23
JiveXML::xAODMuonRetriever::m_keys
SG::ReadHandleKeyArray< xAOD::MuonContainer > m_keys
Definition
xAODMuonRetriever.h:49
JiveXML::xAODMuonRetriever::getData
const DataMap getData(const xAOD::MuonContainer *)
Puts the variables into a DataMap.
Definition
xAODMuonRetriever.cxx:59
JiveXML::xAODMuonRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
For each muon collections retrieve basic parameters.
Definition
xAODMuonRetriever.cxx:33
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
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition
comparitor.cxx:525
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition
BadLArRetriever.cxx:22
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition
DataType.h: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
xAOD::MuonContainer
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Definition
Event/xAOD/xAODMuon/xAODMuon/MuonContainer.h:14
type
xAODMuonRetriever.h
Generated on
for ATLAS Offline Software by
1.17.0