53 std::vector<CSCSegment> segments_temp;
54 std::vector<ChamberHitContainer> rechits_clusters;
55 std::vector<CSCSegment> segments = _segments;
56 const float chi2ndfProbMin = 1.0e-4;
60 int hit_nr_worst = -1;
63 for (std::vector<CSCSegment>::iterator it=segments.begin(); it != segments.end(); it++) {
65 if ( !use_brute_force ) {
67 float chisq = (*it).chi2();
68 int nhits = (*it).nRecHits();
75 globZ = globalPosition.
z();
81 std::vector<CSCRecHit2D> theseRecHits = (*it).specificRecHits();
82 std::vector<CSCRecHit2D>::const_iterator iRH_worst;
85 float xdist_local_worst_sig = -99999.;
86 float xdist_local_2ndworst_sig = -99999.;
87 float xdist_local_sig = -99999.;
93 for ( std::vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++ ) {
98 float loc_x_at_target ;
103 loc_x_at_target = 0.;
110 LocalPoint localPositionRH = (*iRH).localPosition();
113 LocalError rerrlocal = (*iRH).localPositionError();
114 float xxerr = rerrlocal.
xx();
116 float target_z = globalPositionRH.
z();
118 loc_x_at_target = localPos.
x() + (segDir.
x()*( target_z - globZ ));
125 xdist_local_sig = fabs((localPositionRH.
x() -loc_x_at_target)/(xxerr));
127 if( xdist_local_sig > xdist_local_worst_sig ) {
128 xdist_local_2ndworst_sig = xdist_local_worst_sig;
129 xdist_local_worst_sig = xdist_local_sig;
132 hit_nr_worst = hit_nr;
134 else if(xdist_local_sig > xdist_local_2ndworst_sig) {
135 xdist_local_2ndworst_sig = xdist_local_sig;
144 if ( xdist_local_worst_sig / xdist_local_2ndworst_sig < 1.5 ) {
154 std::vector< CSCRecHit2D > buffer;
155 std::vector< std::vector< CSCRecHit2D > > reduced_segments;
156 std::vector< CSCRecHit2D > theseRecHits = (*it).specificRecHits();
157 float best_red_seg_prob = 0.0;
160 if(
ChiSquaredProbability((
double)(*it).chi2(),(double)((2*(*it).nRecHits())-4)) < chi2ndfProbMin ) {
162 buffer = theseRecHits;
166 if( use_brute_force ) {
167 for(
size_t bi = 0; bi < buffer.size(); bi++) {
168 reduced_segments.push_back(buffer);
169 reduced_segments[bi].erase(reduced_segments[bi].
begin()+(bi),reduced_segments[bi].
begin()+(bi+1));
174 if( hit_nr_worst >= 0 && hit_nr_worst <=
int(buffer.size()) ) {
176 buffer.erase(buffer.begin()+(hit_nr_worst),buffer.begin()+(hit_nr_worst+1));
177 reduced_segments.push_back(buffer);
181 reduced_segments.push_back(buffer);
187 for (
size_t iSegment=0; iSegment<reduced_segments.size(); iSegment++ ) {
190 for (
size_t m = 0;
m<reduced_segments[iSegment].size(); ++
m ) {
233 CLHEP::HepMatrix M(4,4,0);
234 CLHEP::HepVector
B(4,0);
235 ChamberHitContainer::const_iterator ih =
protoSegment.begin();
246 CLHEP::HepMatrix IC(2,2);
255 LogDebug(
"CSC") <<
"CSCSegment::fitSlopes: failed to invert covariance matrix=\n" << IC <<
"\n";
261 M(1,3) += IC(1,1) *
z;
262 M(1,4) += IC(1,2) *
z;
263 B(1) += u * IC(1,1) + v * IC(1,2);
267 M(2,3) += IC(2,1) *
z;
268 M(2,4) += IC(2,2) *
z;
269 B(2) += u * IC(2,1) + v * IC(2,2);
271 M(3,1) += IC(1,1) *
z;
272 M(3,2) += IC(1,2) *
z;
273 M(3,3) += IC(1,1) * z *
z;
274 M(3,4) += IC(1,2) * z *
z;
275 B(3) += ( u * IC(1,1) + v * IC(1,2) ) * z;
277 M(4,1) += IC(2,1) *
z;
278 M(4,2) += IC(2,2) *
z;
279 M(4,3) += IC(2,1) * z *
z;
280 M(4,4) += IC(2,2) * z *
z;
281 B(4) += ( u * IC(2,1) + v * IC(2,2) ) * z;
283 CLHEP::HepVector
p = solve(M, B);
302 ChamberHitContainer::const_iterator ih;
317 CLHEP::HepMatrix IC(2,2);
327 LogDebug(
"CSC") <<
"CSCSegment::fillChiSquared: failed to invert covariance matrix=\n" << IC <<
"\n";
332 chsq += du*du*IC(1,1) + 2.*du*dv*IC(1,2) + dv*dv*IC(2,2);
348 double dz = 1./
sqrt(1. + dxdz*dxdz + dydz*dydz);
359 double directionSign = globalZpos * globalZdir;
369 std::vector<const CSCRecHit2D*>::const_iterator it;
395 ChamberHitContainer::const_iterator it;
397 CLHEP::HepMatrix
matrix(2*nhits, 4);
T getParameter(std::string const &) const
CLHEP::HepMatrix derivativeMatrix(void) const
CSCDetId cscDetId() const
const CSCChamber * theChamber
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
~CSCSegAlgoHitPruning()
destructor
CLHEP::HepMatrix AlgebraicMatrix
LocalError localPositionError() const
LocalPoint protoIntercept
void fillChiSquared(void)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
ChamberHitContainer protoSegment
float ChiSquaredProbability(double chiSquared, double nrDOF)
void flipErrors(AlgebraicSymMatrix &) const
CSCSegAlgoHitPruning(const edm::ParameterSet &ps)
constructor
AlgebraicSymMatrix weightMatrix(void) const
AlgebraicSymMatrix calculateError(void) const
LocalVector protoDirection
double chi2() const
Chi2 of the segment fit.
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< CSCSegment > pruneBadHits(const CSCChamber *aChamber, const std::vector< CSCSegment > &segments)
clusterize
LocalPoint localPosition() const
void fillLocalDirection(void)