ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkEvent
TrkTruthData
TrkTruthData
SubDetHitStatistics.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Dear emacs, this is -*-c++-*-
6
25
26
#ifndef SUBDETHITSTATISTICS_H
27
#define SUBDETHITSTATISTICS_H
28
29
#include "
AthenaKernel/CLASS_DEF.h
"
30
31
class
TrackTruthCollectionAccessor
;
32
33
34
class
SubDetHitStatistics
{
35
public
:
36
43
class
OverflowControlledRef
{
44
unsigned
char
*
m_p
;
45
public
:
46
static
const
unsigned
int
OVERFLOW_VALUE
= 255;
47
49
OverflowControlledRef
(
unsigned
char
& c) :
m_p
(&c) {}
50
52
operator
unsigned
int ()
const
{
return
*
m_p
; }
53
unsigned
int
value
()
const
{
return
*
m_p
; }
54
56
OverflowControlledRef
operator=
(
unsigned
int
rhs) { *
m_p
= (rhs >
OVERFLOW_VALUE
) ?
OVERFLOW_VALUE
: rhs;
return
*
this
; }
57
59
OverflowControlledRef
operator++
() {
unsigned
int
tmp = 1 + *
m_p
; *
m_p
= (tmp >
OVERFLOW_VALUE
) ?
OVERFLOW_VALUE
: tmp;
return
*
this
; }
60
62
OverflowControlledRef
operator+=
(
unsigned
int
rhs) {
63
unsigned
int
tmp = *
m_p
+ rhs;
64
*
m_p
= ((tmp >
OVERFLOW_VALUE
)
65
||(tmp < rhs)
/*protection agains overflowing tmp */
66
) ?
OVERFLOW_VALUE
: tmp;
67
return
*
this
;
68
}
69
};
// end of class OverflowControlledRef
70
71
//----------------------------------------------------------------
72
// SubDetHitStatistics non-class members
73
74
enum
SubDetType
{
Pixel
=0,
SCT
,
TRT
,
MDT
,
RPC
,
TGC
,
CSC
,
MM
,
STGC
,
NUM_SUBDETECTORS
};
75
static
const
unsigned
int
OVERFLOW_VALUE
=
OverflowControlledRef::OVERFLOW_VALUE
;
76
77
SubDetHitStatistics
();
78
80
unsigned
int
operator[]
(
SubDetType
i)
const
{
return
m_numPRDs
[i]; }
81
83
OverflowControlledRef
operator[]
(
SubDetType
i) {
return
m_numPRDs
[i]; }
84
85
private
:
90
unsigned
char
m_numPRDs
[
NUM_SUBDETECTORS
];
91
92
friend
class
TrackTruthCollectionAccessor
;
// in TrackTruthTPCnv
93
94
public
:
95
};
96
97
template
<
class
Ostream> Ostream&
operator<<
(Ostream& os,
const
SubDetHitStatistics
& m) {
98
os<<
"SubDetStat("
;
99
for
(
unsigned
i=0; i<
SubDetHitStatistics::NUM_SUBDETECTORS
; i++) {
100
os<<unsigned(m[
SubDetHitStatistics::SubDetType
(i)]);
101
if
(i!=
SubDetHitStatistics::NUM_SUBDETECTORS
) os<<
","
;
102
}
103
return
os<<
")"
;
104
}
105
106
// That method would be the *only* one in a .so file.
107
// So inline it and get rid of the library.
108
// Also note that memset()-ing 7 bytes can be inlined by gcc.
109
#include <cstring>
110
inline
SubDetHitStatistics::SubDetHitStatistics
() {
111
memset(
m_numPRDs
, 0,
NUM_SUBDETECTORS
);
112
}
113
114
CLASS_DEF
(
SubDetHitStatistics
, 73400190, 1)
115
116
#endif
/*SUBDETHITSTATISTICS_H*/
CLASS_DEF.h
macros to associate a CLID to a type
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition
Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:67
operator<<
Ostream & operator<<(Ostream &os, const SubDetHitStatistics &m)
Definition
SubDetHitStatistics.h:97
SubDetHitStatistics::OverflowControlledRef
A simple class to retrofit overflow protection into the existing code.
Definition
SubDetHitStatistics.h:43
SubDetHitStatistics::OverflowControlledRef::operator++
OverflowControlledRef operator++()
protected (prefix) increment
Definition
SubDetHitStatistics.h:59
SubDetHitStatistics::OverflowControlledRef::operator=
OverflowControlledRef operator=(unsigned int rhs)
protected assignment
Definition
SubDetHitStatistics.h:56
SubDetHitStatistics::OverflowControlledRef::OverflowControlledRef
OverflowControlledRef(unsigned char &c)
constructor from a ref to the storage we control
Definition
SubDetHitStatistics.h:49
SubDetHitStatistics::OverflowControlledRef::OVERFLOW_VALUE
static const unsigned int OVERFLOW_VALUE
Definition
SubDetHitStatistics.h:46
SubDetHitStatistics::OverflowControlledRef::m_p
unsigned char * m_p
Definition
SubDetHitStatistics.h:44
SubDetHitStatistics::OverflowControlledRef::value
unsigned int value() const
Definition
SubDetHitStatistics.h:53
SubDetHitStatistics::OverflowControlledRef::operator+=
OverflowControlledRef operator+=(unsigned int rhs)
protected add-to
Definition
SubDetHitStatistics.h:62
SubDetHitStatistics
Definition
SubDetHitStatistics.h:34
SubDetHitStatistics::operator[]
OverflowControlledRef operator[](SubDetType i)
Write access protected agains overflows.
Definition
SubDetHitStatistics.h:83
SubDetHitStatistics::m_numPRDs
unsigned char m_numPRDs[NUM_SUBDETECTORS]
For InDet, the largest typical number of measurements per track is 36 in the TRT.
Definition
SubDetHitStatistics.h:90
SubDetHitStatistics::operator[]
unsigned int operator[](SubDetType i) const
Counts of up to (OVERFLOW_VALUE-1) hits.
Definition
SubDetHitStatistics.h:80
SubDetHitStatistics::SubDetType
SubDetType
Definition
SubDetHitStatistics.h:74
SubDetHitStatistics::RPC
@ RPC
Definition
SubDetHitStatistics.h:74
SubDetHitStatistics::MDT
@ MDT
Definition
SubDetHitStatistics.h:74
SubDetHitStatistics::MM
@ MM
Definition
SubDetHitStatistics.h:74
SubDetHitStatistics::NUM_SUBDETECTORS
@ NUM_SUBDETECTORS
Definition
SubDetHitStatistics.h:74
SubDetHitStatistics::STGC
@ STGC
Definition
SubDetHitStatistics.h:74
SubDetHitStatistics::CSC
@ CSC
Definition
SubDetHitStatistics.h:74
SubDetHitStatistics::TrackTruthCollectionAccessor
friend class TrackTruthCollectionAccessor
Definition
SubDetHitStatistics.h:92
SubDetHitStatistics::OVERFLOW_VALUE
static const unsigned int OVERFLOW_VALUE
Definition
SubDetHitStatistics.h:75
SubDetHitStatistics::SubDetHitStatistics
SubDetHitStatistics()
Definition
SubDetHitStatistics.h:110
TrackTruthCollectionAccessor
Definition
TrackTruthCollectionAccessor.h:16
Pixel
Definition
PixelFEUtils.h:17
SCT
Definition
SCT_ChipUtils.h:14
TGC
Definition
TgcBase.h:6
TRT
Definition
HitInfo.h:33
Generated on
for ATLAS Offline Software by
1.17.0