ATLAS Offline Software
Loading...
Searching...
No Matches
DataHolders.cxx File Reference
#include <vector>
#include <memory>
#include "CaloRecGPU/DataHolders.h"
#include "MacroHelpers.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "CaloDetDescr/CaloDetDescrManager.h"
#include "TileEvent/TileCell.h"
#include "CaloEvent/CaloPrefetch.h"
#include "boost/chrono/chrono.hpp"
#include "boost/chrono/thread_clock.hpp"

Go to the source code of this file.

Macros

#define CALORECGPU_MOMENTS_INPUT_HELPER(VAR_NAME, PROPER_MOMENT, NORMAL_ASSIGN, IS_CALCULATED, MOMENT_NAME, ...)
#define CALORECGPU_MOMENTS_INPUT_HELPER_11(VAR_NAME, MOMENT_NAME)
#define CALORECGPU_MOMENTS_INPUT_HELPER_10(VAR_NAME, MOMENT_NAME)
#define CALORECGPU_MOMENTS_INPUT_HELPER_00(...)
#define CALORECGPU_MOMENTS_INPUT_HELPER_01(...)
#define CALORECGPU_MOMENTS_EXTRA_TAGS_HELPER(VARNAME)
#define CALORECGPU_MOMENTS_TO_GPU_HELPER(VAR_NAME, PROPER_MOMENT, NORMAL_ASSIGN, IS_CALCULATED, MOMENT_NAME, ...)
#define CALORECGPU_MOMENTS_TO_GPU_HELPER_11(VAR_NAME, MOMENT_NAME)
#define CALORECGPU_MOMENTS_TO_GPU_HELPER_10(VAR_NAME, MOMENT_NAME)
#define CALORECGPU_MOMENTS_TO_GPU_HELPER_01(VAR_NAME, MOMENT_NAME)
#define CALORECGPU_MOMENTS_TO_GPU_HELPER_00(PROPER_MOMENT, VAR_NAME, MOMENT_NAME)
#define CALORECGPU_MOMENTS_OUTPUT_HELPER(VAR_NAME, PROPER_MOMENT, NORMAL_ASSIGN, IS_CALCULATED, MOMENT_NAME, ...)
#define CALORECGPU_MOMENTS_OUTPUT_HELPER_11(VAR_NAME, MOMENT_NAME)
#define CALORECGPU_MOMENTS_OUTPUT_HELPER_10(VAR_NAME, MOMENT_NAME)
#define CALORECGPU_MOMENTS_OUTPUT_HELPER_00(...)
#define CALORECGPU_MOMENTS_OUTPUT_HELPER_01(...)

Functions

template<class ReadStateFrom, class OutputCells, class InputCells, class CopyFunc>
static void cell_transfer_helper (ReadStateFrom &state_holder, OutputCells &output_cells, InputCells &input_cells, CopyFunc copy_func, const bool full_copy, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream)
template<class ReadStateFrom, class OutputClusters, class InputClusters, class CopyFunc>
static void cluster_transfer_helper_basic_info (ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, CopyFunc copy_func, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream)
template<class ReadStateFrom, class OutputClusters, class InputClusters, class CopyFunc>
static void cluster_transfer_helper_cell_assignment (ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, CopyFunc copy_func, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream, const int num_total_cells=NCaloCells)
template<class ReadStateFrom, class OutputClusters, class InputClusters, class CopyFunc>
static void cluster_transfer_helper_moments (ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, const MomentsOptionsArray &moments_to_add, CopyFunc copy_func, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream)
template<class ReadStateFrom, class OutputClusters, class InputClusters, class CopyFunc>
static void cluster_transfer_helper (ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, const MomentsOptionsArray &moments_to_add, CopyFunc copy_func, const bool full_copy, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream, const int num_total_cells=CaloRecGPU::NCaloCells)
static void export_cluster_initialize_links (const ClusterInfoArr *clusters, std::vector< std::unique_ptr< CaloClusterCellLink > > &cell_links, const DataLink< CaloCellContainer > &cell_collection_link, const bool skip_validation)
static void export_cluster_process_cells (const ClusterInfoArr *clusters, const CellInfoArr *cells, std::vector< std::unique_ptr< CaloClusterCellLink > > &cell_links, const std::vector< int > &extra_cells_to_fill)
static void export_cluster_sort (const ClusterInfoArr *clusters, std::vector< int > &cluster_order, const bool really_sort)
static void export_cluster_fill_cells_and_basic_info (const ClusterInfoArr *clusters, xAOD::CaloClusterContainer *cluster_collection, std::vector< std::unique_ptr< CaloClusterCellLink > > &cell_links, std::vector< int > &cluster_order, const bool save_uncalibrated)
static void export_cluster_fill_moments (const ClusterInfoArr *clusters, xAOD::CaloClusterContainer *cluster_collection, std::vector< int > &cluster_order, const MomentsOptionsArray &moments_to_add, const bool output_extra_moments)

