Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:33

0001 #ifndef _ClosestApproachInRPhi_H_
0002 #define _ClosestApproachInRPhi_H_
0003 
0004 #include "TrackingTools/PatternTools/interface/ClosestApproachOnHelices.h"
0005 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
0006 #include "FWCore/Utilities/interface/Visibility.h"
0007 
0008 /** Given two trajectory states, computes the two points of closest approach 
0009  *  in the transverse plane for the helices extrapolated from these states. 
0010  *  1) computes the intersections of the circles in transverse plane. 
0011  *     Two cases: - circles have one or two intersection points; 
0012  *                - circles do not cross; the points used are 
0013  *                  the points of closest approach of the two circles. 
0014  *  2) computes the corresponding z-coordinates. In the case where 
0015  *     the circles have two intersections, the point for which 
0016  *     the z-coordinates on the 2 tracks are the closest is chosen. 
0017  */
0018 
0019 // Function for testing ClosestApproachInRPhi
0020 namespace test {
0021   namespace ClosestApproachInRPhi_t {
0022     int test();
0023   }
0024 }  // namespace test
0025 
0026 class ClosestApproachInRPhi final : public ClosestApproachOnHelices {
0027   friend int test::ClosestApproachInRPhi_t::test();
0028 
0029 public:
0030   ClosestApproachInRPhi() { status_ = false; }
0031   ~ClosestApproachInRPhi() override {}
0032 
0033   bool calculate(const TrajectoryStateOnSurface& sta, const TrajectoryStateOnSurface& stb) override;
0034 
0035   bool calculate(const FreeTrajectoryState& sta, const FreeTrajectoryState& stb) override;
0036 
0037   bool status() const override { return status_; }
0038 
0039   /**
0040    * Returns the two PCA on the trajectories.
0041    */
0042   std::pair<GlobalPoint, GlobalPoint> points() const override;
0043 
0044   /** Returns not only the points, but the full GlobalTrajectoryParemeters 
0045    *  at the points of closest approach */
0046   std::pair<GlobalTrajectoryParameters, GlobalTrajectoryParameters> trajectoryParameters() const;
0047 
0048   /** arithmetic mean of the two points of closest approach */
0049   GlobalPoint crossingPoint() const override;
0050 
0051   /** distance between the two points of closest approach in 3D */
0052   float distance() const override;
0053 
0054   /**
0055    *  Clone method
0056    */
0057   ClosestApproachInRPhi* clone() const override { return new ClosestApproachInRPhi(*this); }
0058 
0059 private:
0060   bool compute(const TrackCharge& chargeA,
0061                const GlobalVector& momentumA,
0062                const GlobalPoint& positionA,
0063                const TrackCharge& chargeB,
0064                const GlobalVector& momentumB,
0065                const GlobalPoint& positionB) dso_internal;
0066 
0067   // given the old Parameters, and a new GlobalPoint,
0068   // we return the full new GlobalTrajectoryParameters at the
0069   // Point.
0070   static GlobalTrajectoryParameters newTrajectory(const GlobalPoint& newpt,
0071                                                   const GlobalTrajectoryParameters& oldpar,
0072                                                   double bz) dso_internal;
0073 
0074   // Computes center coordinates and unsigned radius of circle;
0075   static void circleParameters(const TrackCharge& charge,
0076                                const GlobalVector& momemtum,
0077                                const GlobalPoint& position,
0078                                double& xc,
0079                                double& yc,
0080                                double& r,
0081                                double bz) dso_internal;
0082 
0083   // Computes crossing points of 2 circles with centres (cx_i, cy_i)
0084   // and unsigned radii r_i.
0085   // Two cases: - circles have one or two intersection points;
0086   //              return value = 1;
0087   //            - circles do not cross; computes point of closest approach
0088   //              on each circle; return value = 2;
0089   // if the calculation fails (e.g. concentric circles), return value = 0;
0090 
0091   static int transverseCoord(double cxa,
0092                              double cya,
0093                              double ra,
0094                              double cxb,
0095                              double cyb,
0096                              double rb,
0097                              double& xg1,
0098                              double& yg1,
0099                              double& xg2,
0100                              double& yg2) dso_internal;
0101 
0102   // Computes z-coordinate on helix at given transverse coordinates
0103   static double zCoord(const GlobalVector& mom,
0104                        const GlobalPoint& pos,
0105                        double r,
0106                        double xc,
0107                        double yc,
0108                        double xg,
0109                        double yg) dso_internal;
0110 
0111 private:
0112   GlobalPoint posA, posB;
0113   GlobalTrajectoryParameters paramA, paramB;
0114   double bz;
0115   bool status_;
0116 };
0117 
0118 #endif