ATLAS Offline Software
Loading...
Searching...
No Matches
EventInfoDefinitions.h
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3//
4// Dear emacs, this is -*- c++ -*-
5//
6
7#ifndef CALORECGPU_EVENTINFODEFINITIONS_H
8#define CALORECGPU_EVENTINFODEFINITIONS_H
9
10#include "BaseDefinitions.h"
11#include "TagDefinitions.h"
13
14#include <cstdint>
15#include <cmath>
16#include <functional>
17//For fabsf...
18
19#include "CaloGeoHelpers/CaloSampling.h"
21
22namespace CaloRecGPU
23{
24
29 {
30 using GainType = unsigned int;
31 protected:
32
33 constexpr static GainType s_TileLowLow = 0,
37
38 constexpr static GainType s_TileOneLow = 0,
40 //Are these valid/used?
41
42 constexpr static GainType s_LArHigh = 0,
45
46 constexpr static GainType s_InvalidCell = 4;
47
48 constexpr static GainType s_gain_values_minimum = 0;
49 constexpr static GainType s_gain_values_maximum = 4;
50 public:
51
52 inline static constexpr GainType invalid_gain()
53 {
54 return s_InvalidCell;
55 }
56
57 inline static constexpr GainType max_gain_value()
58 {
60 }
61
62 inline static constexpr GainType min_gain_value()
63 {
65 }
66
67 inline static constexpr GainType num_gain_values()
68 {
69 return max_gain_value() - min_gain_value() + 1;
70 }
71
72 template <class T>
73 inline static constexpr bool is_valid(const T & gain)
74 {
75 return gain != s_InvalidCell;
76 }
77
78 inline static constexpr GainType from_standard_gain(const int gain)
79 //Basically, CaloCondUtils::getDbCaloGain without the Athena logging.
80 {
81 switch (gain)
82 {
83 case -16: //Tile LOWLOW
84 return s_TileLowLow;
85 case -15: //Tile LOWHIGH
86 return s_TileLowHigh;
87 case -12: //Tile HIGHLOW
88 return s_TileHighLow;
89 case -11: //Tile HIGHHIGH
90 return s_TileHighHigh;
91 case -4 : //Tile ONELOW
92 return s_TileOneLow;
93 case -3 : //Tile ONEHIGH
94 return s_TileOneHigh;
95 case 0 : //LAr High
96 return s_LArHigh;
97 case 1 : //LAr Medium
98 return s_LArMedium;
99 case 2 : //Lar Low
100 return s_LArLow;
101 default:
102 return s_InvalidCell;
103 }
104 }
105
106 };
107
117 {
118 using carrier = unsigned int;
119
121
122 constexpr static carrier s_16_bit_mask = 0xFFFFU;
123 constexpr static carrier s_8_bit_mask = 0x00FFU;
124
125 public:
126
127 constexpr operator carrier () const
128 {
129 return value;
130 }
131
132 constexpr QualityProvenance (const carrier v): value(v)
133 {
134 }
135
137 {
138 value = v;
139 return (*this);
140 }
141
142 constexpr unsigned int quality() const
143 {
144 return value & s_16_bit_mask;
145 }
146
147 constexpr unsigned int provenance() const
148 {
149 return (value >> 16) & s_16_bit_mask;
150 }
151
152 constexpr QualityProvenance(const uint16_t quality, const uint16_t provenance): value(provenance)
153 //For non-tile
154 {
155 value = (value << 16) | quality;
156 }
157
158 constexpr QualityProvenance(const uint8_t q1, const uint8_t q2, const uint8_t q3, const uint8_t q4):
159 value(q4)
160 //For tile
161 {
162 value = (value << 8) | q3;
163 value = (value << 8) | q2;
164 value = (value << 8) | q1;
165 }
166
167 constexpr unsigned int tile_qual1() const
168 {
169 return value & s_8_bit_mask;
170 }
171
172 constexpr unsigned int tile_qual2() const
173 {
174 return (value >> 8) & s_8_bit_mask;
175 }
176
177 constexpr unsigned int tile_qbit1() const
178 {
179 return (value >> 16) & s_8_bit_mask;
180 }
181
182 constexpr unsigned int tile_qbit2() const
183 {
184 return (value >> 24) & s_8_bit_mask;
185 }
186 };
187
192 {
196
197 constexpr int get_number_of_cells(const bool is_complete = false) const
198 {
199 if (is_complete)
200 {
201 return NCaloCells;
202 }
203 else
204 {
205 return number;
206 }
207 }
208 };
209
215 //are offered.
217 {
218 unsigned char gain[NCaloCells];
222 //We could use/type pun a short2,
223 //but let's go for portability for the time being...
224
227
228 constexpr int get_hash_ID(const int cell, const bool is_complete = false) const
229 {
230 if (is_complete)
231 {
232 return cell;
233 }
234 else
235 {
236 return hashID[cell];
237 }
238 }
239
240 constexpr int get_cell_with_hash_ID(const int index, const bool is_complete = false) const
241 {
242 if (is_complete)
243 {
244 return index;
245 }
246 else
247 {
249 }
250 }
251
255 static constexpr bool is_bad_general(const bool is_tile, const QualityProvenance qp, const bool treat_L1_predicted_as_good = false)
256 {
257 bool ret = false;
258
259 if (is_tile)
260 {
261
262 const unsigned int mask = 0x08U;
263
264 ret = (qp.tile_qbit1() & mask) && (qp.tile_qbit2() & mask);
265 //From TileCell::badcell()
266 //badch1() && badch2()
267 //badch1() -> m_tileQual[2]&TileCell::MASK_BADCH
268 //badch2() -> m_tileQual[3]&TileCell::MASK_BADCH
269 //
270 //TileCell::MASK_BADCH= 0x08
271 //
272 //From CaloCell:
273 //union {
274 // int m_quality ;
275 // uint16_t m_qualProv[2];
276 // uint8_t m_tileQual[4];
277 //};
278 //quality returns m_qualProv[0]
279 //provenance returns m_qualProv[1]
280 //These are used to build our QualityProvenance...
281 //
282 //It's packing and unpacking back and forth, how fun!
283 }
284 else
285 {
286 const unsigned int provenance = qp.provenance();
287 ret = provenance & 0x0800U;
288 //As in LArCell::badcell()
289
290 if (treat_L1_predicted_as_good && (provenance & 0x0200U))
291 //As in CaloBadCellHelper::isBad
292 {
293 ret = false;
294 }
295 }
296 return ret;
297 }
298
302 constexpr bool is_bad(const int cell, const bool treat_L1_predicted_as_good = false, const bool is_complete = false) const
303 {
304 return is_bad_general(GeometryArr::is_tile(get_hash_ID(cell, is_complete)), qualityProvenance[cell], treat_L1_predicted_as_good);
305 }
306
309 constexpr bool passes_time_cut(const GeometryArr & geom, const int cell, const float threshold,
310 const bool use_crosstalk, const float crosstalk_delta, const bool is_complete = false) const
311 {
312 const int real_cell = get_hash_ID(cell, is_complete);
313 const int sampling = geom.sampling(real_cell);
314 if (sampling == CaloSampling::PreSamplerB ||
315 sampling == CaloSampling::PreSamplerE ||
316 sampling == CaloSampling::Unknown )
317 {
318 return true;
319 }
320 else
321 {
322 const QualityProvenance qp = qualityProvenance[cell];
323 const unsigned int mask = geom.is_tile(real_cell) ? 0x8080U : 0x2000U;
324 if (qp.provenance() & mask)
325 {
326 const float this_time = time[cell];
327 if (fabsf(this_time) >= threshold)
328 {
329 if (use_crosstalk)
330 {
331 const float this_energy = energy[cell];
332 const bool eligible = (sampling == CaloSampling::EMB2 || (sampling == CaloSampling::EME2 && fabsf(geom.eta[real_cell]) < 2.5));
333 if (this_energy > 0 && eligible)
334 {
335 int neighbours[NMaxNeighbours] = {};
336
338
339 const int num_neighs = geom.get_neighbours(neigh_options, real_cell, neighbours);
340
341 for (int i = 0; i < num_neighs; ++i)
342 {
343 const int neigh_index = get_cell_with_hash_ID(neighbours[i], is_complete);
344 if (neigh_index >= 0 && energy[neigh_index] > 4 * this_energy)
345 {
346 const QualityProvenance neigh_qp = qualityProvenance[neigh_index];
347 if ( !(neigh_qp.provenance() & mask) || fabsf(time[neigh_index]) < threshold )
348 {
349 if (this_time > -threshold && this_time < threshold + crosstalk_delta)
350 {
351 return true;
352 }
353 }
354 }
355 }
356 }
357 }
358 return false;
359 }
360 }
361 }
362 return true;
363 }
364
365 constexpr bool is_valid(const int hash_ID, const bool is_complete = false, const bool all_cells_are_valid = false) const
366 {
367 if (all_cells_are_valid)
368 {
369 return true;
370 }
371 else if (is_complete)
372 {
373 return GainConversion::is_valid(gain[hash_ID]);
374 }
375 else
376 {
377 return hashIDToCollection[hash_ID] >= 0;
378 }
379 }
380 };
381
382 enum class ClusterInformationState : uint8_t
383 {
384 None, //No cell assignment to clusters
385 Tags, //Cell assignment to clusters using the generic tags, unspecified order, some may be invalid
386 TagsWithBasicInfo, //As before, but also with the basic information having been calculated
387 Full, //Proper cell assignment, all clusters are valid and sorted, but no info
388 WithBasicInfo, //As before, but also with the basic information having been calculated
389 WithMoments, //Moments have been calculated too
390 WithExtraMoments, //And also the additional moments beyond cluster moments calculation
391 };
392
397 {
402
403 constexpr static bool has_cells_per_cluster(const ClusterInformationState this_state)
404 {
405 switch(this_state)
406 {
408 return true;
410 return true;
412 return true;
414 return true;
415 default:
416 return false;
417 }
418 }
419
420 constexpr bool has_cells_per_cluster() const
421 {
423 }
424
425 constexpr bool has_basic_info(const ClusterInformationState this_state) const
426 {
427 switch(this_state)
428 {
430 return true;
432 return true;
434 return true;
436 return true;
437 default:
438 return false;
439 }
440 }
441
442 constexpr bool has_basic_info() const
443 {
444 return has_basic_info(state);
445 }
446
447 constexpr static bool has_moments(const ClusterInformationState this_state)
448 {
449 switch(this_state)
450 {
452 return true;
454 return true;
455 default:
456 return false;
457 }
458 }
459
460 constexpr bool has_moments() const
461 {
462 return has_moments(state);
463 }
464 };
465
482 {
491
493
494 union
495 {
499
500 alignas(tag_type) float cellWeights[2 * NCaloCells];
501
503
504 //We align all the moments to 8 bytes
505 //so that we can use them for larger
506 //temporaries without out-of-bounds access.
507 //Given that NMaxClusters = 2^16,
508 //this would be nonetheless true,
509 //but now it's guaranteed.
511 {
512 alignas(double) float energyPerSample [NumSamplings][NMaxClusters];
513 alignas(double) float maxEPerSample [NumSamplings][NMaxClusters];
516 alignas(double) float etaPerSample [NumSamplings][NMaxClusters];
517 alignas(double) float phiPerSample [NumSamplings][NMaxClusters];
518 alignas(double) float time [NMaxClusters];
519 //These are, strictly speaking, not moments,
520 //but I think they are best left here rather than
521 //in the ClusterInfoArr since they are only filled in
522 //during cluster moments calculation...
523
524 alignas(double) float firstPhi [NMaxClusters];
525 alignas(double) float firstEta [NMaxClusters];
526 alignas(double) float secondR [NMaxClusters];
527 alignas(double) float secondLambda [NMaxClusters];
528 alignas(double) float deltaPhi [NMaxClusters];
529 alignas(double) float deltaTheta [NMaxClusters];
530 alignas(double) float deltaAlpha [NMaxClusters];
531 alignas(double) float centerX [NMaxClusters];
532 alignas(double) float centerY [NMaxClusters];
533 alignas(double) float centerZ [NMaxClusters];
534 alignas(double) float centerMag [NMaxClusters];
535 alignas(double) float centerLambda [NMaxClusters];
536 alignas(double) float lateral [NMaxClusters];
537 alignas(double) float longitudinal [NMaxClusters];
538 alignas(double) float engFracEM [NMaxClusters];
539 alignas(double) float engFracMax [NMaxClusters];
540 alignas(double) float engFracCore [NMaxClusters];
541 alignas(double) float firstEngDens [NMaxClusters];
542 alignas(double) float secondEngDens [NMaxClusters];
543 alignas(double) float isolation [NMaxClusters];
544 alignas(double) float engBadCells [NMaxClusters];
545 alignas(double) int nBadCells [NMaxClusters];
546 alignas(double) int nBadCellsCorr [NMaxClusters];
547 alignas(double) float badCellsCorrE [NMaxClusters];
548 alignas(double) float badLArQFrac [NMaxClusters];
549 alignas(double) float engPos [NMaxClusters];
550 alignas(double) float significance [NMaxClusters];
551 alignas(double) float cellSignificance [NMaxClusters];
552 alignas(double) int cellSigSampling [NMaxClusters];
553 alignas(double) float avgLArQ [NMaxClusters];
554 alignas(double) float avgTileQ [NMaxClusters];
555 alignas(double) float engBadHVCells [NMaxClusters];
556 alignas(double) float nBadHVCells [NMaxClusters];
557 alignas(double) float PTD [NMaxClusters];
558 alignas(double) float mass [NMaxClusters];
559 alignas(double) float EMProbability [NMaxClusters];
560 alignas(double) float hadWeight [NMaxClusters];
561 alignas(double) float OOCweight [NMaxClusters];
562 alignas(double) float DMweight [NMaxClusters];
563 alignas(double) float tileConfidenceLevel [NMaxClusters];
564 alignas(double) float secondTime [NMaxClusters];
566 alignas(double) int nExtraCellSampling [NMaxClusters];
567 alignas(double) float vertexFraction [NMaxClusters];
568 alignas(double) int nVertexFraction [NMaxClusters];
569 alignas(double) float etaCaloFrame [NMaxClusters];
570 alignas(double) float phiCaloFrame [NMaxClusters];
571 alignas(double) float eta1CaloFrame [NMaxClusters];
572 alignas(double) float phi1CaloFrame [NMaxClusters];
573 alignas(double) float eta2CaloFrame [NMaxClusters];
574 alignas(double) float phi2CaloFrame [NMaxClusters];
575 alignas(double) float engCalibTot [NMaxClusters];
576 alignas(double) float engCalibOutL [NMaxClusters];
577 alignas(double) float engCalibOutM [NMaxClusters];
578 alignas(double) float engCalibOutT [NMaxClusters];
579 alignas(double) float engCalibDeadL [NMaxClusters];
580 alignas(double) float engCalibDeadM [NMaxClusters];
581 alignas(double) float engCalibDeadT [NMaxClusters];
582 alignas(double) float engCalibEMB0 [NMaxClusters];
583 alignas(double) float engCalibEME0 [NMaxClusters];
584 alignas(double) float engCalibTileG3 [NMaxClusters];
585 alignas(double) float engCalibDeadTot [NMaxClusters];
586 alignas(double) float engCalibDeadEMB0 [NMaxClusters];
587 alignas(double) float engCalibDeadTile0 [NMaxClusters];
588 alignas(double) float engCalibDeadTileG3 [NMaxClusters];
589 alignas(double) float engCalibDeadEME0 [NMaxClusters];
590 alignas(double) float engCalibDeadHEC0 [NMaxClusters];
591 alignas(double) float engCalibDeadFCAL [NMaxClusters];
592 alignas(double) float engCalibDeadLeakage [NMaxClusters];
593 alignas(double) float engCalibDeadUnclass [NMaxClusters];
594 alignas(double) float engCalibFracEM [NMaxClusters];
595 alignas(double) float engCalibFracHad [NMaxClusters];
596 alignas(double) float engCalibFracRest [NMaxClusters];
597 //And DigiHSTruth ones are reused here if that is the case?
598 //Maybe counting from the end if we need to keep both?
600
601
602//MACRO takes as arguments: the identifier corresponding to the moments,
603//a 0/1 number that defines whether or not it's part of the actual moments
604//or is another cluster property (e. g. per sample things),
605//a 0/1 number that defines whether or not it is a moment that can be easily
606//assigned directly using the normal interface, a 0/1 number that
607//defines whether this moment is calculated as part of the default set, the token/enum name
608//that corresponds to the moment if it can be assigned through the normal interface
609//(or NONE if not) and any additional arguments passed to CALORECGPU_FORALLMOMENTS_INSTANTIATE.
610//For the latter, due to how macros work (and for portability's sake),
611//your macro should expect at least one extra argument (which will be empty
612//if no extra arguments are provided), due to the trailing comma...
613//WARNING: for maximum flexibility, no semicolons are added or expected!
614//Example definition: YOUR_MACRO(VAR_NAME, PROPER_MOMENT, NORMAL_ASSIGN, IS_CALCULATED, MOMENT_NAME, ...)
615#define CALORECGPU_FORALLMOMENTS_INSTANTIATE(MACRO, ...) \
616 MACRO(energyPerSample , 0, 0, 1, NONE , __VA_ARGS__) \
617 MACRO(maxEPerSample , 0, 0, 1, NONE , __VA_ARGS__) \
618 MACRO(maxPhiPerSample , 0, 0, 1, NONE , __VA_ARGS__) \
619 MACRO(maxEtaPerSample , 0, 0, 1, NONE , __VA_ARGS__) \
620 MACRO(etaPerSample , 0, 0, 1, NONE , __VA_ARGS__) \
621 MACRO(phiPerSample , 0, 0, 1, NONE , __VA_ARGS__) \
622 MACRO(time , 0, 0, 1, NONE , __VA_ARGS__) \
623 MACRO(firstPhi , 1, 1, 1, FIRST_PHI , __VA_ARGS__) \
624 MACRO(firstEta , 1, 1, 1, FIRST_ETA , __VA_ARGS__) \
625 MACRO(secondR , 1, 1, 1, SECOND_R , __VA_ARGS__) \
626 MACRO(secondLambda , 1, 1, 1, SECOND_LAMBDA , __VA_ARGS__) \
627 MACRO(deltaPhi , 1, 1, 1, DELTA_PHI , __VA_ARGS__) \
628 MACRO(deltaTheta , 1, 1, 1, DELTA_THETA , __VA_ARGS__) \
629 MACRO(deltaAlpha , 1, 1, 1, DELTA_ALPHA , __VA_ARGS__) \
630 MACRO(centerX , 1, 1, 1, CENTER_X , __VA_ARGS__) \
631 MACRO(centerY , 1, 1, 1, CENTER_Y , __VA_ARGS__) \
632 MACRO(centerZ , 1, 1, 1, CENTER_Z , __VA_ARGS__) \
633 MACRO(centerMag , 1, 1, 1, CENTER_MAG , __VA_ARGS__) \
634 MACRO(centerLambda , 1, 1, 1, CENTER_LAMBDA , __VA_ARGS__) \
635 MACRO(lateral , 1, 1, 1, LATERAL , __VA_ARGS__) \
636 MACRO(longitudinal , 1, 1, 1, LONGITUDINAL , __VA_ARGS__) \
637 MACRO(engFracEM , 1, 1, 1, ENG_FRAC_EM , __VA_ARGS__) \
638 MACRO(engFracMax , 1, 1, 1, ENG_FRAC_MAX , __VA_ARGS__) \
639 MACRO(engFracCore , 1, 1, 1, ENG_FRAC_CORE , __VA_ARGS__) \
640 MACRO(firstEngDens , 1, 1, 1, FIRST_ENG_DENS , __VA_ARGS__) \
641 MACRO(secondEngDens , 1, 1, 1, SECOND_ENG_DENS , __VA_ARGS__) \
642 MACRO(isolation , 1, 1, 1, ISOLATION , __VA_ARGS__) \
643 MACRO(engBadCells , 1, 1, 1, ENG_BAD_CELLS , __VA_ARGS__) \
644 MACRO(nBadCells , 1, 1, 1, N_BAD_CELLS , __VA_ARGS__) \
645 MACRO(nBadCellsCorr , 1, 1, 1, N_BAD_CELLS_CORR , __VA_ARGS__) \
646 MACRO(badCellsCorrE , 1, 1, 1, BAD_CELLS_CORR_E , __VA_ARGS__) \
647 MACRO(badLArQFrac , 1, 1, 1, BADLARQ_FRAC , __VA_ARGS__) \
648 MACRO(engPos , 1, 1, 1, ENG_POS , __VA_ARGS__) \
649 MACRO(significance , 1, 1, 1, SIGNIFICANCE , __VA_ARGS__) \
650 MACRO(cellSignificance , 1, 1, 1, CELL_SIGNIFICANCE , __VA_ARGS__) \
651 MACRO(cellSigSampling , 1, 1, 1, CELL_SIG_SAMPLING , __VA_ARGS__) \
652 MACRO(avgLArQ , 1, 1, 1, AVG_LAR_Q , __VA_ARGS__) \
653 MACRO(avgTileQ , 1, 1, 1, AVG_TILE_Q , __VA_ARGS__) \
654 MACRO(engBadHVCells , 1, 1, 0, ENG_BAD_HV_CELLS , __VA_ARGS__) \
655 MACRO(nBadHVCells , 1, 1, 0, N_BAD_HV_CELLS , __VA_ARGS__) \
656 MACRO(PTD , 1, 1, 1, PTD , __VA_ARGS__) \
657 MACRO(mass , 1, 1, 1, MASS , __VA_ARGS__) \
658 MACRO(EMProbability , 1, 1, 1, EM_PROBABILITY , __VA_ARGS__) \
659 MACRO(hadWeight , 1, 1, 1, HAD_WEIGHT , __VA_ARGS__) \
660 MACRO(OOCweight , 1, 1, 1, OOC_WEIGHT , __VA_ARGS__) \
661 MACRO(DMweight , 1, 1, 1, DM_WEIGHT , __VA_ARGS__) \
662 MACRO(tileConfidenceLevel , 1, 1, 1, TILE_CONFIDENCE_LEVEL , __VA_ARGS__) \
663 MACRO(secondTime , 1, 0, 1, SECOND_TIME , __VA_ARGS__) \
664 MACRO(nCellSampling , 1, 0, 1, NCELL_SAMPLING , __VA_ARGS__) \
665 MACRO(nExtraCellSampling , 0, 0, 1, NCELL_SAMPLING , __VA_ARGS__) \
666 MACRO(vertexFraction , 1, 1, 0, VERTEX_FRACTION , __VA_ARGS__) \
667 MACRO(nVertexFraction , 1, 1, 0, NVERTEX_FRACTION , __VA_ARGS__) \
668 MACRO(etaCaloFrame , 1, 1, 0, ETACALOFRAME , __VA_ARGS__) \
669 MACRO(phiCaloFrame , 1, 1, 0, PHICALOFRAME , __VA_ARGS__) \
670 MACRO(eta1CaloFrame , 1, 1, 0, ETA1CALOFRAME , __VA_ARGS__) \
671 MACRO(phi1CaloFrame , 1, 1, 0, PHI1CALOFRAME , __VA_ARGS__) \
672 MACRO(eta2CaloFrame , 1, 1, 0, ETA2CALOFRAME , __VA_ARGS__) \
673 MACRO(phi2CaloFrame , 1, 1, 0, PHI2CALOFRAME , __VA_ARGS__) \
674 MACRO(engCalibTot , 1, 1, 0, ENG_CALIB_TOT , __VA_ARGS__) \
675 MACRO(engCalibOutL , 1, 1, 0, ENG_CALIB_OUT_L , __VA_ARGS__) \
676 MACRO(engCalibOutM , 1, 1, 0, ENG_CALIB_OUT_M , __VA_ARGS__) \
677 MACRO(engCalibOutT , 1, 1, 0, ENG_CALIB_OUT_T , __VA_ARGS__) \
678 MACRO(engCalibDeadL , 1, 1, 0, ENG_CALIB_DEAD_L , __VA_ARGS__) \
679 MACRO(engCalibDeadM , 1, 1, 0, ENG_CALIB_DEAD_M , __VA_ARGS__) \
680 MACRO(engCalibDeadT , 1, 1, 0, ENG_CALIB_DEAD_T , __VA_ARGS__) \
681 MACRO(engCalibEMB0 , 1, 1, 0, ENG_CALIB_EMB0 , __VA_ARGS__) \
682 MACRO(engCalibEME0 , 1, 1, 0, ENG_CALIB_EME0 , __VA_ARGS__) \
683 MACRO(engCalibTileG3 , 1, 1, 0, ENG_CALIB_TILEG3 , __VA_ARGS__) \
684 MACRO(engCalibDeadTot , 1, 1, 0, ENG_CALIB_DEAD_TOT , __VA_ARGS__) \
685 MACRO(engCalibDeadEMB0 , 1, 1, 0, ENG_CALIB_DEAD_EMB0 , __VA_ARGS__) \
686 MACRO(engCalibDeadTile0 , 1, 1, 0, ENG_CALIB_DEAD_TILE0 , __VA_ARGS__) \
687 MACRO(engCalibDeadTileG3 , 1, 1, 0, ENG_CALIB_DEAD_TILEG3 , __VA_ARGS__) \
688 MACRO(engCalibDeadEME0 , 1, 1, 0, ENG_CALIB_DEAD_EME0 , __VA_ARGS__) \
689 MACRO(engCalibDeadHEC0 , 1, 1, 0, ENG_CALIB_DEAD_HEC0 , __VA_ARGS__) \
690 MACRO(engCalibDeadFCAL , 1, 1, 0, ENG_CALIB_DEAD_FCAL , __VA_ARGS__) \
691 MACRO(engCalibDeadLeakage , 1, 1, 0, ENG_CALIB_DEAD_LEAKAGE , __VA_ARGS__) \
692 MACRO(engCalibDeadUnclass , 1, 1, 0, ENG_CALIB_DEAD_UNCLASS , __VA_ARGS__) \
693 MACRO(engCalibFracEM , 1, 1, 0, ENG_CALIB_FRAC_EM , __VA_ARGS__) \
694 MACRO(engCalibFracHad , 1, 1, 0, ENG_CALIB_FRAC_HAD , __VA_ARGS__) \
695 MACRO(engCalibFracRest , 1, 1, 0, ENG_CALIB_FRAC_REST , __VA_ARGS__)
696
697//Note: SECOND_TIME is weird
698
699
700#define CALORECGPU_FORALLMOMENTS_HELPER(MOMENTNAME, ...) \
701 std::invoke(f, this->moments.MOMENTNAME, std::forward<Args>(args)...);
702
707 template <class F, class ... Args>
708 constexpr void for_all_moments(F && f, Args && ... args) const
709 {
710 // call f as an lvalue every time
712 }
713
718 template <class F, class ... Args>
723
730 constexpr const tag_type & get_extra_cell_info(const int idx) const
731 {
732 constexpr auto max_size = NMaxClusters * sizeof(float) / sizeof(tag_type);
733
734 const int outer_idx = idx / max_size;
735 const int inner_idx = idx % max_size;
736
737 using PtrType = const tag_type *;
738
739 auto get_laundered_pointer = [&](auto * ptr) -> PtrType
740 {
741 return std::launder(static_cast<PtrType>(static_cast<const void *>(ptr)));
742 };
743
744 PtrType arr[6] = { get_laundered_pointer(this->moments.engCalibTot),
745 get_laundered_pointer(this->moments.engCalibOutL),
746 get_laundered_pointer(this->moments.engCalibOutM),
747 get_laundered_pointer(this->moments.engCalibOutT),
748 get_laundered_pointer(this->moments.engCalibDeadL),
749 get_laundered_pointer(this->moments.engCalibDeadM) };
750
751 return *(arr[outer_idx] + inner_idx);
752 }
753
754 constexpr tag_type & get_extra_cell_info(const int idx)
755 {
756 constexpr auto max_size = NMaxClusters * sizeof(float) / sizeof(tag_type);
757
758 const int outer_idx = idx / max_size;
759 const int inner_idx = idx % max_size;
760
761 using PtrType = tag_type *;
762
763 auto get_laundered_pointer = [&](auto * ptr) -> PtrType
764 {
765 return std::launder(static_cast<PtrType>(static_cast<void *>(ptr)));
766 };
767
768 PtrType arr[6] = { get_laundered_pointer(this->moments.engCalibTot),
769 get_laundered_pointer(this->moments.engCalibOutL),
770 get_laundered_pointer(this->moments.engCalibOutM),
771 get_laundered_pointer(this->moments.engCalibOutT),
772 get_laundered_pointer(this->moments.engCalibDeadL),
773 get_laundered_pointer(this->moments.engCalibDeadM) };
774
775 return *(arr[outer_idx] + inner_idx);
776 }
777
778 template <class NewT = tag_type>
779 constexpr const NewT * secondary_tag_array() const
780 {
781 return std::launder(static_cast<const NewT *>(static_cast<const void *>(this->cellWeights)));
782 }
783 template <class NewT = tag_type>
784 constexpr NewT * secondary_tag_array()
785 {
786 return std::launder(static_cast<NewT *>(static_cast<void *>(this->cellWeights)));
787 }
788 template <class NewT = tag_type>
789 constexpr const NewT & secondary_tag_array(const int idx) const
790 {
791 return this->template secondary_tag_array<NewT>()[idx];
792 }
793 template <class NewT = tag_type>
794 constexpr NewT & secondary_tag_array(const int idx)
795 {
796 return this->template secondary_tag_array<NewT>()[idx];
797 }
798
799 template <class NewT = tag_type>
800 constexpr const NewT * tertiary_tag_array() const
801 {
802 return std::launder(static_cast<const NewT *>(static_cast<const void *>(this->clusterIndices)));
803 }
804 template <class NewT = tag_type>
805 constexpr NewT * tertiary_tag_array()
806 {
807 return std::launder(static_cast<NewT *>(static_cast<void *>(this->clusterIndices)));
808 }
809 template <class NewT = tag_type>
810 constexpr const NewT & tertiary_tag_array(const int idx) const
811 {
812 return this->template tertiary_tag_array<NewT>()[idx];
813 }
814 template <class NewT = tag_type>
815 constexpr NewT & tertiary_tag_array(const int idx)
816 {
817 return this->template tertiary_tag_array<NewT>()[idx];
818 }
819
820
821 };
822
823}
824
825#endif
#define CALORECGPU_FORALLMOMENTS_HELPER(MOMENTNAME,...)
#define CALORECGPU_FORALLMOMENTS_INSTANTIATE(MACRO,...)
#define F(x, y, z)
Definition MD5.cxx:112
Provides utility functions to handle the gain conversion.
static constexpr GainType s_TileLowLow
static constexpr GainType from_standard_gain(const int gain)
static constexpr GainType max_gain_value()
static constexpr GainType s_TileHighHigh
static constexpr GainType s_TileHighLow
static constexpr GainType s_LArMedium
static constexpr GainType invalid_gain()
static constexpr GainType s_InvalidCell
static constexpr GainType s_gain_values_maximum
static constexpr GainType min_gain_value()
static constexpr GainType num_gain_values()
static constexpr GainType s_TileOneLow
static constexpr GainType s_gain_values_minimum
static constexpr GainType s_TileLowHigh
static constexpr GainType s_TileOneHigh
static constexpr GainType s_LArLow
static constexpr bool is_valid(const T &gain)
static constexpr GainType s_LArHigh
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
constexpr int NumSamplings
TagBase::carrier tag_type
constexpr int NMaxNeighbours
constexpr int NCaloCells
__host__ __device__ T * get_laundered_pointer(unsigned int idx, PtrLikes &&... p)
constexpr int NMaxClusters
Definition index.py:1
Contains the fundamental information that allows interacting with CellInfoArr so that it is easier to...
constexpr int get_number_of_cells(const bool is_complete=false) const
Contains the per-event cell information: energy, timing, gain, quality and provenance.
QualityProvenance::carrier qualityProvenance[NCaloCells]
constexpr int get_hash_ID(const int cell, const bool is_complete=false) const
constexpr bool passes_time_cut(const GeometryArr &geom, const int cell, const float threshold, const bool use_crosstalk, const float crosstalk_delta, const bool is_complete=false) const
GPU equivalent of CaloTopoClusterMaker::passCellTimeCut.
constexpr int get_cell_with_hash_ID(const int index, const bool is_complete=false) const
constexpr bool is_bad(const int cell, const bool treat_L1_predicted_as_good=false, const bool is_complete=false) const
GPU version of CaloBadCellHelper::isBad.
static constexpr bool is_bad_general(const bool is_tile, const QualityProvenance qp, const bool treat_L1_predicted_as_good=false)
GPU version of CaloBadCellHelper::isBad.
unsigned char gain[NCaloCells]
constexpr bool is_valid(const int hash_ID, const bool is_complete=false, const bool all_cells_are_valid=false) const
Contains the fundamental information that allows interacting with ClusterInfoArr so that it is easier...
constexpr bool has_basic_info() const
constexpr bool has_cells_per_cluster() const
constexpr bool has_basic_info(const ClusterInformationState this_state) const
ClusterInformationState state
constexpr bool has_moments() const
static constexpr bool has_cells_per_cluster(const ClusterInformationState this_state)
static constexpr bool has_moments(const ClusterInformationState this_state)
float etaPerSample[NumSamplings][NMaxClusters]
float maxEtaPerSample[NumSamplings][NMaxClusters]
float maxPhiPerSample[NumSamplings][NMaxClusters]
float energyPerSample[NumSamplings][NMaxClusters]
float maxEPerSample[NumSamplings][NMaxClusters]
float phiPerSample[NumSamplings][NMaxClusters]
constexpr const NewT & tertiary_tag_array(const int idx) const
constexpr void for_all_moments(F &&f, Args &&... args) const
F receives the array associated with the moment and any additional arguments.
constexpr NewT & tertiary_tag_array(const int idx)
struct CaloRecGPU::ClusterInfoArr::ClusterMomentsArr moments
constexpr tag_type & get_extra_cell_info(const int idx)
constexpr NewT * secondary_tag_array()
constexpr const NewT * secondary_tag_array() const
int seedCellIndex[NMaxClusters]
Invalid(ated) clusters have seedCellIndex < 0.
constexpr NewT & secondary_tag_array(const int idx)
constexpr const tag_type & get_extra_cell_info(const int idx) const
Extra representation for the cell tags, to save time for calculating the isolation moment after build...
union CaloRecGPU::ClusterInfoArr::@223264020040143137243361055037275307306030322160 cells
constexpr const NewT * tertiary_tag_array() const
constexpr const NewT & secondary_tag_array(const int idx) const
constexpr NewT * tertiary_tag_array()
constexpr void for_all_moments(F &&f, Args &&... args)
F receives the array associated with the moment and any additional arguments.
static constexpr bool is_tile(const int cell)
Just two uint16_t bit-packed onto a uint32_t.
static constexpr carrier s_8_bit_mask
constexpr QualityProvenance(const uint16_t quality, const uint16_t provenance)
constexpr unsigned int provenance() const
constexpr unsigned int tile_qual2() const
constexpr QualityProvenance(const uint8_t q1, const uint8_t q2, const uint8_t q3, const uint8_t q4)
constexpr unsigned int tile_qbit1() const
constexpr QualityProvenance & operator=(const carrier v)
constexpr QualityProvenance(const carrier v)
constexpr unsigned int tile_qual1() const
constexpr unsigned int quality() const
constexpr unsigned int tile_qbit2() const
static constexpr carrier s_16_bit_mask