ATLAS Offline Software
JetCnv_p3.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 // JetCnv_p3.cxx
8 // Implementation file for class JetCnv_p3
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
28 
30 
31 // pre-allocate converters
32 static const P4ImplPxPyPzECnv_p1 momCnv;
33 static const NavigableCnv_t navCnv;
34 
35 
36 void JetCnv_p3::persToTrans( const Jet_p3* pers,
37  Jet* trans,
38  MsgStream& msg ) const
39 {
40  msg << MSG::DEBUG << "Loading Jet from persistent state... e = "<< pers->m_momentum.m_ene
41  << endmsg;
42 
43  navCnv.persToTrans( &pers->m_nav,
44  &trans->navigableBase(), msg );
45  momCnv.persToTrans( &pers->m_momentum, &trans->momentumBase(), msg );
46 
47  msg << MSG::DEBUG << " after momCnv e=" << trans->e() <<endmsg;
48 
49  trans->m_jetAuthor = pers->m_author;
50 
51  // trans->m_combinedLikelihood = std::vector<double>( pers->m_combinedLikelihood );
52  // trans->setCombinedLikelihood(pers->m_combinedLikelihood);
53 
54 
55 
57  std::vector<std::string> momentNames = keydesc->getKeys(JetKeyConstants::ShapeCat);
58  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;
59  else for(size_t i=0;i<momentNames.size();i++){
60  trans->setMoment(momentNames[i], (pers)->m_shapeStore[i], true);
61  }
62 
63  if (trans->m_tagInfoStore)
64  const_cast<Jet_p3*>(pers)->m_tagJetInfo.swap (*trans->m_tagInfoStore);
65  else if ( !(pers)->m_tagJetInfo.empty() ) {
66  trans->m_tagInfoStore = new Jet::tagstore_t;
67  const_cast<Jet_p3*>(pers)->m_tagJetInfo.swap (*trans->m_tagInfoStore);
68  }
69 
70  if (trans->m_assocStore)
71  const_cast<Jet_p3*>(pers)->m_associations.swap (*trans->m_assocStore);
72  else if ( !(pers)->m_associations.empty() ) {
73  trans->m_assocStore = new Jet::assostore_t;
74  const_cast<Jet_p3*>(pers)->m_associations.swap (*trans->m_assocStore);
75  }
76 
77  // Avoid memory leaks.
78  for (size_t i = 0; i < pers->m_tagJetInfo.size(); i++)
79  delete pers->m_tagJetInfo[i];
80  for (size_t i = 0; i < pers->m_associations.size(); i++)
81  delete pers->m_associations[i];
82 
83 
84  const_cast<Jet_p3*>(pers)->m_shapeStore.clear();
85  const_cast<Jet_p3*>(pers)->m_tagJetInfo.clear();
86  const_cast<Jet_p3*>(pers)->m_associations.clear();
87 
88  // default signal state
90 
91 
92  SignalStateCnv statecnv;
93 
94  trans->setRawE( statecnv.ratio_from_char( pers->m_ratioE) * trans->e() ) ;
95  trans->setRawPx( statecnv.ratio_from_char(pers->m_ratioPx) * trans->px() ) ;
96  trans->setRawPy( statecnv.ratio_from_char(pers->m_ratioPy) * trans->py() ) ;
97  trans->setRawPz( statecnv.ratio_from_char(pers->m_ratioPz) * trans->pz() ) ;
98 
99  // Jet comes from a DataPool.
100  // So we need to be sure to re-initialize everything in the Jet.
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_p3::transToPers( const Jet* trans,
109  Jet_p3* pers,
110  MsgStream& msg ) const
111 {
112  msg << MSG::DEBUG << "Creating persistent state of Jet... e="<< trans->e() << " "<< trans->momentumBase().e()
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 p3
124  //pers->m_combinedLikelihood = std::vector<double>( trans->m_combinedLikelihood );
125 
126  if ( bool(trans->m_tagInfoStore) )
127  pers->m_tagJetInfo = *(trans->m_tagInfoStore);
128  else
129  pers->m_tagJetInfo.clear();
130  if ( bool(trans->m_assocStore) )
131  pers->m_associations = *(trans->m_assocStore);
132  else
133  pers->m_associations.clear();
134 
135 
136 
137  SignalStateCnv statecnv;
138 
139  pers->m_ratioE = statecnv.char_from_ratio(trans->getRawE () / trans->e(P4SignalState::CALIBRATED) );
140  pers->m_ratioPx = statecnv.char_from_ratio(trans->getRawPx() / trans->px(P4SignalState::CALIBRATED));
141  pers->m_ratioPy = statecnv.char_from_ratio(trans->getRawPy() / trans->py(P4SignalState::CALIBRATED));
142  pers->m_ratioPz = statecnv.char_from_ratio(trans->getRawPz() / trans->pz(P4SignalState::CALIBRATED));
143 
144 
145 
146  msg << MSG::DEBUG << "Created persistent state of Jet [OK] e="<< pers->m_momentum.m_ene
147  << endmsg;
148 }
SignalStateCnv
Definition: JetSignalStateCnv.h:50
Jet_p3::m_momentum
P4PxPyPzE_p1 m_momentum
the 4-mom part
Definition: Jet_p3.h:71
P4PxPyPzE_p1::m_ene
float m_ene
Definition: P4PxPyPzE_p1.h:42
ParticleSigStateImpl::py
virtual double py() const
y component of momentum
Definition: ParticleSigStateImpl.h:679
Jet_p3::m_shapeStore
std::vector< float > m_shapeStore
JetMomentStore.
Definition: Jet_p3.h:79
ParticleSigStateImpl::e
virtual double e() const
energy
Definition: ParticleSigStateImpl.h:751
Jet_p3::m_ratioPx
char m_ratioPx
ratio for uncalibrated E
Definition: Jet_p3.h:97
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
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
Jet_p3::m_associations
std::vector< const JetAssociationBase * > m_associations
JetAssociationBase objects.
Definition: Jet_p3.h:85
JetKeyConstants::ShapeCat
static const key_t ShapeCat
Index category for jet shapes.
Definition: JetKeyDescriptor.h:88
JetCnv_p3.h
Jet_p3
Definition: Jet_p3.h:33
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::getRawPz
double getRawPz() const
Definition: Jet.cxx:931
Jet::assostore_t
std::vector< const assoc_t * > assostore_t
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:126
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
JetCnv_p3::transToPers
virtual void transToPers(const Jet *transObj, Jet_p3 *persObj, MsgStream &msg) const override
Method creating the persistent representation Jet_p3 from its transient representation Jet.
Definition: JetCnv_p3.cxx:108
Jet::setRawPy
void setRawPy(double py)
Sets uncalibrated .
Definition: Jet.cxx:905
Jet::setRawE
void setRawE(double e)
Sets uncalibrated
Definition: Jet.cxx:901
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Jet::getRawPy
double getRawPy() const
Definition: Jet.cxx:930
Jet::m_tagInfoStore
tagstore_t * m_tagInfoStore
Tag info store.
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:741
Jet_p3::m_ratioPz
char m_ratioPz
ratio for uncalibrated p_y
Definition: Jet_p3.h:99
Jet::setRawPz
void setRawPz(double pz)
Sets uncalibrated .
Definition: Jet.cxx:907
ParticleSigStateImpl::navigableBase
const navigable_type & navigableBase() const
access to underlying base type (INavigable-like)
Definition: ParticleSigStateImpl.h:439
Jet_p3::m_ratioE
char m_ratioE
Definition: Jet_p3.h:96
P4ImplPxPyPzE::e
double e() const
get energy data member
Definition: P4ImplPxPyPzE.h:214
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
JetSignalStateCnv.h
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
Jet::getRawPx
double getRawPx() const
Definition: Jet.cxx:929
Jet_p3::m_ownPointers
bool m_ownPointers
True if we own the objects pointed to from the above collections.
Definition: Jet_p3.h:92
ParticleSigStateImpl::setSignalState
virtual bool setSignalState(state_t s)
set the current signal state
Definition: ParticleSigStateImpl.h:1157
JetCnv_p3::persToTrans
virtual void persToTrans(const Jet_p3 *persObj, Jet *transObj, MsgStream &msg) const override
Method creating the transient representation of Jet from its persistent representation Jet_p3.
Definition: JetCnv_p3.cxx:36
SignalStateCnv::char_from_ratio
char char_from_ratio(double r) const
Definition: JetSignalStateCnv.h:73
DEBUG
#define DEBUG
Definition: page_access.h:11
Jet_p3::m_tagJetInfo
std::vector< const JetTagInfoBase * > m_tagJetInfo
JetTagInfoBase objects.
Definition: Jet_p3.h:82
SignalStateCnv::ratio_from_char
double ratio_from_char(char c) const
Definition: JetSignalStateCnv.h:85
Jet::setMoment
void setMoment(const mkey_t &shapeName, shape_t shape, bool addIfMissing=true) const
Alias for setShape.
Jet_p3::m_ratioPy
char m_ratioPy
ratio for uncalibrated p_x
Definition: Jet_p3.h:98
P4SignalState::CALIBRATED
@ CALIBRATED
Definition: ISignalState.h:31
Jet::getRawE
double getRawE() const
Definition: Jet.cxx:928
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:903
Jet_p3::m_nav
Navigable_p1< uint32_t, double > m_nav
the navigable part
Definition: Jet_p3.h:68
P4ImplPxPyPzECnv_p1::transToPers
virtual void transToPers(const P4ImplPxPyPzE *transObj, P4ImplPxPyPzE_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation P4ImplPxPyPzE_p1 from its transient representation P4Px...
Definition: P4ImplPxPyPzECnv_p1.cxx:38
NavigableCnv_p1
Definition: NavigableCnv_p1.h:29
Jet_p3::m_author
unsigned int m_author
Definition: Jet_p3.h:73