CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ticl::PatternRecognitionbyCA< TILES > Class Template Referencefinal

#include <PatternRecognitionbyCA.h>

Inheritance diagram for ticl::PatternRecognitionbyCA< TILES >:
ticl::PatternRecognitionAlgoBaseT< TILES >

Public Member Functions

void emptyTrackstersFromSeedsTRK (std::vector< Trackster > &tracksters, std::unordered_map< int, std::vector< int >> &seedToTracksterAssociation, const edm::ProductID &collectionID) const
 
void energyRegressionAndID (const std::vector< reco::CaloCluster > &layerClusters, std::vector< Trackster > &result)
 
void makeTracksters (const typename PatternRecognitionAlgoBaseT< TILES >::Inputs &input, std::vector< Trackster > &result, std::unordered_map< int, std::vector< int >> &seedToTracksterAssociation) override
 
 PatternRecognitionbyCA (const edm::ParameterSet &conf, const CacheBase *cache, edm::ConsumesCollector iC)
 
 ~PatternRecognitionbyCA () override
 
- Public Member Functions inherited from ticl::PatternRecognitionAlgoBaseT< TILES >
virtual void makeTracksters (const Inputs &input, std::vector< Trackster > &result, std::unordered_map< int, std::vector< int >> &seedToTracksterAssociation)=0
 
 PatternRecognitionAlgoBaseT (const edm::ParameterSet &conf, const CacheBase *cache, edm::ConsumesCollector)
 
virtual ~PatternRecognitionAlgoBaseT ()
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &iDesc)
 

Private Member Functions

void mergeTrackstersTRK (const std::vector< Trackster > &, const std::vector< reco::CaloCluster > &, std::vector< Trackster > &, std::unordered_map< int, std::vector< int >> &seedToTracksterAssociation) const
 

Private Attributes

edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeomToken_
 
bool check_missing_layers_ = false
 
const std::string eidInputName_
 
const float eidMinClusterEnergy_
 
const int eidNClusters_
 
const int eidNLayers_
 
const std::string eidOutputNameEnergy_
 
const std::string eidOutputNameId_
 
tensorflow::Session * eidSession_
 
const double energy_em_over_total_threshold_
 
const float etaLimitIncreaseWindow_
 
const std::vector< int > filter_on_categories_
 
const float max_delta_time_
 
const double max_longitudinal_sigmaPCA_
 
const int max_missing_layers_in_trackster_
 
const unsigned int max_out_in_hops_
 
const int min_clusters_per_ntuplet_
 
const float min_cos_pointing_
 
const float min_cos_theta_
 
const unsigned int min_layers_per_trackster_
 
const bool oneTracksterPerTrackSeed_
 
const bool out_in_dfs_
 
const double pid_threshold_
 
const bool promoteEmptyRegionToTrackster_
 
hgcal::RecHitTools rhtools_
 
const float root_doublet_max_distance_from_seed_squared_
 
const unsigned int shower_start_max_layer_
 
const int skip_layers_
 
const std::unique_ptr< HGCGraphT< TILES > > theGraph_
 

Static Private Attributes

static const int eidNFeatures_ = 3
 

Additional Inherited Members

- Public Types inherited from ticl::PatternRecognitionAlgoBaseT< TILES >
enum  VerbosityLevel {
  None = 0, Basic, Advanced, Expert,
  Guru
}
 
- Protected Attributes inherited from ticl::PatternRecognitionAlgoBaseT< TILES >
int algo_verbosity_
 

Detailed Description

template<typename TILES>
class ticl::PatternRecognitionbyCA< TILES >

Definition at line 14 of file PatternRecognitionbyCA.h.

Constructor & Destructor Documentation

◆ PatternRecognitionbyCA()

template<typename TILES >
PatternRecognitionbyCA::PatternRecognitionbyCA ( const edm::ParameterSet conf,
const CacheBase cache,
edm::ConsumesCollector  iC 
)

Definition at line 19 of file PatternRecognitionbyCA.cc.

24  theGraph_(std::make_unique<HGCGraphT<TILES>>()),
25  oneTracksterPerTrackSeed_(conf.getParameter<bool>("oneTracksterPerTrackSeed")),
26  promoteEmptyRegionToTrackster_(conf.getParameter<bool>("promoteEmptyRegionToTrackster")),
27  out_in_dfs_(conf.getParameter<bool>("out_in_dfs")),
28  max_out_in_hops_(conf.getParameter<int>("max_out_in_hops")),
29  min_cos_theta_(conf.getParameter<double>("min_cos_theta")),
30  min_cos_pointing_(conf.getParameter<double>("min_cos_pointing")),
32  conf.getParameter<double>("root_doublet_max_distance_from_seed_squared")),
33  etaLimitIncreaseWindow_(conf.getParameter<double>("etaLimitIncreaseWindow")),
34  skip_layers_(conf.getParameter<int>("skip_layers")),
35  max_missing_layers_in_trackster_(conf.getParameter<int>("max_missing_layers_in_trackster")),
37  shower_start_max_layer_(conf.getParameter<int>("shower_start_max_layer")),
38  min_layers_per_trackster_(conf.getParameter<int>("min_layers_per_trackster")),
39  filter_on_categories_(conf.getParameter<std::vector<int>>("filter_on_categories")),
40  pid_threshold_(conf.getParameter<double>("pid_threshold")),
41  energy_em_over_total_threshold_(conf.getParameter<double>("energy_em_over_total_threshold")),
42  max_longitudinal_sigmaPCA_(conf.getParameter<double>("max_longitudinal_sigmaPCA")),
44  max_delta_time_(conf.getParameter<double>("max_delta_time")),
45  eidInputName_(conf.getParameter<std::string>("eid_input_name")),
46  eidOutputNameEnergy_(conf.getParameter<std::string>("eid_output_name_energy")),
47  eidOutputNameId_(conf.getParameter<std::string>("eid_output_name_id")),
48  eidMinClusterEnergy_(conf.getParameter<double>("eid_min_cluster_energy")),
49  eidNLayers_(conf.getParameter<int>("eid_n_layers")),
50  eidNClusters_(conf.getParameter<int>("eid_n_clusters")),
51  eidSession_(nullptr) {
52  // mount the tensorflow graph onto the session when set
53  const TrackstersCache *trackstersCache = dynamic_cast<const TrackstersCache *>(cache);
54  if (trackstersCache == nullptr || trackstersCache->eidGraphDef == nullptr) {
55  throw cms::Exception("MissingGraphDef")
56  << "PatternRecognitionbyCA received an empty graph definition from the global cache";
57  }
59 }

