CMS 3D CMS Logo

TrackstersMergeProducer.cc
Go to the documentation of this file.
1 #include <memory> // unique_ptr
2 
7 
17 
18 #include "TrackstersPCA.h"
19 
20 using namespace ticl;
21 
22 class TrackstersMergeProducer : public edm::stream::EDProducer<edm::GlobalCache<TrackstersCache>> {
23 public:
24  explicit TrackstersMergeProducer(const edm::ParameterSet &ps, const CacheBase *cache);
26  void produce(edm::Event &, const edm::EventSetup &) override;
27  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
28  void energyRegressionAndID(const std::vector<reco::CaloCluster> &layerClusters, std::vector<Trackster> &result) const;
29 
30  // static methods for handling the global cache
31  static std::unique_ptr<TrackstersCache> initializeGlobalCache(const edm::ParameterSet &);
32  static void globalEndJob(TrackstersCache *);
33 
34 private:
35  enum TracksterIterIndex { EM = 0, TRK, HAD, SEED };
36 
37  void fillTile(TICLTracksterTiles &, const std::vector<Trackster> &, TracksterIterIndex);
38 
39  void printTrackstersDebug(const std::vector<Trackster> &, const char *label) const;
40  void dumpTrackster(const Trackster &) const;
41 
49  const int eta_bin_window_;
50  const int phi_bin_window_;
51  const double pt_sigma_high_;
52  const double pt_sigma_low_;
53  const double cosangle_align_;
54  const double e_over_h_threshold_;
55  const double pt_neutral_threshold_;
56  const double resol_calo_offset_;
57  const double resol_calo_scale_;
58  const bool debug_;
62  const float eidMinClusterEnergy_;
63  const int eidNLayers_;
64  const int eidNClusters_;
65 
66  tensorflow::Session *eidSession_;
68 
69  static constexpr int eidNFeatures_ = 3;
70 };
71 
73  : trackstersem_token_(consumes<std::vector<Trackster>>(ps.getParameter<edm::InputTag>("trackstersem"))),
74  tracksterstrk_token_(consumes<std::vector<Trackster>>(ps.getParameter<edm::InputTag>("tracksterstrk"))),
75  trackstershad_token_(consumes<std::vector<Trackster>>(ps.getParameter<edm::InputTag>("trackstershad"))),
76  seedingTrk_token_(consumes<std::vector<TICLSeedingRegion>>(ps.getParameter<edm::InputTag>("seedingTrk"))),
77  clusters_token_(consumes<std::vector<reco::CaloCluster>>(ps.getParameter<edm::InputTag>("layer_clusters"))),
78  tracks_token_(consumes<std::vector<reco::Track>>(ps.getParameter<edm::InputTag>("tracks"))),
79  optimiseAcrossTracksters_(ps.getParameter<bool>("optimiseAcrossTracksters")),
80  eta_bin_window_(ps.getParameter<int>("eta_bin_window")),
81  phi_bin_window_(ps.getParameter<int>("phi_bin_window")),
82  pt_sigma_high_(ps.getParameter<double>("pt_sigma_high")),
83  pt_sigma_low_(ps.getParameter<double>("pt_sigma_low")),
84  cosangle_align_(ps.getParameter<double>("cosangle_align")),
85  e_over_h_threshold_(ps.getParameter<double>("e_over_h_threshold")),
86  pt_neutral_threshold_(ps.getParameter<double>("pt_neutral_threshold")),
87  resol_calo_offset_(ps.getParameter<double>("resol_calo_offset")),
88  resol_calo_scale_(ps.getParameter<double>("resol_calo_scale")),
89  debug_(ps.getParameter<bool>("debug")),
90  eidInputName_(ps.getParameter<std::string>("eid_input_name")),
91  eidOutputNameEnergy_(ps.getParameter<std::string>("eid_output_name_energy")),
92  eidOutputNameId_(ps.getParameter<std::string>("eid_output_name_id")),
93  eidMinClusterEnergy_(ps.getParameter<double>("eid_min_cluster_energy")),
94  eidNLayers_(ps.getParameter<int>("eid_n_layers")),
95  eidNClusters_(ps.getParameter<int>("eid_n_clusters")),
96  eidSession_(nullptr) {
97  // mount the tensorflow graph onto the session when set
98  const TrackstersCache *trackstersCache = dynamic_cast<const TrackstersCache *>(cache);
99  if (trackstersCache == nullptr || trackstersCache->eidGraphDef == nullptr) {
100  throw cms::Exception("MissingGraphDef")
101  << "TrackstersMergeProducer received an empty graph definition from the global cache";
102  }
104 
105  produces<std::vector<Trackster>>();
106 }
107 
109  const std::vector<Trackster> &tracksters,
110  TracksterIterIndex tracksterIteration) {
111  int tracksterId = 0;
112  for (auto const &t : tracksters) {
113  tracksterTile.fill(tracksterIteration, t.barycenter().eta(), t.barycenter().phi(), tracksterId);
114  LogDebug("TrackstersMergeProducer") << "Adding tracksterId: " << tracksterId << " into bin [eta,phi]: [ "
115  << tracksterTile[tracksterIteration].etaBin(t.barycenter().eta()) << ", "
116  << tracksterTile[tracksterIteration].phiBin(t.barycenter().phi())
117  << "] for iteration: " << tracksterIteration << std::endl;
118 
119  tracksterId++;
120  }
121 }
122 
124  auto e_over_h = (t.raw_em_pt() / ((t.raw_pt() - t.raw_em_pt()) != 0. ? (t.raw_pt() - t.raw_em_pt()) : 1.));
125  LogDebug("TrackstersMergeProducer")
126  << "\nTrackster raw_pt: " << t.raw_pt() << " raw_em_pt: " << t.raw_em_pt() << " eoh: " << e_over_h
127  << " barycenter: " << t.barycenter() << " eta,phi (baricenter): " << t.barycenter().eta() << ", "
128  << t.barycenter().phi() << " eta,phi (eigen): " << t.eigenvectors(0).eta() << ", " << t.eigenvectors(0).phi()
129  << " pt(eigen): " << std::sqrt(t.eigenvectors(0).Unit().perp2()) * t.raw_energy() << " seedID: " << t.seedID()
130  << " seedIndex: " << t.seedIndex() << " size: " << t.vertices().size() << " average usage: "
131  << (std::accumulate(std::begin(t.vertex_multiplicity()), std::end(t.vertex_multiplicity()), 0.) /
132  (float)t.vertex_multiplicity().size())
133  << " raw_energy: " << t.raw_energy() << " regressed energy: " << t.regressed_energy()
134  << " probs(ga/e/mu/np/cp/nh/am/unk): ";
135  for (auto const &p : t.id_probabilities()) {
136  LogDebug("TrackstersMergeProducer") << std::fixed << p << " ";
137  }
138  LogDebug("TrackstersMergeProducer") << " sigmas: ";
139  for (auto const &s : t.sigmas()) {
140  LogDebug("TrackstersMergeProducer") << s << " ";
141  }
142  LogDebug("TrackstersMergeProducer") << std::endl;
143 }
144 
147  auto result = std::make_unique<std::vector<Trackster>>();
148  auto mergedTrackstersTRK = std::make_unique<std::vector<Trackster>>();
149 
150  TICLTracksterTiles tracksterTile;
151  std::vector<bool> usedTrackstersEM;
152  std::vector<bool> usedTrackstersTRK;
153  std::vector<bool> usedTrackstersHAD;
154  std::vector<bool> usedSeeds;
155 
157  evt.getByToken(tracks_token_, track_h);
158  const auto &tracks = *track_h;
159 
161  evt.getByToken(clusters_token_, cluster_h);
162  const auto &layerClusters = *cluster_h;
163 
164  edm::Handle<std::vector<Trackster>> trackstersem_h;
165  evt.getByToken(trackstersem_token_, trackstersem_h);
166  const auto &trackstersEM = *trackstersem_h;
167  usedTrackstersEM.resize(trackstersEM.size(), false);
168 
169  edm::Handle<std::vector<Trackster>> tracksterstrk_h;
170  evt.getByToken(tracksterstrk_token_, tracksterstrk_h);
171  const auto &trackstersTRK = *tracksterstrk_h;
172  usedTrackstersTRK.resize(trackstersTRK.size(), false);
173 
174  edm::Handle<std::vector<Trackster>> trackstershad_h;
175  evt.getByToken(trackstershad_token_, trackstershad_h);
176  const auto &trackstersHAD = *trackstershad_h;
177  usedTrackstersHAD.resize(trackstersHAD.size(), false);
178 
180  evt.getByToken(seedingTrk_token_, seedingTrk_h);
181  const auto &seedingTrk = *seedingTrk_h;
182  usedSeeds.resize(seedingTrk.size(), false);
183 
184  fillTile(tracksterTile, trackstersEM, TracksterIterIndex::EM);
185  fillTile(tracksterTile, trackstersTRK, TracksterIterIndex::TRK);
186  fillTile(tracksterTile, trackstersHAD, TracksterIterIndex::HAD);
187 
188  auto seedId = 0;
189  for (auto const &s : seedingTrk) {
190  tracksterTile.fill(TracksterIterIndex::SEED, s.origin.eta(), s.origin.phi(), seedId++);
191 
192  if (debug_) {
193  LogDebug("TrackstersMergeProducer")
194  << "Seed index: " << seedId << " internal index: " << s.index << " origin: " << s.origin
195  << " mom: " << s.directionAtOrigin << " pt: " << std::sqrt(s.directionAtOrigin.perp2())
196  << " zSide: " << s.zSide << " collectionID: " << s.collectionID << " track pt " << tracks[s.index].pt()
197  << std::endl;
198  }
199  }
200 
201  if (debug_) {
202  printTrackstersDebug(trackstersTRK, "tracksterTRK");
203  printTrackstersDebug(trackstersEM, "tracksterEM");
204  printTrackstersDebug(trackstersHAD, "tracksterHAD");
205  }
206 
207  int tracksterTRK_idx = 0;
208  int tracksterHAD_idx = 0;
210  for (auto const &t : trackstersTRK) {
211  if (debug_) {
212  int entryEtaBin = tracksterTile[TracksterIterIndex::TRK].etaBin(t.barycenter().eta());
213  int entryPhiBin = tracksterTile[TracksterIterIndex::TRK].phiBin(t.barycenter().phi());
214  int bin = tracksterTile[TracksterIterIndex::TRK].globalBin(t.barycenter().eta(), t.barycenter().phi());
215  LogDebug("TrackstersMergeProducer")
216  << "TrackstersMergeProducer Tracking obj: " << t.barycenter() << " in bin " << bin << " etaBin "
217  << entryEtaBin << " phiBin " << entryPhiBin << std::endl;
218  dumpTrackster(t);
219  }
220  auto const &track = tracks[t.seedIndex()];
221  auto trk_pt = (float)track.pt();
222  auto diff_pt = t.raw_pt() - trk_pt;
223  auto pt_err = trk_pt * resol_calo_scale_ + resol_calo_offset_;
224  auto w_cal = 1. / (pt_err * pt_err);
225  auto w_trk = 1. / (track.ptError() * track.ptError());
226  auto diff_pt_sigmas = diff_pt / pt_err;
227  auto e_over_h = (t.raw_em_pt() / ((t.raw_pt() - t.raw_em_pt()) != 0. ? (t.raw_pt() - t.raw_em_pt()) : 1.));
228  LogDebug("TrackstersMergeProducer")
229  << "trackster_pt: " << t.raw_pt() << std::endl
230  << "track pt (inner): " << track.pt() << std::endl
231  << "track eta (inner): " << track.eta() << std::endl
232  << "track _phi (inner): " << track.phi() << std::endl
233  << "track pt (outer): " << std::sqrt(track.outerMomentum().perp2()) << std::endl
234  << "track eta (outer): " << track.outerMomentum().eta() << std::endl
235  << "track _phi (outer): " << track.outerMomentum().phi() << std::endl
236  << "pt_err_track: " << track.ptError() << std::endl
237  << "diff_pt: " << diff_pt << std::endl
238  << "pt_err: " << pt_err << std::endl
239  << "diff_pt_sigmas: " << diff_pt_sigmas << std::endl
240  << "w_cal: " << w_cal << std::endl
241  << "w_trk: " << w_trk << std::endl
242  << "average_pt: " << (t.raw_pt() * w_cal + trk_pt * w_trk) / (w_cal + w_trk) << std::endl
243  << "e_over_h: " << e_over_h << std::endl;
244 
245  // If the energy is unbalanced and higher in Calo ==> balance it by
246  // emitting gammas/neutrals
247  if (diff_pt_sigmas > pt_sigma_high_) {
248  if (e_over_h > e_over_h_threshold_) {
249  auto gamma_pt = std::min(diff_pt, t.raw_em_pt());
250  // Create gamma with calo direction
251  LogDebug("TrackstersMergeProducer")
252  << " Creating a photon from TRK Trackster with energy " << gamma_pt << " and direction "
253  << t.eigenvectors(0).eta() << ", " << t.eigenvectors(0).phi() << std::endl;
254  diff_pt -= gamma_pt;
255  if (diff_pt > pt_neutral_threshold_) {
256  // Create also a neutral on top, with calo direction and diff_pt as energy
257  LogDebug("TrackstersMergeProducer")
258  << " Adding also a neutral hadron from TRK Trackster with energy " << diff_pt << " and direction "
259  << t.eigenvectors(0).eta() << ", " << t.eigenvectors(0).phi() << std::endl;
260  }
261  } else {
262  // Create neutral with calo direction
263  LogDebug("TrackstersMergeProducer")
264  << " Creating a neutral hadron from TRK Trackster with energy " << diff_pt << " and direction "
265  << t.eigenvectors(0).eta() << ", " << t.eigenvectors(0).phi() << std::endl;
266  }
267  }
268  // If the energy is in the correct ball-park (this also covers the
269  // previous case after the neutral emission), use weighted averages
270  if (diff_pt_sigmas > -pt_sigma_low_) {
271  // Create either an electron or a charged hadron, using the weighted
272  // average information between the track and the cluster for the
273  // energy, the direction of the track at the vertex. The PID is simply
274  // passed over to the final trackster, while the energy is changed.
275  auto average_pt = (w_cal * t.raw_pt() + trk_pt * w_trk) / (w_cal + w_trk);
276  LogDebug("TrackstersMergeProducer")
277  << " Creating electron/charged hadron from TRK Trackster with weighted p_t " << average_pt
278  << " and direction " << track.eta() << ", " << track.phi() << std::endl;
279 
280  }
281  // If the energy of the calo is too low, just use track-only information
282  else {
283  // Create either an electron or a charged hadron, using the track
284  // information only.
285  LogDebug("TrackstersMergeProducer")
286  << " Creating electron/charged hadron from TRK Trackster with track p_t " << trk_pt << " and direction "
287  << track.eta() << ", " << track.phi() << std::endl;
288  }
289  result->push_back(t);
290  usedTrackstersTRK[tracksterTRK_idx] = true;
291  tracksterTRK_idx++;
292  }
293  }
294 
295  tracksterTRK_idx = 0;
296  for (auto const &t : trackstersTRK) {
297  if (debug_) {
298  LogDebug("TrackstersMergeProducer") << " Considering trackster " << tracksterTRK_idx
299  << " as used: " << usedTrackstersTRK[tracksterTRK_idx] << std::endl;
300  }
301  if (!usedTrackstersTRK[tracksterTRK_idx]) {
302  LogDebug("TrackstersMergeProducer")
303  << " Creating a charge hadron from TRK Trackster with track energy " << t.raw_energy() << " and direction "
304  << t.eigenvectors(0).eta() << ", " << t.eigenvectors(0).phi() << std::endl;
305  result->push_back(t);
306  }
307  tracksterTRK_idx++;
308  }
309 
310  auto tracksterEM_idx = 0;
311  for (auto const &t : trackstersEM) {
312  if (debug_) {
313  LogDebug("TrackstersMergeProducer") << " Considering trackster " << tracksterEM_idx
314  << " as used: " << usedTrackstersEM[tracksterEM_idx] << std::endl;
315  }
316  if (!usedTrackstersEM[tracksterEM_idx]) {
317  LogDebug("TrackstersMergeProducer")
318  << " Creating a photon from EM Trackster with track energy " << t.raw_energy() << " and direction "
319  << t.eigenvectors(0).eta() << ", " << t.eigenvectors(0).phi() << std::endl;
320  result->push_back(t);
321  }
322  tracksterEM_idx++;
323  }
324 
325  tracksterHAD_idx = 0;
326  for (auto const &t : trackstersHAD) {
327  if (debug_) {
328  LogDebug("TrackstersMergeProducer") << " Considering trackster " << tracksterHAD_idx
329  << " as used: " << usedTrackstersHAD[tracksterHAD_idx] << std::endl;
330  }
331  if (!usedTrackstersHAD[tracksterHAD_idx]) {
332  LogDebug("TrackstersMergeProducer")
333  << " Creating a neutral hadron from HAD Trackster with track energy " << t.raw_energy() << " and direction "
334  << t.eigenvectors(0).eta() << ", " << t.eigenvectors(0).phi() << std::endl;
335  result->push_back(t);
336  }
337  tracksterHAD_idx++;
338  }
339 
341  energyRegressionAndID(layerClusters, *result);
342 
343  printTrackstersDebug(*result, "TrackstersMergeProducer");
344 
345  evt.put(std::move(result));
346 }
347 
348 void TrackstersMergeProducer::energyRegressionAndID(const std::vector<reco::CaloCluster> &layerClusters,
349  std::vector<Trackster> &tracksters) const {
350  // Energy regression and particle identification strategy:
351  //
352  // 1. Set default values for regressed energy and particle id for each trackster.
353  // 2. Store indices of tracksters whose total sum of cluster energies is above the
354  // eidMinClusterEnergy_ (GeV) treshold. Inference is not applied for soft tracksters.
355  // 3. When no trackster passes the selection, return.
356  // 4. Create input and output tensors. The batch dimension is determined by the number of
357  // selected tracksters.
358  // 5. Fill input tensors with layer cluster features. Per layer, clusters are ordered descending
359  // by energy. Given that tensor data is contiguous in memory, we can use pointer arithmetic to
360  // fill values, even with batching.
361  // 6. Zero-fill features for empty clusters in each layer.
362  // 7. Batched inference.
363  // 8. Assign the regressed energy and id probabilities to each trackster.
364  //
365  // Indices used throughout this method:
366  // i -> batch element / trackster
367  // j -> layer
368  // k -> cluster
369  // l -> feature
370 
371  // set default values per trackster, determine if the cluster energy threshold is passed,
372  // and store indices of hard tracksters
373  std::vector<int> tracksterIndices;
374  for (int i = 0; i < (int)tracksters.size(); i++) {
375  // calculate the cluster energy sum (2)
376  // note: after the loop, sumClusterEnergy might be just above the threshold
377  // which is enough to decide whether to run inference for the trackster or
378  // not
379  float sumClusterEnergy = 0.;
380  for (const unsigned int &vertex : tracksters[i].vertices()) {
381  sumClusterEnergy += (float)layerClusters[vertex].energy();
382  // there might be many clusters, so try to stop early
383  if (sumClusterEnergy >= eidMinClusterEnergy_) {
384  // set default values (1)
385  tracksters[i].setRegressedEnergy(0.f);
386  tracksters[i].zeroProbabilities();
387  tracksterIndices.push_back(i);
388  break;
389  }
390  }
391  }
392 
393  // do nothing when no trackster passes the selection (3)
394  int batchSize = (int)tracksterIndices.size();
395  if (batchSize == 0) {
396  return;
397  }
398 
399  // create input and output tensors (4)
400  tensorflow::TensorShape shape({batchSize, eidNLayers_, eidNClusters_, eidNFeatures_});
401  tensorflow::Tensor input(tensorflow::DT_FLOAT, shape);
403  static constexpr int inputDimension = 4;
404 
405  std::vector<tensorflow::Tensor> outputs;
406  std::vector<std::string> outputNames;
407  if (!eidOutputNameEnergy_.empty()) {
409  }
410  if (!eidOutputNameId_.empty()) {
411  outputNames.push_back(eidOutputNameId_);
412  }
413 
414  // fill input tensor (5)
415  for (int i = 0; i < batchSize; i++) {
416  const Trackster &trackster = tracksters[tracksterIndices[i]];
417 
418  // per layer, we only consider the first eidNClusters_ clusters in terms of
419  // energy, so in order to avoid creating large / nested structures to do
420  // the sorting for an unknown number of total clusters, create a sorted
421  // list of layer cluster indices to keep track of the filled clusters
422  std::vector<int> clusterIndices(trackster.vertices().size());
423  for (int k = 0; k < (int)trackster.vertices().size(); k++) {
424  clusterIndices[k] = k;
425  }
426  sort(clusterIndices.begin(), clusterIndices.end(), [&layerClusters, &trackster](const int &a, const int &b) {
427  return layerClusters[trackster.vertices(a)].energy() > layerClusters[trackster.vertices(b)].energy();
428  });
429 
430  // keep track of the number of seen clusters per layer
431  std::vector<int> seenClusters(eidNLayers_);
432 
433  // loop through clusters by descending energy
434  for (const int &k : clusterIndices) {
435  // get features per layer and cluster and store the values directly in the input tensor
436  const reco::CaloCluster &cluster = layerClusters[trackster.vertices(k)];
437  int j = rhtools_.getLayerWithOffset(cluster.hitsAndFractions()[0].first) - 1;
438  if (j < eidNLayers_ && seenClusters[j] < eidNClusters_) {
439  // get the pointer to the first feature value for the current batch, layer and cluster
440  float *features = &input.tensor<float, inputDimension>()(i, j, seenClusters[j], 0);
441 
442  // fill features
443  *(features++) = float(cluster.energy() / float(trackster.vertex_multiplicity(k)));
444  *(features++) = float(std::abs(cluster.eta()));
445  *(features) = float(cluster.phi());
446 
447  // increment seen clusters
448  seenClusters[j]++;
449  }
450  }
451 
452  // zero-fill features of empty clusters in each layer (6)
453  for (int j = 0; j < eidNLayers_; j++) {
454  for (int k = seenClusters[j]; k < eidNClusters_; k++) {
455  float *features = &input.tensor<float, inputDimension>()(i, j, k, 0);
456  for (int l = 0; l < eidNFeatures_; l++) {
457  *(features++) = 0.f;
458  }
459  }
460  }
461  }
462 
463  // run the inference (7)
465 
466  // store regressed energy per trackster (8)
467  if (!eidOutputNameEnergy_.empty()) {
468  // get the pointer to the energy tensor, dimension is batch x 1
469  float *energy = outputs[0].flat<float>().data();
470 
471  for (const int &i : tracksterIndices) {
472  tracksters[i].setRegressedEnergy(*(energy++));
473  }
474  }
475 
476  // store id probabilities per trackster (8)
477  if (!eidOutputNameId_.empty()) {
478  // get the pointer to the id probability tensor, dimension is batch x id_probabilities.size()
479  int probsIdx = !eidOutputNameEnergy_.empty();
480  float *probs = outputs[probsIdx].flat<float>().data();
481 
482  for (const int &i : tracksterIndices) {
483  tracksters[i].setProbabilities(probs);
484  probs += tracksters[i].id_probabilities().size();
485  }
486  }
487 }
488 
490  // this method is supposed to create, initialize and return a TrackstersCache instance
491  std::unique_ptr<TrackstersCache> cache = std::make_unique<TrackstersCache>(params);
492 
493  // load the graph def and save it
494  std::string graphPath = params.getParameter<std::string>("eid_graph_path");
495  if (!graphPath.empty()) {
496  graphPath = edm::FileInPath(graphPath).fullPath();
497  cache->eidGraphDef = tensorflow::loadGraphDef(graphPath);
498  }
499 
500  return cache;
501 }
502 
504  delete cache->eidGraphDef;
505  cache->eidGraphDef = nullptr;
506 }
507 
508 void TrackstersMergeProducer::printTrackstersDebug(const std::vector<Trackster> &tracksters, const char *label) const {
509  if (!debug_)
510  return;
511 
512  int counter = 0;
513  for (auto const &t : tracksters) {
514  LogDebug("TrackstersMergeProducer")
515  << counter++ << " TrackstersMergeProducer (" << label << ") obj barycenter: " << t.barycenter()
516  << " eta,phi (baricenter): " << t.barycenter().eta() << ", " << t.barycenter().phi()
517  << " eta,phi (eigen): " << t.eigenvectors(0).eta() << ", " << t.eigenvectors(0).phi()
518  << " pt(eigen): " << std::sqrt(t.eigenvectors(0).Unit().perp2()) * t.raw_energy() << " seedID: " << t.seedID()
519  << " seedIndex: " << t.seedIndex() << " size: " << t.vertices().size() << " average usage: "
520  << (std::accumulate(std::begin(t.vertex_multiplicity()), std::end(t.vertex_multiplicity()), 0.) /
521  (float)t.vertex_multiplicity().size())
522  << " raw_energy: " << t.raw_energy() << " regressed energy: " << t.regressed_energy()
523  << " probs(ga/e/mu/np/cp/nh/am/unk): ";
524  for (auto const &p : t.id_probabilities()) {
525  LogDebug("TrackstersMergeProducer") << std::fixed << p << " ";
526  }
527  LogDebug("TrackstersMergeProducer") << " sigmas: ";
528  for (auto const &s : t.sigmas()) {
529  LogDebug("TrackstersMergeProducer") << s << " ";
530  }
531  LogDebug("TrackstersMergeProducer") << std::endl;
532  }
533 }
534 
537  desc.add<edm::InputTag>("trackstersem", edm::InputTag("ticlTrackstersEM"));
538  desc.add<edm::InputTag>("tracksterstrk", edm::InputTag("ticlTrackstersTrk"));
539  desc.add<edm::InputTag>("trackstershad", edm::InputTag("ticlTrackstersHAD"));
540  desc.add<edm::InputTag>("seedingTrk", edm::InputTag("ticlSeedingTrk"));
541  desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalLayerClusters"));
542  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
543  desc.add<bool>("optimiseAcrossTracksters", true);
544  desc.add<int>("eta_bin_window", 1);
545  desc.add<int>("phi_bin_window", 1);
546  desc.add<double>("pt_sigma_high", 2.);
547  desc.add<double>("pt_sigma_low", 2.);
548  desc.add<double>("cosangle_align", 0.9945);
549  desc.add<double>("e_over_h_threshold", 1.);
550  desc.add<double>("pt_neutral_threshold", 2.);
551  desc.add<double>("resol_calo_offset", 1.5);
552  desc.add<double>("resol_calo_scale", 0.15);
553  desc.add<bool>("debug", true);
554  desc.add<std::string>("eid_graph_path", "RecoHGCal/TICL/data/tf_models/energy_id_v0.pb");
555  desc.add<std::string>("eid_input_name", "input");
556  desc.add<std::string>("eid_output_name_energy", "output/regressed_energy");
557  desc.add<std::string>("eid_output_name_id", "output/id_probabilities");
558  desc.add<double>("eid_min_cluster_energy", 1.);
559  desc.add<int>("eid_n_layers", 50);
560  desc.add<int>("eid_n_clusters", 10);
561  descriptions.add("trackstersMergeProducer", desc);
562 }
563 
ConfigurationDescriptions.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
TrackstersPCA.h
counter
Definition: counter.py:1
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
ticl::assignPCAtoTracksters
void assignPCAtoTracksters(std::vector< Trackster > &, const std::vector< reco::CaloCluster > &, double, bool energyWeight=true)
Definition: TrackstersPCA.cc:10
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
hgcal::RecHitTools
Definition: RecHitTools.h:21
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
Common.h
input
static const std::string input
Definition: EdmProvDump.cc:48
TensorFlow.h
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
Trackster.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
BeamMonitor_cff.phiBin
phiBin
Definition: BeamMonitor_cff.py:75
min
T min(T a, T b)
Definition: MathUtil.h:58
postprocess-scan-build.features
features
Definition: postprocess-scan-build.py:8
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
TICLGenericTile
Definition: TICLLayerTile.h:57
TrackstersMergeProducer::TracksterIterIndex
TracksterIterIndex
Definition: TrackstersMergeProducer.cc:35
TrackstersMergeProducer::eta_bin_window_
const int eta_bin_window_
Definition: TrackstersMergeProducer.cc:49
TrackstersMergeProducer::printTrackstersDebug
void printTrackstersDebug(const std::vector< Trackster > &, const char *label) const
Definition: TrackstersMergeProducer.cc:508
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
PatBasicFWLiteJetAnalyzer_Selector_cfg.outputs
outputs
Definition: PatBasicFWLiteJetAnalyzer_Selector_cfg.py:48
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TrackstersMergeProducer::seedingTrk_token_
const edm::EDGetTokenT< std::vector< TICLSeedingRegion > > seedingTrk_token_
Definition: TrackstersMergeProducer.cc:45
TrackstersMergeProducer::resol_calo_scale_
const double resol_calo_scale_
Definition: TrackstersMergeProducer.cc:57
EDProducer.h
TrackstersMergeProducer::eidMinClusterEnergy_
const float eidMinClusterEnergy_
Definition: TrackstersMergeProducer.cc:62
TrackstersMergeProducer::eidOutputNameId_
const std::string eidOutputNameId_
Definition: TrackstersMergeProducer.cc:61
TrackstersMergeProducer::fillTile
void fillTile(TICLTracksterTiles &, const std::vector< Trackster > &, TracksterIterIndex)
Definition: TrackstersMergeProducer.cc:108
TrackstersMergeProducer::trackstersem_token_
const edm::EDGetTokenT< std::vector< Trackster > > trackstersem_token_
Definition: TrackstersMergeProducer.cc:42
TrackstersMergeProducer::pt_neutral_threshold_
const double pt_neutral_threshold_
Definition: TrackstersMergeProducer.cc:55
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
ticl
Definition: Common.h:8
edm::Handle
Definition: AssociativeIterator.h:50
TrackstersMergeProducer::tracksterstrk_token_
const edm::EDGetTokenT< std::vector< Trackster > > tracksterstrk_token_
Definition: TrackstersMergeProducer.cc:43
end
#define end
Definition: vmac.h:39
TrackstersMergeProducer::clusters_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
Definition: TrackstersMergeProducer.cc:46
TrackstersMergeProducer::energyRegressionAndID
void energyRegressionAndID(const std::vector< reco::CaloCluster > &layerClusters, std::vector< Trackster > &result) const
Definition: TrackstersMergeProducer.cc:348
TICLLayerTile.h
edm::FileInPath
Definition: FileInPath.h:64
TrackstersMergeProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: TrackstersMergeProducer.cc:145
MakerMacros.h
TrackstersMergeProducer::eidNFeatures_
static constexpr int eidNFeatures_
Definition: TrackstersMergeProducer.cc:69
alignCSCRings.s
s
Definition: alignCSCRings.py:92
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
ticl::TrackstersCache
Definition: GlobalCache.h:19
ticl::CacheBase
Definition: GlobalCache.h:11
TrackstersMergeProducer::rhtools_
hgcal::RecHitTools rhtools_
Definition: TrackstersMergeProducer.cc:67
TrackstersMergeProducer::~TrackstersMergeProducer
~TrackstersMergeProducer() override
Definition: TrackstersMergeProducer.cc:25
TrackstersMergeProducer::initializeGlobalCache
static std::unique_ptr< TrackstersCache > initializeGlobalCache(const edm::ParameterSet &)
Definition: TrackstersMergeProducer.cc:489
reco::CaloCluster
Definition: CaloCluster.h:31
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
ticl::Trackster::vertex_multiplicity
std::vector< uint8_t > & vertex_multiplicity()
Definition: Trackster.h:54
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TrackstersMergeProducer::e_over_h_threshold_
const double e_over_h_threshold_
Definition: TrackstersMergeProducer.cc:54
DDAxes::z
tmtt::Utility::SEED
Definition: Utility.h:28
TrackstersMergeProducer::phi_bin_window_
const int phi_bin_window_
Definition: TrackstersMergeProducer.cc:50
TrackstersMergeProducer::pt_sigma_low_
const double pt_sigma_low_
Definition: TrackstersMergeProducer.cc:52
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
dqmdumpme.k
k
Definition: dqmdumpme.py:60
OrderedSet.t
t
Definition: OrderedSet.py:90
b
double b
Definition: hdecay.h:118
TrackstersMergeProducer::tracks_token_
const edm::EDGetTokenT< std::vector< reco::Track > > tracks_token_
Definition: TrackstersMergeProducer.cc:47
TrackstersMergeProducer::eidNLayers_
const int eidNLayers_
Definition: TrackstersMergeProducer.cc:63
utilities.cache
def cache(function)
Definition: utilities.py:3
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GlobalCache.h
TrackstersMergeProducer::eidInputName_
const std::string eidInputName_
Definition: TrackstersMergeProducer.cc:59
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
a
double a
Definition: hdecay.h:119
reco::CaloCluster::eta
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
TrackstersMergeProducer::TRK
Definition: TrackstersMergeProducer.cc:35
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
TrackstersMergeProducer::TrackstersMergeProducer
TrackstersMergeProducer(const edm::ParameterSet &ps, const CacheBase *cache)
Definition: TrackstersMergeProducer.cc:72
hgcal::RecHitTools::getLayerWithOffset
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:357
hgcal::RecHitTools::lastLayerEE
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:63
tensorflow::NamedTensorList
std::vector< NamedTensor > NamedTensorList
Definition: TensorFlow.h:30
TrackstersMergeProducer::dumpTrackster
void dumpTrackster(const Trackster &) const
Definition: TrackstersMergeProducer.cc:123
TrackstersMergeProducer::eidOutputNameEnergy_
const std::string eidOutputNameEnergy_
Definition: TrackstersMergeProducer.cc:60
createfilelist.int
int
Definition: createfilelist.py:10
TrackstersMergeProducer::resol_calo_offset_
const double resol_calo_offset_
Definition: TrackstersMergeProducer.cc:56
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
edm::stream::EDProducer
Definition: EDProducer.h:38
TrackstersMergeProducer::optimiseAcrossTracksters_
const bool optimiseAcrossTracksters_
Definition: TrackstersMergeProducer.cc:48
TrackstersMergeProducer::globalEndJob
static void globalEndJob(TrackstersCache *)
Definition: TrackstersMergeProducer.cc:503
edm::EventSetup
Definition: EventSetup.h:57
hgcal::RecHitTools::getPositionLayer
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:143
hgcal::RecHitTools::getEventSetup
void getEventSetup(const edm::EventSetup &)
Definition: RecHitTools.cc:70
ticl::TrackstersCache::eidGraphDef
std::atomic< tensorflow::GraphDef * > eidGraphDef
Definition: GlobalCache.h:25
TrackstersMergeProducer::trackstershad_token_
const edm::EDGetTokenT< std::vector< Trackster > > trackstershad_token_
Definition: TrackstersMergeProducer.cc:44
TICLSeedingRegion
Definition: TICLSeedingRegion.h:14
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
tensorflow::loadGraphDef
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:68
TICLSeedingRegion.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
ticl::Trackster::vertices
std::vector< unsigned int > & vertices()
Definition: Trackster.h:53
Exception
Definition: hltDiff.cc:246
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:211
TrackstersMergeProducer
Definition: TrackstersMergeProducer.cc:22
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
TrackstersMergeProducer::debug_
const bool debug_
Definition: TrackstersMergeProducer.cc:58
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
mps_fire.result
result
Definition: mps_fire.py:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackstersMergeProducer::pt_sigma_high_
const double pt_sigma_high_
Definition: TrackstersMergeProducer.cc:51
TrackstersMergeProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TrackstersMergeProducer.cc:535
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
TrackstersMergeProducer::eidNClusters_
const int eidNClusters_
Definition: TrackstersMergeProducer.cc:64
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
TrackstersMergeProducer::cosangle_align_
const double cosangle_align_
Definition: TrackstersMergeProducer.cc:53
edm::InputTag
Definition: InputTag.h:15
begin
#define begin
Definition: vmac.h:32
label
const char * label
Definition: PFTauDecayModeTools.cc:11
RecHitTools.h
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163
TrackstersMergeProducer::eidSession_
tensorflow::Session * eidSession_
Definition: TrackstersMergeProducer.cc:66
ticl::Trackster
Definition: Trackster.h:19
jets_cff.outputNames
outputNames
Definition: jets_cff.py:294
CaloCluster.h
TICLGenericTile::fill
void fill(int index, double eta, double phi, unsigned int objectId)
Definition: TICLLayerTile.h:63
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7