EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetPlane.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetPlane.h
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 #include <memory>
40 
41 
42 namespace genfit {
43 
59 class DetPlane : public TObject {
60 
61  public:
62 
63 
64  // Constructors/Destructors ---------
65  DetPlane(AbsFinitePlane* finite = nullptr);
66 
67  DetPlane(const TVector3& o,
68  const TVector3& u,
69  const TVector3& v,
70  AbsFinitePlane* finite = nullptr);
71 
72  DetPlane(const TVector3& o,
73  const TVector3& n,
74  AbsFinitePlane* finite = nullptr);
75 
76  virtual ~DetPlane();
77 
78  DetPlane(const DetPlane&);
80  void swap(DetPlane& other); // nothrow
81 
82  // Accessors -----------------------
83  const TVector3& getO() const {return o_;}
84  const TVector3& getU() const {return u_;}
85  const TVector3& getV() const {return v_;}
86 
87  // Modifiers -----------------------
88  void set(const TVector3& o,
89  const TVector3& u,
90  const TVector3& v);
91  void setO(const TVector3& o);
92  void setO(double, double, double);
93  void setU(const TVector3& u);
94  void setU(double, double, double);
95  void setV(const TVector3& v);
96  void setV(double, double, double);
97  void setUV(const TVector3& u, const TVector3& v);
98  void setON(const TVector3& o, const TVector3& n);
99 
103  void setFinitePlane(AbsFinitePlane* finite){finitePlane_.reset(finite);}
104 
105  // Operations ----------------------
106  TVector3 getNormal() const;
107  void setNormal(const TVector3& n);
108  void setNormal(double, double, double);
109  void setNormal(const double& theta, const double& phi);
110 
112  TVector2 project(const TVector3& x) const;
113 
115  TVector2 LabToPlane(const TVector3& x) const;
116 
118  TVector3 toLab(const TVector2& x) const;
119 
120  // get vector from point to plane (normal)
121  TVector3 dist(const TVector3& point) const;
122 
124  TVector2 straightLineToPlane(const TVector3& point, const TVector3& dir) const;
125 
127  void straightLineToPlane(const double& posX, const double& posY, const double& posZ,
128  const double& dirX, const double& dirY, const double& dirZ,
129  double& u, double& v) const;
130 
131  void Print(const Option_t* = "") const;
132 
134  friend bool operator== (const DetPlane& lhs, const DetPlane& rhs);
136  friend bool operator!= (const DetPlane& lhs, const DetPlane& rhs);
137 
139  double distance(const TVector3& point) const;
140  double distance(double, double, double) const;
141 
142 
144  bool isInActive(const TVector3& point, const TVector3& dir) const {
145  if(finitePlane_.get() == nullptr) return true;
146  return this->isInActive( this->straightLineToPlane(point,dir));
147  }
148 
150  bool isInActive(const double& posX, const double& posY, const double& posZ,
151  const double& dirX, const double& dirY, const double& dirZ) const {
152  if(finitePlane_.get() == nullptr) return true;
153  double u, v;
154  this->straightLineToPlane(posX, posY, posZ, dirX, dirY, dirZ, u, v);
155  return this->isInActive(u, v);
156  }
157 
159  bool isInActive(double u, double v) const{
160  if(finitePlane_.get() == nullptr) return true;
161  return finitePlane_->isInActive(u,v);
162  }
163 
165  bool isInActive(const TVector2& v) const{
166  return isInActive(v.X(),v.Y());
167  }
168 
169  bool isFinite() const {
170  return (finitePlane_.get() != nullptr);
171  }
172 
174  void rotate(double angle);
175 
177  void reset();
178 
179  private:
180  // Private Methods -----------------
182  void sane();
183 
184  TVector3 o_;
185  TVector3 u_;
186  TVector3 v_;
187 
188  std::unique_ptr<AbsFinitePlane> finitePlane_; // Ownership
189 
190  public:
191  ClassDef(DetPlane,1)
192 
193 };
194 
195 } /* End of namespace genfit */
198 #endif // genfit_DetPlane_h