ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
CaloCellsCounterGPU Class Reference

Outputs counts of cells, both by type and cluster presence, with each cluster being identified by its cell with the largest signal-to-noise ratio. More...

#include <CaloCellsCounterGPU.h>

Inheritance diagram for CaloCellsCounterGPU:
Collaboration diagram for CaloCellsCounterGPU:

Public Member Functions

 CaloCellsCounterGPU (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual StatusCode execute (const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, CaloRecGPU::EventDataHolder &event_data, void *temporary_buffer) const override
 
virtual ~CaloCellsCounterGPU ()=default
 

Private Attributes

Gaudi::Property< std::string > m_savePath {this, "SavePath", "./cell_counts", "Path to where the files should be saved"}
 The path specifying the folder to which the files should be saved. More...
 
Gaudi::Property< std::string > m_filePrefix {this, "FilePrefix", "", "Prefix of the saved files"}
 The prefix of the saved files. More...
 
Gaudi::Property< std::string > m_fileSuffix {this, "FileSuffix", "", "Suffix of the saved files"}
 The suffix of the saved files. More...
 
Gaudi::Property< unsigned int > m_numWidth {this, "NumberWidth", 9, "The number of digits to reserve for the events"}
 The number of digits to reserve for the events. More...
 
Gaudi::Property< float > m_seedThreshold {this, "SeedThresholdOnEorAbsEinSigma", 4., "Seed threshold (in units of noise Sigma)"}
 Value to consider for the seed threshold. More...
 
Gaudi::Property< float > m_growThreshold {this, "NeighborThresholdOnEorAbsEinSigma", 2., "Neighbor (grow) threshold (in units of noise Sigma)"}
 Value to consider for the seed threshold. More...
 
Gaudi::Property< float > m_cellThreshold {this, "CellThresholdOnEorAbsEinSigma", 0., "Cell (terminal) threshold (in units of noise Sigma)"}
 Value to consider for the seed threshold. More...
 

Detailed Description

Outputs counts of cells, both by type and cluster presence, with each cluster being identified by its cell with the largest signal-to-noise ratio.

Author
Nuno Fernandes nuno..nosp@m.dos..nosp@m.santo.nosp@m.s.fe.nosp@m.rnand.nosp@m.es@c.nosp@m.ern.c.nosp@m.h
Date
22 July 2022

Definition at line 22 of file CaloCellsCounterGPU.h.

Constructor & Destructor Documentation

◆ CaloCellsCounterGPU()

CaloCellsCounterGPU::CaloCellsCounterGPU ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 18 of file CaloCellsCounterGPU.cxx.

18  :
19  base_class(type, name, parent)
20 {
21 }

◆ ~CaloCellsCounterGPU()

virtual CaloCellsCounterGPU::~CaloCellsCounterGPU ( )
virtualdefault

Member Function Documentation

◆ execute()

StatusCode CaloCellsCounterGPU::execute ( const EventContext &  ctx,
const CaloRecGPU::ConstantDataHolder constant_data,
CaloRecGPU::EventDataHolder event_data,
void *  temporary_buffer 
) const
overridevirtual

Definition at line 53 of file CaloCellsCounterGPU.cxx.

54 {
55  Helpers::CPU_object<CellNoiseArr> cell_noise(constant_data.m_cell_noise_dev);
56  //We could try to keep this in CPU memory by default,
57  //but, since it isn't quite needed and we don't mind taking a bit longer for this
58  //since we're only debugging, let this be as generic as possible.
59 
63 
64  unsigned int gain_counts[GainConversion::num_gain_values()] = {0};
65 
66  size_struct global_counts, global_cluster_counts;
67 
68  std::vector<int> cluster_max_cell(clusters->number, -1);
69  std::vector<float> cluster_max_snr(clusters->number, -9e99);
70  std::vector<float> cluster_max_energy(clusters->number, -9e99);
71 
72  std::vector<size_struct> cluster_counts(clusters->number);
73 
74  std::vector<int> shared_cells;
75 
76  for (int i = 0; i < NCaloCells; ++i)
77  {
78  if (!cell_info->is_valid(i))
79  {
80  continue;
81  }
82 
83  const int gain = cell_info->gain[i];
84  ++gain_counts[gain - GainConversion::min_gain_value()];
85 
86  const float energy = cell_info->energy[i];
87 
88  const float SNR = std::abs( energy / cell_noise->get_noise(i, gain) );
89 
90  const ClusterTag tag = cell_state->clusterTag[i];
91 
92  const bool is_cluster = tag.is_part_of_cluster();
93 
94  global_cluster_counts.total += is_cluster;
95 
96  if (SNR > m_seedThreshold)
97  {
98  ++global_counts.seed;
99  global_cluster_counts.seed += is_cluster;
100  }
101  else if (SNR > m_growThreshold)
102  {
103  ++global_counts.grow;
104  global_cluster_counts.grow += is_cluster;
105  }
106  else if (SNR > m_cellThreshold)
107  {
108  ++global_counts.term;
109  global_cluster_counts.term += is_cluster;
110  }
111  else
112  {
113  ++global_counts.invalid;
114  global_cluster_counts.invalid += is_cluster;
115  }
116 
117  if (is_cluster)
118  {
119  if (tag.is_shared_between_clusters())
120  {
121  shared_cells.push_back(i);
122  }
123  const int cluster = tag.cluster_index();
124  const int other_cluster = tag.is_shared_between_clusters() ? tag.secondary_cluster_index() : cluster;
125  if (!tag.is_shared_between_clusters() && (SNR > cluster_max_snr[cluster] || (SNR == cluster_max_snr[cluster] && i > cluster_max_cell[cluster])))
126  {
127  cluster_max_snr[cluster] = SNR;
128  cluster_max_cell[cluster] = i;
129  cluster_max_energy[cluster] = std::abs(energy);
130  }
131  ++cluster_counts[cluster].total;
132  cluster_counts[other_cluster].total += (cluster != other_cluster);
133 
134  global_cluster_counts.shared += tag.is_shared_between_clusters();
135  cluster_counts[cluster].shared += tag.is_shared_between_clusters();
136  cluster_counts[other_cluster].shared += tag.is_shared_between_clusters();
137 
138  if (SNR > m_seedThreshold)
139  {
140  ++cluster_counts[cluster].seed;
141  cluster_counts[other_cluster].seed += (cluster != other_cluster);
142  }
143  else if (SNR > m_growThreshold)
144  {
145  ++cluster_counts[cluster].grow;
146  cluster_counts[other_cluster].grow += (cluster != other_cluster);
147  }
148  else if (SNR > m_cellThreshold)
149  {
150  ++cluster_counts[cluster].term;
151  cluster_counts[other_cluster].term += (cluster != other_cluster);
152  }
153  else
154  {
155  ++cluster_counts[cluster].invalid;
156  cluster_counts[other_cluster].invalid += (cluster != other_cluster);
157  }
158  }
159  }
160 
161  std::map<int, cluster_info_struct> cluster_sizes;
162 
163  for (int i = 0; i < clusters->number; ++i)
164  {
165  if (cluster_max_cell[i] >= 0)
166  {
167  cluster_sizes[cluster_max_cell[i]] = cluster_info_struct{cluster_counts[i], cluster_max_snr[i], cluster_max_energy[i]};
168  }
169  }
170 
171  std::sort(shared_cells.begin(), shared_cells.end());
172 
173 
174  const auto err1 = StandaloneDataIO::prepare_folder_for_output(std::string(m_savePath));
176  {
177  return StatusCode::FAILURE;
178  }
179 
180  const std::filesystem::path save_file = m_savePath + "/" + StandaloneDataIO::build_filename((m_filePrefix.size() > 0 ? m_filePrefix + "_counts" : "counts"),
181  ctx.evt(), m_fileSuffix, "txt", m_numWidth);
182 
183  std::ofstream out_file(save_file);
184 
185  if (!out_file.is_open())
186  {
187  return StatusCode::FAILURE;
188  }
189 
190  out_file << "Cell counts: " << global_counts << "\n\n";
191 
192  out_file << "Cells in clusters count: "<< global_cluster_counts << "\n\n";
193  out_file << "Clusters:\n\n";
194 
195  for (const auto & it : cluster_sizes)
196  {
197  out_file << it.first << " " << it.second << "\n";
198  }
199 
200  out_file << std::endl;
201 
202  if (!out_file.good())
203  {
204  return StatusCode::FAILURE;
205  }
206 
207  out_file.close();
208 
209  return StatusCode::SUCCESS;
210 
211 }

Member Data Documentation

◆ m_cellThreshold

Gaudi::Property<float> CaloCellsCounterGPU::m_cellThreshold {this, "CellThresholdOnEorAbsEinSigma", 0., "Cell (terminal) threshold (in units of noise Sigma)"}
private

Value to consider for the seed threshold.

Should be consistent with the one used in Topological Clustering to ensure cell classification is correct.

Definition at line 73 of file CaloCellsCounterGPU.h.

◆ m_filePrefix

Gaudi::Property<std::string> CaloCellsCounterGPU::m_filePrefix {this, "FilePrefix", "", "Prefix of the saved files"}
private

The prefix of the saved files.

Empty string by default.

Definition at line 48 of file CaloCellsCounterGPU.h.

◆ m_fileSuffix

Gaudi::Property<std::string> CaloCellsCounterGPU::m_fileSuffix {this, "FileSuffix", "", "Suffix of the saved files"}
private

The suffix of the saved files.

Empty string by default.

Definition at line 53 of file CaloCellsCounterGPU.h.

◆ m_growThreshold

Gaudi::Property<float> CaloCellsCounterGPU::m_growThreshold {this, "NeighborThresholdOnEorAbsEinSigma", 2., "Neighbor (grow) threshold (in units of noise Sigma)"}
private

Value to consider for the seed threshold.

Should be consistent with the one used in Topological Clustering to ensure cell classification is correct.

Definition at line 68 of file CaloCellsCounterGPU.h.

◆ m_numWidth

Gaudi::Property<unsigned int> CaloCellsCounterGPU::m_numWidth {this, "NumberWidth", 9, "The number of digits to reserve for the events"}
private

The number of digits to reserve for the events.

9 by default.

Definition at line 58 of file CaloCellsCounterGPU.h.

◆ m_savePath

Gaudi::Property<std::string> CaloCellsCounterGPU::m_savePath {this, "SavePath", "./cell_counts", "Path to where the files should be saved"}
private

The path specifying the folder to which the files should be saved.

Default ./cell_counts

Definition at line 43 of file CaloCellsCounterGPU.h.

◆ m_seedThreshold

Gaudi::Property<float> CaloCellsCounterGPU::m_seedThreshold {this, "SeedThresholdOnEorAbsEinSigma", 4., "Seed threshold (in units of noise Sigma)"}
private

Value to consider for the seed threshold.

Should be consistent with the one used in Topological Clustering to ensure cell classification is correct.

Definition at line 63 of file CaloCellsCounterGPU.h.


The documentation for this class was generated from the following files:
StandaloneDataIO::build_filename
static std::string build_filename(const std::string &prefix, const std::string &text, const std::string &suffix, const std::string &ext)
Definition: StandaloneDataIO.h:273
CaloCellsCounterGPU::m_cellThreshold
Gaudi::Property< float > m_cellThreshold
Value to consider for the seed threshold.
Definition: CaloCellsCounterGPU.h:73
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
CaloRecGPU::Helpers::SimpleHolder
Holds one objects of type \T in memory context Context.
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:1074
CaloRecGPU::EventDataHolder::m_cell_state_dev
CaloRecGPU::Helpers::CUDA_object< CaloRecGPU::CellStateArr > m_cell_state_dev
Definition: DataHolders.h:89
skel.it
it
Definition: skel.GENtoEVGEN.py:407
CaloRecGPU::EventDataHolder::m_clusters_dev
CaloRecGPU::Helpers::CUDA_object< CaloRecGPU::ClusterInfoArr > m_clusters_dev
Definition: DataHolders.h:90
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
CaloRecGPU::ClusterTag
Definition: TagDefinitions.h:222
CaloRecGPU::EventDataHolder::m_cell_info_dev
CaloRecGPU::Helpers::CUDA_object< CaloRecGPU::CellInfoArr > m_cell_info_dev
Definition: DataHolders.h:88
CaloCellsCounterGPU::m_numWidth
Gaudi::Property< unsigned int > m_numWidth
The number of digits to reserve for the events.
Definition: CaloCellsCounterGPU.h:58
StandaloneDataIO::ErrorState::OK
@ OK
CaloCellsCounterGPU::m_growThreshold
Gaudi::Property< float > m_growThreshold
Value to consider for the seed threshold.
Definition: CaloCellsCounterGPU.h:68
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:85
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CaloRecGPU::NCaloCells
constexpr int NCaloCells
Definition: BaseDefinitions.h:12
MuonEfficiencyCorrectionsCfg.out_file
out_file
Definition: MuonEfficiencyCorrectionsCfg.py:69
CaloRecGPU::ConstantDataHolder::m_cell_noise_dev
CaloRecGPU::Helpers::CUDA_object< CaloRecGPU::CellNoiseArr > m_cell_noise_dev
Definition: DataHolders.h:30
CaloCellsCounterGPU::m_seedThreshold
Gaudi::Property< float > m_seedThreshold
Value to consider for the seed threshold.
Definition: CaloCellsCounterGPU.h:63
StandaloneDataIO::prepare_folder_for_output
static ErrorState prepare_folder_for_output(const std::filesystem::path &folder, const bool output_errors=true)
Definition: StandaloneDataIO.h:264
CaloCellsCounterGPU::m_filePrefix
Gaudi::Property< std::string > m_filePrefix
The prefix of the saved files.
Definition: CaloCellsCounterGPU.h:48
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
CaloCellsCounterGPU::m_fileSuffix
Gaudi::Property< std::string > m_fileSuffix
The suffix of the saved files.
Definition: CaloCellsCounterGPU.h:53
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
CaloCellsCounterGPU::m_savePath
Gaudi::Property< std::string > m_savePath
The path specifying the folder to which the files should be saved.
Definition: CaloCellsCounterGPU.h:43
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23