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 , pixelBarrel = 6 , pixelTotal = 7 ,
  stripTotal = 8 , hgtdTotal = 9 , unknownTotal = 10 , Total = 11
}
 Regions for which hit counts are computed. More...
enum class  CountType {
  Hit , Outlier , SharedHit , SplitHit ,
  NCountTypes
}
enum  EHitSelection {
  HitFlag = 1 , OutlierFlag = 2 , HitAndOutlierFlag = 3 , SharedHitFlag = 4 ,
  SplitHitFlag = 8
}

Public Member Functions

void reset ()
 reset all summary counters to zero.
bool addHit (xAOD::UncalibMeasType det_type, const InDetDD::SolidStateDetectorElementBase *detEl, 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, CountType hit_type=CountType::Hit) 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, shared hits and/or split hits in the given detector region and layer.
std::array< uint8_t, 4 > sumPerCountType (DetectorRegion region, uint8_t layer) const
 return the total number of hits, outliers, shared hits and split hits in the given detector region and layer.
unsigned int layerPattern (DetectorRegion region, bool include_outlier) const
 Get a bit pattern with one bit set per layer which is set if the layer has a hit or optionally an outlier.

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 unsigned short makeKey (unsigned short region)
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 = 0xFF
static constexpr unsigned short REGION_BITS = 4
static constexpr unsigned short REGION_MASK = 0xF
static constexpr unsigned short LAYER_BITS = 4
static constexpr unsigned short LAYER_MASK = 0xF
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, uint8_t > > m_stat
std::array< std::array< uint8_t, Total+1 >, static_cast< unsigned int >(CountType::NCountTypes)> m_hits {}
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 28 of file HitSummaryDataUtils.h.

Member Enumeration Documentation

◆ CountType

Enumerator
Hit 
Outlier 
SharedHit 
SplitHit 
NCountTypes 

Definition at line 47 of file HitSummaryDataUtils.h.

47 {
48 Hit,
49 Outlier,
50 SharedHit,
51 SplitHit,
52 NCountTypes
53 };

◆ DetectorRegion

Regions for which hit counts are computed.

Enumerator
pixelBarrelFlat 
pixelBarrelInclined 
pixelEndcap 
stripBarrel 
stripEndcap 
unknown 
pixelBarrel 
pixelTotal 
stripTotal 
hgtdTotal 
unknownTotal 
Total 

Definition at line 32 of file HitSummaryDataUtils.h.

◆ EHitSelection

Member Function Documentation

◆ addHit()

bool ActsTrk::detail::HitSummaryData::addHit ( xAOD::UncalibMeasType det_type,
const InDetDD::SolidStateDetectorElementBase * detEl,
EHitSelection hit_selection )
inline

update summaries to take the given hit into account.

Parameters
det_type.
detector_elementsdetector element collection relevant for the given hit.
hit_selectionshould be set to bit mask for Hit, Outlier, SharedHit.
Returns
returns false 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 124 of file HitSummaryDataUtils.h.

126 {
127 DetectorRegion region = unknown;
128 uint8_t layer = 255;
129 int eta_module = 0;
130 Identifier id(detEl ? detEl->identify() : Identifier() );
131 switch (det_type) {
133 if (!detEl) { return false; }
134 assert(detEl ->getIdHelper()->is_pixel(id));
137 else if(type==InDetDD::PixelBarrel) region = pixelBarrelFlat;
138 else region = pixelEndcap;
139
140 const PixelID* pixel_id = static_cast<const PixelID *>(detEl->getIdHelper());
141 layer = pixel_id->layer_disk(detEl->identify());
142 eta_module = pixel_id->eta_module(detEl->identify());
143 break;
144 }
146 if (!detEl) { return false; }
147 assert(detEl ->getIdHelper()->is_sct(id));
148 const SCT_ID* sct_id = static_cast<const SCT_ID *>(detEl->getIdHelper());
149 region = (sct_id->barrel_ec(id)==0 ? stripBarrel : stripEndcap);
150
151 layer = sct_id->layer_disk(detEl->identify());
152 eta_module = sct_id->eta_module(detEl->identify());
153 break;
154 }
156 if (!detEl) { return false; }
157 assert(detEl ->getIdHelper()->is_hgtd(id));
158 const HGTD_ID* hgtd_id = static_cast<const HGTD_ID *>(detEl->getIdHelper());
159 region=hgtdTotal;
160 layer=hgtd_id->layer(id);
161 break;
162 }
163 default: {
164 return false;
165 }
166 }
167
168 unsigned short key = makeKey(region, layer, eta_module);
169 for (auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits, stat_split_hits] : m_stat) {
170 if (stat_key == key) {
171 stat_hits += ((hit_selection & HitSummaryData::HitFlag)!=0);
172 stat_outlier_hits += ((hit_selection & HitSummaryData::OutlierFlag)!=0);
173 stat_shared_hits += ((hit_selection & HitSummaryData::SharedHitFlag)!=0);
174 stat_split_hits += ((hit_selection & HitSummaryData::SplitHitFlag)!=0);
175 return true;
176 }
177 }
178 m_stat.emplace_back( std::make_tuple(key,
179 ((hit_selection & HitSummaryData::HitFlag)!=0),
180 ((hit_selection & HitSummaryData::OutlierFlag)!=0),
181 ((hit_selection & HitSummaryData::SharedHitFlag)!=0),
182 ((hit_selection & HitSummaryData::SplitHitFlag)!=0) ));
183 return true;
184 }
std::vector< std::tuple< unsigned short, uint8_t, uint8_t, uint8_t, uint8_t > > m_stat
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.
int layer(const Identifier &id) const
Definition HGTD_ID.h:477
virtual DetectorType type() const
Type of element.
virtual const DetectorDesign & design() const
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:602
int eta_module(const Identifier &id) const
Definition PixelID.h:627
int layer_disk(const Identifier &id) const
Definition SCT_ID.h:687
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0).
Definition SCT_ID.h:681
int eta_module(const Identifier &id) const
Definition SCT_ID.h:699
const T * getIdHelper(StoreGateSvc *pDetStore, const std::string &helperName)
@ 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 189 of file HitSummaryDataUtils.h.

