ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes | List of all members
ActsTrk::HitSummaryData Class Reference

Helper class to gather hit summary information for e.g. More...

#include <HitSummaryDataUtils.h>

Collaboration diagram for ActsTrk::HitSummaryData:

Public Types

enum  DetectorRegion {
  pixelBarrelFlat = 0, pixelBarrelInclined = 1, pixelEndcap = 2, stripBarrel = 3,
  stripEndcap = 4, unknown = 5, pixelTotal = 6, stripTotal = 7,
  unknownTotal = 8, Total = 9
}
 Regions for which hit counts are computed. More...
 
enum  EHitSelection { Hit = 1, Outlier = 2, HitAndOutlier = 3 }
 

Public Member Functions

void reset ()
 reset all summary counters to zero. More...
 
bool addHit (const InDetDD::SiDetectorElementCollection *detector_elements, unsigned int id_hash, EHitSelection hit_selection)
 update summaries to take the given hit into account. More...
 
void computeSummaries ()
 Compute the varius summaries. More...
 
uint8_t contributingLayers (DetectorRegion region) const
 return the number of layers contributing to the hit collection in the given detector region. More...
 
uint8_t contributingHits (DetectorRegion region) const
 return the number of hits in a certain detector region. More...
 
uint8_t contributingOutlierHits (DetectorRegion region) const
 return the number of outliers in a certain detector region. More...
 
template<unsigned short HIT_SELECTION>
uint8_t sum (DetectorRegion region, uint8_t layer) const
 return the total number of hits, outliers or hits+outliers in the givrn detector region and layer. More...
 

Static Public Member Functions

constexpr static unsigned short makeKey (unsigned short region, unsigned short layer, int eta_mod)
 Compute a counter key for the given region, layer and module eta module index. More...
 
constexpr static DetectorRegion regionFromKey (unsigned short key)
 extract the region index from the given key. More...
 
constexpr static uint8_t layerFromKey (unsigned short key)
 extract the layer index from the given key. More...
 

Static Public Attributes

constexpr static unsigned short LAYER_REGION_MASK = 0x1FF
 
constexpr static unsigned short REGION_BITS = 3
 
constexpr static unsigned short REGION_MASK = 0x7
 
constexpr static unsigned short LAYER_BITS = 6
 
constexpr static unsigned short LAYER_MASK = 0x3F
 
constexpr static unsigned short SIGNED_ETA_MOD_BITS = 7
 
constexpr static unsigned short SIGNED_ETA_MOD_MASK = 0x7F
 

Private Attributes

std::vector< std::tuple< unsigned short, uint8_t, uint8_t > > m_stat
 
std::array< uint8_t, Total+1 > m_hits
 
std::array< uint8_t, Total+1 > m_outlierHits
 
std::array< uint8_t, Total+1 > m_layers
 

Static Private Attributes

static constexpr std::array< uint8_t, unknown+1 > s_type { pixelTotal, pixelTotal, pixelTotal, stripTotal, stripTotal, unknownTotal}
 

Detailed Description

Helper class to gather hit summary information for e.g.

tracks.

Definition at line 38 of file HitSummaryDataUtils.h.

Member Enumeration Documentation

◆ DetectorRegion

Regions for which hit counts are computed.

Enumerator
pixelBarrelFlat 
pixelBarrelInclined 
pixelEndcap 
stripBarrel 
stripEndcap 
unknown 
pixelTotal 
stripTotal 
unknownTotal 
Total 

Definition at line 42 of file HitSummaryDataUtils.h.

42  {
43  pixelBarrelFlat = 0,
45  pixelEndcap = 2,
46  stripBarrel = 3,
47  stripEndcap = 4,
48  unknown = 5,
49  pixelTotal = 6,
50  stripTotal = 7,
51  unknownTotal = 8,
52  Total = 9
53  };

◆ EHitSelection

Enumerator
Hit 
Outlier 
HitAndOutlier 

Definition at line 95 of file HitSummaryDataUtils.h.

95  {
96  Hit = 1,
97  Outlier = 2,
98  HitAndOutlier = 3
99  };