References utilities::cache(), tensorflow::createSession(), ticl::TrackstersCache::eidGraphDef, ticl::PatternRecognitionbyCA< TILES >::eidSession_, and Exception.

◆ ~PatternRecognitionbyCA()

template<typename TILES >
PatternRecognitionbyCA::~PatternRecognitionbyCA ( )
override

Definition at line 62 of file PatternRecognitionbyCA.cc.

62 {};

Member Function Documentation

◆ emptyTrackstersFromSeedsTRK()

template<typename TILES >
void PatternRecognitionbyCA::emptyTrackstersFromSeedsTRK ( std::vector< Trackster > &  tracksters,
std::unordered_map< int, std::vector< int >> &  seedToTracksterAssociation,
const edm::ProductID collectionID 
) const

Definition at line 315 of file PatternRecognitionbyCA.cc.

318  {
319  for (auto &thisSeed : seedToTracksterAssociation) {
320  if (thisSeed.second.empty()) {
321  Trackster t;
322  t.setRegressedEnergy(0.f);
323  t.zeroProbabilities();
325  t.setSeed(collectionID, thisSeed.first);
326  tracksters.emplace_back(t);
327  thisSeed.second.emplace_back(tracksters.size() - 1);
328  }
329  }
330 }

References ticl::Trackster::charged_hadron, f, and submitPVValidationJobs::t.

◆ energyRegressionAndID()

template<typename TILES >
void PatternRecognitionbyCA::energyRegressionAndID ( const std::vector< reco::CaloCluster > &  layerClusters,
std::vector< Trackster > &  result 
)

Definition at line 333 of file PatternRecognitionbyCA.cc.

334  {
335  // Energy regression and particle identification strategy:
336  //
337  // 1. Set default values for regressed energy and particle id for each trackster.
338  // 2. Store indices of tracksters whose total sum of cluster energies is above the
339  // eidMinClusterEnergy_ (GeV) treshold. Inference is not applied for soft tracksters.
340  // 3. When no trackster passes the selection, return.
341  // 4. Create input and output tensors. The batch dimension is determined by the number of
342  // selected tracksters.
343  // 5. Fill input tensors with layer cluster features. Per layer, clusters are ordered descending
344  // by energy. Given that tensor data is contiguous in memory, we can use pointer arithmetic to
345  // fill values, even with batching.
346  // 6. Zero-fill features for empty clusters in each layer.
347  // 7. Batched inference.
348  // 8. Assign the regressed energy and id probabilities to each trackster.
349  //
350  // Indices used throughout this method:
351  // i -> batch element / trackster
352  // j -> layer
353  // k -> cluster
354  // l -> feature
355 
356  // set default values per trackster, determine if the cluster energy threshold is passed,
357  // and store indices of hard tracksters
358  std::vector<int> tracksterIndices;
359  for (int i = 0; i < (int)tracksters.size(); i++) {
360  // calculate the cluster energy sum (2)
361  // note: after the loop, sumClusterEnergy might be just above the threshold which is enough to
362  // decide whether to run inference for the trackster or not
363  float sumClusterEnergy = 0.;
364  for (const unsigned int &vertex : tracksters[i].vertices()) {
365  sumClusterEnergy += (float)layerClusters[vertex].energy();
366  // there might be many clusters, so try to stop early
367  if (sumClusterEnergy >= eidMinClusterEnergy_) {
368  // set default values (1)
369  tracksters[i].setRegressedEnergy(0.f);
370  tracksters[i].zeroProbabilities();
371  tracksterIndices.push_back(i);
372  break;
373  }
374  }
375  }
376 
377  // do nothing when no trackster passes the selection (3)
378  int batchSize = (int)tracksterIndices.size();
379  if (batchSize == 0) {
380  return;
381  }
382 
383  // create input and output tensors (4)
384  tensorflow::TensorShape shape({batchSize, eidNLayers_, eidNClusters_, eidNFeatures_});
385  tensorflow::Tensor input(tensorflow::DT_FLOAT, shape);
387 
388  std::vector<tensorflow::Tensor> outputs;
389  std::vector<std::string> outputNames;
390  if (!eidOutputNameEnergy_.empty()) {
392  }
393  if (!eidOutputNameId_.empty()) {
394  outputNames.push_back(eidOutputNameId_);
395  }
396 
397  // fill input tensor (5)
398  for (int i = 0; i < batchSize; i++) {
399  const Trackster &trackster = tracksters[tracksterIndices[i]];
400 
401  // per layer, we only consider the first eidNClusters_ clusters in terms of energy, so in order
402  // to avoid creating large / nested structures to do the sorting for an unknown number of total
403  // clusters, create a sorted list of layer cluster indices to keep track of the filled clusters
404  std::vector<int> clusterIndices(trackster.vertices().size());
405  for (int k = 0; k < (int)trackster.vertices().size(); k++) {
406  clusterIndices[k] = k;
407  }
408  sort(clusterIndices.begin(), clusterIndices.end(), [&layerClusters, &trackster](const int &a, const int &b) {
409  return layerClusters[trackster.vertices(a)].energy() > layerClusters[trackster.vertices(b)].energy();
410  });
411 
412  // keep track of the number of seen clusters per layer
413  std::vector<int> seenClusters(eidNLayers_);
414 
415  // loop through clusters by descending energy
416  for (const int &k : clusterIndices) {
417  // get features per layer and cluster and store the values directly in the input tensor
418  const reco::CaloCluster &cluster = layerClusters[trackster.vertices(k)];
419  int j = rhtools_.getLayerWithOffset(cluster.hitsAndFractions()[0].first) - 1;
420  if (j < eidNLayers_ && seenClusters[j] < eidNClusters_) {
421  // get the pointer to the first feature value for the current batch, layer and cluster
422  float *features = &input.tensor<float, 4>()(i, j, seenClusters[j], 0);
423 
424  // fill features
425  *(features++) = float(cluster.energy() / float(trackster.vertex_multiplicity(k)));
426  *(features++) = float(std::abs(cluster.eta()));
427  *(features) = float(cluster.phi());
428 
429  // increment seen clusters
430  seenClusters[j]++;
431  }
432  }
433 
434  // zero-fill features of empty clusters in each layer (6)
435  for (int j = 0; j < eidNLayers_; j++) {
436  for (int k = seenClusters[j]; k < eidNClusters_; k++) {
437  float *features = &input.tensor<float, 4>()(i, j, k, 0);
438  for (int l = 0; l < eidNFeatures_; l++) {
439  *(features++) = 0.f;
440  }
441  }
442  }
443  }
444 
445  // run the inference (7)
447 
448  // store regressed energy per trackster (8)
449  if (!eidOutputNameEnergy_.empty()) {
450  // get the pointer to the energy tensor, dimension is batch x 1
451  float *energy = outputs[0].flat<float>().data();
452 
453  for (const int &i : tracksterIndices) {
454  tracksters[i].setRegressedEnergy(*(energy++));
455  }
456  }
457 
458  // store id probabilities per trackster (8)
459  if (!eidOutputNameId_.empty()) {
460  // get the pointer to the id probability tensor, dimension is batch x id_probabilities.size()
461  int probsIdx = eidOutputNameEnergy_.empty() ? 0 : 1;
462  float *probs = outputs[probsIdx].flat<float>().data();
463 
464  for (const int &i : tracksterIndices) {
465  tracksters[i].setProbabilities(probs);
466  probs += tracksters[i].id_probabilities().size();
467  }
468  }
469 }

