Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:40:05

0001 #ifndef DATAFORMATS_TRACKCANDIDATE_TRACKCANDIDATE_H
0002 #define DATAFORMATS_TRACKCANDIDATE_TRACKCANDIDATE_H
0003 
0004 #include "DataFormats/Common/interface/RefToBase.h"
0005 #include "DataFormats/Common/interface/OwnVector.h"
0006 #include "DataFormats/TrackCandidate/interface/TrajectoryStopReasons.h"
0007 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0008 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
0009 #include "FWCore/Utilities/interface/Range.h"
0010 
0011 #include <utility>
0012 
0013 /** A track candidate is
0014     - a TSOS or equivalent (here a PTrajectoryStateOnDet)
0015     - a vector of rechits (here via the OwnVector interface)
0016     - a TrajectorySeed (to be confirmed as matching the final track)
0017     - a reference to the TrajectorySeed in the origianl collection 
0018       of seeds. Often this collection is not saved on disk and 
0019       therefore the reference may be invalid.
0020 
0021 only the second is compulsory,the other three can be empty / not present
0022 **/
0023 
0024 class TrackCandidate {
0025 public:
0026   typedef edm::OwnVector<TrackingRecHit> RecHitContainer;
0027 
0028   TrackCandidate()
0029       : rh_(), seed_(), state_(), seedRef_(), nLoops_(0), stopReason_((uint8_t)StopReason::UNINITIALIZED) {}
0030 
0031   explicit TrackCandidate(RecHitContainer& rh)
0032       : rh_(), seed_(), state_(), seedRef_(), nLoops_(0), stopReason_((uint8_t)StopReason::UNINITIALIZED) {
0033     rh_.swap(rh);
0034   }
0035 
0036   TrackCandidate(RecHitContainer& rh,
0037                  TrajectorySeed const& s,
0038                  PTrajectoryStateOnDet const& st,
0039                  signed char nLoops = 0,
0040                  uint8_t stopReason = (uint8_t)StopReason::UNINITIALIZED)
0041       : rh_(), seed_(s), state_(st), seedRef_(), nLoops_(nLoops), stopReason_(stopReason) {
0042     rh_.swap(rh);
0043   }
0044 
0045   TrackCandidate(RecHitContainer& rh,
0046                  TrajectorySeed const& s,
0047                  PTrajectoryStateOnDet const& st,
0048                  const edm::RefToBase<TrajectorySeed>& seedRef,
0049                  signed char nLoops = 0,
0050                  uint8_t stopReason = (uint8_t)StopReason::UNINITIALIZED)
0051       : rh_(), seed_(s), state_(st), seedRef_(seedRef), nLoops_(nLoops), stopReason_(stopReason) {
0052     rh_.swap(rh);
0053   }
0054 
0055   PTrajectoryStateOnDet const& trajectoryStateOnDet() const { return state_; }
0056 
0057   edm::Range<RecHitContainer::const_iterator> recHits() const { return {rh_.begin(), rh_.end()}; }
0058   auto nRecHits() const { return rh_.size(); }
0059 
0060   TrajectorySeed const& seed() const { return seed_; }
0061 
0062   bool isLooper() const { return (nLoops_ > 0); }
0063   signed char nLoops() const { return nLoops_; }
0064   uint8_t stopReason() const { return stopReason_; }
0065 
0066   void setNLoops(signed char value) { nLoops_ = value; }
0067   void setStopReason(uint8_t value) { stopReason_ = value; }
0068 
0069   /**  return the edm::reference to the trajectory seed in the original
0070    *   seeds collection. If the collection has been dropped from the
0071    *   Event, the reference may be invalid. Its validity should be tested,
0072    *   before the reference is actually used. 
0073    */
0074   edm::RefToBase<TrajectorySeed> seedRef() const { return seedRef_; }
0075 
0076   void setSeedRef(edm::RefToBase<TrajectorySeed>& seedRef) { seedRef_ = seedRef; }
0077 
0078 private:
0079   RecHitContainer rh_;
0080   TrajectorySeed seed_;
0081   PTrajectoryStateOnDet state_;
0082   edm::RefToBase<TrajectorySeed> seedRef_;
0083   signed char nLoops_;
0084   uint8_t stopReason_;
0085 };
0086 #endif