Member Function Documentation

◆ addHit()

bool ActsTrk::HitSummaryData::addHit ( const InDetDD::SiDetectorElementCollection detector_elements,
unsigned int  id_hash,
EHitSelection  hit_selection 
)
inline

update summaries to take the given hit into account.

Parameters
detector_elementsdetector element collection relevant for the given hit.
id_hashthe id_hash of the hit
hit_selectionshould be set to either Hit, or Outlier.
returnsfalse in case the hit was not considered. The hit is not considered if the given id_hash is not valid for the given detector element collectio.

Definition at line 117 of file HitSummaryDataUtils.h.

117  {
118  if (!detector_elements || id_hash>=detector_elements->size() || !(*detector_elements)[id_hash]) {
119  return false;
120  }
121  const InDetDD::SiDetectorElement *detEl=(*detector_elements)[id_hash];
122  DetectorRegion region = unknown;
123  uint8_t layer = 255;
124  int eta_module = 0;
125  if (detEl->isPixel()) {
126  InDetDD::DetectorType type = detEl->design().type();
128  else if(type==InDetDD::PixelBarrel) region = pixelBarrelFlat;
129  else region = pixelEndcap;
130 
131  const PixelID* pixel_id = static_cast<const PixelID *>(detEl->getIdHelper());
132  layer = pixel_id->layer_disk(detEl->identify());
133  eta_module = pixel_id->eta_module(detEl->identify());
134  }
135  else if (detEl->isSCT()) {
136  region = (detEl->isBarrel() ? stripBarrel : stripEndcap);
137 
138  const SCT_ID* sct_id = static_cast<const SCT_ID *>(detEl->getIdHelper());
139  layer = sct_id->layer_disk(detEl->identify());
140  eta_module = sct_id->eta_module(detEl->identify());
141  }
142 
143  unsigned short key = makeKey(region, layer, eta_module);
144  for (auto &[stat_key, stat_hits, stat_outlier_hits] : m_stat) {
145  if (stat_key == key) {
146  stat_hits += ((hit_selection & HitSummaryData::Hit)!=0);
147  stat_outlier_hits += ((hit_selection & HitSummaryData::Outlier)!=0);
148  return true;
149  }
150  }
151  m_stat.emplace_back( std::make_tuple(key,
152  ((hit_selection & HitSummaryData::Hit)!=0),
153  ((hit_selection & HitSummaryData::Outlier)!=0)) );
154  return true;
155  }

◆ computeSummaries()

void ActsTrk::HitSummaryData::computeSummaries ( )
inline

Compute the varius summaries.

Must be called only after all hits have been gathered, and must not be called more than once.

Definition at line 160 of file HitSummaryDataUtils.h.

160  {
161  for (const auto &[stat_key, stat_hits, stat_outlier_hits] : m_stat) {
162  unsigned short region=regionFromKey(stat_key);
163  m_hits.at(region) += stat_hits;
164  m_outlierHits.at(region) += stat_outlier_hits;
165  ++m_layers.at(region);
166  }
167  for (unsigned int region_i=0; region_i<unknown+1; ++region_i) {
168  m_hits.at(s_type.at(region_i)) += m_hits[region_i];
169  m_outlierHits.at(s_type.at(region_i)) += m_outlierHits[region_i];
170  m_layers.at(s_type.at(region_i)) += m_layers[region_i];
171  m_hits.at(Total) += m_hits[region_i];
172  m_outlierHits.at(Total) += m_outlierHits[region_i];
173  m_layers.at(Total) += m_layers[region_i];
174  }
175  }

◆ contributingHits()

uint8_t ActsTrk::HitSummaryData::contributingHits ( DetectorRegion  region) const
inline

return the number of hits in a certain detector region.

Parameters
regionthe detector region. Only meaningful after computeSummaries was called.

Definition at line 189 of file HitSummaryDataUtils.h.

189  {
190  return m_hits.at(region);
191  }

◆ contributingLayers()

uint8_t ActsTrk::HitSummaryData::contributingLayers ( DetectorRegion  region) const
inline

