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 
9 
14 
16 
17 #include <map>
18 
21 
22 
25 
27  GenericTransientTrackingRecHit(other.det(), *(other.hit())) {}
28 
29 
31 
32  if (dynamic_cast<const RecSegment*>(hit()) )
33  return dynamic_cast<const RecSegment*>(hit())->localDirection();
34  else return LocalVector(0.,0.,0.);
35 
36 }
37 
39 
40  if (dynamic_cast<const RecSegment*>(hit()))
41  return dynamic_cast<const RecSegment*>(hit())->localDirectionError();
42  else return LocalError(0.,0.,0.);
43 
44 }
45 
47 {
48  return (det()->surface().toGlobal(localDirection()));
49 }
50 
52 {
54 }
55 
56 
58 
60 
61  if (det()->alignmentPositionError() != 0) {
62 
63  LocalError lape = ErrorFrameTransformer().transform(det()->alignmentPositionError()->globalError(), det()->surface());
64 
65  // Just for speed up the code, the "else" branch can handle also the case of dim = 1.
66  if(err.num_row() == 1) err[0][0] += lape.xx();
67  else{
68  AlgebraicSymMatrix lapeMatrix(5,0);
69  lapeMatrix[3][3] = lape.xx();
70  lapeMatrix[3][4] = lape.xy();
71  lapeMatrix[4][4] = lape.yy();
72 
73  AlgebraicSymMatrix lapeMatrixProj = lapeMatrix.similarity(projectionMatrix());
74 
75  if(err.num_row() != lapeMatrixProj.num_row())
76  throw cms::Exception("MuonTransientTrackingRecHit::parametersError")
77  <<"Discrepancy between alignment error matrix and error matrix: APE "
78  << lapeMatrixProj.num_row()
79  << ", error matrix " << err.num_row()
80  << std::endl;
81 
82  err += lapeMatrixProj;
83  }
84  }
85  return err;
86 }
87 
89 {
90  if (dynamic_cast<const RecSegment*>(hit()))
91  return dynamic_cast<const RecSegment*>(hit())->chi2();
92  else return 0.;
93 }
94 
96 {
97  if (dynamic_cast<const RecSegment*>(hit()))
98  return dynamic_cast<const RecSegment*>(hit())->degreesOfFreedom();
99  else return 0;
100 }
101 
103  return (geographicalId().subdetId() == MuonSubdetId::DT);
104 }
105 
107  return (geographicalId().subdetId() == MuonSubdetId::CSC);
108 }
109 
111  return (geographicalId().subdetId() == MuonSubdetId::RPC);
112 }
113 
114 // FIXME, now it is "on-demand". I have to change it.
115 // FIXME check on mono hit!
117 
118  ConstRecHitContainer theSubTransientRecHits;
119 
120  // the sub rec hit of this TransientRecHit
121  std::vector<const TrackingRecHit*> ownRecHits = recHits();
122 
123  if(ownRecHits.size() == 0){
124  theSubTransientRecHits.push_back(this);
125  return theSubTransientRecHits;
126  }
127 
128  // the components of the geom det on which reside this rechit
129  std::vector<const GeomDet *> geomDets = det()->components();
130 
131  if(isDT() && dimension() == 2 && ownRecHits.front()->dimension() == 1
132  && (geomDets.size() == 3 || geomDets.size() == 2) ){ // it is a phi segment!!
133 
134  std::vector<const GeomDet *> subGeomDets;
135 
136  int sl = 1;
137  for(std::vector<const GeomDet *>::const_iterator geoDet = geomDets.begin();
138  geoDet != geomDets.end(); ++geoDet){
139  if(sl != 3){ // FIXME!! this maybe is not always true
140  std::vector<const GeomDet *> tmp = (*geoDet)->components();
141  std::copy(tmp.begin(),tmp.end(),back_inserter(subGeomDets));
142  }
143  ++sl;
144  }
145  geomDets.clear();
146  geomDets = subGeomDets;
147  }
148 
149  // Fill the GeomDet map
150  std::map<DetId,const GeomDet*> gemDetMap;
151 
152  for (std::vector<const GeomDet*>::const_iterator subDet = geomDets.begin();
153  subDet != geomDets.end(); ++subDet)
154  gemDetMap[ (*subDet)->geographicalId() ] = *subDet;
155 
156  std::map<DetId,const GeomDet*>::iterator gemDetMap_iter;
157 
158  // Loop in order to check the ids
159  for (std::vector<const TrackingRecHit*>::const_iterator rechit = ownRecHits.begin();
160  rechit != ownRecHits.end(); ++rechit){
161 
162  gemDetMap_iter = gemDetMap.find( (*rechit)->geographicalId() );
163 
164  if(gemDetMap_iter != gemDetMap.end() )
165  theSubTransientRecHits.push_back(new MuonTransientTrackingRecHit(gemDetMap_iter->second,
166  *rechit) );
167  else if( (*rechit)->geographicalId() == det()->geographicalId() ) // Phi in DT is on Chamber
168  theSubTransientRecHits.push_back(new MuonTransientTrackingRecHit(det(),
169  *rechit) );
170  }
171  return theSubTransientRecHits;
172 
173 }
virtual int degreesOfFreedom() const
Degrees of freedom for segments, else 0.
bool isCSC() const
if this rec hit is a CSC rec hit
float xx() const
Definition: LocalError.h:19
Local3DVector LocalVector
Definition: LocalVector.h:12
GlobalError transform(const LocalError &le, const Surface &surf) const
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
virtual double chi2() const
Chi square of the fit for segments, else 0.
virtual const TrackingRecHit * hit() const
virtual GlobalVector globalDirection() const
Direction in 3D for segments, otherwise (0,0,0)
virtual AlgebraicSymMatrix parametersError() const
virtual AlgebraicMatrix projectionMatrix() const
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
std::vector< ConstRecHitPointer > RecHitContainer
virtual ConstRecHitContainer transientHits() const
return the sub components of this transient rechit
virtual LocalVector localDirection() const
Direction in 3D for segments, otherwise (0,0,0)
float xy() const
Definition: LocalError.h:20
static const int CSC
Definition: MuonSubdetId.h:15
MuonTransientTrackingRecHit(const GeomDet *geom, const TrackingRecHit *rh)
Construct from a TrackingRecHit and its GeomDet.
float yy() const
Definition: LocalError.h:21
virtual AlgebraicSymMatrix parametersError() const
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:74
virtual std::vector< const GeomDet * > components() const =0
Returns direct components, if any.
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual LocalError localDirectionError() const
Error on the local direction.
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
static const int RPC
Definition: MuonSubdetId.h:16
const GeomDet * det() const
The GomeDet* can be zero for InvalidTransientRecHits and for TConstraintRecHit2Ds.
CLHEP::HepSymMatrix AlgebraicSymMatrix
virtual const Surface * surface() const
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
static const int DT
Definition: MuonSubdetId.h:14
DetId geographicalId() const