References a, funct::abs(), b, data, HCALHighEnergyHPDFilter_cfi::energy, reco::CaloCluster::energy(), reco::CaloCluster::eta(), f, lowptgsfeleseed::features(), dqmMemoryStats::float, reco::CaloCluster::hitsAndFractions(), mps_fire::i, input, createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, cmsLHEtoEOSManager::l, HLTEgPhaseIITestSequence_cff::layerClusters, jets_cff::outputNames, PatBasicFWLiteJetAnalyzer_Selector_cfg::outputs, reco::CaloCluster::phi(), tensorflow::run(), jetUpdater_cfi::sort, bphysicsOniaDQM_cfi::vertex, ticl::Trackster::vertex_multiplicity(), AlignmentTracksFromVertexSelector_cfi::vertices, and ticl::Trackster::vertices().

◆ fillPSetDescription()

template<typename TILES >
void PatternRecognitionbyCA::fillPSetDescription ( edm::ParameterSetDescription iDesc)
static

Definition at line 472 of file PatternRecognitionbyCA.cc.

472  {
473  iDesc.add<int>("algo_verbosity", 0);
474  iDesc.add<bool>("oneTracksterPerTrackSeed", false);
475  iDesc.add<bool>("promoteEmptyRegionToTrackster", false);
476  iDesc.add<bool>("out_in_dfs", true);
477  iDesc.add<int>("max_out_in_hops", 10);
478  iDesc.add<double>("min_cos_theta", 0.915);
479  iDesc.add<double>("min_cos_pointing", -1.);
480  iDesc.add<double>("root_doublet_max_distance_from_seed_squared", 9999);
481  iDesc.add<double>("etaLimitIncreaseWindow", 2.1);
482  iDesc.add<int>("skip_layers", 0);
483  iDesc.add<int>("max_missing_layers_in_trackster", 9999);
484  iDesc.add<int>("shower_start_max_layer", 9999)->setComment("make default such that no filtering is applied");
485  iDesc.add<int>("min_layers_per_trackster", 10);
486  iDesc.add<std::vector<int>>("filter_on_categories", {0});
487  iDesc.add<double>("pid_threshold", 0.)->setComment("make default such that no filtering is applied");
488  iDesc.add<double>("energy_em_over_total_threshold", -1.)
489  ->setComment("make default such that no filtering is applied");
490  iDesc.add<double>("max_longitudinal_sigmaPCA", 9999);
491  iDesc.add<double>("max_delta_time", 3.)->setComment("nsigma");
492  iDesc.add<std::string>("eid_input_name", "input");
493  iDesc.add<std::string>("eid_output_name_energy", "output/regressed_energy");
494  iDesc.add<std::string>("eid_output_name_id", "output/id_probabilities");
495  iDesc.add<double>("eid_min_cluster_energy", 1.);
496  iDesc.add<int>("eid_n_layers", 50);
497  iDesc.add<int>("eid_n_clusters", 10);
498 }