Macro Definition Documentation

◆ CALORECGPU_MOMENTS_EXTRA_TAGS_HELPER

#define CALORECGPU_MOMENTS_EXTRA_TAGS_HELPER ( VARNAME)
Value:
if (remaining_cells > 0) \
{ \
constexpr int max_size_per_array = (sizeof(float) * NMaxClusters)/sizeof(tag_type); \
copy_func(output_clusters->moments. VARNAME, \
input_clusters->moments. VARNAME, \
sizeof(tag_type) * std::min(remaining_cells, max_size_per_array), stream); \
remaining_cells -= max_size_per_array; \
} (void) 0 \
TagBase::carrier tag_type
constexpr int NMaxClusters

◆ CALORECGPU_MOMENTS_INPUT_HELPER

#define CALORECGPU_MOMENTS_INPUT_HELPER ( VAR_NAME,
PROPER_MOMENT,
NORMAL_ASSIGN,
IS_CALCULATED,
MOMENT_NAME,
... )
Value:
CRGPU_CONCAT(CRGPU_CONCAT(CALORECGPU_MOMENTS_INPUT_HELPER_, NORMAL_ASSIGN), IS_CALCULATED) (VAR_NAME, MOMENT_NAME)
#define CRGPU_CONCAT(X, Y)
Helper macro, concatenates two arguments.

◆ CALORECGPU_MOMENTS_INPUT_HELPER_00

#define CALORECGPU_MOMENTS_INPUT_HELPER_00 ( ...)

◆ CALORECGPU_MOMENTS_INPUT_HELPER_01

#define CALORECGPU_MOMENTS_INPUT_HELPER_01 ( ...)

◆ CALORECGPU_MOMENTS_INPUT_HELPER_10

#define CALORECGPU_MOMENTS_INPUT_HELPER_10 ( VAR_NAME,
MOMENT_NAME )
Value:
if (output_extra_moments && moments_to_add[xAOD::CaloCluster:: MOMENT_NAME]) \
{ \
m_clusters->moments. VAR_NAME [cluster_number] = cluster->getMomentValue(xAOD::CaloCluster:: MOMENT_NAME ); \
}

◆ CALORECGPU_MOMENTS_INPUT_HELPER_11

#define CALORECGPU_MOMENTS_INPUT_HELPER_11 ( VAR_NAME,
MOMENT_NAME )
Value:
if (moments_to_add[xAOD::CaloCluster:: MOMENT_NAME]) \
{ \
m_clusters->moments. VAR_NAME [cluster_number] = cluster->getMomentValue(xAOD::CaloCluster:: MOMENT_NAME ); \
}

◆ CALORECGPU_MOMENTS_OUTPUT_HELPER

#define CALORECGPU_MOMENTS_OUTPUT_HELPER ( VAR_NAME,
PROPER_MOMENT,
NORMAL_ASSIGN,
IS_CALCULATED,
MOMENT_NAME,
... )
Value:
CRGPU_CONCAT(CRGPU_CONCAT(CALORECGPU_MOMENTS_OUTPUT_HELPER_, NORMAL_ASSIGN), IS_CALCULATED) (VAR_NAME, MOMENT_NAME)

◆ CALORECGPU_MOMENTS_OUTPUT_HELPER_00

#define CALORECGPU_MOMENTS_OUTPUT_HELPER_00 ( ...)

◆ CALORECGPU_MOMENTS_OUTPUT_HELPER_01

#define CALORECGPU_MOMENTS_OUTPUT_HELPER_01 ( ...)

◆ CALORECGPU_MOMENTS_OUTPUT_HELPER_10

#define CALORECGPU_MOMENTS_OUTPUT_HELPER_10 ( VAR_NAME,
MOMENT_NAME )
Value:
if (output_extra_moments && moments_to_add[xAOD::CaloCluster:: MOMENT_NAME]) \
{ \
cluster->insertMoment(xAOD::CaloCluster:: MOMENT_NAME , clusters->moments. VAR_NAME [cluster_index]); \
}

◆ CALORECGPU_MOMENTS_OUTPUT_HELPER_11

