forked from trackreco/mkFit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGeometry.cc
121 lines (102 loc) · 3.07 KB
/
Geometry.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "Geometry.h"
//#define DEBUG
#include "Debug.h"
namespace mkfit {
VUSolid::EnumInside Geometry::Inside (const UVector3 &aPoint) const {
VUSolid::EnumInside in = VUSolid::eOutside;
for (auto i = solids_.begin(); i != solids_.end(); ++i) {
VUSolid::EnumInside t = (*i)->Inside(aPoint);
if (t < in) in = t;
}
return in;
}
const VUSolid* Geometry::InsideWhat(const UVector3 &aPoint) const {
for (auto i = solids_.begin(); i != solids_.end(); ++i) {
if ((*i)->Inside(aPoint) != VUSolid::eOutside) {
return *i;
}
}
return nullptr;
}
int Geometry::LayerIndex(const UVector3 &aPoint) const {
for (auto i = solids_.begin(); i != solids_.end(); ++i) {
if ((*i)->Inside(aPoint) != VUSolid::eOutside) {
return std::distance(solids_.begin(),i);
}
}
return -1;
}
int Geometry::LayerOfSolid(const VUSolid *s) const
{
for (auto i = solids_.begin(); i != solids_.end(); ++i) {
if (*i == s) {
return std::distance(solids_.begin(),i);
}
}
return -1;
}
double Geometry::SafetyFromInside ( const UVector3 &aPoint, bool aAccurate) const {
double small = 1e10;
for (auto i = solids_.begin(); i != solids_.end(); ++i) {
if ((*i)->Inside(aPoint) != VUSolid::eOutside) {
double next = (*i)->SafetyFromInside(aPoint, aAccurate);
if (next < small) small = next;
}
}
return small;
}
double Geometry::SafetyFromOutside ( const UVector3 &aPoint, bool aAccurate) const {
double small = 1e10;
for (auto i = solids_.begin(); i != solids_.end(); ++i) {
if ((*i)->Inside(aPoint) == VUSolid::eOutside) {
double next = (*i)->SafetyFromOutside(aPoint, aAccurate);
if (next < small) small = next;
}
}
return small;
}
double Geometry::SafetyFromOutsideDr(const UVector3 &aPoint, double ooaCtgTheta,
int skip_layer, int &layer, bool aAccurate) const
{
//bool debug = false;
double small = 1e10;
dprintf("Geometry::SafetyFromOutsideDr r=%f, z=%f\n", aPoint.Perp(), aPoint.Z());
int ii = 0;
layer = -1;
for (auto i = solids_.begin(); i != solids_.end(); ++i, ++ii)
{
if (ii != skip_layer && (*i)->Inside(aPoint) == VUSolid::eOutside)
{
double next = (*i)->SafetyFromOutsideDr(aPoint, ooaCtgTheta, aAccurate);
#ifdef DEBUG
if (next < 15) dprintf(" Radial distance to %2d = %4.5f\n", ii, next);
#endif
if (next < small) { small = next; layer = ii; }
}
}
dprintf(" Selected layer %2d = %f\n", layer, small);
return small;
}
Geometry Geometry::clone() const
{
Geometry NewGeo(*this);
for (auto&& t : NewGeo.solids_) {
t = t->Clone();
}
return NewGeo;
}
} // end namespace mkfit
//==============================================================================
#include "TrackerInfo.h"
namespace mkfit {
void Geometry::BuildFromTrackerInfo(const TrackerInfo& tracker_info)
{
for (auto& li : tracker_info.m_layers)
{
VUSolid* utub = new VUSolid(li.m_rin, li.m_rout,
li.m_zmin, li.m_zmax,
li.is_barrel(), li.m_is_outer);
AddLayer(utub, li.r_mean(), li.z_mean());
}
}
} // end namespace mkfit