References edm::ParameterSetDescription::add(), edm::ParameterDescriptionNode::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ makeTracksters()

template<typename TILES >
void PatternRecognitionbyCA::makeTracksters ( const typename PatternRecognitionAlgoBaseT< TILES >::Inputs input,
std::vector< Trackster > &  result,
std::unordered_map< int, std::vector< int >> &  seedToTracksterAssociation 
)
override

Definition at line 65 of file PatternRecognitionbyCA.cc.

68  {
69  // Protect from events with no seeding regions
70  if (input.regions.empty())
71  return;
72 
73  edm::EventSetup const &es = input.es;
76 
78  theGraph_->clear();
80  LogDebug("HGCPatternRecoByCA") << "Making Tracksters with CA" << std::endl;
81  }
82 
83  int type = input.tiles[0].typeT();
86 
87  bool isRegionalIter = (input.regions[0].index != -1);
88  std::vector<HGCDoublet::HGCntuplet> foundNtuplets;
89  std::vector<int> seedIndices;
90  std::vector<uint8_t> layer_cluster_usage(input.layerClusters.size(), 0);
91  theGraph_->makeAndConnectDoublets(input.tiles,
92  input.regions,
93  nEtaBin,
94  nPhiBin,
95  input.layerClusters,
96  input.mask,
97  input.layerClustersTime,
98  1,
99  1,
104  skip_layers_,
107 
109  //#ifdef FP_DEBUG
110  const auto &doublets = theGraph_->getAllDoublets();
111  int tracksterId = -1;
112 
113  // container for holding tracksters before selection
114  std::vector<Trackster> tmpTracksters;
115  tmpTracksters.reserve(foundNtuplets.size());
116 
117  for (auto const &ntuplet : foundNtuplets) {
118  tracksterId++;
119 
120  std::set<unsigned int> effective_cluster_idx;
121 
122  for (auto const &doublet : ntuplet) {
123  auto innerCluster = doublets[doublet].innerClusterId();
124  auto outerCluster = doublets[doublet].outerClusterId();
125 
126  effective_cluster_idx.insert(innerCluster);
127  effective_cluster_idx.insert(outerCluster);
128 
130  LogDebug("HGCPatternRecoByCA") << " New doublet " << doublet << " for trackster: " << result.size()
131  << " InnerCl " << innerCluster << " " << input.layerClusters[innerCluster].x()
132  << " " << input.layerClusters[innerCluster].y() << " "
133  << input.layerClusters[innerCluster].z() << " OuterCl " << outerCluster << " "
134  << input.layerClusters[outerCluster].x() << " "
135  << input.layerClusters[outerCluster].y() << " "
136  << input.layerClusters[outerCluster].z() << " " << tracksterId << std::endl;
137  }
138  }
139  unsigned showerMinLayerId = 99999;
140  std::vector<unsigned int> uniqueLayerIds;
141  uniqueLayerIds.reserve(effective_cluster_idx.size());
142  std::vector<std::pair<unsigned int, unsigned int>> lcIdAndLayer;
143  lcIdAndLayer.reserve(effective_cluster_idx.size());
144  for (auto const i : effective_cluster_idx) {
145  auto const &haf = input.layerClusters[i].hitsAndFractions();
146  auto layerId = rhtools_.getLayerWithOffset(haf[0].first);
147  showerMinLayerId = std::min(layerId, showerMinLayerId);
148  uniqueLayerIds.push_back(layerId);
149  lcIdAndLayer.emplace_back(i, layerId);
150  }
151  std::sort(uniqueLayerIds.begin(), uniqueLayerIds.end());
152  uniqueLayerIds.erase(std::unique(uniqueLayerIds.begin(), uniqueLayerIds.end()), uniqueLayerIds.end());
153  unsigned int numberOfLayersInTrackster = uniqueLayerIds.size();
154  if (check_missing_layers_) {
155  int numberOfMissingLayers = 0;
156  unsigned int j = showerMinLayerId;
157  unsigned int indexInVec = 0;
158  for (const auto &layer : uniqueLayerIds) {
159  if (layer != j) {
160  numberOfMissingLayers++;
161  j++;
162  if (numberOfMissingLayers > max_missing_layers_in_trackster_) {
163  numberOfLayersInTrackster = indexInVec;
164  for (auto &llpair : lcIdAndLayer) {
165  if (llpair.second >= layer) {
166  effective_cluster_idx.erase(llpair.first);
167  }
168  }
169  break;
170  }
171  }
172  indexInVec++;
173  j++;
174  }
175  }
176 
177  if ((numberOfLayersInTrackster >= min_layers_per_trackster_) and (showerMinLayerId <= shower_start_max_layer_)) {
178  // Put back indices, in the form of a Trackster, into the results vector
179  Trackster tmp;
180  tmp.vertices().reserve(effective_cluster_idx.size());
181  tmp.vertex_multiplicity().resize(effective_cluster_idx.size(), 1);
182  //regions and seedIndices can have different size
183  //if a seeding region does not lead to any trackster
184  tmp.setSeed(input.regions[0].collectionID, seedIndices[tracksterId]);
185 
186  std::copy(std::begin(effective_cluster_idx), std::end(effective_cluster_idx), std::back_inserter(tmp.vertices()));
187  tmpTracksters.push_back(tmp);
188  }
189  }
190  ticl::assignPCAtoTracksters(tmpTracksters,
191  input.layerClusters,
192  input.layerClustersTime,
194 
195  // run energy regression and ID
196  energyRegressionAndID(input.layerClusters, tmpTracksters);
197  // Filter results based on PID criteria or EM/Total energy ratio.
198  // We want to **keep** tracksters whose cumulative
199  // probability summed up over the selected categories
200  // is greater than the chosen threshold. Therefore
201  // the filtering function should **discard** all
202  // tracksters **below** the threshold.
203  auto filter_on_pids = [&](Trackster &t) -> bool {
204  auto cumulative_prob = 0.;
205  for (auto index : filter_on_categories_) {
206  cumulative_prob += t.id_probabilities(index);
207  }
208  return (cumulative_prob <= pid_threshold_) &&
209  (t.raw_em_energy() < energy_em_over_total_threshold_ * t.raw_energy());
210  };
211 
212  std::vector<unsigned int> selectedTrackstersIds;
213  for (unsigned i = 0; i < tmpTracksters.size(); ++i) {
214  if (!filter_on_pids(tmpTracksters[i]) and tmpTracksters[i].sigmasPCA()[0] < max_longitudinal_sigmaPCA_) {
215  selectedTrackstersIds.push_back(i);
216  }
217  }
218 
219  result.reserve(selectedTrackstersIds.size());
220 
221  for (unsigned i = 0; i < selectedTrackstersIds.size(); ++i) {
222  const auto &t = tmpTracksters[selectedTrackstersIds[i]];
223  for (auto const lcId : t.vertices()) {
224  layer_cluster_usage[lcId]++;
226  LogDebug("HGCPatternRecoByCA") << "LayerID: " << lcId << " count: " << (int)layer_cluster_usage[lcId]
227  << std::endl;
228  }
229  if (isRegionalIter) {
230  seedToTracksterAssociation[t.seedIndex()].push_back(i);
231  }
232  result.push_back(t);
233  }
234 
235  for (auto &trackster : result) {
236  assert(trackster.vertices().size() <= trackster.vertex_multiplicity().size());
237  for (size_t i = 0; i < trackster.vertices().size(); ++i) {
238  trackster.vertex_multiplicity()[i] = layer_cluster_usage[trackster.vertices(i)];
240  LogDebug("HGCPatternRecoByCA") << "LayerID: " << trackster.vertices(i)
241  << " count: " << (int)trackster.vertex_multiplicity(i) << std::endl;
242  }
243  }
244  // Now decide if the tracksters from the track-based iterations have to be merged
246  std::vector<Trackster> tmp;
247  mergeTrackstersTRK(result, input.layerClusters, tmp, seedToTracksterAssociation);
248  tmp.swap(result);
249  }
250 
252  input.layerClusters,
253  input.layerClustersTime,
255 
256  // run energy regression and ID
257  energyRegressionAndID(input.layerClusters, result);
258 
259  // now adding dummy tracksters from seeds not connected to any shower in the result collection
260  // these are marked as charged hadrons with probability 1.
262  emptyTrackstersFromSeedsTRK(result, seedToTracksterAssociation, input.regions[0].collectionID);
263  }
264 
266  for (auto &trackster : result) {
267  LogDebug("HGCPatternRecoByCA") << "Trackster characteristics: " << std::endl;
268  LogDebug("HGCPatternRecoByCA") << "Size: " << trackster.vertices().size() << std::endl;
269  auto counter = 0;
270  for (auto const &p : trackster.id_probabilities()) {
271  LogDebug("HGCPatternRecoByCA") << counter++ << ": " << p << std::endl;
272  }
273  }
274  }
275  theGraph_->clear();
276 }

