ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkFitter
TrkGlobalChi2Fitter
src
LayerSort.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LayerSort.h
"
6
#include "
TrkGeometry/Layer.h
"
7
#include "
TrkGeometry/CylinderLayer.h
"
8
#include "
TrkGeometry/DiscLayer.h
"
9
#include "
TrkSurfaces/DiscSurface.h
"
10
#include "
TrkSurfaces/CylinderSurface.h
"
11
#include "
TrkSurfaces/DiscBounds.h
"
12
#include "
TrkSurfaces/CylinderBounds.h
"
13
#include <cmath>
14
15
namespace
GXF
{
16
using
Trk::Layer
;
17
using
Trk::CylinderSurface
;
18
using
Trk::DiscSurface
;
19
using
Trk::CylinderBounds
;
20
using
Trk::DiscBounds
;
21
22
bool
23
LayerSort::operator()
(
const
LayerPtrPair
& one,
const
LayerPtrPair
& two)
const
{
24
auto
castToCylinder = [](
const
LayerPtrPair
&
pair
)->
const
Trk::CylinderSurface
* {
25
if
(
pair
.first)
return
(
const
CylinderSurface
*) &
pair
.first->surfaceRepresentation();
26
else
return
nullptr
;
27
};
28
auto
castToDisc = [](
const
LayerPtrPair
&
pair
)->
const
Trk::DiscSurface
* {
29
if
(
pair
.second)
return
(
const
DiscSurface
*) &
pair
.second->surfaceRepresentation();
30
else
return
nullptr
;
31
};
32
const
CylinderSurface
*cyl1 = castToCylinder(one);
33
const
DiscSurface
*disc1 = castToDisc(one);
34
const
CylinderSurface
*cyl2 = castToCylinder(two);
35
const
DiscSurface
*disc2 = castToDisc(two);
36
37
if
(cyl1 and cyl2) {
38
if
(std::abs(cyl1->
center
().z() - cyl2->
center
().z()) > 1.) {
39
return
(std::abs(cyl1->
center
().z()) < std::abs(cyl2->
center
().z()));
40
}
41
return
(cyl1->
bounds
().
r
() < cyl2->
bounds
().
r
());
42
}
43
if
(disc1 and disc2) {
44
const
DiscBounds
*discbounds1 = (
const
DiscBounds
*) &disc1->
bounds
();
45
const
DiscBounds
*discbounds2 = (
const
DiscBounds
*) &disc2->
bounds
();
46
if
(discbounds1->
rMax
() < discbounds2->
rMin
() + 1) {
47
return
true
;
48
}
49
if
(discbounds1->
rMin
() > discbounds2->
rMax
() - 1) {
50
return
false
;
51
}
52
return
(std::abs(disc1->
center
().z()) < std::abs(disc2->
center
().z()));
53
}
54
55
if
((cyl1 !=
nullptr
) && (disc2 !=
nullptr
)) {
56
const
DiscBounds
*discbounds = (
const
DiscBounds
*) &disc2->
bounds
();
57
if
(cyl1->
bounds
().
r
() > discbounds->
rMax
() - 1) {
58
return
false
;
59
}
60
if
(cyl1->
bounds
().
r
() < discbounds->
rMin
() + 1) {
61
return
true
;
62
}
63
return
(std::abs(cyl1->
center
().z()) < std::abs(disc2->
center
().z()));
64
}
65
66
if
((disc1 ==
nullptr
) || (cyl2 ==
nullptr
)) {
67
throw
std::logic_error(
"Unhandled surface combination."
);
68
}
69
70
const
DiscBounds
*discbounds = (
const
DiscBounds
*) &disc1->
bounds
();
71
72
if
(cyl2->
bounds
().
r
() > discbounds->
rMax
() - 1) {
73
return
true
;
74
}
75
76
if
(cyl2->
bounds
().
r
() < discbounds->
rMin
() + 1) {
77
return
false
;
78
}
79
80
return
(std::abs(cyl2->
center
().z()) > std::abs(disc1->
center
().z()));
81
}
82
83
84
bool
85
LayerSort2::operator()
(
const
Layer
* one,
const
Layer
* two)
const
{
86
auto
castToCylinder = [](
const
Layer
* pLayer) ->
const
CylinderSurface
* {
87
if
(pLayer->surfaceRepresentation().type() ==
Trk::SurfaceType::Cylinder
)
88
return
static_cast<
const
CylinderSurface
*
>
(&pLayer->surfaceRepresentation());
89
return
nullptr
;
90
};
91
auto
castToDisc = [](
const
Layer
* pLayer) ->
const
DiscSurface
*{
92
if
(pLayer->surfaceRepresentation().type() ==
Trk::SurfaceType::Disc
)
93
return
static_cast<
const
DiscSurface
*
>
(&pLayer->surfaceRepresentation());
94
return
nullptr
;
95
};
96
//
97
const
CylinderSurface
*cyl1 = castToCylinder(one);
98
const
CylinderSurface
*cyl2 = castToCylinder(two);
99
if
(cyl1 and cyl2) {
100
return
(cyl1->
bounds
().
r
() < cyl2->
bounds
().
r
());
101
}
102
const
DiscSurface
*disc1 = castToDisc(one);
103
const
DiscSurface
*disc2 = castToDisc(two);
104
if
(disc1 and disc2) {
105
return
(std::abs(disc1->
center
().z()) < std::abs(disc2->
center
().z()));
106
}
107
108
return
false
;
109
}
110
111
}
CylinderBounds.h
CylinderLayer.h
CylinderSurface.h
DiscBounds.h
DiscLayer.h
DiscSurface.h
LayerSort.h
Layer.h
GXF::LayerSort2::operator()
bool operator()(const Trk::Layer *one, const Trk::Layer *two) const
Definition
LayerSort.cxx:85
GXF::LayerSort::operator()
bool operator()(const LayerPtrPair &one, const LayerPtrPair &two) const
Definition
LayerSort.cxx:23
GXF::LayerSort::LayerPtrPair
std::pair< const Trk::Layer *, const Trk::Layer * > LayerPtrPair
Definition
LayerSort.h:13
Trk::CylinderBounds
Bounds for a cylindrical Surface.
Definition
CylinderBounds.h:46
Trk::CylinderBounds::r
virtual double r() const override final
This method returns the radius.
Trk::CylinderSurface
Class for a CylinderSurface in the ATLAS detector.
Definition
CylinderSurface.h:55
Trk::CylinderSurface::bounds
virtual const CylinderBounds & bounds() const override final
This method returns the CylinderBounds by reference (NoBounds is not possible for cylinder).
Trk::DiscBounds
Class to describe the bounds for a planar DiscSurface.
Definition
DiscBounds.h:44
Trk::DiscBounds::rMax
double rMax() const
This method returns outer radius.
Trk::DiscBounds::rMin
double rMin() const
This method returns inner radius.
Trk::DiscSurface
Class for a DiscSurface in the ATLAS detector.
Definition
DiscSurface.h:54
Trk::DiscSurface::bounds
const SurfaceBounds & bounds() const override final
This method returns the bounds by reference.
Trk::Layer
Base Class for a Detector Layer in the Tracking realm.
Definition
Layer.h:72
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
pair
STL class.
GXF
Definition
LayerSort.cxx:15
Trk::SurfaceType::Cylinder
@ Cylinder
Definition
SurfaceTypes.h:19
Trk::SurfaceType::Disc
@ Disc
Definition
SurfaceTypes.h:20
Generated on
for ATLAS Offline Software by
1.17.0