ATLAS Offline Software
PseudoMeasurementOnTrackCnv_p1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
8 #include "TrkSurfaces/Surface.h"
12 
13 
14 void PseudoMeasurementOnTrackCnv_p1::persToTrans( const Trk :: PseudoMeasurementOnTrack_p1 *persObj,
15  Trk :: PseudoMeasurementOnTrack *transObj, MsgStream &log )
16 {
17  Trk::LocalParameters localParams;
18  fillTransFromPStore( &m_localParamsCnv, persObj->m_localParams, &localParams, log );
19  // fillTransFromPStore( &m_localErrMatCnv, persObj->m_localErrMat, &transObj->m_localErrMat, log );
20 
22  Amg::MatrixX localCovariance;
23  fillTransFromPStore( &m_localErrMatCnv, persObj->m_localErrMat, &dummy, log );
24  EigenHelpers::vectorToEigenMatrix(dummy.values, localCovariance, "PseudoMeasurementOnTrackCnv_p1");
25 
26  ITPConverterFor<Trk::Surface>* surfaceCnv=nullptr;
28  (this->createTransFromPStore( &surfaceCnv, persObj->m_associatedSurface, log ));
29 
30  DetElementSurfaceCnv_p1* detElCnv = dynamic_cast<DetElementSurfaceCnv_p1*>(surfaceCnv);
31  if (detElCnv) {
32  // have a DetElementSurface
33  surf = Trk::ConstSurfaceUniquePtr (detElCnv->createSurface(log));
34  }
35 
36  *transObj = Trk::PseudoMeasurementOnTrack (std::move(localParams),
37  std::move(localCovariance),
38  std::move(surf));
39 }
40 
42  Trk :: PseudoMeasurementOnTrack_p1 * persObj, MsgStream & log)
43 {
44  persObj->m_localParams = toPersistent( &m_localParamsCnv, &transObj->localParameters(), log );
45 
46  Trk::ErrorMatrix pMat;
47  EigenHelpers::eigenMatrixToVector(pMat.values, transObj->localCovariance(), "PseudoMeasurementOnTrackCnv_p1");
48  persObj->m_localErrMat = toPersistent( &m_localErrMatCnv, &pMat, log );
49 
50  ITPConverterFor<Trk::Surface>* surfaceCnv=nullptr;
51  if (transObj->hasSurface())
52  {
53  // FIXME - this is to handle curvilinear parameters, by forcing them to build a surface. In fact they need a different
54  //persistent type and should store their GP and not surface.
55  if (transObj->associatedSurface().isFree() ) { // if this is a free surface, write it out 'as is'
56  persObj->m_associatedSurface = toPersistent(&surfaceCnv, transObj->associatedSurface().baseSurface(), log);
57  } else {
58  // else, make it into a DetElementSurface, to allow the correct convertor to be called
59  Trk::DetElementSurface dummySurf( transObj->associatedSurface());
60  persObj->m_associatedSurface = this->toPersistent(&surfaceCnv, &dummySurf, log );
61  // Need to do this->toPersistent() to get around 'error: there are no arguments of 'toPersistent' that depend on a template parameter'
62  }
63  }
64  else {
65  log<<MSG::WARNING<<"TrackParameter doesn't have a surface! Dumping: "<<*transObj<<endmsg;
66  }
67 }
Trk::LocalParameters
Definition: LocalParameters.h:98
ITPConverterFor< Trk::Surface >
PseudoMeasurementOnTrackCnv_p1::m_localParamsCnv
LocalParametersCnv_p1 * m_localParamsCnv
Definition: PseudoMeasurementOnTrackCnv_p1.h:41
DetElementSurfaceCnv_p1::createSurface
const Trk::Surface * createSurface(MsgStream &log)
Definition: DetElementSurfaceCnv_p1.cxx:19
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
Surface.h
PseudoMeasurementOnTrackCnv_p1::persToTrans
virtual void persToTrans(const Trk ::PseudoMeasurementOnTrack_p1 *persObj, Trk ::PseudoMeasurementOnTrack *transObj, MsgStream &log)
Definition: PseudoMeasurementOnTrackCnv_p1.cxx:14
ITPConverterFor< TRANS_BASE >::fillTransFromPStore
void fillTransFromPStore(CNV **cnv, const TPObjRef &ref, TRANS_T *trans, MsgStream &log) const
Convert persistent object, stored in the the top-level persistent object and referenced by the TP Ref...
Definition: TPConverter.h:145
Trk::ErrorMatrix
Definition: ErrorMatrixCnv_p1.h:25
PseudoMeasurementOnTrackCnv_p1::m_localErrMatCnv
ErrorMatrixCnv_p1 * m_localErrMatCnv
Definition: PseudoMeasurementOnTrackCnv_p1.h:42
EigenHelpers::vectorToEigenMatrix
static void vectorToEigenMatrix(VECTOR &vec, COVARIANCE &cov, const char *)
Helper fn to fill the covariance from the raw data (vec<float>)
Definition: EigenHelpers.h:22
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Trk::DetElementSurface
Definition: DetElementSurface.h:32
PseudoMeasurementOnTrack.h
EigenHelpers.h
python.xAODType.dummy
dummy
Definition: xAODType.py:4
EigenHelpers::eigenMatrixToVector
static void eigenMatrixToVector(VECTOR &vec, COVARIANCE &cov, const char *)
Helper fn to get raw data (vec<float>) from the covariance.
Definition: EigenHelpers.h:30
PseudoMeasurementOnTrackCnv_p1.h
ITPConverterFor< TRANS_BASE >::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::ConstSurfaceUniquePtr
SurfaceUniquePtrT< const Trk::Surface > ConstSurfaceUniquePtr
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:468
Trk::ErrorMatrix::values
std::vector< float > values
Definition: ErrorMatrixCnv_p1.h:27
PseudoMeasurementOnTrackCnv_p1::transToPers
virtual void transToPers(const Trk ::PseudoMeasurementOnTrack *transObj, Trk ::PseudoMeasurementOnTrack_p1 *persObj, MsgStream &log)
Definition: PseudoMeasurementOnTrackCnv_p1.cxx:41
DetElementSurfaceCnv_p1
Definition: DetElementSurfaceCnv_p1.h:46
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Trk::MeasurementBaseType::PseudoMeasurementOnTrack
@ PseudoMeasurementOnTrack
Definition: MeasurementBase.h:51
DetElementSurfaceCnv_p1.h
DetElementSurface.h
ITPConverterFor< TRANS_BASE >::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