ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetEventTPCnv
src
JetCnv_p4.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// JetCnv_p4.cxx
8
// Implementation file for class JetCnv_p4
9
// Author: R.Seuster<seuster@cern.ch>
11
12
// STL includes
13
14
// JetEvent includes
15
#include "
JetEvent/Jet.h
"
16
#include "
JetEvent/JetTagInfoBase.h
"
17
#include "
JetEvent/JetAssociationBase.h
"
18
19
// DataModelAthenaPool includes
20
#include "
DataModelAthenaPool/NavigableCnv_p1.h
"
21
22
// EventCommonTPCnv includes
23
#include "
EventCommonTPCnv/P4ImplPxPyPzECnv_p1.h
"
24
25
// JetEventTPCnv includes
26
#include "
JetEventTPCnv/JetCnv_p4.h
"
27
#include "
JetEventTPCnv/JetSignalStateCnv.h
"
28
29
#include "
ParticleEventTPCnv/ParticleBaseCnv_p1.h
"
30
31
#include <vector>
32
using
std::vector;
33
34
using
NavigableCnv_t
=
NavigableCnv_p1<Navigable<INavigable4MomentumCollection, double>
>;
35
36
// pre-allocate converters
37
static
const
P4ImplPxPyPzECnv_p1
momCnv
;
38
static
const
NavigableCnv_t
navCnv
;
39
static
const
ParticleBaseCnv_p1
pbsCnv
;
40
41
42
JetCnv_p4::JetCnv_p4
()
43
:
m_badIndex
(false),
44
m_nIndexTest
(0)
45
{
46
}
47
48
// Destructor
50
52
// Const methods:
54
55
void
JetCnv_p4::persToTrans
(
const
Jet_p4
* pers,
56
Jet
*
trans
,
57
MsgStream&
msg
)
const
58
{
59
msg
<< MSG::DEBUG <<
"Loading Jet from persistent state... e = "
<< pers->
m_momentum
.
m_ene
60
<<
endmsg
;
61
62
navCnv
.persToTrans( &pers->
m_nav
,
63
&
trans
->navigableBase(),
msg
);
64
momCnv
.persToTrans( &pers->
m_momentum
, &
trans
->momentumBase(),
msg
);
65
pbsCnv
.persToTrans( &pers->
m_partBase
, &
trans
->particleBase(),
msg
);
66
67
msg
<< MSG::DEBUG <<
" after momCnv e="
<<
trans
->e() <<
endmsg
;
68
69
trans
->m_jetAuthor = pers->
m_author
;
70
71
//
72
// create the store only if non-zero size (waste of space for constituents)
73
// Use swap to move the vector from one to the other - this way we
74
// don't waste time doing a copy.
75
//
76
77
78
JetKeyDescriptorInstance
* keydesc =
JetKeyDescriptorInstance::instance
();
79
std::vector<std::string> momentNames = keydesc->
getKeys
(
JetKeyConstants::ShapeCat
);
80
if
( !(pers)->m_shapeStore.empty() ){
81
if
( momentNames.size() < (pers)->m_shapeStore.size() ) {}
82
// if( ! pers->m_usedForTrigger ) { msg << MSG::WARNING << " JetCnv_p4 can't convert moments ! num max keys = "<< momentNames.size() << " persistant jet has n="<< (pers)->m_shapeStore.size() <<endmsg; }
83
else
{
84
for
(
size_t
i=0;i<(pers)->m_shapeStore.size();i++){
85
trans
->setMoment(momentNames[i], (pers)->m_shapeStore[i],
true
);
86
}
87
}
88
}
89
const_cast<
Jet_p4
*
>
(pers)->m_shapeStore.clear();
90
91
//
92
// The tag info store can contain nulls. The system
93
// doesn't deal well with that, so we need to filter them out
94
// first. We are dealing with pointers here, not actual objects.
95
//
96
97
if
(pers->
m_tagJetInfo
.empty()) {
98
if
(
trans
->m_tagInfoStore !=
nullptr
) {
99
trans
->m_tagInfoStore->clear();
100
}
101
}
else
{
102
if
(
trans
->m_tagInfoStore !=
nullptr
) {
103
delete
trans
->m_tagInfoStore;
104
}
105
106
vector<const JetTagInfoBase *> *ptags =
107
m_taginfoCnv
.createTransientConst(&(pers->
m_tagJetInfo
),
msg
);
108
if
(ptags !=
nullptr
) {
109
vector<const JetTagInfoBase*> &
tags
(*ptags);
110
for
(
unsigned
int
i = 0; i <
tags
.size(); i++) {
111
trans
->addInfo(
tags
[i]);
112
}
113
delete
ptags;
114
}
115
}
116
117
//
118
// The tag associations are similar to the tag info store
119
// above.
120
//
121
122
if
(pers->
m_associations
.empty()) {
123
if
(
trans
->m_assocStore !=
nullptr
) {
124
trans
->m_assocStore->clear();
125
}
126
}
else
{
127
if
(
trans
->m_assocStore !=
nullptr
) {
128
delete
trans
->m_assocStore;
129
}
130
trans
->m_assocStore =
new
vector<const JetAssociationBase*> ();
131
vector<const JetAssociationBase *> *pass =
132
m_tagAssCnv
.createTransientConst(&(pers->
m_associations
),
msg
);
133
134
if
(pass !=
nullptr
) {
135
vector<const JetAssociationBase *> &
ass
(*pass);
136
vector<const JetAssociationBase *> &store (*
trans
->m_assocStore);
137
for
(
unsigned
int
i = 0; i <
ass
.size(); i++) {
138
// We want to read in the association objects and stick them
139
// into the store vector, at the indices that are stored in the
140
// objects.
141
//
142
// A catch, though, is that in 14.2.0, the indices are not filled
143
// in properly --- one gets garbage. In that case, one can use
144
// the setAssociation method to store the association. We don't
145
// want to do that, though, if the index information is available.
146
//
147
// Further complicating this, there seems to be no reliable way
148
// of distinguishing between these cases, at least not without
149
// trying to dig the version string out of metadata, which has
150
// its own set of issues.
151
//
152
// Instead, we'll do this. The first 10 times we go through
153
// here, we'll cross-check the saved index against what we
154
// compute via getIndex(). If there are any mismatches,
155
// we'll revert to using setAssociation from then on.
156
// Otherwise, we'll just use the index directly.
157
//
158
// Here, m_nIndexTest is the number of times we've done
159
// the cross-check. m_badIndex is set to true if we find
160
// a mismatch.
161
162
// The stored index.
163
unsigned
int
index
=
ass
[i]->keyIndex();
164
165
// Cross-check against getIndex() for up to the first 10 times.
166
if
(
m_nIndexTest
< 10 && !
m_badIndex
) {
167
++
m_nIndexTest
;
168
if
(
JetKeyDescriptorInstance::instance
()->getIndex (
"JetAssociations"
,
169
ass
[i]->name()) !=
index
)
170
m_badIndex
=
true
;
171
}
172
173
// Store the association, either using setAssociation, or
174
// directly using the stored index.
175
if
(
m_badIndex
)
176
trans
->setAssociation (
ass
[i]);
177
else
{
178
if
(
index
>= store.size()) {
179
store.resize(
index
+1,
nullptr
);
180
}
181
store[
index
] =
ass
[i];
182
}
183
184
ass
[i] =
nullptr
;
// Make sure nothing bad happens.
185
}
186
delete
pass;
187
}
188
}
189
190
// default signal state
191
trans
->setSignalState(
P4SignalState::CALIBRATED
);
192
193
SignalStateCnv
statecnv;
194
195
trans
->setRawE ( statecnv.
ratio_from_char
( pers->
m_ratioE
) *
trans
->e() );
196
trans
->setRawPx ( statecnv.
ratio_from_char
(pers->
m_ratioPx
) *
trans
->px());
197
trans
->setRawPy ( statecnv.
ratio_from_char
(pers->
m_ratioPy
) *
trans
->py());
198
trans
->setRawPz ( statecnv.
ratio_from_char
(pers->
m_ratioPz
) *
trans
->pz());
199
200
201
msg
<< MSG::DEBUG <<
"Loaded Jet from persistent state [OK]"
202
<<
endmsg
;
203
}
204
205
void
JetCnv_p4::transToPers
(
const
Jet
*
trans
,
206
Jet_p4
* pers,
207
MsgStream&
msg
)
const
208
{
209
navCnv
.transToPers( &
trans
->navigableBase(), &pers->
m_nav
,
msg
);
210
momCnv
.transToPers( &
trans
->momentumBase(), &pers->
m_momentum
,
msg
);
211
pbsCnv
.transToPers( &
trans
->particleBase(), &pers->
m_partBase
,
msg
);
212
213
214
pers->
m_author
=
trans
->m_jetAuthor;
215
216
// if ( bool(trans->m_shapeStore) )
217
// pers->m_shapeStore = *(trans->m_shapeStore);
218
// else
219
// pers->m_shapeStore.clear();
220
225
226
if
(
trans
->m_tagInfoStore !=
nullptr
) {
227
vector<const JetTagInfoBase*> goodTagInfo;
228
const
vector<const JetTagInfoBase*> &tagInfo(*(
trans
->m_tagInfoStore));
229
for
(
unsigned
int
i = 0; i < tagInfo.size(); i++) {
230
if
(tagInfo[i] !=
nullptr
) {
231
goodTagInfo.push_back(tagInfo[i]);
232
}
233
}
234
m_taginfoCnv
.transToPers(&goodTagInfo, &(pers->
m_tagJetInfo
),
msg
);
235
}
236
240
241
if
(
trans
->m_assocStore !=
nullptr
) {
242
vector<const JetAssociationBase*> goodAssInfo;
243
const
vector<const JetAssociationBase*> &assInfo(*
trans
->m_assocStore);
244
245
for
(
unsigned
int
i = 0; i < assInfo.size(); i++) {
246
if
(assInfo[i] !=
nullptr
) {
247
goodAssInfo.push_back(assInfo[i]);
248
}
249
}
250
251
m_tagAssCnv
.transToPers(&goodAssInfo, &pers->
m_associations
,
msg
);
252
}
253
254
SignalStateCnv
statecnv;
255
256
pers->
m_ratioE
= statecnv.
char_from_ratio
(
trans
->getRawE() /
trans
->e(
P4SignalState::CALIBRATED
) );
257
pers->
m_ratioPx
= statecnv.
char_from_ratio
(
trans
->getRawPx() /
trans
->px(
P4SignalState::CALIBRATED
));
258
pers->
m_ratioPy
= statecnv.
char_from_ratio
(
trans
->getRawPy() /
trans
->py(
P4SignalState::CALIBRATED
));
259
pers->
m_ratioPz
= statecnv.
char_from_ratio
(
trans
->getRawPz() /
trans
->pz(
P4SignalState::CALIBRATED
));
260
261
262
263
msg
<< MSG::DEBUG <<
"Created persistent state of Jet [OK] e="
<< pers->
m_momentum
.
m_ene
264
<<
endmsg
;
265
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
NavigableCnv_t
NavigableCnv_p1< Navigable< INavigable4MomentumCollection, double > > NavigableCnv_t
Definition
CompositeParticleCnv_p1.cxx:30
JetAssociationBase.h
navCnv
static const NavigableCnv_t navCnv
Definition
JetCnv_p1.cxx:31
momCnv
static const P4ImplPxPyPzECnv_p1 momCnv
Definition
JetCnv_p1.cxx:30
pbsCnv
static const ParticleBaseCnv_p1 pbsCnv
Definition
JetCnv_p4.cxx:39
JetCnv_p4.h
JetSignalStateCnv.h
JetTagInfoBase.h
NavigableCnv_p1.h
This file contains the class definition for the NavigableCnv_p1 class.
P4ImplPxPyPzECnv_p1.h
ParticleBaseCnv_p1.h
Jet.h
JetCnv_p4::persToTrans
virtual void persToTrans(const Jet_p4 *persObj, Jet *transObj, MsgStream &msg) const override
Method creating the transient representation of Jet from its persistent representation Jet_p4.
Definition
JetCnv_p4.cxx:55
JetCnv_p4::m_nIndexTest
std::atomic< int > m_nIndexTest
Definition
JetCnv_p4.h:84
JetCnv_p4::JetCnv_p4
JetCnv_p4()
Default constructor:
Definition
JetCnv_p4.cxx:42
JetCnv_p4::m_taginfoCnv
TagInfoCollectionCnv m_taginfoCnv
Definition
JetCnv_p4.h:73
JetCnv_p4::m_badIndex
std::atomic< bool > m_badIndex
Definition
JetCnv_p4.h:83
JetCnv_p4::transToPers
virtual void transToPers(const Jet *transObj, Jet_p4 *persObj, MsgStream &msg) const override
Method creating the persistent representation Jet_p4 from its transient representation Jet.
Definition
JetCnv_p4.cxx:205
JetCnv_p4::m_tagAssCnv
TagAssCollectionCnv m_tagAssCnv
Definition
JetCnv_p4.h:80
JetKeyDescriptorInstance
Theses classes implement a mapping between string and index used by jets.
Definition
JetKeyDescriptor.h:100
JetKeyDescriptorInstance::getKeys
const std::vector< key_t > & getKeys(const category_t &cat) const
Definition
JetKeyDescriptor.cxx:178
JetKeyDescriptorInstance::instance
static JetKeyDescriptorInstance * instance()
Definition
JetKeyDescriptor.h:123
Jet_p4
Definition
Jet_p4.h:37
Jet_p4::m_momentum
P4PxPyPzE_p1 m_momentum
the 4-mom part
Definition
Jet_p4.h:75
Jet_p4::m_nav
Navigable_p1< uint32_t, double > m_nav
the navigable part
Definition
Jet_p4.h:72
Jet_p4::m_author
unsigned int m_author
Definition
Jet_p4.h:80
Jet_p4::m_ratioPy
char m_ratioPy
ratio for uncalibrated p_x
Definition
Jet_p4.h:94
Jet_p4::m_ratioPx
char m_ratioPx
ratio for uncalibrated E
Definition
Jet_p4.h:93
Jet_p4::m_ratioE
char m_ratioE
Definition
Jet_p4.h:92
Jet_p4::m_partBase
ParticleBase_p1 m_partBase
The Particle base stuff – since Jet now inherrits from particle base.
Definition
Jet_p4.h:78
Jet_p4::m_ratioPz
char m_ratioPz
ratio for uncalibrated p_y
Definition
Jet_p4.h:95
Jet_p4::m_associations
std::vector< TPObjRef > m_associations
JetAssociationBase objects.
Definition
Jet_p4.h:89
Jet_p4::m_tagJetInfo
std::vector< TPObjRef > m_tagJetInfo
JetTagInfoBase objects.
Definition
Jet_p4.h:86
Jet
Definition
Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
NavigableCnv_p1
Definition
NavigableCnv_p1.h:29
P4ImplPxPyPzECnv_p1
Definition
P4ImplPxPyPzECnv_p1.h:38
P4PxPyPzE_p1::m_ene
float m_ene
Definition
P4PxPyPzE_p1.h:42
ParticleBaseCnv_p1
Definition
ParticleBaseCnv_p1.h:30
SignalStateCnv
Definition
JetSignalStateCnv.h:78
SignalStateCnv::ratio_from_char
double ratio_from_char(char c) const
Definition
JetSignalStateCnv.h:119
SignalStateCnv::char_from_ratio
char char_from_ratio(double r) const
Definition
JetSignalStateCnv.h:101
ass
make the histogram assessment part of the config
Definition
hcg.cxx:629
trans
TH1F * trans(TH1F *h, bool t=false)
Definition
comparitor.cxx:199
tags
std::vector< std::string > tags
Definition
hcg.cxx:107
index
Definition
index.py:1
JetKeyConstants::ShapeCat
static const key_t ShapeCat
Index category for jet shapes.
Definition
JetKeyDescriptor.h:88
P4SignalState::CALIBRATED
@ CALIBRATED
Definition
ISignalState.h:31
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0