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
Vector3DBase< float, LocalTag >
CSCSegAlgoRU::updateParameters
void updateParameters(AlgoState &aState) const
Definition: CSCSegAlgoRU.cc:596
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
CSCSegAlgoRU::replaceHit
bool replaceHit(AlgoState &aState, const CSCRecHit2D *h, int layer) const
Definition: CSCSegAlgoRU.cc:861
CSCSegAlgoRU::myName
const std::string myName
Definition: CSCSegAlgoRU.h:147
CSCSegmentAlgorithm
Definition: CSCSegmentAlgorithm.h:23
HLT_FULL_cff.points
points
Definition: HLT_FULL_cff.py:21449
CSCSegAlgoRU::AlgoState::dRMax
float dRMax
Definition: CSCSegAlgoRU.h:92
CSCSegAlgoRU::minLayersApart
int minLayersApart
Definition: CSCSegAlgoRU.h:162
CSCSegAlgoRU::ChamberHitContainer
std::vector< const CSCRecHit2D * > ChamberHitContainer
Definition: CSCSegAlgoRU.h:51
CSCSegAlgoRU::tryAddingHitsToSegment
void tryAddingHitsToSegment(AlgoState &aState, const ChamberHitContainer &rechitsInChamber, const BoolContainer &used, const LayerIndex &layerIndex, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2) const
Definition: CSCSegAlgoRU.cc:351
CSCSegAlgoRU::AlgoState::dPhiMax
float dPhiMax
Definition: CSCSegAlgoRU.h:93
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
CSCSegAlgoRU::theOrigin
LocalPoint theOrigin
Definition: CSCSegAlgoRU.h:150
CSCSegAlgoRU::debugInfo
bool debugInfo
Definition: CSCSegAlgoRU.h:163
CSCSegmentAlgorithmRU_cfi.chi2_str
chi2_str
Definition: CSCSegmentAlgorithmRU_cfi.py:6
CSCSegAlgoRU::chi2Max
float chi2Max
Definition: CSCSegAlgoRU.h:158
CSCSegAlgoRU::vz
float vz
Definition: CSCSegAlgoRU.h:152
CSCSegFit
Definition: CSCSegFit.h:30
CSCSegAlgoRU::run
std::vector< CSCSegment > run(const CSCChamber *aChamber, const ChamberHitContainer &rechits) override
Definition: CSCSegAlgoRU.h:77
CSCSegAlgoRU::doCollisions
bool doCollisions
Definition: CSCSegAlgoRU.h:153
CSCSegAlgoRU::ChamberHitContainerCIt
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
Definition: CSCSegAlgoRU.h:52
CSCSegFit.h
CSCSegAlgoRU::AlgoState::sfit
std::unique_ptr< CSCSegFit > sfit
Definition: CSCSegAlgoRU.h:87
CSCSegAlgoRU::AlgoState::chi2_str_
float chi2_str_
Definition: CSCSegAlgoRU.h:97
CSCSegAlgoRU::uz
float uz
Definition: CSCSegAlgoRU.h:152
errors
Definition: errors.py:1
CSCSegAlgoRU::AlgoState::dRIntMax
float dRIntMax
Definition: CSCSegAlgoRU.h:94
CSCSegAlgoRU::AlgoState::doCollisions
bool doCollisions
Definition: CSCSegAlgoRU.h:91
CSCSegAlgoRU::baseline
void baseline(AlgoState &aState, int n_seg_min) const
Definition: CSCSegAlgoRU.cc:623
CSCSegAlgoRU::dPhiIntMax
float dPhiIntMax
Definition: CSCSegAlgoRU.h:157
CSCSegAlgoRU::AlgoState::strip_iadd
int strip_iadd
Definition: CSCSegAlgoRU.h:85
DDAxes::z
CSCSegAlgoRU::increaseProtoSegment
void increaseProtoSegment(AlgoState &aState, const CSCRecHit2D *h, int layer, int chi2_factor) const
Definition: CSCSegAlgoRU.cc:889
CSCChamber
Definition: CSCChamber.h:22
CSCSegAlgoRU::CSCSegAlgoRU
CSCSegAlgoRU(const edm::ParameterSet &ps)
Constructor.
Definition: CSCSegAlgoRU.cc:22
CSCSegAlgoRU::BoolContainer
std::vector< bool > BoolContainer
Definition: CSCSegAlgoRU.h:59
CSCSegAlgoRU::LayerIndex
std::vector< int > LayerIndex
Definition: CSCSegAlgoRU.h:50
CSCSegAlgoRU::theChi2
double theChi2
Definition: CSCSegAlgoRU.h:149
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
CSCSegAlgoRU::theDirection
LocalVector theDirection
Definition: CSCSegAlgoRU.h:151
h
Point3DBase< float, LocalTag >
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CSCSegAlgoRU::hasHitOnLayer
bool hasHitOnLayer(const AlgoState &aState, int layer) const
Definition: CSCSegAlgoRU.cc:852
CSCSegAlgoRU::AlgoState::windowScale
float windowScale
Definition: CSCSegAlgoRU.h:84
edm::ParameterSet
Definition: ParameterSet.h:47
CSCRecHit2D
Definition: CSCRecHit2D.h:18
CSCSegAlgoRU::~CSCSegAlgoRU
~CSCSegAlgoRU() override
Destructor.
Definition: CSCSegAlgoRU.h:64
CSCSegAlgoRU::flagHitsAsUsed
void flagHitsAsUsed(const AlgoState &aState, const ChamberHitContainer &rechitsInChamber, BoolContainer &used) const
Definition: CSCSegAlgoRU.cc:568
CSCSegAlgoRU::AlgoState::dPhiIntMax
float dPhiIntMax
Definition: CSCSegAlgoRU.h:95
CSCSegAlgoRU::isSegmentGood
bool isSegmentGood(const AlgoState &aState, const ChamberHitContainer &rechitsInChamber) const
Definition: CSCSegAlgoRU.cc:551
CSCSegAlgoRU::areHitsCloseInGlobalPhi
bool areHitsCloseInGlobalPhi(const AlgoState &aState, const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
Definition: CSCSegAlgoRU.cc:427
CSCSegAlgoRU::AlgoState::chi2Norm_2D_
float chi2Norm_2D_
Definition: CSCSegAlgoRU.h:98
CSCSegAlgoRU
Definition: CSCSegAlgoRU.h:35
CSCSegAlgoRU::AlgoState::chi2D_iadd
int chi2D_iadd
Definition: CSCSegAlgoRU.h:86
CSCSegAlgoRU::dRIntMax
float dRIntMax
Definition: CSCSegAlgoRU.h:156
CSCSegAlgoRU::dPhiMax
float dPhiMax
Definition: CSCSegAlgoRU.h:155
CSCSegAlgoRU::AlgoState::aChamber
const CSCChamber * aChamber
Definition: CSCSegAlgoRU.h:83
CSCSegAlgoRU::fitX
float fitX(const AlgoState &aState, SVector6 points, SVector6 errors, int ir, int ir2, float &chi2_str) const
Definition: CSCSegAlgoRU.cc:818
CSCSegmentAlgorithm.h
CSCSegAlgoRU::addHit
bool addHit(AlgoState &aState, const CSCRecHit2D *hit, int layer) const
Utility functions.
Definition: CSCSegAlgoRU.cc:582
CSCSegAlgoRU::buildSegments
std::vector< CSCSegment > buildSegments(const CSCChamber *aChamber, const ChamberHitContainer &rechits) const
Definition: CSCSegAlgoRU.cc:56
CSCSegAlgoRU::chi2Norm_2D_
float chi2Norm_2D_
Definition: CSCSegAlgoRU.h:160
CSCSegAlgoRU::AlgoState
Definition: CSCSegAlgoRU.h:82
CSCSegAlgoRU::AlgoState::proto_segment
ChamberHitContainer proto_segment
Definition: CSCSegAlgoRU.h:88
CSCRecHit2D.h
CSCSegAlgoRU::AlgoState::chi2Max
float chi2Max
Definition: CSCSegAlgoRU.h:96
CSCSegAlgoRU::SVector6
ROOT::Math::SVector< double, 6 > SVector6
Typedefs.
Definition: CSCSegAlgoRU.h:48
CSCSegAlgoRU::dRMax
float dRMax
Definition: CSCSegAlgoRU.h:154
CSCSegAlgoRU::phiAtZ
float phiAtZ(const AlgoState &aState, float z) const
Definition: CSCSegAlgoRU.cc:536
CSCSegAlgoRU::isHitNearSegment
bool isHitNearSegment(const AlgoState &aState, const CSCRecHit2D *h) const
Definition: CSCSegAlgoRU.cc:455
CSCSegAlgoRU::fit_r_phi
float fit_r_phi(const AlgoState &aState, const SVector6 &points, int layer) const
Definition: CSCSegAlgoRU.cc:603
CSCSegAlgoRU::areHitsCloseInR
bool areHitsCloseInR(const AlgoState &aState, const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
Utility functions.
Definition: CSCSegAlgoRU.cc:389
hit
Definition: SiStripHitEffFromCalibTree.cc:88
CSCSegAlgoRU::compareProtoSegment
void compareProtoSegment(AlgoState &aState, const CSCRecHit2D *h, int layer) const
Definition: CSCSegAlgoRU.cc:873
CSCSegAlgoRU::chi2_str_
float chi2_str_
Definition: CSCSegAlgoRU.h:159
CSCSegAlgoRU::wideSeg
float wideSeg
Definition: CSCSegAlgoRU.h:161