Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:59

0001 /*!
0002  *  \file       PlanarMeasurement.cc
0003  *  \brief      Handles the palnar type of measurements.
0004  *  \author     Haiwang Yu <yuhw@nmsu.edu>
0005  */
0006 
0007 #include "PlanarMeasurement.h"
0008 
0009 #include <GenFit/DetPlane.h>
0010 #include <GenFit/PlanarMeasurement.h>
0011 #include <GenFit/SharedPlanePtr.h>  // for SharedPlanePtr
0012 #include <GenFit/StateOnPlane.h>
0013 
0014 #include <TMatrixDSymfwd.h>  // for TMatrixDSym
0015 #include <TMatrixTSym.h>     // for TMatrixTSym
0016 #include <TVector3.h>
0017 #include <TVectorDfwd.h>  // for TVectorD
0018 #include <TVectorT.h>     // for TVectorT
0019 
0020 namespace PHGenFit
0021 {
0022   void PlanarMeasurement::init(const TVector3& pos, const TVector3& u, const TVector3& v, const double du, const double dv)
0023   {
0024     int nDim = 2;
0025     TVectorD hitCoords(nDim);
0026     TMatrixDSym hitCov(nDim);
0027 
0028     hitCoords(0) = 0;
0029     hitCoords(1) = 0;
0030 
0031     hitCov(0, 0) = du * du;
0032     hitCov(1, 1) = dv * dv;
0033 
0034     genfit::SharedPlanePtr plane(
0035         new genfit::DetPlane(pos, u, v));
0036 
0037     int measurementCounter_ = 0;
0038     _measurement = new genfit::PlanarMeasurement(hitCoords, hitCov, -1,
0039                                                  measurementCounter_,
0040                                                  nullptr);
0041 
0042     static_cast<genfit::PlanarMeasurement*>(_measurement)->setPlane(plane, measurementCounter_);
0043   }
0044 
0045   PlanarMeasurement::PlanarMeasurement(const TVector3& pos, const TVector3& u, const TVector3& v, const double du, const double dv)
0046   {
0047     init(pos, u, v, du, dv);
0048   }
0049 
0050   PlanarMeasurement::PlanarMeasurement(const TVector3& pos, const TVector3& n, const double du, const double dv)
0051   {
0052     /*!
0053      *  Mainly for "n" in xy plane, or n.z() = 0;
0054      *  In this case, According to https://root.cern.ch/doc/master/TVector3_8h_source.html#l00301
0055      *  u = n.Orthogonal() is always in xy plane
0056      *  v = n x u, is along z direction.
0057      *  If z is not 0, but z <= x or y, then u will still be in xy plane, phi direction error, but v will not be along z axis.
0058      */
0059     TVector3 u = n.Orthogonal();
0060     TVector3 v = n.Cross(u);
0061     init(pos, u, v, du, dv);
0062   }
0063 
0064 }  // namespace PHGenFit