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 class CSCSegFit;
34 
36 public:
37  // Tim tried using map as basic container of all (space-point) RecHit's in a chamber:
38  // The 'key' is a pseudo-layer number (1-6 but with 1 always closest to IP).
39  // The 'value' is a vector of the RecHit's on that layer.
40  // Using the layer number like this removes the need to sort in global z.
41  // Instead we just have to ensure the layer index is correctly adjusted
42  // to enforce the requirement that 'layer 1' is closest in the chamber
43  // to the IP.
44 
46 
47  // 4-dim vector
48  typedef ROOT::Math::SVector<double, 6> SVector6;
49 
50  typedef std::vector<int> LayerIndex;
51  typedef std::vector<const CSCRecHit2D*> ChamberHitContainer;
52  typedef std::vector<const CSCRecHit2D*>::const_iterator ChamberHitContainerCIt;
53 
54  // We need to be able to flag a hit as 'used' and so need a container
55  // of bool's. Naively, this would be vector<bool>... but AVOID that since it's
56  // non-standard i.e. packed-bit implementation which is not a standard STL container.
57  // We don't need what it offers and it could lead to unexpected trouble in the future.
58 
59  typedef std::vector<bool> BoolContainer;
60 
62  explicit CSCSegAlgoRU(const edm::ParameterSet& ps);
64  ~CSCSegAlgoRU() override{};
65 
70  std::vector<CSCSegment> buildSegments(const CSCChamber* aChamber, const ChamberHitContainer& rechits) const;
71 
72  // std::vector<CSCSegment> assambleRechitsInSegments(const ChamberHitContainer& rechits, int iadd, BoolContainer& used, BoolContainer& used3p, int *recHits_per_layer, const LayerIndex& layerIndex, std::vector<CSCSegment> segments);
73 
77  std::vector<CSCSegment> run(const CSCChamber* aChamber, const ChamberHitContainer& rechits) override {
78  return buildSegments(aChamber, rechits);
79  }
80 
81 private:
82  struct AlgoState {
83  const CSCChamber* aChamber = nullptr;
84  float windowScale = 0;
85  int strip_iadd = 0;
86  int chi2D_iadd = 0;
87  std::unique_ptr<CSCSegFit> sfit = nullptr;
89 
90  //adjustable configuration
92  float dRMax;
93  float dPhiMax;
94  float dRIntMax;
95  float dPhiIntMax;
96  float chi2Max;
97  float chi2_str_;
98  float chi2Norm_2D_;
99  };
101  // Could be static at the moment, but in principle one
102  // might like CSCSegmentizer-specific behaviour?
103  bool areHitsCloseInR(const AlgoState& aState, const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
104  bool areHitsCloseInGlobalPhi(const AlgoState& aState, const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
105  bool isHitNearSegment(const AlgoState& aState, const CSCRecHit2D* h) const;
106 
110  void tryAddingHitsToSegment(AlgoState& aState,
111  const ChamberHitContainer& rechitsInChamber,
112  const BoolContainer& used,
113  const LayerIndex& layerIndex,
115  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  // Member variables
145  // ================
146 
148 
149  double theChi2;
152  float uz, vz;
154  float dRMax;
155  float dPhiMax;
156  float dRIntMax;
157  float dPhiIntMax;
158  float chi2Max;
159  float chi2_str_;
161  float wideSeg;
163  bool debugInfo;
164 };
165 
166 #endif
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
Definition: CSCSegAlgoRU.h:52
void baseline(AlgoState &aState, int n_seg_min) const
bool areHitsCloseInR(const AlgoState &aState, const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
Utility functions.
double theChi2
Definition: CSCSegAlgoRU.h:149
LocalVector theDirection
Definition: CSCSegAlgoRU.h:151
const std::string myName
Definition: CSCSegAlgoRU.h:147
std::vector< CSCSegment > buildSegments(const CSCChamber *aChamber, const ChamberHitContainer &rechits) const
Definition: CSCSegAlgoRU.cc:56
bool replaceHit(AlgoState &aState, const CSCRecHit2D *h, int layer) const
float dPhiIntMax
Definition: CSCSegAlgoRU.h:157
ChamberHitContainer proto_segment
Definition: CSCSegAlgoRU.h:88
std::unique_ptr< CSCSegFit > sfit
Definition: CSCSegAlgoRU.h:87
bool isHitNearSegment(const AlgoState &aState, const CSCRecHit2D *h) const
LocalPoint theOrigin
Definition: CSCSegAlgoRU.h:150
bool areHitsCloseInGlobalPhi(const AlgoState &aState, const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
void compareProtoSegment(AlgoState &aState, const CSCRecHit2D *h, int layer) const
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
const CSCChamber * aChamber
Definition: CSCSegAlgoRU.h:83
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
float fit_r_phi(const AlgoState &aState, const SVector6 &points, int layer) const
CSCSegAlgoRU(const edm::ParameterSet &ps)
Constructor.
Definition: CSCSegAlgoRU.cc:22
std::vector< const CSCRecHit2D * > ChamberHitContainer
Definition: CSCSegAlgoRU.h:51
std::vector< bool > BoolContainer
Definition: CSCSegAlgoRU.h:59
std::vector< int > LayerIndex
Definition: CSCSegAlgoRU.h:50
void tryAddingHitsToSegment(AlgoState &aState, const ChamberHitContainer &rechitsInChamber, const BoolContainer &used, const LayerIndex &layerIndex, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2) const
ROOT::Math::SVector< double, 6 > SVector6
Typedefs.
Definition: CSCSegAlgoRU.h:48
float chi2Norm_2D_
Definition: CSCSegAlgoRU.h:160
float phiAtZ(const AlgoState &aState, float z) const
void increaseProtoSegment(AlgoState &aState, const CSCRecHit2D *h, int layer, int chi2_factor) const
std::vector< CSCSegment > run(const CSCChamber *aChamber, const ChamberHitContainer &rechits) override
Definition: CSCSegAlgoRU.h:77
void updateParameters(AlgoState &aState) const
Definition: errors.py:1
bool hasHitOnLayer(const AlgoState &aState, int layer) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
~CSCSegAlgoRU() override
Destructor.
Definition: CSCSegAlgoRU.h:64
bool isSegmentGood(const AlgoState &aState, const ChamberHitContainer &rechitsInChamber) const
bool addHit(AlgoState &aState, const CSCRecHit2D *hit, int layer) const
Utility functions.