Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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