return the number of layers contributing to the hit collection in the given detector region.

Parameters
regionthe detector region. Only meaningful after computeSummaries was called.

Definition at line 181 of file HitSummaryDataUtils.h.

181  {
182  return m_layers.at(region);
183  }

◆ contributingOutlierHits()

uint8_t ActsTrk::HitSummaryData::contributingOutlierHits ( DetectorRegion  region) const
inline

return the number of outliers in a certain detector region.

Parameters
regionthe detector region. Only meaningful after computeSummaries was called.

Definition at line 197 of file HitSummaryDataUtils.h.

197  {
198  return m_outlierHits.at(region);
199  }

◆ layerFromKey()

constexpr static uint8_t ActsTrk::HitSummaryData::layerFromKey ( unsigned short  key)
inlinestaticconstexpr

extract the layer index from the given key.

Definition at line 90 of file HitSummaryDataUtils.h.

90  {
91  return (key>>REGION_BITS) & LAYER_MASK; // bits 3-8
92  }

◆ makeKey()

constexpr static unsigned short ActsTrk::HitSummaryData::makeKey ( unsigned short  region,
unsigned short  layer,
int  eta_mod 
)
inlinestaticconstexpr

Compute a counter key for the given region, layer and module eta module index.

Parameters
regionthe detector region index (0..7).
layerthe layer index (0..63).
thesigned eta module index (-63..63).

Definition at line 68 of file HitSummaryDataUtils.h.

68  {
69  // 3 bits region : 0-7 : pixelBarrelFlat - unknown
70  // 6 bits layer : 0-63
71  // 1+6 bits eta_mod : +- 0-63
72  // @TODO endcap side A/C ?
73  assert(region < (1<<REGION_BITS) );
74  assert(layer < (1<<LAYER_BITS));
75  assert( std::abs(eta_mod) < (1<<(SIGNED_ETA_MOD_BITS-1)) );
76  if (region != stripBarrel && region != pixelBarrelFlat) {
77  layer |= (static_cast<uint8_t>(eta_mod) & SIGNED_ETA_MOD_MASK) << LAYER_BITS ;
78  }
79  return static_cast<uint8_t>(region) | (layer<<REGION_BITS);
80  }

◆ regionFromKey()

constexpr static DetectorRegion ActsTrk::HitSummaryData::regionFromKey ( unsigned short  key)
inlinestaticconstexpr

extract the region index from the given key.

Definition at line 84 of file HitSummaryDataUtils.h.

84  {
85  return static_cast<DetectorRegion>(key & REGION_MASK); // bits 0-2
86  }

◆ reset()

void ActsTrk::HitSummaryData::reset ( )
inline

reset all summary counters to zero.

Definition at line 103 of file HitSummaryDataUtils.h.

103  {
104  m_stat.clear();
105  std::fill(m_hits.begin(),m_hits.end(), 0u);
106  std::fill(m_outlierHits.begin(),m_outlierHits.end(), 0u);
107  std::fill(m_layers.begin(),m_layers.end(), 0u);
108  }

◆ sum()

template<unsigned short HIT_SELECTION>
uint8_t ActsTrk::HitSummaryData::sum ( DetectorRegion  region,
uint8_t  layer 
) const
inline

return the total number of hits, outliers or hits+outliers in the givrn detector region and layer.

Parameters
regionthe detector region.
layerthe detector layer.

Definition at line 207 of file HitSummaryDataUtils.h.

207  {
208  uint8_t total=0u;
209  unsigned short key = makeKey(region, layer, 0);
210  for (auto &[stat_key, stat_hits, stat_outlier_hits] : m_stat) {
211  if ((stat_key & LAYER_REGION_MASK) == key) {
212  if constexpr(HIT_SELECTION & HitSummaryData::Hit) {
213  total += stat_hits;
214  }
215  if constexpr(HIT_SELECTION & HitSummaryData::Outlier) {
216  total += stat_outlier_hits;
217  }
218  }
219  }
220  return total;
221  }

Member Data Documentation

◆ LAYER_BITS

constexpr static unsigned short ActsTrk::HitSummaryData::LAYER_BITS = 6
staticconstexpr

