CMS 3D CMS Logo

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     theLocalError(0.),
00037     theLargerError(0.),
00038     forward(false) {}
00039 
00041   TrackerRecHit( const SiTrackerGSRecHit2D* theSplitHit, 
00042                  const TrackerRecHit& other ) : 
00043     theSplitHit(theSplitHit),
00044     theMatchedHit(0),
00045     theGeomDet(other.geomDet()),
00046     theSubDetId(other.subDetId()),
00047     theLayerNumber(other.layerNumber()),
00048     theRingNumber(other.ringNumber()), 
00049     theLocalError(0.),
00050     theLargerError(0.),
00051     forward(other.isForward()) {}
00052 
00054   TrackerRecHit(const SiTrackerGSRecHit2D* theHit, 
00055                 const TrackerGeometry* theGeometry);
00056   
00057   TrackerRecHit(const SiTrackerGSMatchedRecHit2D* theHit, 
00058                 const TrackerGeometry* theGeometry);
00059 
00061   void init(const TrackerGeometry* theGeometry);
00062   
00063   // TrackerRecHit(const SiTrackerGSMatchedRecHit2D* theHit, 
00064   //            const TrackerGeometry* theGeometry);
00065   
00067   //  const SiTrackerGSRecHit2D* hit() const { return theHit; }
00068   inline const SiTrackerGSMatchedRecHit2D* matchedHit() const { return theMatchedHit; }
00069   inline const SiTrackerGSRecHit2D* splitHit() const { return theSplitHit; }
00070   
00071   inline const GSSiTrackerRecHit2DLocalPos* hit() const { 
00072     return theSplitHit ? (GSSiTrackerRecHit2DLocalPos*)theSplitHit : 
00073       (GSSiTrackerRecHit2DLocalPos*)theMatchedHit; }
00074   
00076   inline unsigned int subDetId() const { return theSubDetId; }
00077   
00079   inline unsigned int layerNumber() const { return theLayerNumber; }
00080   
00082   inline unsigned int ringNumber() const { return theRingNumber; }
00083   
00085   unsigned int cylinderNumber() const { return theCylinderNumber; }
00086 
00088   inline bool isForward() const { return forward; }
00089 
00091   inline const GeomDet* geomDet() const { return theGeomDet; }
00092 
00094   inline GlobalPoint globalPosition() const { 
00095     return theGeomDet->surface().toGlobal(hit()->localPosition());
00096   }
00097 
00099   inline LocalPoint localPosition() const { return hit()->localPosition(); }
00100 
00102   bool isOnRequestedDet(const std::vector<unsigned int>& whichDet) const;
00103 
00105   bool makesAPairWith(const TrackerRecHit& anotherHit) const;
00106 
00108   bool makesATripletWith(const TrackerRecHit& anotherHit,
00109                          const TrackerRecHit& yetAnotherHit) const;
00110  
00112   inline bool isOnTheSameLayer(const TrackerRecHit& other) const {
00113     
00114     return 
00115       theSubDetId == other.subDetId() && 
00116       theLayerNumber == other.layerNumber();
00117   }
00118 
00119   // The smaller local error
00120   double localError() { 
00121 
00122     // Check if it has been already computed
00123     if ( theLocalError != 0. ) return theLocalError;
00124 
00125     // Otherwise, compute it!
00126     double xx = hit()->localPositionError().xx();
00127     double yy = hit()->localPositionError().yy();
00128     double xy = hit()->localPositionError().xy();
00129     double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
00130     theLocalError = 0.5 * (xx+yy-delta);
00131     return theLocalError;
00132 
00133   }
00134   
00135   // The larger local error
00136   double largerError() { 
00137 
00138     // Check if it has been already computed
00139     if ( theLargerError != 0. ) return theLargerError;
00140 
00141     // Otherwise, compute it!
00142     double xx = hit()->localPositionError().xx();
00143     double yy = hit()->localPositionError().yy();
00144     double xy = hit()->localPositionError().xy();
00145     double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
00146     theLargerError = 0.5 * (xx+yy+delta);
00147     return theLargerError;
00148 
00149   }
00150   
00151   inline bool operator!=(const TrackerRecHit& aHit) const {
00152     return 
00153       aHit.geomDet() != this->geomDet() ||
00154       aHit.hit()->localPosition().x() != this->hit()->localPosition().x() ||
00155       aHit.hit()->localPosition().y() != this->hit()->localPosition().y() ||
00156       aHit.hit()->localPosition().z() != this->hit()->localPosition().z();
00157   }
00158 
00159  private:
00160   
00161   const SiTrackerGSRecHit2D* theSplitHit;
00162   const SiTrackerGSMatchedRecHit2D* theMatchedHit;
00163   const GeomDet* theGeomDet;
00164   unsigned int theSubDetId; 
00165   unsigned int theLayerNumber;
00166   unsigned int theRingNumber;
00167   unsigned int theCylinderNumber;
00168   double theLocalError;
00169   double theLargerError;
00170   bool forward;
00171   
00172 };
00173 
00174 #endif
00175 

Generated on Tue Jun 9 17:35:14 2009 for CMSSW by  doxygen 1.5.4