CMS 3D CMS Logo

MuonTransientTrackingRecHit.cc
Go to the documentation of this file.
1 
7 
12 
14 
15 #include <map>
16 
19 
21  : GenericTransientTrackingRecHit(*geom, *rh) {}
22 
24  : GenericTransientTrackingRecHit(*other.det(), *(other.hit())) {}
25 
27  if (dynamic_cast<const RecSegment*>(hit()))
28  return dynamic_cast<const RecSegment*>(hit())->localDirection();
29  else
30  return LocalVector(0., 0., 0.);
31 }
32 
34  if (dynamic_cast<const RecSegment*>(hit()))
35  return dynamic_cast<const RecSegment*>(hit())->localDirectionError();
36  else
37  return LocalError(0., 0., 0.);
38 }
39 
41  return (det()->surface().toGlobal(localDirection()));
42 }
43 
46 }
47 
51 
53  if (APE != nullptr) {
54  AlgebraicVector positions(2, 0);
56 
57  if (err.num_row() == 1) {
58  positions[0] = 0.;
59  positions[1] = 0.;
60  directions[0] = 0.;
61  directions[1] = 0.;
63  err[0][0] += lape.cxx();
64  } else if (err.num_row() == 2) {
65  positions[0] = localPosition().x();
66  positions[1] = 0.;
67  directions[0] = 0.;
68  directions[1] = 0.;
70 
71  AlgebraicSymMatrix lapeMatrix(2, 0);
72  lapeMatrix[1][1] = lape.cxx();
73  lapeMatrix[0][0] = lape.cphixphix();
74  lapeMatrix[0][1] = lape.cphixx();
75 
76  if (err.num_row() != lapeMatrix.num_row())
77  throw cms::Exception("MuonTransientTrackingRecHit::parametersError")
78  << "Discrepancy between alignment error matrix and error matrix: APE " << lapeMatrix.num_row()
79  << ", error matrix " << err.num_row() << std::endl;
80 
81  err += lapeMatrix;
82  } else if (err.num_row() == 4) {
83  positions[0] = par[2];
84  positions[1] = par[3];
85  directions[0] = par[0];
86  directions[1] = par[1];
87 
89 
90  AlgebraicSymMatrix lapeMatrix(4, 0);
91  lapeMatrix[2][2] = lape.cxx();
92  lapeMatrix[2][3] = lape.cyx();
93  lapeMatrix[3][3] = lape.cyy();
94  lapeMatrix[0][0] = lape.cphixphix();
95  lapeMatrix[0][1] = lape.cphiyphix();
96  lapeMatrix[1][1] = lape.cphiyphiy();
97 
98  lapeMatrix[0][2] = lape.cphixx();
99  lapeMatrix[0][3] = lape.cphixy();
100  lapeMatrix[1][3] = lape.cphiyy();
101  lapeMatrix[1][2] = lape.cphiyx();
102 
103  if (err.num_row() != lapeMatrix.num_row())
104  throw cms::Exception("MuonTransientTrackingRecHit::parametersError")
105  << "Discrepancy between alignment error matrix and error matrix: APE " << lapeMatrix.num_row()
106  << ", error matrix " << err.num_row() << std::endl;
107 
108  err += lapeMatrix;
109  }
110  }
111  return err;
112 }
113 
115  if (dynamic_cast<const RecSegment*>(hit()))
116  return dynamic_cast<const RecSegment*>(hit())->chi2();
117  else
118  return 0.;
119 }
120 
122  if (dynamic_cast<const RecSegment*>(hit()))
123  return dynamic_cast<const RecSegment*>(hit())->degreesOfFreedom();
124  else
125  return 0;
126 }
127 
128 bool MuonTransientTrackingRecHit::isDT() const { return (geographicalId().subdetId() == MuonSubdetId::DT); }
129 
130 bool MuonTransientTrackingRecHit::isCSC() const { return (geographicalId().subdetId() == MuonSubdetId::CSC); }
131 
132 bool MuonTransientTrackingRecHit::isGEM() const { return (geographicalId().subdetId() == MuonSubdetId::GEM); }
133 
134 bool MuonTransientTrackingRecHit::isME0() const { return (geographicalId().subdetId() == MuonSubdetId::ME0); }
135 
136 bool MuonTransientTrackingRecHit::isRPC() const { return (geographicalId().subdetId() == MuonSubdetId::RPC); }
137 
138 // FIXME, now it is "on-demand". I have to change it.
139 // FIXME check on mono hit!
141  ConstRecHitContainer theSubTransientRecHits;
142 
143  // the sub rec hit of this TransientRecHit
144  std::vector<const TrackingRecHit*> ownRecHits = recHits();
145 
146  if (ownRecHits.empty()) {
147  theSubTransientRecHits.push_back(TransientTrackingRecHit::RecHitPointer(clone()));
148  return theSubTransientRecHits;
149  }
150 
151  // the components of the geom det on which reside this rechit
152  std::vector<const GeomDet*> geomDets = det()->components();
153 
154  if (isDT() && dimension() == 2 && ownRecHits.front()->dimension() == 1 &&
155  (geomDets.size() == 3 || geomDets.size() == 2)) { // it is a phi segment!!
156 
157  std::vector<const GeomDet*> subGeomDets;
158 
159  int sl = 1;
160  for (std::vector<const GeomDet*>::const_iterator geoDet = geomDets.begin(); geoDet != geomDets.end(); ++geoDet) {
161  if (sl != 3) { // FIXME!! this maybe is not always true
162  std::vector<const GeomDet*> tmp = (*geoDet)->components();
163  std::copy(tmp.begin(), tmp.end(), back_inserter(subGeomDets));
164  }
165  ++sl;
166  }
167  geomDets.clear();
168  geomDets = subGeomDets;
169  }
170 
171  // Fill the GeomDet map
172  std::map<DetId, const GeomDet*> gemDetMap;
173 
174  for (std::vector<const GeomDet*>::const_iterator subDet = geomDets.begin(); subDet != geomDets.end(); ++subDet)
175  gemDetMap[(*subDet)->geographicalId()] = *subDet;
176 
177  std::map<DetId, const GeomDet*>::iterator gemDetMap_iter;
178 
179  // Loop in order to check the ids
180  for (std::vector<const TrackingRecHit*>::const_iterator rechit = ownRecHits.begin(); rechit != ownRecHits.end();
181  ++rechit) {
182  gemDetMap_iter = gemDetMap.find((*rechit)->geographicalId());
183 
184  if (gemDetMap_iter != gemDetMap.end())
185  theSubTransientRecHits.push_back(
186  TransientTrackingRecHit::RecHitPointer(new MuonTransientTrackingRecHit(gemDetMap_iter->second, *rechit)));
187  else if ((*rechit)->geographicalId() == det()->geographicalId()) // Phi in DT is on Chamber
188  theSubTransientRecHits.push_back(
190  }
191  return theSubTransientRecHits;
192 }
193 
195  setType(bad);
197 
198  if (isDT()) {
199  if (dimension() > 1) { // MB4s have 2D, but formatted in 4D segments
200  std::vector<TrackingRecHit*> seg2D = recHits(); // 4D --> 2D
201  // load 1D hits (2D --> 1D)
202  for (std::vector<TrackingRecHit*>::iterator it = seg2D.begin(); it != seg2D.end(); ++it) {
203  std::vector<TrackingRecHit*> hits1D = (*it)->recHits();
204  (*it)->setType(bad);
205  for (std::vector<TrackingRecHit*>::iterator it2 = hits1D.begin(); it2 != hits1D.end(); ++it2)
206  (*it2)->setType(bad);
207  }
208  }
209  } else if (isCSC())
210  if (dimension() == 4) {
211  std::vector<TrackingRecHit*> hits = recHits(); // load 2D hits (4D --> 1D)
212  for (std::vector<TrackingRecHit*>::iterator it = hits.begin(); it != hits.end(); ++it)
213  (*it)->setType(bad);
214  }
215 }
virtual int degreesOfFreedom() const
Degrees of freedom for segments, else 0.
static GlobalError transform(const LocalError &le, const Surface &surf)
bool isCSC() const
if this rec hit is a CSC rec hit
Local3DVector LocalVector
Definition: LocalVector.h:12
static LocalErrorExtended transform46(const GlobalErrorExtended &ge, const AlgebraicVector &positions, const AlgebraicVector &directions)
static constexpr int GEM
Definition: MuonSubdetId.h:14
MuonTransientTrackingRecHit::RecHitContainer MuonRecHitContainer
virtual double chi2() const
Chi square of the fit for segments, else 0.
virtual GlobalVector globalDirection() const
Direction in 3D for segments, otherwise (0,0,0)
ConstRecHitContainer transientHits() const override
return the sub components of this transient rechit
std::vector< ConstRecHitPointer > RecHitContainer
bool isGEM() const
if this rec hit is a GEM rec hit
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
Definition: GeomDet.h:73
virtual GlobalError globalDirectionError() const
Error on the global direction.
bool isRPC() const
if this rec hit is a RPC rec hit
AlgebraicVector parameters() const override
bool isDT() const
if this rec hit is a DT rec hit
const TrackingRecHit * hit() const override
const GlobalErrorExtended & globalError() const
virtual LocalVector localDirection() const
Direction in 3D for segments, otherwise (0,0,0)
MuonTransientTrackingRecHit(const GeomDet *geom, const TrackingRecHit *rh)
Construct from a TrackingRecHit and its GeomDet.
MuonTransientTrackingRecHit * clone() const override
std::shared_ptr< MuonTransientTrackingRecHit > MuonRecHitPointer
const GeomDet * det() const
void setType(Type ttype)
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
const Surface * surface() const final
static constexpr int ME0
Definition: MuonSubdetId.h:15
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
std::shared_ptr< TrackingRecHit const > RecHitPointer
AlgebraicSymMatrix parametersError() const override
std::vector< ConstRecHitPointer > ConstRecHitContainer
CLHEP::HepVector AlgebraicVector
virtual LocalError localDirectionError() const
Error on the local direction.
bool isME0() const
if this rec hit is a ME0 rec hit
static constexpr int RPC
Definition: MuonSubdetId.h:13
AlgebraicSymMatrix parametersError() const override
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
CLHEP::HepSymMatrix AlgebraicSymMatrix
DetId geographicalId() const
static constexpr int DT
Definition: MuonSubdetId.h:11
tmp
align.sh
Definition: createJobs.py:716
static constexpr int CSC
Definition: MuonSubdetId.h:12
T x() const
Definition: PV3DBase.h:59
AlignmentPositionError const * alignmentPositionError() const
Return pointer to alignment errors.
Definition: GeomDet.h:80