ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::detail::HitSummaryData Class Reference

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

#include <HitSummaryDataUtils.h>

Collaboration diagram for ActsTrk::detail::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 , SharedHit = 4 }

Public Member Functions

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

Static Public Member Functions

static constexpr 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.
static constexpr DetectorRegion regionFromKey (unsigned short key)
 extract the region index from the given key.
static constexpr uint8_t layerFromKey (unsigned short key)
 extract the layer index from the given key.

Static Public Attributes

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

Private Attributes

std::vector< std::tuple< unsigned short, uint8_t, 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_sharedHits
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.

◆ EHitSelection

Member Function Documentation

◆ addHit()

bool ActsTrk::detail::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 bit mask for Hit, Outlier, SharedHit.
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 119 of file HitSummaryDataUtils.h.

119 {
120 if (!detector_elements || id_hash>=detector_elements->size() || !(*detector_elements)[id_hash]) {
121 return false;
122 }
123 const InDetDD::SiDetectorElement *detEl=(*detector_elements)[id_hash];
124 DetectorRegion region = unknown;
125 uint8_t layer = 255;
126 int eta_module = 0;
127 if (detEl->isPixel()) {
130 else if(type==InDetDD::PixelBarrel) region = pixelBarrelFlat;
131 else region = pixelEndcap;
132
133 const PixelID* pixel_id = static_cast<const PixelID *>(detEl->getIdHelper());
134 layer = pixel_id->layer_disk(detEl->identify());
135 eta_module = pixel_id->eta_module(detEl->identify());
136 }
137 else if (detEl->isSCT()) {
138 region = (detEl->isBarrel() ? stripBarrel : stripEndcap);
139
140 const SCT_ID* sct_id = static_cast<const SCT_ID *>(detEl->getIdHelper());
141 layer = sct_id->layer_disk(detEl->identify());
142 eta_module = sct_id->eta_module(detEl->identify());
143 }
144
145 unsigned short key = makeKey(region, layer, eta_module);
146 for (auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits] : m_stat) {
147 if (stat_key == key) {
148 stat_hits += ((hit_selection & HitSummaryData::Hit)!=0);
149 stat_outlier_hits += ((hit_selection & HitSummaryData::Outlier)!=0);
150 stat_shared_hits += ((hit_selection & HitSummaryData::SharedHit)!=0);
151 return true;
152 }
153 }
154 m_stat.emplace_back( std::make_tuple(key,
155 ((hit_selection & HitSummaryData::Hit)!=0),
156 ((hit_selection & HitSummaryData::Outlier)!=0),
157 ((hit_selection & HitSummaryData::SharedHit)!=0)) );
158 return true;
159 }
DetectorRegion
Regions for which hit counts are computed.
static constexpr 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.
std::vector< std::tuple< unsigned short, uint8_t, uint8_t, uint8_t > > m_stat
size_type size() const noexcept
Returns the number of elements in the collection.
virtual DetectorType type() const
Type of element.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
virtual Identifier identify() const override final
identifier of this detector element (inline)
const AtlasDetectorID * getIdHelper() const
Returns the id helper (inline)
int layer_disk(const Identifier &id) const
Definition PixelID.h:607
int eta_module(const Identifier &id) const
Definition PixelID.h:632
int layer_disk(const Identifier &id) const
Definition SCT_ID.h:687
int eta_module(const Identifier &id) const
Definition SCT_ID.h:699
@ layer
Definition HitInfo.h:79

◆ computeSummaries()

void ActsTrk::detail::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 164 of file HitSummaryDataUtils.h.

164 {
165 for (const auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits] : m_stat) {
166 unsigned short region=regionFromKey(stat_key);
167 m_hits.at(region) += stat_hits;
168 m_outlierHits.at(region) += stat_outlier_hits;
169 m_sharedHits.at(region) += stat_shared_hits;
170 ++m_layers.at(region);
171 }
172 for (unsigned int region_i=0; region_i<unknown+1; ++region_i) {
173 m_hits.at(s_type.at(region_i)) += m_hits[region_i];
174 m_outlierHits.at(s_type.at(region_i)) += m_outlierHits[region_i];
175 m_sharedHits.at(s_type.at(region_i)) += m_sharedHits[region_i];
176 m_layers.at(s_type.at(region_i)) += m_layers[region_i];
177 m_hits.at(Total) += m_hits[region_i];
178 m_outlierHits.at(Total) += m_outlierHits[region_i];
179 m_sharedHits.at(Total) += m_sharedHits[region_i];
180 m_layers.at(Total) += m_layers[region_i];
181 }
182 }
std::array< uint8_t, Total+1 > m_layers
static constexpr DetectorRegion regionFromKey(unsigned short key)
extract the region index from the given key.
static constexpr std::array< uint8_t, unknown+1 > s_type
std::array< uint8_t, Total+1 > m_hits
std::array< uint8_t, Total+1 > m_outlierHits
std::array< uint8_t, Total+1 > m_sharedHits

