ATLAS Offline Software
Loading...
Searching...
No Matches
SurfaceCnv_p2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5//-----------------------------------------------------------------------------
6//
7// file: SurfaceCnv_p2.cxx
8//
9// ----------------------------------------------------------------------------
10
11#include "TrkSurfaces/Surface.h"
21
22template <class SURFACE>
23SURFACE* SurfaceCnv_p2<SURFACE>::createTransient( const Trk::Surface_p2 * persObj,MsgStream& ){
24 SURFACE* surface=nullptr;
25 if (persObj->m_transform.empty()) {
26 // det element surface
28 const SURFACE* detSurf = static_cast<const SURFACE*>(m_eventCnvTool->getSurface(id));
29 // In this case, we return a surface object held by detdescr.
30 // We need to cast away const to match the createTransient interface.
31 // This is ugly, but in practice should be ok.
32 // FIXME: can this be done better?
33 SURFACE* surface_nc ATLAS_THREAD_SAFE = const_cast<SURFACE*>(detSurf);
34 surface= surface_nc; // Needed to fulfill interface...
35 } else {
36 // Not Det element surface, so need to create surface & fill transform
38 EigenHelpers::vectorToEigenTransform3D( persObj->m_transform, transform );
39 surface=new SURFACE(transform);
40 }
41 return surface;
42}
43
44template <class SURFACE>
45void SurfaceCnv_p2<SURFACE>::persToTrans( const Trk::Surface_p2 * , SURFACE * , MsgStream &) {
46 throw std::runtime_error("SurfaceCnv_p2::persToTrans shouldn't be called any more!");
47 // The reason for this is that persToTrans relies on an object being created already.
48 // But for det element surfaces, we will return one which already exists and belongs to the detector elements.
49}
50
51template <class SURFACE>
52void SurfaceCnv_p2<SURFACE>::transToPers( const SURFACE * transObj,
53 Trk::Surface_p2 * persObj,
54 MsgStream & log)
55{
56 if (not transObj){
57 log<<MSG::WARNING<<"SurfaceCnv_p2<SURFACE>::transToPers - null pointer for transient object."<<endmsg;
58 return;
59 }
60 persObj->m_associatedDetElementId = transObj->associatedDetectorElementIdentifier().get_identifier32().get_compact();
61 if (transObj->isFree() ) {
62 // if this is a free surface, write it out 'as is'
63 // - otherwise we're relying on the fact that the Identifier is there (and valid!) to reconstruct it on reading
64 EigenHelpers::eigenTransform3DToVector( *transObj->cachedTransform(),persObj->m_transform );
65
66 } else {
67 if (!transObj->associatedDetectorElementIdentifier().is_valid()) {
68 log<<MSG::WARNING<<"SurfaceCnv_p2<SURFACE>::transToPers - invalid detector element for non-free surface: "<<*transObj<<endmsg;
69 }
70 }
71 persObj->m_surfaceType = static_cast<uint8_t>(transObj->type());
72}
73
74// Specialisation for SaggedLineSurface - hopefully this will only ever be a DetEl surface, otherwise we need a new persistent type.
75template <>
77 Trk::Surface_p2 * persObj,
78 MsgStream &log)
79{
81 persObj->m_surfaceType = static_cast<uint8_t>(transObj->type());
82 if (transObj->isFree() ) {
83 log << MSG::WARNING<<"Not expecting these to be Free!"<<endmsg;
84 }
85}
86
#define endmsg
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
void transToPers(const SURFACE *, Trk::Surface_p2 *, MsgStream &)
void persToTrans(const Trk::Surface_p2 *, SURFACE *, MsgStream &)
ToolHandle< Trk::IEventCnvSuperTool > m_eventCnvTool
SURFACE * createTransient(const Trk::Surface_p2 *persObj, MsgStream &log)
The distorted surface itself is the nominal surface.
virtual constexpr SurfaceType type() const override final
Return the surface type.
uint8_t m_surfaceType
Definition Surface_p2.h:26
std::vector< float > m_transform
Definition Surface_p2.h:25
Identifier32::value_type m_associatedDetElementId
Definition Surface_p2.h:24
bool isFree() const
Returns 'true' if this surface is 'free', i.e.
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
Eigen::Affine3d Transform3D