CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoTracker/TransientTrackingRecHit/src/TkTransientTrackingRecHitBuilder.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
00002 //
00003 // include all the concrete ones
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 // For FAMOS
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, 1.,1.,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, 1.,1., 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, 1.,1., 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, 1.,1., 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                                         1.,1.,
00076                                         theComputeCoarseLocalPosition);
00077       }
00078     else if (tp == typeid(SiTrackerGSRecHit2D))
00079       {
00080         const SiTrackerGSRecHit2D* gh = reinterpret_cast<const SiTrackerGSRecHit2D*>(p);
00081         return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh )); 
00082       }
00083     else if (tp == typeid(SiTrackerGSMatchedRecHit2D))
00084       {
00085         const SiTrackerGSMatchedRecHit2D* gh = reinterpret_cast<const SiTrackerGSMatchedRecHit2D*>(p);
00086         return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh )); 
00087       } 
00088       return oldbuild(p);
00089 }
00090 
00091 TransientTrackingRecHit::RecHitPointer 
00092 TkTransientTrackingRecHitBuilder::oldbuild (const TrackingRecHit * p) const 
00093 {
00094   if ( const SiPixelRecHit* ph = dynamic_cast<const SiPixelRecHit*>(p)) {
00095     return ( TSiPixelRecHit::build( tGeometry_->idToDet(p->geographicalId()), ph, pixelCPE, 1.,1.,theComputeCoarseLocalPosition) ); 
00096   } else if ( const SiStripRecHit2D* sh = dynamic_cast<const SiStripRecHit2D*>(p)) { 
00097     return ( TSiStripRecHit2DLocalPos::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, 1.,1., theComputeCoarseLocalPosition ) ); 
00098   } else if ( const SiStripRecHit1D* sh = dynamic_cast<const SiStripRecHit1D*>(p)) { 
00099     return ( TSiStripRecHit1D::build(tGeometry_->idToDet(p->geographicalId()), sh, stripCPE, 1.,1., theComputeCoarseLocalPosition ) ); 
00100   } else if ( const SiStripMatchedRecHit2D* mh = dynamic_cast<const SiStripMatchedRecHit2D*>(p)) {
00101     return ( TSiStripMatchedRecHit::build(tGeometry_->idToDet(p->geographicalId()), mh, theMatcher, stripCPE, 1.,1., theComputeCoarseLocalPosition)); 
00102   } else if (dynamic_cast<const InvalidTrackingRecHit*>(p)){
00103     return ( InvalidTransientRecHit::build((p->geographicalId().rawId() == 0 ? 0 : 
00104                                             tGeometry_->idToDet(p->geographicalId())),
00105                                            p->getType()
00106                                            ) );
00107     
00108   }else if (const ProjectedSiStripRecHit2D* ph = dynamic_cast<const ProjectedSiStripRecHit2D*>(p)) {
00109     return ProjectedRecHit2D::build(tGeometry_->idToDet(p->geographicalId()),
00110                                     tGeometry_->idToDet(ph->originalHit().geographicalId()),
00111                                     ph,stripCPE,
00112                                     1.,1.,
00113                                     theComputeCoarseLocalPosition);
00114   } else if ( const SiTrackerGSRecHit2D* gh = dynamic_cast<const SiTrackerGSRecHit2D*>(p)) {
00115     return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh )); 
00116 
00117   } else if ( const SiTrackerGSMatchedRecHit2D* gh = dynamic_cast<const SiTrackerGSMatchedRecHit2D*>(p)) {
00118     return ( GenericTransientTrackingRecHit::build(tGeometry_->idToDet(p->geographicalId()), gh )); 
00119   } 
00120   
00121   throw cms::Exception("LogicError") << "TrackingRecHit* cannot be casted to a known concrete type. hit type is: "<< className(*p);
00122 }
00123 
00124 
00125 TransientTrackingRecHit::RecHitPointer
00126 TkTransientTrackingRecHitBuilder::build (const TrackingRecHit * p,
00127                                          const TrajectoryStateOnSurface & tsos) const
00128 {
00129   TransientTrackingRecHit::RecHitPointer noRefit = build(p);
00130   return noRefit->clone(tsos);
00131 }