◆ contributingHits()

uint8_t ActsTrk::detail::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 196 of file HitSummaryDataUtils.h.

196 {
197 return m_hits.at(region);
198 }

◆ contributingLayers()

uint8_t ActsTrk::detail::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 188 of file HitSummaryDataUtils.h.

188 {
189 return m_layers.at(region);
190 }

◆ contributingOutlierHits()

uint8_t ActsTrk::detail::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 204 of file HitSummaryDataUtils.h.

204 {
205 return m_outlierHits.at(region);
206 }

◆ contributingSharedHits()

uint8_t ActsTrk::detail::HitSummaryData::contributingSharedHits ( DetectorRegion region) const
inline

return the number of shared hits in a certain detector region.

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

Definition at line 212 of file HitSummaryDataUtils.h.

212 {
213 return m_sharedHits.at(region);
214 }

◆ layerFromKey()

constexpr uint8_t ActsTrk::detail::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 }
static constexpr unsigned short REGION_BITS
static constexpr unsigned short LAYER_MASK

◆ makeKey()

constexpr unsigned short ActsTrk::detail::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 }
static constexpr unsigned short LAYER_BITS
static constexpr unsigned short SIGNED_ETA_MOD_MASK
static constexpr unsigned short SIGNED_ETA_MOD_BITS

◆ regionFromKey()

constexpr DetectorRegion ActsTrk::detail::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 }
static constexpr unsigned short REGION_MASK

◆ reset()

void ActsTrk::detail::HitSummaryData::reset ( )
inline

reset all summary counters to zero.

Definition at line 104 of file HitSummaryDataUtils.h.

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

◆ sum()

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

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

Parameters
regionthe detector region.
layerthe detector layer.

Definition at line 222 of file HitSummaryDataUtils.h.

222 {
223 uint8_t total=0u;
224 unsigned short key = makeKey(region, layer, 0);
225 for (const auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits] : m_stat) {
226 if ((stat_key & LAYER_REGION_MASK) == key) {
227 if constexpr(HIT_SELECTION & HitSummaryData::Hit) {
228 total += stat_hits;
229 }
230 if constexpr(HIT_SELECTION & HitSummaryData::Outlier) {
231 total += stat_outlier_hits;
232 }
233 if constexpr(HIT_SELECTION & HitSummaryData::SharedHit) {
234 total += stat_shared_hits;
235 }
236 }
237 }
238 return total;
239 }
static constexpr unsigned short LAYER_REGION_MASK
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

Member Data Documentation

◆ LAYER_BITS

unsigned short ActsTrk::detail::HitSummaryData::LAYER_BITS = 6
staticconstexpr

Definition at line 58 of file HitSummaryDataUtils.h.

◆ LAYER_MASK

unsigned short ActsTrk::detail::HitSummaryData::LAYER_MASK = 0x3F
staticconstexpr

Definition at line 59 of file HitSummaryDataUtils.h.

◆ LAYER_REGION_MASK

unsigned short ActsTrk::detail::HitSummaryData::LAYER_REGION_MASK = 0x1FF
staticconstexpr

Definition at line 55 of file HitSummaryDataUtils.h.

◆ m_hits

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

Definition at line 243 of file HitSummaryDataUtils.h.

◆ m_layers

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

Definition at line 246 of file HitSummaryDataUtils.h.

◆ m_outlierHits

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

Definition at line 244 of file HitSummaryDataUtils.h.

◆ m_sharedHits

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

Definition at line 245 of file HitSummaryDataUtils.h.

◆ m_stat

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

Definition at line 242 of file HitSummaryDataUtils.h.

◆ REGION_BITS

unsigned short ActsTrk::detail::HitSummaryData::REGION_BITS = 3
staticconstexpr

Definition at line 56 of file HitSummaryDataUtils.h.

◆ REGION_MASK

unsigned short ActsTrk::detail::HitSummaryData::REGION_MASK = 0x7
staticconstexpr

Definition at line 57 of file HitSummaryDataUtils.h.

◆ s_type

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

◆ SIGNED_ETA_MOD_BITS

unsigned short ActsTrk::detail::HitSummaryData::SIGNED_ETA_MOD_BITS = 7
staticconstexpr

Definition at line 60 of file HitSummaryDataUtils.h.

◆ SIGNED_ETA_MOD_MASK

unsigned short ActsTrk::detail::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: