ATLAS Offline Software
Loading...
Searching...
No Matches
VolumeSplitterUtils.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef InDetGeoModelUtils_VolumeSplitterUtils_H
6#define InDetGeoModelUtils_VolumeSplitterUtils_H
7
8#include <string>
9#include <vector>
10#include <iostream>
11
12class GeoTube;
13class GeoPcon;
14
15namespace InDetDD {
16
17 class Zone;
18
19 class Point
20 {
21 public:
22 Point();
23 Point(double z, double r);
24 bool valid() const {return m_valid;}
25 bool exit() const {return m_exit;} //point is an exit point.
26 bool last() const {return m_last;}
27
28 double z() const {return m_z;}
29 double r() const {return m_r;}
30 const Zone * child() const {return m_child;} // point belongs to child
31 void setChild(const Zone * zone) {m_child = zone;}
32 void setInvalid() {m_valid = false;}
33 void setExit() {m_exit = true;}
34 void setLast() {m_last = true;}
35 private:
36 bool m_valid;
37 bool m_exit;
38 bool m_last;
39 double m_z;
40 double m_r;
41 const Zone * m_child;
42 };
43
44 class Ray {
45 public:
46 Ray();
47 Ray(const Point & start, const Point & end);
48 void set(const Point & start, const Point & end);
49 const Point & start() const {return m_start;}
50 const Point & end() const {return m_end;}
51 bool valid() const {return m_valid;}
52 bool foundStart() const {return m_found;}
53 bool horizontal() const {return m_horizontal;}
54 bool vertical() const {return m_vertical;}
55 void setFound() {m_found = true;}
56 void setInvalid() {m_valid = false;}
57
58 private:
59 void setDirection();
60
61 bool m_valid;
62 bool m_found;
63 bool m_horizontal = false;
64 bool m_vertical = false;
67 };
68
69
70
71 class Zone {
72 public:
73 typedef std::vector<const Zone *>::const_iterator ChildIterator;
74 Zone(const std::string & label, bool rotated = false);
75 virtual ~Zone();
76 virtual bool inSide(const Point & point) const = 0;
77 virtual Point findEntry(const Ray & ray) const = 0;
78 virtual Point findExit(const Ray & ray) const = 0;
79 void add(const Zone *);
80 ChildIterator begin() const {return m_children.begin();}
81 ChildIterator end() const {return m_children.end();}
82 const std::string & label() const {return m_label;}
83 bool rotated() const {return m_rotated;}
84 private:
85 std::string m_label;
87 std::vector<const Zone *> m_children;
88 };
89
90 class UnboundedZone : public Zone {
91 public:
92 UnboundedZone(const std::string & label);
93 virtual bool inSide(const Point & point) const;
94 virtual Point findEntry(const Ray & ray) const;
95 virtual Point findExit(const Ray & ray) const;
96 };
97
98 class TubeZone : public Zone
99 {
100 public:
101 TubeZone(const std::string & label, double zmin, double zmax, double rmin, double rmax, bool rotated = false);
102 TubeZone(const std::string & label, const GeoTube * shape, double zOffset, bool rotated = false);
103 virtual bool inSide(const Point & point) const;
104 virtual Point findEntry(const Ray & ray) const;
105 virtual Point findExit(const Ray & ray) const;
106 virtual double getRmin() const { return m_rmin; }
107 virtual double getRmax() const { return m_rmax; }
108 virtual double getZmin() const { return m_zmin; }
109 virtual double getZmax() const { return m_zmax; }
110 private:
111 bool inR(double r) const;
112 bool inZ(double z) const;
113 double m_zmin;
114 double m_zmax;
115 double m_rmin;
116 double m_rmax;
117 };
118
119 class PconZone : public Zone
120 {
121 public:
122 PconZone( const std::string & label, bool rotated = false);
123 PconZone(const std::string & label, const GeoPcon * shape, bool rotated = false);
124 void addPlane(double z, double rmin, double rmax);
125 virtual bool inSide(const Point & point) const;
126 virtual Point findEntry(const Ray & ray) const;
127 virtual Point findExit(const Ray & ray) const;
128 private:
129 bool inR(unsigned int i, double r) const;
130 bool inZ(unsigned int i, double z) const;
131 std::vector<double> m_z;
132 std::vector<double> m_rmin;
133 std::vector<double> m_rmax;
134 };
135
136 class Segment {
137 public:
138 Segment(const std::string & label, const Point & start, const Point & end, bool rotated = false);
139 const std::string & label() const {return m_label;}
140 bool rotated() const {return m_rotated;}
141 double zmin() const {return m_zmin;}
142 double zmax() const {return m_zmax;}
143 double rmin() const {return m_rmin;}
144 double rmax() const {return m_rmax;}
145 void print() const;
146 private:
147 std::string m_label;
149 double m_zmin;
150 double m_zmax;
151 double m_rmin;
152 double m_rmax;
153 };
154
156 {
157 public:
158 void add(const std::string & label, const Point & start, const Point & end, bool rotated = false);
159 void add(const Segment & segment);
160 unsigned int size() const {return m_segments.size();}
161 const Segment & getSegment(unsigned int i) const {return m_segments[i];}
162 bool horizontal() const;
163 void print() const;
164 //std::string getSegmentLabel(int i);
165 //double getSegmentZmin(int i);
166 //double getSegmentZmax(int i);
167 //double getSegmentRmin(int i);
168 //double getSegmentRmax(int i);
169 private:
170 std::vector<Segment> m_segments;
171 };
172
173
175 {
176 public:
177 const SegmentList & split(const Zone *, const Ray &);
178
179 private:
180 Ray addChildSegment(const Zone *, const Ray &);
181 void addSegment(const Zone *, const Point & start, const Point & end);
182 Point getNextBoundary(const Zone *, const Ray &);
183 Ray searchPoint(const Zone * zone, const Ray & ray);
184 Point nearestPoint(const Point & point1, const Point & point2);
185
186 private:
188 //m_ray;
189
190 };
191
192
193 std::ostream & operator<<(std::ostream & os, const InDetDD::Point & point);
194 std::ostream & operator<<(std::ostream & os, const InDetDD::Ray & ray);
195
196
197}
198
199
200#endif // InDetGeoModelUtils_VolumeSplitterUtils_H
#define z
PconZone(const std::string &label, bool rotated=false)
virtual Point findExit(const Ray &ray) const
std::vector< double > m_z
std::vector< double > m_rmax
virtual bool inSide(const Point &point) const
std::vector< double > m_rmin
bool inZ(unsigned int i, double z) const
virtual Point findEntry(const Ray &ray) const
void addPlane(double z, double rmin, double rmax)
bool inR(unsigned int i, double r) const
const Zone * child() const
void setChild(const Zone *zone)
bool valid() const
bool vertical() const
void set(const Point &start, const Point &end)
const Point & end() const
const Point & start() const
bool horizontal() const
bool foundStart() const
void add(const std::string &label, const Point &start, const Point &end, bool rotated=false)
unsigned int size() const
std::vector< Segment > m_segments
const Segment & getSegment(unsigned int i) const
void addSegment(const Zone *, const Point &start, const Point &end)
const SegmentList & split(const Zone *, const Ray &)
Ray searchPoint(const Zone *zone, const Ray &ray)
Point getNextBoundary(const Zone *, const Ray &)
Point nearestPoint(const Point &point1, const Point &point2)
Ray addChildSegment(const Zone *, const Ray &)
const std::string & label() const
Segment(const std::string &label, const Point &start, const Point &end, bool rotated=false)
virtual double getRmin() const
virtual double getZmax() const
virtual double getRmax() const
TubeZone(const std::string &label, double zmin, double zmax, double rmin, double rmax, bool rotated=false)
virtual double getZmin() const
virtual bool inSide(const Point &point) const
virtual Point findExit(const Ray &ray) const
bool inR(double r) const
bool inZ(double z) const
virtual Point findEntry(const Ray &ray) const
UnboundedZone(const std::string &label)
virtual Point findExit(const Ray &ray) const
virtual Point findEntry(const Ray &ray) const
virtual bool inSide(const Point &point) const
ChildIterator begin() const
void add(const Zone *)
bool rotated() const
virtual Point findExit(const Ray &ray) const =0
std::vector< constZone * >::const_iterator ChildIterator
const std::string & label() const
virtual bool inSide(const Point &point) const =0
virtual Point findEntry(const Ray &ray) const =0
std::vector< const Zone * > m_children
ChildIterator end() const
Zone(const std::string &label, bool rotated=false)
int r
Definition globals.cxx:22
std::string label(const std::string &format, int i)
Definition label.h:19
Message Stream Member.
std::ostream & operator<<(std::ostream &os, const SiCellId &cellId)
Definition SiCellId.cxx:8