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  float dRMax ;
95  float dPhiMax;
96  float dRIntMax;
97  float dPhiIntMax;
98  float chi2Max;
99  float chi2_str_;
100  float chi2Norm_2D_;
101  };
103  // Could be static at the moment, but in principle one
104  // might like CSCSegmentizer-specific behaviour?
105  bool areHitsCloseInR(const AlgoState& aState, const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
106  bool areHitsCloseInGlobalPhi(const AlgoState& aState, const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
107  bool isHitNearSegment(const AlgoState& aState, const CSCRecHit2D* h) const;
108 
112  void tryAddingHitsToSegment(AlgoState& aState, const ChamberHitContainer& rechitsInChamber,
113  const BoolContainer& used, const LayerIndex& layerIndex,
114  const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2) const;
115 
120  bool isSegmentGood(const AlgoState& aState, const ChamberHitContainer& rechitsInChamber) const;
121 
125  void flagHitsAsUsed(const AlgoState& aState, const ChamberHitContainer& rechitsInChamber,BoolContainer& used) const;
126 
128  bool addHit(AlgoState& aState, const CSCRecHit2D* hit, int layer) const;
129  void updateParameters(AlgoState& aState) const;
130  float fit_r_phi(const AlgoState& aState, const SVector6& points, int layer) const;
131  float fitX(const AlgoState& aState, SVector6 points, SVector6 errors, int ir, int ir2, float &chi2_str) const;
132  void baseline(AlgoState& aState, int n_seg_min) const;//function for arasing bad hits in case of bad chi2/NDOF
137  float phiAtZ(const AlgoState& aState, float z) const;
138  bool hasHitOnLayer(const AlgoState& aState, int layer) const;
139  bool replaceHit(AlgoState& aState, const CSCRecHit2D* h, int layer) const;
140  void compareProtoSegment(AlgoState& aState, const CSCRecHit2D* h, int layer) const;
141  void increaseProtoSegment(AlgoState& aState, const CSCRecHit2D* h, int layer, int chi2_factor) const;
142 
143 
144  // Member variables
145  // ================
146 
148 
149 
150  double theChi2;
153  float uz, vz;
155  float dRMax ;
156  float dPhiMax;
157  float dRIntMax;
158  float dPhiIntMax;
159  float chi2Max;
160  float chi2_str_;
161  float chi2Norm_2D_;
162  float wideSeg;
164  bool debugInfo;
165 
166 };
167 
168 #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:150
bool replaceHit(AlgoState &aState, const CSCRecHit2D *h, int layer) const
LocalVector theDirection
Definition: CSCSegAlgoRU.h:152
const std::string myName
Definition: CSCSegAlgoRU.h:147
float dPhiIntMax
Definition: CSCSegAlgoRU.h:158
ChamberHitContainer proto_segment
Definition: CSCSegAlgoRU.h:90
std::unique_ptr< CSCSegFit > sfit
Definition: CSCSegAlgoRU.h:89
LocalPoint theOrigin
Definition: CSCSegAlgoRU.h:151
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:161
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:55
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