CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/FastSimulation/Tracking/interface/TrackerRecHit.h

Go to the documentation of this file.
00001 #ifndef FastSimulation_Tracking_TrackerRecHit_H_
00002 #define FastSimulation_Tracking_TrackerRecHit_H_
00003 
00004 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00005 #include "DataFormats/DetId/interface/DetId.h"
00006 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00007 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00008 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00009 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSRecHit2D.h" 
00010 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSMatchedRecHit2D.h" 
00011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00012 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00013 
00014 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00015 
00016 #include <vector>
00017 
00018 class TrackerTopology;
00019 
00023 class TrackerRecHit {
00024 public:
00025   
00027   TrackerRecHit() :
00028     theSplitHit(0),
00029     theMatchedHit(0),
00030     theGeomDet(0),
00031     theSubDetId(0),
00032     theLayerNumber(0),
00033     theRingNumber(0), 
00034     theCylinderNumber(0), 
00035     theLocalError(0.),
00036     theLargerError(0.),
00037     forward(false) {}
00038 
00040   TrackerRecHit( const SiTrackerGSRecHit2D* theSplitHit, 
00041                  const TrackerRecHit& other ) : 
00042     theSplitHit(theSplitHit),
00043     theMatchedHit(0),
00044     theGeomDet(other.geomDet()),
00045     theSubDetId(other.subDetId()),
00046     theLayerNumber(other.layerNumber()),
00047     theRingNumber(other.ringNumber()), 
00048     theCylinderNumber(other.cylinderNumber()), 
00049     theLocalError(0.),
00050     theLargerError(0.),
00051     forward(other.isForward()) {}
00052 
00054   TrackerRecHit(const SiTrackerGSRecHit2D* theHit, 
00055                 const TrackerGeometry* theGeometry,
00056                 const TrackerTopology* tTopo);
00057   
00058   TrackerRecHit(const SiTrackerGSMatchedRecHit2D* theHit, 
00059                 const TrackerGeometry* theGeometry,
00060                 const TrackerTopology *tTopo);
00061 
00063   void init(const TrackerGeometry* theGeometry,
00064             const TrackerTopology *tTopo);
00065   
00066   // TrackerRecHit(const SiTrackerGSMatchedRecHit2D* theHit, 
00067   //            const TrackerGeometry* theGeometry);
00068   
00070   //  const SiTrackerGSRecHit2D* hit() const { return theHit; }
00071   inline const SiTrackerGSMatchedRecHit2D* matchedHit() const { return theMatchedHit; }
00072   inline const SiTrackerGSRecHit2D* splitHit() const { return theSplitHit; }
00073   
00074   inline const GSSiTrackerRecHit2DLocalPos* hit() const { 
00075     return theSplitHit ? (GSSiTrackerRecHit2DLocalPos*)theSplitHit : 
00076       (GSSiTrackerRecHit2DLocalPos*)theMatchedHit; }
00077   
00079   inline unsigned int subDetId() const { return theSubDetId; }
00080   
00082   inline unsigned int layerNumber() const { return theLayerNumber; }
00083   
00085   inline unsigned int ringNumber() const { return theRingNumber; }
00086   
00088   unsigned int cylinderNumber() const { return theCylinderNumber; }
00089 
00091   inline bool isForward() const { return forward; }
00092 
00094   inline const GeomDet* geomDet() const { return theGeomDet; }
00095 
00097   inline GlobalPoint globalPosition() const { 
00098     return theGeomDet->surface().toGlobal(hit()->localPosition());
00099   }
00100 
00102   inline LocalPoint localPosition() const { return hit()->localPosition(); }
00103 
00105     //  bool isOnRequestedDet(const std::vector<unsigned int>& whichDet) const;
00106   bool isOnRequestedDet(const std::vector<unsigned int>& whichDet, const std::string& seedingAlgo) const; 
00107   bool isOnRequestedDet(const std::vector<std::string>& layerList) const; // AG
00108 
00110   bool makesAPairWith(const TrackerRecHit& anotherHit) const;
00111   bool makesAPairWith3rd(const TrackerRecHit& anotherHit) const;
00112 
00114   bool makesATripletWith(const TrackerRecHit& anotherHit,
00115                          const TrackerRecHit& yetAnotherHit) const;
00116 
00118   inline bool isOnTheSameLayer(const TrackerRecHit& other) const {
00119     
00120     return 
00121       theSubDetId == other.subDetId() && 
00122       theLayerNumber == other.layerNumber();
00123   }
00124 
00125   // The smaller local error
00126   double localError() { 
00127 
00128     // Check if it has been already computed
00129     if ( theLocalError != 0. ) return theLocalError;
00130 
00131     // Otherwise, compute it!
00132     double xx = hit()->localPositionError().xx();
00133     double yy = hit()->localPositionError().yy();
00134     double xy = hit()->localPositionError().xy();
00135     double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
00136     theLocalError = 0.5 * (xx+yy-delta);
00137     return theLocalError;
00138 
00139   }
00140   
00141   // The larger local error
00142   double largerError() { 
00143 
00144     // Check if it has been already computed
00145     if ( theLargerError != 0. ) return theLargerError;
00146 
00147     // Otherwise, compute it!
00148     double xx = hit()->localPositionError().xx();
00149     double yy = hit()->localPositionError().yy();
00150     double xy = hit()->localPositionError().xy();
00151     double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
00152     theLargerError = 0.5 * (xx+yy+delta);
00153     return theLargerError;
00154 
00155   }
00156   
00157   inline bool operator!=(const TrackerRecHit& aHit) const {
00158     return 
00159       aHit.geomDet() != this->geomDet() ||
00160       aHit.hit()->localPosition().x() != this->hit()->localPosition().x() ||
00161       aHit.hit()->localPosition().y() != this->hit()->localPosition().y() ||
00162       aHit.hit()->localPosition().z() != this->hit()->localPosition().z();
00163   }
00164 
00165  private:
00166   
00167   const SiTrackerGSRecHit2D* theSplitHit;
00168   const SiTrackerGSMatchedRecHit2D* theMatchedHit;
00169   const GeomDet* theGeomDet;
00170   unsigned int theSubDetId; 
00171   unsigned int theLayerNumber;
00172   unsigned int theRingNumber;
00173   unsigned int theCylinderNumber;
00174   double theLocalError;
00175   double theLargerError;
00176   bool forward;
00177   
00178 };
00179 
00180 #endif
00181