ATLAS Offline Software
Loading...
Searching...
No Matches
TopoAutomatonClusteringImpl.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_TOPOAUTOMATONCLUSTERING_CUDA_H
8#define CALORECGPU_TOPOAUTOMATONCLUSTERING_CUDA_H
9
12#include "CaloRecGPU/Helpers.h"
13#include "ExtraTagDefinitions.h"
14
16
17namespace TAGrowing
18{
19
21 {
22 using CaloRecGPU::Tag_1_1_12_32_18::Tag_1_1_12_32_18;
23
24 protected:
25
26 constexpr static carrier s_grow_tag = 0x7FFFFFFFFFFFFFFFULL;
27
28 constexpr static carrier s_terminal_tag = 0x0000000000000001ULL;
29
30 constexpr static carrier s_minimum_seed_tag = 0x8000000000000000ULL;
31
32 constexpr static uint32_t s_start_counter = 0xFFFU;
33
35
37
38 public:
39
40 [[nodiscard]] static constexpr carrier make_seed_tag(const uint32_t cell, const uint32_t SNR_pattern, const bool can_merge_with_others = true)
41 {
42 return make_generic_tag(cell, SNR_pattern, s_start_counter, !can_merge_with_others, true);
43 }
44
45 [[nodiscard]] static constexpr carrier make_grow_tag()
46 {
47 return s_grow_tag;
48 }
49
50 [[nodiscard]] static constexpr carrier make_terminal_tag()
51 {
52 return s_terminal_tag;
53 }
54
55 [[nodiscard]] constexpr bool is_part_of_cluster() const
56 {
57 return value > s_grow_tag;
58 }
59
60 [[nodiscard]] static constexpr bool is_part_of_cluster(const TACTag tag)
61 {
62 return tag.is_part_of_cluster();
63 }
64
65 [[nodiscard]] constexpr bool is_valid() const
66 {
67 return value >= s_terminal_tag;
68 }
69
70 [[nodiscard]] static constexpr bool is_valid(const TACTag tag)
71 {
72 return tag.is_valid();
73 }
74
75 [[nodiscard]] constexpr bool is_invalid() const
76 {
77 return !(this->is_valid());
78 }
79
80 [[nodiscard]] static constexpr bool is_invalid(const TACTag tag)
81 {
82 return tag.is_invalid();
83 }
84
85 [[nodiscard]] constexpr bool is_non_assigned_terminal() const
86 {
87 return value >= s_terminal_tag && value < s_grow_tag;
88 }
89
90 [[nodiscard]] static constexpr bool is_non_assigned_terminal(const TACTag tag)
91 {
92 return tag.is_non_assigned_terminal();
93 }
94
95 [[nodiscard]] constexpr bool is_non_assigned_grow() const
96 {
98 }
99
100 [[nodiscard]] static constexpr bool is_non_assigned_grow(const TACTag tag)
101 {
102 return tag.is_non_assigned_grow();
103 }
104
105 [[nodiscard]] constexpr bool is_seed() const
106 {
107 return value >= s_minimum_seed_tag;
108 }
109
110 [[nodiscard]] static constexpr bool is_seed(const TACTag tag)
111 {
112 return tag.is_seed();
113 }
114
115 [[nodiscard]] constexpr bool is_grow_or_seed() const
116 {
117 return value >= s_grow_tag;
118 }
119
120 [[nodiscard]] static constexpr bool is_grow_or_seed(const TACTag tag)
121 {
122 return tag.is_grow_or_seed();
123 }
124
125 [[nodiscard]] constexpr carrier propagate() const
126 {
128 }
129
130 [[nodiscard]] static constexpr carrier propagate(const TACTag tag)
131 {
132 return tag.propagate();
133 }
134
135 [[nodiscard]] constexpr uint32_t index() const
136 {
137 return this->get_18_bits();
138 }
139
140 [[nodiscard]] static constexpr uint32_t index(const TACTag tag)
141 {
142 return tag.index();
143 }
144
145 [[nodiscard]] constexpr uint32_t SNR() const
146 {
147 return this->get_32_bits();
148 }
149
150 [[nodiscard]] static constexpr uint32_t SNR(const TACTag tag)
151 {
152 return tag.SNR();
153 }
154
155 [[nodiscard]] constexpr uint32_t counter() const
156 {
157 return this->get_12_bits();
158 }
159
160 [[nodiscard]] static constexpr uint32_t counter(const TACTag tag)
161 {
162 return tag.counter();
163 }
164
165 [[nodiscard]] constexpr carrier clear_counter_and_no_merge() const
166 {
168 }
169
170 [[nodiscard]] static constexpr carrier clear_counter_and_no_merge(const TACTag tag)
171 {
172 return tag.clear_counter_and_no_merge();
173 }
174
175 [[nodiscard]] constexpr carrier set_index(const uint32_t new_index) const
176 {
177 return (value & (~s_18_bit_mask)) | (new_index & 0x3FFFFU);
178 }
179
180 [[nodiscard]] constexpr bool can_merge() const
181 {
182 return this->is_seed() && !this->get_second_flag();
183 }
184
185 [[nodiscard]] static constexpr bool can_merge(const TACTag tag)
186 {
187 return tag.can_merge();
188 }
189
190 [[nodiscard]] constexpr bool cannot_merge() const
191 {
192 return !this->can_merge();
193 }
194
195 [[nodiscard]] static constexpr bool cannot_merge(const TACTag tag)
196 {
197 return tag.cannot_merge();
198 }
199
200 [[nodiscard]] constexpr carrier clear_no_merge_flag() const
201 {
202 return this->unset_second_flag();
203 }
204
205 [[nodiscard]] static constexpr carrier clear_no_merge_flag(const TACTag tag)
206 {
207 return tag.clear_no_merge_flag();
208 }
209 };
210
212 {
222
225 unsigned int neighbour_options;
226
229
231 //This is used to pack the bits that tell us whether a sample can be used to have seeds or not.
233 //This is a way to express the selection of calorimeters to use for the algorithm
234 //through the samplings (as the calorimeter <-> sampling relation is fixed...)
235
236 constexpr bool uses_seed_sampling(const int sampling) const
237 {
238 return (valid_sampling_seed >> sampling) & 1;
239 }
240
246 constexpr bool uses_calorimeter_by_sampling(const int sampling) const
247 {
248 return (valid_calorimeter_by_sampling >> sampling) & 1;
249 }
250
251 };
252 //Just a bundled way to pass the options for the Topo-Automaton Clustering.
253
267
269
271 const CaloRecGPU::ConstantDataHolder & instance_data,
272 const TACOptionsHolder & options,
273 const IGPUKernelSizeOptimizer & optimizer,
274 const bool synchronize = false,
276
278 const CaloRecGPU::ConstantDataHolder & instance_data,
279 const TACOptionsHolder & options,
280 const IGPUKernelSizeOptimizer & optimizer,
281 const bool synchronize = false,
283
285 const CaloRecGPU::ConstantDataHolder & instance_data,
286 const TACOptionsHolder & options,
287 const IGPUKernelSizeOptimizer & optimizer,
288 const bool synchronize = false,
290
291}
292#endif //CALORECGPU_TOPOAUTOMATONCLUSTERING_CUDA_H
Holds CPU and GPU versions of the geometry and cell noise information, which are assumed to be consta...
Definition DataHolders.h:27
Holds the mutable per-event information (clusters and cells) and provides utilities to convert betwee...
Definition DataHolders.h:73
Interface for GPU kernel size optimization (allowing adjustment of kernel sizes to the properties of ...
SimpleHolder< T, MemoryContext::CUDAGPU, true > CUDA_object
Holds an object of type T in CUDA GPU memory.
SimpleHolder< T, MemoryContext::CPU, true > CPU_object
Holds an object of type T in CPU memory.
void signalToNoise(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const TACOptionsHolder &options, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
void register_kernels(IGPUKernelSizeOptimizer &optimizer)
void clusterGrowing(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const TACOptionsHolder &options, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
void cellPairs(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const TACOptionsHolder &options, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
CaloRecGPU::TagBase::carrier carrier
A tag with two bit flags, then 12 bits (for a counter), 32 bits (for a float) and 18 bits (for a cell...
constexpr uint32_t get_18_bits() const
constexpr uint32_t get_12_bits() const
constexpr carrier unset_second_flag() const
static constexpr carrier make_generic_tag(const uint32_t bits_18, const uint32_t bits_32, const uint32_t bits_12, const bool flag_2, const bool flag_1)
static constexpr carrier s_12_bit_mask
static constexpr carrier s_second_flag_mask
static constexpr carrier s_18_bit_mask
constexpr uint32_t get_32_bits() const
static constexpr unsigned int s_12_bit_offset
constexpr bool get_second_flag() const
CaloRecGPU::Helpers::CPU_object< TopoAutomatonOptions > m_options
void sendToGPU(const bool clear_CPU=false)
CaloRecGPU::Helpers::CUDA_object< TopoAutomatonOptions > m_options_dev
constexpr uint32_t counter() const
static constexpr bool cannot_merge(const TACTag tag)
constexpr bool is_valid() const
static constexpr uint32_t index(const TACTag tag)
static constexpr bool is_grow_or_seed(const TACTag tag)
constexpr bool is_non_assigned_terminal() const
constexpr uint32_t index() const
static constexpr carrier make_grow_tag()
static constexpr bool is_non_assigned_terminal(const TACTag tag)
static constexpr carrier clear_no_merge_flag(const TACTag tag)
static constexpr bool is_non_assigned_grow(const TACTag tag)
constexpr bool is_invalid() const
static constexpr carrier s_no_can_merge_flag
constexpr uint32_t SNR() const
static constexpr bool is_part_of_cluster(const TACTag tag)
static constexpr bool is_valid(const TACTag tag)
static constexpr carrier s_grow_tag
static constexpr bool is_invalid(const TACTag tag)
constexpr bool can_merge() const
static constexpr uint32_t SNR(const TACTag tag)
static constexpr carrier s_tag_propagation_delta
constexpr carrier set_index(const uint32_t new_index) const
static constexpr bool can_merge(const TACTag tag)
constexpr bool is_part_of_cluster() const
static constexpr uint32_t s_start_counter
constexpr bool cannot_merge() const
static constexpr carrier propagate(const TACTag tag)
constexpr carrier clear_counter_and_no_merge() const
static constexpr uint32_t counter(const TACTag tag)
constexpr bool is_non_assigned_grow() const
constexpr bool is_grow_or_seed() const
constexpr bool is_seed() const
constexpr carrier propagate() const
static constexpr carrier make_seed_tag(const uint32_t cell, const uint32_t SNR_pattern, const bool can_merge_with_others=true)
static constexpr carrier clear_counter_and_no_merge(const TACTag tag)
static constexpr carrier s_minimum_seed_tag
static constexpr carrier s_terminal_tag
static constexpr carrier make_terminal_tag()
constexpr carrier clear_no_merge_flag() const
static constexpr bool is_seed(const TACTag tag)
constexpr bool uses_calorimeter_by_sampling(const int sampling) const
Checks if the calorimeter is used through the sampling to which the cell belongs.
constexpr bool uses_seed_sampling(const int sampling) const