CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TkTransientTrackingRecHitBuilder.cc
Go to the documentation of this file.
2 //
3 // include all the concrete ones
4 //
6 
16 //
17 // For FAMOS
18 //
22 
24 #include <typeinfo>
25 
26 TkTransientTrackingRecHitBuilder::TkTransientTrackingRecHitBuilder( const TrackingGeometry* trackingGeometry,
27  const PixelClusterParameterEstimator * pCPE,
28  const StripClusterParameterEstimator * sCPE,
29  const SiStripRecHitMatcher * matcher,
30  bool computeCoarseLocalPositionFromDisk):
31  tGeometry_(trackingGeometry),
32  pixelCPE(pCPE),
33  stripCPE(sCPE),
34  theMatcher(matcher),
35  theComputeCoarseLocalPosition(computeCoarseLocalPositionFromDisk){}
36 
39 {
40  std::type_info const & tp = typeid(*p);
41 
42  if (tp == typeid(SiPixelRecHit))
43  {
44  const SiPixelRecHit* ph = reinterpret_cast<const SiPixelRecHit*>(p);
45  return TSiPixelRecHit::build( tGeometry_->idToDet(p->geographicalId()), ph, pixelCPE, theComputeCoarseLocalPosition);
46  }
47  else if (tp == typeid(SiStripRecHit2D))
48  {
49  const SiStripRecHit2D* sh = reinterpret_cast<const SiStripRecHit2D*>(p);
50  return TSiStripRecHit2DLocalPos::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, theComputeCoarseLocalPosition );
51  }
52  else if (tp == typeid(SiStripRecHit1D))
53  {
54  const SiStripRecHit1D* sh = reinterpret_cast<const SiStripRecHit1D*>(p);
55  return TSiStripRecHit1D::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, theComputeCoarseLocalPosition );
56  }
57  else if (tp == typeid(SiStripMatchedRecHit2D))
58  {
59  const SiStripMatchedRecHit2D* mh = reinterpret_cast<const SiStripMatchedRecHit2D*>(p);
60  return TSiStripMatchedRecHit::build(tGeometry_->idToDet(p->geographicalId()), mh, theMatcher, stripCPE, theComputeCoarseLocalPosition);
61  }
62  else if (tp == typeid(InvalidTrackingRecHit))
63  {
64  return InvalidTransientRecHit::build((p->geographicalId().rawId() == 0 ? 0 :
65  tGeometry_->idToDet(p->geographicalId())),
66  p->getType()
67  );
68  }
69  else if (tp == typeid(ProjectedSiStripRecHit2D))
70  {
71  const ProjectedSiStripRecHit2D* ph = reinterpret_cast<const ProjectedSiStripRecHit2D*>(p);
72  return ProjectedRecHit2D::build(tGeometry_->idToDet(p->geographicalId()),
73  tGeometry_->idToDet(ph->originalHit().geographicalId()),
74  ph,stripCPE,
75  theComputeCoarseLocalPosition);
76  }
77  else if (tp == typeid(SiTrackerGSRecHit2D))
78  {
79  const SiTrackerGSRecHit2D* gh = reinterpret_cast<const SiTrackerGSRecHit2D*>(p);
80  return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh ));
81  }
82  else if (tp == typeid(SiTrackerGSMatchedRecHit2D))
83  {
84  const SiTrackerGSMatchedRecHit2D* gh = reinterpret_cast<const SiTrackerGSMatchedRecHit2D*>(p);
85  return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh ));
86  }
87  return oldbuild(p);
88 }
89 
91 TkTransientTrackingRecHitBuilder::oldbuild (const TrackingRecHit * p) const
92 {
93  if ( const SiPixelRecHit* ph = dynamic_cast<const SiPixelRecHit*>(p)) {
94  return ( TSiPixelRecHit::build( tGeometry_->idToDet(p->geographicalId()), ph, pixelCPE, theComputeCoarseLocalPosition) );
95  } else if ( const SiStripRecHit2D* sh = dynamic_cast<const SiStripRecHit2D*>(p)) {
96  return ( TSiStripRecHit2DLocalPos::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, theComputeCoarseLocalPosition ) );
97  } else if ( const SiStripRecHit1D* sh = dynamic_cast<const SiStripRecHit1D*>(p)) {
98  return ( TSiStripRecHit1D::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, theComputeCoarseLocalPosition ) );
99  } else if ( const SiStripMatchedRecHit2D* mh = dynamic_cast<const SiStripMatchedRecHit2D*>(p)) {
100  return ( TSiStripMatchedRecHit::build(tGeometry_->idToDet(p->geographicalId()), mh, theMatcher, stripCPE, theComputeCoarseLocalPosition));
101  } else if (dynamic_cast<const InvalidTrackingRecHit*>(p)){
102  return ( InvalidTransientRecHit::build((p->geographicalId().rawId() == 0 ? 0 :
103  tGeometry_->idToDet(p->geographicalId())),
104  p->getType()
105  ) );
106 
107  }else if (const ProjectedSiStripRecHit2D* ph = dynamic_cast<const ProjectedSiStripRecHit2D*>(p)) {
108  return ProjectedRecHit2D::build(tGeometry_->idToDet(p->geographicalId()),
109  tGeometry_->idToDet(ph->originalHit().geographicalId()),
110  ph,stripCPE,
111  theComputeCoarseLocalPosition);
112  } else if ( const SiTrackerGSRecHit2D* gh = dynamic_cast<const SiTrackerGSRecHit2D*>(p)) {
113  return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh ));
114 
115  } else if ( const SiTrackerGSMatchedRecHit2D* gh = dynamic_cast<const SiTrackerGSMatchedRecHit2D*>(p)) {
116  return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh ));
117  }
118 
119  throw cms::Exception("LogicError") << "TrackingRecHit* cannot be casted to a known concrete type. hit type is: "<< className(*p);
120 }
121 
122 
125  const TrajectoryStateOnSurface & tsos) const
126 {
128  return noRefit->clone(tsos);
129 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
static RecHitPointer build(const GeomDet *geom, const TrackingRecHit *rh)
Type getType() const
DetId geographicalId() const
const SiStripRecHit2D & originalHit() const
std::string className(const T &t)
Definition: ClassName.h:30
Pixel Reconstructed Hit.