189 {
190 for (const auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits, stat_split_hits] : m_stat) {
191 unsigned short region=regionFromKey(stat_key);
192 m_hits[static_cast<unsigned int>(CountType::Hit)].at(region) += stat_hits;
193 m_hits[static_cast<unsigned int>(CountType::Outlier)].at(region) += stat_outlier_hits;
194 m_hits[static_cast<unsigned int>(CountType::SharedHit)].at(region) += stat_shared_hits;
195 m_hits[static_cast<unsigned int>(CountType::SplitHit)].at(region) += stat_split_hits;
196 ++m_layers.at(region);
197 }
198 for (unsigned int region_i=0; region_i<unknown+1; ++region_i) {
199 for (unsigned int count_type_i=0; count_type_i<static_cast<unsigned int>(CountType::NCountTypes);++count_type_i) {
200 m_hits[count_type_i].at(s_type.at(region_i)) += m_hits[count_type_i][region_i];
201 m_hits[count_type_i].at(Total) += m_hits[count_type_i][region_i];
202 }
203 m_layers.at(s_type.at(region_i)) += m_layers[region_i];
204 m_layers.at(Total) += m_layers[region_i];
205 }
207 for (unsigned int count_type_i=0; count_type_i<static_cast<unsigned int>(CountType::NCountTypes);++count_type_i) {
208 assert( pixelBarrelFlat < m_hits[count_type_i].size() && pixelBarrelInclined < m_hits[count_type_i].size());
209 m_hits[count_type_i].at(pixelBarrel) = m_hits[count_type_i][pixelBarrelFlat]+m_hits[count_type_i][pixelBarrelInclined];
210 }
211 }
size_t size() const
Number of registered mappings.
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< std::array< uint8_t, Total+1 >, static_cast< unsigned int >(CountType::NCountTypes)> m_hits
mapped_type at(key_type key) const
Look up an element in the map.

◆ contributingHits()

uint8_t ActsTrk::detail::HitSummaryData::contributingHits ( DetectorRegion region,
CountType hit_type = CountType::Hit ) 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 225 of file HitSummaryDataUtils.h.

225 {
226 assert( static_cast<unsigned int>(hit_type) < static_cast<unsigned int>(CountType::NCountTypes));
227 return m_hits[static_cast<unsigned int>(hit_type)].at(region);
228 }

◆ 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 217 of file HitSummaryDataUtils.h.

217 {
218 return m_layers.at(region);
219 }

◆ 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 234 of file HitSummaryDataUtils.h.

234 {
235 return contributingHits(region, CountType::Outlier);
236 }
uint8_t contributingHits(DetectorRegion region, CountType hit_type=CountType::Hit) const
return the number of hits in a certain detector region.

◆ 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 242 of file HitSummaryDataUtils.h.

242 {
244 }

◆ layerFromKey()

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

extract the layer index from the given key.

Definition at line 94 of file HitSummaryDataUtils.h.

94 {
95 return (key>>REGION_BITS) & LAYER_MASK; // bits 3-8
96 }
static constexpr unsigned short REGION_BITS
static constexpr unsigned short LAYER_MASK

◆ layerPattern()

unsigned int ActsTrk::detail::HitSummaryData::layerPattern ( DetectorRegion region,
bool include_outlier ) const
inline

Get a bit pattern with one bit set per layer which is set if the layer has a hit or optionally an outlier.

Parameters
regionselector
include_outlierif true also set the corresponding bit if the layer contains an outlier only.
Returns
a bit pattern, where each bit corresponds to one detector and the bit is set if the layer contains a hit (or outlier).

Definition at line 296 of file HitSummaryDataUtils.h.

