ATLAS Offline Software
Loading...
Searching...
No Matches
CaloGPUClusterAndCellDataMonitor.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_CaloGPUClusterAndCellDataMonitor_H
8#define CALORECGPU_CaloGPUClusterAndCellDataMonitor_H
9
13#include "CaloRecGPU/Helpers.h"
14#include <string>
15#include <vector>
16#include <utility>
17#include <memory>
18#include <mutex>
19#include <tuple>
20
22
25
27
28class CaloCell_ID;
29
39
41 public extends<AthAlgTool, ICaloClusterGPUPlotter>
42{
43 public:
44
45 CaloGPUClusterAndCellDataMonitor(const std::string & type, const std::string & name, const IInterface * parent);
46
47 virtual StatusCode initialize() override;
48
50
51
52 virtual StatusCode update_plots_start(const EventContext & ctx,
53 const CaloRecGPU::ConstantDataHolder & constant_data,
54 const xAOD::CaloClusterContainer * cluster_collection_ptr) const override;
55
56 virtual StatusCode update_plots_end(const EventContext & ctx,
57 const CaloRecGPU::ConstantDataHolder & constant_data,
58 const xAOD::CaloClusterContainer * cluster_collection_ptr) const override;
59
60 virtual StatusCode update_plots(const EventContext & ctx,
61 const CaloRecGPU::ConstantDataHolder & constant_data,
62 const xAOD::CaloClusterContainer * cluster_collection_ptr,
63 const CaloClusterCollectionProcessor * tool) const override;
64
65 virtual StatusCode update_plots(const EventContext & ctx,
66 const CaloRecGPU::ConstantDataHolder & constant_data,
67 const xAOD::CaloClusterContainer * cluster_collection_ptr,
68 const CaloRecGPU::EventDataHolder & event_data,
69 const ICaloClusterGPUInputTransformer * tool) const override;
70
71 virtual StatusCode update_plots(const EventContext & ctx,
72 const CaloRecGPU::ConstantDataHolder & constant_data,
73 const xAOD::CaloClusterContainer * cluster_collection_ptr,
74 const CaloRecGPU::EventDataHolder & event_data,
75 const CaloClusterGPUProcessor * tool) const override;
76
77 virtual StatusCode update_plots(const EventContext & ctx,
78 const CaloRecGPU::ConstantDataHolder & constant_data,
79 const xAOD::CaloClusterContainer * cluster_collection_ptr,
80 const CaloRecGPU::EventDataHolder & event_data,
81 const ICaloClusterGPUOutputTransformer * tool) const override;
82
83 virtual StatusCode finalize_plots() const override;
84
85 private:
86
88
89 StatusCode add_data(const EventContext & ctx,
90 const CaloRecGPU::ConstantDataHolder & constant_data,
91 const CaloRecGPU::CellInfoArr * cell_info,
92 const CaloRecGPU::ClusterInfoArr * clusters,
93 const std::vector<int> & cells_prefix_sum,
94 const std::string & tool_name) const;
95
96
97 StatusCode add_combination(const EventContext & ctx,
98 const CaloRecGPU::ConstantDataHolder & constant_data,
99 const int index_1,
100 const int index_2,
101 const std::string & prefix,
102 const bool match_in_energy,
103 const bool match_without_shared,
104 const bool match_perfectly) const;
105
108 bool filter_tool_by_name(const std::string & tool_name) const;
109
112 StatusCode update_cell_representation(const EventContext & ctx,
113 const CaloRecGPU::ConstantDataHolder & constant_data,
114 const CaloRecGPU::CellInfoArr * cell_info,
116 std::vector<int> & cells_prefix_sum) const;
117
118
120 {
121 std::vector<int> r2t_table, t2r_table;
123
126 int r2t(const int i) const
127 {
128 return r2t_table[i];
129 }
130
132 int t2r(const int i) const
133 {
134 return t2r_table[i];
135 }
136
137 int ref_unmatched() const
138 {
139 return unmatched_ref_list.size();
140 }
141
142 int test_unmatched() const
143 {
144 return unmatched_test_list.size();
145 }
146 };
147
148 StatusCode match_clusters(sample_comparisons_holder & sch,
149 const CaloRecGPU::ConstantDataHolder & constant_data,
150 const CaloRecGPU::CellInfoArr & cell_info_1,
151 const CaloRecGPU::CellInfoArr & cell_info_2,
152 const std::vector<int> & cells_prefix_sum_1,
153 const std::vector<int> & cells_prefix_sum_2,
154 const CaloRecGPU::ClusterInfoArr & cluster_info_1,
155 const CaloRecGPU::ClusterInfoArr & cluster_info_2,
156 const bool match_in_energy,
157 const bool match_without_shared) const;
158
159 StatusCode match_clusters_perfectly(sample_comparisons_holder & sch,
160 const CaloRecGPU::ConstantDataHolder & constant_data,
161 const CaloRecGPU::CellInfoArr & cell_info_1,
162 const CaloRecGPU::CellInfoArr & cell_info_2,
163 const std::vector<int> & cells_prefix_sum_1,
164 const std::vector<int> & cells_prefix_sum_2,
165 const CaloRecGPU::ClusterInfoArr & cluster_info_1,
166 const CaloRecGPU::ClusterInfoArr & cluster_info_2,
167 const bool match_without_shared) const;
168
169 //--------------------------------------------------
170 //
171 // GENERAL OPTIONS/SETTINGS
172 //
173 //--------------------------------------------------
174
178 Gaudi::Property<float> m_termThreshold {this, "CellThreshold", 0., "Cell (terminal) threshold (in units of noise Sigma)"};
179
183 Gaudi::Property<float> m_growThreshold {this, "NeighborThreshold", 2., "Neighbor (grow) threshold (in units of noise Sigma)"};
184
188 Gaudi::Property<float> m_seedThreshold {this, "SeedThreshold", 4., "Seed threshold (in units of noise Sigma)"};
189
193 SG::ReadHandleKey<CaloCellContainer> m_cellsKey {this, "CellsName", "", "Name(s) of Cell Containers"};
194
197 ToolHandle< GenericMonitoringTool > m_moniTool { this, "MonitoringTool", "", "Monitoring tool" };
198
201 Gaudi::Property<std::vector<int>> m_missingCellsToFill {this, "MissingCellsToFill", {}, "Force fill these cells as disabled on empty containers."};
202
203 //--------------------------------------------------
204 //
205 // PLOT OPTIONS
206 //
207 //--------------------------------------------------
208
213 Gaudi::Property<std::vector<SimpleSingleTool>> m_toolsToPlot
214 {this, "ToolsToPlot", {}, "Tools to be plotted individually"};
215
218 Gaudi::Property< std::vector<SimpleToolPair> > m_pairsToPlot
219 {this, "PairsToPlot", {}, "Pairs of tools to be compared and plotted"};
220
223 Gaudi::Property<MatchingOptions> m_matchingOptions
224 {this, "ClusterMatchingParameters", {}, "Parameters for the cluster matching algorithm"};
225
226 //--------------------------------------------------
227 //
228 // OTHER MEMBER VARIABLES
229 //
230 //--------------------------------------------------
231
235 double m_min_similarity = 0.5, m_seed_weight = 5000., m_grow_weight = 250., m_terminal_weight = 10.;
236
240 const CaloCell_ID * m_calo_id {nullptr};
241
248 std::map<std::string, int> m_toolsToCheckFor;
249
251 std::map<std::string, std::string> m_toolToIdMap;
252
255
257 {
258 int index_ref = -1, index_test = -1;
259 std::string prefix;
260 bool match_in_energy = false;
262 bool match_perfectly = false;
263 };
264
265 std::vector<pair_to_plot> m_toolCombinations;
266
268 mutable std::map<std::string, std::atomic<size_t>> m_numClustersPerTool ATLAS_THREAD_SAFE;
269
271 size_t m_numEvents = 0;
272
279
283
291
294 bool m_doCells = false, m_doClusters = false, m_doCombinedCells = false, m_doCombinedClusters = false;
295
296
300 mutable std::atomic<bool> m_plottedVariablesInitialized;
301
302
305 mutable std::mutex m_mutex;
306
307};
308
309#endif //CALORECGPU_CaloGPUClusterAndCellDataMonitor_H
Property holding a SG store/key/clid from which a ReadHandle is made.
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
Base class for GPU-accelerated cluster processing tools to be called from CaloGPUHybridClusterProcess...
Gaudi::Property< float > m_seedThreshold
Seed threshold to use for cluster matching.
Gaudi::Property< std::vector< SimpleSingleTool > > m_toolsToPlot
Tools to plot individually.
Gaudi::Property< std::vector< SimpleToolPair > > m_pairsToPlot
Pairs of tools to compare.
std::atomic< bool > m_plottedVariablesInitialized
A flag to signal that the variables to be monitored have been detected based on the booked histograms...
virtual ~CaloGPUClusterAndCellDataMonitor()=default
StatusCode add_data(const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, const CaloRecGPU::CellInfoArr *cell_info, const CaloRecGPU::ClusterInfoArr *clusters, const std::vector< int > &cells_prefix_sum, const std::string &tool_name) const
virtual StatusCode update_plots_start(const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, const xAOD::CaloClusterContainer *cluster_collection_ptr) const override
Gaudi::Property< float > m_termThreshold
Cell (terminal) threshold to use for cluster matching.
virtual StatusCode update_plots_end(const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, const xAOD::CaloClusterContainer *cluster_collection_ptr) const override
std::vector< bool > m_clusterPropertiesToDo
Control which properties will actually be calculated and stored.
bool m_doCells
If no properties are asked for, skip the relevant loops entirely...
ToolHandle< GenericMonitoringTool > m_moniTool
Monitoring tool.
int m_numToolsToKeep
The number of tools that will actually need to be kept in memory for combined plotting.
StatusCode add_combination(const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, const int index_1, const int index_2, const std::string &prefix, const bool match_in_energy, const bool match_without_shared, const bool match_perfectly) const
std::map< std::string, std::atomic< size_t > > m_numClustersPerTool ATLAS_THREAD_SAFE
Counts the total number of clusters per tool.
std::map< std::string, std::string > m_toolToIdMap
Maps tools to their respective identifying prefix for variables.
Gaudi::Property< float > m_growThreshold
Neighbor (growing) threshold to use for cluster matching.
Gaudi::Property< MatchingOptions > m_matchingOptions
Option for adjusting the parameters for the cluster matching algorithm.
Gaudi::Property< std::vector< int > > m_missingCellsToFill
Cell indices to fill as disabled cells (useful if the cell vector is always missing the same cells).
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
vector of names of the cell containers to use as input.
std::map< std::string, int > m_toolsToCheckFor
Map of the strings corresponding to all the tools that will be relevant for plotting (individually or...
StatusCode match_clusters(sample_comparisons_holder &sch, const CaloRecGPU::ConstantDataHolder &constant_data, const CaloRecGPU::CellInfoArr &cell_info_1, const CaloRecGPU::CellInfoArr &cell_info_2, const std::vector< int > &cells_prefix_sum_1, const std::vector< int > &cells_prefix_sum_2, const CaloRecGPU::ClusterInfoArr &cluster_info_1, const CaloRecGPU::ClusterInfoArr &cluster_info_2, const bool match_in_energy, const bool match_without_shared) const
size_t m_numEvents
Counts the number of events.
bool filter_tool_by_name(const std::string &tool_name) const
Returns true if this tool should be plotted for.
const CaloCell_ID * m_calo_id
Pointer to Calo ID Helper.
double m_min_similarity
Parameters for the cluster matching algorithm, for easier access.
virtual StatusCode update_plots(const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, const xAOD::CaloClusterContainer *cluster_collection_ptr, const CaloClusterCollectionProcessor *tool) const override
CaloGPUClusterAndCellDataMonitor(const std::string &type, const std::string &name, const IInterface *parent)
StatusCode update_cell_representation(const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, const CaloRecGPU::CellInfoArr *cell_info, CaloRecGPU::ClusterInfoArr *clusters, std::vector< int > &cells_prefix_sum) const
Update the cell representation so the cells-in-clusters are ordered by index and have a prefix sum.
std::mutex m_mutex
This mutex is locked to ensure only one thread detects the monotired variables.
StatusCode match_clusters_perfectly(sample_comparisons_holder &sch, const CaloRecGPU::ConstantDataHolder &constant_data, const CaloRecGPU::CellInfoArr &cell_info_1, const CaloRecGPU::CellInfoArr &cell_info_2, const std::vector< int > &cells_prefix_sum_1, const std::vector< int > &cells_prefix_sum_2, const CaloRecGPU::ClusterInfoArr &cluster_info_1, const CaloRecGPU::ClusterInfoArr &cluster_info_2, const bool match_without_shared) const
virtual StatusCode finalize_plots() const override
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
Manages objects of type T in a thread-safe way, ensuring that there's an object available for each se...
Base class for tools that convert event information from the Athena structures to the GPU-friendly fo...
Base class for tools that convert event information from the GPU-friendly format used in CaloGPUHybri...
Property holding a SG store/key/clid from which a ReadHandle is made.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
int test_unmatched() const
Returns the number of unmatched clusters in the test (second) tool.
int ref_unmatched() const
Returns the number of unmatched clusters in the reference (first) tool.
int t2r(const int i) const
Converts a cluster index from the test tool (second) to the reference tool (first).
int r2t(const int i) const
Converts a cluster index from the reference tool (first) to the test tool (second).
Contains the per-event cell information: energy, timing, gain, quality and provenance.