ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRec
Root
JetConstituentsRetriever.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// JetConstituentsRetriever.cxx
6
7
#include "
JetRec/JetConstituentsRetriever.h
"
8
#include "fastjet/PseudoJet.hh"
9
#include "
JetEDM/LabelIndex.h
"
10
#include "
JetEDM/IndexedConstituentUserInfo.h
"
11
#include "
JetEDM/IndexedTConstituentUserInfo.h
"
12
#include "
xAODMuon/MuonSegment.h
"
13
#include "
xAODMuon/MuonSegmentContainer.h
"
14
15
using
std::string;
16
using
xAOD::IParticle
;
17
using
xAOD::MuonSegment
;
18
19
using
IParticleVector
= std::vector<const IParticle *>;
20
using
MuonSegmentVector
= std::vector<const MuonSegment *>;
21
using
PseudoJetVector
=
IJetConstituentsRetriever::PseudoJetVector
;
22
using
NameList
=
IJetConstituentsRetriever::NameList
;
23
24
//**********************************************************************
25
26
JetConstituentsRetriever::JetConstituentsRetriever
(
const
std::string& name)
27
:
AsgTool
(name),
m_hpjr
(
""
,this) {
28
declareProperty
(
"UsePseudojet"
,
m_usepj
=
true
);
29
declareProperty
(
"UseJetConstituents"
,
m_usejetcons
=
true
);
30
declareProperty
(
"PseudojetRetriever"
,
m_hpjr
);
31
declareProperty
(
"GhostLabels"
,
m_glabs
);
32
declareProperty
(
"GhostScale"
,
m_gscale
);
33
}
34
35
//**********************************************************************
36
37
StatusCode
JetConstituentsRetriever::initialize
() {
38
if
(
m_usepj
) {
39
if
(
m_hpjr
.empty() ) {
40
ATH_MSG_ERROR
(
" PseudojetRetriever is missing."
);
41
}
42
}
43
return
StatusCode::SUCCESS;
44
}
45
46
//**********************************************************************
47
48
int
JetConstituentsRetriever::
49
constituents
(
const
xAOD::Jet
&
jet
,
PseudoJetVector
& constits,
50
NameList
* pghostlabs)
const
{
51
// If flag is set, try to retrieve constituents from jet pseudojet.
52
if
(
m_usepj
) {
53
ATH_MSG_VERBOSE
(
"Using pseudojet to search for constituents."
);
54
if
(
m_hpjr
.empty() ) {
55
ATH_MSG_WARNING
(
"Pseudojet retriever not found."
);
56
}
else
{
57
const
fastjet::PseudoJet* ppj =
m_hpjr
->pseudojet(
jet
);
58
if
( ppj ==
nullptr
) {
59
ATH_MSG_VERBOSE
(
"Pseudojet not found."
);
60
}
else
{
61
if
( ! ppj->has_constituents() ) {
62
ATH_MSG_WARNING
(
"Jet pseudojet does not have constituents."
);
63
}
else
{
64
PseudoJetVector
pjcons = ppj->constituents();
65
constits.insert(constits.end(), pjcons.begin(), pjcons.end());
66
return
0;
67
}
68
}
69
}
70
}
71
// Remainder requires access to the label index map;
72
jet::LabelIndex
* pli =
nullptr
;
73
const
string
liname =
"PseudoJetLabelMap"
;
74
if
(
evtStore
()->
contains<jet::LabelIndex>
(liname) ) {
75
ATH_MSG_DEBUG
(
"Fetching existing pseudojet label map."
);
76
pli =
evtStore
()->retrieve<
jet::LabelIndex
>(liname);
77
if
( pli ==
nullptr
) {
78
ATH_MSG_ERROR
(
"Unable to fetch pseudojet label map."
);
79
return
1;
80
}
81
}
else
{
82
ATH_MSG_DEBUG
(
"Creating new pseudojet label map."
);
83
pli =
new
jet::LabelIndex
(liname);
84
if
(
evtStore
()->record(pli, liname).isFailure() ) {
85
ATH_MSG_ERROR
(
"Unable to store pseudojet label map."
);
86
return
2;
87
}
88
}
89
// Add ATLAS jet constituents.
90
if
(
m_usejetcons
) {
91
xAOD::JetInput::Type
intype =
jet
.getInputType();
92
string
lab =
xAOD::JetInput::typeName
(intype);
93
int
labidx = pli->
addLabel
(lab);
94
ATH_MSG_DEBUG
(
"Jet input type is "
<< lab);
95
ATH_MSG_VERBOSE
(
"Looping over "
<<
jet
.getConstituents().size()
96
<<
" real constituents."
);
97
for
(
const
auto
*
const
pjetcon :
jet
.getConstituents() ) {
98
if
( pjetcon ==
nullptr
) {
99
ATH_MSG_WARNING
(
"Jet has null constituent"
);
100
}
else
{
101
//fastjet::PseudoJet psj(*pjetcon);
102
fastjet::PseudoJet psj(pjetcon->px(), pjetcon->py(), pjetcon->pz(), pjetcon->e());
103
const
xAOD::IParticle
* ppar = pjetcon->rawConstituent();
104
jet::IConstituentUserInfo
* pcui =
105
new
jet::IndexedConstituentUserInfo
(*ppar, labidx, pli);
106
psj.set_user_info(pcui);
107
constits.push_back(psj);
108
ATH_MSG_VERBOSE
(
" Real user info: particle="
<< pcui->
particle
()
109
<<
", index="
<< pcui->
index
()
110
<<
", label="
<< pcui->
label
()
111
<<
", isGhost="
<< pcui->
isGhost
());
112
}
113
}
114
}
115
// Add ghosts.
116
NameList
glabs;
117
ATH_MSG_VERBOSE
(
"Looping over "
<<
m_glabs
.size() <<
" ghost labels."
);
118
for
(
const
std::string& glab :
m_glabs
) {
119
string
gname =
"Ghost"
+ glab;
120
double
fac =
m_gscale
;
121
if
( glab ==
"MuonSegment"
) {
122
MuonSegmentVector
psegs;
123
if
(
jet
.getAssociatedObjects(gname, psegs) ) {
124
ATH_MSG_VERBOSE
(
" Found Muon segment vector "
<< gname <<
" with "
125
<< psegs.size() <<
" entries."
);
126
int
labidx = pli->
addLabel
(glab);
127
glabs.push_back(glab);
128
unsigned
int
iseg = 0;
129
for
(
const
MuonSegment
* pseg : psegs ) {
130
if
( pseg ==
nullptr
) {
131
ATH_MSG_DEBUG
(
"Muon segment not found: "
<< gname <<
"["
<< iseg <<
"]"
);
132
}
else
{
133
// Cut and paste from MuonSegmentPseudoJetGetter.
134
double
pt = 1.0e-20;
// Should be property?
135
double
x
= pseg->x();
136
double
y
= pseg->y();
137
double
z
= pseg->z();
138
double
xy = sqrt(
x
*
x
+
y
*
y
);
139
double
r
= xy*xy +
z
*
z
;
140
double
pfac = pt/xy;
141
double
px = pfac*
x
;
142
double
py = pfac*
y
;
143
double
pz = pfac*
z
;
144
double
e = pfac*
r
;
145
fastjet::PseudoJet psj(px, py, pz, e);
146
jet::IConstituentUserInfo
* pcui =
147
new
jet::IndexedTConstituentUserInfo<MuonSegment>
(*pseg, -labidx, pli);
148
psj.set_user_info(pcui);
149
constits.push_back(psj);
150
ATH_MSG_VERBOSE
(
" Muon ghost user info: particle="
<< pcui->
particle
()
151
<<
", index="
<< pcui->
index
()
152
<<
", label="
<< pcui->
label
()
153
<<
", isGhost="
<< pcui->
isGhost
());
154
ATH_MSG_VERBOSE
(
" Adding "
<< gname <<
"["
<< iseg <<
"]"
);
155
}
156
++iseg;
157
}
158
}
else
{
159
ATH_MSG_VERBOSE
(
" Muon segment vector "
<< gname <<
" is not found on jet."
);
160
}
161
162
}
else
{
163
IParticleVector
ppars;
164
if
(
jet
.getAssociatedObjects(gname, ppars) ) {
165
ATH_MSG_VERBOSE
(
" Found IParticle vector "
<< gname <<
" with "
166
<< ppars.size() <<
" entries."
);
167
int
labidx = pli->
addLabel
(glab);
168
glabs.push_back(glab);
169
unsigned
int
ipar = 0;
170
for
(
const
IParticle
* ppar : ppars ) {
171
if
( ppar ==
nullptr
) {
172
ATH_MSG_DEBUG
(
"IParticle not found: "
<< gname <<
"["
<< ipar <<
"]"
);
173
}
else
{
174
auto
p4 = ppar->p4();
175
fastjet::PseudoJet psj(fac*p4.Px(), fac*p4.Py(), fac*p4.Pz(), fac*p4.E());
176
jet::IConstituentUserInfo
* pcui =
177
new
jet::IndexedConstituentUserInfo
(*ppar, -labidx, pli);
178
psj.set_user_info(pcui);
179
constits.push_back(psj);
180
ATH_MSG_VERBOSE
(
" Ghost user info: particle="
<< pcui->
particle
()
181
<<
", index="
<< pcui->
index
()
182
<<
", label="
<< pcui->
label
()
183
<<
", isGhost="
<< pcui->
isGhost
());
184
ATH_MSG_VERBOSE
(
" Adding "
<< gname <<
"["
<< ipar <<
"]"
);
185
}
186
++ipar;
187
}
188
}
else
{
189
ATH_MSG_VERBOSE
(
" IParticle vector "
<< gname <<
" is not found on jet."
);
190
}
191
}
192
}
193
if
( pghostlabs !=
nullptr
) {
194
pghostlabs->insert(pghostlabs->end(), glabs.begin(), glabs.end());
195
}
196
return
1;
197
}
198
199
//**********************************************************************
200
201
void
JetConstituentsRetriever::print
()
const
{
202
ATH_MSG_INFO
(
"JetConstituentsRetriever"
);
203
ATH_MSG_INFO
(
" UsePseudojet: "
<<
m_usepj
);
204
if
(
m_usepj
) {
205
if
(
m_hpjr
.empty() ) {
206
ATH_MSG_INFO
(
" PseudojetRetriever is missing."
);
207
}
else
{
208
ATH_MSG_INFO
(
" PseudojetRetriever: "
<<
m_hpjr
->name());
209
}
210
}
211
ATH_MSG_INFO
(
" UsePseudojet: "
<<
m_usepj
);
212
if
(
m_glabs
.empty() ) {
213
ATH_MSG_INFO
(
" GhostLabels:"
);
214
for
(
const
std::string& glab :
m_glabs
) {
215
ATH_MSG_INFO
(
" "
<< glab);
216
}
217
}
218
ATH_MSG_INFO
(
" GhostScale: "
<<
m_gscale
);
219
}
220
221
//**********************************************************************
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
MuonSegment.h
IndexedConstituentUserInfo.h
IndexedTConstituentUserInfo.h
MuonSegmentVector
std::vector< const MuonSegment * > MuonSegmentVector
Definition
JetConstituentFiller.cxx:27
PseudoJetVector
std::vector< fastjet::PseudoJet > PseudoJetVector
Definition
JetConstituentFiller.cxx:17
IParticleVector
std::vector< const IParticle * > IParticleVector
Definition
JetConstituentsRetriever.cxx:19
NameList
IJetConstituentsRetriever::NameList NameList
Definition
JetConstituentsRetriever.cxx:22
JetConstituentsRetriever.h
LabelIndex.h
MuonSegmentContainer.h
y
#define y
x
#define x
z
#define z
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
IJetConstituentsRetriever::NameList
std::vector< std::string > NameList
Definition
IJetConstituentsRetriever.h:33
IJetConstituentsRetriever::PseudoJetVector
std::vector< fastjet::PseudoJet > PseudoJetVector
Definition
IJetConstituentsRetriever.h:32
IParticle
Definition
Event/EventKernel/EventKernel/IParticle.h:43
JetConstituentsRetriever::m_hpjr
ToolHandle< IJetPseudojetRetriever > m_hpjr
Definition
JetConstituentsRetriever.h:52
JetConstituentsRetriever::constituents
int constituents(const xAOD::Jet &jet, PseudoJetVector &cons, NameList *pghostlabs=nullptr) const
Append constituents to the supplied vector.
Definition
JetConstituentsRetriever.cxx:49
JetConstituentsRetriever::JetConstituentsRetriever
JetConstituentsRetriever(const std::string &name)
Definition
JetConstituentsRetriever.cxx:26
JetConstituentsRetriever::m_glabs
NameList m_glabs
Definition
JetConstituentsRetriever.h:53
JetConstituentsRetriever::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition
JetConstituentsRetriever.cxx:37
JetConstituentsRetriever::m_gscale
double m_gscale
Definition
JetConstituentsRetriever.h:54
JetConstituentsRetriever::m_usejetcons
bool m_usejetcons
Definition
JetConstituentsRetriever.h:51
JetConstituentsRetriever::print
void print() const
Print the state of the tool.
Definition
JetConstituentsRetriever.cxx:201
JetConstituentsRetriever::m_usepj
bool m_usepj
Definition
JetConstituentsRetriever.h:50
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
jet::IConstituentUserInfo
Definition
IConstituentUserInfo.h:26
jet::IConstituentUserInfo::label
virtual Label label() const =0
jet::IConstituentUserInfo::isGhost
virtual bool isGhost() const
Returns true if this constituent is a ghost.
Definition
IConstituentUserInfo.cxx:26
jet::IConstituentUserInfo::particle
virtual const xAOD::IParticle * particle() const =0
jet::IConstituentUserInfo::index
virtual Index index() const
Definition
IConstituentUserInfo.cxx:14
jet::IndexedConstituentUserInfo
Definition
IndexedConstituentUserInfo.h:28
jet::IndexedTConstituentUserInfo
Definition
IndexedTConstituentUserInfo.h:31
jet::LabelIndex
Definition
LabelIndex.h:22
jet::LabelIndex::addLabel
Index addLabel(const Label &lab)
Add a label and get its index.
Definition
LabelIndex.cxx:23
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
r
int r
Definition
globals.cxx:22
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::JetInput::Type
Type
Definition
JetContainerInfo.h:54
xAOD::JetInput::typeName
const std::string & typeName(Type id)
Definition
JetContainerInfo.cxx:199
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::MuonSegment
MuonSegment_v1 MuonSegment
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/MuonSegment.h:13
Generated on
for ATLAS Offline Software by
1.17.0