ATLAS Offline Software
JetCnv_p6.cxx
Go to the documentation of this file.
1 
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
20 #include "VxVertex/VxContainer.h"
21 
22 
23 // JetEvent includes
24 #include "JetEvent/Jet.h"
28 
29 // JetEventTPCnv includes
32 
34 
35 
36 #include <vector>
37 using std::vector;
38 
40 
41 // pre-allocate converters
42 static const VxLinkCnv_t vxCnv;
43 
44 
45 
47 
48 // pre-allocate converters
49 // static const P4ImplPxPyPzECnv_p1 momCnv;
50 static const NavigableCnv_t navCnv;
51 //static const DataLinkCnv_p2<DataLink<JetMomentMap> > momentMapCnv;
52 
53 
54 
55 double JetCnvE(float px,float py, float pz, float m){
56  return std::sqrt( px*px + py*py + pz*pz + m*m);
57 }
58 
59 void 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);
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 
191 void 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  }
Jet_p6::m_RoIword
unsigned int m_RoIword
Definition: Jet_p6.h:99
Jet_p6::m_momentum
float m_momentum[12]
the 4-mom part
Definition: Jet_p6.h:83
JetCnvE
double JetCnvE(float px, float py, float pz, float m)
Definition: JetCnv_p6.cxx:55
Jet::getCalPy
double getCalPy() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:940
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
Jet_p6::m_dataType
int m_dataType
Definition: Jet_p6.h:90
ElementLinkCnv_p3
Definition: ElementLinkCnv_p3.h:27
Jet::getCalPz
double getCalPz() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:941
ElementLinkCnv_p3.h
This file contains the class definition for the ElementLinkCnv_p3 class.
test_pyathena.px
px
Definition: test_pyathena.py:18
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
ParticleSigStateImpl::e
virtual double e() const
energy
Definition: ParticleSigStateImpl.h:751
Jet::setCalE
void setCalE(double e)
Sets calibrated
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:919
Jet
Basic data class defines behavior for all Jet objects The Jet class is the principal data class for...
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
JetTagInfoBase.h
index
Definition: index.py:1
JetCnv_p6.h
Jet::setCScalePz
void setCScalePz(double pz)
Sets uncalibrated .
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:916
ParticleSigStateImpl::originLink
virtual const ElementLink< VxContainer > & originLink() const
Return an ElementLink corresponding to particle's Origin.
Definition: ParticleSigStateImpl.h:883
JetAssociationBase.h
NavigableCnv_p2
Definition: NavigableCnv_p2.h:30
Jet_p6::m_author
unsigned int m_author
storing what jet algorithm the jet belongs to
Definition: Jet_p6.h:104
Jet::getCScalePy
double getCScalePy() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:935
DataLinkCnv_p2.h
This file contains the class definition for the DataLinkCnv_p2 class and DataLinkVectorCnv_p2 class.
Jet::setCScalePx
void setCScalePx(double px)
Sets uncalibrated .
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:912
Jet::getCScaleE
double getCScaleE() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:933
Jet_p6::m_constituentsN
unsigned int m_constituentsN
Definition: Jet_p6.h:101
Jet::getCalE
double getCalE() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:938
Jet::setCScaleE
void setCScaleE(double e)
Sets uncalibrated
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:910
Jet::getCalPx
double getCalPx() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:939
ParticleDataType::DataType
DataType
Definition: Event/EventKernel/EventKernel/IParticle.h:36
Jet::getRawPz
double getRawPz() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:931
Jet_p6::m_nav
Navigable_p2< uint32_t, float > m_nav
the navigable part
Definition: Jet_p6.h:70
NavigableCnv_p1::persToTrans
void persToTrans(const PersNavigable_t &pers, Navigable_t &trans, MsgStream &log) const
ParticleSigStateImpl::dataType
virtual ParticleDataType::DataType dataType() const
Return enum indicating real data, fast, or full simulation Return Type has a DataType enum with the f...
Definition: ParticleSigStateImpl.h:867
Jet::id
size_t id() const
returns this jet unique identifier in its collection
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:1194
Jet_p6::m_constituentSigState
int m_constituentSigState
we store the recoStatus for jets here
Definition: Jet_p6.h:98
Jet::setRawPy
void setRawPy(double py)
Sets uncalibrated .
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:905
JetINav4MomAssociation.h
tags
std::vector< std::string > tags
Definition: hcg.cxx:102
Jet::setCalPx
void setCalPx(double px)
Sets calibrated .
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:921
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
Jet::setRawE
void setRawE(double e)
Sets uncalibrated
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:901
lumiFormat.i
int i
Definition: lumiFormat.py:92
ElementLinkCnv_p1::transToPers
void transToPers(const Link_t &trans, PersLink_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
Jet::getRawPy
double getRawPy() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:930
ParticleSigStateImpl::set_dataType
virtual void set_dataType(ParticleDataType::DataType x)
Definition: ParticleSigStateImpl.h:1084
Jet::jetAuthor
std::string jetAuthor() const
Author and calibration history are encoded in a simple way inside the jet object.
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:1108
Jet::m_tagInfoStore
tagstore_t * m_tagInfoStore
Tag info store.
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:741
VxContainer.h
Jet::setCalPz
void setCalPz(double pz)
Sets calibrated .
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:925
Jet_p6::m_associations
std::vector< TPObjRef > m_associations
JetAssociationBase objects.
Definition: Jet_p6.h:116
Jet::setRawPz
void setRawPz(double pz)
Sets uncalibrated .
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:907
ParticleSigStateImpl::navigableBase
const navigable_type & navigableBase() const
access to underlying base type (INavigable-like)
Definition: ParticleSigStateImpl.h:439
ElementLinkCnv_p1< ElementLink< VxContainer > >
Jet::setCalPy
void setCalPy(double py)
Sets calibrated .
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:923
Amg::py
@ py
Definition: GeoPrimitives.h:39
Jet::m_jetAuthor
size_t m_jetAuthor
Jet author store.
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:725
Jet::setCScalePy
void setCScalePy(double py)
Sets uncalibrated .
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:914
Jet::setFastjetPtr
void setFastjetPtr(const fastjet::PseudoJet *fj)
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:851
ElementLinkCnv_p1::persToTrans
void persToTrans(const PersLink_t &pers, Link_t &trans, MsgStream &log) const
JetSignalStateCnv.h
Jet::m_constituentSigState
signalstate_t m_constituentSigState
Constituent Signal State.
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:744
JetINav4MomAssociation
A JetAssociation object for a generic object.
Definition: JetINav4MomAssociation.h:33
Jet_p6::m_origin
ElementLinkInt_p3 m_origin
link to the particle's origin (vertex)
Definition: Jet_p6.h:92
JetMomentMapCnv_p6.h
P4SignalState::JETFINAL
@ JETFINAL
Definition: ISignalState.h:34
NavigableCnv_p1::transToPers
void transToPers(const Navigable_t &trans, PersNavigable_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
Jet::m_assocStore
assostore_t * m_assocStore
key descriptor for all jet stores
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:738
DeMoScan.index
string index
Definition: DeMoScan.py:362
Jet::getRawPx
double getRawPx() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:929
Jet::addInfo
void addInfo(const TAGINFO *tag)
Add tag info object.
Jet::m_RoIword
unsigned int m_RoIword
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:540
Jet::getCScalePx
double getCScalePx() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:934
ParticleSigStateImpl::setSignalState
virtual bool setSignalState(state_t s)
set the current signal state
Definition: ParticleSigStateImpl.h:1157
P4SignalState::State
State
Definition: ISignalState.h:28
DEBUG
#define DEBUG
Definition: page_access.h:11
Jet_p6::m_tagJetInfo
std::vector< TPObjRef > m_tagJetInfo
JetTagInfoBase objects.
Definition: Jet_p6.h:113
Jet::m_jetId
size_t m_jetId
the identifier of this jet within its collection.
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:672
Jet::getRawE
double getRawE() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:928
Jet_p6
Definition: Jet_p6.h:34
ParticleSigStateImpl::set_origin
virtual void set_origin(const VxContainer *theContainer, int index)
Definition: ParticleSigStateImpl.h:1108
JetConverterBase< Jet_p6 >::persToTrans
virtual void persToTrans(const Jet_p6 *persObj, Jet *transObj, MsgStream &msg) const override
Method creating the transient representation of Jet from its persistent representation Jet_p6.
Definition: JetCnv_p6.cxx:59
Jet.h
Jet::getCScalePz
double getCScalePz() const
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:936
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
Jet_p6::m_jetId
short m_jetId
Definition: Jet_p6.h:109
Jet::m_constituentsN
numconstit_t m_constituentsN
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:310
Jet::setRawPx
void setRawPx(double px)
Sets uncalibrated .
Definition: Reconstruction/Jet/JetEvent/src/Jet.cxx:903
NavigableCnv_p2.h
This file contains the class definition for the NavigableCnv_p2 class. NOTE: it should be included fi...
ass
make the histogram assessment part of the config
Definition: hcg.cxx:626
JetConverterBase< Jet_p6 >::transToPers
virtual void transToPers(const Jet *transObj, Jet_p6 *persObj, MsgStream &msg) const override
Method creating the persistent representation Jet_p6 from its transient representation Jet.
Definition: JetCnv_p6.cxx:191
NavigableCnv_p1
Definition: NavigableCnv_p1.h:29