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() );
109 std::vector<CSCSegment> segmentInChamber;
110 segmentInChamber.clear();
112 unsigned nHitInChamber = rechits.size();
113 if ( nHitInChamber < 3 )
return segmentInChamber;
117 unsigned nLayers = 0;
119 for (
unsigned int i = 0;
i < nHitInChamber;
i++ ) {
120 int this_layer = rechits[
i]->cscDetId().layer();
121 layerIndex[
i] = this_layer;
122 if ( this_layer != old_layer ) {
123 old_layer = this_layer;
128 if ( nLayers < 3 )
return segmentInChamber;
135 reverse( layerIndex.begin(), layerIndex.end() );
136 reverse( rechits.begin(), rechits.end() );
139 else if ( z1 < 0. ) {
141 reverse( layerIndex.begin(), layerIndex.end() );
142 reverse( rechits.begin(), rechits.end() );
151 if ( segShower.
nRecHits() < 3 )
return segmentInChamber;
153 segmentInChamber.push_back(segShower);
155 return segmentInChamber;
168 if ( usedHits[i1-ib] )
continue;
171 int layer1 = layerIndex[i1-ib];
179 if ( usedHits[i2-ib] )
continue;
181 int layer2 = layerIndex[i2-ib];
196 float dz = gp2.
z()-gp1.
z();
234 double directionSign = globalZpos * globalZdir;
245 segmentInChamber.push_back(temp);
247 if (nHitInChamber-
protoSegment.size() < 3)
return segmentInChamber;
248 if (segmentInChamber.size() > 4)
return segmentInChamber;
255 return segmentInChamber;
283 if (
i == i1 ||
i == i2 )
continue;
287 int layer = layerIndex[
i-ib];
288 int layer1 = layerIndex[i1-ib];
289 int layer2 = layerIndex[i2-ib];
292 if (rechits.size() < 9) {
324 int layer = (*i)->cscDetId().layer();
341 double Hphi = Hgp.
phi();
342 if (Hphi < 0.) Hphi += 2.*
M_PI;
350 double Sphi = Sgp.
phi();
351 if (Sphi < 0.) Sphi += 2.*
M_PI;
352 double R =
sqrt(Sgp.
x()*Sgp.
x() + Sgp.
y()*Sgp.
y());
355 if (deltaPhi > 2.*
M_PI) deltaPhi -= 2.*
M_PI;
356 if (deltaPhi < -2.*
M_PI) deltaPhi += 2.*
M_PI;
357 if (deltaPhi < 0.) deltaPhi = -
deltaPhi;
381 if ( aHit == (*it) )
return false;
397 CLHEP::HepMatrix M(4,4,0);
398 CLHEP::HepVector
B(4,0);
400 ChamberHitContainer::const_iterator ih;
414 CLHEP::HepMatrix IC(2,2);
424 LogDebug(
"CSC") <<
"CSCSegment::fitSlopes: failed to invert covariance matrix=\n" << IC <<
"\n";
429 M(1,3) += IC(1,1) *
z;
430 M(1,4) += IC(1,2) *
z;
431 B(1) += u * IC(1,1) + v * IC(1,2);
435 M(2,3) += IC(2,1) *
z;
436 M(2,4) += IC(2,2) *
z;
437 B(2) += u * IC(2,1) + v * IC(2,2);
439 M(3,1) += IC(1,1) *
z;
440 M(3,2) += IC(1,2) *
z;
441 M(3,3) += IC(1,1) * z *
z;
442 M(3,4) += IC(1,2) * z *
z;
443 B(3) += ( u * IC(1,1) + v * IC(1,2) ) * z;
445 M(4,1) += IC(2,1) *
z;
446 M(4,2) += IC(2,2) *
z;
447 M(4,3) += IC(2,1) * z *
z;
448 M(4,4) += IC(2,2) * z *
z;
449 B(4) += ( u * IC(2,1) + v * IC(2,2) ) * z;
452 CLHEP::HepVector
p = solve(M, B);
480 CLHEP::HepMatrix IC(2,2);
490 LogDebug(
"CSC") <<
"CSCSegment::fillChiSquared: failed to invert covariance matrix=\n" << IC <<
"\n";
492 chsq += du*du*IC(1,1) + 2.*du*dv*IC(1,2) + dv*dv*IC(2,2);
506 if ( (*it)->cscDetId().layer() == layer )
return true;
530 ChamberHitContainer::iterator it;
532 if ( (*it)->cscDetId().layer() == layer ) {
542 if ( (
protoChi2 > old_protoChi2) || ( !ok ) ) {
565 for ( iu = ib; iu != rechitsInChamber.end(); ++iu ) {
566 if (*hi == *iu)
usedHits[iu-ib] =
true;
574 for ( iu = ib; iu != rechitsInChamber.end(); ++iu ) {
575 if (*hi == *iu)
usedHits[iu-ib] =
true;
584 std::vector<const CSCRecHit2D*>::const_iterator it;
607 ChamberHitContainer::const_iterator it;
609 CLHEP::HepMatrix
matrix(2*nhits, 4);
679 float maxResidual = 0.;
680 float sumResidual = 0.;
686 ChamberHitContainer::const_iterator ih;
701 float residual =
sqrt(du*du + dv*dv);
703 sumResidual += residual;
705 if ( residual > maxResidual ) {
706 maxResidual = residual;
712 float corrAvgResidual = (sumResidual - maxResidual)/(nHits -1);
724 if ( j != badIndex ) newProtoSegment.push_back(*ih);
730 for ( ih = newProtoSegment.begin(); ih != newProtoSegment.end(); ++ih ) {
void flipErrors(AlgebraicSymMatrix &) const
std::vector< CSCSegment > run(const CSCChamber *aChamber, ChamberHitContainer rechits)
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
CSCSegment showerSeg(const CSCChamber *aChamber, ChamberHitContainer rechits)
CSCDetId cscDetId() const
AlgebraicSymMatrix weightMatrix(void) const
CLHEP::HepMatrix derivativeMatrix(void) const
virtual ~CSCSegAlgoDF()
Destructor.
CSCSegAlgoPreClustering * preCluster_
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)
void orderSecondSeed(GlobalPoint gp1, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2, const ChamberHitContainer &rechits, LayerIndex layerIndex)
bool isHitNearSegment(const CSCRecHit2D *h) const
CSCSegAlgoDF(const edm::ParameterSet &ps)
Constructor.
CSCSegAlgoShowering * showering_
ChamberHitContainer secondSeedHits
void updateParameters(void)
std::deque< bool > BoolContainer
const Surface::PositionType & position() const
The position (origin of the R.F.)
std::vector< std::vector< const CSCRecHit2D * > > clusterHits(const CSCChamber *aChamber, ChamberHitContainer rechits)
clusterize
CLHEP::HepMatrix AlgebraicMatrix
LocalError localPositionError() const
LocalPoint protoIntercept
void compareProtoSegment(const CSCRecHit2D *h, int layer)
std::vector< CSCSegment > buildSegments(ChamberHitContainer rechits)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
std::vector< int > LayerIndex
Typedefs.
int minHitsForPreClustering
void flagHitsAsUsed(const ChamberHitContainer &rechitsInChamber)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
CLHEP::HepSymMatrix AlgebraicSymMatrix
void tryAddingHitsToSegment(const ChamberHitContainer &rechitsInChamber, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2, LayerIndex layerIndex)
Utility functions.
AlgebraicSymMatrix calculateError(void) const
const CSCChamber * theChamber
LocalVector protoDirection
LocalPoint localPosition() const
int nHitsPerClusterIsShower
bool hasHitOnLayer(int layer) const