References cms::cuda::assert(), ticl::assignPCAtoTracksters(), filterCSVwithJSON::copy, HLT_FULL_cff::doublets, mps_fire::end, first, foundNtuplets, relativeConstraints::geom, edm::EventSetup::getData(), mps_fire::i, input, createfilelist::int, dqmiolumiharvest::j, phase1PixelTopology::layer, LogDebug, min(), ticl::TileConstants::nEtaBins, ticl::TileConstantsHFNose::nEtaBins, ticl::TileConstants::nPhiBins, ticl::TileConstantsHFNose::nPhiBins, pixelTracksMonitoring_cff::ntuplet, AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, jetUpdater_cfi::sort, submitPVValidationJobs::t, createJobs::tmp, and tier0::unique().

◆ mergeTrackstersTRK()

template<typename TILES >
void PatternRecognitionbyCA::mergeTrackstersTRK ( const std::vector< Trackster > &  input,
const std::vector< reco::CaloCluster > &  layerClusters,
std::vector< Trackster > &  output,
std::unordered_map< int, std::vector< int >> &  seedToTracksterAssociation 
) const
private

Definition at line 279 of file PatternRecognitionbyCA.cc.

283  {
284  output.reserve(input.size());
285  for (auto &thisSeed : seedToTracksterAssociation) {
286  auto &tracksters = thisSeed.second;
287  if (!tracksters.empty()) {
288  auto numberOfTrackstersInSeed = tracksters.size();
289  output.emplace_back(input[tracksters[0]]);
290  auto &outTrackster = output.back();
291  tracksters[0] = output.size() - 1;
292  auto updated_size = outTrackster.vertices().size();
293  for (unsigned int j = 1; j < numberOfTrackstersInSeed; ++j) {
294  auto &thisTrackster = input[tracksters[j]];
295  updated_size += thisTrackster.vertices().size();
297  LogDebug("HGCPatternRecoByCA") << "Updated size: " << updated_size << std::endl;
298  }
299  outTrackster.vertices().reserve(updated_size);
300  outTrackster.vertex_multiplicity().reserve(updated_size);
301  std::copy(std::begin(thisTrackster.vertices()),
302  std::end(thisTrackster.vertices()),
303  std::back_inserter(outTrackster.vertices()));
304  std::copy(std::begin(thisTrackster.vertex_multiplicity()),
305  std::end(thisTrackster.vertex_multiplicity()),
306  std::back_inserter(outTrackster.vertex_multiplicity()));
307  }
308  tracksters.resize(1);
309  }
310  }
311  output.shrink_to_fit();
312 }

