ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
EventCommonD3PDMaker
src
FourMomFillerTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
11
12
13
#include "
FourMomFillerTool.h
"
14
#include "
EventKernel/INavigable4Momentum.h
"
15
#include "
EventKernel/I4Momentum.h
"
16
#include "
AthenaKernel/errorcheck.h
"
17
#include "CLHEP/Vector/LorentzVector.h"
18
#include "TLorentzVector.h"
19
#include <typeinfo>
20
#include <cmath>
21
22
23
namespace
D3PD
{
24
25
32
FourMomFillerTool::FourMomFillerTool
(
const
std::string&
type
,
33
const
std::string& name,
34
const
IInterface* parent)
35
:
Base
(
type
, name, parent)
36
{
37
m_do_E
=
true
;
38
m_do_p
=
true
;
39
m_do_Et
=
true
;
40
m_do_pt
=
true
;
41
m_do_m
=
true
;
42
m_do_rapidity
=
true
;
43
m_do_tanth
=
true
;
44
m_do_etaphi
=
true
;
45
m_do_rect
=
true
;
46
FourMomFillerTool::book
().ignore();
// Avoid coverity warnings.
47
48
declareProperty (
"WriteE"
,
m_do_E
=
false
);
49
declareProperty (
"WriteP"
,
m_do_p
=
false
);
50
declareProperty (
"WriteEt"
,
m_do_Et
=
false
);
51
declareProperty (
"WritePt"
,
m_do_pt
=
true
);
52
declareProperty (
"WriteM"
,
m_do_m
=
true
);
53
declareProperty (
"WriteRapidity"
,
m_do_rapidity
=
false
);
54
declareProperty (
"WriteTanTh"
,
m_do_tanth
=
false
);
55
declareProperty (
"WriteEtaPhi"
,
m_do_etaphi
=
true
);
56
declareProperty (
"WriteRect"
,
m_do_rect
=
false
);
57
}
58
59
63
StatusCode
FourMomFillerTool::book
()
64
{
65
if
(
m_do_E
)
CHECK
(
addVariable
(
"E"
,
m_E
) );
66
if
(
m_do_p
)
CHECK
(
addVariable
(
"p"
,
m_p
) );
67
if
(
m_do_Et
)
CHECK
(
addVariable
(
"Et"
,
m_Et
) );
68
if
(
m_do_pt
)
CHECK
(
addVariable
(
"pt"
,
m_pt
) );
69
if
(
m_do_m
)
CHECK
(
addVariable
(
"m"
,
m_m
) );
70
if
(
m_do_rapidity
)
CHECK
(
addVariable
(
"y"
,
m_y
) );
71
if
(
m_do_tanth
)
CHECK
(
addVariable
(
"tanth"
,
m_tanth
) );
72
73
if
(
m_do_etaphi
) {
74
CHECK
(
addVariable
(
"eta"
,
m_eta
) );
75
CHECK
(
addVariable
(
"phi"
,
m_phi
) );
76
}
77
78
if
(
m_do_rect
) {
79
CHECK
(
addVariable
(
"px"
,
m_px
) );
80
CHECK
(
addVariable
(
"py"
,
m_py
) );
81
CHECK
(
addVariable
(
"pz"
,
m_pz
) );
82
}
83
84
return
StatusCode::SUCCESS;
85
}
86
87
88
#define FILL_BODY(P, PT, TANTH) \
89
do { \
90
if (m_do_E) *m_E = static_cast<float> (p.e()); \
91
if (m_do_p) *m_p = static_cast<float> (P); \
92
if (m_do_Et) *m_Et = static_cast<float> (p.et()); \
93
if (m_do_pt) *m_pt = static_cast<float> (PT); \
94
if (m_do_m) *m_m = static_cast<float> (p.m()); \
95
if (m_do_rapidity) *m_y = static_cast<float> (p.rapidity()); \
96
if (m_do_tanth) *m_tanth = static_cast<float> (TANTH); \
97
\
98
if (m_do_etaphi) { \
99
*m_eta = static_cast<float> (p.eta()); \
100
*m_phi = static_cast<float> (p.phi()); \
101
} \
102
\
103
if (m_do_rect) { \
104
*m_px = static_cast<float> (p.px()); \
105
*m_py = static_cast<float> (p.py()); \
106
*m_pz = static_cast<float> (p.pz()); \
107
} \
108
} while(0)
109
110
115
StatusCode
FourMomFillerTool::fill
(
const
I4Momentum
& p)
116
{
117
FILL_BODY
(p.p(), p.pt(), p.tanTh());
118
119
return
StatusCode::SUCCESS;
120
}
121
122
127
StatusCode
FourMomFillerTool::fill
(
const
INavigable4Momentum
& p)
128
{
129
return
fill
(
static_cast<
const
I4Momentum
&
>
(p));
130
}
131
132
137
StatusCode
FourMomFillerTool::fill
(
const
CLHEP::HepLorentzVector& p)
138
{
139
FILL_BODY
(p.mag(), p.perp(), std::tan(p.theta()));
140
141
return
StatusCode::SUCCESS;
142
}
143
144
149
StatusCode
FourMomFillerTool::fill
(
const
xAOD::IParticle
& p)
150
{
151
return
fill
(p.p4());
152
}
153
154
159
StatusCode
FourMomFillerTool::fill
(
const
TLorentzVector& p)
160
{
161
double
pt = p.Pt();
162
163
if
(
m_do_E
) *
m_E
=
static_cast<
float
>
(p.E());
164
if
(
m_do_p
) *
m_p
=
static_cast<
float
>
(p.P());
165
if
(
m_do_Et
) *
m_Et
=
static_cast<
float
>
(p.Et());
166
if
(
m_do_pt
) *
m_pt
=
static_cast<
float
>
(pt);
167
if
(
m_do_m
) *
m_m
=
static_cast<
float
>
(p.M());
168
if
(
m_do_rapidity
) *
m_y
=
static_cast<
float
>
(p.Rapidity());
169
if
(
m_do_tanth
) *
m_tanth
=
static_cast<
float
>
(tan(p.Theta()));
170
171
if
(
m_do_etaphi
) {
172
if
(pt < 1e-6) {
173
if
(p.Pz() > 0)
174
*
m_eta
= 10e10;
175
else
176
*
m_eta
= 10e-10;
177
}
178
else
179
*
m_eta
=
static_cast<
float
>
(p.Eta());
180
*
m_phi
=
static_cast<
float
>
(p.Phi());
181
}
182
183
if
(
m_do_rect
) {
184
*
m_px
=
static_cast<
float
>
(p.Px());
185
*
m_py
=
static_cast<
float
>
(p.Py());
186
*
m_pz
=
static_cast<
float
>
(p.Pz());
187
}
188
189
return
StatusCode::SUCCESS;
190
}
191
192
193
}
// namespace D3PD
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
FILL_BODY
#define FILL_BODY(P, PT, TANTH)
Definition
FourMomFillerTool.cxx:88
FourMomFillerTool.h
Block filler tool for a four-momentum.
I4Momentum.h
INavigable4Momentum.h
D3PD::BlockFillerTool< Types< INavigable4Momentum, I4Momentum, CLHEP::HepLorentzVector, xAOD::IParticle > >::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Definition
AddVariable.cxx:85
D3PD::FourMomFillerTool::m_pt
float * m_pt
Variable: Transverse momentum.
Definition
FourMomFillerTool.h:152
D3PD::FourMomFillerTool::m_py
float * m_py
Variable: y-component of momentum.
Definition
FourMomFillerTool.h:173
D3PD::FourMomFillerTool::fill
virtual StatusCode fill(const INavigable4Momentum &p)
Fill one block — type-safe version.
Definition
FourMomFillerTool.cxx:127
D3PD::FourMomFillerTool::m_do_rapidity
bool m_do_rapidity
Property: Should we fill rapidity?
Definition
FourMomFillerTool.h:130
D3PD::FourMomFillerTool::m_do_Et
bool m_do_Et
Property: Should we fill Et?
Definition
FourMomFillerTool.h:121
D3PD::FourMomFillerTool::m_pz
float * m_pz
Variable: z-component of momentum.
Definition
FourMomFillerTool.h:176
D3PD::FourMomFillerTool::m_tanth
float * m_tanth
Variable: Tangent of polar angle.
Definition
FourMomFillerTool.h:161
D3PD::FourMomFillerTool::m_do_m
bool m_do_m
Property: Should we fill m?
Definition
FourMomFillerTool.h:127
D3PD::FourMomFillerTool::book
virtual StatusCode book()
Book variables for this block.
Definition
FourMomFillerTool.cxx:63
D3PD::FourMomFillerTool::m_do_p
bool m_do_p
Property: Should we fill p?
Definition
FourMomFillerTool.h:118
D3PD::FourMomFillerTool::FourMomFillerTool
FourMomFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition
FourMomFillerTool.cxx:32
D3PD::FourMomFillerTool::m_m
float * m_m
Variable: Mass.
Definition
FourMomFillerTool.h:155
D3PD::FourMomFillerTool::m_y
float * m_y
Variable: Rapidity.
Definition
FourMomFillerTool.h:158
D3PD::FourMomFillerTool::m_do_E
bool m_do_E
Property: Should we fill E?
Definition
FourMomFillerTool.h:115
D3PD::FourMomFillerTool::m_E
float * m_E
Variable: Energy.
Definition
FourMomFillerTool.h:143
D3PD::FourMomFillerTool::m_p
float * m_p
Variable: Momentum.
Definition
FourMomFillerTool.h:146
D3PD::FourMomFillerTool::m_do_etaphi
bool m_do_etaphi
Property: Should we fill eta/phi?
Definition
FourMomFillerTool.h:136
D3PD::FourMomFillerTool::m_phi
float * m_phi
Variable: Azimuth.
Definition
FourMomFillerTool.h:167
D3PD::FourMomFillerTool::m_Et
float * m_Et
Variable: Transverse energy (E*sin(theta)).
Definition
FourMomFillerTool.h:149
D3PD::FourMomFillerTool::m_do_pt
bool m_do_pt
Property: Should we fill pt?
Definition
FourMomFillerTool.h:124
D3PD::FourMomFillerTool::Base
BlockFillerTool< Types< INavigable4Momentum, I4Momentum, CLHEP::HepLorentzVector, xAOD::IParticle > > Base
Definition
FourMomFillerTool.h:61
D3PD::FourMomFillerTool::m_do_tanth
bool m_do_tanth
Property: Should we fill tan(theta)?
Definition
FourMomFillerTool.h:133
D3PD::FourMomFillerTool::m_eta
float * m_eta
Variable: Pseudorapidity.
Definition
FourMomFillerTool.h:164
D3PD::FourMomFillerTool::m_px
float * m_px
Variable: x-component of momentum.
Definition
FourMomFillerTool.h:170
D3PD::FourMomFillerTool::m_do_rect
bool m_do_rect
Property: Should we fill px/py/pz?
Definition
FourMomFillerTool.h:139
I4Momentum
I4Momentum is an abstract base class providing 4-momentum behavior.
Definition
I4Momentum.h:31
INavigable4Momentum
Definition
INavigable4Momentum.h:21
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
D3PD
Block filler tool for noisy FEB information.
Definition
CaloCellDetailsFillerTool.cxx:29
D3PD::fill
virtual StatusCode fill()
Fill one object.
type
Generated on
for ATLAS Offline Software by
1.17.0