21 declareInterface<CaloClusterGPUProcessor> (
this);
30 unsigned int total = 0, seed = 0, grow = 0, term = 0, invalid = 0, shared = 0;
32 friend Str &
operator << (Str &
s,
const size_struct & sst)
34 s << sst.total <<
" " << sst.seed <<
" " << sst.grow <<
" " << sst.term <<
" " << sst.invalid <<
" " << sst.shared;
39 struct cluster_info_struct
42 float seed_snr = -9e99;
43 float seed_energy = -9e99;
45 friend Str &
operator << (Str &
s,
const cluster_info_struct & cis)
47 s << cis.size <<
" (" << cis.seed_snr <<
" " << cis.seed_energy <<
")";
65 unsigned int gain_counts[GainConversion::num_gain_values()] = {0};
67 size_struct global_counts, global_cluster_counts;
69 std::vector<int> cluster_max_cell(
clusters->number, -1);
70 std::vector<float> cluster_max_snr(
clusters->number, -9e99);
71 std::vector<float> cluster_max_energy(
clusters->number, -9e99);
73 std::vector<size_struct> cluster_counts(
clusters->number);
75 std::vector<int> shared_cells;
79 if (!cell_info->is_valid(
i))
84 const int gain = cell_info->gain[
i];
85 ++gain_counts[
gain - GainConversion::min_gain_value()];
87 const float energy = cell_info->energy[
i];
89 const float SNR = std::abs(
energy / cell_noise->get_noise(
i,
gain) );
93 const bool is_cluster =
tag.is_part_of_cluster();
95 global_cluster_counts.total += is_cluster;
100 global_cluster_counts.seed += is_cluster;
104 ++global_counts.grow;
105 global_cluster_counts.grow += is_cluster;
109 ++global_counts.term;
110 global_cluster_counts.term += is_cluster;
114 ++global_counts.invalid;
115 global_cluster_counts.invalid += is_cluster;
120 if (
tag.is_shared_between_clusters())
122 shared_cells.push_back(
i);
124 const int cluster =
tag.cluster_index();
125 const int other_cluster =
tag.is_shared_between_clusters() ?
tag.secondary_cluster_index() : cluster;
126 if (!
tag.is_shared_between_clusters() && (SNR > cluster_max_snr[cluster] || (SNR == cluster_max_snr[cluster] &&
i > cluster_max_cell[cluster])))
128 cluster_max_snr[cluster] = SNR;
129 cluster_max_cell[cluster] =
i;
130 cluster_max_energy[cluster] = std::abs(
energy);
132 ++cluster_counts[cluster].total;
133 cluster_counts[other_cluster].total += (cluster != other_cluster);
135 global_cluster_counts.shared +=
tag.is_shared_between_clusters();
136 cluster_counts[cluster].shared +=
tag.is_shared_between_clusters();
137 cluster_counts[other_cluster].shared +=
tag.is_shared_between_clusters();
141 ++cluster_counts[cluster].seed;
142 cluster_counts[other_cluster].seed += (cluster != other_cluster);
146 ++cluster_counts[cluster].grow;
147 cluster_counts[other_cluster].grow += (cluster != other_cluster);
151 ++cluster_counts[cluster].term;
152 cluster_counts[other_cluster].term += (cluster != other_cluster);
156 ++cluster_counts[cluster].invalid;
157 cluster_counts[other_cluster].invalid += (cluster != other_cluster);
162 std::map<int, cluster_info_struct> cluster_sizes;
166 if (cluster_max_cell[
i] >= 0)
168 cluster_sizes[cluster_max_cell[
i]] = cluster_info_struct{cluster_counts[
i], cluster_max_snr[
i], cluster_max_energy[
i]};
172 std::sort(shared_cells.begin(), shared_cells.end());
178 return StatusCode::FAILURE;
184 std::ofstream out_file(save_file);
186 if (!out_file.is_open())
188 return StatusCode::FAILURE;
191 out_file <<
"Cell counts: " << global_counts <<
"\n\n";
193 out_file <<
"Cells in clusters count: "<< global_cluster_counts <<
"\n\n";
194 out_file <<
"Clusters:\n\n";
196 for (
const auto &
it : cluster_sizes)
198 out_file <<
it.first <<
" " <<
it.second <<
"\n";
201 out_file << std::endl;
203 if (!out_file.good())
205 return StatusCode::FAILURE;
210 return StatusCode::SUCCESS;