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,
151 const CaloRecGPU::ClusterInfoArr & cluster_info_1,
152 const CaloRecGPU::ClusterInfoArr & cluster_info_2,
153 const bool match_in_energy,
154 const bool match_without_shared) const;
155
156 StatusCode match_clusters_perfectly(sample_comparisons_holder & sch,
157 const CaloRecGPU::ConstantDataHolder & constant_data,
158 const CaloRecGPU::CellInfoArr & cell_info,
159 const CaloRecGPU::ClusterInfoArr & cluster_info_1,
160 const CaloRecGPU::ClusterInfoArr & cluster_info_2,
161 const bool match_without_shared) const;
162
163 //--------------------------------------------------
164 //
165 // GENERAL OPTIONS/SETTINGS
166 //
167 //--------------------------------------------------
168
172 Gaudi::Property<float> m_termThreshold {this, "CellThreshold", 0., "Cell (terminal) threshold (in units of noise Sigma)"};
173
177 Gaudi::Property<float> m_growThreshold {this, "NeighborThreshold", 2., "Neighbor (grow) threshold (in units of noise Sigma)"};
178
182 Gaudi::Property<float> m_seedThreshold {this, "SeedThreshold", 4., "Seed threshold (in units of noise Sigma)"};
183
187 SG::ReadHandleKey<CaloCellContainer> m_cellsKey {this, "CellsName", "", "Name(s) of Cell Containers"};
188
191 ToolHandle< GenericMonitoringTool > m_moniTool { this, "MonitoringTool", "", "Monitoring tool" };
192
195 Gaudi::Property<std::vector<int>> m_missingCellsToFill {this, "MissingCellsToFill", {}, "Force fill these cells as disabled on empty containers."};
196
197 //--------------------------------------------------
198 //
199 // PLOT OPTIONS
200 //
201 //--------------------------------------------------
202
207 Gaudi::Property<std::vector<SimpleSingleTool>> m_toolsToPlot
208 {this, "ToolsToPlot", {}, "Tools to be plotted individually"};
209
212 Gaudi::Property< std::vector<SimpleToolPair> > m_pairsToPlot
213 {this, "PairsToPlot", {}, "Pairs of tools to be compared and plotted"};
214
217 Gaudi::Property<MatchingOptions> m_matchingOptions
218 {this, "ClusterMatchingParameters", {}, "Parameters for the cluster matching algorithm"};
219
220 //--------------------------------------------------
221 //
222 // OTHER MEMBER VARIABLES
223 //
224 //--------------------------------------------------
225
229 double m_min_similarity = 0.5, m_seed_weight = 5000., m_grow_weight = 250., m_terminal_weight = 10.;
230
234 const CaloCell_ID * m_calo_id {nullptr};
235
242 std::map<std::string, int> m_toolsToCheckFor;
243
245 std::map<std::string, std::string> m_toolToIdMap;
246
249
251 {
252 int index_ref = -1, index_test = -1;
253 std::string prefix;
254 bool match_in_energy = false;
256 bool match_perfectly = false;
257 };
258
259 std::vector<pair_to_plot> m_toolCombinations;
260
262 mutable std::map<std::string, std::atomic<size_t>> m_numClustersPerTool ATLAS_THREAD_SAFE;
263
265 size_t m_numEvents = 0;
266
273
277
285
288 bool m_doCells = false, m_doClusters = false, m_doCombinedCells = false, m_doCombinedClusters = false;
289
290
294 mutable std::atomic<bool> m_plottedVariablesInitialized;
295
296
299 mutable std::mutex m_mutex;
300
301};
302
303#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.
StatusCode match_clusters_perfectly(sample_comparisons_holder &sch, const CaloRecGPU::ConstantDataHolder &constant_data, const CaloRecGPU::CellInfoArr &cell_info, const CaloRecGPU::ClusterInfoArr &cluster_info_1, const CaloRecGPU::ClusterInfoArr &cluster_info_2, const bool match_without_shared) const
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.
StatusCode match_clusters(sample_comparisons_holder &sch, const CaloRecGPU::ConstantDataHolder &constant_data, const CaloRecGPU::CellInfoArr &cell_info, const CaloRecGPU::ClusterInfoArr &cluster_info_1, const CaloRecGPU::ClusterInfoArr &cluster_info_2, const bool match_in_energy, const bool match_without_shared) const
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...
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.
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.