Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:39

0001 /****************************************************************************
0002 *
0003 * This is a part of TOTEM offline software.
0004 * Authors: 
0005 *   Jan Kašpar (jan.kaspar@gmail.com) 
0006 *
0007 ****************************************************************************/
0008 
0009 #ifndef RecoPPS_Local_FastLineRecognition
0010 #define RecoPPS_Local_FastLineRecognition
0011 
0012 #include "DataFormats/Common/interface/DetSet.h"
0013 #include "DataFormats/Common/interface/DetSetVector.h"
0014 
0015 #include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h"
0016 #include "DataFormats/CTPPSDetId/interface/TotemRPDetId.h"
0017 #include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h"
0018 #include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h"
0019 
0020 /**
0021  * \brief Class performing optimized hough transform to recognize lines.
0022 **/
0023 
0024 class FastLineRecognition {
0025 public:
0026   FastLineRecognition(double cw_a = 0., double cw_b = 0.);
0027 
0028   ~FastLineRecognition();
0029 
0030   void resetGeometry(const CTPPSGeometry *_g) {
0031     geometry = _g;
0032     geometryMap.clear();
0033   }
0034 
0035   void getPatterns(const edm::DetSetVector<TotemRPRecHit> &input,
0036                    double _z0,
0037                    double threshold,
0038                    edm::DetSet<TotemRPUVPattern> &patterns);
0039 
0040 private:
0041   /// the uncertainty of 1-hit cluster, in mm
0042   static const double sigma0;
0043 
0044   /// "typical" z
0045   double z0;
0046 
0047   /// cluster half widths in a and b
0048   double chw_a, chw_b;
0049 
0050   /// weight threshold for accepting pattern candidates (clusters)
0051   double threshold;
0052 
0053   /// pointer to the geometry
0054   const CTPPSGeometry *geometry;
0055 
0056   struct GeomData {
0057     double z;  ///< z position of a sensor (wrt. IP)
0058     double s;  ///< sensor's centre projected to its read-out direction
0059   };
0060 
0061   /// map: raw detector id --> GeomData
0062   std::map<unsigned int, GeomData> geometryMap;
0063 
0064   /// expects raw detector id
0065   GeomData getGeomData(unsigned int id);
0066 
0067   struct Point {
0068     unsigned int detId;        ///< raw detector id
0069     const TotemRPRecHit *hit;  ///< pointer to original reco hit
0070     double h;                  ///< hit position in global coordinate system
0071     double z;                  ///< z position with respect to z0
0072     double w;                  ///< weight
0073     bool usable;               ///< whether the point can still be used
0074     Point(unsigned int _d = 0, const TotemRPRecHit *_hit = nullptr, double _h = 0., double _z = 0., double _w = 0.)
0075         : detId(_d), hit(_hit), h(_h), z(_z), w(_w), usable(true) {}
0076   };
0077 
0078   /// cluster of intersection points
0079   struct Cluster {
0080     double Saw, Sbw, Sw, S1;
0081     double weight;
0082 
0083     std::vector<const Point *> contents;
0084 
0085     Cluster() : Saw(0.), Sbw(0.), Sw(0.), S1(0.), weight(0.) {}
0086 
0087     void add(const Point *p1, const Point *p2, double a, double b, double w);
0088 
0089     bool operator<(const Cluster &c) const { return (this->Sw > c.Sw) ? true : false; }
0090   };
0091 
0092   /// gets the most significant pattern in the (remaining) points
0093   /// returns true when a pattern was found
0094   bool getOneLine(const std::vector<Point> &points, double threshold, Cluster &result);
0095 };
0096 
0097 #endif