ATLAS Offline Software
Loading...
Searching...
No Matches
JetCnv_p6.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5*/
6
7// Implementation file for class JetCnv_p6
8// Author: R.Seuster<seuster@cern.ch>
10
11// STL includes
12
13// DataModelAthenaPool includes
16
18
19// for origin
21
22
23// JetEvent includes
24#include "JetEvent/Jet.h"
28
29// JetEventTPCnv includes
32
34
35
36#include <vector>
37using std::vector;
38
40
41// pre-allocate converters
42static const VxLinkCnv_t vxCnv;
43
44
45
47
48// pre-allocate converters
49// static const P4ImplPxPyPzECnv_p1 momCnv;
51//static const DataLinkCnv_p2<DataLink<JetMomentMap> > momentMapCnv;
52
53
54
55double JetCnvE(float px,float py, float pz, float m){
56 return std::sqrt( px*px + py*py + pz*pz + m*m);
57}
58
59void JetCnv_p6::persToTrans( const Jet_p6* pers,
60 Jet* trans,
61 MsgStream& msg ) const
62{
63 if(msg.level() == MSG::DEBUG ) msg << MSG::DEBUG << "JetCnv_p6 Loading Jet from persistent state... " << endmsg;
64
65 navCnv.persToTrans( &pers->m_nav,
66 &trans->navigableBase(), msg );
67 // store as floats and use compressors for the signal state
68 // momCnv.persToTrans( &pers->m_momentum, &trans->momentumBase(), msg );
69 //pbsCnv.persToTrans( &pers->m_partBase, &trans->particleBase(), msg);
71 ElementLink<VxContainer> origin;
72 vxCnv.persToTrans( &pers->m_origin, &origin, msg );
73 trans->set_origin (origin);
74
75
76 trans->m_jetAuthor = pers->m_author;
77 trans->m_RoIword = pers->m_RoIword;
78 trans->m_constituentsN = pers->m_constituentsN;
79 trans->m_jetId = pers->m_jetId ;
80 if (trans->m_constituentsN > 10000 ) {
81 // then we assume this is non physical. Most probably this means
82 // we are reading pre 15.1.0 files were m_constituentsN was not saved
83 // and that ROOT is assigning a default value. we reset it to 0
84 trans->m_constituentsN = 0;
85 }
86
87
88
90
91 //trans->setCalE( JetCnvE( pers->m_px ,pers->m_py ,pers->m_pz , pers->m_m ) );
92 const float *momentum = (pers->m_momentum);
93 trans->setCalPx( momentum[ 0 ] );
94 trans->setCalPy( momentum[ 1 ] );
95 trans->setCalPz( momentum[ 2 ] );
96 trans->setCalE ( momentum[ 3 ] );
97
98 trans->setRawPx( momentum[ 4 ] );
99 trans->setRawPy( momentum[ 5 ] );
100 trans->setRawPz( momentum[ 6 ] );
101 trans->setRawE ( momentum[ 7 ] );
102
103 trans->setCScalePx( momentum[ 8 ] );
104 trans->setCScalePy( momentum[ 9 ] );
105 trans->setCScalePz( momentum[ 10 ] );
106 trans->setCScaleE ( momentum[ 11 ] );
107
108
109 // ALWAYS read at FINAL state.
111
112
113
114
115
116
117
118 //momentMapCnv.persToTrans(&pers->m_moments , &trans->m_momentMapLink, msg);
119
120 //
121 // The tag info store can contain nulls. The system
122 // doesn't deal well with that, so we need to filter them out
123 // first. We are dealing with pointers here, not actual objects.
124 //
125
126 if (pers->m_tagJetInfo.empty()) {
127 if (trans->m_tagInfoStore != nullptr) {
128 trans->m_tagInfoStore->clear();
129 }
130 } else {
131 if (trans->m_tagInfoStore != nullptr) {
132 delete trans->m_tagInfoStore;
133 }
134
135 vector<const JetTagInfoBase *> *ptags =
136 m_taginfoCnv.createTransientConst(&(pers->m_tagJetInfo), msg);
137 if (ptags != nullptr) {
138 vector<const JetTagInfoBase*> &tags (*ptags);
139 for (unsigned int i = 0; i < tags.size(); i++) {
140 trans->addInfo(tags[i]);
141 }
142 delete ptags;
143 }
144 }
145
146 //
147 // The tag associations are similar to the tag info store
148 // above.
149 //
150
151 if (pers->m_associations.empty()) {
152 if (trans->m_assocStore != nullptr) {
153 trans->m_assocStore->clear();
154 }
155 } else {
156 if (trans->m_assocStore != nullptr) {
157 delete trans->m_assocStore;
158 }
159 trans->m_assocStore = new vector<const JetAssociationBase*> ();
160 vector<const JetAssociationBase *> *pass =
161 m_tagAssCnv.createTransientConst(&(pers->m_associations), msg);
162
163 if (pass != nullptr) {
164 vector<const JetAssociationBase *> &ass (*pass);
165 vector<const JetAssociationBase *> &store (*trans->m_assocStore);
166 for (unsigned int i = 0; i < ass.size(); i++) {
167 unsigned int index = ass[i]->m_keyIndex;
168 if (index >= store.size()) {
169 store.resize(index+1, nullptr);
170 }
171 store[index] = ass[i];
172 ass[i] = nullptr; // Make sure nothing bad happens.
173 }
174 delete pass;
175 }
176 }
177
178 // Force PseudoJet pointer to null
179 trans->setFastjetPtr(nullptr);
180
181 if(msg.level() == MSG::DEBUG ) msg << MSG::DEBUG << "Loaded Jet from persistent state [OK]. Final e=" << trans->e()
182 << endmsg;
183}
184
185
186
187
188// ------------------------------------------------------------------------------------------------
189// ------------------------------------------------------------------------------------------------
190
191void JetCnv_p6::transToPers( const Jet* trans,
192 Jet_p6* pers,
193 MsgStream& msg ) const
194{
195 if(msg.level() == MSG::DEBUG ) msg << MSG::DEBUG << "JetCnv_p6 writing Jet to persistent state... " << trans->jetAuthor() <<" id="<<trans->id() << endmsg;
196
197 if( ! s_write0constit) {
198 navCnv.transToPers( &trans->navigableBase(), &pers->m_nav, msg );
199 }
200
201 // we store the momentum now as floats, plus use signal state compressors
202 // momCnv.transToPers( &trans->momentumBase(), &pers->m_momentum, msg );
203 //pbsCnv.transToPers( &trans->particleBase(), &pers->m_partBase, msg);
204
205
206 pers->m_author = trans->m_jetAuthor;
207 pers->m_RoIword = trans->m_RoIword;
208 pers->m_constituentsN = trans->m_constituentsN;
209 pers->m_jetId = trans->m_jetId ;
210
211 //std::cout << " JetCnv_p6 id="<< pers->m_jetId << " trans id="<< trans->m_jetId << std::endl;
212
213 //momentMapCnv.transToPers( &trans->m_momentMapLink, &pers->m_moments ,msg);
214
215 pers->m_dataType = trans->dataType();
216 vxCnv.transToPers( &trans->originLink(), &pers->m_origin, msg );
217
219
220 pers->m_momentum[ 0 ] = trans->getCalPx( );
221 pers->m_momentum[ 1 ] = trans->getCalPy( );
222 pers->m_momentum[ 2 ] = trans->getCalPz( );
223 pers->m_momentum[ 3 ] = trans->getCalE( );
224
225 pers->m_momentum[ 4 ] = trans->getRawPx( );
226 pers->m_momentum[ 5 ] = trans->getRawPy( );
227 pers->m_momentum[ 6 ] = trans->getRawPz( );
228 pers->m_momentum[ 7 ] = trans->getRawE( );
229
230 pers->m_momentum[ 8 ] = trans->getCScalePx( );
231 pers->m_momentum[ 9 ] = trans->getCScalePy( );
232 pers->m_momentum[ 10 ] = trans->getCScalePz( );
233 pers->m_momentum[ 11 ] = trans->getCScaleE( );
234
235
240
241 if (trans->m_tagInfoStore != nullptr) {
242 vector<const JetTagInfoBase*> goodTagInfo;
243 const vector<const JetTagInfoBase*> &tagInfo(*(trans->m_tagInfoStore));
244 for (unsigned int i = 0; i < tagInfo.size(); i++) {
245 if (tagInfo[i] != nullptr) {
246 goodTagInfo.push_back(tagInfo[i]);
247 }
248 }
249 m_taginfoCnv.transToPers(&goodTagInfo, &(pers->m_tagJetInfo), msg);
250 }
251
255
256 if (trans->m_assocStore != nullptr) {
257 vector<const JetAssociationBase*> goodAssInfo;
258 const vector<const JetAssociationBase*> &assInfo(*trans->m_assocStore);
259
260 for (unsigned int i = 0; i < assInfo.size(); i++) {
261 if( (assInfo[i] != nullptr) &&
262 ( ! bool( dynamic_cast<const JetINav4MomAssociation* >(assInfo[i])) ) ){// don't save JetINav4MomAssociation : we don't have persistant class. THIS IS AN AWFULL HACK
263 goodAssInfo.push_back(assInfo[i]);
264 }
265 }
266
267 m_tagAssCnv.transToPers(&goodAssInfo, &pers->m_associations, msg);
268 }
269
270 if(msg.level() == MSG::DEBUG ){
271 msg << MSG::DEBUG << "Created persistent state of Jet [OK]" << endmsg;
272 }
273 }
#define endmsg
NavigableCnv_p1< Navigable< INavigable4MomentumCollection, double > > NavigableCnv_t
This file contains the class definition for the DataLinkCnv_p2 class and DataLinkVectorCnv_p2 class.
This file contains the class definition for the ElementLinkCnv_p3 class.
static const NavigableCnv_t navCnv
Definition JetCnv_p1.cxx:31
double JetCnvE(float px, float py, float pz, float m)
Definition JetCnv_p6.cxx:55
This file contains the class definition for the NavigableCnv_p2 class.
static const VxLinkCnv_t vxCnv
ElementLinkCnv_p1< ElementLink< VxContainer > > VxLinkCnv_t
void persToTrans(const PersLink_t &pers, Link_t &trans, MsgStream &log) const
void transToPers(const Link_t &trans, PersLink_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
short m_jetId
Definition Jet_p6.h:109
unsigned int m_RoIword
Definition Jet_p6.h:99
float m_momentum[12]
the 4-mom part
Definition Jet_p6.h:83
Navigable_p2< uint32_t, float > m_nav
the navigable part
Definition Jet_p6.h:70
int m_constituentSigState
we store the recoStatus for jets here
Definition Jet_p6.h:98
std::vector< TPObjRef > m_associations
JetAssociationBase objects.
Definition Jet_p6.h:116
ElementLinkInt_p3 m_origin
link to the particle's origin (vertex)
Definition Jet_p6.h:92
unsigned int m_author
storing what jet algorithm the jet belongs to
Definition Jet_p6.h:104
std::vector< TPObjRef > m_tagJetInfo
JetTagInfoBase objects.
Definition Jet_p6.h:113
unsigned int m_constituentsN
Definition Jet_p6.h:101
int m_dataType
Definition Jet_p6.h:90
double getRawPz() const
Definition Jet.cxx:931
size_t id() const
Index category for jet shapes.
Definition Jet.cxx:1194
double getCScalePy() const
Definition Jet.cxx:935
double getCalPy() const
Definition Jet.cxx:940
size_t m_jetId
the identifier of this jet within its collection.
double getCScalePz() const
Definition Jet.cxx:936
void setCalE(double e)
Sets calibrated .
Definition Jet.cxx:919
double getRawPy() const
Definition Jet.cxx:930
void addInfo(const TAGINFO *tag)
Add tag info object.
double getRawPx() const
Definition Jet.cxx:929
void setFastjetPtr(const fastjet::PseudoJet *fj)
double getCalE() const
Definition Jet.cxx:938
tagstore_t * m_tagInfoStore
Tag info store.
std::string jetAuthor() const
Author and calibration history are encoded in a simple way inside the jet object.
Definition Jet.cxx:1108
double getCScalePx() const
Definition Jet.cxx:934
size_t m_jetAuthor
Jet author store.
double getCalPx() const
Definition Jet.cxx:939
void setCalPy(double py)
Sets calibrated .
Definition Jet.cxx:923
assostore_t * m_assocStore
key descriptor for all jet stores
double getCScaleE() const
Definition Jet.cxx:933
void setCalPz(double pz)
Sets calibrated .
Definition Jet.cxx:925
void setCScaleE(double e)
Sets uncalibrated .
Definition Jet.cxx:910
void setCScalePy(double py)
Sets uncalibrated .
Definition Jet.cxx:914
void setRawPx(double px)
Sets uncalibrated .
Definition Jet.cxx:903
void setCScalePx(double px)
Sets uncalibrated .
Definition Jet.cxx:912
double getRawE() const
Definition Jet.cxx:928
void setRawE(double e)
Sets uncalibrated .
Definition Jet.cxx:901
void setRawPy(double py)
Sets uncalibrated .
Definition Jet.cxx:905
void setCalPx(double px)
Sets calibrated .
Definition Jet.cxx:921
void setCScalePz(double pz)
Sets uncalibrated .
Definition Jet.cxx:916
double getCalPz() const
Definition Jet.cxx:941
void setRawPz(double pz)
Sets uncalibrated .
Definition Jet.cxx:907
signalstate_t m_constituentSigState
Constituent Signal State.
void transToPers(const Navigable_t &trans, PersNavigable_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
void persToTrans(const PersNavigable_t &pers, Navigable_t &trans, MsgStream &log) const
virtual bool setSignalState(state_t s)
set the current signal state
virtual ParticleDataType::DataType dataType() const
Return enum indicating real data, fast, or full simulation Return Type has a DataType enum with the f...
virtual double e() const
energy
virtual void set_origin(const VxContainer *theContainer, int index)
const navigable_type & navigableBase() const
access to underlying base type (INavigable-like)
virtual const ElementLink< VxContainer > & originLink() const
Return an ElementLink corresponding to particle's Origin.
virtual void set_dataType(ParticleDataType::DataType x)
std::vector< std::string > tags
Definition hcg.cxx:105
str index
Definition DeMoScan.py:362
TestStore store
Definition TestStore.cxx:23
MsgStream & msg
Definition testRead.cxx:32