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 
58  /* FIMXE : new MUON APE CODE GOES HERE
59  LocalError lape = det()->localAlignmentError();
60  if (lape.valid()) {
61 
62  // Just for speed up the code, the "else" branch can handle also the case of dim = 1.
63  if(err.num_row() == 1) err[0][0] += lape.xx();
64  else{
65  AlgebraicSymMatrix lapeMatrix(5,0);
66  lapeMatrix[3][3] = lape.xx();
67  lapeMatrix[3][4] = lape.xy();
68  lapeMatrix[4][4] = lape.yy();
69 
70  AlgebraicSymMatrix lapeMatrixProj = lapeMatrix.similarity(projectionMatrix());
71 
72  if(err.num_row() != lapeMatrixProj.num_row())
73  throw cms::Exception("MuonTransientTrackingRecHit::parametersError")
74  <<"Discrepancy between alignment error matrix and error matrix: APE "
75  << lapeMatrixProj.num_row()
76  << ", error matrix " << err.num_row()
77  << std::endl;
78 
79  err += lapeMatrixProj;
80  }
81  }
82  */
83  return err;
84 }
85 
87 {
88  if (dynamic_cast<const RecSegment*>(hit()))
89  return dynamic_cast<const RecSegment*>(hit())->chi2();
90  else return 0.;
91 }
92 
94 {
95  if (dynamic_cast<const RecSegment*>(hit()))
96  return dynamic_cast<const RecSegment*>(hit())->degreesOfFreedom();
97  else return 0;
98 }
99 
101  return (geographicalId().subdetId() == MuonSubdetId::DT);
102 }
103 
105  return (geographicalId().subdetId() == MuonSubdetId::CSC);
106 }
107 
109  return (geographicalId().subdetId() == MuonSubdetId::RPC);
110 }
111 
112 // FIXME, now it is "on-demand". I have to change it.
113 // FIXME check on mono hit!
115 
116  ConstRecHitContainer theSubTransientRecHits;
117 
118  // the sub rec hit of this TransientRecHit
119  std::vector<const TrackingRecHit*> ownRecHits = recHits();
120 
121  if(ownRecHits.size() == 0){
122  theSubTransientRecHits.push_back(TransientTrackingRecHit::RecHitPointer(clone()));
123  return theSubTransientRecHits;
124  }
125 
126  // the components of the geom det on which reside this rechit
127  std::vector<const GeomDet *> geomDets = det()->components();
128 
129  if(isDT() && dimension() == 2 && ownRecHits.front()->dimension() == 1
130  && (geomDets.size() == 3 || geomDets.size() == 2) ){ // it is a phi segment!!
131 
132  std::vector<const GeomDet *> subGeomDets;
133 
134  int sl = 1;
135  for(std::vector<const GeomDet *>::const_iterator geoDet = geomDets.begin();
136  geoDet != geomDets.end(); ++geoDet){
137  if(sl != 3){ // FIXME!! this maybe is not always true
138  std::vector<const GeomDet *> tmp = (*geoDet)->components();
139  std::copy(tmp.begin(),tmp.end(),back_inserter(subGeomDets));
140  }
141  ++sl;
142  }
143  geomDets.clear();
144  geomDets = subGeomDets;
145  }
146 
147  // Fill the GeomDet map
148  std::map<DetId,const GeomDet*> gemDetMap;
149 
150  for (std::vector<const GeomDet*>::const_iterator subDet = geomDets.begin();
151  subDet != geomDets.end(); ++subDet)
152  gemDetMap[ (*subDet)->geographicalId() ] = *subDet;
153 
154  std::map<DetId,const GeomDet*>::iterator gemDetMap_iter;
155 
156  // Loop in order to check the ids
157  for (std::vector<const TrackingRecHit*>::const_iterator rechit = ownRecHits.begin();
158  rechit != ownRecHits.end(); ++rechit){
159 
160  gemDetMap_iter = gemDetMap.find( (*rechit)->geographicalId() );
161 
162  if(gemDetMap_iter != gemDetMap.end() )
163  theSubTransientRecHits.push_back(TransientTrackingRecHit::RecHitPointer(new MuonTransientTrackingRecHit(gemDetMap_iter->second,
164  *rechit)) );
165  else if( (*rechit)->geographicalId() == det()->geographicalId() ) // Phi in DT is on Chamber
166  theSubTransientRecHits.push_back(TransientTrackingRecHit::RecHitPointer(new MuonTransientTrackingRecHit(det(),
167  *rechit)) );
168  }
169  return theSubTransientRecHits;
170 
171 }
172 
173 
176 
177 
178  if (isDT()){
179  if(dimension() > 1){ // MB4s have 2D, but formatted in 4D segments
180  std::vector<TrackingRecHit*> seg2D = recHits(); // 4D --> 2D
181  // load 1D hits (2D --> 1D)
182  for(std::vector<TrackingRecHit*>::iterator it = seg2D.begin(); it != seg2D.end(); ++it){
183  std::vector<TrackingRecHit*> hits1D = (*it)->recHits();
184  (*it)->setType(bad);
185  for(std::vector<TrackingRecHit*>::iterator it2 = hits1D.begin(); it2 != hits1D.end(); ++it2)
186  (*it2)->setType(bad);
187  }
188  }
189  }
190  else if(isCSC())
191  if(dimension() == 4){
192  std::vector<TrackingRecHit*> hits = recHits(); // load 2D hits (4D --> 1D)
193  for(std::vector<TrackingRecHit*>::iterator it = hits.begin(); it != hits.end(); ++it)
194  (*it)->setType(bad);
195  }
196 
197 
198 }
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
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)
std::vector< ConstRecHitPointer > RecHitContainer
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)
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
virtual LocalError localDirectionError() const
Error on the local direction.
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