#define CALORECGPU_MOMENTS_OUTPUT_HELPER_11 ( VAR_NAME,
MOMENT_NAME )
Value:
if (moments_to_add[xAOD::CaloCluster:: MOMENT_NAME]) \
{ \
cluster->insertMoment(xAOD::CaloCluster:: MOMENT_NAME , clusters->moments. VAR_NAME [cluster_index]); \
}

◆ CALORECGPU_MOMENTS_TO_GPU_HELPER

#define CALORECGPU_MOMENTS_TO_GPU_HELPER ( VAR_NAME,
PROPER_MOMENT,
NORMAL_ASSIGN,
IS_CALCULATED,
MOMENT_NAME,
... )
Value:
CRGPU_CONCAT(CRGPU_CONCAT(CALORECGPU_MOMENTS_TO_GPU_HELPER_, PROPER_MOMENT), IS_CALCULATED) (VAR_NAME, MOMENT_NAME)

◆ CALORECGPU_MOMENTS_TO_GPU_HELPER_00

#define CALORECGPU_MOMENTS_TO_GPU_HELPER_00 ( PROPER_MOMENT,
VAR_NAME,
MOMENT_NAME )
Value:
{ \
moments_copy_helper(output_clusters->moments. VAR_NAME, input_clusters->moments. VAR_NAME); \
}

◆ CALORECGPU_MOMENTS_TO_GPU_HELPER_01

#define CALORECGPU_MOMENTS_TO_GPU_HELPER_01 ( VAR_NAME,
MOMENT_NAME )
Value:
moments_copy_helper(output_clusters->moments. VAR_NAME, input_clusters->moments. VAR_NAME);

◆ CALORECGPU_MOMENTS_TO_GPU_HELPER_10

#define CALORECGPU_MOMENTS_TO_GPU_HELPER_10 ( VAR_NAME,
MOMENT_NAME )
Value:
moments_to_add[xAOD::CaloCluster:: MOMENT_NAME ] ) \
{ \
moments_copy_helper(output_clusters->moments. VAR_NAME, input_clusters->moments. VAR_NAME); \
}

◆ CALORECGPU_MOMENTS_TO_GPU_HELPER_11

#define CALORECGPU_MOMENTS_TO_GPU_HELPER_11 ( VAR_NAME,
MOMENT_NAME )
Value:
if (moments_to_add[xAOD::CaloCluster:: MOMENT_NAME ]) \
{ \
moments_copy_helper(output_clusters->moments. VAR_NAME, input_clusters->moments. VAR_NAME); \
}

Function Documentation

◆ cell_transfer_helper()

template<class ReadStateFrom, class OutputCells, class InputCells, class CopyFunc>
void cell_transfer_helper ( ReadStateFrom & state_holder,
OutputCells & output_cells,
InputCells & input_cells,
CopyFunc copy_func,
const bool full_copy,
CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream )
static

Definition at line 579 of file DataHolders.cxx.

585{
586 if (full_copy)
587 {
588 copy_func(output_cells, input_cells, sizeof(CaloRecGPU::CellInfoArr), stream);
589 }
590 else
591 {
592 copy_func(output_cells->gain,
593 input_cells->gain,
594 sizeof(unsigned char) * state_holder->number, stream);
595
596 copy_func(output_cells->energy,
597 input_cells->energy,
598 sizeof(float) * state_holder->number, stream);
599
600 copy_func(output_cells->time,
601 input_cells->time,
602 sizeof(float) * state_holder->number, stream);
603
604 copy_func(output_cells->qualityProvenance,
605 input_cells->qualityProvenance,
606 sizeof(QualityProvenance::carrier) * state_holder->number, stream);
607
608 copy_func(output_cells->hashID,
609 input_cells->hashID,
610 sizeof(int) * state_holder->number, stream);
611
612 copy_func(output_cells->hashIDToCollection,
613 input_cells->hashIDToCollection,
614 sizeof(int) * CaloRecGPU::NCaloCells, stream);
615
616 }
617}
constexpr int NCaloCells
Contains the per-event cell information: energy, timing, gain, quality and provenance.

◆ cluster_transfer_helper()

template<class ReadStateFrom, class OutputClusters, class InputClusters, class CopyFunc>
void cluster_transfer_helper ( ReadStateFrom & state_holder,
OutputClusters & output_clusters,
InputClusters & input_clusters,
const MomentsOptionsArray & moments_to_add,
CopyFunc copy_func,
const bool full_copy,
CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream,
const int num_total_cells = CaloRecGPU::NCaloCells )
static

