Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:21

0001 /* Copyright 2008-2010, Technische Universitaet Muenchen,
0002    Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 // Description:
0020 //      Detector plane - a geometric object
0021 /**
0022  *  @author Christian H&ouml;ppner (Technische Universit&auml;t M&uuml;nchen, original author)
0023  *  @author Sebastian Neubert  (Technische Universit&auml;t M&uuml;nchen, original author)
0024  *
0025  */
0026 
0027 /** @addtogroup genfit
0028  * @{
0029  */
0030 
0031 #ifndef genfit_DetPlane_h
0032 #define genfit_DetPlane_h
0033 
0034 #include "AbsFinitePlane.h"
0035 
0036 #include <TObject.h>
0037 #include <TVector3.h>
0038 
0039 #include <memory>
0040 
0041 
0042 namespace genfit {
0043 
0044 /** @brief Detector plane.
0045  *
0046  * A detector plane is the principle object to define coordinate systems for
0047  * track fitting in genfit. Since a particle trajectory is a
0048  * one-dimensional object (regardless of any specific parameterization)
0049  * positions with respect to the track are always measured in a plane.
0050  *
0051  * Which plane is chosen depends on the type of detector. Fixed plane
0052  * detectors have their detector plane defined by their mechanical setup. While
0053  * wire chambers or time projection chambers might want to define a detector
0054  * plane more flexibly.
0055  *
0056  * This class parameterizes a plane in terms of an origin vector o
0057  * and two plane-spanning directions u and v.
0058  */
0059 class DetPlane : public TObject {
0060 
0061  public:
0062 
0063 
0064   // Constructors/Destructors ---------
0065   DetPlane(AbsFinitePlane* finite = nullptr);
0066 
0067   DetPlane(const TVector3& o,
0068              const TVector3& u,
0069              const TVector3& v,
0070              AbsFinitePlane* finite = nullptr);
0071 
0072   DetPlane(const TVector3& o,
0073              const TVector3& n,
0074              AbsFinitePlane* finite = nullptr);
0075 
0076   virtual ~DetPlane();
0077 
0078   DetPlane(const DetPlane&);
0079   DetPlane& operator=(DetPlane);
0080   void swap(DetPlane& other); // nothrow
0081 
0082   // Accessors -----------------------
0083   const TVector3& getO() const {return o_;}
0084   const TVector3& getU() const {return u_;}
0085   const TVector3& getV() const {return v_;}
0086 
0087   // Modifiers -----------------------
0088   void set(const TVector3& o,
0089            const TVector3& u,
0090            const TVector3& v);
0091   void setO(const TVector3& o);
0092   void setO(double, double, double);
0093   void setU(const TVector3& u);
0094   void setU(double, double, double);
0095   void setV(const TVector3& v);
0096   void setV(double, double, double);
0097   void setUV(const TVector3& u, const TVector3& v);
0098   void setON(const TVector3& o, const TVector3& n);
0099 
0100   //! Optionally, set the finite plane definition. This is most important for
0101   //! avoiding fake intersection points in fitting of curlers. This should
0102   //! be implemented for silicon detectors most importantly.
0103   void setFinitePlane(AbsFinitePlane* finite){finitePlane_.reset(finite);}
0104 
0105   // Operations ----------------------
0106   TVector3 getNormal() const;
0107   void setNormal(const TVector3& n);
0108   void setNormal(double, double, double);
0109   void setNormal(const double& theta, const double& phi);
0110 
0111   //! projecting a direction onto the plane:
0112   TVector2 project(const TVector3& x) const;
0113 
0114   //! transform from Lab system into plane
0115   TVector2 LabToPlane(const TVector3& x) const;
0116 
0117   //! transform from plane coordinates to lab system
0118   TVector3 toLab(const TVector2& x) const;
0119 
0120   // get vector from point to plane (normal)
0121   TVector3 dist(const TVector3& point) const;
0122 
0123   //! gives u,v coordinates of the intersection point of a straight line with plane
0124   TVector2 straightLineToPlane(const TVector3& point, const TVector3& dir) const;
0125 
0126   //! gives u,v coordinates of the intersection point of a straight line with plane
0127   void straightLineToPlane(const double& posX, const double& posY, const double& posZ,
0128                            const double& dirX, const double& dirY, const double& dirZ,
0129                            double& u, double& v) const;
0130 
0131   void Print(const Option_t* = "") const;
0132 
0133   //! Checks equality of planes by comparing the 9 double values that define them.
0134   friend bool operator== (const DetPlane& lhs, const DetPlane& rhs);
0135   //! returns NOT ==
0136   friend bool operator!= (const DetPlane& lhs, const DetPlane& rhs);
0137 
0138   //! absolute distance from a point to the plane
0139   double distance(const TVector3& point) const;
0140   double distance(double, double, double) const;
0141 
0142 
0143   //! intersect in the active area? C.f. AbsFinitePlane
0144   bool isInActive(const TVector3& point, const TVector3& dir) const {
0145     if(finitePlane_.get() == nullptr) return true;
0146     return this->isInActive( this->straightLineToPlane(point,dir));
0147   }
0148 
0149   //! intersect in the active area? C.f. AbsFinitePlane
0150   bool isInActive(const double& posX, const double& posY, const double& posZ,
0151                   const double& dirX, const double& dirY, const double& dirZ) const {
0152     if(finitePlane_.get() == nullptr) return true;
0153     double u, v;
0154     this->straightLineToPlane(posX, posY, posZ, dirX, dirY, dirZ, u, v);
0155     return this->isInActive(u, v);
0156   }
0157 
0158   //! isInActive methods refer to finite plane. C.f. AbsFinitePlane
0159   bool isInActive(double u, double v) const{
0160     if(finitePlane_.get() == nullptr) return true;
0161     return finitePlane_->isInActive(u,v);
0162   }
0163 
0164   //! isInActive methods refer to finite plane. C.f. AbsFinitePlane
0165   bool isInActive(const TVector2& v) const{
0166     return isInActive(v.X(),v.Y());
0167   }
0168 
0169   bool isFinite() const {
0170     return (finitePlane_.get() != nullptr);
0171   }
0172 
0173   //! rotate u and v around normal. Angle is in rad. More for debugging than for actual use.
0174   void rotate(double angle);
0175 
0176   //! delete finitePlane_ and set O, U, V to default values
0177   void reset();
0178 
0179  private:
0180   // Private Methods -----------------
0181   //! ensures orthonormal coordinates
0182   void sane();
0183 
0184   TVector3 o_;
0185   TVector3 u_;
0186   TVector3 v_;
0187 
0188   std::unique_ptr<AbsFinitePlane> finitePlane_; // Ownership
0189 
0190  public:
0191   ClassDef(DetPlane,1)
0192 
0193 };
0194 
0195 } /* End of namespace genfit */
0196 /** @} */
0197 
0198 #endif // genfit_DetPlane_h