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