00001 #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
00002
00003
00004
00005 #include "FWCore/Utilities/interface/Exception.h"
00006
00007 #include "RecoTracker/TransientTrackingRecHit/interface/TSiStripRecHit2DLocalPos.h"
00008 #include "RecoTracker/TransientTrackingRecHit/interface/TSiStripRecHit1D.h"
00009 #include "RecoTracker/TransientTrackingRecHit/interface/TSiStripMatchedRecHit.h"
00010 #include "RecoTracker/TransientTrackingRecHit/interface/TSiPixelRecHit.h"
00011 #include "TrackingTools/TransientTrackingRecHit/interface/InvalidTransientRecHit.h"
00012 #include "DataFormats/TrackingRecHit/interface/InvalidTrackingRecHit.h"
00013 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
00014 #include "DataFormats/TrackerRecHit2D/interface/ProjectedSiStripRecHit2D.h"
00015 #include "RecoTracker/TransientTrackingRecHit/interface/ProjectedRecHit2D.h"
00016
00017
00018
00019 #include "TrackingTools/TransientTrackingRecHit/interface/GenericTransientTrackingRecHit.h"
00020 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSRecHit2D.h"
00021 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSMatchedRecHit2D.h"
00022
00023 #include "Utilities/General/interface/ClassName.h"
00024 #include <typeinfo>
00025
00026 TkTransientTrackingRecHitBuilder::TkTransientTrackingRecHitBuilder( const TrackingGeometry* trackingGeometry,
00027 const PixelClusterParameterEstimator * pCPE,
00028 const StripClusterParameterEstimator * sCPE,
00029 const SiStripRecHitMatcher * matcher,
00030 bool computeCoarseLocalPositionFromDisk):
00031 tGeometry_(trackingGeometry),
00032 pixelCPE(pCPE),
00033 stripCPE(sCPE),
00034 theMatcher(matcher),
00035 theComputeCoarseLocalPosition(computeCoarseLocalPositionFromDisk){}
00036
00037 TransientTrackingRecHit::RecHitPointer
00038 TkTransientTrackingRecHitBuilder::build (const TrackingRecHit * p) const
00039 {
00040 std::type_info const & tp = typeid(*p);
00041
00042 if (tp == typeid(SiPixelRecHit))
00043 {
00044 const SiPixelRecHit* ph = reinterpret_cast<const SiPixelRecHit*>(p);
00045 return TSiPixelRecHit::build( tGeometry_->idToDet(p->geographicalId()), ph, pixelCPE, theComputeCoarseLocalPosition);
00046 }
00047 else if (tp == typeid(SiStripRecHit2D))
00048 {
00049 const SiStripRecHit2D* sh = reinterpret_cast<const SiStripRecHit2D*>(p);
00050 return TSiStripRecHit2DLocalPos::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, theComputeCoarseLocalPosition );
00051 }
00052 else if (tp == typeid(SiStripRecHit1D))
00053 {
00054 const SiStripRecHit1D* sh = reinterpret_cast<const SiStripRecHit1D*>(p);
00055 return TSiStripRecHit1D::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, theComputeCoarseLocalPosition );
00056 }
00057 else if (tp == typeid(SiStripMatchedRecHit2D))
00058 {
00059 const SiStripMatchedRecHit2D* mh = reinterpret_cast<const SiStripMatchedRecHit2D*>(p);
00060 return TSiStripMatchedRecHit::build(tGeometry_->idToDet(p->geographicalId()), mh, theMatcher, stripCPE, theComputeCoarseLocalPosition);
00061 }
00062 else if (tp == typeid(InvalidTrackingRecHit))
00063 {
00064 return InvalidTransientRecHit::build((p->geographicalId().rawId() == 0 ? 0 :
00065 tGeometry_->idToDet(p->geographicalId())),
00066 p->getType()
00067 );
00068 }
00069 else if (tp == typeid(ProjectedSiStripRecHit2D))
00070 {
00071 const ProjectedSiStripRecHit2D* ph = reinterpret_cast<const ProjectedSiStripRecHit2D*>(p);
00072 return ProjectedRecHit2D::build(tGeometry_->idToDet(p->geographicalId()),
00073 tGeometry_->idToDet(ph->originalHit().geographicalId()),
00074 ph,stripCPE,
00075 theComputeCoarseLocalPosition);
00076 }
00077 else if (tp == typeid(SiTrackerGSRecHit2D))
00078 {
00079 const SiTrackerGSRecHit2D* gh = reinterpret_cast<const SiTrackerGSRecHit2D*>(p);
00080 return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh ));
00081 }
00082 else if (tp == typeid(SiTrackerGSMatchedRecHit2D))
00083 {
00084 const SiTrackerGSMatchedRecHit2D* gh = reinterpret_cast<const SiTrackerGSMatchedRecHit2D*>(p);
00085 return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh ));
00086 }
00087 return oldbuild(p);
00088 }
00089
00090 TransientTrackingRecHit::RecHitPointer
00091 TkTransientTrackingRecHitBuilder::oldbuild (const TrackingRecHit * p) const
00092 {
00093 if ( const SiPixelRecHit* ph = dynamic_cast<const SiPixelRecHit*>(p)) {
00094 return ( TSiPixelRecHit::build( tGeometry_->idToDet(p->geographicalId()), ph, pixelCPE, theComputeCoarseLocalPosition) );
00095 } else if ( const SiStripRecHit2D* sh = dynamic_cast<const SiStripRecHit2D*>(p)) {
00096 return ( TSiStripRecHit2DLocalPos::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, theComputeCoarseLocalPosition ) );
00097 } else if ( const SiStripRecHit1D* sh = dynamic_cast<const SiStripRecHit1D*>(p)) {
00098 return ( TSiStripRecHit1D::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, theComputeCoarseLocalPosition ) );
00099 } else if ( const SiStripMatchedRecHit2D* mh = dynamic_cast<const SiStripMatchedRecHit2D*>(p)) {
00100 return ( TSiStripMatchedRecHit::build(tGeometry_->idToDet(p->geographicalId()), mh, theMatcher, stripCPE, theComputeCoarseLocalPosition));
00101 } else if (dynamic_cast<const InvalidTrackingRecHit*>(p)){
00102 return ( InvalidTransientRecHit::build((p->geographicalId().rawId() == 0 ? 0 :
00103 tGeometry_->idToDet(p->geographicalId())),
00104 p->getType()
00105 ) );
00106
00107 }else if (const ProjectedSiStripRecHit2D* ph = dynamic_cast<const ProjectedSiStripRecHit2D*>(p)) {
00108 return ProjectedRecHit2D::build(tGeometry_->idToDet(p->geographicalId()),
00109 tGeometry_->idToDet(ph->originalHit().geographicalId()),
00110 ph,stripCPE,
00111 theComputeCoarseLocalPosition);
00112 } else if ( const SiTrackerGSRecHit2D* gh = dynamic_cast<const SiTrackerGSRecHit2D*>(p)) {
00113 return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh ));
00114
00115 } else if ( const SiTrackerGSMatchedRecHit2D* gh = dynamic_cast<const SiTrackerGSMatchedRecHit2D*>(p)) {
00116 return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh ));
00117 }
00118
00119 throw cms::Exception("LogicError") << "TrackingRecHit* cannot be casted to a known concrete type. hit type is: "<< className(*p);
00120 }
00121
00122
00123 TransientTrackingRecHit::RecHitPointer
00124 TkTransientTrackingRecHitBuilder::build (const TrackingRecHit * p,
00125 const TrajectoryStateOnSurface & tsos) const
00126 {
00127 TransientTrackingRecHit::RecHitPointer noRefit = build(p);
00128 return noRefit->clone(tsos);
00129 }