Definition at line 58 of file HitSummaryDataUtils.h.

◆ LAYER_MASK

constexpr static unsigned short ActsTrk::HitSummaryData::LAYER_MASK = 0x3F
staticconstexpr

Definition at line 59 of file HitSummaryDataUtils.h.

◆ LAYER_REGION_MASK

constexpr static unsigned short ActsTrk::HitSummaryData::LAYER_REGION_MASK = 0x1FF
staticconstexpr

Definition at line 55 of file HitSummaryDataUtils.h.

◆ m_hits

std::array<uint8_t, Total+1> ActsTrk::HitSummaryData::m_hits
private

Definition at line 225 of file HitSummaryDataUtils.h.

◆ m_layers

std::array<uint8_t, Total+1> ActsTrk::HitSummaryData::m_layers
private

Definition at line 227 of file HitSummaryDataUtils.h.

◆ m_outlierHits

std::array<uint8_t, Total+1> ActsTrk::HitSummaryData::m_outlierHits
private

Definition at line 226 of file HitSummaryDataUtils.h.

◆ m_stat

std::vector< std::tuple<unsigned short, uint8_t, uint8_t> > ActsTrk::HitSummaryData::m_stat
private

Definition at line 224 of file HitSummaryDataUtils.h.

◆ REGION_BITS

constexpr static unsigned short ActsTrk::HitSummaryData::REGION_BITS = 3
staticconstexpr

Definition at line 56 of file HitSummaryDataUtils.h.

◆ REGION_MASK

constexpr static unsigned short ActsTrk::HitSummaryData::REGION_MASK = 0x7
staticconstexpr

Definition at line 57 of file HitSummaryDataUtils.h.

◆ s_type

constexpr std::array<uint8_t, unknown+1> ActsTrk::HitSummaryData::s_type { pixelTotal, pixelTotal, pixelTotal, stripTotal, stripTotal, unknownTotal}
staticconstexprprivate

Definition at line 228 of file HitSummaryDataUtils.h.

◆ SIGNED_ETA_MOD_BITS

constexpr static unsigned short ActsTrk::HitSummaryData::SIGNED_ETA_MOD_BITS = 7
staticconstexpr

Definition at line 60 of file HitSummaryDataUtils.h.

◆ SIGNED_ETA_MOD_MASK

constexpr static unsigned short ActsTrk::HitSummaryData::SIGNED_ETA_MOD_MASK = 0x7F
staticconstexpr

Definition at line 61 of file HitSummaryDataUtils.h.