References filterCSVwithJSON::copy, mps_fire::end, input, dqmiolumiharvest::j, LogDebug, and convertSQLitetoXML_cfg::output.

Member Data Documentation

◆ caloGeomToken_

template<typename TILES >
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> ticl::PatternRecognitionbyCA< TILES >::caloGeomToken_
private

Definition at line 35 of file PatternRecognitionbyCA.h.

◆ check_missing_layers_

template<typename TILES >
bool ticl::PatternRecognitionbyCA< TILES >::check_missing_layers_ = false
private

Definition at line 47 of file PatternRecognitionbyCA.h.

◆ eidInputName_

template<typename TILES >
const std::string ticl::PatternRecognitionbyCA< TILES >::eidInputName_
private

Definition at line 56 of file PatternRecognitionbyCA.h.

◆ eidMinClusterEnergy_

template<typename TILES >
const float ticl::PatternRecognitionbyCA< TILES >::eidMinClusterEnergy_
private

Definition at line 59 of file PatternRecognitionbyCA.h.

◆ eidNClusters_

template<typename TILES >
const int ticl::PatternRecognitionbyCA< TILES >::eidNClusters_
private

Definition at line 61 of file PatternRecognitionbyCA.h.

◆ eidNFeatures_

template<typename TILES >
const int ticl::PatternRecognitionbyCA< TILES >::eidNFeatures_ = 3
staticprivate

Definition at line 66 of file PatternRecognitionbyCA.h.

◆ eidNLayers_

template<typename TILES >
const int ticl::PatternRecognitionbyCA< TILES >::eidNLayers_
private

Definition at line 60 of file PatternRecognitionbyCA.h.

◆ eidOutputNameEnergy_

template<typename TILES >
const std::string ticl::PatternRecognitionbyCA< TILES >::eidOutputNameEnergy_
private

Definition at line 57 of file PatternRecognitionbyCA.h.

◆ eidOutputNameId_

template<typename TILES >
const std::string ticl::PatternRecognitionbyCA< TILES >::eidOutputNameId_
private

Definition at line 58 of file PatternRecognitionbyCA.h.

◆ eidSession_

template<typename TILES >
tensorflow::Session* ticl::PatternRecognitionbyCA< TILES >::eidSession_
private

◆ energy_em_over_total_threshold_

template<typename TILES >
const double ticl::PatternRecognitionbyCA< TILES >::energy_em_over_total_threshold_
private

Definition at line 52 of file PatternRecognitionbyCA.h.

◆ etaLimitIncreaseWindow_

template<typename TILES >
const float ticl::PatternRecognitionbyCA< TILES >::etaLimitIncreaseWindow_
private

Definition at line 44 of file PatternRecognitionbyCA.h.

◆ filter_on_categories_

template<typename TILES >
const std::vector<int> ticl::PatternRecognitionbyCA< TILES >::filter_on_categories_
private

Definition at line 50 of file PatternRecognitionbyCA.h.

◆ max_delta_time_

template<typename TILES >
const float ticl::PatternRecognitionbyCA< TILES >::max_delta_time_
private

Definition at line 55 of file PatternRecognitionbyCA.h.

◆ max_longitudinal_sigmaPCA_

template<typename TILES >
const double ticl::PatternRecognitionbyCA< TILES >::max_longitudinal_sigmaPCA_
private

Definition at line 53 of file PatternRecognitionbyCA.h.

◆ max_missing_layers_in_trackster_

template<typename TILES >
const int ticl::PatternRecognitionbyCA< TILES >::max_missing_layers_in_trackster_
private

Definition at line 46 of file PatternRecognitionbyCA.h.

◆ max_out_in_hops_

template<typename TILES >
const unsigned int ticl::PatternRecognitionbyCA< TILES >::max_out_in_hops_
private

Definition at line 40 of file PatternRecognitionbyCA.h.

◆ min_clusters_per_ntuplet_

template<typename TILES >
const int ticl::PatternRecognitionbyCA< TILES >::min_clusters_per_ntuplet_
private

Definition at line 54 of file PatternRecognitionbyCA.h.

◆ min_cos_pointing_

template<typename TILES >
const float ticl::PatternRecognitionbyCA< TILES >::min_cos_pointing_
private

Definition at line 42 of file PatternRecognitionbyCA.h.

◆ min_cos_theta_

template<typename TILES >
const float ticl::PatternRecognitionbyCA< TILES >::min_cos_theta_
private

Definition at line 41 of file PatternRecognitionbyCA.h.

◆ min_layers_per_trackster_

template<typename TILES >
const unsigned int ticl::PatternRecognitionbyCA< TILES >::min_layers_per_trackster_
private

Definition at line 49 of file PatternRecognitionbyCA.h.

◆ oneTracksterPerTrackSeed_

template<typename TILES >
const bool ticl::PatternRecognitionbyCA< TILES >::oneTracksterPerTrackSeed_
private

Definition at line 37 of file PatternRecognitionbyCA.h.

◆ out_in_dfs_

template<typename TILES >
const bool ticl::PatternRecognitionbyCA< TILES >::out_in_dfs_
private

Definition at line 39 of file PatternRecognitionbyCA.h.

◆ pid_threshold_

template<typename TILES >
const double ticl::PatternRecognitionbyCA< TILES >::pid_threshold_
private

Definition at line 51 of file PatternRecognitionbyCA.h.

◆ promoteEmptyRegionToTrackster_

