ATLAS Offline Software
TrackStateOnSurfaceCnv_p3.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //-----------------------------------------------------------------------------
6 //
7 // file: TrackStateOnSurfaceCnv_p3.cxx
8 //
9 //-----------------------------------------------------------------------------
10 
15 
18 
20 persToTrans( const Trk::TrackStateOnSurface_p3 *persObj, Trk::TrackStateOnSurface *transObj, MsgStream &log )
21 {
22  ITPConverterFor<Trk::MeasurementBase> *measureCnv = nullptr;
23  Trk::MeasurementBase* meas = createTransFromPStore( &measureCnv, persObj->m_measurementOnTrack, log );
24 
26  if (!m_parametersCnv) m_parametersCnv = dynamic_cast<TrackParametersCnv_p2*>(dummy); // FIXME - only in init?
28 
29  std::unique_ptr<const Trk::FitQuality> fitQ(createTransFromPStore( &m_fitQCnv, persObj->m_fitQualityOnSurface, log));
30  auto fitQos = fitQ ? Trk::FitQualityOnSurface(*fitQ) : Trk::FitQualityOnSurface{};
31 
32  ITPConverterFor<Trk::MaterialEffectsBase> *matBaseCnv = nullptr;
33  Trk::MaterialEffectsBase* materialEffects = createTransFromPStore( &matBaseCnv, persObj->m_materialEffects, log );
34 
35  std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> types;
36  std::bitset<Trk::TrackStateOnSurface::NumberOfPersistencyHints> hints;
38  // There were some tracks saved that violate the isSane test in
39  // TrackStateOnSurface. If we were to pass meas or materialEffects
40  // to this ctor then we would trip that assertion. However,
41  // we want to preserve the previous behavior of the TP converters,
42  // which did allow reading such tracks. So defer setting these pointers
43  // until after the checks,
44  *transObj = Trk::TrackStateOnSurface(
45  fitQos,
46  nullptr,
47  std::unique_ptr<Trk::TrackParameters>(trackParameters),
48  nullptr,
49  types);
50  transObj->m_measurementOnTrack.reset(meas);
51  transObj->m_materialEffectsOnTrack.reset(materialEffects);
52  //Hints are atomic. Set once here if TSOS was slimmed
53  //aka not 0. If 0 we want to allow setting them later on
54  uint8_t hintsUInt = hints.to_ulong();
55  if(hintsUInt!=0){
56  transObj->setHints(hintsUInt);
57  }
58 }
59 
60 
62 transToPers( const Trk::TrackStateOnSurface *transObj, Trk::TrackStateOnSurface_p3 *persObj, MsgStream &log )
63 {
64  //--- Parameters
66  if (!m_parametersCnv) {
68  }
69 
70  std::bitset<Trk::TrackStateOnSurface::NumberOfPersistencyHints> persHints = transObj->hints();
71  bool persistify_all = !(persHints.test(Trk::TrackStateOnSurface::PartialPersistification));
72 
74  ( (persistify_all || persHints.test(Trk::TrackStateOnSurface::PersistifyTrackParameters) )
75  ? transObj->trackParameters()
76  : nullptr),
77  log );
78 
79  auto fitQos =
80  persistify_all
81  ? std::make_unique<Trk::FitQuality>(transObj->fitQualityOnSurface())
82  : nullptr;
83 
84  persObj->m_fitQualityOnSurface = toPersistent(&m_fitQCnv, fitQos.get(), log);
85 
86  ITPConverterFor<Trk::MeasurementBase> *measureCnv = nullptr;
87  persObj->m_measurementOnTrack = toPersistent( &measureCnv,
88  ((persistify_all || persHints.test(Trk::TrackStateOnSurface::PersistifyMeasurement) )
89  ? transObj->measurementOnTrack()
90  : nullptr),
91  log );
92 
93  ITPConverterFor<Trk::MaterialEffectsBase> *matBaseCnv = nullptr;
94  persObj->m_materialEffects = toPersistent( &matBaseCnv,
95  ((persistify_all || persHints.test(Trk::TrackStateOnSurface::PersistifySlimCaloDeposit))
96  ? transObj->materialEffectsOnTrack()
97  : nullptr), log );
98  if (persistify_all) {
99  // If we persistiy all we copy the input as is
100  persObj->m_typeFlags =
101  Trk::TrackStateOnSurface::joinBitsets(transObj->types(), persHints);
102  } else {
103  std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
104  typePattern;
105  if ((persistify_all ||
108  typePattern.set(Trk::TrackStateOnSurface::Perigee);
109  }
110  if (persistify_all ||
113  typePattern.set(Trk::TrackStateOnSurface::Measurement);
114  }
115  if (transObj->type(Trk::TrackStateOnSurface::Outlier)) {
116  typePattern.set(Trk::TrackStateOnSurface::Outlier);
117  }
118  }
119  //also copy over the persHints here
120  persObj->m_typeFlags =
121  Trk::TrackStateOnSurface::joinBitsets(typePattern, persHints);
122  }
123 }
124 
125 void
127  const Trk::TrackStateOnSurface_p3* persObj,
129  MsgStream& log)
130 {
135  }
136  m_trackStateOnSurfaceCnv->persToTrans(persObj, transObj, log);
137 }
138 void
140  const Trk::MultiComponentStateOnSurface* transObj,
142  MsgStream& log)
143 {
148  }
149  m_trackStateOnSurfaceCnv->transToPers(transObj, persObj, log);
150 }
151 
TrackStateOnSurfaceCnv_p3::persToTrans
virtual void persToTrans(const Trk::TrackStateOnSurface_p3 *persObj, Trk::TrackStateOnSurface *transObj, MsgStream &log)
Definition: TrackStateOnSurfaceCnv_p3.cxx:20
Trk::TrackStateOnSurface::trackParameters
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
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::TrackStateOnSurface::Perigee
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
Definition: TrackStateOnSurface.h:117
ITPConverterFor< Trk::MeasurementBase >
TrackStateOnSurfaceCnv_p3::m_parametersCnv
TrackParametersCnv_p2 * m_parametersCnv
Definition: TrackStateOnSurfaceCnv_p3.h:42
TrackParameters.h
Trk::TrackStateOnSurface_p3::m_trackParameters
TPObjRef m_trackParameters
Definition: TrackStateOnSurface_p3.h:24
MeasurementBase.h
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
Trk::TrackStateOnSurface_p3
Definition: TrackStateOnSurface_p3.h:19
Trk::TrackStateOnSurface::PersistifyTrackParameters
@ PersistifyTrackParameters
Mark track parameters for persisitification.
Definition: TrackStateOnSurface.h:167
TrackParametersCnv_p2
New convertor which handles all track parameters in one go - i.e.
Definition: TrackParametersCnv_p2.h:30
Trk::TrackStateOnSurface::m_materialEffectsOnTrack
std::unique_ptr< MaterialEffectsBase > m_materialEffectsOnTrack
Definition: TrackStateOnSurface.h:370
Trk::TrackStateOnSurface::measurementOnTrack
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
Trk::TrackStateOnSurface::types
const std::bitset< NumberOfTrackStateOnSurfaceTypes > types() const
returns a bitset with the types of this bitset.
MultiComponentStateOnSurfaceCnv_p1::persToTrans
virtual void persToTrans(const Trk::TrackStateOnSurface_p3 *persObj, Trk::MultiComponentStateOnSurface *transObj, MsgStream &log)
Definition: TrackStateOnSurfaceCnv_p3.cxx:126
Trk::TrackStateOnSurface::PersistifyMeasurement
@ PersistifyMeasurement
Mark the measuremenet for persistification.
Definition: TrackStateOnSurface.h:162
Trk::MaterialEffectsBase
base class to integrate material effects on Trk::Track in a flexible way.
Definition: MaterialEffectsBase.h:35
MaterialEffectsBase.h
ITPConverterFor::topConverter
virtual TopLevelTPCnvBase * topConverter()
return the top-level converter for this elemental TP converter
Definition: TPConverter.h:191
Trk::TrackStateOnSurface::fitQualityOnSurface
const FitQualityOnSurface & fitQualityOnSurface() const
return FitQuality On Surface const overload
Trk::TrackStateOnSurface::Outlier
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
Definition: TrackStateOnSurface.h:122
Trk::FitQualityOnSurface
Definition: FitQualityOnSurface.h:19
Trk::TrackStateOnSurface::type
bool type(const TrackStateOnSurfaceType type) const
Use this method to find out if the TSoS is of a certain type: i.e.
TrackStateOnSurfaceCnv_p3::transToPers
virtual void transToPers(const Trk::TrackStateOnSurface *transObj, Trk::TrackStateOnSurface_p3 *persObj, MsgStream &log)
Definition: TrackStateOnSurfaceCnv_p3.cxx:62
MultiComponentStateOnSurfaceCnv_p1::m_trackStateOnSurfaceCnv
TrackStateOnSurfaceCnv_p3 * m_trackStateOnSurfaceCnv
Definition: TrackStateOnSurfaceCnv_p3.h:67
Trk::TrackStateOnSurface::materialEffectsOnTrack
const MaterialEffectsBase * materialEffectsOnTrack() const
return material effects const overload
Trk::TrackStateOnSurface_p3::m_typeFlags
long m_typeFlags
Definition: TrackStateOnSurface_p3.h:31
Trk::TrackStateOnSurface::joinBitsets
static unsigned int long joinBitsets(const std::bitset< NumberOfTrackStateOnSurfaceTypes > &types, const std::bitset< NumberOfPersistencyHints > &hints)
Definition: TrackStateOnSurface.h:183
MultiComponentStateOnSurfaceCnv_p1::transToPers
virtual void transToPers(const Trk::MultiComponentStateOnSurface *transObj, Trk::TrackStateOnSurface_p3 *persObj, MsgStream &log)
Definition: TrackStateOnSurfaceCnv_p3.cxx:139
Trk::TrackStateOnSurface_p3::m_measurementOnTrack
TPObjRef m_measurementOnTrack
Definition: TrackStateOnSurface_p3.h:30
ParametersT.h
TrackStateOnSurfaceCnv_p3::m_fitQCnv
FitQualityCnv_p1 * m_fitQCnv
Definition: TrackStateOnSurfaceCnv_p3.h:40
python.xAODType.dummy
dummy
Definition: xAODType.py:4
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::TrackStateOnSurface::PersistifySlimCaloDeposit
@ PersistifySlimCaloDeposit
Mark track parameters for persisitification.
Definition: TrackStateOnSurface.h:172
Trk::MeasurementBase
Definition: MeasurementBase.h:58
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::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
TrackStateOnSurfaceCnv_p3
Definition: TrackStateOnSurfaceCnv_p3.h:28
Trk::TrackStateOnSurface::splitToBitsets
static void splitToBitsets(const unsigned int long input, std::bitset< NumberOfTrackStateOnSurfaceTypes > &types, std::bitset< NumberOfPersistencyHints > &hints)
Definition: TrackStateOnSurface.h:196
Trk::TrackStateOnSurface_p3::m_fitQualityOnSurface
TPObjRef m_fitQualityOnSurface
Definition: TrackStateOnSurface_p3.h:26
Trk::TrackStateOnSurface::setHints
void setHints(const uint8_t hints) const
Use this method to set persistification hints.
Definition: TrackStateOnSurface.cxx:235
Trk::MultiComponentStateOnSurface
Definition: MultiComponentStateOnSurface.h:42
Trk::TrackStateOnSurface::hints
const std::bitset< NumberOfPersistencyHints > hints() const
Use this method to get the persistification hints.
TrackStateOnSurfaceCnv_p3.h
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Trk::TrackStateOnSurface_p3::m_materialEffects
TPObjRef m_materialEffects
Definition: TrackStateOnSurface_p3.h:28
Trk::TrackStateOnSurface::m_measurementOnTrack
std::unique_ptr< MeasurementBase > m_measurementOnTrack
Definition: TrackStateOnSurface.h:369
ITPConverter
Definition: TPTools/TPTools/ITPConverter.h:32
Trk::TrackStateOnSurface::PartialPersistification
@ PartialPersistification
Definition: TrackStateOnSurface.h:158
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
TrackStateOnSurface.h
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