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