CMS 3D CMS Logo

TrackExtraBase.h
Go to the documentation of this file.
1 #ifndef DataFormats_TrackReco_TrackExtraBase_h
2 #define DataFormats_TrackReco_TrackExtraBase_h
3 
19 
20 namespace reco
21 {
22 
24 {
25 public:
26  using TrajParams = std::vector<LocalTrajectoryParameters>;
27  using Chi2sFive = std::vector<unsigned char>;
28 
30  TrackExtraBase() : m_firstHit((unsigned int) -1), m_nHits(0) { }
31 
32  void setHits(TrackingRecHitRefProd const & prod, unsigned firstH, unsigned int nH) {
33  m_hitCollection.pushBackItem(prod.refCore(), true);
34  m_firstHit = firstH;
35  m_nHits = nH;
36  }
37 
38  void setTrajParams(TrajParams tmps, Chi2sFive chi2s) {
39  m_trajParams = std::move(tmps);
40  m_chi2sX5 = std::move(chi2s);
41  }
42 
43  unsigned int firstRecHit() const {
44  return m_firstHit;
45  }
46 
48  unsigned int recHitsSize() const {
49  return m_nHits;
50  }
51 
53  auto recHits() const { return TrackingRecHitRange(recHitsBegin(), recHitsEnd()); }
54 
57  return recHitsProduct().data().begin()+firstRecHit();
58  }
59 
62  return recHitsBegin()+recHitsSize();
63  }
64 
66  TrackingRecHitRef recHitRef(unsigned int i) const {
67  //Another thread might change the RefCore at the same time.
68  // By using a copy we will be safe.
70  if(hitCollection.productPtr()) {
72  TrackingRecHitRef::value_type const* item = finder(*(static_cast<TrackingRecHitRef::product_type const*>(hitCollection.productPtr())), m_firstHit+i);
73  return TrackingRecHitRef(hitCollection.id(), item, m_firstHit+i);
74  }
75  return TrackingRecHitRef(hitCollection, m_firstHit+i);
76  }
77 
79  TrackingRecHitRef recHit(unsigned int i) const {
80  return recHitRef(i);
81  }
82 
84  return *edm::getProduct<TrackingRecHitCollection>(m_hitCollection);
85  }
86 
87  TrajParams const & trajParams() const {return m_trajParams;}
88  Chi2sFive const & chi2sX5() const { return m_chi2sX5;}
89 
90 private:
92  unsigned int m_firstHit;
93  unsigned int m_nHits;
95  Chi2sFive m_chi2sX5; // chi2 * 5 chopped at 255 (max chi2 is 51)
96 };
97 
98 } // namespace reco
99 
100 #endif // DataFormats_TrackReco_TrackExtraBase_h
void pushBackItem(RefCore const &productToBeInserted, bool checkPointer)
Definition: RefCore.cc:194
std::vector< unsigned char > Chi2sFive
TrackingRecHitCollection const & recHitsProduct() const
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
trackingRecHit_iterator recHitsEnd() const
last iterator over RecHits
TrackingRecHitRef recHitRef(unsigned int i) const
get a ref to i-th recHit
std::vector< LocalTrajectoryParameters > TrajParams
TrackingRecHitRef recHit(unsigned int i) const
get i-th recHit
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
unsigned int recHitsSize() const
number of RecHits
TrajParams const & trajParams() const
auto recHits() const
accessor to RecHits
void const * productPtr() const
Definition: RefCore.h:52
RefCore const & refCore() const
Definition: RefProd.h:123
Chi2sFive const & chi2sX5() const
TrackExtraBase()
default constructor
trackingRecHit_iterator recHitsBegin() const
first iterator over RecHits
unsigned int m_nHits
edm::Range< trackingRecHit_iterator > TrackingRecHitRange
Range class to enable range-based loops for a tracks RecHits.
T value_type
Definition: Ref.h:163
F finder_type
Definition: Ref.h:165
ProductID id() const
Definition: RefCore.h:49
fixed size matrix
base const & data() const
Definition: OwnVector.h:440
unsigned int m_firstHit
unsigned int firstRecHit() const
def move(src, dest)
Definition: eostools.py:511
void setTrajParams(TrajParams tmps, Chi2sFive chi2s)
edm::RefCore m_hitCollection