CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/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 
00108   bool makesAPairWith(const TrackerRecHit& anotherHit) const;
00109   bool makesAPairWith3rd(const TrackerRecHit& anotherHit) const;
00110 
00112   bool makesATripletWith(const TrackerRecHit& anotherHit,
00113                          const TrackerRecHit& yetAnotherHit) const;
00114 
00116   inline bool isOnTheSameLayer(const TrackerRecHit& other) const {
00117     
00118     return 
00119       theSubDetId == other.subDetId() && 
00120       theLayerNumber == other.layerNumber();
00121   }
00122 
00123   // The smaller local error
00124   double localError() { 
00125 
00126     // Check if it has been already computed
00127     if ( theLocalError != 0. ) return theLocalError;
00128 
00129     // Otherwise, compute it!
00130     double xx = hit()->localPositionError().xx();
00131     double yy = hit()->localPositionError().yy();
00132     double xy = hit()->localPositionError().xy();
00133     double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
00134     theLocalError = 0.5 * (xx+yy-delta);
00135     return theLocalError;
00136 
00137   }
00138   
00139   // The larger local error
00140   double largerError() { 
00141 
00142     // Check if it has been already computed
00143     if ( theLargerError != 0. ) return theLargerError;
00144 
00145     // Otherwise, compute it!
00146     double xx = hit()->localPositionError().xx();
00147     double yy = hit()->localPositionError().yy();
00148     double xy = hit()->localPositionError().xy();
00149     double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
00150     theLargerError = 0.5 * (xx+yy+delta);
00151     return theLargerError;
00152 
00153   }
00154   
00155   inline bool operator!=(const TrackerRecHit& aHit) const {
00156     return 
00157       aHit.geomDet() != this->geomDet() ||
00158       aHit.hit()->localPosition().x() != this->hit()->localPosition().x() ||
00159       aHit.hit()->localPosition().y() != this->hit()->localPosition().y() ||
00160       aHit.hit()->localPosition().z() != this->hit()->localPosition().z();
00161   }
00162 
00163  private:
00164   
00165   const SiTrackerGSRecHit2D* theSplitHit;
00166   const SiTrackerGSMatchedRecHit2D* theMatchedHit;
00167   const GeomDet* theGeomDet;
00168   unsigned int theSubDetId; 
00169   unsigned int theLayerNumber;
00170   unsigned int theRingNumber;
00171   unsigned int theCylinderNumber;
00172   double theLocalError;
00173   double theLargerError;
00174   bool forward;
00175   
00176 };
00177 
00178 #endif
00179