Definition at line 770 of file DataHolders.cxx.

778{
779 if (full_copy)
780 {
781 copy_func(output_clusters, input_clusters, sizeof(CaloRecGPU::ClusterInfoArr), stream);
782 }
783 else
784 {
785 cluster_transfer_helper_basic_info(state_holder, output_clusters, input_clusters, copy_func, stream);
786
787 cluster_transfer_helper_cell_assignment(state_holder, output_clusters, input_clusters, copy_func, stream, num_total_cells);
788
789 cluster_transfer_helper_moments(state_holder, output_clusters, input_clusters, moments_to_add, copy_func, stream);
790 }
791}
static void cluster_transfer_helper_moments(ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, const MomentsOptionsArray &moments_to_add, CopyFunc copy_func, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream)
static void cluster_transfer_helper_cell_assignment(ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, CopyFunc copy_func, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream, const int num_total_cells=NCaloCells)
static void cluster_transfer_helper_basic_info(ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, CopyFunc copy_func, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream)

◆ cluster_transfer_helper_basic_info()

template<class ReadStateFrom, class OutputClusters, class InputClusters, class CopyFunc>
void cluster_transfer_helper_basic_info ( ReadStateFrom & state_holder,
OutputClusters & output_clusters,
InputClusters & input_clusters,
CopyFunc copy_func,
CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream )
static

Definition at line 620 of file DataHolders.cxx.

625{
626
627 if (state_holder->has_basic_info())
628 {
629 copy_func(output_clusters->clusterEnergy,
630 input_clusters->clusterEnergy,
631 sizeof(float) * state_holder->number, stream);
632
633 copy_func(output_clusters->clusterEt,
634 input_clusters->clusterEt,
635 sizeof(float) * state_holder->number, stream);
636
637 copy_func(output_clusters->clusterEta,
638 input_clusters->clusterEta,
639 sizeof(float) * state_holder->number, stream);
640
641 copy_func(output_clusters->clusterPhi,
642 input_clusters->clusterPhi,
643 sizeof(float) * state_holder->number, stream);
644
645 copy_func(output_clusters->seedCellIndex,
646 input_clusters->seedCellIndex,
647 sizeof(int) * state_holder->number, stream);
648 }
649
650}

◆ cluster_transfer_helper_cell_assignment()

template<class ReadStateFrom, class OutputClusters, class InputClusters, class CopyFunc>
void cluster_transfer_helper_cell_assignment ( ReadStateFrom & state_holder,
OutputClusters & output_clusters,
InputClusters & input_clusters,
CopyFunc copy_func,
CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream,
const int num_total_cells = NCaloCells )
static

Definition at line 653 of file DataHolders.cxx.

659{
660
661 if (state_holder->has_cells_per_cluster())
662 {
663 copy_func(output_clusters->cellsPrefixSum,
664 input_clusters->cellsPrefixSum,
665 sizeof(int) * (state_holder->number + 1), stream);
666
667 copy_func(output_clusters->cells.indices,
668 input_clusters->cells.indices,
669 sizeof(int) * state_holder->number_cells, stream);
670
671 copy_func(output_clusters->cellWeights,
672 input_clusters->cellWeights,
673 sizeof(float) * state_holder->number_cells, stream);
674
675 copy_func(output_clusters->clusterIndices,
676 input_clusters->clusterIndices,
677 sizeof(int) * state_holder->number_cells, stream);
678
679 int remaining_cells = num_total_cells;
680
681#define CALORECGPU_MOMENTS_EXTRA_TAGS_HELPER(VARNAME) \
682 if (remaining_cells > 0) \
683 { \
684 constexpr int max_size_per_array = (sizeof(float) * NMaxClusters)/sizeof(tag_type); \
685 copy_func(output_clusters->moments. VARNAME, \
686 input_clusters->moments. VARNAME, \
687 sizeof(tag_type) * std::min(remaining_cells, max_size_per_array), stream); \
688 remaining_cells -= max_size_per_array; \
689 } (void) 0 \
690
697
698 }
699 else if (state_holder->state != CaloRecGPU::ClusterInformationState::None)
700 {
701 copy_func(output_clusters->cells.tags,
702 input_clusters->cells.tags,
703 sizeof(tag_type) * state_holder->number_cells, stream);
704
705 }
706}
#define CALORECGPU_MOMENTS_EXTRA_TAGS_HELPER(VARNAME)

◆ cluster_transfer_helper_moments()

