ATLAS Offline Software
TrackParticleCnv_p3.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include <cmath>
10 #include <typeinfo>
11 
13 {
15  m_elementLinkTrackCollectionConverter.persToTrans(&persObj->m_originalTrack,&trackLink,log);
16 
18  static_cast<Trk::TrackParticleOrigin> (persObj->bitsAndPieces[0]);
19 
20  ElementLink<VxContainer> vxCandidate;
22 
23  auto trkSummary = std::unique_ptr<Trk::TrackSummary>
25 
26  //--- Parameters
27  std::vector<const Trk::TrackParameters*> parameters;
29  if (!m_parameterCnv) m_parameterCnv = dynamic_cast<TrackParametersCnv_p2*>(dummy); // FIXME - only in init?
30 
31  unsigned int index=0, indexMax=persObj->m_trackParameters.size();
32  parameters.resize(indexMax);
33  for (;index<indexMax;index++) {
35  }
36 
37  auto fq = std::make_unique<Trk::FitQuality>
38  (persObj->m_fitQuality_m_chiSquared,
39  persObj->m_fitQuality_m_numberDoF);
40 
41  //----- Track Info
43  Trk::ParticleHypothesis hypothesis = static_cast<Trk::ParticleHypothesis> (persObj->bitsAndPieces[2]);
44  std::bitset<Trk::TrackInfo::NumberOfTrackProperties> properties(persObj->bitsAndPieces[3]);
45 
46  std::bitset<Trk::TrackInfo::NumberOfTrackRecoInfo> patternRecognition(persObj->bitsAndPieces[4]);
47  // TODO - is there a better way to do the below, avoiding loop?
48  for (unsigned int i = 32;i<Trk::TrackInfo::NumberOfTrackRecoInfo;++i) {
49  unsigned int mask = (1<<(i-32));
50  patternRecognition[i] = (persObj->bitsAndPieces[5] & mask );
51  }
53  hypothesis,
54  properties,
55  patternRecognition);
56 
57  //----- Kinematics
58  P4PxPyPzE fmom;
59  const std::vector<const Trk::TrackParameters*>& parms =
60  transObj->trackParameters();
61  if (!parms.empty() && parms.back()) {
62  const Amg::Vector3D& mom = parameters.back()->momentum();
64  fmom.setPx (mom[Trk::px]);
65  fmom.setPy (mom[Trk::py]);
66  fmom.setPz (mom[Trk::pz]);
67  fmom.setE (std::sqrt ((long double)mom.mag2() + (long double)mpi*mpi));
68  }
69 
70  *transObj = Rec::TrackParticle (trackLink,
71  origin,
72  vxCandidate,
73  std::move(trkSummary),
74  std::move(parameters),
75  std::move(fq),
76  info,
77  fmom);
78 
79  //----- Barcode
81  m_AthenaBarCodeCnv.persToTrans(&persObj->m_abc, &abc, log);
82  transObj->setAthenaBarCode (abc.getAthenaBarCode());
83 }
84 
85 void TrackParticleCnv_p3::transToPers(const Rec::TrackParticle * transObj, Rec::TrackParticle_p3 * persObj, MsgStream &log){
86  // std::cout<<"TrackParticleCnv_p3::transToPers"<<std::endl;
87 
89  abc.setAthenaBarCode (transObj->getAthenaBarCode());
90  m_AthenaBarCodeCnv.transToPers(&abc, &persObj->m_abc, log);
91 
94 
95  //---- Parameters
97  if (!m_parameterCnv) m_parameterCnv = dynamic_cast<TrackParametersCnv_p2*>(dummy); // FIXME - only in init?
98 
99  if (!m_parameterCnv) std::cout<<"TrackParticleCnv_p3::transToPers WARNING! No m_parameterCnv"<<std::endl;
100 
101  unsigned int index=0, indexMax=transObj->trackParameters().size();
102  persObj->m_trackParameters.resize(indexMax);
103  for (;index<indexMax;index++) {
105  }
106 
107  persObj->m_trackSummary = toPersistent( &m_trackSummaryCnv, transObj->trackSummary(), log );
108 
109  if (transObj->fitQuality()){
110  persObj->m_fitQuality_m_chiSquared=transObj->fitQuality()->chiSquared();
111  persObj->m_fitQuality_m_numberDoF =transObj->fitQuality()->numberDoF();
112  }
113 
114  const Trk::TrackInfo& info = transObj->info();
115 
116  persObj->bitsAndPieces[0] = static_cast<unsigned int>(transObj->particleOriginType());
117  persObj->bitsAndPieces[1] = static_cast<unsigned int>(info.trackFitter());
118  persObj->bitsAndPieces[2] = static_cast<unsigned int>(info.particleHypothesis());
119  persObj->bitsAndPieces[3] = info.properties().to_ulong();
120  if (info.patternRecognition().size()<32) {
121  persObj->bitsAndPieces[4] = info.patternRecognition().to_ulong();
122  } else {
123  // more than 32 bits so have to do it the hard way.
124  unsigned int i = 0;
125  unsigned int size=info.patternRecognition().size();
126  persObj->bitsAndPieces[4]=0;
127  persObj->bitsAndPieces[5]=0;
128  for (;i<32;++i) persObj->bitsAndPieces[4] |= ((info.patternRecognition()[i]) << i);
129  for (i=32;i<size;++i) persObj->bitsAndPieces[5] |= ((info.patternRecognition()[i]) << (i-32));
130  }
131 }
grepfile.info
info
Definition: grepfile.py:38
Trk::TrackInfo::NumberOfTrackRecoInfo
@ NumberOfTrackRecoInfo
Maximum number of enums.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:268
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
Trk::TrackParticleBase::particleOriginType
TrackParticleOrigin particleOriginType() const
Get the particle origin type.
Definition: TrackParticleBase.h:235
Trk::py
@ py
Definition: ParamDefs.h:60
TopLevelTPCnvBase::converterForType
ITPConverter * converterForType(const std::type_info &info) const
Find and return a TP converter for a given C++ type info.
Definition: TopLevelTPCnvBase.h:80
Trk::TrackInfo
Contains information about the 'fitter' of this track.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:32
Trk::TrackParticleBase::reconstructedVertexLink
const ElementLink< VxContainer > & reconstructedVertexLink() const
Definition: TrackParticleBase.h:225
ElementLinkCnv_p3::persToTrans
void persToTrans(const PersLink_t &pers, Link_t &trans, MsgStream &log) const
TrackParameters.h
TrackParticle.h
Rec::TrackParticle_p3::m_fitQuality_m_chiSquared
float m_fitQuality_m_chiSquared
Definition: TrackParticle_p3.h:25
python.TestDriveDummies.properties
dictionary properties
Definition: TestDriveDummies.py:14
Rec::TrackParticle::setAthenaBarCode
void setAthenaBarCode(AthenaBarCode_t)
Definition: TrackParticle.cxx:221
AthenaBarCodeImpl
Definition: AthenaBarCodeImpl.h:37
index
Definition: index.py:1
TrackParametersCnv_p2
New convertor which handles all track parameters in one go - i.e.
Definition: TrackParametersCnv_p2.h:30
Trk::VertexType
VertexType
Definition: VertexType.h:25
Rec::TrackParticle_p3::m_abc
AthenaBarCode_p1 m_abc
Definition: TrackParticle_p3.h:42
Trk::TrackParticleBase::trackSummary
const TrackSummary * trackSummary() const
accessor function for TrackSummary.
Definition: TrackParticleBase.h:247
Rec::TrackParticle_p3::bitsAndPieces
unsigned int bitsAndPieces[6]
bitsAndPieces contains the following: unsigned int m_trackParticleOrigin; Data properties related to ...
Definition: TrackParticle_p3.h:38
TrackParticleCnv_p3::m_trackSummaryCnv
TrackSummaryCnv_p2 * m_trackSummaryCnv
Definition: TrackParticleCnv_p3.h:47
Rec::TrackParticle_p3::m_trackSummary
TPObjRef m_trackSummary
Definition: TrackParticle_p3.h:24
Rec::TrackParticle::getAthenaBarCode
AthenaBarCode_t getAthenaBarCode() const
Definition: TrackParticle.cxx:217
AthenaBarCodeImpl::setAthenaBarCode
void setAthenaBarCode(AthenaBarCode_t id)
Definition: AthenaBarCodeImpl.cxx:211
Trk::pz
@ pz
global momentum (cartesian)
Definition: ParamDefs.h:61
TrackParticleCnv_p3.h
ITPConverterFor::topConverter
virtual TopLevelTPCnvBase * topConverter()
return the top-level converter for this elemental TP converter
Definition: TPConverter.h:191
AthenaBarCodeCnv_p1::transToPers
virtual void transToPers(const AthenaBarCodeImpl *transObj, AthenaBarCode_p1 *persObj, MsgStream &) const override
Definition: AthenaBarCodeCnv_p1.h:36
Rec::TrackParticle_p3::m_fitQuality_m_numberDoF
float m_fitQuality_m_numberDoF
Definition: TrackParticle_p3.h:26
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
Rec::TrackParticle_p3::m_trackParameters
std::vector< TPObjRef > m_trackParameters
Definition: TrackParticle_p3.h:22
AthenaBarCodeCnv_p1::persToTrans
virtual void persToTrans(const AthenaBarCode_p1 *persObj, AthenaBarCodeImpl *transObj, MsgStream &) const override
Definition: AthenaBarCodeCnv_p1.h:43
TrackParticleCnv_p3::m_elementLinkTrackCollectionConverter
ElementLinkCnv_p3< ElementLink< TrackCollection > > m_elementLinkTrackCollectionConverter
Definition: TrackParticleCnv_p3.h:48
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
P4PxPyPzE::setE
virtual void setE(double theE)
set energy data member
Definition: P4PxPyPzE.h:144
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GeoPrimitives.h
ElementLinkCnv_p3::transToPers
void transToPers(const Link_t &trans, PersLink_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::TrackInfo::TrackFitter
TrackFitter
enums to identify who created this track and what propertis does it have.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:39
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrackParticleCnv_p3::m_parameterCnv
TrackParametersCnv_p2 * m_parameterCnv
Definition: TrackParticleCnv_p3.h:51
P4PxPyPzE::setPx
virtual void setPx(double thePx)
set Px data member
Definition: P4PxPyPzE.h:135
Trk::TrackParticleBase::trackElementLink
const ElementLink< TrackCollection > * trackElementLink() const
Return the ElementLink to the Track.
Definition: TrackParticleBase.h:230
TrackParticleCnv_p3::persToTrans
virtual void persToTrans(const Rec ::TrackParticle_p3 *persObj, Rec ::TrackParticle *transObj, MsgStream &log)
Definition: TrackParticleCnv_p3.cxx:12
Trk::pion
@ pion
Definition: ParticleHypothesis.h:29
TrackParticleCnv_p3::transToPers
virtual void transToPers(const Rec ::TrackParticle *transObj, Rec ::TrackParticle_p3 *persObj, MsgStream &log)
Definition: TrackParticleCnv_p3.cxx:85
Trk::TrackParticleBase::fitQuality
const FitQuality * fitQuality() const
accessor function for FitQuality.
Definition: TrackParticleBase.h:259
Trk::px
@ px
Definition: ParamDefs.h:59
python.xAODType.dummy
dummy
Definition: xAODType.py:4
Rec::TrackParticle_p3::m_elVxCandidate
ElementLinkInt_p3 m_elVxCandidate
Definition: TrackParticle_p3.h:21
Trk::ParametersBase
Definition: ParametersBase.h:55
ITPConverterFor::toPersistent
TPObjRef toPersistent(CNV **cnv, const typename CNV::TransBase_t *transObj, MsgStream &log) const
Persistify an object and store the persistent represenation in the storage vector of the top-level pe...
Definition: TPConverter.h:119
Trk::ParticleMasses::mass
constexpr double mass[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:53
TrackParticleCnv_p3::m_elementLinkVxContainerConverter
ElementLinkCnv_p3< ElementLink< VxContainer > > m_elementLinkVxContainerConverter
Definition: TrackParticleCnv_p3.h:49
Trk::TrackParticleBase::trackParameters
const std::vector< const TrackParameters * > & trackParameters() const
Returns the track parameters.
Definition: TrackParticleBase.h:243
Rec::TrackParticle_p3
Definition: TrackParticle_p3.h:16
AthenaBarCodeImpl::getAthenaBarCode
AthenaBarCode_t getAthenaBarCode() const
Definition: AthenaBarCodeImpl.cxx:203
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Rec::TrackParticle
Definition: Reconstruction/Particle/Particle/TrackParticle.h:47
DeMoScan.index
string index
Definition: DeMoScan.py:364
P4PxPyPzE
Definition: P4PxPyPzE.h:29
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
P4PxPyPzE::setPz
virtual void setPz(double thePz)
set Pz data member
Definition: P4PxPyPzE.h:141
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
HepMC::mpi
int mpi(const GenEvent &e)
Definition: GenEvent.h:629
Trk::FitQuality::chiSquared
double chiSquared() const
returns the of the overall track fit
Definition: FitQuality.h:56
Trk::FitQuality::numberDoF
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition: FitQuality.h:60
P4PxPyPzE::setPy
virtual void setPy(double thePy)
set Py data member
Definition: P4PxPyPzE.h:138
ITPConverter
Definition: TPTools/TPTools/ITPConverter.h:32
Rec::TrackParticle_p3::m_originalTrack
ElementLinkInt_p3 m_originalTrack
Definition: TrackParticle_p3.h:20
ITPConverterFor::createTransFromPStore
CNV::Trans_t * createTransFromPStore(CNV **cnv, const TPObjRef &ref, MsgStream &log) const
Create transient representation of a persistent object, stored in the the top-level persistent object...
Definition: TPConverter.h:172
Trk::TrackParticleBase::info
const TrackInfo & info() const
returns the info of the track.
Definition: TrackParticleBase.h:276
TrackParticleCnv_p3::m_AthenaBarCodeCnv
AthenaBarCodeCnv_p1 m_AthenaBarCodeCnv
Definition: TrackParticleCnv_p3.h:52