24 myName(
"CSCSegAlgoSK") {
37 <<
"--------------------------------------------------------------------\n"
38 <<
"dRPhiMax = " << dRPhiMax <<
'\n'
39 <<
"dPhiMax = " << dPhiMax <<
'\n'
40 <<
"dRPhiFineMax = " << dRPhiFineMax <<
'\n'
41 <<
"dPhiFineMax = " << dPhiFineMax <<
'\n'
42 <<
"chi2Max = " << chi2Max <<
'\n'
43 <<
"wideSeg = " << wideSeg <<
'\n'
44 <<
"minLayersApart = " << minLayersApart << std::endl;
54 LogDebug(
"CSC") <<
"*********************************************";
56 LogDebug(
"CSC") <<
"*********************************************";
61 for(
unsigned int i = 0;
i < rechits.size();
i++) {
63 layerIndex[
i] = rechits[
i]->cscDetId().layer();
71 reverse(layerIndex.begin(), layerIndex.end());
72 reverse(rechits.begin(), rechits.end());
77 reverse(layerIndex.begin(), layerIndex.end());
78 reverse(rechits.begin(), rechits.end());
87 if (rechits.size() < 2) {
89 " hit(s) in chamber is not enough to build a segment.\n";
90 return std::vector<CSCSegment>();
110 std::vector<CSCSegment> segments;
118 int npass = (
wideSeg > 1.)? 2 : 1;
120 for (
int ipass = 0; ipass < npass; ++ipass) {
126 int layer1 = layerIndex[i1-ib];
133 int layer2 = layerIndex[i2-ib];
147 LogDebug(
"CSC") <<
"start new segment from hits " <<
"h1: "
148 << gp1 <<
" - h2: " << gp2 <<
"\n";
150 if (!
addHit(h1, layer1)) {
151 LogDebug(
"CSC") <<
" failed to add hit h1\n";
155 if (!
addHit(h2, layer2)) {
156 LogDebug(
"CSC") <<
" failed to add hit h2\n";
171 LogDebug(
"CSC") <<
"No segment has been found !!!\n";
185 LogDebug(
"CSC") <<
"Found a segment !!!\n";
186 segments.push_back(temp);
196 if (segments.size() > 1)
226 if (
i == i1 ||
i == i2 || used[
i-ib])
229 int layer = layerIndex[
i-ib];
234 LogDebug(
"CSC") <<
" hit at global " << gp1 <<
" is near segment\n.";
240 <<
" hits on segment...skip hit on same layer.\n";
255 LogDebug(
"CSC") <<
" Hits at local x= " << h1x <<
", "
256 << h2x <<
" have separation= " << deltaX;
267 float h1p = gp1.
phi();
268 float h2p = gp2.
phi();
269 float dphi12 = h1p - h2p;
276 LogDebug(
"CSC") <<
" Hits at global phi= " << h1p <<
", "
277 << h2p <<
" have separation= " << dphi12;
292 float hphi = hp.
phi();
296 float phidif = sphi-hphi;
302 float dRPhi = fabs(phidif)*hp.
perp();
303 LogDebug(
"CSC") <<
" is hit at phi_h= " << hphi <<
" near segment phi_seg= " << sphi
308 (fabs(phidif) <
dPhiFineMax*windowScale))?
true:
false;
318 float x = gp.
x() + (gv.
x()/gv.
z())*(z - gp.
z());
319 float y = gp.
y() + (gv.
y()/gv.
z())*(z - gp.
z());
320 float phi = atan2(y, x);
332 for(it=rechits.begin(); it!=rechits.end(); it++) {
337 edm::LogInfo(
"CSC") <<
"Global pos.: " << gp1 <<
", phi: " << gp1.
phi() <<
". Local position: "
338 << (*it)->localPosition() <<
", phi: "
339 << (*it)->localPosition().phi() <<
". Layer: "
340 << (*it)->cscDetId().layer() <<
"\n";
351 unsigned int iadd = ( rechitsInChamber.size() > 20 )? 1 : 0;
370 for(iu = ib; iu != rechitsInChamber.end(); ++iu) {
383 ChamberHitContainer::const_iterator it;
386 if (((*it)->cscDetId().layer() == layer) && (aHit != (*it)))
415 ChamberHitContainer::const_iterator ih =
proto_segment.begin();
416 int il1 = (*ih)->cscDetId().layer();
439 float dz = h2pos.
z()-h1pos.
z();
440 uz = (h2pos.
x()-h1pos.
x())/dz ;
441 vz = (h2pos.
y()-h1pos.
y())/dz ;
536 CLHEP::HepMatrix M(4,4,0);
537 CLHEP::HepVector
B(4,0);
539 ChamberHitContainer::const_iterator ih =
proto_segment.begin();
554 CLHEP::HepMatrix IC(2,2);
564 LogDebug(
"CSC") <<
"CSCSegment::fitSlopes: failed to invert covariance matrix=\n" << IC <<
"\n";
573 M(1,3) += IC(1,1) *
z;
574 M(1,4) += IC(1,2) *
z;
575 B(1) += u * IC(1,1) + v * IC(1,2);
579 M(2,3) += IC(2,1) *
z;
580 M(2,4) += IC(2,2) *
z;
581 B(2) += u * IC(2,1) + v * IC(2,2);
583 M(3,1) += IC(1,1) *
z;
584 M(3,2) += IC(1,2) *
z;
585 M(3,3) += IC(1,1) * z *
z;
586 M(3,4) += IC(1,2) * z *
z;
587 B(3) += ( u * IC(1,1) + v * IC(1,2) ) * z;
589 M(4,1) += IC(2,1) *
z;
590 M(4,2) += IC(2,2) *
z;
591 M(4,3) += IC(2,1) * z *
z;
592 M(4,4) += IC(2,2) * z *
z;
593 B(4) += ( u * IC(2,1) + v * IC(2,2) ) * z;
598 CLHEP::HepVector
p = solve(M, B);
617 ChamberHitContainer::const_iterator ih;
629 double du = u0 +
uz * hz - hu;
630 double dv = v0 +
vz * hz - hv;
632 CLHEP::HepMatrix IC(2,2);
642 LogDebug(
"CSC") <<
"CSCSegment::fillChiSquared: failed to invert covariance matrix=\n" << IC <<
"\n";
647 chsq += du*du*IC(1,1) + 2.*du*dv*IC(1,2) + dv*dv*IC(2,2);
658 double dz = 1./
sqrt(1. + dxdz*dxdz + dydz*dydz);
669 double directionSign = globalZpos * globalZdir;
681 if ((*it)->cscDetId().layer() == layer)
690 ChamberHitContainer::iterator it;
692 if ((*it)->cscDetId().layer() == layer)
712 LogDebug(
"CSC") <<
" hit in same layer as a hit on segment; try replacing old one..."
713 <<
" chi2 new: " <<
theChi2 <<
" old: " << oldChi2 <<
"\n";
716 if ((
theChi2 < oldChi2) && (ok)) {
717 LogDebug(
"CSC") <<
" segment with replaced hit is better.\n";
737 LogDebug(
"CSC") <<
" hit in new layer: added to segment, new chi2: "
744 LogDebug(
"CSC") <<
" segment with added hit is good.\n" ;
756 ChamberHitContainer::const_iterator it;
758 CLHEP::HepMatrix
matrix(2*nhits, 4);
781 std::vector<const CSCRecHit2D*>::const_iterator it;
void dumpHits(const ChamberHitContainer &rechits) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
CSCDetId cscDetId() const
AlgebraicSymMatrix weightMatrix(void) const
void fillChiSquared(void)
bool areHitsCloseInLocalX(const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
Utility functions.
ChamberHitContainer proto_segment
void flagHitsAsUsed(const ChamberHitContainer &rechitsInChamber, BoolContainer &used) const
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
bool replaceHit(const CSCRecHit2D *h, int layer)
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.
std::vector< CSCSegment > buildSegments(ChamberHitContainer rechits)
bool addHit(const CSCRecHit2D *hit, int layer)
Utility functions.
bool isHitNearSegment(const CSCRecHit2D *h) const
std::string chamberTypeName() const
AlgebraicSymMatrix calculateError(void) const
const Surface::PositionType & position() const
The position (origin of the R.F.)
const CSCChamberSpecs * specs() const
CLHEP::HepMatrix AlgebraicMatrix
LocalError localPositionError() const
void increaseProtoSegment(const CSCRecHit2D *h, int layer)
void flipErrors(AlgebraicSymMatrix &) const
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
float phiAtZ(float z) const
void updateParameters(void)
CSCSegAlgoSK(const edm::ParameterSet &ps)
Constructor.
bool hasHitOnLayer(int layer) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void tryAddingHitsToSegment(const ChamberHitContainer &rechitsInChamber, BoolContainer used, LayerIndex layerIndex, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2)
std::vector< int > LayerIndex
Typedefs.
CLHEP::HepSymMatrix AlgebraicSymMatrix
bool isSegmentGood(const ChamberHitContainer &rechitsInChamber) const
std::vector< const CSCRecHit2D * > ChamberHitContainer
std::vector< CSCSegment > run(const CSCChamber *aChamber, ChamberHitContainer rechits)
CLHEP::HepMatrix derivativeMatrix(void) const
LocalPoint localPosition() const
bool areHitsCloseInGlobalPhi(const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
std::deque< bool > BoolContainer
void compareProtoSegment(const CSCRecHit2D *h, int layer)
const CSCChamber * theChamber
void fillLocalDirection(void)