Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:41

0001 #ifndef CSCSegment_CSCSegAlgoST_h
0002 #define CSCSegment_CSCSegAlgoST_h
0003 
0004 /**
0005  * \class CSCSegAlgoST
0006  *
0007  * This algorithm is based on the Minimum Spanning Tree (ST) approach 
0008  * for building endcap muon track segments out of the rechit's in a CSCChamber.<BR>
0009  *
0010  * A CSCSegment is a RecSegment4D, and is built from
0011  * CSCRecHit2D objects, each of which is a RecHit2DLocalPos. <BR>
0012  *
0013  * This builds segments consisting of at least 3 hits.
0014  * Segments can share a common rechit, but only one.
0015  * 
0016  *  \authors S. Stoynev  - NWU
0017  *           I. Bloch    - FNAL
0018  *           E. James    - FNAL
0019  *           A. Sakharov - WSU (extensive revision to handle weird segments)
0020  *           ... ... ...
0021  *           T. Cox      - UC Davis (struggling to handle this monster)
0022  *
0023  */
0024 
0025 #include <RecoLocalMuon/CSCSegment/src/CSCSegmentAlgorithm.h>
0026 #include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
0027 #include <FWCore/ParameterSet/interface/ParameterSet.h>
0028 #include <deque>
0029 #include <vector>
0030 
0031 class CSCSegAlgoShowering;
0032 class CSCSegAlgoST : public CSCSegmentAlgorithm {
0033 public:
0034   /// Typedefs
0035 
0036   typedef std::vector<const CSCRecHit2D*> ChamberHitContainer;
0037   typedef std::vector<std::vector<const CSCRecHit2D*> > Segments;
0038   typedef std::deque<bool> BoolContainer;
0039 
0040   /// Constructor
0041   explicit CSCSegAlgoST(const edm::ParameterSet& ps);
0042 
0043   /// Destructor
0044   ~CSCSegAlgoST() override;
0045 
0046   /**
0047    * Build track segments in this chamber (this is where the actual
0048    * segment-building algorithm hides.)
0049    */
0050   std::vector<CSCSegment> buildSegments(const ChamberHitContainer& rechits);
0051 
0052   /**
0053    * Build track segments in this chamber (this is where the actual
0054    * segment-building algorithm hides.)
0055    */
0056   std::vector<CSCSegment> buildSegments2(const ChamberHitContainer& rechits);
0057 
0058   /**
0059    * Build segments for all desired groups of hits
0060    */
0061   std::vector<CSCSegment> run(const CSCChamber* aChamber, const ChamberHitContainer& rechits) override;
0062 
0063   /**
0064    * Build groups of rechits that are separated in x and y to save time on the segment finding
0065    */
0066   std::vector<std::vector<const CSCRecHit2D*> > clusterHits(const CSCChamber* aChamber,
0067                                                             const ChamberHitContainer& rechits);
0068 
0069   /* Build groups of rechits that are separated in strip numbers and Z to save time on the segment finding
0070    */
0071   std::vector<std::vector<const CSCRecHit2D*> > chainHits(const CSCChamber* aChamber,
0072                                                           const ChamberHitContainer& rechits);
0073 
0074   /**
0075    * Remove bad hits from found segments based not only on chi2, but also on charge and 
0076    * further "low level" chamber information.
0077    */
0078   std::vector<CSCSegment> prune_bad_hits(const CSCChamber* aChamber, std::vector<CSCSegment>& segments);
0079 
0080 private:
0081   // Retrieve pset
0082   const edm::ParameterSet& pset(void) const { return ps_; }
0083 
0084   // Adjust covariance matrix?
0085   bool adjustCovariance(void) { return adjustCovariance_; }
0086 
0087   /// Utility functions
0088   double theWeight(
0089       double coordinate_1, double coordinate_2, double coordinate_3, float layer_1, float layer_2, float layer_3);
0090 
0091   void ChooseSegments(void);
0092 
0093   // Return the segment with the smallest weight
0094   void ChooseSegments2a(std::vector<ChamberHitContainer>& best_segments, int best_seg);
0095   // Version of ChooseSegments for the case without fake hits
0096   void ChooseSegments2(int best_seg);
0097 
0098   // Choose routine with reduce nr of loops
0099   void ChooseSegments3(int best_seg);
0100   void ChooseSegments3(std::vector<ChamberHitContainer>& best_segments, std::vector<float>& best_weight, int best_seg);
0101   //
0102 
0103   // Find duplicates in ME1/1a, if it has ganged strips (i.e. pre-LS1)
0104   void findDuplicates(std::vector<CSCSegment>& segments);
0105 
0106   bool isGoodToMerge(bool isME11a, ChamberHitContainer& newChain, ChamberHitContainer& oldChain);
0107 
0108   void dumpSegment(const CSCSegment& seg) const;
0109   const CSCChamber* chamber() const { return theChamber; }
0110 
0111   // Member variables
0112   const std::string myName_;
0113   const edm::ParameterSet ps_;
0114   CSCSegAlgoShowering* showering_;
0115 
0116   const CSCChamber* theChamber;
0117   Segments GoodSegments;
0118 
0119   ChamberHitContainer PAhits_onLayer[6];
0120   ChamberHitContainer Psegments_hits;
0121 
0122   std::vector<ChamberHitContainer> Psegments;
0123   std::vector<ChamberHitContainer> Psegments_noLx;
0124   std::vector<ChamberHitContainer> Psegments_noL1;
0125   std::vector<ChamberHitContainer> Psegments_noL2;
0126   std::vector<ChamberHitContainer> Psegments_noL3;
0127   std::vector<ChamberHitContainer> Psegments_noL4;
0128   std::vector<ChamberHitContainer> Psegments_noL5;
0129   std::vector<ChamberHitContainer> Psegments_noL6;
0130   std::vector<ChamberHitContainer> chosen_Psegments;
0131   std::vector<float> weight_A;
0132   std::vector<float> weight_noLx_A;
0133   std::vector<float> weight_noL1_A;
0134   std::vector<float> weight_noL2_A;
0135   std::vector<float> weight_noL3_A;
0136   std::vector<float> weight_noL4_A;
0137   std::vector<float> weight_noL5_A;
0138   std::vector<float> weight_noL6_A;
0139   std::vector<float> chosen_weight_A;
0140   std::vector<float> curv_A;
0141   std::vector<float> curv_noL1_A;
0142   std::vector<float> curv_noL2_A;
0143   std::vector<float> curv_noL3_A;
0144   std::vector<float> curv_noL4_A;
0145   std::vector<float> curv_noL5_A;
0146   std::vector<float> curv_noL6_A;
0147   std::vector<float> weight_B;
0148   std::vector<float> weight_noL1_B;
0149   std::vector<float> weight_noL2_B;
0150   std::vector<float> weight_noL3_B;
0151   std::vector<float> weight_noL4_B;
0152   std::vector<float> weight_noL5_B;
0153   std::vector<float> weight_noL6_B;
0154 
0155   ChamberHitContainer protoSegment;
0156 
0157   // input from .cfi file
0158   bool debug;
0159   //  int     minLayersApart;
0160   //  double  nSigmaFromSegment;
0161   int minHitsPerSegment;
0162   //  int     muonsPerChamberMax;
0163   //  double  chi2Max;
0164   double dXclusBoxMax;
0165   double dYclusBoxMax;
0166   int maxRecHitsInCluster;
0167   bool preClustering;
0168   bool preClustering_useChaining;
0169   bool Pruning;
0170   bool BrutePruning;
0171   double BPMinImprovement;
0172   bool onlyBestSegment;
0173   bool useShowering;
0174 
0175   double hitDropLimit4Hits;
0176   double hitDropLimit5Hits;
0177   double hitDropLimit6Hits;
0178 
0179   float a_yweightPenaltyThreshold[5][5];
0180 
0181   double yweightPenaltyThreshold;
0182   double yweightPenalty;
0183 
0184   double curvePenaltyThreshold;
0185   double curvePenalty;
0186 
0187   bool adjustCovariance_;  /// Flag whether to 'improve' covariance matrix
0188 
0189   bool condpass1, condpass2;
0190 
0191   double chi2Norm_3D_;  /// Chi^2 normalization for the initial fit
0192 
0193   bool prePrun_;         /// Allow to prune a (rechit in a) segment in segment buld method
0194                          /// once it passed through Chi^2-X and  chi2uCorrection is big.
0195   double prePrunLimit_;  /// The upper limit of protoChiUCorrection to apply prePrun
0196 };
0197 
0198 #endif