Skip to content

Commit

Permalink
TICL: protect from empty seeding region
Browse files Browse the repository at this point in the history
  • Loading branch information
felicepantaleo committed Nov 11, 2024
1 parent b96fd02 commit 5032d9e
Showing 1 changed file with 43 additions and 40 deletions.
83 changes: 43 additions & 40 deletions RecoHGCal/TICL/plugins/TrackstersProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,48 +172,51 @@ void TrackstersProducer::produce(edm::Event& evt, const edm::EventSetup& es) {

std::unordered_map<int, std::vector<int>> seedToTrackstersAssociation;
// if it's regional iteration and there are seeding regions
if (!seeding_regions.empty() and seeding_regions[0].index != -1) {
auto numberOfSeedingRegions = seeding_regions.size();
for (unsigned int i = 0; i < numberOfSeedingRegions; ++i) {
seedToTrackstersAssociation.emplace(seeding_regions[i].index, 0);
if (!seeding_regions.empty()) {
if (seeding_regions[0].index != -1) {
auto numberOfSeedingRegions = seeding_regions.size();
for (unsigned int i = 0; i < numberOfSeedingRegions; ++i) {
seedToTrackstersAssociation.emplace(seeding_regions[i].index, 0);
}
}
}

if (doNose_) {
const auto& layer_clusters_hfnose_tiles = evt.get(layer_clusters_tiles_hfnose_token_);
const typename PatternRecognitionAlgoBaseT<TICLLayerTilesHFNose>::Inputs inputHFNose(
evt, es, layerClusters, inputClusterMask, layerClustersTimes, layer_clusters_hfnose_tiles, seeding_regions);

myAlgoHFNose_->makeTracksters(inputHFNose, *initialResult, seedToTrackstersAssociation);
// Run inference algorithm
inferenceAlgo_->inputData(layerClusters, *initialResult);
inferenceAlgo_->runInference(*initialResult);
myAlgoHFNose_->filter(*result, *initialResult, inputHFNose, seedToTrackstersAssociation);

} else {
const auto& layer_clusters_tiles = evt.get(layer_clusters_tiles_token_);
const typename PatternRecognitionAlgoBaseT<TICLLayerTiles>::Inputs input(
evt, es, layerClusters, inputClusterMask, layerClustersTimes, layer_clusters_tiles, seeding_regions);

myAlgo_->makeTracksters(input, *initialResult, seedToTrackstersAssociation);
// Run inference algorithm
inferenceAlgo_->inputData(layerClusters, *initialResult);
inferenceAlgo_->runInference(*initialResult);
myAlgo_->filter(*result, *initialResult, input, seedToTrackstersAssociation);
}
// Now update the global mask and put it into the event
output_mask->reserve(original_layerclusters_mask.size());
// Copy over the previous state
std::copy(
std::begin(original_layerclusters_mask), std::end(original_layerclusters_mask), std::back_inserter(*output_mask));

for (auto& trackster : *result) {
trackster.setIteration(iterIndex_);
// Mask the used elements, accordingly
for (auto const v : trackster.vertices()) {
// TODO(rovere): for the moment we mask the layer cluster completely. In
// the future, properly compute the fraction of usage.
(*output_mask)[v] = 0.;
if (doNose_) {
const auto& layer_clusters_hfnose_tiles = evt.get(layer_clusters_tiles_hfnose_token_);
const typename PatternRecognitionAlgoBaseT<TICLLayerTilesHFNose>::Inputs inputHFNose(
evt, es, layerClusters, inputClusterMask, layerClustersTimes, layer_clusters_hfnose_tiles, seeding_regions);

myAlgoHFNose_->makeTracksters(inputHFNose, *initialResult, seedToTrackstersAssociation);
// Run inference algorithm
inferenceAlgo_->inputData(layerClusters, *initialResult);
inferenceAlgo_->runInference(*initialResult);
myAlgoHFNose_->filter(*result, *initialResult, inputHFNose, seedToTrackstersAssociation);

} else {
const auto& layer_clusters_tiles = evt.get(layer_clusters_tiles_token_);
const typename PatternRecognitionAlgoBaseT<TICLLayerTiles>::Inputs input(
evt, es, layerClusters, inputClusterMask, layerClustersTimes, layer_clusters_tiles, seeding_regions);

myAlgo_->makeTracksters(input, *initialResult, seedToTrackstersAssociation);
// Run inference algorithm
inferenceAlgo_->inputData(layerClusters, *initialResult);
inferenceAlgo_->runInference(*initialResult);
myAlgo_->filter(*result, *initialResult, input, seedToTrackstersAssociation);
}
// Now update the global mask and put it into the event
output_mask->reserve(original_layerclusters_mask.size());
// Copy over the previous state
std::copy(std::begin(original_layerclusters_mask),
std::end(original_layerclusters_mask),
std::back_inserter(*output_mask));

for (auto& trackster : *result) {
trackster.setIteration(iterIndex_);
// Mask the used elements, accordingly
for (auto const v : trackster.vertices()) {
// TODO(rovere): for the moment we mask the layer cluster completely. In
// the future, properly compute the fraction of usage.
(*output_mask)[v] = 0.;
}
}
}

Expand Down

0 comments on commit 5032d9e

Please sign in to comment.