CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/RecoLocalMuon/CSCSegment/src/CSCSegAlgoTC.h

Go to the documentation of this file.
00001 #ifndef CSCSegment_CSCSegAlgoTC_h
00002 #define CSCSegment_CSCSegAlgoTC_h
00003 
00027 #include <RecoLocalMuon/CSCSegment/src/CSCSegmentAlgorithm.h>
00028 
00029 #include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
00030 
00031 #include <deque>
00032 #include <vector>
00033 
00034 
00035 class CSCSegAlgoTC : public CSCSegmentAlgorithm {
00036  public:
00037   
00038   // Tim tried using map as basic container of all (space-point) RecHit's in a chamber:
00039   // The 'key' is a pseudo-layer number (1-6 but with 1 always closest to IP).
00040   // The 'value' is a vector of the RecHit's on that layer.
00041   // Using the layer number like this removes the need to sort in global z.
00042   // Instead we just have to ensure the layer index is correctly adjusted 
00043   // to enforce the requirement that 'layer 1' is closest in the chamber
00044   // to the IP.
00045   // However a map is very painful to use when handling the original 'SK' algorithm,
00046   // particularly when we need to flag a hit as 'used'. Because of this I am now
00047   // favouring a pair of vectors, vector<RecHit> and vector<int> for the layer id.
00048   
00050   typedef std::vector<int> LayerIndex;
00051   typedef std::vector<const CSCRecHit2D*> ChamberHitContainer;
00052   typedef ChamberHitContainer::const_iterator ChamberHitContainerCIt;
00053   
00054   // We need to be able to flag a hit as 'used' and so need a container
00055   // of bool's. Naively, this would be vector<bool>... but AVOID that since it's
00056   // non-standard i.e. packed-bit implementation which is not a standard STL container. 
00057   // We don't need what it offers and it could lead to unexpected trouble in the future
00058   
00059   typedef std::deque<bool> BoolContainer;
00060   
00062   explicit CSCSegAlgoTC(const edm::ParameterSet& ps);
00064   virtual ~CSCSegAlgoTC() {};
00065   
00070   std::vector<CSCSegment> buildSegments(ChamberHitContainer rechits);
00071   
00075   std::vector<CSCSegment> run(const CSCChamber* aChamber, ChamberHitContainer rechits);
00076   
00077  private:
00078   
00080   
00081   bool addHit(const CSCRecHit2D* aHit, int layer);
00082   bool replaceHit(const CSCRecHit2D* h, int layer);
00083   void compareProtoSegment(const CSCRecHit2D* h, int layer);
00084   void increaseProtoSegment(const CSCRecHit2D* h, int layer);
00085   AlgebraicSymMatrix calculateError() const;
00086   CLHEP::HepMatrix derivativeMatrix() const;
00087   AlgebraicSymMatrix weightMatrix() const;
00088   void flipErrors(AlgebraicSymMatrix&) const;
00089   
00093   bool areHitsCloseInLocalX(const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
00094   
00098   bool areHitsCloseInGlobalPhi(const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
00099   
00100   bool hasHitOnLayer(int layer) const;
00101   
00108   bool isHitNearSegment(const CSCRecHit2D* h) const;
00109   
00113   void dumpHits(const ChamberHitContainer& rechits) const;
00114   
00118   void tryAddingHitsToSegment(const ChamberHitContainer& rechits, 
00119                               const ChamberHitContainerCIt i1, 
00120                               const ChamberHitContainerCIt i2);
00121   
00127   bool isSegmentGood(std::vector<ChamberHitContainer>::iterator is, 
00128                      std::vector<double>::iterator ichi,
00129                      const ChamberHitContainer& rechitsInChamber,  
00130                      BoolContainer& used) const;
00131   
00135   void flagHitsAsUsed(std::vector<ChamberHitContainer>::iterator is, 
00136                       const ChamberHitContainer& rechitsInChamber, BoolContainer& used) const;
00137   
00142   void pruneTheSegments(const ChamberHitContainer& rechitsInChamber);
00146   void segmentSort();  
00147   
00148   float phiAtZ(float z) const;  
00149   void fillLocalDirection();
00150   void fillChiSquared();
00151   void fitSlopes();
00152   void updateParameters();
00153   
00155   // ================
00156   
00157   const CSCChamber* theChamber;
00158   std::vector<ChamberHitContainer> candidates;
00159   std::vector<LocalPoint> origins;
00160   std::vector<LocalVector> directions;
00161   std::vector<AlgebraicSymMatrix> errors;
00162   std::vector<double> chi2s;
00163 
00164   ChamberHitContainer proto_segment;
00165   double theChi2;
00166   LocalPoint theOrigin;
00167   LocalVector theDirection;
00168   float uz, vz;
00169   
00172   float chi2Max;
00173   
00177   float chi2ndfProbMin;
00178 
00182   float dRPhiFineMax;
00183   
00187   float dPhiFineMax;
00188   
00192   float dRPhiMax;
00193   
00196   float dPhiMax;
00197   
00200   int minLayersApart;
00201   
00208   int SegmentSorting;
00209 
00212   const std::string myName;
00213   bool debugInfo;
00214 };
00215 
00216 #endif