ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
EventCommonD3PDMaker
src
DRAssociationTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
10
11
// STL include(s):
12
#include <cmath>
13
14
#include "
DRAssociationTool.h
"
15
#include "
FourMomUtils/P4Helpers.h
"
16
#include "
EventKernel/INavigable4Momentum.h
"
17
#include "
AthenaKernel/errorcheck.h
"
18
#include "GaudiKernel/SystemOfUnits.h"
19
20
21
using
Gaudi::Units::MeV;
22
23
24
namespace
D3PD
{
25
26
33
DRAssociationTool::DRAssociationTool (
const
std::string&
type
,
34
const
std::string& name,
35
const
IInterface* parent)
36
:
Base
(
type
, name, parent),
37
m_getter
(this)
38
{
39
declareProperty (
"Getter"
,
m_getter
,
40
"ICollectionGetterTool instance defining "
41
"the target collection"
);
42
declareProperty (
"DRCut"
,
m_drcut
= 999,
43
"DR cut for the association"
);
44
45
DRAssociationTool::book().ignore();
// Avoid coverity warnings.
46
}
47
48
52
StatusCode DRAssociationTool::initialize()
53
{
54
// Retrieve the getter tool and configure it, saying that we want
55
// to get @c INavigable4Momentum objects from it.
56
CHECK
( m_getter.retrieve() );
57
//CHECK( m_getter->configureD3PD<INavigable4Momentum>() );
58
//CHECK( m_getter->configureElementTypeinfo
59
return
Base::initialize();
60
}
61
62
71
StatusCode
DRAssociationTool::configureD3PD (IAddVariable*
tree
,
72
const
std::type_info& ti)
73
{
74
CHECK
( Base::configureD3PD (
tree
, ti) );
75
CHECK
(
m_getter
->configureElementTypeinfo (this->typeinfo()));
76
return
StatusCode::SUCCESS;
77
}
78
79
83
StatusCode
DRAssociationTool::book ()
84
{
85
CHECK
( addVariable (
"dr"
, m_dr) );
86
return
StatusCode::SUCCESS;
87
}
88
89
96
const
INavigable4Momentum
*
97
DRAssociationTool::get (
const
INavigable4Momentum
& p)
98
{
99
// Protect against null 4-momenta --- they'll crash deltaR.
100
if
(
p
.p() < 1e-3*
MeV
)
return
0;
101
// Protect against infinite eta. It appears in some circumstances.
102
if
( std::isinf(
p
.eta()) )
return
0;
103
104
*
m_dr
= -1;
105
106
if
(
m_getter
->reset().isFailure()) {
107
REPORT_MESSAGE
(MSG::ERROR) <<
"Can't reset input getter."
;
108
return
0;
109
}
110
111
const
INavigable4Momentum
*
pout
= 0;
112
float
min_dr =
m_drcut
;
113
while
(
const
INavigable4Momentum
* obj =
114
m_getter
->next<
INavigable4Momentum
>())
115
{
116
if
(
obj
->pt() < 1e-2*
MeV
)
continue
;
117
if
( std::isinf(
obj
->eta() ) )
continue
;
118
float
dr
=
static_cast<
float
>
(
P4Helpers::deltaR
(p, *obj));
119
if
(dr < min_dr) {
120
*
m_dr
=
dr
;
121
min_dr =
dr
;
122
pout
=
obj
;
123
}
124
}
125
return
pout
;
126
}
127
128
135
const
xAOD::IParticle
*
136
DRAssociationTool::get (
const
xAOD::IParticle
& p)
137
{
138
// Protect against null 4-momenta --- they'll crash deltaR.
139
if
(
p
.e() < 1e-3*
MeV
)
return
0;
140
// Protect against infinite eta. It appears in some circumstances.
141
if
( std::isinf(
p
.eta()) )
return
0;
142
143
*
m_dr
= -1;
144
145
if
(
m_getter
->reset().isFailure()) {
146
REPORT_MESSAGE
(MSG::ERROR) <<
"Can't reset input getter."
;
147
return
0;
148
}
149
150
const
xAOD::IParticle
*
pout
= 0;
151
float
min_dr =
m_drcut
;
152
while
(
const
xAOD::IParticle
* obj =
153
m_getter
->next<
xAOD::IParticle
>())
154
{
155
if
(
obj
->pt() < 1e-2*
MeV
)
continue
;
156
if
( std::isinf(
obj
->eta() ) )
continue
;
157
float
dr
=
p
.p4().DeltaR (
obj
->p4());
158
if
(dr < min_dr) {
159
*
m_dr
=
dr
;
160
min_dr =
dr
;
161
pout
=
obj
;
162
}
163
}
164
return
pout
;
165
}
166
167
168
}
// namespace D3PD
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:365
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DRAssociationTool.h
Associate to particle closest in DR.
MeV
static const double MeV
Definition
HIEventSelectionToolRun3.cxx:72
INavigable4Momentum.h
P4Helpers.h
Base
doing TRTHTH Hypo selection
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::pout
const void * pout
Definition
IndexAssociationFillerTool.cxx:161
D3PD::m_dr
float * m_dr
Variable: DR to associated object.
Definition
DRAssociationTool.h:112
D3PD::m_getter
ToolHandle< ICollectionGetterTool > m_getter
Property: The collection getter tool.
Definition
VectorFillerTool.h:135
D3PD::m_drcut
float m_drcut
Property: DR cut.
Definition
DRAssociationTool.h:109
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
P4Helpers::deltaR
double deltaR(const I4Momentum &p4, double eta, double phi)
from 1 I4Momentum
Definition
P4Helpers.h:209
python.PyAthena.obj
obj
Definition
PyAthena.py:131
python.TurnDataReader.dr
dr
Definition
TurnDataReader.py:111
python.utils.AtlRunQueryDQUtils.p
p
Definition
AtlRunQueryDQUtils.py:209
type
tree
TChain * tree
Definition
tile_monitor.h:30
Generated on
for ATLAS Offline Software by
1.17.0