CMS 3D CMS Logo

GEMCSCSegment.cc
Go to the documentation of this file.
1 
8 #include <iostream>
9 
10 
11 namespace {
12  // Get CSCDetId from one of the rechits, but then remove the layer part so it's a _chamber_ id
13  inline
14  DetId buildDetId(CSCDetId id) {
15  return CSCDetId (id.endcap(),id.station(),id.ring(),id.chamber(),0);
16  }
17 }
18 
19 
21  // Aider class to make the return of the projection Matrix thread-safe
22 protected:
24 public:
25  ProjectionMatrixDiag() : theProjectionMatrix(4,5,0) {
26  theProjectionMatrix[0][1] = 1;
27  theProjectionMatrix[1][2] = 1;
28  theProjectionMatrix[2][3] = 1;
29  theProjectionMatrix[3][4] = 1;
30  }
31  const AlgebraicMatrix &getMatrix() const {
32  return (theProjectionMatrix);
33  }
34 };
35 
36 
37 
38 
39 GEMCSCSegment::GEMCSCSegment(const CSCSegment* csc_segment, const std::vector<const GEMRecHit*> gem_rhs, LocalPoint origin, LocalVector direction, AlgebraicSymMatrix errors, double chi2) :
40 
41  RecSegment(buildDetId(csc_segment->cscDetId())),
42  theOrigin(origin),
43  theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2) {
44 
45  for(unsigned int i=0; i<gem_rhs.size(); ++i) {
46  theGEMRecHits.push_back((*gem_rhs[i]));
47  }
48  theCSCSegment = *csc_segment;
49  // LogDebug
50  edm::LogVerbatim("GEMCSCSegment")<< "[GEMCSCSegment :: ctor] CSCDetId: " << csc_segment->cscDetId() << " CSC RecHits: " <<csc_segment->specificRecHits().size()
51  << " GEM RecHits: " << gem_rhs.size()<<"\n" // << " Fit chi2: "<<chi2<<" Position: "<<origin<<" Direction: "<<direction
52  << " CSC Segment Details: \n"<<*csc_segment<<"\n"
53  << " GEMCSC Segment Details: \n"<<*this<<"\n"
54  << "[GEMCSCSegment :: ctor] ------------------------------------------------------------";
55 }
56 
57 
59 
60 
61 std::vector<const TrackingRecHit*> GEMCSCSegment::recHits() const{
62 
63  std::vector<const TrackingRecHit*> pointersOfRecHits;
64  for (std::vector<GEMRecHit>::const_iterator irh = theGEMRecHits.begin(); irh!=theGEMRecHits.end(); ++irh) {
65  pointersOfRecHits.push_back(&(*irh));
66  }
67  for (std::vector<CSCRecHit2D>::const_iterator irh = theCSCSegment.specificRecHits().begin(); irh!=theCSCSegment.specificRecHits().end(); ++irh) {
68  pointersOfRecHits.push_back(&(*irh));
69  }
70  return pointersOfRecHits;
71 }
72 
73 std::vector<TrackingRecHit*> GEMCSCSegment::recHits() {
74 
75  std::vector<TrackingRecHit*> pointersOfRecHits;
76  for (std::vector<GEMRecHit>::iterator irh = theGEMRecHits.begin(); irh!=theGEMRecHits.end(); ++irh) {
77  pointersOfRecHits.push_back(&(*irh));
78  }
79  return pointersOfRecHits;
80 }
81 
82 
84  return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
85 }
86 
87 
89  return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
90 }
91 
92 
94  // For consistency with DT, CSC and what we require for the TrackingRecHit interface,
95  // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z)
96 
98  if(theLocalDirection.z()!=0) {
99  result[0] = theLocalDirection.x()/theLocalDirection.z();
100  result[1] = theLocalDirection.y()/theLocalDirection.z();
101  }
102  result[2] = theOrigin.x();
103  result[3] = theOrigin.y();
104  return result;
105 }
106 
109  return (theProjectionMatrix.getMatrix());
110 }
111 
112 
113 
114 
115 std::ostream& operator<<(std::ostream& os, const GEMCSCSegment& seg) {
116  os << "GEMCSCSegment: local pos = " << seg.localPosition() <<
117  " posErr = (" << sqrt(seg.localPositionError().xx())<<","<<sqrt(seg.localPositionError().yy())<<
118  "0,)\n"<<
119  " dir = " << seg.localDirection() <<
120  " dirErr = (" << sqrt(seg.localDirectionError().xx())<<","<<sqrt(seg.localDirectionError().yy())<<
121  "0,)\n"<<
122  " chi2/ndf = " << ((seg.degreesOfFreedom()!=0)?(seg.chi2()/double(seg.degreesOfFreedom())):0.0) <<
123  " #rechits = " << seg.nRecHits();
124  return os;
125 }
126 
127 
float xx() const
Definition: LocalError.h:24
LocalPoint theOrigin
Definition: GEMCSCSegment.h:89
CSCDetId cscDetId() const
Definition: CSCSegment.h:69
T y() const
Definition: PV3DBase.h:63
LocalError localPositionError() const
GEMCSCSegment()
Default constructor.
Definition: GEMCSCSegment.h:31
LocalError localDirectionError() const
Error on the local direction.
std::vector< GEMRecHit > theGEMRecHits
Definition: GEMCSCSegment.h:83
CSCSegment theCSCSegment
Definition: GEMCSCSegment.h:84
int nRecHits() const
Definition: GEMCSCSegment.h:63
AlgebraicMatrix theProjectionMatrix
static const AlgebraicMatrix theProjectionMatrix
Definition: CSCSegment.cc:80
virtual ~GEMCSCSegment()
Destructor.
LocalPoint localPosition() const
Definition: GEMCSCSegment.h:42
AlgebraicVector parameters() const
Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y )
CLHEP::HepMatrix AlgebraicMatrix
LocalVector localDirection() const
Local direction.
Definition: GEMCSCSegment.h:45
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
AlgebraicSymMatrix theCovMatrix
Definition: GEMCSCSegment.h:91
const std::vector< CSCRecHit2D > & specificRecHits() const
Definition: CSCSegment.h:65
Definition: DetId.h:18
CLHEP::HepVector AlgebraicVector
virtual AlgebraicMatrix projectionMatrix() const
The projection matrix relates the trajectory state parameters to the segment parameters().
std::ostream & operator<<(std::ostream &os, const GEMCSCSegment &seg)
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
LocalVector theLocalDirection
Definition: GEMCSCSegment.h:90
CLHEP::HepSymMatrix AlgebraicSymMatrix
virtual int degreesOfFreedom() const
Degrees of freedom of the segment fit.
Definition: GEMCSCSegment.h:61
Definition: errors.py:1
const AlgebraicMatrix & getMatrix() const
T x() const
Definition: PV3DBase.h:62
double chi2() const
Chi2 of the segment fit.
Definition: GEMCSCSegment.h:57