ATLAS Offline Software
JetCnv_p2.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // JetCnv_p1.cxx
8 // Implementation file for class JetCnv_p2
9 // Author: R.Seuster<seuster@cern.ch>
11 
12 // STL includes
13 
14 // JetEvent includes
15 #include "JetEvent/Jet.h"
18 
19 // DataModelAthenaPool includes
21 
22 // EventCommonTPCnv includes
24 
25 // JetEventTPCnv includes
27 
29 
30 // pre-allocate converters
31 static const P4ImplPxPyPzECnv_p1 momCnv;
32 static const NavigableCnv_t navCnv;
33 
34 
35 void JetCnv_p2::persToTrans( const Jet_p2* pers,
36  Jet* trans,
37  MsgStream& msg ) const
38 {
39  msg << MSG::DEBUG << "Loading Jet from persistent state..."
40  << endmsg;
41 
42  navCnv.persToTrans( &pers->m_nav,
43  &trans->navigableBase(), msg );
44  momCnv.persToTrans( &pers->m_momentum, &trans->momentumBase(), msg );
45 
46  trans->m_jetAuthor = pers->m_author;
47 
48  //trans->m_combinedLikelihood = std::vector<double>( pers->m_combinedLikelihood );
51 
52  // use swap() to avoid copying vector contents.
53  //const_cast<Jet_p2*>(pers)->m_shapeStore.swap ( *trans->m_shapeStore);
54 
55  // create the store only if non-zero size (waste of space for constituents)
56 
57  // Use swap to avoid copying the vector contents.
58 
60  std::vector<std::string> momentNames = keydesc->getKeys(JetKeyConstants::ShapeCat);
61  if( momentNames.size() != (pers)->m_shapeStore.size() ) msg << MSG::ERROR << " JEtCnv_p2 can't convert moments ! expected moment n= "<< momentNames.size() << " persistatn has "<< (pers)->m_shapeStore.size() <<endmsg;
62  else for(size_t i=0;i<momentNames.size();i++){
63  trans->setMoment(momentNames[i], (pers)->m_shapeStore[i], true);
64  }
65 
66 
67  if (trans->m_tagInfoStore)
68  const_cast<Jet_p2*>(pers)->m_tagJetInfo.swap (*trans->m_tagInfoStore);
69  else if ( !(pers)->m_tagJetInfo.empty() ) {
70  trans->m_tagInfoStore = new Jet::tagstore_t;
71  const_cast<Jet_p2*>(pers)->m_tagJetInfo.swap (*trans->m_tagInfoStore);
72  }
73 
74  if (trans->m_assocStore)
75  const_cast<Jet_p2*>(pers)->m_associations.swap (*trans->m_assocStore);
76  else if ( !(pers)->m_associations.empty() ) {
77  trans->m_assocStore = new Jet::assostore_t;
78  const_cast<Jet_p2*>(pers)->m_associations.swap (*trans->m_assocStore);
79  }
80 
81  // Avoid memory leaks.
82  for (size_t i = 0; i < pers->m_tagJetInfo.size(); i++)
83  delete pers->m_tagJetInfo[i];
84  for (size_t i = 0; i < pers->m_associations.size(); i++)
85  delete pers->m_associations[i];
86 
87  const_cast<Jet_p2*>(pers)->m_shapeStore.clear();
88  const_cast<Jet_p2*>(pers)->m_tagJetInfo.clear();
89  const_cast<Jet_p2*>(pers)->m_associations.clear();
90 
91  // default signal state
93 
94  // Jet comes from a DataPool.
95  // So we need to be sure to re-initialize everything in the Jet.
96  trans->setRawE( trans->e() ) ;
97  trans->setRawPx( trans->px() ) ;
98  trans->setRawPy( trans->py() ) ;
99  trans->setRawPz( trans->pz() ) ;
100 
101  static const Jet jtmp;
102  trans->particleBase() = jtmp.particleBase();
103 
104  msg << MSG::DEBUG << "Loaded Jet from persistent state [OK]"
105  << endmsg;
106 }
107 
108 void JetCnv_p2::transToPers( const Jet* /*trans*/,
109  Jet_p2* /*pers*/,
110  MsgStream& msg ) const
111 {
112  msg << MSG::ERROR << " Don't write Jet_p2 anymore"
113  << endmsg;
114 
115  // pers->m_ownPointers = false;
116 
117  // navCnv.transToPers( &trans->navigableBase(), &pers->m_nav, msg );
118  // momCnv.transToPers( &trans->momentumBase(), &pers->m_momentum, msg );
119 
120 
121  // pers->m_author = trans->m_jetAuthor;
122 
123  // // no more needed : we don't save nomore to p2
124  // //pers->m_combinedLikelihood = std::vector<double>( trans->m_combinedLikelihood );
125 
126 
127  // if ( bool(trans->m_tagInfoStore) )
128  // pers->m_tagJetInfo = *(trans->m_tagInfoStore);
129  // else
130  // pers->m_tagJetInfo.clear();
131  // if ( bool(trans->m_assocStore) )
132  // pers->m_associations = *(trans->m_assocStore);
133  // else
134  // pers->m_associations.clear();
135 
136  // msg << MSG::DEBUG << "Created persistent state of Jet [OK]"
137  // << endmsg;
138  // return;
139 }
ParticleSigStateImpl::py
virtual double py() const
y component of momentum
Definition: ParticleSigStateImpl.h:679
Jet_p2::m_momentum
P4PxPyPzE_p1 m_momentum
the 4-mom part
Definition: Jet_p2.h:71
JetCnv_p2.h
ParticleSigStateImpl::e
virtual double e() const
energy
Definition: ParticleSigStateImpl.h:751
Jet_p2::m_author
unsigned int m_author
Definition: Jet_p2.h:73
JetCnv_p2::transToPers
virtual void transToPers(const Jet *transObj, Jet_p2 *persObj, MsgStream &msg) const override
Method creating the persistent representation Jet_p2 from its transient representation Jet.
Definition: JetCnv_p2.cxx:108
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
Jet_p2::m_associations
std::vector< const JetAssociationBase * > m_associations
JetAssociationBase objects.
Definition: Jet_p2.h:85
ParticleSigStateImpl::px
virtual double px() const
We re-define here extra class routines that will allow direct access to signal state kinematics witho...
Definition: ParticleSigStateImpl.h:671
JetKeyConstants::ShapeCat
static const key_t ShapeCat
Index category for jet shapes.
Definition: JetKeyDescriptor.h:88
JetAssociationBase.h
ParticleSigStateImpl::particleBase
const particle_type & particleBase() const
access to underlying base type (IParticle-like)
Definition: ParticleSigStateImpl.h:469
ParticleSigStateImpl::momentumBase
const momentum_type & momentumBase(state_t s) const
access to underlying base type (I4Momentum-like)
Definition: ParticleSigStateImpl.h:447
Jet::assostore_t
std::vector< const assoc_t * > assostore_t
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:126
Jet_p2::m_tagJetInfo
std::vector< const JetTagInfoBase * > m_tagJetInfo
JetTagInfoBase objects.
Definition: Jet_p2.h:82
NavigableCnv_p1::persToTrans
void persToTrans(const PersNavigable_t &pers, Navigable_t &trans, MsgStream &log) const
P4ImplPxPyPzECnv_p1.h
JetKeyDescriptorInstance::instance
static JetKeyDescriptorInstance * instance()
Definition: JetKeyDescriptor.h:123
Jet::tagstore_t
std::vector< const taginfo_t * > tagstore_t
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:130
Jet::setRawPy
void setRawPy(double py)
Sets uncalibrated .
Definition: Jet.cxx:904
Jet_p2::m_combinedLikelihood
std::vector< double > m_combinedLikelihood
combined likelihoods
Definition: Jet_p2.h:76
Jet_p2
Definition: Jet_p2.h:33
Jet::setRawE
void setRawE(double e)
Sets uncalibrated
Definition: Jet.cxx:900
Jet::setCombinedLikelihood
void setCombinedLikelihood(const std::vector< double > &combinedLikelihood)
(depreciated) Likelihood store setter
Definition: Jet.cxx:977
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
JetCnv_p2::persToTrans
virtual void persToTrans(const Jet_p2 *persObj, Jet *transObj, MsgStream &msg) const override
Method creating the transient representation of Jet from its persistent representation Jet_p2.
Definition: JetCnv_p2.cxx:35
Jet_p2::m_nav
Navigable_p1< uint32_t, double > m_nav
the navigable part
Definition: Jet_p2.h:68
Jet::m_tagInfoStore
tagstore_t * m_tagInfoStore
Tag info store.
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:741
Jet::setRawPz
void setRawPz(double pz)
Sets uncalibrated .
Definition: Jet.cxx:906
ParticleSigStateImpl::navigableBase
const navigable_type & navigableBase() const
access to underlying base type (INavigable-like)
Definition: ParticleSigStateImpl.h:439
JetKeyDescriptorInstance::getKeys
const std::vector< key_t > & getKeys(const category_t &cat) const
Definition: JetKeyDescriptor.cxx:178
Jet::m_jetAuthor
size_t m_jetAuthor
Jet author store.
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:725
P4ImplPxPyPzECnv_p1
Definition: P4ImplPxPyPzECnv_p1.h:38
Jet::m_assocStore
assostore_t * m_assocStore
key descriptor for all jet stores
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:738
ParticleSigStateImpl::setSignalState
virtual bool setSignalState(state_t s)
set the current signal state
Definition: ParticleSigStateImpl.h:1157
Jet_p2::m_shapeStore
std::vector< float > m_shapeStore
JetMomentStore.
Definition: Jet_p2.h:79
DEBUG
#define DEBUG
Definition: page_access.h:11
Jet::m_jetId
size_t m_jetId
the identifier of this jet within its collection.
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:672
Jet::setMoment
void setMoment(const mkey_t &shapeName, shape_t shape, bool addIfMissing=true) const
Alias for setShape.
Jet::s_defaultJetId
static const size_t s_defaultJetId
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:670
P4SignalState::CALIBRATED
@ CALIBRATED
Definition: ISignalState.h:31
Jet.h
P4ImplPxPyPzECnv_p1::persToTrans
virtual void persToTrans(const P4ImplPxPyPzE_p1 *persObj, P4ImplPxPyPzE *transObj, MsgStream &msg) const override
Method creating the transient representation of P4ImplPxPyPzE from its persistent representation P4Im...
Definition: P4ImplPxPyPzECnv_p1.cxx:26
NavigableCnv_p1.h
This file contains the class definition for the NavigableCnv_p1 class. NOTE: it should be included fi...
ParticleSigStateImpl::pz
virtual double pz() const
z component of momentum
Definition: ParticleSigStateImpl.h:687
JetKeyDescriptorInstance
Definition: JetKeyDescriptor.h:100
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
Jet::setRawPx
void setRawPx(double px)
Sets uncalibrated .
Definition: Jet.cxx:902
NavigableCnv_p1
Definition: NavigableCnv_p1.h:29