CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
33  const AlgebraicSymMatrix& errors,
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,
50  const AlgebraicSymMatrix& errors,
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  for (const auto& rh : theME0RecHits)
72  pointersOfRecHits.push_back(&rh);
73  return pointersOfRecHits;
74 }
75 
76 std::vector<TrackingRecHit*> ME0Segment::recHits() {
77  std::vector<TrackingRecHit*> pointersOfRecHits;
78  for (auto& rh : theME0RecHits)
79  pointersOfRecHits.push_back(&rh);
80  return pointersOfRecHits;
81 }
82 
84  return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
85 }
86 
88  return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
89 }
90 
92  // For consistency with DT and CSC and what we require for the TrackingRecHit interface,
93  // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z)
94 
96 
97  if (theLocalDirection.z() != 0) {
98  result[0] = theLocalDirection.x() / theLocalDirection.z();
99  result[1] = theLocalDirection.y() / theLocalDirection.z();
100  }
101  result[2] = theOrigin.x();
102  result[3] = theOrigin.y();
103 
104  return result;
105 }
106 
109  return (theProjectionMatrix.getMatrix());
110 }
111 
112 //
113 void ME0Segment::print() const { LogDebug("ME0Segment") << *this; }
114 
115 std::ostream& operator<<(std::ostream& os, const ME0Segment& seg) {
116  os << "ME0Segment: local pos = " << seg.localPosition() << " posErr = (" << sqrt(seg.localPositionError().xx()) << ","
117  << sqrt(seg.localPositionError().yy()) << "0,)\n"
118  << " dir = " << seg.localDirection() << " dirErr = (" << sqrt(seg.localDirectionError().xx()) << ","
119  << sqrt(seg.localDirectionError().yy()) << "0,)\n"
120  << " chi2/ndf = " << ((seg.degreesOfFreedom() != 0.) ? seg.chi2() / double(seg.degreesOfFreedom()) : 0)
121  << " #rechits = " << seg.specificRecHits().size() << " time = " << seg.time() << " +/- " << seg.timeErr()
122  << " ns ";
123 
124  return os;
125 }
LocalPoint localPosition() const override
Definition: ME0Segment.h:47
LocalPoint theOrigin
Definition: ME0Segment.h:89
float xx() const
Definition: LocalError.h:22
LocalVector theLocalDirection
Definition: ME0Segment.h:90
const std::vector< ME0RecHit > & specificRecHits() const
Definition: ME0Segment.h:74
~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:107
T y() const
Definition: PV3DBase.h:60
AlgebraicMatrix theProjectionMatrix
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
static const AlgebraicMatrix theProjectionMatrix
Definition: CSCSegment.cc:79
tuple result
Definition: mps_fire.py:311
std::vector< ME0RecHit > theME0RecHits
Definition: ME0Segment.h:88
ME0Segment()
Default constructor.
Definition: ME0Segment.h:23
CLHEP::HepMatrix AlgebraicMatrix
float yy() const
Definition: LocalError.h:24
T sqrt(T t)
Definition: SSEVec.h:19
void print() const
Definition: ME0Segment.cc:113
double chi2() const override
Chi2 of the segment fit.
Definition: ME0Segment.h:66
T z() const
Definition: PV3DBase.h:61
int degreesOfFreedom() const override
Degrees of freedom of the segment fit.
Definition: ME0Segment.h:70
AlgebraicVector parameters() const override
Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y )
Definition: ME0Segment.cc:91
Definition: DetId.h:17
CLHEP::HepVector AlgebraicVector
LocalError localDirectionError() const override
Error on the local direction.
Definition: ME0Segment.cc:87
LocalError localPositionError() const override
Definition: ME0Segment.cc:83
LocalVector localDirection() const override
Local direction.
Definition: ME0Segment.h:50
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: ME0Segment.cc:69
float timeErr() const
Definition: ME0Segment.h:81
const AlgebraicMatrix & getMatrix() const
Definition: ME0Segment.cc:27
AlgebraicSymMatrix theCovMatrix
Definition: ME0Segment.h:91
T x() const
Definition: PV3DBase.h:59
#define LogDebug(id)
float time() const
Definition: ME0Segment.h:80