Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-18 23:17:57

0001 #ifndef DTSegment_DTSegmentCand_h
0002 #define DTSegment_DTSegmentCand_h
0003 
0004 /** \class DTSegmentCand
0005  *
0006  * A Candidate for a DT segment. It's used by the algorithm to build segments
0007  * and store relative information. It must be transformed into a DTSegment
0008  * for further use.
0009  *
0010  * \author Stefano Lacaprara - INFN Legnaro <stefano.lacaprara@pd.infn.it>
0011  * \author Riccardo Bellan - INFN TO <riccardo.bellan@cern.ch>
0012  *
0013  */
0014 
0015 /* Base Class Headers */
0016 
0017 /* Collaborating Class Declarations */
0018 #include "RecoLocalMuon/DTSegment/src/DTHitPairForFit.h"
0019 
0020 /* C++ Headers */
0021 #include <vector>
0022 #include <set>
0023 #include <iostream>
0024 
0025 /* ====================================================================== */
0026 
0027 /* Class DTSegmentCand Interface */
0028 
0029 class DTSLRecSegment2D;
0030 class DTChamberRecSegment2D;
0031 class DTChamber;
0032 class DTSuperLayer;
0033 
0034 class DTSegmentCand {
0035 public:
0036   struct AssPointLessZ;
0037   typedef std::pair<std::shared_ptr<DTHitPairForFit>, DTEnums::DTCellSide> AssPoint;
0038   typedef std::set<AssPoint, AssPointLessZ> AssPointCont;
0039 
0040   /// Constructor
0041   DTSegmentCand(AssPointCont& hits, const DTSuperLayer* sl);
0042 
0043   DTSegmentCand(const AssPointCont& hits,
0044                 LocalPoint& position,
0045                 LocalVector& direction,
0046                 double chi2,
0047                 const AlgebraicSymMatrix& covMat,
0048                 const DTSuperLayer* sl);
0049 
0050   /// Destructor
0051   virtual ~DTSegmentCand();
0052 
0053   /* Operations */
0054   virtual bool good() const;
0055 
0056   virtual bool hitsShareLayer() const;
0057 
0058   virtual unsigned int nHits() const { return theHits.size(); }
0059 
0060   /// the chi2 (NOT chi2/NDOF) of the fit
0061   virtual double chi2() const { return theChi2; }
0062 
0063   /// the chi2/NDOF of the fit
0064   virtual double chi2ndof() const { return theChi2 / (nHits() - 2.); }
0065 
0066   /// the t0 of the segment
0067   virtual double t0() const { return thet0; }
0068 
0069   /// equality operator based on position, direction, chi2 and nHits
0070   virtual bool operator==(const DTSegmentCand& seg) const;
0071 
0072   /// less operator based on nHits and chi2
0073   virtual bool operator<(const DTSegmentCand& seg) const;
0074 
0075   /// the super layer on which relies
0076   const DTSuperLayer* superLayer() const { return theSL; }
0077 
0078   // in SL frame
0079   virtual LocalPoint position() const { return thePosition; }
0080 
0081   // in SL frame
0082   virtual LocalVector direction() const { return theDirection; }
0083 
0084   /// the covariance matrix
0085   virtual AlgebraicSymMatrix covMatrix() const { return theCovMatrix; }
0086 
0087   virtual unsigned int NDOF() const { return nHits() - 2; }
0088 
0089   ///set position
0090   virtual void setPosition(LocalPoint& pos) { thePosition = pos; }
0091 
0092   /// set direction
0093   virtual void setDirection(LocalVector& dir) { theDirection = dir; }
0094 
0095   /// add hits to the hit list.
0096   virtual void add(AssPoint newHit);
0097   virtual void add(std::shared_ptr<DTHitPairForFit> hit, DTEnums::DTCellSide code);
0098 
0099   /// remove hit from the candidate
0100   virtual void removeHit(AssPoint hit);
0101 
0102   /// set chi2
0103   virtual void setChi2(double& chi2) { theChi2 = chi2; }
0104 
0105   /// set t0
0106   virtual void sett0(double& t0) { thet0 = t0; }
0107 
0108   /// number of shared hit pair with other segment candidate
0109   virtual int nSharedHitPairs(const DTSegmentCand& seg) const;
0110 
0111   /** return the hits shared with other segment and with confliction L/R
0112      * assignment */
0113   virtual AssPointCont conflictingHitPairs(const DTSegmentCand& seg) const;
0114 
0115   /// set the cov matrix
0116   virtual void setCovMatrix(AlgebraicSymMatrix& cov) { theCovMatrix = cov; }
0117 
0118   /// number of different layers with hits
0119   virtual int nLayers() const;
0120 
0121   /// the used hits
0122   virtual const AssPointCont& hits() const { return theHits; }
0123 
0124   /// convert this DTSegmentCand into a DTRecSegment2D
0125   //  DTSLRecSegment2D* convert() const;
0126   operator DTSLRecSegment2D*() const;
0127 
0128   /// convert this DTSegmentCand into a DTChamberRecSegment2D
0129   operator DTChamberRecSegment2D*() const;
0130 
0131   struct AssPointLessZ {
0132   public:
0133     bool operator()(const AssPoint& pt1, const AssPoint& pt2) const;
0134   };
0135 
0136 private:
0137   const DTSuperLayer* theSL;  // the SL
0138   LocalPoint thePosition;     // in SL frame
0139   LocalVector theDirection;   // in SL frame
0140   double theChi2;             // chi2 of the fit
0141   double thet0;               // the t0 offset
0142 
0143   /// mat[1][1]=sigma (dx/dz)
0144   /// mat[2][2]=sigma (x)
0145   /// mat[1][2]=cov(dx/dz,x)
0146   AlgebraicSymMatrix theCovMatrix;  // the covariance matrix
0147 
0148   AssPointCont theHits;  // the used hits
0149 
0150 protected:
0151   static const double chi2max;         // to be tuned!!
0152   static const unsigned int nHitsMin;  // to be tuned!!
0153 };
0154 
0155 std::ostream& operator<<(std::ostream& out, const DTSegmentCand& seg);
0156 std::ostream& operator<<(std::ostream& out, const DTSegmentCand::AssPoint& hit);
0157 #endif  // DTSegment_DTSegmentCand_h