CMS 3D CMS Logo

GEMSegment.cc
Go to the documentation of this file.
1 
7 #include <iostream>
8 
9 namespace {
10  // create reference GEM Chamber ID for segment
11  inline
12  DetId buildDetId(GEMDetId id) {
13  return GEMDetId(id.superChamberId());
14  }
15 }
16 
18  // Aider class to make the return of the projection Matrix thread-safe
19 protected:
21 public:
22  ProjectionMatrixDiag() : theProjectionMatrix(4,5,0) {
23  theProjectionMatrix[0][1] = 1;
24  theProjectionMatrix[1][2] = 1;
25  theProjectionMatrix[2][3] = 1;
26  theProjectionMatrix[3][4] = 1;
27  }
28  const AlgebraicMatrix &getMatrix() const {
29  return (theProjectionMatrix);
30  }
31 };
32 
33 
34 GEMSegment::GEMSegment(const std::vector<const GEMRecHit*>& proto_segment, const LocalPoint& origin,
35  const LocalVector& direction, const AlgebraicSymMatrix& errors, double chi2) :
36  RecSegment(buildDetId(proto_segment.front()->gemId())),
37  theOrigin(origin),
38  theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2){
39  theTimeValue = 0.0;
40  theTimeUncrt = 0.0;
41  theBX = -10.0;
42  for(unsigned int i=0; i<proto_segment.size(); ++i)
43  theGEMRecHits.push_back(*proto_segment[i]);
44 }
45 
46 GEMSegment::GEMSegment(const std::vector<const GEMRecHit*>& proto_segment, const LocalPoint& origin,
47  const LocalVector& direction, const AlgebraicSymMatrix& errors, double chi2, float bx) :
48  RecSegment(buildDetId(proto_segment.front()->gemId())),
49  theOrigin(origin),
50  theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2){
51  theTimeValue = 0.0;
52  theTimeUncrt = 0.0;
53  theBX = bx;
54  for(unsigned int i=0; i<proto_segment.size(); ++i)
55  theGEMRecHits.push_back(*proto_segment[i]);
56 }
57 
58 GEMSegment::GEMSegment(const std::vector<const GEMRecHit*>& proto_segment, const LocalPoint& origin,
59  const LocalVector& direction, const AlgebraicSymMatrix& errors, double chi2, double time, double timeErr) :
60  RecSegment(buildDetId(proto_segment.front()->gemId())),
61  theOrigin(origin),
62  theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2){
65  theBX = -10.0;
66  for(unsigned int i=0; i<proto_segment.size(); ++i)
67  theGEMRecHits.push_back(*proto_segment[i]);
68 }
69 
71 
72 std::vector<const TrackingRecHit*> GEMSegment::recHits() const{
73  std::vector<const TrackingRecHit*> pointersOfRecHits;
74  for (std::vector<GEMRecHit>::const_iterator irh = theGEMRecHits.begin(); irh!=theGEMRecHits.end(); ++irh) {
75  pointersOfRecHits.push_back(&(*irh));
76  }
77  return pointersOfRecHits;
78 }
79 
80 std::vector<TrackingRecHit*> GEMSegment::recHits() {
81 
82  std::vector<TrackingRecHit*> pointersOfRecHits;
83  for (std::vector<GEMRecHit>::iterator irh = theGEMRecHits.begin(); irh!=theGEMRecHits.end(); ++irh) {
84  pointersOfRecHits.push_back(&(*irh));
85  }
86  return pointersOfRecHits;
87 }
88 
90  return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
91 }
92 
94  return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
95 }
96 
97 
99  // For consistency with DT and CSC and what we require for the TrackingRecHit interface,
100  // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z)
101 
103 
104  if(theLocalDirection.z() != 0)
105  {
106  result[0] = theLocalDirection.x()/theLocalDirection.z();
107  result[1] = theLocalDirection.y()/theLocalDirection.z();
108  }
109  result[2] = theOrigin.x();
110  result[3] = theOrigin.y();
111 
112  return result;
113 }
114 
117  return (theProjectionMatrix.getMatrix());
118 }
119 
120 //
121 void GEMSegment::print() const {
122  LogDebug("GEMSegment") << *this;
123 
124 }
125 
126 std::ostream& operator<<(std::ostream& os, const GEMSegment& seg) {
127  os << "GEMSegment: local pos = " << seg.localPosition() <<
128  " posErr = (" << sqrt(seg.localPositionError().xx())<<","<<sqrt(seg.localPositionError().yy())<<
129  "0,)\n"<<
130  " dir = " << seg.localDirection() <<
131  " dirErr = (" << sqrt(seg.localDirectionError().xx())<<","<<sqrt(seg.localDirectionError().yy())<<
132  "0,)\n"<<
133  " chi2/ndf = " << ((seg.degreesOfFreedom() != 0.) ? seg.chi2()/double(seg.degreesOfFreedom()) :0 ) <<
134  " #rechits = " << seg.specificRecHits().size()<<
135  " bx = "<< seg.bunchX() <<
136  " time = "<< seg.time() << " +/- " << seg.timeErr() << " ns";
137 
138  return os;
139 }
140 
#define LogDebug(id)
std::ostream & operator<<(std::ostream &os, const GEMSegment &seg)
Definition: GEMSegment.cc:126
float xx() const
Definition: LocalError.h:24
float bunchX() const
Definition: GEMSegment.h:77
LocalError localPositionError() const override
Definition: GEMSegment.cc:89
LocalVector localDirection() const override
Local direction.
Definition: GEMSegment.h:45
float theBX
Definition: GEMSegment.h:89
T y() const
Definition: PV3DBase.h:63
double theTimeValue
Definition: GEMSegment.h:87
AlgebraicMatrix theProjectionMatrix
static const AlgebraicMatrix theProjectionMatrix
Definition: CSCSegment.cc:80
double theTimeUncrt
Definition: GEMSegment.h:88
~GEMSegment() override
Destructor.
Definition: GEMSegment.cc:70
LocalVector theLocalDirection
Definition: GEMSegment.h:84
int degreesOfFreedom() const override
Degrees of freedom of the segment fit.
Definition: GEMSegment.h:65
CLHEP::HepMatrix AlgebraicMatrix
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:18
float time() const
Definition: GEMSegment.h:75
AlgebraicMatrix projectionMatrix() const override
The projection matrix relates the trajectory state parameters to the segment parameters().
Definition: GEMSegment.cc:115
T z() const
Definition: PV3DBase.h:64
LocalPoint theOrigin
Definition: GEMSegment.h:83
double chi2() const override
Chi2 of the segment fit.
Definition: GEMSegment.h:61
LocalPoint localPosition() const override
Definition: GEMSegment.h:42
Definition: DetId.h:18
CLHEP::HepVector AlgebraicVector
GEMSegment()
Default constructor.
Definition: GEMSegment.h:24
double theChi2
Definition: GEMSegment.h:86
LocalError localDirectionError() const override
Error on the local direction.
Definition: GEMSegment.cc:93
CLHEP::HepSymMatrix AlgebraicSymMatrix
float timeErr() const
Definition: GEMSegment.h:76
AlgebraicVector parameters() const override
Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y )
Definition: GEMSegment.cc:98
Definition: errors.py:1
const std::vector< GEMRecHit > & specificRecHits() const
Definition: GEMSegment.h:69
const AlgebraicMatrix & getMatrix() const
Definition: GEMSegment.cc:28
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: GEMSegment.cc:72
void print() const
Definition: GEMSegment.cc:121
T x() const
Definition: PV3DBase.h:62
AlgebraicSymMatrix theCovMatrix
Definition: GEMSegment.h:85
std::vector< GEMRecHit > theGEMRecHits
Definition: GEMSegment.h:82