ATLAS Offline Software
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 
12 class GeoTube;
13 class GeoPcon;
14 
15 namespace 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;
86  bool m_rotated;
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;
148  bool m_rotated;
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
InDetDD::Zone::ChildIterator
std::vector< const Zone * >::const_iterator ChildIterator
Definition: VolumeSplitterUtils.h:73
beamspotman.r
def r
Definition: beamspotman.py:676
InDetDD::TubeZone::getRmin
virtual double getRmin() const
Definition: VolumeSplitterUtils.h:106
InDetDD::Segment::m_rmin
double m_rmin
Definition: VolumeSplitterUtils.h:151
InDetDD::Point::child
const Zone * child() const
Definition: VolumeSplitterUtils.h:30
InDetDD::SegmentSplitter::addSegment
void addSegment(const Zone *, const Point &start, const Point &end)
Definition: VolumeSplitterUtils.cxx:55
InDetDD::PconZone::addPlane
void addPlane(double z, double rmin, double rmax)
Definition: VolumeSplitterUtils.cxx:237
InDetDD::SegmentSplitter::split
const SegmentList & split(const Zone *, const Ray &)
Definition: VolumeSplitterUtils.cxx:13
InDetDD::Point::valid
bool valid() const
Definition: VolumeSplitterUtils.h:24
InDetDD::UnboundedZone
Definition: VolumeSplitterUtils.h:90
InDetDD::Ray::m_start
Point m_start
Definition: VolumeSplitterUtils.h:65
InDetDD::Point::Point
Point()
Definition: VolumeSplitterUtils.cxx:349
InDetDD::PconZone::m_z
std::vector< double > m_z
Definition: VolumeSplitterUtils.h:131
InDetDD::Ray::setDirection
void setDirection()
Definition: VolumeSplitterUtils.cxx:340
InDetDD::SegmentList::m_segments
std::vector< Segment > m_segments
Definition: VolumeSplitterUtils.h:170
InDetDD::Zone::begin
ChildIterator begin() const
Definition: VolumeSplitterUtils.h:80
InDetDD::UnboundedZone::findExit
virtual Point findExit(const Ray &ray) const
Definition: VolumeSplitterUtils.cxx:144
InDetDD::Segment::rmin
double rmin() const
Definition: VolumeSplitterUtils.h:143
InDetDD::Zone::m_rotated
bool m_rotated
Definition: VolumeSplitterUtils.h:86
InDetDD::Zone::label
const std::string & label() const
Definition: VolumeSplitterUtils.h:82
InDetDD::Segment::Segment
Segment(const std::string &label, const Point &start, const Point &end, bool rotated=false)
Definition: VolumeSplitterUtils.cxx:367
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:169
InDetDD::Zone::add
void add(const Zone *)
Definition: VolumeSplitterUtils.cxx:124
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
InDetDD::Zone
Definition: VolumeSplitterUtils.h:71
InDetDD::Segment::zmax
double zmax() const
Definition: VolumeSplitterUtils.h:142
InDetDD::Ray::end
const Point & end() const
Definition: VolumeSplitterUtils.h:50
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
InDetDD::TubeZone::inZ
bool inZ(double z) const
Definition: VolumeSplitterUtils.cxx:172
InDetDD::SegmentSplitter::nearestPoint
Point nearestPoint(const Point &point1, const Point &point2)
Definition: VolumeSplitterUtils.cxx:80
InDetDD::Segment::print
void print() const
Definition: VolumeSplitterUtils.cxx:404
InDetDD::SegmentSplitter::addChildSegment
Ray addChildSegment(const Zone *, const Ray &)
Definition: VolumeSplitterUtils.cxx:19
InDetDD::Point::exit
bool exit() const
Definition: VolumeSplitterUtils.h:25
InDetDD::Point::setExit
void setExit()
Definition: VolumeSplitterUtils.h:33
InDetDD::Point::last
bool last() const
Definition: VolumeSplitterUtils.h:26
InDetDD::TubeZone::m_rmin
double m_rmin
Definition: VolumeSplitterUtils.h:115
InDetDD::Ray::setInvalid
void setInvalid()
Definition: VolumeSplitterUtils.h:56
InDetDD::SegmentList
Definition: VolumeSplitterUtils.h:156
InDetDD::Segment::m_zmin
double m_zmin
Definition: VolumeSplitterUtils.h:149
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
InDetDD::Point::z
double z() const
Definition: VolumeSplitterUtils.h:28
InDetDD::operator<<
std::ostream & operator<<(std::ostream &os, const SiCellId &cellId)
Definition: SiCellId.cxx:8
InDetDD::Segment::m_zmax
double m_zmax
Definition: VolumeSplitterUtils.h:150
InDetDD::Point::setLast
void setLast()
Definition: VolumeSplitterUtils.h:34
InDetDD::Zone::~Zone
virtual ~Zone()
Definition: VolumeSplitterUtils.cxx:117
InDetDD::PconZone::inR
bool inR(unsigned int i, double r) const
Definition: VolumeSplitterUtils.cxx:258
InDetDD::Ray
Definition: VolumeSplitterUtils.h:44
InDetDD::PconZone::m_rmax
std::vector< double > m_rmax
Definition: VolumeSplitterUtils.h:133
InDetDD::Segment::label
const std::string & label() const
Definition: VolumeSplitterUtils.h:139
InDetDD::TubeZone::getRmax
virtual double getRmax() const
Definition: VolumeSplitterUtils.h:107
InDetDD::TubeZone::findEntry
virtual Point findEntry(const Ray &ray) const
Definition: VolumeSplitterUtils.cxx:183
InDetDD::Segment::m_label
std::string m_label
Definition: VolumeSplitterUtils.h:147
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
InDetDD::Ray::horizontal
bool horizontal() const
Definition: VolumeSplitterUtils.h:53
InDetDD::SegmentList::size
unsigned int size() const
Definition: VolumeSplitterUtils.h:160
InDetDD::PconZone::PconZone
PconZone(const std::string &label, bool rotated=false)
Definition: VolumeSplitterUtils.cxx:225
InDetDD::Zone::end
ChildIterator end() const
Definition: VolumeSplitterUtils.h:81
InDetDD::Ray::m_valid
bool m_valid
Definition: VolumeSplitterUtils.h:61
InDetDD::SegmentSplitter::getNextBoundary
Point getNextBoundary(const Zone *, const Ray &)
Definition: VolumeSplitterUtils.cxx:60
InDetDD::SegmentSplitter::m_segments
SegmentList m_segments
Definition: VolumeSplitterUtils.h:187
InDetDD::Point::setInvalid
void setInvalid()
Definition: VolumeSplitterUtils.h:32
InDetDD::Segment::rotated
bool rotated() const
Definition: VolumeSplitterUtils.h:140
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:169
InDetDD::Point::m_last
bool m_last
Definition: VolumeSplitterUtils.h:38
InDetDD::PconZone::inSide
virtual bool inSide(const Point &point) const
Definition: VolumeSplitterUtils.cxx:244
InDetDD::TubeZone::getZmin
virtual double getZmin() const
Definition: VolumeSplitterUtils.h:108
InDetDD::Point::m_child
const Zone * m_child
Definition: VolumeSplitterUtils.h:41
InDetDD::SegmentSplitter
Definition: VolumeSplitterUtils.h:175
InDetDD::Point
Definition: VolumeSplitterUtils.h:20
InDetDD::SegmentList::horizontal
bool horizontal() const
Definition: VolumeSplitterUtils.cxx:387
InDetDD::Point::setChild
void setChild(const Zone *zone)
Definition: VolumeSplitterUtils.h:31
InDetDD::Ray::start
const Point & start() const
Definition: VolumeSplitterUtils.h:49
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
InDetDD::Zone::findExit
virtual Point findExit(const Ray &ray) const =0
InDetDD::SegmentList::add
void add(const std::string &label, const Point &start, const Point &end, bool rotated=false)
Definition: VolumeSplitterUtils.cxx:377
InDetDD::Ray::m_found
bool m_found
Definition: VolumeSplitterUtils.h:62
InDetDD::Zone::inSide
virtual bool inSide(const Point &point) const =0
InDetDD::PconZone::m_rmin
std::vector< double > m_rmin
Definition: VolumeSplitterUtils.h:132
InDetDD::UnboundedZone::findEntry
virtual Point findEntry(const Ray &ray) const
Definition: VolumeSplitterUtils.cxx:138
python.draw_obj.zone
def zone(nx, ny)
Definition: draw_obj.py:288
InDetDD::Ray::setFound
void setFound()
Definition: VolumeSplitterUtils.h:55
InDetDD::Ray::set
void set(const Point &start, const Point &end)
Definition: VolumeSplitterUtils.cxx:333
InDetDD::UnboundedZone::inSide
virtual bool inSide(const Point &point) const
Definition: VolumeSplitterUtils.cxx:133
InDetDD::PconZone::findEntry
virtual Point findEntry(const Ray &ray) const
Definition: VolumeSplitterUtils.cxx:266
InDetDD::Point::m_z
double m_z
Definition: VolumeSplitterUtils.h:39
InDetDD::Zone::m_children
std::vector< const Zone * > m_children
Definition: VolumeSplitterUtils.h:87
InDetDD::Point::m_exit
bool m_exit
Definition: VolumeSplitterUtils.h:37
InDetDD::Point::m_r
double m_r
Definition: VolumeSplitterUtils.h:40
InDetDD::Segment
Definition: VolumeSplitterUtils.h:136
InDetDD::TubeZone::findExit
virtual Point findExit(const Ray &ray) const
Definition: VolumeSplitterUtils.cxx:205
InDetDD::Segment::zmin
double zmin() const
Definition: VolumeSplitterUtils.h:141
InDetDD::TubeZone::m_rmax
double m_rmax
Definition: VolumeSplitterUtils.h:116
InDetDD::Zone::m_label
std::string m_label
Definition: VolumeSplitterUtils.h:85
InDetDD::PconZone
Definition: VolumeSplitterUtils.h:120
InDetDD::Zone::findEntry
virtual Point findEntry(const Ray &ray) const =0
InDetDD::UnboundedZone::UnboundedZone
UnboundedZone(const std::string &label)
Definition: VolumeSplitterUtils.cxx:128
InDetDD::PconZone::inZ
bool inZ(unsigned int i, double z) const
Definition: VolumeSplitterUtils.cxx:253
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
InDetDD::Zone::Zone
Zone(const std::string &label, bool rotated=false)
Definition: VolumeSplitterUtils.cxx:112
InDetDD::Ray::Ray
Ray()
Definition: VolumeSplitterUtils.cxx:316
InDetDD::Segment::rmax
double rmax() const
Definition: VolumeSplitterUtils.h:144
InDetDD::SegmentList::print
void print() const
Definition: VolumeSplitterUtils.cxx:397
InDetDD::TubeZone::inR
bool inR(double r) const
Definition: VolumeSplitterUtils.cxx:177
InDetDD::Zone::rotated
bool rotated() const
Definition: VolumeSplitterUtils.h:83
InDetDD::TubeZone::inSide
virtual bool inSide(const Point &point) const
Definition: VolumeSplitterUtils.cxx:167
InDetDD::Point::r
double r() const
Definition: VolumeSplitterUtils.h:29
InDetDD::Segment::m_rmax
double m_rmax
Definition: VolumeSplitterUtils.h:152
InDetDD::SegmentList::getSegment
const Segment & getSegment(unsigned int i) const
Definition: VolumeSplitterUtils.h:161
InDetDD::Ray::m_end
Point m_end
Definition: VolumeSplitterUtils.h:66
InDetDD::TubeZone::TubeZone
TubeZone(const std::string &label, double zmin, double zmax, double rmin, double rmax, bool rotated=false)
Definition: VolumeSplitterUtils.cxx:149
InDetDD::TubeZone::m_zmax
double m_zmax
Definition: VolumeSplitterUtils.h:114
InDetDD::Ray::vertical
bool vertical() const
Definition: VolumeSplitterUtils.h:54
InDetDD::TubeZone::m_zmin
double m_zmin
Definition: VolumeSplitterUtils.h:113
InDetDD::Ray::m_vertical
bool m_vertical
Definition: VolumeSplitterUtils.h:64
InDetDD::Ray::valid
bool valid() const
Definition: VolumeSplitterUtils.h:51
InDetDD::Ray::foundStart
bool foundStart() const
Definition: VolumeSplitterUtils.h:52
InDetDD::Point::m_valid
bool m_valid
Definition: VolumeSplitterUtils.h:36
InDetDD::SegmentSplitter::searchPoint
Ray searchPoint(const Zone *zone, const Ray &ray)
Definition: VolumeSplitterUtils.cxx:95
InDetDD::Segment::m_rotated
bool m_rotated
Definition: VolumeSplitterUtils.h:148
InDetDD::TubeZone
Definition: VolumeSplitterUtils.h:99
InDetDD::TubeZone::getZmax
virtual double getZmax() const
Definition: VolumeSplitterUtils.h:109
InDetDD::Ray::m_horizontal
bool m_horizontal
Definition: VolumeSplitterUtils.h:63
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
InDetDD::PconZone::findExit
virtual Point findExit(const Ray &ray) const
Definition: VolumeSplitterUtils.cxx:292