296 {
297 unsigned int layer_pattern=0u;
298 unsigned short key = makeKey(region);
299 std::array<uint8_t,2> stat_mask{ 0xff, static_cast<uint8_t>(include_outlier ? 0xff : 0) };
300 for (const auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits, stat_split_hits] : m_stat) {
301 if ((stat_key & REGION_MASK) == key) {
302 if ((stat_hits & stat_mask[0])+(stat_outlier_hits & stat_mask[1]) >0u) {
303 layer_pattern |= 1u<<layerFromKey(stat_key);
304 }
305 }
306 }
307 return layer_pattern;
308 }
static constexpr unsigned short REGION_MASK
static constexpr uint8_t layerFromKey(unsigned short key)
extract the layer index from the given key.
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ makeKey() [1/2]

constexpr unsigned short ActsTrk::detail::HitSummaryData::makeKey ( unsigned short region)
inlinestaticconstexpr

Definition at line 81 of file HitSummaryDataUtils.h.

81 {
82 assert(region < (1<<REGION_BITS) );
83 return static_cast<uint8_t>(region);
84 }

◆ makeKey() [2/2]

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..9).
layerthe layer index (0..15).
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 88 of file HitSummaryDataUtils.h.

88 {
89 return static_cast<DetectorRegion>(key & REGION_MASK); // bits 0-2
90 }

◆ reset()

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

reset all summary counters to zero.

Definition at line 109 of file HitSummaryDataUtils.h.

109 {
110 m_stat.clear();
111 for(unsigned int i=0;i<static_cast<unsigned int>(CountType::NCountTypes); ++i) {
112 std::fill(m_hits[i].begin(),m_hits[i].end(), 0u);
113 }
114 std::fill(m_layers.begin(),m_layers.end(), 0u);
115 }

◆ 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, shared hits and/or split hits in the given detector region and layer.

Parameters
regionthe detector region.
layerthe detector layer.

Definition at line 252 of file HitSummaryDataUtils.h.

252 {
253 uint8_t total=0u;
254 unsigned short key = makeKey(region, layer, 0);
255 for (const auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits, stat_split_hits] : m_stat) {
256 if ((stat_key & LAYER_REGION_MASK) == key) {
257 if constexpr(HIT_SELECTION & HitSummaryData::HitFlag) {
258 total += stat_hits;
259 }
260 if constexpr(HIT_SELECTION & HitSummaryData::OutlierFlag) {
261 total += stat_outlier_hits;
262 }
263 if constexpr(HIT_SELECTION & HitSummaryData::SharedHitFlag) {
264 total += stat_shared_hits;
265 }
266 if constexpr(HIT_SELECTION & HitSummaryData::SplitHitFlag) {
267 total += stat_split_hits;
268 }
269 }
270 }
271 return total;
272 }
static constexpr unsigned short LAYER_REGION_MASK

◆ sumPerCountType()

std::array< uint8_t, 4 > ActsTrk::detail::HitSummaryData::sumPerCountType ( DetectorRegion region,
uint8_t layer ) const
inline

return the total number of hits, outliers, shared hits and split hits in the given detector region and layer.

Parameters
regionthe detector region.
layerthe detector layer.

Definition at line 277 of file HitSummaryDataUtils.h.

277 {
278 std::array<uint8_t,4> total{};
279 unsigned short key = makeKey(region, layer, 0);
280 for (const auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits, stat_split_hits] : m_stat) {
281 if ((stat_key & LAYER_REGION_MASK) == key) {
282 total[static_cast<unsigned int>(CountType::Hit)] += stat_hits;
283 total[static_cast<unsigned int>(CountType::Outlier)] += stat_outlier_hits;
284 total[static_cast<unsigned int>(CountType::SharedHit)] += stat_shared_hits;
285 total[static_cast<unsigned int>(CountType::SplitHit)] += stat_split_hits;
286 }
287 }
288 return total;
289 }

Member Data Documentation

◆ LAYER_BITS

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

Definition at line 58 of file HitSummaryDataUtils.h.

◆ LAYER_MASK

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

Definition at line 59 of file HitSummaryDataUtils.h.

◆ LAYER_REGION_MASK

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

Definition at line 55 of file HitSummaryDataUtils.h.

◆ m_hits

std::array<std::array<uint8_t, Total+1>,static_cast<unsigned int>(CountType::NCountTypes)> ActsTrk::detail::HitSummaryData::m_hits {}
private

Definition at line 312 of file HitSummaryDataUtils.h.

312{};

◆ m_layers

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

Definition at line 313 of file HitSummaryDataUtils.h.

313{};

◆ m_stat

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

Definition at line 311 of file HitSummaryDataUtils.h.

◆ REGION_BITS

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

Definition at line 56 of file HitSummaryDataUtils.h.

◆ REGION_MASK

unsigned short ActsTrk::detail::HitSummaryData::REGION_MASK = 0xF
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: