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 , NCountTypes }
enum  EHitSelection { Hit = 1 , Outlier = 2 , HitAndOutlier = 3 , SharedHit = 4 }

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, and/or shared hits in the givrn detector region and layer.
unsigned int layerPattern (DetectorRegion region, bool include_outlier) const

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 > > 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 
NCountTypes 

Definition at line 47 of file HitSummaryDataUtils.h.

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

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

124 {
125 DetectorRegion region = unknown;
126 uint8_t layer = 255;
127 int eta_module = 0;
128 Identifier id(detEl ? detEl->identify() : Identifier() );
129 switch (det_type) {
131 if (!detEl) { return false; }
132 assert(detEl ->getIdHelper()->is_pixel(id));
135 else if(type==InDetDD::PixelBarrel) region = pixelBarrelFlat;
136 else region = pixelEndcap;
137
138 const PixelID* pixel_id = static_cast<const PixelID *>(detEl->getIdHelper());
139 layer = pixel_id->layer_disk(detEl->identify());
140 eta_module = pixel_id->eta_module(detEl->identify());
141 break;
142 }
144 if (!detEl) { return false; }
145 assert(detEl ->getIdHelper()->is_sct(id));
146 const SCT_ID* sct_id = static_cast<const SCT_ID *>(detEl->getIdHelper());
147 region = (sct_id->barrel_ec(id)==0 ? stripBarrel : stripEndcap);
148
149 layer = sct_id->layer_disk(detEl->identify());
150 eta_module = sct_id->eta_module(detEl->identify());
151 break;
152 }
154 if (!detEl) { return false; }
155 assert(detEl ->getIdHelper()->is_hgtd(id));
156 const HGTD_ID* hgtd_id = static_cast<const HGTD_ID *>(detEl->getIdHelper());
157 region=hgtdTotal;
158 layer=hgtd_id->layer(id);
159 break;
160 }
161 default: {
162 return false;
163 }
164 }
165
166 unsigned short key = makeKey(region, layer, eta_module);
167 for (auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits] : m_stat) {
168 if (stat_key == key) {
169 stat_hits += ((hit_selection & HitSummaryData::Hit)!=0);
170 stat_outlier_hits += ((hit_selection & HitSummaryData::Outlier)!=0);
171 stat_shared_hits += ((hit_selection & HitSummaryData::SharedHit)!=0);
172 return true;
173 }
174 }
175 m_stat.emplace_back( std::make_tuple(key,
176 ((hit_selection & HitSummaryData::Hit)!=0),
177 ((hit_selection & HitSummaryData::Outlier)!=0),
178 ((hit_selection & HitSummaryData::SharedHit)!=0)) );
179 return true;
180 }
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
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 185 of file HitSummaryDataUtils.h.

185 {
186 for (const auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits] : m_stat) {
187 unsigned short region=regionFromKey(stat_key);
188 m_hits[static_cast<unsigned int>(CountType::Hit)].at(region) += stat_hits;
189 m_hits[static_cast<unsigned int>(CountType::Outlier)].at(region) += stat_outlier_hits;
190 m_hits[static_cast<unsigned int>(CountType::SharedHit)].at(region) += stat_shared_hits;
191 ++m_layers.at(region);
192 }
193 for (unsigned int region_i=0; region_i<unknown+1; ++region_i) {
194 for (unsigned int count_type_i=0; count_type_i<static_cast<unsigned int>(CountType::NCountTypes);++count_type_i) {
195 m_hits[count_type_i].at(s_type.at(region_i)) += m_hits[count_type_i][region_i];
196 m_hits[count_type_i].at(Total) += m_hits[count_type_i][region_i];
197 }
198 m_layers.at(s_type.at(region_i)) += m_layers[region_i];
199 m_layers.at(Total) += m_layers[region_i];
200 }
202 for (unsigned int count_type_i=0; count_type_i<static_cast<unsigned int>(CountType::NCountTypes);++count_type_i) {
203 assert( pixelBarrelFlat < m_hits[count_type_i].size() && pixelBarrelInclined < m_hits[count_type_i].size());
204 m_hits[count_type_i].at(pixelBarrel) = m_hits[count_type_i][pixelBarrelFlat]+m_hits[count_type_i][pixelBarrelInclined];
205 }
206 }
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 220 of file HitSummaryDataUtils.h.

220 {
221 assert( static_cast<unsigned int>(hit_type) < static_cast<unsigned int>(CountType::NCountTypes));
222 return m_hits[static_cast<unsigned int>(hit_type)].at(region);
223 }

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

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

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

229 {
230 return contributingHits(region, CountType::Outlier);
231 }
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 237 of file HitSummaryDataUtils.h.

237 {
239 }

◆ layerFromKey()

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

extract the layer index from the given key.

Definition at line 93 of file HitSummaryDataUtils.h.

93 {
94 return (key>>REGION_BITS) & LAYER_MASK; // bits 3-8
95 }
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

Definition at line 265 of file HitSummaryDataUtils.h.

265 {
266 unsigned int layer_pattern=0u;
267 unsigned short key = makeKey(region);
268 std::array<uint8_t,2> stat_mask{ 0xff, static_cast<uint8_t>(include_outlier ? 0xff : 0) };
269 for (const auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits] : m_stat) {
270 if ((stat_key & REGION_MASK) == key) {
271 if ((stat_hits & stat_mask[0])+(stat_outlier_hits & stat_mask[1]) >0u) {
272 layer_pattern |= 1u<<layerFromKey(stat_key);
273 }
274 }
275 }
276 return layer_pattern;
277 }
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 80 of file HitSummaryDataUtils.h.

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

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

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

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

◆ reset()

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

reset all summary counters to zero.

Definition at line 107 of file HitSummaryDataUtils.h.

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

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

247 {
248 uint8_t total=0u;
249 unsigned short key = makeKey(region, layer, 0);
250 for (const auto &[stat_key, stat_hits, stat_outlier_hits, stat_shared_hits] : m_stat) {
251 if ((stat_key & LAYER_REGION_MASK) == key) {
252 if constexpr(HIT_SELECTION & HitSummaryData::Hit) {
253 total += stat_hits;
254 }
255 if constexpr(HIT_SELECTION & HitSummaryData::Outlier) {
256 total += stat_outlier_hits;
257 }
258 if constexpr(HIT_SELECTION & HitSummaryData::SharedHit) {
259 total += stat_shared_hits;
260 }
261 }
262 }
263 return total;
264 }
static constexpr unsigned short LAYER_REGION_MASK

Member Data Documentation

◆ LAYER_BITS

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

Definition at line 57 of file HitSummaryDataUtils.h.

◆ LAYER_MASK

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

Definition at line 58 of file HitSummaryDataUtils.h.

◆ LAYER_REGION_MASK

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

Definition at line 54 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 281 of file HitSummaryDataUtils.h.

281{};

◆ m_layers

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

Definition at line 282 of file HitSummaryDataUtils.h.

282{};

◆ m_stat

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

Definition at line 280 of file HitSummaryDataUtils.h.

◆ REGION_BITS

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

Definition at line 55 of file HitSummaryDataUtils.h.

◆ REGION_MASK

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

Definition at line 56 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 59 of file HitSummaryDataUtils.h.

◆ SIGNED_ETA_MOD_MASK

unsigned short ActsTrk::detail::HitSummaryData::SIGNED_ETA_MOD_MASK = 0x7F
staticconstexpr

Definition at line 60 of file HitSummaryDataUtils.h.


The documentation for this class was generated from the following file: