CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoLocalMuon/DTSegment/src/DTCombinatorialPatternReco.h

Go to the documentation of this file.
00001 #ifndef DTSegment_DTCombinatorialPatternReco_h
00002 #define DTSegment_DTCombinatorialPatternReco_h
00003 
00015 /* Base Class Headers */
00016 #include "RecoLocalMuon/DTSegment/src/DTRecSegment2DBaseAlgo.h"
00017 #include <boost/unordered_set.hpp>
00018 
00019 /* Collaborating Class Declarations */
00020 namespace edm {
00021   class ParameterSet;
00022   class EventSetup;
00023   //  class ESHandle;
00024 }
00025 class DTSegmentUpdator;
00026 class DTSegmentCleaner;
00027 class DTHitPairForFit;
00028 class DTSegmentCand;
00029 
00030 /* C++ Headers */
00031 #include <vector>
00032 #include <deque>
00033 #include <utility>
00034 
00035 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00036 #include "FWCore/Framework/interface/ESHandle.h"
00037 
00038 /* ====================================================================== */
00039 
00040 /* Class DTCombinatorialPatternReco Interface */
00041 
00042 class DTCombinatorialPatternReco : public DTRecSegment2DBaseAlgo {
00043 
00044   public:
00045 
00047     DTCombinatorialPatternReco(const edm::ParameterSet& pset) ;
00048 
00050     virtual ~DTCombinatorialPatternReco() ;
00051 
00052     /* Operations */
00053 
00055     virtual edm::OwnVector<DTSLRecSegment2D>
00056       reconstruct(const DTSuperLayer* sl,
00057                   const std::vector<DTRecHit1DPair>& hits);
00058 
00060     virtual std::string algoName() const { return theAlgoName; }
00061 
00064     virtual void setES(const edm::EventSetup& setup);
00065 
00066   protected:
00067 
00068   private:
00069     friend class DTCombinatorialPatternReco4D;
00070 
00071     typedef std::pair<DTHitPairForFit*, DTEnums::DTCellSide> AssPoint;
00072 
00073     // create the DTHitPairForFit from the pairs for easy use
00074     std::vector<DTHitPairForFit*> initHits(const DTSuperLayer* sl,
00075                                            const std::vector<DTRecHit1DPair>& hits);
00076 
00077     // search for candidate, starting from pairs of hits in different layers
00078     std::vector<DTSegmentCand*> buildSegments(const DTSuperLayer* sl,
00079                                               const std::vector<DTHitPairForFit*>& hits);
00080 
00081     // find all the hits compatible with the candidate
00082     std::vector<AssPoint> findCompatibleHits(const LocalPoint& pos,
00083                                              const LocalVector& dir,
00084                                              const std::vector<DTHitPairForFit*>& hits);
00085 
00086     // build segments from hits collection
00087     DTSegmentCand* buildBestSegment(std::vector<AssPoint>& assHits,
00088                                     const DTSuperLayer* sl) ;
00089 
00090     bool checkDoubleCandidates(std::vector<DTSegmentCand*>& segs,
00091                                DTSegmentCand* seg);
00092 
00095     void buildPointsCollection(std::vector<AssPoint>& points, 
00096                                std::deque<DTHitPairForFit* >& pointsNoLR,
00097                                std::vector<DTSegmentCand*>& candidates,
00098                                const DTSuperLayer* sl);
00099   private:
00100 
00101     std::string theAlgoName;
00102     unsigned int theMaxAllowedHits;
00103     double theAlphaMaxTheta;
00104     double theAlphaMaxPhi;
00105     bool debug;
00106     bool usePairs;
00107     DTSegmentUpdator* theUpdator; // the updator and fitter
00108     DTSegmentCleaner* theCleaner; // the cleaner
00109 
00110     edm::ESHandle<DTGeometry> theDTGeometry; // the DT geometry
00111 
00112   public:
00113     // The type must be public, as otherwise the global 'hash_value' function can't locate it
00114     class TriedPattern {
00115         public:
00116             typedef std::vector<short unsigned int> values;
00117             
00118             // empty costructor
00119             TriedPattern() : hash_(1) { values_.reserve(8); }
00120 
00121             // equality operator
00122             bool operator==(const TriedPattern & other) const { 
00123                 return (hash_ == other.hash_) &&   // cheap
00124                        (values_ == other.values_); // expensive last resort
00125             }
00126 
00128             void push_back(short unsigned int i) { 
00129                 boost::hash_combine(hash_,i);
00130                 values_.push_back(i);
00131             }
00134             size_t hash() const { return hash_; }
00135 
00136             // some extra methods to look like a std::vector
00137             typedef values::const_iterator const_iterator;
00138             const_iterator begin() const { return values_.begin(); }
00139             const_iterator end() const { return values_.end(); }
00140             values::size_type size() const { return values_.size(); }
00141         private:
00142             values values_;
00143             size_t hash_;
00144     };
00145     typedef boost::unordered_set<TriedPattern> TriedPatterns;
00146  private:
00147 
00148     TriedPatterns theTriedPattern;
00149 };
00150 
00151 inline std::size_t hash_value(const DTCombinatorialPatternReco::TriedPattern &t) { return t.hash(); }
00152 #endif // DTSegment_DTCombinatorialPatternReco_h