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  bool enlarge;
93  float dRMax;
94  float dPhiMax;
95  float dRIntMax;
96  float dPhiIntMax;
97  float chi2Max;
98  float chi2_str_;
99  float chi2Norm_2D_;
100  };
102  // Could be static at the moment, but in principle one
103  // might like CSCSegmentizer-specific behaviour?
104  bool areHitsCloseInR(const AlgoState& aState, const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
105  bool areHitsCloseInGlobalPhi(const AlgoState& aState, const CSCRecHit2D* h1, const CSCRecHit2D* h2) const;
106  bool isHitNearSegment(const AlgoState& aState, const CSCRecHit2D* h) const;
107 
111  void tryAddingHitsToSegment(AlgoState& aState,
112  const ChamberHitContainer& rechitsInChamber,
113  const BoolContainer& used,
114  const LayerIndex& layerIndex,
116  const ChamberHitContainerCIt i2) const;
117 
122  bool isSegmentGood(const AlgoState& aState, const ChamberHitContainer& rechitsInChamber) const;
123 
127  void flagHitsAsUsed(const AlgoState& aState, const ChamberHitContainer& rechitsInChamber, BoolContainer& used) const;
128 
130  bool addHit(AlgoState& aState, const CSCRecHit2D* hit, int layer) const;
131  void updateParameters(AlgoState& aState) const;
132  float fit_r_phi(const AlgoState& aState, const SVector6& points, int layer) const;
133  float fitX(const AlgoState& aState, SVector6 points, SVector6 errors, int ir, int ir2, float& chi2_str) const;
134  void baseline(AlgoState& aState, int n_seg_min) const; //function for arasing bad hits in case of bad chi2/NDOF
139  float phiAtZ(const AlgoState& aState, float z) const;
140  bool hasHitOnLayer(const AlgoState& aState, int layer) const;
141  bool replaceHit(AlgoState& aState, const CSCRecHit2D* h, int layer) const;
142  void compareProtoSegment(AlgoState& aState, const CSCRecHit2D* h, int layer) const;
143  void increaseProtoSegment(AlgoState& aState, const CSCRecHit2D* h, int layer, int chi2_factor) const;
144 
145  // Member variables
146  // ================
147 
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_;
162  float wideSeg;
164  bool debugInfo;
165  bool enlarge;
166 };
167 
168 #endif
Vector3DBase< float, LocalTag >
CSCSegAlgoRU::updateParameters
void updateParameters(AlgoState &aState) const
Definition: CSCSegAlgoRU.cc:622
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
CSCSegAlgoRU::replaceHit
bool replaceHit(AlgoState &aState, const CSCRecHit2D *h, int layer) const
Definition: CSCSegAlgoRU.cc:887
CSCSegAlgoRU::myName
const std::string myName
Definition: CSCSegAlgoRU.h:148
CSCSegmentAlgorithm
Definition: CSCSegmentAlgorithm.h:23
HLT_FULL_cff.points
points
Definition: HLT_FULL_cff.py:21455
CSCSegAlgoRU::AlgoState::dRMax
float dRMax
Definition: CSCSegAlgoRU.h:93
CSCSegAlgoRU::minLayersApart
int minLayersApart
Definition: CSCSegAlgoRU.h:163
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:359
CSCSegAlgoRU::AlgoState::dPhiMax
float dPhiMax
Definition: CSCSegAlgoRU.h:94
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
CSCSegAlgoRU::AlgoState::enlarge
bool enlarge
Definition: CSCSegAlgoRU.h:92
CSCSegAlgoRU::theOrigin
LocalPoint theOrigin
Definition: CSCSegAlgoRU.h:151
CSCSegAlgoRU::debugInfo
bool debugInfo
Definition: CSCSegAlgoRU.h:164
CSCSegmentAlgorithmRU_cfi.chi2_str
chi2_str
Definition: CSCSegmentAlgorithmRU_cfi.py:7
CSCSegAlgoRU::chi2Max
float chi2Max
Definition: CSCSegAlgoRU.h:159
CSCSegAlgoRU::vz
float vz
Definition: CSCSegAlgoRU.h:153
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:154
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:98
CSCSegAlgoRU::uz
float uz
Definition: CSCSegAlgoRU.h:153
errors
Definition: errors.py:1
CSCSegAlgoRU::AlgoState::dRIntMax
float dRIntMax
Definition: CSCSegAlgoRU.h:95
CSCSegAlgoRU::AlgoState::doCollisions
bool doCollisions
Definition: CSCSegAlgoRU.h:91
CSCSegAlgoRU::baseline
void baseline(AlgoState &aState, int n_seg_min) const
Definition: CSCSegAlgoRU.cc:649
CSCSegAlgoRU::dPhiIntMax
float dPhiIntMax
Definition: CSCSegAlgoRU.h:158
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:915
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:150
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
CSCSegAlgoRU::theDirection
LocalVector theDirection
Definition: CSCSegAlgoRU.h:152
h
Point3DBase< float, LocalTag >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CSCSegAlgoRU::hasHitOnLayer
bool hasHitOnLayer(const AlgoState &aState, int layer) const
Definition: CSCSegAlgoRU.cc:878
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:594
CSCSegAlgoRU::enlarge
bool enlarge
Definition: CSCSegAlgoRU.h:165
CSCSegAlgoRU::AlgoState::dPhiIntMax
float dPhiIntMax
Definition: CSCSegAlgoRU.h:96
CSCSegAlgoRU::isSegmentGood
bool isSegmentGood(const AlgoState &aState, const ChamberHitContainer &rechitsInChamber) const
Definition: CSCSegAlgoRU.cc:577
CSCSegAlgoRU::areHitsCloseInGlobalPhi
bool areHitsCloseInGlobalPhi(const AlgoState &aState, const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
Definition: CSCSegAlgoRU.cc:444
CSCSegAlgoRU::AlgoState::chi2Norm_2D_
float chi2Norm_2D_
Definition: CSCSegAlgoRU.h:99
CSCSegAlgoRU
Definition: CSCSegAlgoRU.h:35
CSCSegAlgoRU::AlgoState::chi2D_iadd
int chi2D_iadd
Definition: CSCSegAlgoRU.h:86
CSCSegAlgoRU::dRIntMax
float dRIntMax
Definition: CSCSegAlgoRU.h:157
CSCSegAlgoRU::dPhiMax
float dPhiMax
Definition: CSCSegAlgoRU.h:156
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:844
CSCSegmentAlgorithm.h
CSCSegAlgoRU::addHit
bool addHit(AlgoState &aState, const CSCRecHit2D *hit, int layer) const
Utility functions.
Definition: CSCSegAlgoRU.cc:608
CSCSegAlgoRU::buildSegments
std::vector< CSCSegment > buildSegments(const CSCChamber *aChamber, const ChamberHitContainer &rechits) const
Definition: CSCSegAlgoRU.cc:57
CSCSegAlgoRU::chi2Norm_2D_
float chi2Norm_2D_
Definition: CSCSegAlgoRU.h:161
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:97
CSCSegAlgoRU::SVector6
ROOT::Math::SVector< double, 6 > SVector6
Typedefs.
Definition: CSCSegAlgoRU.h:48
CSCSegAlgoRU::dRMax
float dRMax
Definition: CSCSegAlgoRU.h:155
CSCSegAlgoRU::phiAtZ
float phiAtZ(const AlgoState &aState, float z) const
Definition: CSCSegAlgoRU.cc:562
CSCSegAlgoRU::isHitNearSegment
bool isHitNearSegment(const AlgoState &aState, const CSCRecHit2D *h) const
Definition: CSCSegAlgoRU.cc:472
CSCSegAlgoRU::fit_r_phi
float fit_r_phi(const AlgoState &aState, const SVector6 &points, int layer) const
Definition: CSCSegAlgoRU.cc:629
CSCSegAlgoRU::areHitsCloseInR
bool areHitsCloseInR(const AlgoState &aState, const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
Utility functions.
Definition: CSCSegAlgoRU.cc:397
hit
Definition: SiStripHitEffFromCalibTree.cc:88
CSCSegAlgoRU::compareProtoSegment
void compareProtoSegment(AlgoState &aState, const CSCRecHit2D *h, int layer) const
Definition: CSCSegAlgoRU.cc:899
CSCSegAlgoRU::chi2_str_
float chi2_str_
Definition: CSCSegAlgoRU.h:160
CSCSegAlgoRU::wideSeg
float wideSeg
Definition: CSCSegAlgoRU.h:162