ATLAS Offline Software
Loading...
Searching...
No Matches
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
12void TrackParticleCnv_p3::persToTrans(const Rec::TrackParticle_p3 * persObj, Rec::TrackParticle * transObj, MsgStream &log)
13{
15 m_elementLinkTrackCollectionConverter.persToTrans(&persObj->m_originalTrack,&trackLink,log);
16
18 static_cast<Trk::TrackParticleOrigin> (persObj->bitsAndPieces[0]);
19
20 ElementLink<VxContainer> vxCandidate;
21 m_elementLinkVxContainerConverter.persToTrans(&persObj->m_elVxCandidate,&vxCandidate,log);
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++) {
34 parameters[index] = createTransFromPStore(&m_parameterCnv,(persObj->m_trackParameters)[index],log);
35 }
36
37 auto fq = std::make_unique<Trk::FitQuality>
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 }
52 Trk::TrackInfo info(fitter,
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
85void 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
92 m_elementLinkTrackCollectionConverter.transToPers(transObj->trackElementLink(),&persObj->m_originalTrack,log);
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++) {
104 (persObj->m_trackParameters)[index] = toPersistent(&m_parameterCnv,(transObj->trackParameters())[index],log);
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}
void setAthenaBarCode(AthenaBarCode_t id)
CNV::Trans_t * createTransFromPStore(CNV **cnv, const TPObjRef &ref, MsgStream &log) const
virtual TopLevelTPCnvBase * topConverter()
TPObjRef toPersistent(CNV **cnv, const typename CNV::TransBase_t *transObj, MsgStream &log) const
Base interface class for all TP converters - typeless.
P4PxPyPzE is a class with 4-momentum behavior, for which Px, Py, Pz and M are data members.
Definition P4PxPyPzE.h:29
virtual void setE(double theE)
set energy data member
Definition P4PxPyPzE.h:144
virtual void setPz(double thePz)
set Pz data member
Definition P4PxPyPzE.h:141
virtual void setPx(double thePx)
set Px data member
Definition P4PxPyPzE.h:135
virtual void setPy(double thePy)
set Py data member
Definition P4PxPyPzE.h:138
std::vector< TPObjRef > m_trackParameters
ElementLinkInt_p3 m_originalTrack
unsigned int bitsAndPieces[6]
bitsAndPieces contains the following: unsigned int m_trackParticleOrigin; Data properties related to ...
ElementLinkInt_p3 m_elVxCandidate
AthenaBarCode_p1 m_abc
AthenaBarCode_t getAthenaBarCode() const
void setAthenaBarCode(AthenaBarCode_t)
ITPConverter * converterForType(const std::type_info &info) const
Find and return a TP converter for a given C++ type info.
New convertor which handles all track parameters in one go - i.e.
TrackSummaryCnv_p2 * m_trackSummaryCnv
ElementLinkCnv_p3< ElementLink< VxContainer > > m_elementLinkVxContainerConverter
ElementLinkCnv_p3< ElementLink< TrackCollection > > m_elementLinkTrackCollectionConverter
virtual void persToTrans(const Rec ::TrackParticle_p3 *persObj, Rec ::TrackParticle *transObj, MsgStream &log)
TrackParametersCnv_p2 * m_parameterCnv
AthenaBarCodeCnv_p1 m_AthenaBarCodeCnv
virtual void transToPers(const Rec ::TrackParticle *transObj, Rec ::TrackParticle_p3 *persObj, MsgStream &log)
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition FitQuality.h:60
double chiSquared() const
returns the of the overall track fit
Definition FitQuality.h:56
Contains information about the 'fitter' of this track.
TrackFitter
enums to identify who created this track and what propertis does it have.
const ElementLink< TrackCollection > * trackElementLink() const
Return the ElementLink to the Track.
const FitQuality * fitQuality() const
accessor function for FitQuality.
const TrackSummary * trackSummary() const
accessor function for TrackSummary.
const std::vector< const TrackParameters * > & trackParameters() const
Returns the track parameters.
const ElementLink< VxContainer > & reconstructedVertexLink() const
TrackParticleOrigin particleOriginType() const
Get the particle origin type.
const TrackInfo & info() const
returns the info of the track.
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr double mass[PARTICLEHYPOTHESES]
the array of masses
VertexType TrackParticleOrigin
@ pz
global momentum (cartesian)
Definition ParamDefs.h:61
@ px
Definition ParamDefs.h:59
@ py
Definition ParamDefs.h:60
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters
Definition index.py:1