22 myName(
"CSCSegAlgoSK") {
35 <<
"--------------------------------------------------------------------\n"
36 <<
"dRPhiMax = " << dRPhiMax <<
'\n'
37 <<
"dPhiMax = " << dPhiMax <<
'\n'
38 <<
"dRPhiFineMax = " << dRPhiFineMax <<
'\n'
39 <<
"dPhiFineMax = " << dPhiFineMax <<
'\n'
40 <<
"chi2Max = " << chi2Max <<
'\n'
41 <<
"wideSeg = " << wideSeg <<
'\n'
42 <<
"minLayersApart = " << minLayersApart << std::endl;
52 LogDebug(
"CSC") <<
"*********************************************";
54 LogDebug(
"CSC") <<
"*********************************************";
59 for(
unsigned int i = 0;
i < rechits.size();
i++) {
61 layerIndex[
i] = rechits[
i]->cscDetId().layer();
69 reverse(layerIndex.begin(), layerIndex.end());
70 reverse(rechits.begin(), rechits.end());
75 reverse(layerIndex.begin(), layerIndex.end());
76 reverse(rechits.begin(), rechits.end());
85 if (rechits.size() < 2) {
87 " hit(s) in chamber is not enough to build a segment.\n";
88 return std::vector<CSCSegment>();
108 std::vector<CSCSegment> segments;
116 int npass = (
wideSeg > 1.)? 2 : 1;
118 for (
int ipass = 0; ipass < npass; ++ipass) {
124 int layer1 = layerIndex[i1-
ib];
131 int layer2 = layerIndex[i2-
ib];
145 LogDebug(
"CSC") <<
"start new segment from hits " <<
"h1: "
146 << gp1 <<
" - h2: " << gp2 <<
"\n";
148 if (!
addHit(h1, layer1)) {
149 LogDebug(
"CSC") <<
" failed to add hit h1\n";
153 if (!
addHit(h2, layer2)) {
154 LogDebug(
"CSC") <<
" failed to add hit h2\n";
169 LogDebug(
"CSC") <<
"No segment has been found !!!\n";
183 LogDebug(
"CSC") <<
"Found a segment !!!\n";
184 segments.push_back(temp);
194 if (segments.size() > 1)
224 if (
i == i1 ||
i == i2 || used[
i-ib])
227 int layer = layerIndex[
i-
ib];
232 LogDebug(
"CSC") <<
" hit at global " << gp1 <<
" is near segment\n.";
238 <<
" hits on segment...skip hit on same layer.\n";
253 LogDebug(
"CSC") <<
" Hits at local x= " << h1x <<
", "
254 << h2x <<
" have separation= " << deltaX;
265 float h1p = gp1.
phi();
266 float h2p = gp2.
phi();
267 float dphi12 = h1p - h2p;
274 LogDebug(
"CSC") <<
" Hits at global phi= " << h1p <<
", "
275 << h2p <<
" have separation= " << dphi12;
290 float hphi = hp.
phi();
294 float phidif = sphi-hphi;
300 float dRPhi = fabs(phidif)*hp.
perp();
301 LogDebug(
"CSC") <<
" is hit at phi_h= " << hphi <<
" near segment phi_seg= " << sphi
306 (fabs(phidif) <
dPhiFineMax*windowScale))?
true:
false;
316 float x = gp.
x() + (gv.
x()/gv.
z())*(z - gp.
z());
317 float y = gp.
y() + (gv.
y()/gv.
z())*(z - gp.
z());
318 float phi = atan2(y, x);
330 for(it=rechits.begin(); it!=rechits.end(); it++) {
335 edm::LogInfo(
"CSC") <<
"Global pos.: " << gp1 <<
", phi: " << gp1.
phi() <<
". Local position: "
336 << (*it)->localPosition() <<
", phi: "
337 << (*it)->localPosition().
phi() <<
". Layer: "
338 << (*it)->cscDetId().layer() <<
"\n";
349 unsigned int iadd = ( rechitsInChamber.size() > 20 )? 1 : 0;
368 for(iu = ib; iu != rechitsInChamber.end(); ++iu) {
381 ChamberHitContainer::const_iterator it;
384 if (((*it)->cscDetId().layer() == layer) && (aHit != (*it)))
413 ChamberHitContainer::const_iterator ih =
proto_segment.begin();
414 int il1 = (*ih)->cscDetId().layer();
437 float dz = h2pos.
z()-h1pos.
z();
438 uz = (h2pos.
x()-h1pos.
x())/dz ;
439 vz = (h2pos.
y()-h1pos.
y())/dz ;
534 CLHEP::HepMatrix M(4,4,0);
535 CLHEP::HepVector
B(4,0);
537 ChamberHitContainer::const_iterator ih =
proto_segment.begin();
552 CLHEP::HepMatrix IC(2,2);
562 LogDebug(
"CSC") <<
"CSCSegment::fitSlopes: failed to invert covariance matrix=\n" << IC <<
"\n";
571 M(1,3) += IC(1,1) *
z;
572 M(1,4) += IC(1,2) *
z;
573 B(1) += u * IC(1,1) + v * IC(1,2);
577 M(2,3) += IC(2,1) *
z;
578 M(2,4) += IC(2,2) *
z;
579 B(2) += u * IC(2,1) + v * IC(2,2);
581 M(3,1) += IC(1,1) *
z;
582 M(3,2) += IC(1,2) *
z;
583 M(3,3) += IC(1,1) * z *
z;
584 M(3,4) += IC(1,2) * z *
z;
585 B(3) += ( u * IC(1,1) + v * IC(1,2) ) * z;
587 M(4,1) += IC(2,1) *
z;
588 M(4,2) += IC(2,2) *
z;
589 M(4,3) += IC(2,1) * z *
z;
590 M(4,4) += IC(2,2) * z *
z;
591 B(4) += ( u * IC(2,1) + v * IC(2,2) ) * z;
596 CLHEP::HepVector
p = solve(M, B);
615 ChamberHitContainer::const_iterator ih;
627 double du = u0 +
uz * hz - hu;
628 double dv = v0 +
vz * hz -
hv;
630 CLHEP::HepMatrix IC(2,2);
640 LogDebug(
"CSC") <<
"CSCSegment::fillChiSquared: failed to invert covariance matrix=\n" << IC <<
"\n";
645 chsq += du*du*IC(1,1) + 2.*du*dv*IC(1,2) + dv*dv*IC(2,2);
656 double dz = 1./
sqrt(1. + dxdz*dxdz + dydz*dydz);
667 double directionSign = globalZpos * globalZdir;
679 if ((*it)->cscDetId().layer() == layer)
688 ChamberHitContainer::iterator it;
690 if ((*it)->cscDetId().layer() == layer)
710 LogDebug(
"CSC") <<
" hit in same layer as a hit on segment; try replacing old one..."
711 <<
" chi2 new: " <<
theChi2 <<
" old: " << oldChi2 <<
"\n";
714 if ((
theChi2 < oldChi2) && (ok)) {
715 LogDebug(
"CSC") <<
" segment with replaced hit is better.\n";
735 LogDebug(
"CSC") <<
" hit in new layer: added to segment, new chi2: "
742 LogDebug(
"CSC") <<
" segment with added hit is good.\n" ;
754 ChamberHitContainer::const_iterator it;
756 CLHEP::HepMatrix
matrix(2*nhits, 4);
779 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.
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
Abs< T >::type abs(const T &t)
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.
float phiAtZ(float z) const
void updateParameters(void)
CSCSegAlgoSK(const edm::ParameterSet &ps)
Constructor.
std::vector< CSCSegment > buildSegments(const ChamberHitContainer &rechits)
bool hasHitOnLayer(int layer) const
std::vector< int > LayerIndex
Typedefs.
std::vector< CSCSegment > run(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
CLHEP::HepSymMatrix AlgebraicSymMatrix
bool isSegmentGood(const ChamberHitContainer &rechitsInChamber) const
std::vector< const CSCRecHit2D * > ChamberHitContainer
void tryAddingHitsToSegment(const ChamberHitContainer &rechitsInChamber, const BoolContainer &used, const LayerIndex &layerIndex, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2)
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)