template<class ReadStateFrom, class OutputClusters, class InputClusters, class CopyFunc>
void cluster_transfer_helper_moments ( ReadStateFrom & state_holder,
OutputClusters & output_clusters,
InputClusters & input_clusters,
const MomentsOptionsArray & moments_to_add,
CopyFunc copy_func,
CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream )
static

Definition at line 709 of file DataHolders.cxx.

715{
716 if (state_holder->has_moments())
717 {
718 auto moments_copy_helper = [&](auto & output_arr, const auto & input_arr)
719 {
720 if constexpr(std::is_pointer_v<std::decay_t<decltype(*input_arr)>>)
721 //This is a per-sampling array.
722 {
723 for (int i = 0; i < CaloRecGPU::NumSamplings; ++i)
724 {
725 copy_func(output_arr[i],
726 input_arr[i],
727 sizeof(decltype(input_arr[0][0])) * state_holder->number,
728 stream);
729 }
730 }
731 else
732 {
733 copy_func(output_arr,
734 input_arr,
735 sizeof(decltype(input_arr[0])) * state_holder->number,
736 stream);
737 }
738 };
739
740#define CALORECGPU_MOMENTS_TO_GPU_HELPER(VAR_NAME, PROPER_MOMENT, NORMAL_ASSIGN, IS_CALCULATED, MOMENT_NAME, ...) \
741 CRGPU_CONCAT(CRGPU_CONCAT(CALORECGPU_MOMENTS_TO_GPU_HELPER_, PROPER_MOMENT), IS_CALCULATED) (VAR_NAME, MOMENT_NAME)
742
743#define CALORECGPU_MOMENTS_TO_GPU_HELPER_11(VAR_NAME, MOMENT_NAME) \
744 if (moments_to_add[xAOD::CaloCluster:: MOMENT_NAME ]) \
745 { \
746 moments_copy_helper(output_clusters->moments. VAR_NAME, input_clusters->moments. VAR_NAME); \
747 }
748
749#define CALORECGPU_MOMENTS_TO_GPU_HELPER_10(VAR_NAME, MOMENT_NAME) \
750 if ( state_holder->state == CaloRecGPU::ClusterInformationState::WithExtraMoments && \
751 moments_to_add[xAOD::CaloCluster:: MOMENT_NAME ] ) \
752 { \
753 moments_copy_helper(output_clusters->moments. VAR_NAME, input_clusters->moments. VAR_NAME); \
754 }
755
756#define CALORECGPU_MOMENTS_TO_GPU_HELPER_01( VAR_NAME, MOMENT_NAME) \
757 moments_copy_helper(output_clusters->moments. VAR_NAME, input_clusters->moments. VAR_NAME);
758
759#define CALORECGPU_MOMENTS_TO_GPU_HELPER_00(PROPER_MOMENT, VAR_NAME, MOMENT_NAME) \
760 if (state_holder->state == CaloRecGPU::ClusterInformationState::WithExtraMoments) \
761 { \
762 moments_copy_helper(output_clusters->moments. VAR_NAME, input_clusters->moments. VAR_NAME); \
763 }
764
766 }
767}
#define CALORECGPU_MOMENTS_TO_GPU_HELPER(VAR_NAME, PROPER_MOMENT, NORMAL_ASSIGN, IS_CALCULATED, MOMENT_NAME,...)
#define CALORECGPU_FORALLMOMENTS_INSTANTIATE(MACRO,...)
constexpr int NumSamplings

◆ export_cluster_fill_cells_and_basic_info()

void export_cluster_fill_cells_and_basic_info ( const ClusterInfoArr * clusters,
xAOD::CaloClusterContainer * cluster_collection,
std::vector< std::unique_ptr< CaloClusterCellLink > > & cell_links,
std::vector< int > & cluster_order,
const bool save_uncalibrated )
static

Definition at line 1052 of file DataHolders.cxx.

