70 int nHits = rechits.size();
73 std::vector<CSCSegment> segments_temp;
77 std::vector<CSCSegment> testSegments;
80 for (std::vector<ChamberHitContainer>::iterator subrechits = clusteredHits.begin(); subrechits != clusteredHits.end(); ++subrechits ) {
82 std::vector<CSCSegment> segs =
buildSegments( (*subrechits) );
84 segments_temp.insert( segments_temp.end(), segs.begin(), segs.end() );
89 segments_temp.insert( segments_temp.end(), segs.begin(), segs.end() );
110 std::vector<CSCSegment> segmentInChamber;
111 segmentInChamber.clear();
113 unsigned nHitInChamber = rechits.size();
114 if ( nHitInChamber < 3 )
return segmentInChamber;
118 unsigned nLayers = 0;
120 for (
unsigned int i = 0;
i < nHitInChamber;
i++ ) {
121 int this_layer = rechits[
i]->cscDetId().layer();
122 layerIndex[
i] = this_layer;
123 if ( this_layer != old_layer ) {
124 old_layer = this_layer;
129 if ( nLayers < 3 )
return segmentInChamber;
136 reverse( layerIndex.begin(), layerIndex.end() );
137 reverse( rechits.begin(), rechits.end() );
140 else if ( z1 < 0. ) {
142 reverse( layerIndex.begin(), layerIndex.end() );
143 reverse( rechits.begin(), rechits.end() );
152 if ( segShower.
nRecHits() < 3 )
return segmentInChamber;
154 segmentInChamber.push_back(segShower);
156 return segmentInChamber;
169 if ( usedHits[i1-ib] )
continue;
172 int layer1 = layerIndex[i1-
ib];
180 if ( usedHits[i2-ib] )
continue;
182 int layer2 = layerIndex[i2-
ib];
197 float dz = gp2.
z()-gp1.
z();
235 double directionSign = globalZpos * globalZdir;
246 segmentInChamber.push_back(temp);
248 if (nHitInChamber-
protoSegment.size() < 3)
return segmentInChamber;
249 if (segmentInChamber.size() > 4)
return segmentInChamber;
256 return segmentInChamber;
284 if (
i == i1 ||
i == i2 )
continue;
288 int layer = layerIndex[
i-
ib];
289 int layer1 = layerIndex[i1-
ib];
290 int layer2 = layerIndex[i2-
ib];
293 if (rechits.size() < 9) {
325 int layer = (*i)->cscDetId().layer();
342 double Hphi = Hgp.
phi();
343 if (Hphi < 0.) Hphi += 2.*
M_PI;
351 double Sphi = Sgp.
phi();
352 if (Sphi < 0.) Sphi += 2.*
M_PI;
353 double R =
sqrt(Sgp.
x()*Sgp.
x() + Sgp.
y()*Sgp.
y());
356 if (deltaPhi > 2.*
M_PI) deltaPhi -= 2.*
M_PI;
357 if (deltaPhi < -2.*
M_PI) deltaPhi += 2.*
M_PI;
358 if (deltaPhi < 0.) deltaPhi = -
deltaPhi;
382 if ( aHit == (*it) )
return false;
398 CLHEP::HepMatrix M(4,4,0);
399 CLHEP::HepVector
B(4,0);
401 ChamberHitContainer::const_iterator ih;
415 CLHEP::HepMatrix IC(2,2);
425 LogDebug(
"CSC") <<
"CSCSegment::fitSlopes: failed to invert covariance matrix=\n" << IC <<
"\n";
430 M(1,3) += IC(1,1) *
z;
431 M(1,4) += IC(1,2) *
z;
432 B(1) += u * IC(1,1) + v * IC(1,2);
436 M(2,3) += IC(2,1) *
z;
437 M(2,4) += IC(2,2) *
z;
438 B(2) += u * IC(2,1) + v * IC(2,2);
440 M(3,1) += IC(1,1) *
z;
441 M(3,2) += IC(1,2) *
z;
442 M(3,3) += IC(1,1) * z *
z;
443 M(3,4) += IC(1,2) * z *
z;
444 B(3) += ( u * IC(1,1) + v * IC(1,2) ) * z;
446 M(4,1) += IC(2,1) *
z;
447 M(4,2) += IC(2,2) *
z;
448 M(4,3) += IC(2,1) * z *
z;
449 M(4,4) += IC(2,2) * z *
z;
450 B(4) += ( u * IC(2,1) + v * IC(2,2) ) * z;
453 CLHEP::HepVector
p = solve(M, B);
481 CLHEP::HepMatrix IC(2,2);
491 LogDebug(
"CSC") <<
"CSCSegment::fillChiSquared: failed to invert covariance matrix=\n" << IC <<
"\n";
493 chsq += du*du*IC(1,1) + 2.*du*dv*IC(1,2) + dv*dv*IC(2,2);
507 if ( (*it)->cscDetId().layer() == layer )
return true;
531 ChamberHitContainer::iterator it;
533 if ( (*it)->cscDetId().layer() == layer ) {
543 if ( (
protoChi2 > old_protoChi2) || ( !ok ) ) {
566 for ( iu = ib; iu != rechitsInChamber.end(); ++iu ) {
575 for ( iu = ib; iu != rechitsInChamber.end(); ++iu ) {
585 std::vector<const CSCRecHit2D*>::const_iterator it;
608 ChamberHitContainer::const_iterator it;
610 CLHEP::HepMatrix
matrix(2*nhits, 4);
680 float maxResidual = 0.;
681 float sumResidual = 0.;
687 ChamberHitContainer::const_iterator ih;
702 float residual =
sqrt(du*du + dv*dv);
704 sumResidual += residual;
706 if ( residual > maxResidual ) {
707 maxResidual = residual;
713 float corrAvgResidual = (sumResidual - maxResidual)/(nHits -1);
725 if ( j != badIndex ) newProtoSegment.push_back(*ih);
731 for ( ih = newProtoSegment.begin(); ih != newProtoSegment.end(); ++ih ) {
void tryAddingHitsToSegment(const ChamberHitContainer &rechitsInChamber, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2, const LayerIndex &layerIndex)
Utility functions.
void flipErrors(AlgebraicSymMatrix &) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ChamberHitContainer protoSegment
std::vector< const CSCRecHit2D * > ChamberHitContainer
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
void orderSecondSeed(GlobalPoint gp1, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2, const ChamberHitContainer &rechits, const LayerIndex &layerIndex)
CSCDetId cscDetId() const
AlgebraicSymMatrix weightMatrix(void) const
CLHEP::HepMatrix derivativeMatrix(void) const
virtual ~CSCSegAlgoDF()
Destructor.
CSCSegAlgoPreClustering * preCluster_
CSCSegment showerSeg(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Geom::Phi< T > phi() const
ChamberHitContainer closeHits
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
bool addHit(const CSCRecHit2D *hit, int layer)
bool isHitNearSegment(const CSCRecHit2D *h) const
CSCSegAlgoDF(const edm::ParameterSet &ps)
Constructor.
CSCSegAlgoShowering * showering_
ChamberHitContainer secondSeedHits
std::vector< CSCSegment > buildSegments(const ChamberHitContainer &rechits)
std::vector< CSCSegment > run(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
void updateParameters(void)
std::deque< bool > BoolContainer
const Surface::PositionType & position() const
The position (origin of the R.F.)
CLHEP::HepMatrix AlgebraicMatrix
LocalError localPositionError() const
LocalPoint protoIntercept
void compareProtoSegment(const CSCRecHit2D *h, int layer)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::vector< int > LayerIndex
Typedefs.
int minHitsForPreClustering
void flagHitsAsUsed(const ChamberHitContainer &rechitsInChamber)
std::vector< std::vector< const CSCRecHit2D * > > clusterHits(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
clusterize
CLHEP::HepSymMatrix AlgebraicSymMatrix
AlgebraicSymMatrix calculateError(void) const
const CSCChamber * theChamber
LocalVector protoDirection
LocalPoint localPosition() const
int nHitsPerClusterIsShower
bool hasHitOnLayer(int layer) const