CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/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/SiPixelDetId/interface/PXBDetId.h"
00008 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00009 #include "DataFormats/SiStripDetId/interface/TIBDetId.h" 
00010 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00011 #include "DataFormats/SiStripDetId/interface/TOBDetId.h" 
00012 #include "DataFormats/SiStripDetId/interface/TECDetId.h" 
00013 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSRecHit2D.h" 
00014 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSMatchedRecHit2D.h" 
00015 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00016 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00017 
00018 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00019 
00020 #include <vector>
00021 
00025 class TrackerRecHit {
00026 public:
00027   
00029   TrackerRecHit() :
00030     theSplitHit(0),
00031     theMatchedHit(0),
00032     theGeomDet(0),
00033     theSubDetId(0),
00034     theLayerNumber(0),
00035     theRingNumber(0), 
00036     theCylinderNumber(0), 
00037     theLocalError(0.),
00038     theLargerError(0.),
00039     forward(false) {}
00040 
00042   TrackerRecHit( const SiTrackerGSRecHit2D* theSplitHit, 
00043                  const TrackerRecHit& other ) : 
00044     theSplitHit(theSplitHit),
00045     theMatchedHit(0),
00046     theGeomDet(other.geomDet()),
00047     theSubDetId(other.subDetId()),
00048     theLayerNumber(other.layerNumber()),
00049     theRingNumber(other.ringNumber()), 
00050     theCylinderNumber(other.cylinderNumber()), 
00051     theLocalError(0.),
00052     theLargerError(0.),
00053     forward(other.isForward()) {}
00054 
00056   TrackerRecHit(const SiTrackerGSRecHit2D* theHit, 
00057                 const TrackerGeometry* theGeometry);
00058   
00059   TrackerRecHit(const SiTrackerGSMatchedRecHit2D* theHit, 
00060                 const TrackerGeometry* theGeometry);
00061 
00063   void init(const TrackerGeometry* theGeometry);
00064   
00065   // TrackerRecHit(const SiTrackerGSMatchedRecHit2D* theHit, 
00066   //            const TrackerGeometry* theGeometry);
00067   
00069   //  const SiTrackerGSRecHit2D* hit() const { return theHit; }
00070   inline const SiTrackerGSMatchedRecHit2D* matchedHit() const { return theMatchedHit; }
00071   inline const SiTrackerGSRecHit2D* splitHit() const { return theSplitHit; }
00072   
00073   inline const GSSiTrackerRecHit2DLocalPos* hit() const { 
00074     return theSplitHit ? (GSSiTrackerRecHit2DLocalPos*)theSplitHit : 
00075       (GSSiTrackerRecHit2DLocalPos*)theMatchedHit; }
00076   
00078   inline unsigned int subDetId() const { return theSubDetId; }
00079   
00081   inline unsigned int layerNumber() const { return theLayerNumber; }
00082   
00084   inline unsigned int ringNumber() const { return theRingNumber; }
00085   
00087   unsigned int cylinderNumber() const { return theCylinderNumber; }
00088 
00090   inline bool isForward() const { return forward; }
00091 
00093   inline const GeomDet* geomDet() const { return theGeomDet; }
00094 
00096   inline GlobalPoint globalPosition() const { 
00097     return theGeomDet->surface().toGlobal(hit()->localPosition());
00098   }
00099 
00101   inline LocalPoint localPosition() const { return hit()->localPosition(); }
00102 
00104     //  bool isOnRequestedDet(const std::vector<unsigned int>& whichDet) const;
00105   bool isOnRequestedDet(const std::vector<unsigned int>& whichDet, const std::string& seedingAlgo) const; 
00106   bool isOnRequestedDet(const std::vector<std::string>& layerList) const; // AG
00107 
00109   bool makesAPairWith(const TrackerRecHit& anotherHit) const;
00110   bool makesAPairWith3rd(const TrackerRecHit& anotherHit) const;
00111 
00113   bool makesATripletWith(const TrackerRecHit& anotherHit,
00114                          const TrackerRecHit& yetAnotherHit) const;
00115 
00117   inline bool isOnTheSameLayer(const TrackerRecHit& other) const {
00118     
00119     return 
00120       theSubDetId == other.subDetId() && 
00121       theLayerNumber == other.layerNumber();
00122   }
00123 
00124   // The smaller local error
00125   double localError() { 
00126 
00127     // Check if it has been already computed
00128     if ( theLocalError != 0. ) return theLocalError;
00129 
00130     // Otherwise, compute it!
00131     double xx = hit()->localPositionError().xx();
00132     double yy = hit()->localPositionError().yy();
00133     double xy = hit()->localPositionError().xy();
00134     double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
00135     theLocalError = 0.5 * (xx+yy-delta);
00136     return theLocalError;
00137 
00138   }
00139   
00140   // The larger local error
00141   double largerError() { 
00142 
00143     // Check if it has been already computed
00144     if ( theLargerError != 0. ) return theLargerError;
00145 
00146     // Otherwise, compute it!
00147     double xx = hit()->localPositionError().xx();
00148     double yy = hit()->localPositionError().yy();
00149     double xy = hit()->localPositionError().xy();
00150     double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
00151     theLargerError = 0.5 * (xx+yy+delta);
00152     return theLargerError;
00153 
00154   }
00155   
00156   inline bool operator!=(const TrackerRecHit& aHit) const {
00157     return 
00158       aHit.geomDet() != this->geomDet() ||
00159       aHit.hit()->localPosition().x() != this->hit()->localPosition().x() ||
00160       aHit.hit()->localPosition().y() != this->hit()->localPosition().y() ||
00161       aHit.hit()->localPosition().z() != this->hit()->localPosition().z();
00162   }
00163 
00164  private:
00165   
00166   const SiTrackerGSRecHit2D* theSplitHit;
00167   const SiTrackerGSMatchedRecHit2D* theMatchedHit;
00168   const GeomDet* theGeomDet;
00169   unsigned int theSubDetId; 
00170   unsigned int theLayerNumber;
00171   unsigned int theRingNumber;
00172   unsigned int theCylinderNumber;
00173   double theLocalError;
00174   double theLargerError;
00175   bool forward;
00176   
00177 };
00178 
00179 #endif
00180