ATLAS Offline Software
Loading...
Searching...
No Matches
JetCnv_p3.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// 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
34
35
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() ) {
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
108void 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}
#define endmsg
NavigableCnv_p1< Navigable< INavigable4MomentumCollection, double > > NavigableCnv_t
static const NavigableCnv_t navCnv
Definition JetCnv_p1.cxx:31
static const P4ImplPxPyPzECnv_p1 momCnv
Definition JetCnv_p1.cxx:30
This file contains the class definition for the NavigableCnv_p1 class.
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
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.
Theses classes implement a mapping between string and index used by jets.
const std::vector< key_t > & getKeys(const category_t &cat) const
static JetKeyDescriptorInstance * instance()
char m_ratioPy
ratio for uncalibrated p_x
Definition Jet_p3.h:98
bool m_ownPointers
True if we own the objects pointed to from the above collections.
Definition Jet_p3.h:92
char m_ratioPx
ratio for uncalibrated E
Definition Jet_p3.h:97
char m_ratioE
Definition Jet_p3.h:96
P4PxPyPzE_p1 m_momentum
the 4-mom part
Definition Jet_p3.h:71
std::vector< const JetTagInfoBase * > m_tagJetInfo
JetTagInfoBase objects.
Definition Jet_p3.h:82
Navigable_p1< uint32_t, double > m_nav
the navigable part
Definition Jet_p3.h:68
std::vector< const JetAssociationBase * > m_associations
JetAssociationBase objects.
Definition Jet_p3.h:85
unsigned int m_author
Definition Jet_p3.h:73
char m_ratioPz
ratio for uncalibrated p_y
Definition Jet_p3.h:99
double getRawPz() const
Definition Jet.cxx:931
double getRawPy() const
Definition Jet.cxx:930
double getRawPx() const
Definition Jet.cxx:929
std::vector< const assoc_t * > assostore_t
tagstore_t * m_tagInfoStore
Tag info store.
std::vector< const taginfo_t * > tagstore_t
size_t m_jetAuthor
Jet author store.
assostore_t * m_assocStore
key descriptor for all jet stores
void setMoment(const mkey_t &shapeName, shape_t shape, bool addIfMissing=true) const
Alias for setShape.
void setRawPx(double px)
Sets uncalibrated .
Definition Jet.cxx:903
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 setRawPz(double pz)
Sets uncalibrated .
Definition Jet.cxx:907
double e() const
get energy data member
virtual bool setSignalState(state_t s)
set the current signal state
const particle_type & particleBase() const
access to underlying base type (IParticle-like)
virtual double pz() const
z component of momentum
virtual double e() const
energy
virtual double py() const
y component of momentum
const navigable_type & navigableBase() const
access to underlying base type (INavigable-like)
const momentum_type & momentumBase(state_t s) const
access to underlying base type (I4Momentum-like)
virtual double px() const
We re-define here extra class routines that will allow direct access to signal state kinematics witho...
double ratio_from_char(char c) const
char char_from_ratio(double r) const
static const key_t ShapeCat
Index category for jet shapes.
MsgStream & msg
Definition testRead.cxx:32