Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:37:39

0001 #ifndef CSCSegment_CSCSegAlgoSK_h
0002 #define CSCSegment_CSCSegAlgoSK_h
0003 
0004 /**
0005  * \class CSCSegAlgoSK
0006  *
0007  * This is the original algorithm for building endcap muon track segments
0008  * out of the rechit's in a CSCChamber. cf. CSCSegmentizerTC.<BR>
0009  * 'SK' = 'Sasha Khanov' = Speed King <BR>
0010  *
0011  * A CSCSegment is a RecSegment4D, and is built from
0012  * CSCRecHit2D objects, each of which is a RecHit2DLocalPos. <BR>
0013  *
0014  * This class is used by the CSCSegmentAlgorithm. <BR>
0015  * Alternative algorithms can be used for the segment building
0016  * by writing classes like this, and then selecting which one is actually
0017  * used via the CSCSegmentBuilder. <BR>
0018  *
0019  * Original (in FORTRAN): Alexandre.Khanov@cern.ch <BR>
0020  * Ported to C++ and improved: Rick.Wilkinson@cern.ch <BR>
0021  * Reimplemented in terms of layer index, and bug fix: Tim.Cox@cern.ch <BR>
0022  * Ported to CMSSW 2006-04-03: Matteo.Sani@cern.ch <BR>
0023  * Factored out segment fitter Tim.Cox@cern.ch Feb-2015 <BR>
0024  *
0025  */
0026 
0027 #include <RecoLocalMuon/CSCSegment/src/CSCSegmentAlgorithm.h>
0028 #include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
0029 
0030 #include <deque>
0031 #include <vector>
0032 
0033 class CSCSegFit;
0034 
0035 class CSCSegAlgoSK : public CSCSegmentAlgorithm {
0036 public:
0037   // Tim tried using map as basic container of all (space-point) RecHit's in a chamber:
0038   // The 'key' is a pseudo-layer number (1-6 but with 1 always closest to IP).
0039   // The 'value' is a vector of the RecHit's on that layer.
0040   // Using the layer number like this removes the need to sort in global z.
0041   // Instead we just have to ensure the layer index is correctly adjusted
0042   // to enforce the requirement that 'layer 1' is closest in the chamber
0043   // to the IP.
0044 
0045   /// Typedefs
0046 
0047   typedef std::vector<int> LayerIndex;
0048   typedef std::vector<const CSCRecHit2D*> ChamberHitContainer;
0049   typedef std::vector<const CSCRecHit2D*>::const_iterator ChamberHitContainerCIt;
0050 
0051   // We need to be able to flag a hit as 'used' and so need a container
0052   // of bool's. Naively, this would be vector<bool>... but AVOID that since it's
0053   // non-standard i.e. packed-bit implementation which is not a standard STL container.
0054   // We don't need what it offers and it could lead to unexpected trouble in the future.
0055 
0056   typedef std::deque<bool> BoolContainer;
0057 
0058   /// Constructor
0059   explicit CSCSegAlgoSK(const edm::ParameterSet& ps);
0060   /// Destructor
0061   ~CSCSegAlgoSK() override {}
0062 
0063   /**
0064      * Build track segments in this chamber (this is where the actual
0065      * segment-building algorithm hides.)
0066      */
0067   std::vector<CSCSegment> buildSegments(const ChamberHitContainer& rechits);
0068 
0069   /**
0070      * Here we must implement the algorithm
0071      */
0072   std::vector<CSCSegment> run(const CSCChamber* aChamber, const ChamberHitContainer& rechits) override;
0073 
0074 private:
0075   /// Utility functions
0076   // Could be static at the moment, but in principle one
0077   // might like CSCSegmentizer-specific behaviour?
0078   bool areHitsCloseInLocalX(const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
0079   bool areHitsCloseInGlobalPhi(const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
0080   bool isHitNearSegment(const CSCRecHit2D* h) const;
0081 
0082   /**
0083      * Dump position and phi of each rechit in chamber after sort in z
0084      */
0085   void dumpHits(const ChamberHitContainer& rechits) const;
0086 
0087   /**
0088      * Try adding non-used hits to segment
0089      */
0090   void tryAddingHitsToSegment(const ChamberHitContainer& rechitsInChamber,
0091                               const BoolContainer& used,
0092                               const LayerIndex& layerIndex,
0093                               const ChamberHitContainerCIt i1,
0094                               const ChamberHitContainerCIt i2);
0095 
0096   /**
0097      * Return true if segment is 'good'.
0098      * In this algorithm, 'good' means has sufficient hits
0099      */
0100   bool isSegmentGood(const ChamberHitContainer& rechitsInChamber) const;
0101 
0102   /**
0103      * Flag hits on segment as used
0104      */
0105   void flagHitsAsUsed(const ChamberHitContainer& rechitsInChamber, BoolContainer& used) const;
0106 
0107   /// Utility functions
0108   bool addHit(const CSCRecHit2D* hit, int layer);
0109   void updateParameters(void);
0110   float phiAtZ(float z) const;
0111   bool hasHitOnLayer(int layer) const;
0112   bool replaceHit(const CSCRecHit2D* h, int layer);
0113   void compareProtoSegment(const CSCRecHit2D* h, int layer);
0114   void increaseProtoSegment(const CSCRecHit2D* h, int layer);
0115   void dumpSegment(const CSCSegment& seg) const;
0116 
0117   // Member variables
0118   // ================
0119 
0120   const CSCChamber* theChamber;
0121   ChamberHitContainer proto_segment;
0122   const std::string myName;
0123 
0124   float windowScale;
0125   float dRPhiMax;
0126   float dPhiMax;
0127   float dRPhiFineMax;
0128   float dPhiFineMax;
0129   float chi2Max;
0130   float wideSeg;
0131   int minLayersApart;
0132   bool debugInfo;
0133 
0134   CSCSegFit* sfit_;
0135 };
0136 
0137 #endif