1057{
1058 const int total_size = (cluster_order.size() ? cluster_order.size() : clusters->number);
1059 for (int i = 0; i < total_size; ++i)
1060 {
1061 const int cluster_index = (cluster_order.size() ? cluster_order[i] : i);
1062
1063 if (cell_links[cluster_index] != nullptr && cell_links[cluster_index]->size() > 0)
1064 {
1065 xAOD::CaloCluster * cluster = new xAOD::CaloCluster();
1066 cluster_collection->push_back(cluster);
1067
1068 cluster->addCellLink(std::move(cell_links[cluster_index]));
1069
1070 if (clusters->has_basic_info())
1071 {
1072
1073 cluster->setE (clusters->clusterEnergy[cluster_index]);
1074 cluster->setEta(clusters->clusterEta [cluster_index]);
1075 cluster->setPhi(clusters->clusterPhi [cluster_index]);
1076
1077 if (save_uncalibrated)
1078 {
1079 cluster->setRawE(cluster->calE());
1080 cluster->setRawEta(cluster->calEta());
1081 cluster->setRawPhi(cluster->calPhi());
1082 cluster->setRawM(cluster->calM());
1083 }
1084 }
1085 }
1086 }
1087}
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void setRawEta(flt_t)
Set for signal state UNCALIBRATED.
void setRawPhi(flt_t)
Set for signal state UNCALIBRATED.
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
flt_t calPhi() const
Get in signal state CALIBRATED.
void addCellLink(CaloClusterCellLink *CCCL)
void setRawE(flt_t)
Set Energy for signal state UNCALIBRATED.
void setRawM(flt_t)
Set mass for singal state UNCALIBRATED.
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
flt_t calEta() const
Get in signal state CALIBRATED.
flt_t calE() const
Geet Energy in signal state CALIBRATED.
flt_t calM() const
Get mass in signal state CALIBRATED.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ export_cluster_fill_moments()

void export_cluster_fill_moments ( const ClusterInfoArr * clusters,
xAOD::CaloClusterContainer * cluster_collection,
std::vector< int > & cluster_order,
const MomentsOptionsArray & moments_to_add,
const bool output_extra_moments )
static

Definition at line 1089 of file DataHolders.cxx.

