ATLAS Offline Software
TimedHitPtr.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef HITMANAGEMENT_TIMEDHITPTR
6 #define HITMANAGEMENT_TIMEDHITPTR
7 
15 template <class HIT>
16 class TimedHitPtr {
17 public:
19  TimedHitPtr() : m_eventTime(0), m_eventId(0), m_pileupType(0), m_pHit(nullptr) {}
22 
24  TimedHitPtr(float eventTime, const HIT* pHit, int pileupType=0) :
27  TimedHitPtr(float eventTime, unsigned short eventId, const HIT* pHit, int pileupType=0) :
29 
32  if(&rhs != this) { m_eventTime = rhs.m_eventTime; m_eventId = rhs.m_eventId; m_pileupType = rhs.m_pileupType; m_pHit = rhs.m_pHit; }
33  return *this;
34  }
35 
37  const HIT& operator*() const { return *m_pHit; }
38  const HIT* operator->() const { return m_pHit; }
39 
42  unsigned short eventId() const { return m_eventId; }
43 
46  int pileupType() const { return m_pileupType; }
47 
50  float eventTime() const { return m_eventTime; }
51 
52 private:
53 
55  float m_eventTime;
57  unsigned short m_eventId;
59  const HIT* m_pHit; //don't own
60 
61  template <class FHIT>
62  friend float hitTime(const TimedHitPtr<FHIT>&);
63 };
64 
65 template <class HIT>
66 inline float hitTime(const TimedHitPtr<HIT>& tHit) {
67  return tHit.m_eventTime + hitTime(*tHit);
68 }
69 
70 
71 
72 template <class HIT>
73 bool operator < (const TimedHitPtr<HIT>& lhs, const TimedHitPtr<HIT>& rhs ) {
74  return ( 0 != lhs.operator->() && 0 != rhs.operator->() && *lhs < *rhs);
75 }
76 
77 #endif
TimedHitPtr::m_pileupType
int m_pileupType
Definition: TimedHitPtr.h:58
TimedHitPtr::TimedHitPtr
TimedHitPtr(float eventTime, unsigned short eventId, const HIT *pHit, int pileupType=0)
use this constructor when hit has a PileUpTimeEventIndex
Definition: TimedHitPtr.h:27
TimedHitPtr::m_eventId
unsigned short m_eventId
the index in PileUpEventInfo of the component event hosting this hit
Definition: TimedHitPtr.h:57
TimedHitPtr::operator->
const HIT * operator->() const
Definition: TimedHitPtr.h:38
TimedHitPtr
a smart pointer to a hit that also provides access to the extended timing info of the host event....
Definition: SCT_SurfaceChargesGenerator.h:77
TimedHitPtr::eventTime
float eventTime() const
t0 offset of the bunch xing containing the hit in ns.
Definition: TimedHitPtr.h:50
TimedHitPtr::pileupType
int pileupType() const
the type of event which the hit came from (signal, low pt minbias, high pt minbias,...
Definition: TimedHitPtr.h:46
TimedHitPtr::m_eventTime
float m_eventTime
t0 offset of the bunch xing in ns
Definition: TimedHitPtr.h:55
TimedHitPtr::hitTime
friend float hitTime(const TimedHitPtr< FHIT > &)
TimedHitPtr::m_pHit
const HIT * m_pHit
Definition: TimedHitPtr.h:59
TimedHitPtr::operator*
const HIT & operator*() const
smart pointer interface
Definition: TimedHitPtr.h:37
hitTime
float hitTime(const TimedHitPtr< HIT > &tHit)
Definition: TimedHitPtr.h:66
TimedHitPtr::operator=
TimedHitPtr< HIT > & operator=(const TimedHitPtr< HIT > &rhs)
assignment operator
Definition: TimedHitPtr.h:31
TimedHitPtr::eventId
unsigned short eventId() const
the index of the component event in PileUpEventInfo.
Definition: TimedHitPtr.h:42
TimedHitPtr::TimedHitPtr
TimedHitPtr(const TimedHitPtr< HIT > &rhs)
Definition: TimedHitPtr.h:20
TimedHitPtr::TimedHitPtr
TimedHitPtr()
STL required constructors.
Definition: TimedHitPtr.h:19
operator<
bool operator<(const TimedHitPtr< HIT > &lhs, const TimedHitPtr< HIT > &rhs)
Definition: TimedHitPtr.h:73
TimedHitPtr::TimedHitPtr
TimedHitPtr(float eventTime, const HIT *pHit, int pileupType=0)
minimal constructor: pass only t0 offset of bunch xing
Definition: TimedHitPtr.h:24