CMS 3D CMS Logo

ME0Segment.cc
Go to the documentation of this file.
1 
8 #include <iostream>
9 
10 namespace {
11  // define a Super Layer Id from the first layer of the first rechits, and put to first layer
12  inline DetId buildDetId(ME0DetId id) { return ME0DetId(id.chamberId()); }
13 } // namespace
14 
16  // Aider class to make the return of the projection Matrix thread-safe
17 protected:
19 
20 public:
22  theProjectionMatrix[0][1] = 1;
23  theProjectionMatrix[1][2] = 1;
24  theProjectionMatrix[2][3] = 1;
25  theProjectionMatrix[3][4] = 1;
26  }
27  const AlgebraicMatrix& getMatrix() const { return (theProjectionMatrix); }
28 };
29 
30 ME0Segment::ME0Segment(const std::vector<const ME0RecHit*>& proto_segment,
31  const LocalPoint& origin,
32  const LocalVector& direction,
34  float chi2)
35  : RecSegment(buildDetId(proto_segment.front()->me0Id())),
36  theOrigin(origin),
37  theLocalDirection(direction),
38  theCovMatrix(errors),
39  theChi2(chi2),
40  theTimeValue(0.),
41  theTimeUncrt(0.),
42  theDeltaPhi(0.) {
43  for (const auto* rh : proto_segment)
44  theME0RecHits.push_back(*rh);
45 }
46 
47 ME0Segment::ME0Segment(const std::vector<const ME0RecHit*>& proto_segment,
48  const LocalPoint& origin,
49  const LocalVector& direction,
51  float chi2,
52  float time,
53  float timeErr,
54  float deltaPhi)
55  : RecSegment(buildDetId(proto_segment.front()->me0Id())),
56  theOrigin(origin),
57  theLocalDirection(direction),
58  theCovMatrix(errors),
59  theChi2(chi2),
60  theTimeValue(time),
61  theTimeUncrt(timeErr),
62  theDeltaPhi(deltaPhi) {
63  for (const auto* rh : proto_segment)
64  theME0RecHits.push_back(*rh);
65 }
66 
68 
69 std::vector<const TrackingRecHit*> ME0Segment::recHits() const {
70  std::vector<const TrackingRecHit*> pointersOfRecHits;
71  pointersOfRecHits.reserve(theME0RecHits.size());
72  for (const auto& rh : theME0RecHits)
73  pointersOfRecHits.push_back(&rh);
74  return pointersOfRecHits;
75 }
76 
77 std::vector<TrackingRecHit*> ME0Segment::recHits() {
78  std::vector<TrackingRecHit*> pointersOfRecHits;
79  pointersOfRecHits.reserve(theME0RecHits.size());
80  for (auto& rh : theME0RecHits)
81  pointersOfRecHits.push_back(&rh);
82  return pointersOfRecHits;
83 }
84 
86  return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
87 }
88 
90  return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
91 }
92 
94  // For consistency with DT and 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 
99  if (theLocalDirection.z() != 0) {
102  }
103  result[2] = theOrigin.x();
104  result[3] = theOrigin.y();
105 
106  return result;
107 }
108 
111  return (theProjectionMatrix.getMatrix());
112 }
113 
114 //
115 void ME0Segment::print() const { LogDebug("ME0Segment") << *this; }
116 
117 std::ostream& operator<<(std::ostream& os, const ME0Segment& seg) {
118  os << "ME0Segment: local pos = " << seg.localPosition() << " posErr = (" << sqrt(seg.localPositionError().xx()) << ","
119  << sqrt(seg.localPositionError().yy()) << "0,)\n"
120  << " dir = " << seg.localDirection() << " dirErr = (" << sqrt(seg.localDirectionError().xx()) << ","
121  << sqrt(seg.localDirectionError().yy()) << "0,)\n"
122  << " chi2/ndf = " << ((seg.degreesOfFreedom() != 0.) ? seg.chi2() / double(seg.degreesOfFreedom()) : 0)
123  << " #rechits = " << seg.specificRecHits().size() << " time = " << seg.time() << " +/- " << seg.timeErr()
124  << " ns ";
125 
126  return os;
127 }
LocalPoint localPosition() const override
Definition: ME0Segment.h:47
LocalPoint theOrigin
Definition: ME0Segment.h:89
LocalVector theLocalDirection
Definition: ME0Segment.h:90
float time() const
Definition: ME0Segment.h:80
T z() const
Definition: PV3DBase.h:61
~ME0Segment() override
Destructor.
Definition: ME0Segment.cc:67
AlgebraicMatrix projectionMatrix() const override
The projection matrix relates the trajectory state parameters to the segment parameters().
Definition: ME0Segment.cc:109
AlgebraicMatrix theProjectionMatrix
const std::vector< ME0RecHit > & specificRecHits() const
Definition: ME0Segment.h:74
static const AlgebraicMatrix theProjectionMatrix
Definition: CSCSegment.cc:79
std::vector< ME0RecHit > theME0RecHits
Definition: ME0Segment.h:88
float yy() const
Definition: LocalError.h:24
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
ME0Segment()
Default constructor.
Definition: ME0Segment.h:23
CLHEP::HepMatrix AlgebraicMatrix
std::ostream & operator<<(std::ostream &os, const ME0Segment &seg)
Definition: ME0Segment.cc:117
T sqrt(T t)
Definition: SSEVec.h:23
double chi2() const override
Chi2 of the segment fit.
Definition: ME0Segment.h:66
int degreesOfFreedom() const override
Degrees of freedom of the segment fit.
Definition: ME0Segment.h:70
void print() const
Definition: ME0Segment.cc:115
AlgebraicVector parameters() const override
Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y )
Definition: ME0Segment.cc:93
Definition: DetId.h:17
CLHEP::HepVector AlgebraicVector
LocalError localDirectionError() const override
Error on the local direction.
Definition: ME0Segment.cc:89
LocalError localPositionError() const override
Definition: ME0Segment.cc:85
float timeErr() const
Definition: ME0Segment.h:81
LocalVector localDirection() const override
Local direction.
Definition: ME0Segment.h:50
const AlgebraicMatrix & getMatrix() const
Definition: ME0Segment.cc:27
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: ME0Segment.cc:69
Definition: errors.py:1
AlgebraicSymMatrix theCovMatrix
Definition: ME0Segment.h:91
float xx() const
Definition: LocalError.h:22
#define LogDebug(id)