template<typename TILES >
const bool ticl::PatternRecognitionbyCA< TILES >::promoteEmptyRegionToTrackster_
private

Definition at line 38 of file PatternRecognitionbyCA.h.

◆ rhtools_

template<typename TILES >
hgcal::RecHitTools ticl::PatternRecognitionbyCA< TILES >::rhtools_
private

Definition at line 63 of file PatternRecognitionbyCA.h.

◆ root_doublet_max_distance_from_seed_squared_

template<typename TILES >
const float ticl::PatternRecognitionbyCA< TILES >::root_doublet_max_distance_from_seed_squared_
private

Definition at line 43 of file PatternRecognitionbyCA.h.

◆ shower_start_max_layer_

template<typename TILES >
const unsigned int ticl::PatternRecognitionbyCA< TILES >::shower_start_max_layer_
private

Definition at line 48 of file PatternRecognitionbyCA.h.

◆ skip_layers_

template<typename TILES >
const int ticl::PatternRecognitionbyCA< TILES >::skip_layers_
private

Definition at line 45 of file PatternRecognitionbyCA.h.

◆ theGraph_

template<typename TILES >
const std::unique_ptr<HGCGraphT<TILES> > ticl::PatternRecognitionbyCA< TILES >::theGraph_
private

Definition at line 36 of file PatternRecognitionbyCA.h.

