ATLAS Offline Software
TimedHitPtr.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef HITMANAGEMENT_TIMEDHITPTR
6 #define HITMANAGEMENT_TIMEDHITPTR
7 
15 #include <type_traits>
16 
17 template <typename HIT>
18 class TimedHitPtr {
19 public:
20  using element_type = std::add_const_t<HIT>;
21  using value_type = HIT;
24  TimedHitPtr() = default;
25  TimedHitPtr(const TimedHitPtr<HIT>& rhs) = default;
26  TimedHitPtr(TimedHitPtr<HIT>&& rhs) = default;
27 
28 
30  TimedHitPtr(float eventTime, const HIT* pHit, int pileupType=0) :
33  TimedHitPtr(float eventTime, unsigned short eventId, const HIT* pHit, int pileupType=0) :
35 
40  const HIT& operator*() const { return *m_pHit; }
41  const HIT* operator->() const { return m_pHit; }
42  const HIT* get() const { return m_pHit; }
43 
44  operator bool () const { return m_pHit != nullptr; }
47  unsigned short eventId() const { return m_eventId; }
48 
51  int pileupType() const { return m_pileupType; }
52 
55  float eventTime() const { return m_eventTime; }
56 
57 private:
58 
60  float m_eventTime{0.f};
62  unsigned short m_eventId{0u};
63  int m_pileupType{0};
64  const HIT* m_pHit{nullptr}; //don't own
65 
66  template <class FHIT>
67  friend float hitTime(const TimedHitPtr<FHIT>&);
68 };
69 
70 template <class HIT>
71 inline float hitTime(const TimedHitPtr<HIT>& tHit) {
72  return tHit.m_eventTime + hitTime(*tHit);
73 }
74 
75 
76 
77 template <class HIT>
78 bool operator < (const TimedHitPtr<HIT>& lhs, const TimedHitPtr<HIT>& rhs ) {
79  return ( lhs.get() && rhs.get() && *lhs < *rhs);
80 }
81 #endif
TimedHitPtr::m_pileupType
int m_pileupType
Definition: TimedHitPtr.h:63
TimedHitPtr::operator=
TimedHitPtr< HIT > & operator=(const TimedHitPtr< HIT > &rhs)=default
assignment operator
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:33
TimedHitPtr::operator=
TimedHitPtr< HIT > & operator=(TimedHitPtr< HIT > &&rhs)=default
TimedHitPtr::m_eventId
unsigned short m_eventId
the index in PileUpEventInfo of the component event hosting this hit
Definition: TimedHitPtr.h:62
TimedHitPtr::operator->
const HIT * operator->() const
Definition: TimedHitPtr.h:41
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
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
TimedHitPtr::eventTime
float eventTime() const
t0 offset of the bunch xing containing the hit in ns.
Definition: TimedHitPtr.h:55
TimedHitPtr::pileupType
int pileupType() const
the type of event which the hit came from (signal, low pt minbias, high pt minbias,...
Definition: TimedHitPtr.h:51
TimedHitPtr< CSCSimHit >::element_type
std::add_const_t< HIT > element_type
Definition: TimedHitPtr.h:20
TimedHitPtr::get
const HIT * get() const
Definition: TimedHitPtr.h:42
TimedHitPtr::TimedHitPtr
TimedHitPtr(TimedHitPtr< HIT > &&rhs)=default
TimedHitPtr< CSCSimHit >::const_value_type
element_type const_value_type
Definition: TimedHitPtr.h:22
TimedHitPtr::m_eventTime
float m_eventTime
t0 offset of the bunch xing in ns
Definition: TimedHitPtr.h:60
TimedHitPtr::TimedHitPtr
TimedHitPtr(const TimedHitPtr< HIT > &rhs)=default
TimedHitPtr::hitTime
friend float hitTime(const TimedHitPtr< FHIT > &)
TimedHitPtr::m_pHit
const HIT * m_pHit
Definition: TimedHitPtr.h:64
TimedHitPtr::operator*
const HIT & operator*() const
smart pointer interface
Definition: TimedHitPtr.h:40
hitTime
float hitTime(const TimedHitPtr< HIT > &tHit)
Definition: TimedHitPtr.h:71
TimedHitPtr::eventId
unsigned short eventId() const
the index of the component event in PileUpEventInfo.
Definition: TimedHitPtr.h:47
TimedHitPtr::TimedHitPtr
TimedHitPtr()=default
STL required constructors.
value_type
Definition: EDM_MasterSearch.h:11
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
operator<
bool operator<(const TimedHitPtr< HIT > &lhs, const TimedHitPtr< HIT > &rhs)
Definition: TimedHitPtr.h:78
TimedHitPtr::TimedHitPtr
TimedHitPtr(float eventTime, const HIT *pHit, int pileupType=0)
minimal constructor: pass only t0 offset of bunch xing
Definition: TimedHitPtr.h:30