Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-27 04:17:44

0001 #ifndef DATAFORMATS_TRAJECTORYSEED_TRAJECTORYSEED_h
0002 #define DATAFORMATS_TRAJECTORYSEED_TRAJECTORYSEED_h
0003 
0004 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
0005 #include "DataFormats/Common/interface/OwnVector.h"
0006 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0007 #include "DataFormats/TrajectoryState/interface/PTrajectoryStateOnDet.h"
0008 #include "FWCore/Utilities/interface/Range.h"
0009 #include <utility>
0010 #include <algorithm>
0011 
0012 /**
0013    TrajectorySeed contains
0014    - a TSOS
0015    - a vector of RecHits (with Own_vector to store polimorphic)
0016    - a propagation direction
0017 **/
0018 class TrajectorySeed {
0019 public:
0020   typedef edm::OwnVector<TrackingRecHit> RecHitContainer;
0021   typedef edm::Range<RecHitContainer::const_iterator> RecHitRange;
0022 
0023   TrajectorySeed() {}
0024   virtual ~TrajectorySeed() {}
0025 
0026   TrajectorySeed(PTrajectoryStateOnDet const& ptsos, RecHitContainer const& rh, PropagationDirection dir)
0027       : hits_(rh), tsos_(ptsos), dir_(dir) {}
0028 
0029   TrajectorySeed(PTrajectoryStateOnDet const& ptsos, RecHitContainer&& rh, PropagationDirection dir) noexcept
0030       : hits_(std::move(rh)), tsos_(ptsos), dir_(dir) {}
0031 
0032   void swap(PTrajectoryStateOnDet& ptsos, RecHitContainer& rh, PropagationDirection& dir) noexcept {
0033     hits_.swap(rh);
0034     std::swap(tsos_, ptsos);
0035     std::swap(dir_, dir);
0036   }
0037 
0038   void swap(TrajectorySeed& rh) noexcept {
0039     hits_.swap(rh.hits_);
0040     std::swap(tsos_, rh.tsos_);
0041     std::swap(dir_, rh.dir_);
0042   }
0043 
0044   TrajectorySeed(TrajectorySeed const& o) = default;
0045 
0046   TrajectorySeed& operator=(TrajectorySeed const& o) = default;
0047 
0048   TrajectorySeed(TrajectorySeed&& o) noexcept = default;
0049 
0050   TrajectorySeed& operator=(TrajectorySeed&& o) noexcept = default;
0051 
0052   RecHitRange recHits() const { return {hits_.begin(), hits_.end()}; }
0053   unsigned int nHits() const { return hits_.size(); }
0054   PropagationDirection direction() const { return dir_; }
0055   PTrajectoryStateOnDet const& startingState() const { return tsos_; }
0056 
0057   virtual TrajectorySeed* clone() const { return new TrajectorySeed(*this); }
0058 
0059 private:
0060   RecHitContainer hits_;
0061   PTrajectoryStateOnDet tsos_;
0062   PropagationDirection dir_ = invalidDirection;
0063 };
0064 
0065 inline void swap(TrajectorySeed& rh, TrajectorySeed& lh) noexcept { rh.swap(lh); }
0066 
0067 typedef TrajectorySeed BasicTrajectorySeed;
0068 
0069 #endif