Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-28 03:10:23

0001 #ifndef TrackingTools_TransientTrack_TrackingTransientTrack_h
0002 #define TrackingTools_TransientTrack_TrackingTransientTrack_h
0003 
0004 #include <atomic>
0005 
0006 /**
0007    * Concrete implementation of the TransientTrack for a reco::Track
0008    */
0009 
0010 #include "TrackingTools/TransientTrack/interface/BasicTransientTrack.h"
0011 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
0012 #include "DataFormats/TrackReco/interface/Track.h"
0013 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0014 #include "TrackingTools/PatternTools/interface/TSCPBuilderNoMaterial.h"
0015 
0016 namespace reco {
0017 
0018   class TrackTransientTrack : public Track, public BasicTransientTrack {
0019   public:
0020     // constructor from persistent track
0021     TrackTransientTrack();
0022     TrackTransientTrack(const Track& tk, const MagneticField* field);
0023     TrackTransientTrack(const Track& tk, const double time, const double dtime, const MagneticField* field);
0024 
0025     TrackTransientTrack(const TrackRef& tk, const MagneticField* field);
0026     TrackTransientTrack(const TrackRef& tk, const double time, const double dtime, const MagneticField* field);
0027 
0028     TrackTransientTrack(const TrackRef& tk,
0029                         const MagneticField* field,
0030                         const edm::ESHandle<GlobalTrackingGeometry>& trackingGeometry);
0031     TrackTransientTrack(const TrackRef& tk,
0032                         const double time,
0033                         const double dtime,
0034                         const MagneticField* field,
0035                         const edm::ESHandle<GlobalTrackingGeometry>& trackingGeometry);
0036 
0037     TrackTransientTrack(const Track& tk,
0038                         const MagneticField* field,
0039                         const edm::ESHandle<GlobalTrackingGeometry>& trackingGeometry);
0040     TrackTransientTrack(const Track& tk,
0041                         const double time,
0042                         const double dtime,
0043                         const MagneticField* field,
0044                         const edm::ESHandle<GlobalTrackingGeometry>& trackingGeometry);
0045 
0046     TrackTransientTrack(const TrackTransientTrack& tt);
0047 
0048     TrackTransientTrack& operator=(const TrackTransientTrack& tt);
0049 
0050     void setTrackingGeometry(const edm::ESHandle<GlobalTrackingGeometry>&) override;
0051 
0052     void setBeamSpot(const reco::BeamSpot& beamSpot) override;
0053 
0054     FreeTrajectoryState initialFreeState() const override { return initialFTS; }
0055 
0056     TrajectoryStateOnSurface outermostMeasurementState() const override;
0057 
0058     TrajectoryStateOnSurface innermostMeasurementState() const override;
0059 
0060     TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint& point) const override {
0061       return builder(initialFTS, point);
0062     }
0063 
0064     /**
0065     * The TSOS at any point. The initial state will be used for the propagation.
0066     */
0067     TrajectoryStateOnSurface stateOnSurface(const GlobalPoint& point) const override;
0068 
0069     TrajectoryStateClosestToPoint impactPointTSCP() const override;
0070 
0071     TrajectoryStateOnSurface impactPointState() const override;
0072 
0073     bool impactPointStateAvailable() const override { return (m_TSOS.load() == kSet ? true : false); }
0074 
0075     /**
0076    * access to original persistent track
0077    */
0078     TrackRef persistentTrackRef() const { return tkr_; }
0079 
0080     TrackBaseRef trackBaseRef() const override { return TrackBaseRef(tkr_); }
0081 
0082     TrackCharge charge() const override { return Track::charge(); }
0083 
0084     const MagneticField* field() const override { return theField; }
0085 
0086     const Track& track() const override { return *this; }
0087 
0088     TrajectoryStateClosestToBeamLine stateAtBeamLine() const override;
0089 
0090     double timeExt() const override { return (hasTime ? timeExt_ : std::numeric_limits<double>::quiet_NaN()); }
0091     double dtErrorExt() const override { return (hasTime ? dtErrorExt_ : std::numeric_limits<double>::quiet_NaN()); }
0092 
0093   private:
0094     TrackRef tkr_;
0095     bool hasTime;
0096     double timeExt_, dtErrorExt_;
0097     const MagneticField* theField;
0098 
0099     FreeTrajectoryState initialFTS;
0100 
0101     // mutable member data, those should be treated very carefully to guarantee
0102     // thread safeness of the code by using atomic thread-safe helpers, see below
0103     mutable TrajectoryStateOnSurface initialTSOS;
0104     mutable TrajectoryStateClosestToPoint initialTSCP;
0105     mutable TrajectoryStateClosestToBeamLine trajectoryStateClosestToBeamLine;
0106     // thread-safe helpers to guarantee proper update of mutable member data
0107     mutable std::atomic<char> m_TSOS;
0108     mutable std::atomic<char> m_TSCP;
0109     mutable std::atomic<char> m_SCTBL;
0110 
0111     TSCPBuilderNoMaterial builder;
0112     edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
0113     reco::BeamSpot theBeamSpot;
0114 
0115     // to be used to setup thread states of class mutables
0116     enum CacheStates { kUnset, kSetting, kSet };
0117   };
0118 
0119 }  // namespace reco
0120 
0121 #endif