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