Skip to content

Commit

Permalink
Merge pull request #45838 from AuroraPerego/fixResize_pre7
Browse files Browse the repository at this point in the history
fix HGCAL Layer Cluster times in heterogeneous workflows at HLT
  • Loading branch information
cmsbuild authored Nov 4, 2024
2 parents a71bca3 + c733b85 commit 669f2de
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class HGCalLayerClustersFromSoAProducer : public edm::stream::EDProducer<> {
std::unique_ptr<std::vector<reco::BasicCluster>> clusters(new std::vector<reco::BasicCluster>);
clusters->reserve(deviceData->metadata().size());

// Create a vector of <clusters> locations, where each location holds a
// vector of <nCells> floats. These vectors are used to compute the time for
// each cluster.
std::vector<std::vector<float>> times(deviceData->metadata().size());
std::vector<std::vector<float>> timeErrors(deviceData->metadata().size());

for (int i = 0; i < deviceData->metadata().size(); ++i) {
std::vector<std::pair<DetId, float>> thisCluster;
thisCluster.reserve(deviceView.cells(i));
Expand All @@ -75,20 +81,14 @@ class HGCalLayerClustersFromSoAProducer : public edm::stream::EDProducer<> {
std::move(thisCluster),
algoId_);
clusters->back().setSeed(deviceView.seed(i));
times[i].reserve(deviceView.cells(i));
timeErrors[i].reserve(deviceView.cells(i));
}

// Populate hits and fractions required to compute the cluster's time.
// This procedure is complex and involves two SoAs: the original RecHits
// SoA and the clustering algorithm's output SoA. Both SoAs have the same
// cardinality, and crucially, the output SoA includes the cluster index.

// Create a vector of <clusters> locations, where each location holds a
// vector of 16 floats. These vectors are used to compute the time for
// each cluster. The size of 16 is a heuristic to minimize memory
// reallocation and the associated overhead when the vector's capacity
// needs to be extended.
std::vector<std::vector<float>> times(clusters->size(), std::vector<float>(16, 0.0f));
std::vector<std::vector<float>> timeErrors(clusters->size(), std::vector<float>(16, 0.0f));
for (int32_t i = 0; i < soaRecHitsExtra_v.metadata().size(); ++i) {
if (soaRecHitsExtra_v[i].clusterIndex() == -1) {
continue;
Expand All @@ -105,6 +105,7 @@ class HGCalLayerClustersFromSoAProducer : public edm::stream::EDProducer<> {

// Finally, compute and assign the time to each cluster.
std::vector<std::pair<float, float>> cluster_times;
cluster_times.reserve(clusters->size());
hgcalsimclustertime::ComputeClusterTime timeEstimator;
for (unsigned i = 0; i < clusters->size(); ++i) {
if (detector_ != "BH") {
Expand Down

0 comments on commit 669f2de

Please sign in to comment.