CMS 3D CMS Logo

CSCSegAlgoRU.h
Go to the documentation of this file.
1 #ifndef CSCSegment_CSCSegAlgoRU_h
2 #define CSCSegment_CSCSegAlgoRU_h
3 
25 #include "CSCSegFit.h"
26 
27 #include <Math/Functions.h>
28 #include <Math/SVector.h>
29 #include <Math/SMatrix.h>
30 
31 #include <vector>
32 
33 
34 class CSCSegFit;
35 
37 
38 public:
39 
40  // Tim tried using map as basic container of all (space-point) RecHit's in a chamber:
41  // The 'key' is a pseudo-layer number (1-6 but with 1 always closest to IP).
42  // The 'value' is a vector of the RecHit's on that layer.
43  // Using the layer number like this removes the need to sort in global z.
44  // Instead we just have to ensure the layer index is correctly adjusted
45  // to enforce the requirement that 'layer 1' is closest in the chamber
46  // to the IP.
47 
49 
50 
51  // 4-dim vector
52  typedef ROOT::Math::SVector<double,6> SVector6;
53 
54  typedef std::vector<int> LayerIndex;
55  typedef std::vector<const CSCRecHit2D*> ChamberHitContainer;
56  typedef std::vector<const CSCRecHit2D*>::const_iterator ChamberHitContainerCIt;
57 
58  // We need to be able to flag a hit as 'used' and so need a container
59  // of bool's. Naively, this would be vector<bool>... but AVOID that since it's
60  // non-standard i.e. packed-bit implementation which is not a standard STL container.
61  // We don't need what it offers and it could lead to unexpected trouble in the future.
62 
63  typedef std::vector<bool> BoolContainer;
64 
66  explicit CSCSegAlgoRU(const edm::ParameterSet& ps);
68  ~CSCSegAlgoRU() override {};
69 
74  std::vector<CSCSegment> buildSegments(const CSCChamber* aChamber, const ChamberHitContainer& rechits) const;
75 
76  // std::vector<CSCSegment> assambleRechitsInSegments(const ChamberHitContainer& rechits, int iadd, BoolContainer& used, BoolContainer& used3p, int *recHits_per_layer, const LayerIndex& layerIndex, std::vector<CSCSegment> segments);
77 
81  std::vector<CSCSegment> run(const CSCChamber* aChamber, const ChamberHitContainer& rechits) override{ return buildSegments(aChamber, rechits); }
82 
83 private:
84  struct AlgoState {
85  const CSCChamber* aChamber = nullptr;
86  float windowScale = 0;
87  int strip_iadd = 0;
88  int chi2D_iadd = 0;
89  std::unique_ptr<CSCSegFit> sfit = nullptr;
90  ChamberHitContainer proto_segment;
91 
92  //adjustable configuration
94  bool enlarge;
95  float dRMax ;
96  float dPhiMax;
97  float dRIntMax;
98  float dPhiIntMax;
99  float chi2Max;
100  float chi2_str_;
101  float chi2Norm_2D_;
102  };
104  // Could be static at the moment, but in principle one
105  // might like CSCSegmentizer-specific behaviour?
106  bool areHitsCloseInR(const AlgoState& aState, const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
107  bool areHitsCloseInGlobalPhi(const AlgoState& aState, const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
108  bool isHitNearSegment(const AlgoState& aState, const CSCRecHit2D* h) const;
109 
113  void tryAddingHitsToSegment(AlgoState& aState, const ChamberHitContainer& rechitsInChamber,
114  const BoolContainer& used, const LayerIndex& layerIndex,
115  const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2) const;
116 
121  bool isSegmentGood(const AlgoState& aState, const ChamberHitContainer& rechitsInChamber) const;
122 
126  void flagHitsAsUsed(const AlgoState& aState, const ChamberHitContainer& rechitsInChamber,BoolContainer& used) const;
127 
129  bool addHit(AlgoState& aState, const CSCRecHit2D* hit, int layer) const;
130  void updateParameters(AlgoState& aState) const;
131  float fit_r_phi(const AlgoState& aState, const SVector6& points, int layer) const;
132  float fitX(const AlgoState& aState, SVector6 points, SVector6 errors, int ir, int ir2, float &chi2_str) const;
133  void baseline(AlgoState& aState, int n_seg_min) const;//function for arasing bad hits in case of bad chi2/NDOF
138  float phiAtZ(const AlgoState& aState, float z) const;
139  bool hasHitOnLayer(const AlgoState& aState, int layer) const;
140  bool replaceHit(AlgoState& aState, const CSCRecHit2D* h, int layer) const;
141  void compareProtoSegment(AlgoState& aState, const CSCRecHit2D* h, int layer) const;
142  void increaseProtoSegment(AlgoState& aState, const CSCRecHit2D* h, int layer, int chi2_factor) const;
143 
144 
145  // Member variables
146  // ================
147 
149 
150 
151  double theChi2;
154  float uz, vz;
156  float dRMax ;
157  float dPhiMax;
158  float dRIntMax;
159  float dPhiIntMax;
160  float chi2Max;
161  float chi2_str_;
162  float chi2Norm_2D_;
163  float wideSeg;
165  bool debugInfo;
166  bool enlarge;
167 };
168 
169 #endif
bool areHitsCloseInR(const AlgoState &aState, const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
Utility functions.
ROOT::Math::SVector< double, 6 > SVector6
Typedefs.
Definition: CSCSegAlgoRU.h:52
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
Definition: CSCSegAlgoRU.h:56
bool areHitsCloseInGlobalPhi(const AlgoState &aState, const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
float phiAtZ(const AlgoState &aState, float z) const
double theChi2
Definition: CSCSegAlgoRU.h:151
bool replaceHit(AlgoState &aState, const CSCRecHit2D *h, int layer) const
LocalVector theDirection
Definition: CSCSegAlgoRU.h:153
const std::string myName
Definition: CSCSegAlgoRU.h:148
float dPhiIntMax
Definition: CSCSegAlgoRU.h:159
ChamberHitContainer proto_segment
Definition: CSCSegAlgoRU.h:90
std::unique_ptr< CSCSegFit > sfit
Definition: CSCSegAlgoRU.h:89
LocalPoint theOrigin
Definition: CSCSegAlgoRU.h:152
void tryAddingHitsToSegment(AlgoState &aState, const ChamberHitContainer &rechitsInChamber, const BoolContainer &used, const LayerIndex &layerIndex, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2) const
bool isSegmentGood(const AlgoState &aState, const ChamberHitContainer &rechitsInChamber) const
void baseline(AlgoState &aState, int n_seg_min) const
bool isHitNearSegment(const AlgoState &aState, const CSCRecHit2D *h) const
void increaseProtoSegment(AlgoState &aState, const CSCRecHit2D *h, int layer, int chi2_factor) const
CSCSegAlgoRU(const edm::ParameterSet &ps)
Constructor.
Definition: CSCSegAlgoRU.cc:20
std::vector< const CSCRecHit2D * > ChamberHitContainer
Definition: CSCSegAlgoRU.h:55
std::vector< bool > BoolContainer
Definition: CSCSegAlgoRU.h:63
std::vector< int > LayerIndex
Definition: CSCSegAlgoRU.h:54
void updateParameters(AlgoState &aState) const
void compareProtoSegment(AlgoState &aState, const CSCRecHit2D *h, int layer) const
float chi2Norm_2D_
Definition: CSCSegAlgoRU.h:162
bool addHit(AlgoState &aState, const CSCRecHit2D *hit, int layer) const
Utility functions.
float fit_r_phi(const AlgoState &aState, const SVector6 &points, int layer) const
std::vector< CSCSegment > buildSegments(const CSCChamber *aChamber, const ChamberHitContainer &rechits) const
Definition: CSCSegAlgoRU.cc:56
float fitX(const AlgoState &aState, SVector6 points, SVector6 errors, int ir, int ir2, float &chi2_str) const
void flagHitsAsUsed(const AlgoState &aState, const ChamberHitContainer &rechitsInChamber, BoolContainer &used) const
std::vector< CSCSegment > run(const CSCChamber *aChamber, const ChamberHitContainer &rechits) override
Definition: CSCSegAlgoRU.h:81
bool hasHitOnLayer(const AlgoState &aState, int layer) const
Definition: errors.py:1
~CSCSegAlgoRU() override
Destructor.
Definition: CSCSegAlgoRU.h:68