56 std::vector<float>
x,
y, gz;
60 for (
int i = 0;
i < 6; ++
i) {
68 for (ChamberHitContainer::const_iterator it = rechits.begin(); it != rechits.end(); it++ ) {
71 int l_id =
id.
layer();
79 gz[l_id -1] += gp.
z();
84 float avgChamberX = 0.;
85 float avgChamberY = 0.;
88 for (
unsigned i = 0;
i < 6; ++
i) {
89 if (n[
i] < 1 )
continue;
100 avgChamberX = avgChamberX / n_lay;
101 avgChamberY = avgChamberY / n_lay;
107 LocalPoint lpCOM(avgChamberX, avgChamberY, 0.);
111 float Gdxdz = gpCOM.
x()/gpCOM.
z();
112 float Gdydz = gpCOM.
y()/gpCOM.
z();
116 std::vector<LocalPoint> layerPoints;
118 for (
unsigned i = 1;
i < 7;
i++) {
123 float layer_Z = gp.
z();
126 float layer_X = Gdxdz * layer_Z;
127 float layer_Y = Gdydz * layer_Z;
131 float layerX = Lintersect.
x();
132 float layerY = Lintersect.
y();
133 float layerZ = Lintersect.
z();
134 LocalPoint layerPoint(layerX, layerY, layerZ);
135 layerPoints.push_back(layerPoint);
139 std::vector<float> r_closest;
141 for (
unsigned i = 0;
i < 6; ++
i ) {
143 r_closest.push_back(9999.);
149 for (ChamberHitContainer::const_iterator it = rechits.begin(); it != rechits.end(); it++ ) {
156 float d_x = lp.
x() - layerPoints[layId-1].x();
157 float d_y = lp.
y() - layerPoints[layId-1].y();
161 if ( fabs(diff.
mag() ) < r_closest[layId-1] ) {
162 r_closest[layId-1] = fabs(diff.
mag());
173 for (ChamberHitContainer::const_iterator it = rechits.begin(); it != rechits.end(); it++ ) {
184 if ( gz[0] > gz[5] ) {
188 else if ( gz[0] < 0. ) {
189 if ( gz[0] < gz[5] ) {
202 for (ChamberHitContainer::const_iterator it = rechits.begin(); it != rechits.end(); it++ ) {
225 double directionSign = globalZpos * globalZdir;
230 double protoTheta = protoGlobalDir.
theta();
231 double protoPhi = protoGlobalDir.
phi();
232 double simTheta = gvCOM.theta();
233 double simPhi = gvCOM.phi();
235 float dTheta = fabs(protoTheta - simTheta);
236 float dPhi = fabs(protoPhi - simPhi);
270 double Hphi = Hgp.
phi();
271 if (Hphi < 0.) Hphi += 2.*
M_PI;
279 double Sphi = Sgp.
phi();
280 if (Sphi < 0.) Sphi += 2.*
M_PI;
281 double R =
sqrt(Sgp.
x()*Sgp.
x() + Sgp.
y()*Sgp.
y());
284 if (deltaPhi > 2.*
M_PI) deltaPhi -= 2.*
M_PI;
285 if (deltaPhi < -2.*
M_PI) deltaPhi += 2.*
M_PI;
286 if (deltaPhi < 0.) deltaPhi = -
deltaPhi;
310 if ( aHit == (*it) )
return false;
326 CLHEP::HepMatrix M(4,4,0);
327 CLHEP::HepVector
B(4,0);
329 ChamberHitContainer::const_iterator ih;
343 CLHEP::HepMatrix IC(2,2);
353 LogDebug(
"CSC") <<
"CSCSegment::fitSlopes: failed to invert covariance matrix=\n" << IC <<
"\n";
358 M(1,3) += IC(1,1) *
z;
359 M(1,4) += IC(1,2) *
z;
360 B(1) += u * IC(1,1) + v * IC(1,2);
364 M(2,3) += IC(2,1) *
z;
365 M(2,4) += IC(2,2) *
z;
366 B(2) += u * IC(2,1) + v * IC(2,2);
368 M(3,1) += IC(1,1) *
z;
369 M(3,2) += IC(1,2) *
z;
370 M(3,3) += IC(1,1) * z *
z;
371 M(3,4) += IC(1,2) * z *
z;
372 B(3) += ( u * IC(1,1) + v * IC(1,2) ) * z;
374 M(4,1) += IC(2,1) *
z;
375 M(4,2) += IC(2,2) *
z;
376 M(4,3) += IC(2,1) * z *
z;
377 M(4,4) += IC(2,2) * z *
z;
378 B(4) += ( u * IC(2,1) + v * IC(2,2) ) * z;
381 CLHEP::HepVector
p = solve(M, B);
408 CLHEP::HepMatrix IC(2,2);
418 LogDebug(
"CSC") <<
"CSCSegment::fillChiSquared: failed to invert covariance matrix=\n" << IC <<
"\n";
420 chsq += du*du*IC(1,1) + 2.*du*dv*IC(1,2) + dv*dv*IC(2,2);
445 ChamberHitContainer::iterator it;
447 if ( (*it)->cscDetId().layer() == layer ) {
457 if ( (
protoChi2 > old_protoChi2) || ( !ok ) ) {
469 std::vector<const CSCRecHit2D*>::const_iterator it;
492 ChamberHitContainer::const_iterator it;
494 CLHEP::HepMatrix
matrix(2*nhits, 4);
563 float maxResidual = 0.;
564 float sumResidual = 0.;
570 ChamberHitContainer::const_iterator ih;
585 float residual =
sqrt(du*du + dv*dv);
587 sumResidual += residual;
589 if ( residual > maxResidual ) {
590 maxResidual = residual;
596 float corrAvgResidual = (sumResidual - maxResidual)/(nHits -1);
608 if ( j != badIndex ) newProtoSegment.push_back(*ih);
614 for ( ih = newProtoSegment.begin(); ih != newProtoSegment.end(); ++ih ) {
T getParameter(std::string const &) const
CSCSegment showerSeg(const CSCChamber *aChamber, ChamberHitContainer rechits)
CSCDetId cscDetId() const
void updateParameters(void)
void compareProtoSegment(const CSCRecHit2D *h, int layer)
AlgebraicSymMatrix calculateError(void) const
bool isHitNearSegment(const CSCRecHit2D *h) const
Utility functions.
virtual ~CSCSegAlgoShowering()
Destructor.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Geom::Phi< T > phi() const
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Geom::Theta< T > theta() const
bool addHit(const CSCRecHit2D *hit, int layer)
LocalVector protoDirection
CLHEP::HepMatrix AlgebraicMatrix
LocalError localPositionError() const
double dPhi(double phi1, double phi2)
CSCSegAlgoShowering(const edm::ParameterSet &ps)
Constructor.
LocalPoint protoIntercept
CLHEP::HepMatrix derivativeMatrix(void) const
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
std::vector< const CSCRecHit2D * > ChamberHitContainer
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void flipErrors(AlgebraicSymMatrix &) const
AlgebraicSymMatrix weightMatrix(void) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
LocalPoint localPosition() const
const CSCChamber * theChamber
ChamberHitContainer protoSegment