17 #include "CLHEP/Units/SystemOfUnits.h"
27 m_plottedVariablesInitialized(false)
29 declareInterface<ICaloClusterGPUPlotter> (
this);
38 const std::string this_name = this->
name();
40 const std::string algorithm_name_prefix = this_name.substr(0, this_name.rfind(
'.'));
44 auto final_string = [& algorithm_name_prefix](
const std::string & unpref_str) -> std::string
46 return algorithm_name_prefix +
"." + unpref_str;
58 const std::string tool_name = final_string(
tool.tool);
63 auto add_tool_from_pair = [
this](
const std::string &
name) ->
int
88 const int first_index = add_tool_from_pair(final_string(pair.tool_ref));
89 const int second_index = add_tool_from_pair(final_string(pair.tool_test));
92 pair.match_without_shared,
93 pair.match_perfectly});
98 return StatusCode::SUCCESS;
109 auto mon_num_clust =
Monitored::Scalar(k_v.second +
"_num_total_clusters", m_numClustersPerTool.at(k_v.first).load());
112 return StatusCode::SUCCESS;
121 std::lock_guard<std::mutex> lock_guard(
m_mutex);
127 ATH_CHECK( dhis->initialize_plotted_variables() );
137 return StatusCode::SUCCESS;
148 if (combination.index_ref < 0 || combination.index_test < 0)
150 ATH_MSG_WARNING(
"Invalid tool combination, please check your configuration! " << combination.prefix);
154 combination.match_in_energy, combination.match_without_shared, combination.match_perfectly) );
161 m_storageHolder.release_one();
165 return StatusCode::SUCCESS;
181 cell_info, cell_state,
clusters, moments ) );
187 return StatusCode::SUCCESS;
204 return StatusCode::SUCCESS;
227 return StatusCode::SUCCESS;
245 cell_info, cell_state,
clusters, moments ) );
251 return StatusCode::SUCCESS;
274 if ( !cell_collection.
isValid() )
276 ATH_MSG_ERROR(
" Cannot retrieve CaloCellContainer: " << cell_collection.
name() );
277 return StatusCode::FAILURE;
282 if (cluster_collection !=
nullptr)
284 ret_state.allocate();
285 ret_clusts.allocate();
286 ret_moments.allocate();
291 ret_info->energy[
i] = 0;
292 ret_info->gain[
i] = GainConversion::invalid_gain();
293 ret_info->time[
i] = 0;
294 ret_info->qualityProvenance[
i] = 0;
296 if (cluster_collection !=
nullptr)
298 ret_state->clusterTag[
i] = ClusterTag::make_invalid_tag();
310 const unsigned int gain = GainConversion::from_standard_gain(
cell->gain());
319 if (cluster_collection !=
nullptr)
321 const auto cluster_end = cluster_collection->
end();
322 auto cluster_iter = cluster_collection->
begin();
324 for (
int cluster_number = 0; cluster_iter != cluster_end; ++cluster_iter, ++cluster_number )
330 ATH_MSG_ERROR(
"Can't get valid links to CaloCells (CaloClusterCellLink)!");
331 return StatusCode::FAILURE;
334 ret_clusts->clusterEnergy[cluster_number] = cluster->
e();
335 ret_clusts->clusterEt[cluster_number] = cluster->
et();
336 ret_clusts->clusterEta[cluster_number] = cluster->
eta();
337 ret_clusts->clusterPhi[cluster_number] = cluster->
phi();
349 ret_moments->time[cluster_number] = cluster->
time();
392 ret_moments->numCells[cluster_number] = cluster->
numberCells();
423 for (
auto it = cell_links->
begin();
it != cell_links->
end(); ++
it)
425 const int cell_ID =
m_calo_id->calo_cell_hash(
it->ID());
429 std::memcpy(&weight_as_int, &
weight,
sizeof(
float));
434 if (weight_as_int == 0)
442 const ClusterTag other_tag = ret_state->clusterTag[cell_ID];
450 ret_state->clusterTag[cell_ID] = ClusterTag::make_tag(cluster_number, weight_as_int, 0);
454 ret_state->clusterTag[cell_ID] = ClusterTag::make_tag(cluster_number);
459 ret_state->clusterTag[cell_ID] = ClusterTag::make_tag(cluster_number, other_tag.
secondary_cluster_weight(), other_index);
464 const int max_cluster = cluster_number > other_index ? cluster_number : other_index;
465 const int min_cluster = cluster_number > other_index ? other_index : cluster_number;
466 ret_state->clusterTag[cell_ID] = ClusterTag::make_tag(max_cluster, weight_as_int, min_cluster);
470 ret_state->clusterTag[cell_ID] = ClusterTag::make_tag(other_index, weight_as_int, cluster_number);
475 ret_clusts->number = cluster_collection->
size();
478 return StatusCode::SUCCESS;
488 std::map<int, int> tag_map;
490 std::vector<int> cluster_order(
clusters->number);
492 std::iota(cluster_order.begin(), cluster_order.end(), 0);
494 std::sort(cluster_order.begin(), cluster_order.end(), [&](
const int a,
const int b)
496 if (clusters->seedCellID[a] < 0)
510 int real_cluster_numbers =
clusters->number;
512 for (
size_t i = 0;
i < cluster_order.size(); ++
i)
514 const int this_id = cluster_order[
i];
515 if (
clusters->seedCellID[this_id] < 0)
517 tag_map[this_id] = -1;
518 --real_cluster_numbers;
522 tag_map[this_id] =
i;
529 clusters->number = real_cluster_numbers;
531 for (
int i = 0;
i < temp_clusters->number; ++
i)
533 clusters->clusterEnergy[
i] = temp_clusters->clusterEnergy[cluster_order[
i]];
534 clusters->clusterEt[
i] = temp_clusters->clusterEt[cluster_order[
i]];
535 clusters->clusterEta[
i] = temp_clusters->clusterEta[cluster_order[
i]];
536 clusters->clusterPhi[
i] = temp_clusters->clusterPhi[cluster_order[
i]];
537 clusters->seedCellID[
i] = temp_clusters->seedCellID[cluster_order[
i]];
540 moments->energyPerSample[j][
i] = temp_moments->energyPerSample[j][cluster_order[
i]];
541 moments->maxEPerSample[j][
i] = temp_moments->maxEPerSample[j][cluster_order[
i]];
542 moments->maxPhiPerSample[j][
i] = temp_moments->maxPhiPerSample[j][cluster_order[
i]];
543 moments->maxEtaPerSample[j][
i] = temp_moments->maxEtaPerSample[j][cluster_order[
i]];
544 moments->etaPerSample[j][
i] = temp_moments->etaPerSample[j][cluster_order[
i]];
545 moments->phiPerSample[j][
i] = temp_moments->phiPerSample[j][cluster_order[
i]];
547 moments->time[
i] = temp_moments->time[cluster_order[
i]];
548 moments->firstPhi[
i] = temp_moments->firstPhi[cluster_order[
i]];
549 moments->firstEta[
i] = temp_moments->firstEta[cluster_order[
i]];
550 moments->secondR[
i] = temp_moments->secondR[cluster_order[
i]];
551 moments->secondLambda[
i] = temp_moments->secondLambda[cluster_order[
i]];
552 moments->deltaPhi[
i] = temp_moments->deltaPhi[cluster_order[
i]];
553 moments->deltaTheta[
i] = temp_moments->deltaTheta[cluster_order[
i]];
554 moments->deltaAlpha[
i] = temp_moments->deltaAlpha[cluster_order[
i]];
555 moments->centerX[
i] = temp_moments->centerX[cluster_order[
i]];
556 moments->centerY[
i] = temp_moments->centerY[cluster_order[
i]];
557 moments->centerZ[
i] = temp_moments->centerZ[cluster_order[
i]];
558 moments->centerMag[
i] = temp_moments->centerMag[cluster_order[
i]];
559 moments->centerLambda[
i] = temp_moments->centerLambda[cluster_order[
i]];
560 moments->lateral[
i] = temp_moments->lateral[cluster_order[
i]];
561 moments->longitudinal[
i] = temp_moments->longitudinal[cluster_order[
i]];
562 moments->engFracEM[
i] = temp_moments->engFracEM[cluster_order[
i]];
563 moments->engFracMax[
i] = temp_moments->engFracMax[cluster_order[
i]];
564 moments->engFracCore[
i] = temp_moments->engFracCore[cluster_order[
i]];
565 moments->firstEngDens[
i] = temp_moments->firstEngDens[cluster_order[
i]];
566 moments->secondEngDens[
i] = temp_moments->secondEngDens[cluster_order[
i]];
567 moments->isolation[
i] = temp_moments->isolation[cluster_order[
i]];
568 moments->engBadCells[
i] = temp_moments->engBadCells[cluster_order[
i]];
569 moments->nBadCells[
i] = temp_moments->nBadCells[cluster_order[
i]];
570 moments->nBadCellsCorr[
i] = temp_moments->nBadCellsCorr[cluster_order[
i]];
571 moments->badCellsCorrE[
i] = temp_moments->badCellsCorrE[cluster_order[
i]];
572 moments->badLArQFrac[
i] = temp_moments->badLArQFrac[cluster_order[
i]];
573 moments->engPos[
i] = temp_moments->engPos[cluster_order[
i]];
574 moments->significance[
i] = temp_moments->significance[cluster_order[
i]];
575 moments->cellSignificance[
i] = temp_moments->cellSignificance[cluster_order[
i]];
576 moments->cellSigSampling[
i] = temp_moments->cellSigSampling[cluster_order[
i]];
577 moments->avgLArQ[
i] = temp_moments->avgLArQ[cluster_order[
i]];
578 moments->avgTileQ[
i] = temp_moments->avgTileQ[cluster_order[
i]];
579 moments->engBadHVCells[
i] = temp_moments->engBadHVCells[cluster_order[
i]];
580 moments->nBadHVCells[
i] = temp_moments->nBadHVCells[cluster_order[
i]];
581 moments->PTD[
i] = temp_moments->PTD[cluster_order[
i]];
582 moments->mass[
i] = temp_moments->mass[cluster_order[
i]];
583 moments->EMProbability[
i] = temp_moments->EMProbability[cluster_order[
i]];
584 moments->hadWeight[
i] = temp_moments->hadWeight[cluster_order[
i]];
585 moments->OOCweight[
i] = temp_moments->OOCweight[cluster_order[
i]];
586 moments->DMweight[
i] = temp_moments->DMweight[cluster_order[
i]];
587 moments->tileConfidenceLevel[
i] = temp_moments->tileConfidenceLevel[cluster_order[
i]];
588 moments->secondTime[
i] = temp_moments->secondTime[cluster_order[
i]];
591 moments->nCellSampling[j][
i] = temp_moments->nCellSampling[j][cluster_order[
i]];
593 moments->nExtraCellSampling[
i] = temp_moments->nExtraCellSampling[cluster_order[
i]];
594 moments->numCells[
i] = temp_moments->numCells[cluster_order[
i]];
595 moments->vertexFraction[
i] = temp_moments->vertexFraction[cluster_order[
i]];
596 moments->nVertexFraction[
i] = temp_moments->nVertexFraction[cluster_order[
i]];
597 moments->etaCaloFrame[
i] = temp_moments->etaCaloFrame[cluster_order[
i]];
598 moments->phiCaloFrame[
i] = temp_moments->phiCaloFrame[cluster_order[
i]];
599 moments->eta1CaloFrame[
i] = temp_moments->eta1CaloFrame[cluster_order[
i]];
600 moments->phi1CaloFrame[
i] = temp_moments->phi1CaloFrame[cluster_order[
i]];
601 moments->eta2CaloFrame[
i] = temp_moments->eta2CaloFrame[cluster_order[
i]];
602 moments->phi2CaloFrame[
i] = temp_moments->phi2CaloFrame[cluster_order[
i]];
603 moments->engCalibTot[
i] = temp_moments->engCalibTot[cluster_order[
i]];
604 moments->engCalibOutL[
i] = temp_moments->engCalibOutL[cluster_order[
i]];
605 moments->engCalibOutM[
i] = temp_moments->engCalibOutM[cluster_order[
i]];
606 moments->engCalibOutT[
i] = temp_moments->engCalibOutT[cluster_order[
i]];
607 moments->engCalibDeadL[
i] = temp_moments->engCalibDeadL[cluster_order[
i]];
608 moments->engCalibDeadM[
i] = temp_moments->engCalibDeadM[cluster_order[
i]];
609 moments->engCalibDeadT[
i] = temp_moments->engCalibDeadT[cluster_order[
i]];
610 moments->engCalibEMB0[
i] = temp_moments->engCalibEMB0[cluster_order[
i]];
611 moments->engCalibEME0[
i] = temp_moments->engCalibEME0[cluster_order[
i]];
612 moments->engCalibTileG3[
i] = temp_moments->engCalibTileG3[cluster_order[
i]];
613 moments->engCalibDeadTot[
i] = temp_moments->engCalibDeadTot[cluster_order[
i]];
614 moments->engCalibDeadEMB0[
i] = temp_moments->engCalibDeadEMB0[cluster_order[
i]];
615 moments->engCalibDeadTile0[
i] = temp_moments->engCalibDeadTile0[cluster_order[
i]];
616 moments->engCalibDeadTileG3[
i] = temp_moments->engCalibDeadTileG3[cluster_order[
i]];
617 moments->engCalibDeadEME0[
i] = temp_moments->engCalibDeadEME0[cluster_order[
i]];
618 moments->engCalibDeadHEC0[
i] = temp_moments->engCalibDeadHEC0[cluster_order[
i]];
619 moments->engCalibDeadFCAL[
i] = temp_moments->engCalibDeadFCAL[cluster_order[
i]];
620 moments->engCalibDeadLeakage[
i] = temp_moments->engCalibDeadLeakage[cluster_order[
i]];
621 moments->engCalibDeadUnclass[
i] = temp_moments->engCalibDeadUnclass[cluster_order[
i]];
622 moments->engCalibFracEM[
i] = temp_moments->engCalibFracEM[cluster_order[
i]];
623 moments->engCalibFracHad[
i] = temp_moments->engCalibFracHad[cluster_order[
i]];
624 moments->engCalibFracRest[
i] = temp_moments->engCalibFracRest[cluster_order[
i]];
629 if (!cell_info->is_valid(
i))
633 const ClusterTag this_tag = cell_state->clusterTag[
i];
636 cell_state->clusterTag[
i] = ClusterTag::make_invalid_tag();
641 const int new_idx = tag_map[old_idx];
643 const int new_idx2 = old_idx2 >= 0 ? tag_map[old_idx2] : -1;
644 if (new_idx < 0 && new_idx2 < 0)
646 cell_state->clusterTag[
i] = ClusterTag::make_invalid_tag();
648 else if (new_idx < 0)
650 cell_state->clusterTag[
i] = ClusterTag::make_tag(new_idx2);
652 else if (new_idx2 < 0)
654 cell_state->clusterTag[
i] = ClusterTag::make_tag(new_idx);
663 return StatusCode::SUCCESS;
668 template <
class ...
Args>
669 struct multi_class_holder
671 static constexpr
size_t size()
673 return sizeof...(Args);
679 static constexpr decltype(
auto) suppress_warning(Arg &&
a)
681 return std::forward<Arg>(
a);
684 template <
class F,
class ...
Types,
class ...
Args>
685 void apply_to_multi_class(
F &&
f,
const multi_class_holder<Types...> &,
Args && ...
args)
688 if constexpr (std::is_same_v < decltype(
f((
Types{}, ...),
i, std::forward<Args>(
args)...)),
void > )
690 (
f(
Types{},
i++, std::forward<Args>(
args)...), ...);
694 (suppress_warning(
f(
Types{},
i++, std::forward<Args>(
args)...)), ...);
698 static float float_unhack(
const unsigned int bits)
701 std::memcpy(&
res, &bits,
sizeof(
float));
706 static double protect_from_zero(
const double x)
708 return x == 0 ? 1
e-15 :
x;
711 static float protect_from_zero(
const float x)
713 return x == 0 ? 1
e-7 :
x;
726 const bool match_in_energy,
727 const bool match_without_shared)
const
735 std::vector<double> similarity_map(cluster_info_1.
number * cluster_info_2.
number, 0.);
737 std::vector<double> ref_normalization(cluster_info_1.
number, 0.);
738 std::vector<double> test_normalization(cluster_info_2.
number, 0.);
750 double SNR = 0.00001;
757 if (std::isfinite(cellNoise) && cellNoise > 0.0
f)
759 SNR = std::abs(cell_info.
energy[
i] / cellNoise);
763 const double quantity = ( match_in_energy ? std::abs(cell_info.
energy[
i]) : SNR );
764 const double weight = (quantity + 1
e-8) *
773 int ref_c1 = -1, ref_c2 = -1, test_c1 = -1, test_c2 = -1;
798 float ref_cw = 1.0f - ref_rev_cw;
799 float test_cw = 1.0f - test_rev_cw;
801 if (ref_c1 >=
int(cluster_info_1.
number) || ref_c2 >=
int(cluster_info_1.
number) ||
802 test_c1 >=
int(cluster_info_2.
number) || test_c2 >=
int(cluster_info_2.
number) )
804 ATH_MSG_DEBUG(
"Error in matches: " <<
i <<
" " << ref_c1 <<
" " << ref_c2 <<
" "
805 << test_c1 <<
" " << test_c2 <<
" ("
806 << cluster_info_1.
number <<
" | " << cluster_info_2.
number <<
")" );
810 if (ref_c1 >= 0 && test_c1 >= 0)
812 similarity_map[test_c1 * cluster_info_1.
number + ref_c1] +=
weight * ref_cw * test_cw;
813 similarity_map[test_c1 * cluster_info_1.
number + ref_c2] +=
weight * ref_rev_cw * test_cw;
814 similarity_map[test_c2 * cluster_info_1.
number + ref_c1] +=
weight * ref_cw * test_rev_cw;
815 similarity_map[test_c2 * cluster_info_1.
number + ref_c2] +=
weight * ref_rev_cw * test_rev_cw;
819 ref_normalization[ref_c1] +=
weight * ref_cw * ref_cw;
820 ref_normalization[ref_c2] +=
weight * ref_rev_cw * ref_rev_cw;
824 test_normalization[test_c1] +=
weight * test_cw * test_cw;
825 test_normalization[test_c2] +=
weight * test_rev_cw * test_rev_cw;
829 for (
int testc = 0; testc < cluster_info_2.
number; ++testc)
831 const double test_norm = test_normalization[testc] +
double(test_normalization[testc] == 0.);
832 for (
int refc = 0; refc < cluster_info_1.
number; ++refc)
834 const double ref_norm = ref_normalization[refc] +
double(ref_normalization[refc] == 0.);
835 similarity_map[testc * cluster_info_1.
number + refc] /= std::sqrt(ref_norm * test_norm);
841 std::vector<std::vector<int>> sorted_GPU_matches;
843 sorted_GPU_matches.reserve(cluster_info_2.
number);
845 for (
int testc = 0; testc < cluster_info_2.
number; ++testc)
851 [&](
const int a,
const int b)
853 const double a_weight = similarity_map[testc * cluster_info_1.number + a];
854 const double b_weight = similarity_map[testc * cluster_info_1.number + b];
855 return a_weight > b_weight;
859 size_t wanted_size = 0;
861 for (; wanted_size <
sorter.size(); ++wanted_size)
863 const double match_weight = similarity_map[testc * cluster_info_1.
number +
sorter[wanted_size]];
876 sorter.resize(wanted_size);
878 sorted_GPU_matches.push_back(
sorter);
883 constexpr
int max_iter = 32;
885 std::vector<double> matched_weights(cluster_info_1.
number, -1.);
887 std::vector<size_t> skipped_matching(cluster_info_2.
number, 0);
889 for (
int stop_counter = 0; stop_counter < cluster_info_2.
number && num_iter < max_iter; ++num_iter)
892 for (
int testc = 0; testc <
int(sorted_GPU_matches.size()); ++testc)
894 if (skipped_matching[testc] < sorted_GPU_matches[testc].
size())
896 const int match_c = sorted_GPU_matches[testc][skipped_matching[testc]];
897 const double match_weight = similarity_map[testc * cluster_info_1.
number + match_c];
898 if (match_weight >=
m_min_similarity && match_weight > matched_weights[match_c])
900 const int prev_match = sch.
r2t_table[match_c];
903 ++skipped_matching[prev_match];
907 matched_weights[match_c] = match_weight;
912 ++skipped_matching[testc];
947 char message_buffer[256];
948 snprintf(message_buffer, 256,
949 "%2d: %5d / %5d || %5d / %5d || %3d || %5d | %5d || %5d",
961 return StatusCode::SUCCESS;
974 const bool match_without_shared)
const
982 std::vector<char> match_possibilities(cluster_info_1.
number * cluster_info_2.
number, 1);
994 int ref_c1 = -1, ref_c2 = -1, test_c1 = -1, test_c2 = -1;
1016 for (
int refc = 0; refc < cluster_info_1.
number; ++refc)
1018 if (refc == ref_c1 || refc == ref_c2)
1025 match_possibilities[test_c1 * cluster_info_1.
number + refc] = 0;
1029 match_possibilities[test_c2 * cluster_info_1.
number + refc] = 0;
1033 for (
int testc = 0; testc < cluster_info_2.
number; ++testc)
1035 if (testc == test_c1 || testc == test_c2)
1042 match_possibilities[testc * cluster_info_1.
number + ref_c1] = 0;
1046 match_possibilities[testc * cluster_info_1.
number + ref_c2] = 0;
1052 for (
int testc = 0; testc < cluster_info_2.
number; ++testc)
1054 for (
int refc = 0; refc < cluster_info_1.
number; ++refc)
1056 if (match_possibilities[testc * cluster_info_1.
number + refc] > 0)
1064 for (
int refc = 0; refc < cluster_info_1.
number; ++refc)
1072 for (
int testc = 0; testc < cluster_info_2.
number; ++testc)
1081 char message_buffer[256];
1082 snprintf(message_buffer, 256,
1083 "%2d: %5d / %5d || %5d / %5d || %3d || %5d | %5d || %5d",
1095 return StatusCode::SUCCESS;
1104 #define CALORECGPU_BASIC_CLUSTER_PROPERTY(NAME, ...) \
1105 struct clusters_ ## NAME \
1107 static std::string name() \
1111 static double get_property([[maybe_unused]] const ConstantDataHolder & constant_data, \
1112 [[maybe_unused]] const CaloRecGPU::CellInfoArr & cell_info, \
1113 [[maybe_unused]] const CaloRecGPU::CellStateArr & cell_state, \
1114 [[maybe_unused]] const CaloRecGPU::ClusterInfoArr & cluster_info, \
1115 [[maybe_unused]] const CaloRecGPU::ClusterMomentsArr & cluster_moments, \
1116 [[maybe_unused]] const int cluster_index ) \
1134 #define CALORECGPU_CLUSTER_MOMENT(...) CALORECGPU_CLUSTER_MOMENT_INNER(__VA_ARGS__, 1, 1)
1135 #define CALORECGPU_CLUSTER_MOMENT_INNER(NAME, PROPERTY, UNIT, ...) CALORECGPU_BASIC_CLUSTER_PROPERTY(moments_ ## NAME, return cluster_moments . PROPERTY [cluster_index] / UNIT;)
1211 using BasicClusterProperties = multi_class_holder <
1218 clusters_moments_time,
1219 clusters_moments_FIRST_PHI,
1220 clusters_moments_FIRST_ETA,
1221 clusters_moments_SECOND_R,
1222 clusters_moments_SECOND_LAMBDA,
1223 clusters_moments_DELTA_PHI,
1224 clusters_moments_DELTA_THETA,
1225 clusters_moments_DELTA_ALPHA,
1226 clusters_moments_CENTER_X,
1227 clusters_moments_CENTER_Y,
1228 clusters_moments_CENTER_Z,
1229 clusters_moments_CENTER_MAG,
1230 clusters_moments_CENTER_LAMBDA,
1231 clusters_moments_LATERAL,
1232 clusters_moments_LONGITUDINAL,
1233 clusters_moments_ENG_FRAC_EM,
1234 clusters_moments_ENG_FRAC_MAX,
1235 clusters_moments_ENG_FRAC_CORE,
1236 clusters_moments_FIRST_ENG_DENS,
1237 clusters_moments_SECOND_ENG_DENS,
1238 clusters_moments_ISOLATION,
1239 clusters_moments_ENG_BAD_CELLS,
1240 clusters_moments_N_BAD_CELLS,
1241 clusters_moments_N_BAD_CELLS_CORR,
1242 clusters_moments_BAD_CELLS_CORR_E,
1243 clusters_moments_BADLARQ_FRAC,
1244 clusters_moments_ENG_POS,
1245 clusters_moments_SIGNIFICANCE,
1246 clusters_moments_CELL_SIGNIFICANCE,
1247 clusters_moments_CELL_SIG_SAMPLING,
1248 clusters_moments_AVG_LAR_Q,
1249 clusters_moments_AVG_TILE_Q,
1250 clusters_moments_ENG_BAD_HV_CELLS,
1251 clusters_moments_N_BAD_HV_CELLS,
1252 clusters_moments_PTD,
1253 clusters_moments_MASS,
1254 clusters_moments_EM_PROBABILITY,
1255 clusters_moments_HAD_WEIGHT,
1256 clusters_moments_OOC_WEIGHT,
1257 clusters_moments_DM_WEIGHT,
1258 clusters_moments_TILE_CONFIDENCE_LEVEL,
1259 clusters_moments_SECOND_TIME,
1260 clusters_moments_number_of_cells,
1261 clusters_moments_VERTEX_FRACTION,
1262 clusters_moments_NVERTEX_FRACTION,
1263 clusters_moments_ETACALOFRAME,
1264 clusters_moments_PHICALOFRAME,
1265 clusters_moments_ETA1CALOFRAME,
1266 clusters_moments_PHI1CALOFRAME,
1267 clusters_moments_ETA2CALOFRAME,
1268 clusters_moments_PHI2CALOFRAME,
1269 clusters_moments_ENG_CALIB_TOT,
1270 clusters_moments_ENG_CALIB_OUT_L,
1271 clusters_moments_ENG_CALIB_OUT_M,
1272 clusters_moments_ENG_CALIB_OUT_T,
1273 clusters_moments_ENG_CALIB_DEAD_L,
1274 clusters_moments_ENG_CALIB_DEAD_M,
1275 clusters_moments_ENG_CALIB_DEAD_T,
1276 clusters_moments_ENG_CALIB_EMB0,
1277 clusters_moments_ENG_CALIB_EME0,
1278 clusters_moments_ENG_CALIB_TILEG3,
1279 clusters_moments_ENG_CALIB_DEAD_TOT,
1280 clusters_moments_ENG_CALIB_DEAD_EMB0,
1281 clusters_moments_ENG_CALIB_DEAD_TILE0,
1282 clusters_moments_ENG_CALIB_DEAD_TILEG3,
1283 clusters_moments_ENG_CALIB_DEAD_EME0,
1284 clusters_moments_ENG_CALIB_DEAD_HEC0,
1285 clusters_moments_ENG_CALIB_DEAD_FCAL,
1286 clusters_moments_ENG_CALIB_DEAD_LEAKAGE,
1287 clusters_moments_ENG_CALIB_DEAD_UNCLASS,
1288 clusters_moments_ENG_CALIB_FRAC_EM,
1289 clusters_moments_ENG_CALIB_FRAC_HAD,
1290 clusters_moments_ENG_CALIB_FRAC_REST
1296 using ClusterProperties::BasicClusterProperties;
1300 #define CALORECGPU_COMPARED_CLUSTER_PROPERTY(NAME, ...) \
1301 struct clusters_ ## NAME \
1303 static std::string name() \
1307 static double get_property([[maybe_unused]] const ConstantDataHolder & constant_data, \
1308 [[maybe_unused]] const CaloRecGPU::CellInfoArr & cell_info_1, \
1309 [[maybe_unused]] const CaloRecGPU::CellStateArr & cell_state_1, \
1310 [[maybe_unused]] const CaloRecGPU::ClusterInfoArr & cluster_info_1, \
1311 [[maybe_unused]] const CaloRecGPU::ClusterMomentsArr & cluster_moments_1, \
1312 [[maybe_unused]] const int cluster_index_1, \
1313 [[maybe_unused]] const CaloRecGPU::CellInfoArr & cell_info_2, \
1314 [[maybe_unused]] const CaloRecGPU::CellStateArr & cell_state_2, \
1315 [[maybe_unused]] const CaloRecGPU::ClusterInfoArr & cluster_info_2, \
1316 [[maybe_unused]] const CaloRecGPU::ClusterMomentsArr & cluster_moments_2, \
1317 [[maybe_unused]] const int cluster_index_2) \
1324 return Helpers::regularize_angle( Helpers::regularize_angle(cluster_info_2.clusterPhi[cluster_index_2]) -
1325 Helpers::regularize_angle(cluster_info_1.clusterPhi[cluster_index_1]) );
1329 const double delta_eta = cluster_info_2.clusterEta[cluster_index_2] - cluster_info_1.clusterEta[cluster_index_1];
1330 const double delta_phi = Helpers::regularize_angle( Helpers::regularize_angle(cluster_info_2.clusterPhi[cluster_index_2]) -
1331 Helpers::regularize_angle(cluster_info_1.clusterPhi[cluster_index_1]) );
1337 using ComparedClusterProperties = multi_class_holder <
1339 clusters_delta_phi_in_range,
1346 using ExtraClusterComparisons::ComparedClusterProperties;
1350 #define CALORECGPU_BASIC_CELL_PROPERTY(NAME, ...) \
1351 struct cells_ ## NAME \
1353 static std::string name() \
1357 static double get_property([[maybe_unused]] const ConstantDataHolder & constant_data, \
1358 [[maybe_unused]] const CaloRecGPU::CellInfoArr & cell_info, \
1359 [[maybe_unused]] const CaloRecGPU::CellStateArr & cell_state, \
1360 [[maybe_unused]] const CaloRecGPU::ClusterInfoArr & cluster_info, \
1361 [[maybe_unused]] const CaloRecGPU::ClusterMomentsArr & cluster_moments, \
1362 [[maybe_unused]] const int cell ) \
1376 protect_from_zero(constant_data.m_cell_noise->get_noise(
cell, cell_info.gain[
cell]));
1380 protect_from_zero(constant_data.m_cell_noise->get_noise(
cell, cell_info.gain[
cell])));)
1405 if (
tag.is_part_of_cluster())
1407 float rev_weight = float_unhack(tag.secondary_cluster_weight());
1408 return 1.0f - rev_weight;
1420 if (
tag.is_part_of_cluster())
1422 float rev_weight = float_unhack(tag.secondary_cluster_weight());
1432 using BasicCellProperties = multi_class_holder <
1448 cells_primary_cluster_index,
1449 cells_secondary_cluster_index,
1450 cells_primary_weight,
1451 cells_secondary_weight
1457 using CellProperties::BasicCellProperties;
1461 #define CALORECGPU_BASIC_CELL_TYPE(NAME, ...) \
1462 struct cell_type_ ## NAME \
1464 static std::string name() \
1468 static bool is_type([[maybe_unused]] const ConstantDataHolder & constant_data, \
1469 [[maybe_unused]] const CaloRecGPU::CellInfoArr & cell_info, \
1470 [[maybe_unused]] const CaloRecGPU::CellStateArr & cell_state, \
1471 [[maybe_unused]] const CaloRecGPU::ClusterInfoArr & cluster_info, \
1472 [[maybe_unused]] const CaloRecGPU::ClusterMomentsArr & cluster_moments, \
1473 [[maybe_unused]] const int cell ) \
1485 return tag.is_part_of_cluster() &&
tag.is_shared_between_clusters(); )
1487 using BasicCellTypes = multi_class_holder <
1489 cell_type_intracluster,
1490 cell_type_extracluster,
1500 enum ExtraThingsToCalculate
1503 ClusterComparedSize,
1508 SameSNRCellsCombined,
1515 const std::vector<std::string> histo_strings =
m_moniTool->histogramService()->getHists();
1528 auto string_contains = [](
const std::string & container,
const std::string & contained) ->
bool
1530 return container.find(contained) != std::string::npos;
1533 auto search_lambda = [&](
const auto & prop,
const size_t count,
bool &
check,
1534 const std::string &
str, std::vector<bool> & to_do,
1535 const std::string &
prefix =
"",
const std::string &
suffix =
"")
1539 to_do[
count] =
true;
1544 for (
const auto &
str : histo_strings)
1591 if ( string_contains(
str,
"cluster_size_ref") ||
1592 string_contains(
str,
"cluster_size_test") ||
1593 string_contains(
str,
"cluster_delta_size") ||
1594 string_contains(
str,
"cluster_weighted_size_ref") ||
1595 string_contains(
str,
"cluster_weighted_size_test") ||
1596 string_contains(
str,
"cluster_delta_weighted_size") )
1602 else if ( string_contains(
str,
"cluster_size") ||
1603 string_contains(
str,
"cluster_weighted_size") )
1610 if (string_contains(
str,
"cluster_diff_cells"))
1617 if ( string_contains(
str,
"_num_same_E_cells_ref") ||
1618 string_contains(
str,
"_num_same_E_cells_test") ||
1619 string_contains(
str,
"delta_num_same_E_cells") ||
1620 string_contains(
str,
"_num_same_abs_E_cells_ref") ||
1621 string_contains(
str,
"_num_same_abs_E_cells_test") ||
1622 string_contains(
str,
"delta_num_same_abs_E_cells") )
1627 else if ( string_contains(
str,
"_num_same_E_cells") ||
1628 string_contains(
str,
"_num_same_abs_E_cells") )
1634 if ( string_contains(
str,
"_num_same_SNR_cells_ref") ||
1635 string_contains(
str,
"_num_same_SNR_cells_test") ||
1636 string_contains(
str,
"delta_num_same_SNR_cells") ||
1637 string_contains(
str,
"_num_same_abs_SNR_cells_ref") ||
1638 string_contains(
str,
"_num_same_abs_SNR_cells_test") ||
1639 string_contains(
str,
"delta_num_same_abs_SNR_cells") )
1644 else if ( string_contains(
str,
"_num_same_SNR_cells") ||
1645 string_contains(
str,
"_num_same_abs_SNR_cells") )
1652 return StatusCode::SUCCESS;
1663 const std::string & tool_name)
const
1665 m_numClustersPerTool[tool_name].fetch_add(
clusters->number);
1673 std::vector<per_tool_storage> & store_vec = m_storageHolder.get_for_thread();
1674 store_vec[
index].cell_info = *cell_info;
1675 store_vec[
index].cell_state = *cell_state;
1677 store_vec[
index].moments = *moments;
1684 std::unordered_map<std::string, std::vector<double>> cluster_properties, cell_properties;
1686 std::unordered_map<std::string, long long int> cell_counts;
1688 cluster_properties[
"size"].resize(
clusters->number, 0.);
1689 cluster_properties[
"weighted_size"].resize(
clusters->number, 0.);
1691 long long int same_energy = 0, same_abs_energy = 0, same_snr = 0, same_abs_snr = 0;
1693 std::set<double> energies, snrs;
1700 if (!cell_info->is_valid(
cell))
1705 apply_to_multi_class([&](
const auto & prop,
const size_t i)
1709 cell_properties[prop.name()].push_back(prop.get_property(constant_data, *cell_info, *cell_state, *
clusters, *moments,
cell));
1711 }, BasicCellProperties{});
1713 apply_to_multi_class([&](
const auto & prop,
const size_t i)
1717 cell_counts[prop.name()] += prop.is_type(constant_data, *cell_info, *cell_state, *
clusters, *moments,
cell);
1719 }, BasicCellTypes{});
1721 const float this_energy = cell_info->energy[
cell];
1726 if (energies.count(this_energy))
1731 else if (energies.count(-this_energy))
1735 energies.insert(this_energy);
1741 const float this_snr = this_energy / protect_from_zero(constant_data.
m_cell_noise->get_noise(
cell, cell_info->gain[
cell]));
1743 if (snrs.count(this_snr))
1748 else if (snrs.count(-this_snr))
1752 snrs.insert(this_snr);
1758 const float weight = float_unhack(
tag.secondary_cluster_weight());
1759 if (
tag.is_part_of_cluster())
1761 cluster_properties[
"size"][
tag.cluster_index()] += 1;
1762 cluster_properties[
"weighted_size"][
tag.cluster_index()] += 1.0f -
weight;
1763 if (
tag.is_shared_between_clusters())
1765 cluster_properties[
"size"][
tag.secondary_cluster_index()] += 1;
1766 cluster_properties[
"weighted_size"][
tag.secondary_cluster_index()] +=
weight;
1775 for (
int cluster = 0; cluster <
clusters->number; ++cluster)
1777 apply_to_multi_class([&](
const auto & prop,
const size_t i)
1781 cluster_properties[prop.name()].push_back(prop.get_property(constant_data, *cell_info, *cell_state, *
clusters, *moments, cluster));
1783 }, BasicClusterProperties{});
1788 using scalar_type = decltype(
Monitored::Scalar(
"", std::declval<long long int>()));
1790 std::vector<coll_type> collections;
1791 std::vector<scalar_type> count_scalars;
1792 std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> cluster_group, cell_group, counts_group;
1794 collections.reserve(cluster_properties.size() + cell_properties.size());
1795 count_scalars.reserve(cell_counts.size());
1796 cluster_group.reserve(cluster_properties.size());
1797 cell_group.reserve(cell_properties.size());
1798 counts_group.reserve(cell_counts.size() + 5);
1806 counts_group.push_back(
std::ref(mon_clus_num));
1807 counts_group.push_back(
std::ref(mon_same_energy));
1808 counts_group.push_back(
std::ref(mon_same_abs_energy));
1809 counts_group.push_back(
std::ref(mon_same_snr));
1810 counts_group.push_back(
std::ref(mon_same_abs_snr));
1816 for (
const auto & k_v : cluster_properties)
1819 cluster_group.push_back(
std::ref(collections.back()));
1822 for (
const auto & k_v : cell_properties)
1825 cell_group.push_back(
std::ref(collections.back()));
1828 for (
const auto & k_v : cell_counts)
1831 counts_group.push_back(
std::ref(count_scalars.back()));
1839 return StatusCode::SUCCESS;
1847 const std::string &
prefix,
1848 const bool match_in_energy,
1849 const bool match_without_shared,
1850 const bool match_perfectly)
const
1858 std::vector<per_tool_storage> & store_vec = m_storageHolder.get_for_thread();
1872 if (match_perfectly)
1875 clusters_1, clusters_2, moments_1, moments_2, match_without_shared) );
1880 clusters_1, clusters_2, moments_1, moments_2, match_in_energy, match_without_shared) );
1883 std::unordered_map<std::string, std::vector<double>> cluster_properties, cell_properties;
1885 std::unordered_map<std::string, long long int> cell_counts;
1887 std::vector<double> ref_size_vec(clusters_1.
number, 0.), test_size_vec(clusters_2.
number, 0.),
1888 ref_weighted_size_vec(clusters_1.
number, 0.), test_weighted_size_vec(clusters_2.
number, 0.),
1889 ref_diff_cells(clusters_1.
number, 0.), test_diff_cells(clusters_2.
number, 0.),
1890 ref_diff_cells_weight(clusters_1.
number, 0.), test_diff_cells_weight(clusters_2.
number, 0.);
1893 long long int same_energy_1 = 0, same_energy_2 = 0,
1894 same_abs_energy_1 = 0, same_abs_energy_2 = 0,
1895 same_snr_1 = 0, same_snr_2 = 0,
1896 same_abs_snr_1 = 0, same_abs_snr_2 = 0,
1897 same_cluster_cells_count = 0, diff_cluster_cells_count = 0;
1899 std::set<double> energies_1, energies_2, snrs_1, snrs_2;
1910 apply_to_multi_class([&](
const auto & prop,
const size_t i)
1914 const auto prop_1 = prop.get_property(constant_data, cell_info_1, cell_state_1, clusters_1, moments_1,
cell);
1915 const auto prop_2 = prop.get_property(constant_data, cell_info_2, cell_state_2, clusters_2, moments_2,
cell);
1917 cell_properties[prop.name() +
"_ref"].push_back(prop_1);
1918 cell_properties[prop.name() +
"_test"].push_back(prop_2);
1920 cell_properties[
"delta_" + prop.name()].push_back(prop_2 - prop_1);
1921 cell_properties[
"delta_" + prop.name() +
"_rel_ref"].push_back((prop_2 - prop_1) / protect_from_zero(std::abs(prop_1)));
1922 cell_properties[
"delta_" + prop.name() +
"_rel_test"].push_back((prop_2 - prop_1) / protect_from_zero(std::abs(prop_2)));
1924 }, BasicCellProperties{});
1926 apply_to_multi_class([&](
const auto & prop,
const size_t i)
1930 const auto is_1 = prop.is_type(constant_data, cell_info_1, cell_state_1, clusters_1, moments_1,
cell);
1931 const auto is_2 = prop.is_type(constant_data, cell_info_2, cell_state_2, clusters_2, moments_2,
cell);
1933 cell_counts[
"num_" + prop.name() +
"_cells_ref"] += is_1;
1934 cell_counts[
"num_" + prop.name() +
"_cells_test"] += is_2;
1935 cell_counts[
"delta_num_" + prop.name() +
"_cells"] += is_2 - is_1;
1937 }, BasicCellTypes{});
1939 const float this_energy_1 = cell_info_1.
energy[
cell];
1940 const float this_energy_2 = cell_info_2.
energy[
cell];
1945 if (energies_1.count(this_energy_1))
1948 ++same_abs_energy_1;
1950 else if (energies_1.count(-this_energy_1))
1952 ++same_abs_energy_1;
1954 energies_1.insert(this_energy_1);
1956 if (energies_2.count(this_energy_2))
1959 ++same_abs_energy_2;
1961 else if (energies_2.count(-this_energy_2))
1963 ++same_abs_energy_2;
1965 energies_2.insert(this_energy_2);
1970 const float this_snr_1 = this_energy_1 / protect_from_zero(constant_data.
m_cell_noise->get_noise(
cell, cell_info_1.
gain[
cell]));
1972 if (snrs_1.count(this_snr_1))
1977 else if (snrs_1.count(-this_snr_1))
1981 snrs_1.insert(this_snr_1);
1984 const float this_snr_2 = this_energy_2 / protect_from_zero(constant_data.
m_cell_noise->get_noise(
cell, cell_info_2.
gain[
cell]));
1986 if (snrs_2.count(this_snr_2))
1991 else if (snrs_2.count(-this_snr_2))
1995 snrs_2.insert(this_snr_2);
2003 int ref_c1 = -3, ref_c2 = -3, test_c1 = -3, test_c2 = -3;
2016 const int match_1 = test_c1 < 0 ? -1 : sch.
t2r(test_c1);
2017 const int match_2 = test_c2 < 0 ? -1 : sch.
t2r(test_c2);
2022 const float ref_weight = 1.0f - ref_rev_weight;
2023 const float test_weight = 1.0f - test_rev_weight;
2025 bool cell_is_diff =
false;
2029 ref_size_vec[ref_c1] += 1;
2030 ref_weighted_size_vec[ref_c1] += ref_weight;
2031 #if CALORECGPU_DISABLE_STRICT_MATCHING
2032 if (!(ref_c1 == match_1 || ref_c1 == match_2 || (match_1 < 0 || match_2 < 0)))
2034 if (!(ref_c1 == match_1 || ref_c1 == match_2))
2037 cell_is_diff =
true;
2038 ref_diff_cells[ref_c1] += 1;
2039 ref_diff_cells_weight[ref_c1] += ref_weight;
2045 ref_size_vec[ref_c2] += 1;
2046 ref_weighted_size_vec[ref_c2] += ref_rev_weight;
2047 #if CALORECGPU_DISABLE_STRICT_MATCHING
2048 if (!(ref_c2 == match_1 || ref_c2 == match_2 || (match_1 < 0 || match_2 < 0)))
2050 if (!(ref_c2 == match_1 || ref_c2 == match_2))
2053 cell_is_diff =
true;
2054 ref_diff_cells[ref_c2] += 1;
2055 ref_diff_cells_weight[ref_c2] += ref_rev_weight;
2061 test_size_vec[test_c1] += 1;
2062 test_weighted_size_vec[test_c1] += test_weight;
2063 #if CALORECGPU_DISABLE_STRICT_MATCHING
2064 if (match_1 >= 0 && !(match_1 == ref_c1 || match_1 == ref_c2 || (ref_c1 < 0 || ref_c2 < 0)))
2066 if (match_1 < 0 || !(match_1 == ref_c1 || match_1 == ref_c2))
2069 cell_is_diff =
true;
2070 test_diff_cells[test_c1] += 1;
2071 test_diff_cells_weight[test_c1] += test_weight;
2077 test_size_vec[test_c2] += 1;
2078 test_weighted_size_vec[test_c2] += test_rev_weight;
2079 #if CALORECGPU_DISABLE_STRICT_MATCHING
2080 if (match_2 >= 0 && !(match_2 == ref_c1 || match_2 == ref_c2 || (ref_c1 < 0 || ref_c2 < 0)))
2082 if (match_2 < 0 || !(match_2 == ref_c1 || match_2 == ref_c2))
2085 cell_is_diff =
true;
2086 test_diff_cells[test_c2] += 1;
2087 test_diff_cells_weight[test_c2] += test_rev_weight;
2091 if (!cell_is_diff && (ref_c1 >= 0 || ref_c2 >= 0 || test_c1 >= 0 || test_c2 >= 0))
2093 ++same_cluster_cells_count;
2095 else if (cell_is_diff)
2097 char message_buffer[256];
2098 snprintf(message_buffer, 256,
2099 "%7d | %18f || %6d | %6d | %6d | %6d || %6d | %6d || %016llX | %016llX",
2101 ref_c1, ref_c2, test_c1, test_c2,
2105 ++diff_cluster_cells_count;
2115 for (
int cluster = 0; cluster < clusters_1.
number; ++cluster)
2117 const int match = sch.
r2t(cluster);
2124 apply_to_multi_class([&](
const auto & prop,
const size_t i)
2128 const auto prop_1 = prop.get_property(constant_data, cell_info_1, cell_state_1, clusters_1, moments_1, cluster);
2129 const auto prop_2 = prop.get_property(constant_data, cell_info_2, cell_state_2, clusters_2, moments_2,
match);
2131 cluster_properties[prop.name() +
"_ref"].push_back(prop_1);
2132 cluster_properties[prop.name() +
"_test"].push_back(prop_2);
2134 cluster_properties[
"delta_" + prop.name()].push_back(prop_2 - prop_1);
2135 cluster_properties[
"delta_" + prop.name() +
"_rel_ref"].push_back((prop_2 - prop_1) / protect_from_zero(std::abs(prop_1)));
2136 cluster_properties[
"delta_" + prop.name() +
"_rel_test"].push_back((prop_2 - prop_1) / protect_from_zero(std::abs(prop_2)));
2138 }, BasicClusterProperties{});
2140 apply_to_multi_class([&](
const auto & prop,
const size_t i)
2144 cluster_properties[prop.name()].push_back(prop.get_property(constant_data, cell_info_1, cell_state_1, clusters_1, moments_1, cluster,
2145 cell_info_2, cell_state_2, clusters_2, moments_2,
match));
2147 }, ComparedClusterProperties{});
2151 cluster_properties[
"size_ref"].push_back(ref_size_vec[cluster]);
2152 cluster_properties[
"size_test"].push_back(test_size_vec[
match]);
2153 cluster_properties[
"delta_size"].push_back(ref_size_vec[cluster] - test_size_vec[
match]);
2154 cluster_properties[
"delta_size_rel_ref"].push_back((ref_size_vec[cluster] - test_size_vec[
match]) / protect_from_zero(ref_size_vec[cluster]));
2155 cluster_properties[
"delta_size_rel_test"].push_back((ref_size_vec[cluster] - test_size_vec[
match]) / protect_from_zero(test_size_vec[
match]));
2157 cluster_properties[
"weighted_size_ref"].push_back(ref_weighted_size_vec[cluster]);
2158 cluster_properties[
"weighted_size_test"].push_back(test_weighted_size_vec[
match]);
2159 cluster_properties[
"delta_weighted_size"].push_back(ref_weighted_size_vec[cluster] - test_weighted_size_vec[
match]);
2160 cluster_properties[
"delta_weighted_size_rel_ref"].push_back((ref_weighted_size_vec[cluster] - test_weighted_size_vec[
match]) / protect_from_zero(ref_weighted_size_vec[cluster]));
2161 cluster_properties[
"delta_weighted_size_rel_test"].push_back((ref_weighted_size_vec[cluster] - test_weighted_size_vec[
match]) / protect_from_zero(test_weighted_size_vec[
match]));
2166 cluster_properties[
"diff_cells_ref"].push_back(ref_diff_cells[cluster]);
2167 cluster_properties[
"diff_cells_ref_rel_size"].push_back(ref_diff_cells[cluster] / protect_from_zero(ref_size_vec[cluster]));
2168 cluster_properties[
"diff_cells_test"].push_back(test_diff_cells[
match]);
2169 cluster_properties[
"diff_cells_test_rel_size"].push_back(test_diff_cells[
match] / protect_from_zero(test_size_vec[
match]));
2170 cluster_properties[
"diff_cells"].push_back(ref_diff_cells[cluster] + test_diff_cells[
match]);
2172 cluster_properties[
"weighted_diff_cells_ref"].push_back(ref_diff_cells_weight[cluster]);
2173 cluster_properties[
"weighted_diff_cells_ref_rel_size"].push_back(ref_diff_cells_weight[cluster] / protect_from_zero(ref_weighted_size_vec[cluster]));
2174 cluster_properties[
"weighted_diff_cells_test"].push_back(test_diff_cells_weight[
match]);
2175 cluster_properties[
"weighted_diff_cells_test_rel_size"].push_back(test_diff_cells_weight[
match] / protect_from_zero(test_weighted_size_vec[
match]));
2176 cluster_properties[
"weighted_diff_cells"].push_back(ref_diff_cells_weight[cluster] + test_diff_cells_weight[
match]);
2182 using scalar_type = decltype(
Monitored::Scalar(
"", std::declval<long long int>()));
2184 std::vector<coll_type> collections;
2185 std::vector<scalar_type> count_scalars;
2186 std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> cluster_group, cell_group, counts_group;
2188 collections.reserve(cluster_properties.size() + cell_properties.size());
2189 count_scalars.reserve(cell_counts.size() + 6 * 3);
2190 cluster_group.reserve(cluster_properties.size());
2191 cell_group.reserve(cell_properties.size());
2192 counts_group.reserve(cell_counts.size() + 3 + 6 * 3);
2194 auto add_count_vars = [&](
const std::string &
name,
const long long int ref_num,
const long long int test_num)
2197 counts_group.push_back(
std::ref(count_scalars.back()));
2200 counts_group.push_back(
std::ref(count_scalars.back()));
2203 counts_group.push_back(
std::ref(count_scalars.back()));
2206 add_count_vars(
"num_clusters", clusters_1.
number, clusters_2.
number);
2209 add_count_vars(
"num_same_E_cells", same_energy_1, same_energy_2);
2210 add_count_vars(
"num_same_abs_E_cells", same_abs_energy_1, same_abs_energy_2);
2211 add_count_vars(
"num_same_SNR_cells", same_snr_1, same_snr_2);
2212 add_count_vars(
"num_same_abs_SNR_cells", same_abs_snr_1, same_abs_snr_2);
2218 counts_group.push_back(
std::ref(mon_total_unmatched));
2219 counts_group.push_back(
std::ref(mon_same_cluster_cell));
2220 counts_group.push_back(
std::ref(mon_diff_cluster_cell));
2222 for (
const auto & k_v : cluster_properties)
2225 cluster_group.push_back(
std::ref(collections.back()));
2228 for (
const auto & k_v : cell_properties)
2231 cell_group.push_back(
std::ref(collections.back()));
2234 for (
const auto & k_v : cell_counts)
2237 counts_group.push_back(
std::ref(count_scalars.back()));
2244 return StatusCode::SUCCESS;