1094{
1095 if (clusters->has_moments())
1096 {
1097 const int total_size = (cluster_order.size() ? cluster_order.size() : clusters->number);
1098 for (int i = 0; i < total_size; ++i)
1099 {
1100 const int cluster_index = (cluster_order.size() ? cluster_order[i] : i);
1101
1102 xAOD::CaloCluster * cluster = (*cluster_collection)[cluster_index];
1103
1104 cluster->clearSamplingData();
1105
1106 uint32_t sampling_pattern = 0;
1107 for (int sampl = 0; sampl < NumSamplings; ++sampl)
1108 {
1109 const int cells_per_sampling = clusters->moments.nCellSampling[sampl][cluster_index];
1110
1111 if (cells_per_sampling > 0)
1112 {
1113 sampling_pattern |= (0x1U << sampl);
1114 }
1115 }
1116
1117 if (clusters->moments.nExtraCellSampling[cluster_index] > 0)
1118 {
1119 sampling_pattern |= (1U << static_cast<unsigned int>(CaloSampling::EME2));
1120 }
1121
1122 cluster->setSamplingPattern(sampling_pattern);
1123
1124 for (int s = 0; s < NumSamplings; ++s)
1125 {
1126 if (sampling_pattern & (1U << s))
1127 {
1128 cluster->setNumberCellsInSampling(static_cast<CaloSampling::CaloSample>(s), clusters->moments.nCellSampling[s][cluster_index], false);
1129 }
1130 }
1131
1132 if (clusters->moments.nExtraCellSampling[cluster_index] > 0)
1133 {
1134 cluster->setNumberCellsInSampling(CaloSampling::EME2, clusters->moments.nExtraCellSampling[cluster_index], true);
1135 }
1136
1137 for (int s = 0; s < NumSamplings; ++s)
1138 {
1139 if (sampling_pattern & (1U << s))
1140 {
1141 cluster->setEnergy(static_cast<CaloSampling::CaloSample>(s), clusters->moments.energyPerSample[s][cluster_index]);
1142 }
1143 }
1144 for (int s = 0; s < NumSamplings; ++s)
1145 {
1146 if (sampling_pattern & (1U << s))
1147 {
1148 cluster->setEmax(static_cast<CaloSampling::CaloSample>(s), clusters->moments.maxEPerSample[s][cluster_index]);
1149 }
1150 }
1151 for (int s = 0; s < NumSamplings; ++s)
1152 {
1153 if (sampling_pattern & (1U << s))
1154 {
1155 cluster->setEtamax(static_cast<CaloSampling::CaloSample>(s), clusters->moments.maxEtaPerSample[s][cluster_index] );
1156 }
1157 }
1158 for (int s = 0; s < NumSamplings; ++s)
1159 {
1160 if (sampling_pattern & (1U << s))
1161 {
1162 cluster->setPhimax(static_cast<CaloSampling::CaloSample>(s), clusters->moments.maxPhiPerSample[s][cluster_index]);
1163 }
1164 }
1165 for (int s = 0; s < NumSamplings; ++s)
1166 {
1167 if (sampling_pattern & (1U << s))
1168 {
1169 cluster->setEta(static_cast<CaloSampling::CaloSample>(s), clusters->moments.etaPerSample[s][cluster_index]);
1170 }
1171 }
1172 for (int s = 0; s < NumSamplings; ++s)
1173 {
1174 if (sampling_pattern & (1U << s))
1175 {
1176 cluster->setPhi(static_cast<CaloSampling::CaloSample>(s), clusters->moments.phiPerSample[s][cluster_index]);
1177 }
1178 }
1179
1180 cluster->setTime(clusters->moments.time[cluster_index]);
1181 cluster->setSecondTime(clusters->moments.secondTime[cluster_index]);
1182
1183#define CALORECGPU_MOMENTS_OUTPUT_HELPER(VAR_NAME, PROPER_MOMENT, NORMAL_ASSIGN, IS_CALCULATED, MOMENT_NAME, ...) \
1184 CRGPU_CONCAT(CRGPU_CONCAT(CALORECGPU_MOMENTS_OUTPUT_HELPER_, NORMAL_ASSIGN), IS_CALCULATED) (VAR_NAME, MOMENT_NAME)
1185
1186#define CALORECGPU_MOMENTS_OUTPUT_HELPER_11(VAR_NAME, MOMENT_NAME) \
1187 if (moments_to_add[xAOD::CaloCluster:: MOMENT_NAME]) \
1188 { \
1189 cluster->insertMoment(xAOD::CaloCluster:: MOMENT_NAME , clusters->moments. VAR_NAME [cluster_index]); \
1190 }
1191
1192#define CALORECGPU_MOMENTS_OUTPUT_HELPER_10(VAR_NAME, MOMENT_NAME) \
1193 if (output_extra_moments && moments_to_add[xAOD::CaloCluster:: MOMENT_NAME]) \
1194 { \
1195 cluster->insertMoment(xAOD::CaloCluster:: MOMENT_NAME , clusters->moments. VAR_NAME [cluster_index]); \
1196 }
1197
1198#define CALORECGPU_MOMENTS_OUTPUT_HELPER_00(...)
1199#define CALORECGPU_MOMENTS_OUTPUT_HELPER_01(...)
1200
1202 }
1203 }
1204}
#define CALORECGPU_MOMENTS_OUTPUT_HELPER(VAR_NAME, PROPER_MOMENT, NORMAL_ASSIGN, IS_CALCULATED, MOMENT_NAME,...)
void setSecondTime(flt_t stime)
Set second moment of cell timing distribution.
void setTime(flt_t)
Set cluster time.
bool setPhimax(const CaloSample sampling, const float phiMax)
Set the phi of the cell with the highest energy in a particular sampling.
bool setEmax(const CaloSample sampling, const float eMax)
Set the Energy of the cell with the highest energy in a particular sampling.
bool setEnergy(const CaloSample sampling, const float e)
Set energy for a given sampling. Returns false if the sample isn't part of the cluster.
void setSamplingPattern(const unsigned sp, const bool clearSamplingVars=false)
Set sampling pattern (one bit per sampling.
void setNumberCellsInSampling(CaloSampling::CaloSample samp, int ncells, bool isInnerWheel=false)
Set the number of cells in a sampling layer.
bool setEtamax(const CaloSample sampling, const float etaMax)
Set the eta of the cell with the highest energy in a particular sampling.
void clearSamplingData()
Clear the sampling data.
setEventNumber uint32_t

◆ export_cluster_initialize_links()

void export_cluster_initialize_links ( const ClusterInfoArr * clusters,
std::vector< std::unique_ptr< CaloClusterCellLink > > & cell_links,
const DataLink< CaloCellContainer > & cell_collection_link,
const bool skip_validation )
static

Definition at line 889 of file DataHolders.cxx.

893{
894 cell_links.reserve(clusters->number);
895
896 for (int i = 0; i < clusters->number; ++i)
897 {
898 if (skip_validation || clusters->seedCellIndex[i] >= 0)
899 {
900 cell_links.emplace_back(std::make_unique<CaloClusterCellLink>(cell_collection_link));
901 cell_links.back()->reserve(256);
902 //To be adjusted.
903 }
904 else
905 {
906 cell_links.emplace_back(nullptr);
907 //The excluded clusters don't have any cells.
908 }
909 }
910}

◆ export_cluster_process_cells()

void export_cluster_process_cells ( const ClusterInfoArr * clusters,
const CellInfoArr * cells,
std::vector< std::unique_ptr< CaloClusterCellLink > > & cell_links,
const std::vector< int > & extra_cells_to_fill )
static

Definition at line 915 of file DataHolders.cxx.

919{
920
921 std::vector<int> real_cells_to_fill;
922
923 if (cells->number == CaloRecGPU::NCaloCells && !cells->all_cells_valid)
924 {
925 real_cells_to_fill.reserve(extra_cells_to_fill.size());
926
927 for (const int cell : extra_cells_to_fill)
928 {
929 if (cells->hashIDToCollection[cell] <= 0)
930 {
931 real_cells_to_fill.push_back(cell);
932 }
933 }
934 }
935
936 auto corrected_index_to_real_index = [&](const int index)
937 {
938 if (cells->all_cells_valid)
939 {
940 return index;
941 }
942
943 int ret = index;
944
945 for (const int cell : real_cells_to_fill)
946 {
947 ret -= (index > cell);
948 }
949
950 return ret;
951 };
952
953 if (clusters->has_cells_per_cluster())
954 {
955 for (int i = 0; i < clusters->number_cells; ++i)
956 {
957 std::unique_ptr<CaloClusterCellLink> & this_link_ptr = cell_links[clusters->clusterIndices[i]];
958 if (this_link_ptr)
959 //This should always be true at this stage,
960 //but guarding against any potentially invalidated clusters.
961 {
962 this_link_ptr->addCell(corrected_index_to_real_index(clusters->cells.indices[i]), clusters->cellWeights[i]);
963 }
964 }
965 }
966 else
967 {
968 for (int i = 0; i < clusters->number; ++i)
969 {
970 if (cell_links[i])
971 {
972 cell_links[i]->addCell(corrected_index_to_real_index(clusters->seedCellIndex[i]), 1);
973 //Seed cells aren't shared, by construction.
974 }
975 }
976
977 for (int i = 0; i < clusters->number_cells; ++i)
978 {
979 const ClusterTag this_tag = clusters->cells.tags[i];
980
981 if (this_tag.is_part_of_cluster())
982 {
983 const int this_cell_index = corrected_index_to_real_index(i);
984
985 const int this_index = this_tag.cluster_index();
986 const int32_t weight_pattern = this_tag.secondary_cluster_weight();
987
988 float tempf = 1.0f;
989
990 std::memcpy(&tempf, &weight_pattern, sizeof(float));
991
992 const float reverse_weight = tempf;
993
994 const float this_weight = 1.0f - reverse_weight;
995
996 if (cell_links[this_index] && clusters->seedCellIndex[this_index] != i)
997 {
998 cell_links[this_index]->addCell(this_cell_index, this_weight);
999 }
1000
1001 if (this_tag.is_shared_between_clusters())
1002 {
1003 const int other_index = this_tag.secondary_cluster_index();
1004 if (cell_links[other_index] && clusters->seedCellIndex[other_index] != i)
1005 {
1006 cell_links[other_index]->addCell(this_cell_index, reverse_weight);
1007 }
1008 }
1009 }
1010 }
1011 }
1012}
Definition index.py:1
The class that actually expresses the cluster assignment.
constexpr int32_t secondary_cluster_index() const
constexpr int32_t secondary_cluster_weight() const
constexpr bool is_shared_between_clusters() const
constexpr bool is_part_of_cluster() const
constexpr int32_t cluster_index() const

◆ export_cluster_sort()

void export_cluster_sort ( const ClusterInfoArr * clusters,
std::vector< int > & cluster_order,
const bool really_sort )
static

Definition at line 1014 of file DataHolders.cxx.

1017{
1018 if (really_sort)
1019 {
1020 cluster_order.resize(clusters->number);
1021
1022 std::iota(cluster_order.begin(), cluster_order.end(), 0);
1023
1024 std::sort(cluster_order.begin(), cluster_order.end(), [&](const int a, const int b) -> bool
1025 {
1026 const bool a_valid = clusters->seedCellIndex[a] >= 0;
1027 const bool b_valid = clusters->seedCellIndex[b] >= 0;
1028 if (a_valid && b_valid)
1029 {
1030 return (clusters->clusterEt[a] > clusters->clusterEt[b]);
1031 }
1032 else if (a_valid)
1033 {
1034 return true;
1035 }
1036 else if (b_valid)
1037 {
1038 return false;
1039 }
1040 else
1041 {
1042 return b > a;
1043 }
1044 } );
1045 }
1046 else
1047 {
1048 cluster_order.clear();
1049 }
1050}
static Double_t a
if(febId1==febId2)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.