CMS 3D CMS Logo

SeedingHit.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkSeedingLayers/interface/SeedingHit.h"
00002 
00003 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00005 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00006 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00009 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00010 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00011 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00012 #include "FWCore/Framework/interface/ESHandle.h"
00013 #include "RecoTracker/TkSeedingLayers/interface/SeedingLayer.h"
00014 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00015 #include "Geometry/CommonDetUnit/interface/GeomDetEnumerators.h"
00016 
00017 #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
00018 
00019 using namespace ctfseeding;
00020 
00021 class SeedingHit::SeedingHitImpl {
00022 public:
00023 
00024   // obsolete - remove asap!
00025   SeedingHitImpl(const TrackingRecHit * hit ,  const edm::EventSetup& es)
00026     : theRecHit(hit), hasTransientHit(false)
00027   {
00028     edm::ESHandle<TrackerGeometry> tracker;
00029     es.get<TrackerDigiGeometryRecord>().get(tracker);
00030     GlobalPoint gp = tracker->idToDet(
00031         hit->geographicalId())->surface().toGlobal(hit->localPosition());
00032     thePhi = gp.phi();
00033     theR = gp.perp();
00034     theZ = gp.z();
00035     unsigned int subid=hit->geographicalId().subdetId();
00036     theRZ = (   subid == PixelSubdetector::PixelBarrel
00037              || subid == StripSubdetector::TIB
00038              || subid == StripSubdetector::TOB) ? theZ : theR;
00039   }
00040 
00041   
00042   SeedingHitImpl(const TrackingRecHit * hit, const SeedingLayer &layer, const edm::EventSetup& es)
00043     : theLayer(layer), theRecHit(hit), hasTransientHit(false)  
00044   {
00045     edm::ESHandle<TrackerGeometry> tracker;
00046     es.get<TrackerDigiGeometryRecord>().get(tracker);
00047     GlobalPoint gp = tracker->idToDet(
00048         hit->geographicalId())->surface().toGlobal(hit->localPosition());
00049     init(gp);
00050   }
00051 
00052   SeedingHitImpl(const TransientTrackingRecHit::ConstRecHitPointer& ttrh, const SeedingLayer &layer)
00053     : theLayer(layer), theTransientRecHit(ttrh), theRecHit(0), hasTransientHit(true)
00054   {
00055     GlobalPoint gp = theTransientRecHit->globalPosition();
00056     init(gp);
00057   }
00058 
00059   void init(const GlobalPoint & gp) {
00060     thePhi =  gp.phi();
00061     theR = gp.perp();
00062     theZ = gp.z();
00063     theLayer.detLayer()->location();
00064     theRZ = (theLayer.detLayer()->location() == GeomDetEnumerators::barrel) ?  theZ : theR; 
00065     if (theLayer.hasPredefinedHitErrors()) {
00066       theErrorRZ = theLayer.predefinedHitErrorRZ(); 
00067       theErrorRPhi = theLayer.predefinedHitErrorRPhi();
00068     } else {
00069       theErrorRZ = 0.;
00070       theErrorRPhi = 0.;
00071     }
00072   }
00073 
00074 
00075 
00076   float phi() const {return thePhi;}
00077   float rOrZ() const { return theRZ; }
00078   float r() const {return theR; }
00079   float z() const {return theZ; }
00080 
00081 
00082   float errorRZ() const {
00083     if (!hasHitErrors) setErrorsFromTTRH(); 
00084     return theErrorRZ;
00085   }
00086 
00087  
00088   float errorRPhi() const {
00089     if (!hasHitErrors) setErrorsFromTTRH(); 
00090     return theErrorRPhi;
00091   }
00092 
00093 
00094   const TrackingRecHit * trackingRecHit() const { 
00095     return hasTransientHit ? theTransientRecHit->hit() : theRecHit; 
00096   }
00097 
00098 
00099   const TransientTrackingRecHit::ConstRecHitPointer & transientRecHit() const {
00100     if (!hasTransientHit) {
00101       theTransientRecHit = theLayer.hitBuilder()->build(theRecHit);  
00102       hasTransientHit = true; 
00103     }
00104     return theTransientRecHit; 
00105   }
00106 
00107   void setErrorsFromTTRH() const {
00108     const TransientTrackingRecHit::ConstRecHitPointer & hit = transientRecHit();
00109     GlobalPoint hitPos = hit->globalPosition();
00110     GlobalError hitErr = hit->globalPositionError();
00111     theErrorRPhi =  r()*sqrt(hitErr.phierr(hitPos)); 
00112     theErrorRZ = (theLayer.detLayer()->location() == GeomDetEnumerators::barrel) ? 
00113                   sqrt(hitErr.czz())
00114                 : sqrt(hitErr.rerr(hitPos));
00115     hasHitErrors = true;
00116   }
00117 
00118 private:
00119 
00120   SeedingLayer theLayer;
00121   mutable TransientTrackingRecHit::ConstRecHitPointer theTransientRecHit;
00122   const TrackingRecHit *theRecHit;
00123   float thePhi, theR, theZ, theRZ;
00124   mutable bool hasTransientHit;
00125   mutable bool hasHitErrors;
00126   mutable float theErrorRZ, theErrorRPhi;
00127 };
00128 
00129 
00130 
00131 
00132 
00133 SeedingHit::SeedingHit( const TransientTrackingRecHit::ConstRecHitPointer& ttrh, 
00134     const SeedingLayer& layer)
00135 {
00136   SeedingHitImpl * h = new SeedingHitImpl(ttrh, layer);
00137   theImpl = boost::shared_ptr<SeedingHitImpl>(h);
00138 }
00139 
00140 SeedingHit::SeedingHit( const TrackingRecHit* hit, 
00141    const SeedingLayer &layer,  const edm::EventSetup& es)
00142 {
00143   SeedingHitImpl * h = new SeedingHitImpl(hit,layer,es);
00144   theImpl = boost::shared_ptr<SeedingHitImpl>(h);
00145 }
00146 
00147 SeedingHit::SeedingHit( const TrackingRecHit* hit, const edm::EventSetup& es)
00148 {
00149   SeedingHitImpl * h = new SeedingHitImpl(hit,es);
00150   theImpl = boost::shared_ptr<SeedingHitImpl>(h);
00151 }
00152 
00153 
00154 float SeedingHit::phi() const { return theImpl->phi(); }
00155 float SeedingHit::rOrZ() const { return theImpl->rOrZ(); }
00156 float SeedingHit::r() const { return theImpl->r(); }
00157 float SeedingHit::z() const { return theImpl->z(); }
00158 float SeedingHit::errorRZ() const { return theImpl->errorRZ(); }
00159 float SeedingHit::errorRPhi() const { return theImpl->errorRPhi(); }
00160 
00161 SeedingHit::operator const TrackingRecHit* () const {
00162   return  theImpl->trackingRecHit();
00163 }
00164 
00165 SeedingHit::operator const TransientTrackingRecHit::ConstRecHitPointer& () const {
00166   return theImpl->transientRecHit();
00167 }

Generated on Tue Jun 9 17:45:59 2009 for CMSSW by  doxygen 1.5.4