CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonTransientTrackingRecHit.cc
Go to the documentation of this file.
1 
7 
12 
14 
15 #include <map>
16 
19 
20 
23 
25  GenericTransientTrackingRecHit(*other.det(), *(other.hit())) {}
26 
27 
29 
30  if (dynamic_cast<const RecSegment*>(hit()) )
31  return dynamic_cast<const RecSegment*>(hit())->localDirection();
32  else return LocalVector(0.,0.,0.);
33 
34 }
35 
37 
38  if (dynamic_cast<const RecSegment*>(hit()))
39  return dynamic_cast<const RecSegment*>(hit())->localDirectionError();
40  else return LocalError(0.,0.,0.);
41 
42 }
43 
45 {
46  return (det()->surface().toGlobal(localDirection()));
47 }
48 
50 {
52 }
53 
54 
56 
59 
61  if (APE != NULL) {
62  AlgebraicVector positions(2,0);
64 
65  if(err.num_row() == 1) {
66  positions[0] = 0.;
67  positions[1] = 0.;
68  directions[0] = 0.;
69  directions[1] = 0.;
71  err[0][0] += lape.cxx();
72  } else if (err.num_row() == 2) {
73  positions[0] = localPosition().x();
74  positions[1] = 0.;
75  directions[0] = 0.;
76  directions[1] = 0.;
78 
79  AlgebraicSymMatrix lapeMatrix(2,0);
80  lapeMatrix[1][1] = lape.cxx();
81  lapeMatrix[0][0] = lape.cphixphix();
82  lapeMatrix[0][1] = lape.cphixx();
83 
84  if(err.num_row() != lapeMatrix.num_row())
85  throw cms::Exception("MuonTransientTrackingRecHit::parametersError")
86  <<"Discrepancy between alignment error matrix and error matrix: APE "
87  << lapeMatrix.num_row()
88  << ", error matrix " << err.num_row()
89  << std::endl;
90 
91  err += lapeMatrix;
92  } else if (err.num_row() == 4) {
93  positions[0] = par[2];
94  positions[1] = par[3];
95  directions[0] = par[0];
96  directions[1] = par[1];
97 
99 
100  AlgebraicSymMatrix lapeMatrix(4,0);
101  lapeMatrix[2][2] = lape.cxx();
102  lapeMatrix[2][3] = lape.cyx();
103  lapeMatrix[3][3] = lape.cyy();
104  lapeMatrix[0][0] = lape.cphixphix();
105  lapeMatrix[0][1] = lape.cphiyphix();
106  lapeMatrix[1][1] = lape.cphiyphiy();
107 
108  lapeMatrix[0][2] = lape.cphixx();
109  lapeMatrix[0][3] = lape.cphixy();
110  lapeMatrix[1][3] = lape.cphiyy();
111  lapeMatrix[1][2] = lape.cphiyx();
112 
113  if(err.num_row() != lapeMatrix.num_row())
114  throw cms::Exception("MuonTransientTrackingRecHit::parametersError")
115  <<"Discrepancy between alignment error matrix and error matrix: APE "
116  << lapeMatrix.num_row()
117  << ", error matrix " << err.num_row()
118  << std::endl;
119 
120  err += lapeMatrix;
121  }
122  }
123  return err;
124 }
125 
127 {
128  if (dynamic_cast<const RecSegment*>(hit()))
129  return dynamic_cast<const RecSegment*>(hit())->chi2();
130  else return 0.;
131 }
132 
134 {
135  if (dynamic_cast<const RecSegment*>(hit()))
136  return dynamic_cast<const RecSegment*>(hit())->degreesOfFreedom();
137  else return 0;
138 }
139 
141  return (geographicalId().subdetId() == MuonSubdetId::DT);
142 }
143 
145  return (geographicalId().subdetId() == MuonSubdetId::CSC);
146 }
147 
149  return (geographicalId().subdetId() == MuonSubdetId::RPC);
150 }
151 
152 // FIXME, now it is "on-demand". I have to change it.
153 // FIXME check on mono hit!
155 
156  ConstRecHitContainer theSubTransientRecHits;
157 
158  // the sub rec hit of this TransientRecHit
159  std::vector<const TrackingRecHit*> ownRecHits = recHits();
160 
161  if(ownRecHits.size() == 0){
162  theSubTransientRecHits.push_back(TransientTrackingRecHit::RecHitPointer(clone()));
163  return theSubTransientRecHits;
164  }
165 
166  // the components of the geom det on which reside this rechit
167  std::vector<const GeomDet *> geomDets = det()->components();
168 
169  if(isDT() && dimension() == 2 && ownRecHits.front()->dimension() == 1
170  && (geomDets.size() == 3 || geomDets.size() == 2) ){ // it is a phi segment!!
171 
172  std::vector<const GeomDet *> subGeomDets;
173 
174  int sl = 1;
175  for(std::vector<const GeomDet *>::const_iterator geoDet = geomDets.begin();
176  geoDet != geomDets.end(); ++geoDet){
177  if(sl != 3){ // FIXME!! this maybe is not always true
178  std::vector<const GeomDet *> tmp = (*geoDet)->components();
179  std::copy(tmp.begin(),tmp.end(),back_inserter(subGeomDets));
180  }
181  ++sl;
182  }
183  geomDets.clear();
184  geomDets = subGeomDets;
185  }
186 
187  // Fill the GeomDet map
188  std::map<DetId,const GeomDet*> gemDetMap;
189 
190  for (std::vector<const GeomDet*>::const_iterator subDet = geomDets.begin();
191  subDet != geomDets.end(); ++subDet)
192  gemDetMap[ (*subDet)->geographicalId() ] = *subDet;
193 
194  std::map<DetId,const GeomDet*>::iterator gemDetMap_iter;
195 
196  // Loop in order to check the ids
197  for (std::vector<const TrackingRecHit*>::const_iterator rechit = ownRecHits.begin();
198  rechit != ownRecHits.end(); ++rechit){
199 
200  gemDetMap_iter = gemDetMap.find( (*rechit)->geographicalId() );
201 
202  if(gemDetMap_iter != gemDetMap.end() )
203  theSubTransientRecHits.push_back(TransientTrackingRecHit::RecHitPointer(new MuonTransientTrackingRecHit(gemDetMap_iter->second,
204  *rechit)) );
205  else if( (*rechit)->geographicalId() == det()->geographicalId() ) // Phi in DT is on Chamber
206  theSubTransientRecHits.push_back(TransientTrackingRecHit::RecHitPointer(new MuonTransientTrackingRecHit(det(),
207  *rechit)) );
208  }
209  return theSubTransientRecHits;
210 
211 }
212 
213 
216 
217 
218  if (isDT()){
219  if(dimension() > 1){ // MB4s have 2D, but formatted in 4D segments
220  std::vector<TrackingRecHit*> seg2D = recHits(); // 4D --> 2D
221  // load 1D hits (2D --> 1D)
222  for(std::vector<TrackingRecHit*>::iterator it = seg2D.begin(); it != seg2D.end(); ++it){
223  std::vector<TrackingRecHit*> hits1D = (*it)->recHits();
224  (*it)->setType(bad);
225  for(std::vector<TrackingRecHit*>::iterator it2 = hits1D.begin(); it2 != hits1D.end(); ++it2)
226  (*it2)->setType(bad);
227  }
228  }
229  }
230  else if(isCSC())
231  if(dimension() == 4){
232  std::vector<TrackingRecHit*> hits = recHits(); // load 2D hits (4D --> 1D)
233  for(std::vector<TrackingRecHit*>::iterator it = hits.begin(); it != hits.end(); ++it)
234  (*it)->setType(bad);
235  }
236 
237 
238 }
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)
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
virtual double chi2() const
Chi square of the fit for segments, else 0.
virtual MuonTransientTrackingRecHit * clone() const override
virtual const TrackingRecHit * hit() const
virtual GlobalVector globalDirection() const
Direction in 3D for segments, otherwise (0,0,0)
virtual LocalPoint localPosition() const override
std::vector< ConstRecHitPointer > RecHitContainer
#define NULL
Definition: scimark2.h:8
virtual GlobalError globalDirectionError() const
Error on the global direction.
bool isRPC() const
if this rec hit is a RPC rec hit
bool isDT() const
if this rec hit is a DT rec hit
virtual std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
const GlobalErrorExtended & globalError() const
virtual LocalVector localDirection() const
Direction in 3D for segments, otherwise (0,0,0)
static const int CSC
Definition: MuonSubdetId.h:13
MuonTransientTrackingRecHit(const GeomDet *geom, const TrackingRecHit *rh)
Construct from a TrackingRecHit and its GeomDet.
virtual AlgebraicSymMatrix parametersError() const
const GeomDet * det() const
void setType(Type ttype)
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:77
std::shared_ptr< TrackingRecHit const > RecHitPointer
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
Definition: GeomDet.h:86
CLHEP::HepVector AlgebraicVector
virtual LocalError localDirectionError() const
Error on the local direction.
virtual AlgebraicVector parameters() const
virtual ConstRecHitContainer transientHits() const override
return the sub components of this transient rechit
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
static const int RPC
Definition: MuonSubdetId.h:14
virtual AlgebraicSymMatrix parametersError() const override
CLHEP::HepSymMatrix AlgebraicSymMatrix
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
static const int DT
Definition: MuonSubdetId.h:12
DetId geographicalId() const
virtual const Surface * surface() const
T x() const
Definition: PV3DBase.h:62
AlignmentPositionError const * alignmentPositionError() const
Return pointer to alignment errors.
Definition: GeomDet.h:93