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