ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkEventCnv
TrkEventTPCnv
src
TrkSurfaces
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
"
12
#include "
TrkSurfaces/StraightLineSurface.h
"
13
#include "
TrkSurfaces/DiscSurface.h
"
14
#include "
TrkSurfaces/PlaneSurface.h
"
15
#include "
TrkSurfaces/CylinderSurface.h
"
16
#include "
TrkSurfaces/PerigeeSurface.h
"
17
#include "
TrkDistortedSurfaces/SaggedLineSurface.h
"
18
#include "
TrkEventTPCnv/TrkSurfaces/SurfaceCnv_p2.h
"
19
#include "
TrkEventTPCnv/helpers/EigenHelpers.h
"
20
#include "
CxxUtils/checker_macros.h
"
21
22
template
<
class
SURFACE>
23
SURFACE*
SurfaceCnv_p2<SURFACE>::createTransient
(
const
Trk::Surface_p2
* persObj,MsgStream& ){
24
SURFACE* surface=
nullptr
;
25
if
(persObj->
m_transform
.empty()) {
26
// det element surface
27
Identifier
id
=
Identifier32
(persObj->
m_associatedDetElementId
);
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
37
Amg::Transform3D
transform;
38
EigenHelpers::vectorToEigenTransform3D( persObj->
m_transform
, transform );
39
surface=
new
SURFACE(transform);
40
}
41
return
surface;
42
}
43
44
template
<
class
SURFACE>
45
void
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
51
template
<
class
SURFACE>
52
void
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.
75
template
<>
76
void
SurfaceCnv_p2<Trk::SaggedLineSurface>::transToPers
(
const
Trk::SaggedLineSurface
* transObj,
77
Trk::Surface_p2
* persObj,
78
MsgStream &log)
79
{
80
persObj->
m_associatedDetElementId
= transObj->
associatedDetectorElementIdentifier
().
get_identifier32
().
get_compact
();
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
87
template
class
SurfaceCnv_p2<Trk::ConeSurface>
;
88
template
class
SurfaceCnv_p2<Trk::CylinderSurface>
;
89
template
class
SurfaceCnv_p2<Trk::DiscSurface>
;
90
template
class
SurfaceCnv_p2<Trk::PerigeeSurface>
;
91
template
class
SurfaceCnv_p2<Trk::PlaneSurface>
;
92
template
class
SurfaceCnv_p2<Trk::StraightLineSurface>
;
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
CylinderSurface.h
DiscSurface.h
EigenHelpers.h
PerigeeSurface.h
PlaneSurface.h
SaggedLineSurface.h
StraightLineSurface.h
SurfaceCnv_p2.h
Surface.h
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
Identifier32
Definition
Identifier32.h:28
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition
Identifier32.h:47
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
SurfaceCnv_p2
Definition
SurfaceCnv_p2.h:33
SurfaceCnv_p2::transToPers
void transToPers(const SURFACE *, Trk::Surface_p2 *, MsgStream &)
Definition
SurfaceCnv_p2.cxx:52
SurfaceCnv_p2::persToTrans
void persToTrans(const Trk::Surface_p2 *, SURFACE *, MsgStream &)
Definition
SurfaceCnv_p2.cxx:45
SurfaceCnv_p2::m_eventCnvTool
ToolHandle< Trk::IEventCnvSuperTool > m_eventCnvTool
Definition
SurfaceCnv_p2.h:46
SurfaceCnv_p2::createTransient
SURFACE * createTransient(const Trk::Surface_p2 *persObj, MsgStream &log)
Definition
SurfaceCnv_p2.cxx:23
Trk::SaggedLineSurface
The distorted surface itself is the nominal surface.
Definition
SaggedLineSurface.h:33
Trk::StraightLineSurface::type
virtual constexpr SurfaceType type() const override final
Return the surface type.
Trk::Surface_p2
Definition
Surface_p2.h:22
Trk::Surface_p2::m_surfaceType
uint8_t m_surfaceType
Definition
Surface_p2.h:28
Trk::Surface_p2::m_transform
std::vector< float > m_transform
Definition
Surface_p2.h:27
Trk::Surface_p2::m_associatedDetElementId
Identifier32::value_type m_associatedDetElementId
Definition
Surface_p2.h:26
Trk::Surface::isFree
bool isFree() const
Returns 'true' if this surface is 'free', i.e.
Trk::Surface::associatedDetectorElementIdentifier
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition
GeoPrimitives.h:46
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0