The documentation for this class was generated from the following file:
ActsTrk::HitSummaryData::LAYER_MASK
constexpr static unsigned short LAYER_MASK
Definition: HitSummaryDataUtils.h:59
ActsTrk::HitSummaryData::unknownTotal
@ unknownTotal
Definition: HitSummaryDataUtils.h:51
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
ActsTrk::HitSummaryData::LAYER_REGION_MASK
constexpr static unsigned short LAYER_REGION_MASK
Definition: HitSummaryDataUtils.h:55
ActsTrk::HitSummaryData::SIGNED_ETA_MOD_MASK
constexpr static unsigned short SIGNED_ETA_MOD_MASK
Definition: HitSummaryDataUtils.h:61
ActsTrk::HitSummaryData::Hit
@ Hit
Definition: HitSummaryDataUtils.h:96
ActsTrk::HitSummaryData::m_hits
std::array< uint8_t, Total+1 > m_hits
Definition: HitSummaryDataUtils.h:225
ActsTrk::HitSummaryData::stripEndcap
@ stripEndcap
Definition: HitSummaryDataUtils.h:47
ActsTrk::HitSummaryData::HitAndOutlier
@ HitAndOutlier
Definition: HitSummaryDataUtils.h:98
ActsTrk::HitSummaryData::pixelBarrelInclined
@ pixelBarrelInclined
Definition: HitSummaryDataUtils.h:44
ActsTrk::HitSummaryData::pixelTotal
@ pixelTotal
Definition: HitSummaryDataUtils.h:49
ActsTrk::HitSummaryData::unknown
@ unknown
Definition: HitSummaryDataUtils.h:48
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
InDetDD::SolidStateDetectorElementBase::getIdHelper
const AtlasDetectorID * getIdHelper() const
Returns the id helper (inline)
InDetDD::PixelInclined
@ PixelInclined
Definition: DetectorDesign.h:46
ActsTrk::HitSummaryData::stripTotal
@ stripTotal
Definition: HitSummaryDataUtils.h:50
Hit
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloGpu/ISF_FastCaloGpu/Hit.h:16
ActsTrk::HitSummaryData::REGION_MASK
constexpr static unsigned short REGION_MASK
Definition: HitSummaryDataUtils.h:57
InDetDD::DetectorType
DetectorType
Definition: DetectorDesign.h:45
ActsTrk::HitSummaryData::DetectorRegion
DetectorRegion
Regions for which hit counts are computed.
Definition: HitSummaryDataUtils.h:42
ActsTrk::HitSummaryData::SIGNED_ETA_MOD_BITS
constexpr static unsigned short SIGNED_ETA_MOD_BITS
Definition: HitSummaryDataUtils.h:60
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
InDetDD::DetectorDesign::type
virtual DetectorType type() const
Type of element.
Definition: DetectorDesign.cxx:101
ActsTrk::HitSummaryData::m_outlierHits
std::array< uint8_t, Total+1 > m_outlierHits
Definition: HitSummaryDataUtils.h:226
InDetDD::SiDetectorElement::isPixel
bool isPixel() const
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
ActsTrk::HitSummaryData::makeKey
constexpr static unsigned short makeKey(unsigned short region, unsigned short layer, int eta_mod)
Compute a counter key for the given region, layer and module eta module index.
Definition: HitSummaryDataUtils.h:68
InDetDD::PixelBarrel
@ PixelBarrel
Definition: DetectorDesign.h:46
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDetDD::SiDetectorElement::isBarrel
bool isBarrel() const
ActsTrk::HitSummaryData::pixelEndcap
@ pixelEndcap
Definition: HitSummaryDataUtils.h:45
ActsTrk::HitSummaryData::stripBarrel
@ stripBarrel
Definition: HitSummaryDataUtils.h:46
ActsTrk::HitSummaryData::m_layers
std::array< uint8_t, Total+1 > m_layers
Definition: HitSummaryDataUtils.h:227
SCT_ID
Definition: SCT_ID.h:68
lumiFormat.fill
fill
Definition: lumiFormat.py:111
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
ActsTrk::HitSummaryData::pixelBarrelFlat
@ pixelBarrelFlat
Definition: HitSummaryDataUtils.h:43
ActsTrk::HitSummaryData::s_type
static constexpr std::array< uint8_t, unknown+1 > s_type
Definition: HitSummaryDataUtils.h:229
InDetDD::SiDetectorElement::isSCT
bool isSCT() const
ActsTrk::HitSummaryData::Outlier
@ Outlier
Definition: HitSummaryDataUtils.h:97
ActsTrk::HitSummaryData::REGION_BITS
constexpr static unsigned short REGION_BITS
Definition: HitSummaryDataUtils.h:56
ActsTrk::HitSummaryData::Total
@ Total
Definition: HitSummaryDataUtils.h:52
InDetDD::SiDetectorElement::design
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
PixelID
Definition: PixelID.h:67
ActsTrk::HitSummaryData::regionFromKey
constexpr static DetectorRegion regionFromKey(unsigned short key)
extract the region index from the given key.
Definition: HitSummaryDataUtils.h:84
InDetDD::SolidStateDetectorElementBase::identify
virtual Identifier identify() const override final
identifier of this detector element (inline)
ActsTrk::HitSummaryData::LAYER_BITS
constexpr static unsigned short LAYER_BITS
Definition: HitSummaryDataUtils.h:58
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
ActsTrk::HitSummaryData::m_stat
std::vector< std::tuple< unsigned short, uint8_t, uint8_t > > m_stat
Definition: HitSummaryDataUtils.h:224