Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:54

0001 #ifndef TValidTrackingRecHit_H
0002 #define TValidTrackingRecHit_H
0003 
0004 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0005 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitGlobalState.h"
0006 #include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
0007 
0008 /**
0009  *
0010  *  only for valid hits
0011  */
0012 class TValidTrackingRecHit : public TransientTrackingRecHit {
0013 public:
0014   TValidTrackingRecHit(const GeomDet& geom) : TrackingRecHit(geom) {}
0015 
0016   template <typename... Args>
0017   TValidTrackingRecHit(Args&&... args) : TrackingRecHit(std::forward<Args>(args)...) {}
0018 
0019   // to be moved in children
0020   TrackingRecHit* cloneHit() const override { return hit()->clone(); }
0021 
0022   // Extension of the TrackingRecHit interface
0023   const Surface* surface() const final { return &(det()->surface()); }
0024 
0025   GlobalPoint globalPosition() const final { return surface()->toGlobal(localPosition()); }
0026 
0027   GlobalError globalPositionError() const final {
0028     return ErrorFrameTransformer().transform(localPositionError(), *surface());
0029   }
0030   float errorGlobalR() const final { return std::sqrt(globalPositionError().rerr(globalPosition())); }
0031   float errorGlobalZ() const final { return std::sqrt(globalPositionError().czz()); }
0032   float errorGlobalRPhi() const final {
0033     return globalPosition().perp() * sqrt(globalPositionError().phierr(globalPosition()));
0034   }
0035 
0036   // once cache removed will obsolete the above
0037   TrackingRecHitGlobalState globalState() const {
0038     GlobalError globalError = ErrorFrameTransformer::transform(localPositionError(), *surface());
0039     auto gp = globalPosition();
0040     float r = gp.perp();
0041     float errorRPhi = r * std::sqrt(float(globalError.phierr(gp)));
0042     float errorR = std::sqrt(float(globalError.rerr(gp)));
0043     float errorZ = std::sqrt(float(globalError.czz()));
0044     return (TrackingRecHitGlobalState){gp.basicVector(), r, gp.barePhi(), errorR, errorZ, errorRPhi};
0045   }
0046 
0047   /// Returns true if the clone( const TrajectoryStateOnSurface&) method returns an
0048   /// improved hit, false if it returns an identical copy.
0049   /// In order to avoid redundent copies one should call canImproveWithTrack() before
0050   /// calling clone( const TrajectoryStateOnSurface&).
0051   bool canImproveWithTrack() const override { return false; }
0052 
0053   /// cluster probability, overloaded by pixel rechits.
0054   virtual float clusterProbability() const { return 1.f; }
0055 
0056 private:
0057   // hide the clone method for ReferenceCounted. Warning: this method is still
0058   // accessible via the bas class TrackingRecHit interface!
0059   TValidTrackingRecHit* clone() const override = 0;
0060 };
0061 
0062 #endif