PandaRoot
DetPlane.h
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 // Description:
20 // Detector plane - a geometric object
31 #ifndef genfit_DetPlane_h
32 #define genfit_DetPlane_h
33 
34 #include "AbsFinitePlane.h"
35 
36 #include <TObject.h>
37 #include <TVector3.h>
38 
39 #ifndef __CINT__
40 #include <boost/scoped_ptr.hpp>
41 #endif
42 
43 namespace genfit {
44 
60 class DetPlane : public TObject {
61 
62  public:
63  // Constructors/Destructors ---------
64  DetPlane(AbsFinitePlane *finite = nullptr);
65 
66  DetPlane(const TVector3 &o, const TVector3 &u, const TVector3 &v, AbsFinitePlane *finite = nullptr);
67 
68  DetPlane(const TVector3 &o, const TVector3 &n, AbsFinitePlane *finite = nullptr);
69 
70  virtual ~DetPlane();
71 
72  DetPlane(const DetPlane &);
74  void swap(DetPlane &other); // nothrow
75 
76  // Accessors -----------------------
77  const TVector3 &getO() const { return o_; }
78  const TVector3 &getU() const { return u_; }
79  const TVector3 &getV() const { return v_; }
80 
81  // Modifiers -----------------------
82  void set(const TVector3 &o, const TVector3 &u, const TVector3 &v);
83  void setO(const TVector3 &o);
84  void setO(double, double, double);
85  void setU(const TVector3 &u);
86  void setU(double, double, double);
87  void setV(const TVector3 &v);
88  void setV(double, double, double);
89  void setUV(const TVector3 &u, const TVector3 &v);
90  void setON(const TVector3 &o, const TVector3 &n);
91 
95  void setFinitePlane(AbsFinitePlane *finite) { finitePlane_.reset(finite); }
96 
97  // Operations ----------------------
98  TVector3 getNormal() const;
99  void setNormal(const TVector3 &n);
100  void setNormal(double, double, double);
101  void setNormal(const double &theta, const double &phi);
102 
104  TVector2 project(const TVector3 &x) const;
105 
107  TVector2 LabToPlane(const TVector3 &x) const;
108 
110  TVector3 toLab(const TVector2 &x) const;
111 
112  // get vector from point to plane (normal)
113  TVector3 dist(const TVector3 &point) const;
114 
116  TVector2 straightLineToPlane(const TVector3 &point, const TVector3 &dir) const;
117 
119  void straightLineToPlane(const double &posX, const double &posY, const double &posZ, const double &dirX, const double &dirY, const double &dirZ, double &u, double &v) const;
120 
121  void Print(const Option_t * = "") const;
122 
124  friend bool operator==(const DetPlane &lhs, const DetPlane &rhs);
126  friend bool operator!=(const DetPlane &lhs, const DetPlane &rhs);
127 
129  double distance(const TVector3 &point) const;
130  double distance(double, double, double) const;
131 
133  bool isInActive(const TVector3 &point, const TVector3 &dir) const
134  {
135  if (finitePlane_.get() == nullptr)
136  return true;
137  return this->isInActive(this->straightLineToPlane(point, dir));
138  }
139 
141  bool isInActive(const double &posX, const double &posY, const double &posZ, const double &dirX, const double &dirY, const double &dirZ) const
142  {
143  if (finitePlane_.get() == nullptr)
144  return true;
145  double u, v;
146  this->straightLineToPlane(posX, posY, posZ, dirX, dirY, dirZ, u, v);
147  return this->isInActive(u, v);
148  }
149 
151  bool isInActive(double u, double v) const
152  {
153  if (finitePlane_.get() == nullptr)
154  return true;
155  return finitePlane_->isInActive(u, v);
156  }
157 
159  bool isInActive(const TVector2 &v) const { return isInActive(v.X(), v.Y()); }
160 
161  bool isFinite() const { return (finitePlane_.get() != nullptr); }
162 
164  void rotate(double angle);
165 
167  void reset();
168 
169  private:
170  // Private Methods -----------------
172  void sane();
173 
174  TVector3 o_;
175  TVector3 u_;
176  TVector3 v_;
177 
178 #ifndef __CINT__
179  boost::scoped_ptr<AbsFinitePlane> finitePlane_; // Ownership
180 #else
181  class AbsFinitePlane *finitePlane_;
182 #endif
183 
184  public:
185  ClassDef(DetPlane, 1)
186 };
187 
188 } /* End of namespace genfit */
191 #endif // genfit_DetPlane_h
void setNormal(const TVector3 &n)
void setU(const TVector3 &u)
void setON(const TVector3 &o, const TVector3 &n)
TVector2 LabToPlane(const TVector3 &x) const
transform from Lab system into plane
Detector plane.
Definition: DetPlane.h:60
virtual ~DetPlane()
DetPlane(AbsFinitePlane *finite=nullptr)
double distance(const TVector3 &point) const
absolute distance from a point to the plane
const TVector3 & getV() const
Definition: DetPlane.h:79
Abstract base class for finite detector planes.
__m128 v
Definition: P4_F32vec4.h:3
TVector3 getNormal() const
friend bool operator==(const DetPlane &lhs, const DetPlane &rhs)
Checks equality of planes by comparing the 9 double values that define them.
bool isFinite() const
Definition: DetPlane.h:161
bool isInActive(const double &posX, const double &posY, const double &posZ, const double &dirX, const double &dirY, const double &dirZ) const
intersect in the active area? C.f. AbsFinitePlane
Definition: DetPlane.h:141
TVector3 dist(const TVector3 &point) const
void swap(DetPlane &other)
void setV(const TVector3 &v)
DetPlane & operator=(DetPlane)
void setUV(const TVector3 &u, const TVector3 &v)
bool isInActive(double u, double v) const
isInActive methods refer to finite plane. C.f. AbsFinitePlane
Definition: DetPlane.h:151
void setFinitePlane(AbsFinitePlane *finite)
Definition: DetPlane.h:95
void reset()
delete finitePlane_ and set O, U, V to default values
TVector3 toLab(const TVector2 &x) const
transform from plane coordinates to lab system
const TVector3 & getU() const
Definition: DetPlane.h:78
friend bool operator!=(const DetPlane &lhs, const DetPlane &rhs)
returns NOT ==
bool isInActive(const TVector2 &v) const
isInActive methods refer to finite plane. C.f. AbsFinitePlane
Definition: DetPlane.h:159
void setO(const TVector3 &o)
bool isInActive(const TVector3 &point, const TVector3 &dir) const
intersect in the active area? C.f. AbsFinitePlane
Definition: DetPlane.h:133
TVector2 project(const TVector3 &x) const
projecting a direction onto the plane:
void rotate(double angle)
rotate u and v around normal. Angle is in rad. More for debugging than for actual use...
const TVector3 & getO() const
Definition: DetPlane.h:77
TVector2 straightLineToPlane(const TVector3 &point, const TVector3 &dir) const
gives u,v coordinates of the intersection point of a straight line with plane
void Print(const Option_t *="") const
Matrix inversion tools.
Definition: AbsBField.h:28