reco::CaloCluster::phi
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:184
tensorflow::createSession
Session * createSession(SessionOptions &sessionOptions)
Definition: TensorFlow.cc:85
counter
Definition: counter.py:1
ticl::TileConstantsHFNose::nEtaBins
static constexpr int nEtaBins
Definition: Common.h:23
ticl::PatternRecognitionbyCA::eidOutputNameEnergy_
const std::string eidOutputNameEnergy_
Definition: PatternRecognitionbyCA.h:57
mps_fire.i
i
Definition: mps_fire.py:428
ticl::TileConstants::nEtaBins
static constexpr int nEtaBins
Definition: Common.h:12
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
input
static const std::string input
Definition: EdmProvDump.cc:48
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
ticl::PatternRecognitionbyCA::shower_start_max_layer_
const unsigned int shower_start_max_layer_
Definition: PatternRecognitionbyCA.h:48
ticl::PatternRecognitionbyCA::rhtools_
hgcal::RecHitTools rhtools_
Definition: PatternRecognitionbyCA.h:63
ticl::PatternRecognitionbyCA::oneTracksterPerTrackSeed_
const bool oneTracksterPerTrackSeed_
Definition: PatternRecognitionbyCA.h:37
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
ticl::TileConstantsHFNose::nPhiBins
static constexpr int nPhiBins
Definition: Common.h:24
min
T min(T a, T b)
Definition: MathUtil.h:58
ticl::PatternRecognitionbyCA::skip_layers_
const int skip_layers_
Definition: PatternRecognitionbyCA.h:45
ticl::PatternRecognitionbyCA::eidNLayers_
const int eidNLayers_
Definition: PatternRecognitionbyCA.h:60
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
ticl::Trackster::ParticleType::charged_hadron
PatBasicFWLiteJetAnalyzer_Selector_cfg.outputs
outputs
Definition: PatBasicFWLiteJetAnalyzer_Selector_cfg.py:48
cms::cuda::assert
assert(be >=bs)
ticl::PatternRecognitionbyCA::max_out_in_hops_
const unsigned int max_out_in_hops_
Definition: PatternRecognitionbyCA.h:40
ticl::PatternRecognitionbyCA::max_longitudinal_sigmaPCA_
const double max_longitudinal_sigmaPCA_
Definition: PatternRecognitionbyCA.h:53
ticl::PatternRecognitionbyCA::max_missing_layers_in_trackster_
const int max_missing_layers_in_trackster_
Definition: PatternRecognitionbyCA.h:46
ticl::TileConstants::nPhiBins
static constexpr int nPhiBins
Definition: Common.h:13
HLT_FULL_cff.doublets
doublets
Definition: HLT_FULL_cff.py:9872
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
edm::ConsumesCollector::esConsumes
auto esConsumes()
Definition: ConsumesCollector.h:97
ticl::PatternRecognitionbyCA::out_in_dfs_
const bool out_in_dfs_
Definition: PatternRecognitionbyCA.h:39
AlignmentTracksFromVertexSelector_cfi.vertices
vertices
Definition: AlignmentTracksFromVertexSelector_cfi.py:5
ticl::PatternRecognitionbyCA::filter_on_categories_
const std::vector< int > filter_on_categories_
Definition: PatternRecognitionbyCA.h:50
ticl::assignPCAtoTracksters
void assignPCAtoTracksters(std::vector< Trackster > &, const std::vector< reco::CaloCluster > &, const edm::ValueMap< std::pair< float, float >> &, double, bool energyWeight=true)
Definition: TrackstersPCA.cc:12
ticl::PatternRecognitionAlgoBaseT
Definition: PatternRecognitionAlgoBase.h:25
CaloGeometry
Definition: CaloGeometry.h:21
ticl::PatternRecognitionbyCA::eidSession_
tensorflow::Session * eidSession_
Definition: PatternRecognitionbyCA.h:64
ticl::TrackstersCache
Definition: GlobalCache.h:19
reco::CaloCluster
Definition: CaloCluster.h:31
mps_fire.end
end
Definition: mps_fire.py:242
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
ticl::PatternRecognitionbyCA::theGraph_
const std::unique_ptr< HGCGraphT< TILES > > theGraph_
Definition: PatternRecognitionbyCA.h:36
ticl::PatternRecognitionbyCA::min_cos_pointing_
const float min_cos_pointing_
Definition: PatternRecognitionbyCA.h:42
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HLTEgPhaseIITestSequence_cff.layerClusters
layerClusters
Definition: HLTEgPhaseIITestSequence_cff.py:2506
ticl::PatternRecognitionbyCA::emptyTrackstersFromSeedsTRK
void emptyTrackstersFromSeedsTRK(std::vector< Trackster > &tracksters, std::unordered_map< int, std::vector< int >> &seedToTracksterAssociation, const edm::ProductID &collectionID) const
Definition: PatternRecognitionbyCA.cc:315
b
double b
Definition: hdecay.h:118
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
utilities.cache
def cache(function)
Definition: utilities.py:3
lowptgsfeleseed::features
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
Definition: LowPtGsfElectronFeatures.cc:17
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
ticl::PatternRecognitionbyCA::caloGeomToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
Definition: PatternRecognitionbyCA.h:35
ticl::PatternRecognitionbyCA::min_clusters_per_ntuplet_
const int min_clusters_per_ntuplet_
Definition: PatternRecognitionbyCA.h:54
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
a
double a
Definition: hdecay.h:119
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
reco::CaloCluster::eta
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
ticl::PatternRecognitionbyCA::check_missing_layers_
bool check_missing_layers_
Definition: PatternRecognitionbyCA.h:47
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
ticl::PatternRecognitionbyCA::eidOutputNameId_
const std::string eidOutputNameId_
Definition: PatternRecognitionbyCA.h:58
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
hgcal::RecHitTools::getLayerWithOffset
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:362
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
hgcal::RecHitTools::lastLayerEE
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:67
tensorflow::NamedTensorList
std::vector< NamedTensor > NamedTensorList
Definition: TensorFlow.h:30
createfilelist.int
int
Definition: createfilelist.py:10
foundNtuplets
const uint32_t *__restrict__ HitContainer * foundNtuplets
Definition: CAHitNtupletGeneratorKernelsImpl.h:139
ticl::PatternRecognitionbyCA::etaLimitIncreaseWindow_
const float etaLimitIncreaseWindow_
Definition: PatternRecognitionbyCA.h:44
ticl::Trackster::vertex_multiplicity
std::vector< float > & vertex_multiplicity()
Definition: Trackster.h:57
edm::EventSetup
Definition: EventSetup.h:58
ticl::PatternRecognitionbyCA::root_doublet_max_distance_from_seed_squared_
const float root_doublet_max_distance_from_seed_squared_
Definition: PatternRecognitionbyCA.h:43
hgcal::RecHitTools::getPositionLayer
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:138
ticl::TrackstersCache::eidGraphDef
std::atomic< tensorflow::GraphDef * > eidGraphDef
Definition: GlobalCache.h:25
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
hgcal::RecHitTools::lastLayer
unsigned int lastLayer(bool nose=false) const
Definition: RecHitTools.h:71
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
pixelTracksMonitoring_cff.ntuplet
ntuplet
Definition: pixelTracksMonitoring_cff.py:54
ticl::PatternRecognitionbyCA::eidNFeatures_
static const int eidNFeatures_
Definition: PatternRecognitionbyCA.h:66
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
hgcal::RecHitTools::setGeometry
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
ticl::Trackster::vertices
std::vector< unsigned int > & vertices()
Definition: Trackster.h:56
Exception
Definition: hltDiff.cc:245
tensorflow::run
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Definition: TensorFlow.cc:213
ticl::PatternRecognitionbyCA::min_layers_per_trackster_
const unsigned int min_layers_per_trackster_
Definition: PatternRecognitionbyCA.h:49
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ticl::PatternRecognitionbyCA::min_cos_theta_
const float min_cos_theta_
Definition: PatternRecognitionbyCA.h:41
ticl::PatternRecognitionbyCA::energy_em_over_total_threshold_
const double energy_em_over_total_threshold_
Definition: PatternRecognitionbyCA.h:52
ticl::PatternRecognitionbyCA::promoteEmptyRegionToTrackster_
const bool promoteEmptyRegionToTrackster_
Definition: PatternRecognitionbyCA.h:38
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
ticl::PatternRecognitionbyCA::energyRegressionAndID
void energyRegressionAndID(const std::vector< reco::CaloCluster > &layerClusters, std::vector< Trackster > &result)
Definition: PatternRecognitionbyCA.cc:333
HGCGraphT
Definition: HGCGraph.h:15
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ticl::PatternRecognitionbyCA::eidInputName_
const std::string eidInputName_
Definition: PatternRecognitionbyCA.h:56
edm::ParameterDescriptionNode::setComment
void setComment(std::string const &value)
Definition: ParameterDescriptionNode.cc:106
ticl::PatternRecognitionbyCA::pid_threshold_
const double pid_threshold_
Definition: PatternRecognitionbyCA.h:51
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ticl::PatternRecognitionbyCA::eidNClusters_
const int eidNClusters_
Definition: PatternRecognitionbyCA.h:61
ticl::PatternRecognitionbyCA::mergeTrackstersTRK
void mergeTrackstersTRK(const std::vector< Trackster > &, const std::vector< reco::CaloCluster > &, std::vector< Trackster > &, std::unordered_map< int, std::vector< int >> &seedToTracksterAssociation) const
Definition: PatternRecognitionbyCA.cc:279
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
ticl::PatternRecognitionbyCA::max_delta_time_
const float max_delta_time_
Definition: PatternRecognitionbyCA.h:55
ticl::Trackster
Definition: Trackster.h:19
jets_cff.outputNames
outputNames
Definition: jets_cff.py:335
ticl::PatternRecognitionbyCA::eidMinClusterEnergy_
const float eidMinClusterEnergy_
Definition: PatternRecognitionbyCA.h:59