CMS 3D CMS Logo

TICLDumper.cc
Go to the documentation of this file.
1 // Authors: Philipp Zehetner, Wahid Redjeb, Aurora Perego, Felice Pantaleo
2 
3 #include "TTree.h"
4 #include "TFile.h"
5 
6 #include <iostream>
7 #include <fstream>
8 #include <sstream>
9 #include <variant>
10 
11 #include <memory> // unique_ptr
24 
40 
46 
49 
53 
57 
59 
60 // TFileService
63 
66 // Helper class for geometry, magnetic field, etc
68 public:
70  const CaloGeometry& geom,
71  const MagneticField& bfieldH,
72  const Propagator& propH)
73  : hgcons(hgcons), rhtools(), bfield(bfieldH), propagator(propH) {
75 
76  // build disks at HGCal front & EM-Had interface for track propagation
77  float zVal = hgcons.waferZ(1, true);
78  std::pair<float, float> rMinMax = hgcons.rangeR(zVal, true);
79 
80  float zVal_interface = rhtools.getPositionLayer(rhtools.lastLayerEE()).z();
81  std::pair<float, float> rMinMax_interface = hgcons.rangeR(zVal_interface, true);
82 
83  for (int iSide = 0; iSide < 2; ++iSide) {
84  float zSide = (iSide == 0) ? (-1. * zVal) : zVal;
85  firstDisk_[iSide] = std::make_unique<GeomDet>(
86  Disk::build(Disk::PositionType(0, 0, zSide),
88  SimpleDiskBounds(rMinMax.first, rMinMax.second, zSide - 0.5, zSide + 0.5))
89  .get());
90 
91  zSide = (iSide == 0) ? (-1. * zVal_interface) : zVal_interface;
92  interfaceDisk_[iSide] = std::make_unique<GeomDet>(
93  Disk::build(Disk::PositionType(0, 0, zSide),
95  SimpleDiskBounds(rMinMax_interface.first, rMinMax_interface.second, zSide - 0.5, zSide + 0.5))
96  .get());
97  }
98  }
99 
101  std::unique_ptr<GeomDet> firstDisk_[2];
102  std::unique_ptr<GeomDet> interfaceDisk_[2];
106 };
107 
108 // Helper class that dumps a single trackster collection (either tracksters or simTracksters)
110 public:
111  enum class TracksterType {
112  Trackster,
115  };
116 
118  if (str == "Trackster")
120  if (str == "SimTracksterCP")
122  if (str == "SimTracksterSC")
124  throw std::runtime_error("TICLDumper : TracksterDumperHelper : Invalid trackster type " + str);
125  }
126 
129 
134  void initTree(TTree* trackster_tree_, edm::EventID* eventId_) {
135  trackster_tree_->Branch("event", eventId_);
136  trackster_tree_->Branch("NTracksters", &nTracksters);
137  trackster_tree_->Branch("NClusters", &nClusters);
138  trackster_tree_->Branch("time", &trackster_time);
139  trackster_tree_->Branch("timeError", &trackster_timeError);
140  trackster_tree_->Branch("regressed_energy", &trackster_regressed_energy);
141  trackster_tree_->Branch("raw_energy", &trackster_raw_energy);
142  trackster_tree_->Branch("raw_em_energy", &trackster_raw_em_energy);
143  trackster_tree_->Branch("raw_pt", &trackster_raw_pt);
144  trackster_tree_->Branch("raw_em_pt", &trackster_raw_em_pt);
145  trackster_tree_->Branch("barycenter_x", &trackster_barycenter_x);
146  trackster_tree_->Branch("barycenter_y", &trackster_barycenter_y);
147  trackster_tree_->Branch("barycenter_z", &trackster_barycenter_z);
148  trackster_tree_->Branch("barycenter_eta", &trackster_barycenter_eta);
149  trackster_tree_->Branch("barycenter_phi", &trackster_barycenter_phi);
150  trackster_tree_->Branch("EV1", &trackster_EV1);
151  trackster_tree_->Branch("EV2", &trackster_EV2);
152  trackster_tree_->Branch("EV3", &trackster_EV3);
153  trackster_tree_->Branch("eVector0_x", &trackster_eVector0_x);
154  trackster_tree_->Branch("eVector0_y", &trackster_eVector0_y);
155  trackster_tree_->Branch("eVector0_z", &trackster_eVector0_z);
156  trackster_tree_->Branch("sigmaPCA1", &trackster_sigmaPCA1);
157  trackster_tree_->Branch("sigmaPCA2", &trackster_sigmaPCA2);
158  trackster_tree_->Branch("sigmaPCA3", &trackster_sigmaPCA3);
160  trackster_tree_->Branch("regressed_pt", &simtrackster_regressed_pt);
161  trackster_tree_->Branch("pdgID", &simtrackster_pdgID);
162  trackster_tree_->Branch("trackIdx", &simtrackster_trackIdx);
163  trackster_tree_->Branch("trackTime", &simtrackster_trackTime);
164  trackster_tree_->Branch("timeBoundary", &simtrackster_timeBoundary);
165  trackster_tree_->Branch("boundaryX", &simtrackster_boundaryX);
166  trackster_tree_->Branch("boundaryY", &simtrackster_boundaryY);
167  trackster_tree_->Branch("boundaryZ", &simtrackster_boundaryZ);
168  trackster_tree_->Branch("boundaryEta", &simtrackster_boundaryEta);
169  trackster_tree_->Branch("boundaryPhi", &simtrackster_boundaryPhi);
170  trackster_tree_->Branch("boundaryPx", &simtrackster_boundaryPx);
171  trackster_tree_->Branch("boundaryPy", &simtrackster_boundaryPy);
172  trackster_tree_->Branch("boundaryPz", &simtrackster_boundaryPz);
173  trackster_tree_->Branch("track_boundaryX", &simtrackster_track_boundaryX);
174  trackster_tree_->Branch("track_boundaryY", &simtrackster_track_boundaryY);
175  trackster_tree_->Branch("track_boundaryZ", &simtrackster_track_boundaryZ);
176  trackster_tree_->Branch("track_boundaryEta", &simtrackster_track_boundaryEta);
177  trackster_tree_->Branch("track_boundaryPhi", &simtrackster_track_boundaryPhi);
178  trackster_tree_->Branch("track_boundaryPx", &simtrackster_track_boundaryPx);
179  trackster_tree_->Branch("track_boundaryPy", &simtrackster_track_boundaryPy);
180  trackster_tree_->Branch("track_boundaryPz", &simtrackster_track_boundaryPz);
181  }
182  trackster_tree_->Branch("id_probabilities", &trackster_id_probabilities);
183  trackster_tree_->Branch("vertices_indexes", &trackster_vertices_indexes);
184  trackster_tree_->Branch("vertices_x", &trackster_vertices_x);
185  trackster_tree_->Branch("vertices_y", &trackster_vertices_y);
186  trackster_tree_->Branch("vertices_z", &trackster_vertices_z);
187  trackster_tree_->Branch("vertices_time", &trackster_vertices_time);
188  trackster_tree_->Branch("vertices_timeErr", &trackster_vertices_timeErr);
189  trackster_tree_->Branch("vertices_energy", &trackster_vertices_energy);
190  trackster_tree_->Branch("vertices_correctedEnergy", &trackster_vertices_correctedEnergy);
191  trackster_tree_->Branch("vertices_correctedEnergyUncertainty", &trackster_vertices_correctedEnergyUncertainty);
192  trackster_tree_->Branch("vertices_multiplicity", &trackster_vertices_multiplicity);
193  }
194 
195  void clearVariables() {
196  nTracksters = 0;
197  nClusters = 0;
198  trackster_time.clear();
199  trackster_timeError.clear();
201  trackster_raw_energy.clear();
202  trackster_raw_em_energy.clear();
203  trackster_raw_pt.clear();
204  trackster_raw_em_pt.clear();
205  trackster_barycenter_x.clear();
206  trackster_barycenter_y.clear();
207  trackster_barycenter_z.clear();
208  trackster_EV1.clear();
209  trackster_EV2.clear();
210  trackster_EV3.clear();
211  trackster_eVector0_x.clear();
212  trackster_eVector0_y.clear();
213  trackster_eVector0_z.clear();
214  trackster_sigmaPCA1.clear();
215  trackster_sigmaPCA2.clear();
216  trackster_sigmaPCA3.clear();
217 
219  simtrackster_pdgID.clear();
220  simtrackster_trackIdx.clear();
221  simtrackster_trackTime.clear();
223  simtrackster_boundaryX.clear();
224  simtrackster_boundaryY.clear();
225  simtrackster_boundaryZ.clear();
226  simtrackster_boundaryEta.clear();
227  simtrackster_boundaryPhi.clear();
228  simtrackster_boundaryPx.clear();
229  simtrackster_boundaryPy.clear();
230  simtrackster_boundaryPz.clear();
239 
240  trackster_barycenter_eta.clear();
241  trackster_barycenter_phi.clear();
244  trackster_vertices_x.clear();
245  trackster_vertices_y.clear();
246  trackster_vertices_z.clear();
247  trackster_vertices_time.clear();
253  }
254 
255  void fillFromEvent(std::vector<ticl::Trackster> const& tracksters,
256  std::vector<reco::CaloCluster> const& clusters,
257  edm::ValueMap<std::pair<float, float>> const& layerClustersTimes,
258  DetectorTools const& detectorTools,
259  edm::Handle<std::vector<SimCluster>> simClusters_h,
260  edm::Handle<std::vector<CaloParticle>> caloparticles_h,
261  std::vector<reco::Track> const& tracks) {
262  nTracksters = tracksters.size();
263  nClusters = clusters.size();
264  for (auto trackster_iterator = tracksters.begin(); trackster_iterator != tracksters.end(); ++trackster_iterator) {
265  //per-trackster analysis
266  trackster_time.push_back(trackster_iterator->time());
267  trackster_timeError.push_back(trackster_iterator->timeError());
268  trackster_regressed_energy.push_back(trackster_iterator->regressed_energy());
269  trackster_raw_energy.push_back(trackster_iterator->raw_energy());
270  trackster_raw_em_energy.push_back(trackster_iterator->raw_em_energy());
271  trackster_raw_pt.push_back(trackster_iterator->raw_pt());
272  trackster_raw_em_pt.push_back(trackster_iterator->raw_em_pt());
273  trackster_barycenter_x.push_back(trackster_iterator->barycenter().x());
274  trackster_barycenter_y.push_back(trackster_iterator->barycenter().y());
275  trackster_barycenter_z.push_back(trackster_iterator->barycenter().z());
276  trackster_barycenter_eta.push_back(trackster_iterator->barycenter().eta());
277  trackster_barycenter_phi.push_back(trackster_iterator->barycenter().phi());
278  trackster_EV1.push_back(trackster_iterator->eigenvalues()[0]);
279  trackster_EV2.push_back(trackster_iterator->eigenvalues()[1]);
280  trackster_EV3.push_back(trackster_iterator->eigenvalues()[2]);
281  trackster_eVector0_x.push_back((trackster_iterator->eigenvectors()[0]).x());
282  trackster_eVector0_y.push_back((trackster_iterator->eigenvectors()[0]).y());
283  trackster_eVector0_z.push_back((trackster_iterator->eigenvectors()[0]).z());
284  trackster_sigmaPCA1.push_back(trackster_iterator->sigmasPCA()[0]);
285  trackster_sigmaPCA2.push_back(trackster_iterator->sigmasPCA()[1]);
286  trackster_sigmaPCA3.push_back(trackster_iterator->sigmasPCA()[2]);
287 
288  if (tracksterType_ != TracksterType::Trackster) { // is simtrackster
289  auto const& simclusters = *simClusters_h;
290  auto const& caloparticles = *caloparticles_h;
291 
292  simtrackster_timeBoundary.push_back(trackster_iterator->boundaryTime());
293 
295  simtrackster_pdgID.push_back(caloparticles[trackster_iterator->seedIndex()].pdgId());
297  simtrackster_pdgID.push_back(simclusters[trackster_iterator->seedIndex()].pdgId());
298 
299  using CaloObjectVariant = std::variant<CaloParticle, SimCluster>;
300  CaloObjectVariant caloObj;
301  if (trackster_iterator->seedID() == caloparticles_h.id()) {
302  caloObj = caloparticles[trackster_iterator->seedIndex()];
303  } else {
304  caloObj = simclusters[trackster_iterator->seedIndex()];
305  }
306 
307  auto const& simTrack = std::visit([](auto&& obj) { return obj.g4Tracks()[0]; }, caloObj);
308  auto const& caloPt = std::visit([](auto&& obj) { return obj.pt(); }, caloObj);
309  simtrackster_regressed_pt.push_back(caloPt);
310  if (simTrack.crossedBoundary()) {
311  simtrackster_boundaryX.push_back(simTrack.getPositionAtBoundary().x());
312  simtrackster_boundaryY.push_back(simTrack.getPositionAtBoundary().y());
313  simtrackster_boundaryZ.push_back(simTrack.getPositionAtBoundary().z());
314  simtrackster_boundaryEta.push_back(simTrack.getPositionAtBoundary().eta());
315  simtrackster_boundaryPhi.push_back(simTrack.getPositionAtBoundary().phi());
316  simtrackster_boundaryPx.push_back(simTrack.getMomentumAtBoundary().x());
317  simtrackster_boundaryPy.push_back(simTrack.getMomentumAtBoundary().y());
318  simtrackster_boundaryPz.push_back(simTrack.getMomentumAtBoundary().z());
319  } else {
320  simtrackster_boundaryX.push_back(-999);
321  simtrackster_boundaryY.push_back(-999);
322  simtrackster_boundaryZ.push_back(-999);
323  simtrackster_boundaryEta.push_back(-999);
324  simtrackster_boundaryPhi.push_back(-999);
325  simtrackster_boundaryPx.push_back(-999);
326  simtrackster_boundaryPy.push_back(-999);
327  simtrackster_boundaryPz.push_back(-999);
328  }
329 
330  auto const trackIdx = trackster_iterator->trackIdx();
331  simtrackster_trackIdx.push_back(trackIdx);
332  if (trackIdx != -1) {
333  const auto& track = tracks[trackIdx];
334 
335  int iSide = int(track.eta() > 0);
336 
337  const auto& fts = trajectoryStateTransform::outerFreeState((track), &detectorTools.bfield);
338  // to the HGCal front
339  const auto& tsos = detectorTools.propagator.propagate(fts, detectorTools.firstDisk_[iSide]->surface());
340  if (tsos.isValid()) {
341  const auto& globalPos = tsos.globalPosition();
342  const auto& globalMom = tsos.globalMomentum();
343  simtrackster_track_boundaryX.push_back(globalPos.x());
344  simtrackster_track_boundaryY.push_back(globalPos.y());
345  simtrackster_track_boundaryZ.push_back(globalPos.z());
346  simtrackster_track_boundaryEta.push_back(globalPos.eta());
347  simtrackster_track_boundaryPhi.push_back(globalPos.phi());
348  simtrackster_track_boundaryPx.push_back(globalMom.x());
349  simtrackster_track_boundaryPy.push_back(globalMom.y());
350  simtrackster_track_boundaryPz.push_back(globalMom.z());
351  simtrackster_trackTime.push_back(track.t0());
352  } else {
353  simtrackster_track_boundaryX.push_back(-999);
354  simtrackster_track_boundaryY.push_back(-999);
355  simtrackster_track_boundaryZ.push_back(-999);
356  simtrackster_track_boundaryEta.push_back(-999);
357  simtrackster_track_boundaryPhi.push_back(-999);
358  simtrackster_track_boundaryPx.push_back(-999);
359  simtrackster_track_boundaryPy.push_back(-999);
360  simtrackster_track_boundaryPz.push_back(-999);
361  }
362  } else {
363  simtrackster_track_boundaryX.push_back(-999);
364  simtrackster_track_boundaryY.push_back(-999);
365  simtrackster_track_boundaryZ.push_back(-999);
366  simtrackster_track_boundaryEta.push_back(-999);
367  simtrackster_track_boundaryPhi.push_back(-999);
368  simtrackster_track_boundaryPx.push_back(-999);
369  simtrackster_track_boundaryPy.push_back(-999);
370  simtrackster_track_boundaryPz.push_back(-999);
371  }
372  }
373 
374  std::vector<float> id_probs;
375  for (size_t i = 0; i < 8; i++)
376  id_probs.push_back(trackster_iterator->id_probabilities(i));
377  trackster_id_probabilities.push_back(id_probs);
378 
379  // Clusters
380  std::vector<uint32_t> vertices_indexes;
381  std::vector<float> vertices_x;
382  std::vector<float> vertices_y;
383  std::vector<float> vertices_z;
384  std::vector<float> vertices_time;
385  std::vector<float> vertices_timeErr;
386  std::vector<float> vertices_energy;
387  std::vector<float> vertices_correctedEnergy;
388  std::vector<float> vertices_correctedEnergyUncertainty;
389  for (auto idx : trackster_iterator->vertices()) {
390  vertices_indexes.push_back(idx);
391  const auto& associated_cluster = clusters[idx];
392  vertices_x.push_back(associated_cluster.x());
393  vertices_y.push_back(associated_cluster.y());
394  vertices_z.push_back(associated_cluster.z());
395  vertices_energy.push_back(associated_cluster.energy());
396  vertices_correctedEnergy.push_back(associated_cluster.correctedEnergy());
397  vertices_correctedEnergyUncertainty.push_back(associated_cluster.correctedEnergyUncertainty());
398  vertices_time.push_back(layerClustersTimes.get(idx).first);
399  vertices_timeErr.push_back(layerClustersTimes.get(idx).second);
400  }
401  trackster_vertices_indexes.push_back(vertices_indexes);
402  trackster_vertices_x.push_back(vertices_x);
403  trackster_vertices_y.push_back(vertices_y);
404  trackster_vertices_z.push_back(vertices_z);
405  trackster_vertices_time.push_back(vertices_time);
406  trackster_vertices_timeErr.push_back(vertices_timeErr);
407  trackster_vertices_energy.push_back(vertices_energy);
408  trackster_vertices_correctedEnergy.push_back(vertices_correctedEnergy);
409  trackster_vertices_correctedEnergyUncertainty.push_back(vertices_correctedEnergyUncertainty);
410 
411  // Multiplicity
412  std::vector<float> vertices_multiplicity;
413  for (auto multiplicity : trackster_iterator->vertex_multiplicity()) {
414  vertices_multiplicity.push_back(multiplicity);
415  }
416  trackster_vertices_multiplicity.push_back(vertices_multiplicity);
417  }
418  }
419 
420 private:
422 
423  unsigned int nTracksters;
424  unsigned int nClusters;
425  std::vector<float> trackster_time;
426  std::vector<float> trackster_timeError;
427  std::vector<float> trackster_regressed_energy;
428  std::vector<float> trackster_raw_energy;
429  std::vector<float> trackster_raw_em_energy;
430  std::vector<float> trackster_raw_pt;
431  std::vector<float> trackster_raw_em_pt;
432  std::vector<float> trackster_barycenter_x;
433  std::vector<float> trackster_barycenter_y;
434  std::vector<float> trackster_barycenter_z;
435  std::vector<float> trackster_EV1;
436  std::vector<float> trackster_EV2;
437  std::vector<float> trackster_EV3;
438  std::vector<float> trackster_eVector0_x;
439  std::vector<float> trackster_eVector0_y;
440  std::vector<float> trackster_eVector0_z;
441  std::vector<float> trackster_sigmaPCA1;
442  std::vector<float> trackster_sigmaPCA2;
443  std::vector<float> trackster_sigmaPCA3;
444  std::vector<float> trackster_barycenter_eta;
445  std::vector<float> trackster_barycenter_phi;
446 
447  // for simtrackster
448  std::vector<float> simtrackster_regressed_pt;
449  std::vector<int> simtrackster_pdgID;
450  std::vector<int> simtrackster_trackIdx;
451  std::vector<float> simtrackster_trackTime;
452  std::vector<float> simtrackster_timeBoundary;
453  std::vector<float> simtrackster_boundaryX;
454  std::vector<float> simtrackster_boundaryY;
455  std::vector<float> simtrackster_boundaryZ;
456  std::vector<float> simtrackster_boundaryEta;
457  std::vector<float> simtrackster_boundaryPhi;
458  std::vector<float> simtrackster_boundaryPx;
459  std::vector<float> simtrackster_boundaryPy;
460  std::vector<float> simtrackster_boundaryPz;
461  std::vector<float> simtrackster_track_boundaryX;
462  std::vector<float> simtrackster_track_boundaryY;
463  std::vector<float> simtrackster_track_boundaryZ;
464  std::vector<float> simtrackster_track_boundaryEta;
465  std::vector<float> simtrackster_track_boundaryPhi;
466  std::vector<float> simtrackster_track_boundaryPx;
467  std::vector<float> simtrackster_track_boundaryPy;
468  std::vector<float> simtrackster_track_boundaryPz;
469 
470  std::vector<std::vector<float>> trackster_id_probabilities;
471  std::vector<std::vector<uint32_t>> trackster_vertices_indexes;
472  std::vector<std::vector<float>> trackster_vertices_x;
473  std::vector<std::vector<float>> trackster_vertices_y;
474  std::vector<std::vector<float>> trackster_vertices_z;
475  std::vector<std::vector<float>> trackster_vertices_time;
476  std::vector<std::vector<float>> trackster_vertices_timeErr;
477  std::vector<std::vector<float>> trackster_vertices_energy;
478  std::vector<std::vector<float>> trackster_vertices_correctedEnergy;
479  std::vector<std::vector<float>> trackster_vertices_correctedEnergyUncertainty;
480  std::vector<std::vector<float>> trackster_vertices_multiplicity;
481 };
482 
483 // Helper class to dump a TracksterToSimTrackster association map (dumps recoToSim and simToReco at the same time)
485 public:
491  void initTree(TTree* tree, std::string branchPrefix, std::string branchSuffix) {
492  tree->Branch((branchPrefix + "_recoToSim_" + branchSuffix).c_str(), &recoToSim);
493  tree->Branch((branchPrefix + "_recoToSim_" + branchSuffix + "_score").c_str(), &recoToSim_score);
494  tree->Branch((branchPrefix + "_recoToSim_" + branchSuffix + "_sharedE").c_str(), &recoToSim_sharedE);
495  tree->Branch((branchPrefix + "_simToReco_" + branchSuffix).c_str(), &simToReco);
496  tree->Branch((branchPrefix + "_simToReco_" + branchSuffix + "_score").c_str(), &simToReco_score);
497  tree->Branch((branchPrefix + "_simToReco_" + branchSuffix + "_sharedE").c_str(), &simToReco_sharedE);
498  }
499 
500  void clearVariables() {
501  recoToSim.clear();
502  recoToSim_score.clear();
503  recoToSim_sharedE.clear();
504  simToReco.clear();
505  simToReco_score.clear();
506  simToReco_sharedE.clear();
507  }
508 
509  void fillFromEvent(TracksterToTracksterMap const& recoToSimMap, TracksterToTracksterMap const& simToRecoMap) {
510  // Reco -> Sim
511  const auto numberOfTracksters = recoToSimMap.getMap().size();
512  recoToSim.resize(numberOfTracksters);
513  recoToSim_score.resize(numberOfTracksters);
514  recoToSim_sharedE.resize(numberOfTracksters);
515 
516  for (size_t i = 0; i < numberOfTracksters; ++i) {
517  for (const auto& [simTracksterIndex, sharedEnergyAndScorePair] : recoToSimMap[i]) {
518  recoToSim[i].push_back(simTracksterIndex);
519  recoToSim_sharedE[i].push_back(sharedEnergyAndScorePair.first);
520  recoToSim_score[i].push_back(sharedEnergyAndScorePair.second);
521  }
522  }
523 
524  // Sim -> Reco
525  const auto numberOfSimTracksters = simToRecoMap.getMap().size();
526  simToReco.resize(numberOfSimTracksters);
527  simToReco_score.resize(numberOfSimTracksters);
528  simToReco_sharedE.resize(numberOfSimTracksters);
529 
530  for (size_t i = 0; i < numberOfSimTracksters; ++i) {
531  for (const auto& [recoTracksterIndex, sharedEnergyAndScorePair] : simToRecoMap[i]) {
532  simToReco[i].push_back(recoTracksterIndex);
533  simToReco_sharedE[i].push_back(sharedEnergyAndScorePair.first);
534  simToReco_score[i].push_back(sharedEnergyAndScorePair.second);
535  }
536  }
537  }
538 
539 private:
540  std::vector<std::vector<uint32_t>> recoToSim;
541  std::vector<std::vector<float>> recoToSim_score;
542  std::vector<std::vector<float>> recoToSim_sharedE;
543  std::vector<std::vector<uint32_t>> simToReco;
544  std::vector<std::vector<float>> simToReco_score;
545  std::vector<std::vector<float>> simToReco_sharedE;
546 };
547 
548 class TICLDumper : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
549 public:
550  explicit TICLDumper(const edm::ParameterSet&);
551  ~TICLDumper() override;
552  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
554  typedef std::vector<double> Vec;
555 
556 private:
557  void beginJob() override;
558  void beginRun(const edm::Run&, const edm::EventSetup&) override;
559 
560  void analyze(const edm::Event&, const edm::EventSetup&) override;
561  void endRun(edm::Run const& iEvent, edm::EventSetup const&) override {};
562  void endJob() override;
563 
564  // Define Tokens
565  const std::vector<edm::ParameterSet>
567  std::vector<edm::EDGetTokenT<std::vector<ticl::Trackster>>>
569  std::vector<TracksterDumperHelper>
571  std::vector<TTree*> tracksters_trees;
572 
605 
606  // associators
607  const std::vector<edm::ParameterSet>
609  std::vector<edm::EDGetTokenT<TracksterToTracksterMap>>
611  std::vector<edm::EDGetTokenT<TracksterToTracksterMap>> associations_recoToSim_token_;
612  std::vector<TracksterToSimTracksterAssociationHelper>
614 
616 
619 
626  std::unique_ptr<DetectorTools> detectorTools_;
627  bool saveLCs_;
634 
635  // Output tree
636  TTree* tree_;
637 
638  void clearVariables();
639 
640  // Variables for branches
642  unsigned int nclusters_;
643 
644  std::vector<std::vector<unsigned int>>
645  superclustering_linkedResultTracksters; // Map of indices from superclusteredTracksters collection back into ticlTrackstersCLUE3DEM collection
646  // reco::SuperCluster dump
647  std::vector<double> recoSuperCluster_rawEnergy;
648  std::vector<double> recoSuperCluster_energy;
649  std::vector<double> recoSuperCluster_correctedEnergy;
650  std::vector<double> recoSuperCluster_position_x;
651  std::vector<double> recoSuperCluster_position_y;
652  std::vector<double> recoSuperCluster_position_z;
653  std::vector<double> recoSuperCluster_position_eta;
654  std::vector<double> recoSuperCluster_position_phi;
655  std::vector<uint32_t>
657  std::vector<std::vector<uint32_t>>
659 
660  std::vector<float> simTICLCandidate_raw_energy;
662  std::vector<std::vector<int>> simTICLCandidate_simTracksterCPIndex;
663  std::vector<float> simTICLCandidate_boundaryX;
664  std::vector<float> simTICLCandidate_boundaryY;
665  std::vector<float> simTICLCandidate_boundaryZ;
666  std::vector<float> simTICLCandidate_boundaryPx;
667  std::vector<float> simTICLCandidate_boundaryPy;
668  std::vector<float> simTICLCandidate_boundaryPz;
670  std::vector<float> simTICLCandidate_time;
671  std::vector<int> simTICLCandidate_pdgId;
672  std::vector<int> simTICLCandidate_charge;
674 
675  // from TICLCandidate, product of linking
676  size_t nCandidates;
677  std::vector<int> candidate_charge;
678  std::vector<int> candidate_pdgId;
679  std::vector<float> candidate_energy;
680  std::vector<float> candidate_raw_energy;
681  std::vector<double> candidate_px;
682  std::vector<double> candidate_py;
683  std::vector<double> candidate_pz;
684  std::vector<float> candidate_time;
685  std::vector<float> candidate_time_err;
686  std::vector<std::vector<float>> candidate_id_probabilities;
687  std::vector<std::vector<uint32_t>> tracksters_in_candidate;
688  std::vector<int> track_in_candidate;
689 
690  // Layer clusters
691  std::vector<uint32_t> cluster_seedID;
692  std::vector<float> cluster_energy;
693  std::vector<float> cluster_correctedEnergy;
695  std::vector<float> cluster_position_x;
696  std::vector<float> cluster_position_y;
697  std::vector<float> cluster_position_z;
698  std::vector<float> cluster_position_eta;
699  std::vector<float> cluster_position_phi;
700  std::vector<unsigned int> cluster_layer_id;
701  std::vector<int> cluster_type;
702  std::vector<float> cluster_time;
703  std::vector<float> cluster_timeErr;
704  std::vector<uint32_t> cluster_number_of_hits;
705 
706  // Tracks
707  std::vector<unsigned int> track_id;
708  std::vector<float> track_hgcal_x;
709  std::vector<float> track_hgcal_y;
710  std::vector<float> track_hgcal_z;
711  std::vector<float> track_hgcal_px;
712  std::vector<float> track_hgcal_py;
713  std::vector<float> track_hgcal_pz;
714  std::vector<float> track_hgcal_eta;
715  std::vector<float> track_hgcal_phi;
716  std::vector<float> track_hgcal_pt;
717  std::vector<float> track_pt;
718  std::vector<int> track_quality;
719  std::vector<int> track_missing_outer_hits;
720  std::vector<int> track_missing_inner_hits;
721  std::vector<int> track_charge;
722  std::vector<double> track_time;
723  std::vector<float> track_time_quality;
724  std::vector<float> track_time_err;
725  std::vector<float> track_beta;
726  std::vector<float> track_time_mtd;
727  std::vector<float> track_time_mtd_err;
728  std::vector<GlobalPoint> track_pos_mtd;
729  std::vector<int> track_nhits;
730  std::vector<int> track_isMuon;
731  std::vector<int> track_isTrackerMuon;
732 
736  TTree* tracks_tree_;
738 };
739 
741  // event info
742  nclusters_ = 0;
743 
745  tsDumper.clearVariables();
746  }
747 
749 
751  recoSuperCluster_energy.clear();
758  recoSuperCluster_seedTs.clear();
760 
770  simTICLCandidate_time.clear();
772  simTICLCandidate_pdgId.clear();
773  simTICLCandidate_charge.clear();
775 
776  nCandidates = 0;
777  candidate_charge.clear();
778  candidate_pdgId.clear();
779  candidate_energy.clear();
780  candidate_raw_energy.clear();
781  candidate_px.clear();
782  candidate_py.clear();
783  candidate_pz.clear();
784  candidate_time.clear();
785  candidate_time_err.clear();
787  tracksters_in_candidate.clear();
788  track_in_candidate.clear();
789 
790  for (auto& helper : associations_dumperHelpers_) {
791  helper.clearVariables();
792  }
793 
794  cluster_seedID.clear();
795  cluster_energy.clear();
796  cluster_correctedEnergy.clear();
798  cluster_position_x.clear();
799  cluster_position_y.clear();
800  cluster_position_z.clear();
801  cluster_position_eta.clear();
802  cluster_position_phi.clear();
803  cluster_layer_id.clear();
804  cluster_type.clear();
805  cluster_time.clear();
806  cluster_timeErr.clear();
807  cluster_number_of_hits.clear();
808 
809  track_id.clear();
810  track_hgcal_x.clear();
811  track_hgcal_y.clear();
812  track_hgcal_z.clear();
813  track_hgcal_eta.clear();
814  track_hgcal_phi.clear();
815  track_hgcal_px.clear();
816  track_hgcal_py.clear();
817  track_hgcal_pz.clear();
818  track_hgcal_pt.clear();
819  track_quality.clear();
820  track_pt.clear();
821  track_missing_outer_hits.clear();
822  track_missing_inner_hits.clear();
823  track_charge.clear();
824  track_time.clear();
825  track_time_quality.clear();
826  track_time_err.clear();
827  track_beta.clear();
828  track_time_mtd.clear();
829  track_time_mtd_err.clear();
830  track_pos_mtd.clear();
831  track_nhits.clear();
832  track_isMuon.clear();
833  track_isTrackerMuon.clear();
834 };
835 
837  : tracksters_parameterSets_(ps.getParameter<std::vector<edm::ParameterSet>>("tracksterCollections")),
838  tracksters_token_(),
839  tracksters_in_candidate_token_(
840  consumes<std::vector<ticl::Trackster>>(ps.getParameter<edm::InputTag>("trackstersInCand"))),
841  layer_clusters_token_(consumes<std::vector<reco::CaloCluster>>(ps.getParameter<edm::InputTag>("layerClusters"))),
842  ticl_candidates_token_(consumes<std::vector<TICLCandidate>>(ps.getParameter<edm::InputTag>("ticlcandidates"))),
843  ticl_candidates_tracksters_token_(
844  consumes<std::vector<ticl::Trackster>>(ps.getParameter<edm::InputTag>("ticlcandidates"))),
845  tracks_token_(consumes<std::vector<reco::Track>>(ps.getParameter<edm::InputTag>("tracks"))),
846  tracks_time_token_(consumes<edm::ValueMap<float>>(ps.getParameter<edm::InputTag>("tracksTime"))),
847  tracks_time_quality_token_(consumes<edm::ValueMap<float>>(ps.getParameter<edm::InputTag>("tracksTimeQual"))),
848  tracks_time_err_token_(consumes<edm::ValueMap<float>>(ps.getParameter<edm::InputTag>("tracksTimeErr"))),
849  tracks_beta_token_(consumes<edm::ValueMap<float>>(ps.getParameter<edm::InputTag>("tracksBeta"))),
850  tracks_time_mtd_token_(consumes<edm::ValueMap<float>>(ps.getParameter<edm::InputTag>("tracksTimeMtd"))),
851  tracks_time_mtd_err_token_(consumes<edm::ValueMap<float>>(ps.getParameter<edm::InputTag>("tracksTimeMtdErr"))),
852  tracks_pos_mtd_token_(consumes<edm::ValueMap<GlobalPoint>>(ps.getParameter<edm::InputTag>("tracksPosMtd"))),
853  muons_token_(consumes<std::vector<reco::Muon>>(ps.getParameter<edm::InputTag>("muons"))),
854  clustersTime_token_(
855  consumes<edm::ValueMap<std::pair<float, float>>>(ps.getParameter<edm::InputTag>("layer_clustersTime"))),
856  superclustering_linkedResultTracksters_token(
857  consumes<std::vector<std::vector<unsigned int>>>(ps.getParameter<edm::InputTag>("superclustering"))),
858  recoSuperClusters_token(
859  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("recoSuperClusters"))),
860  recoSuperClusters_caloClusters_token(
861  consumes<reco::CaloClusterCollection>(ps.getParameter<edm::InputTag>("recoSuperClusters"))),
862  recoSuperClusters_sourceTracksters_token(consumes<std::vector<ticl::Trackster>>(
863  ps.getParameter<edm::InputTag>("recoSuperClusters_sourceTracksterCollection"))),
864  caloGeometry_token_(esConsumes<CaloGeometry, CaloGeometryRecord, edm::Transition::BeginRun>()),
865  simTracksters_SC_token_(
866  consumes<std::vector<ticl::Trackster>>(ps.getParameter<edm::InputTag>("simtrackstersSC"))),
867  simTICLCandidate_token_(
868  consumes<std::vector<TICLCandidate>>(ps.getParameter<edm::InputTag>("simTICLCandidates"))),
869  associations_parameterSets_(ps.getParameter<std::vector<edm::ParameterSet>>("associators")),
870  // The DumperHelpers should not be moved after construction (needed by TTree branch pointers), so construct them all here
871  associations_dumperHelpers_(associations_parameterSets_.size()),
872  simclusters_token_(consumes(ps.getParameter<edm::InputTag>("simclusters"))),
873  caloparticles_token_(consumes(ps.getParameter<edm::InputTag>("caloparticles"))),
874  geometry_token_(esConsumes<CaloGeometry, CaloGeometryRecord, edm::Transition::BeginRun>()),
875  detector_(ps.getParameter<std::string>("detector")),
876  propName_(ps.getParameter<std::string>("propagator")),
877  bfield_token_(esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()),
878  propagator_token_(
880  saveLCs_(ps.getParameter<bool>("saveLCs")),
881  saveSuperclustering_(ps.getParameter<bool>("saveSuperclustering")),
882  //saveSuperclusteringDNNScore_(ps.getParameter<bool>("saveSuperclusteringDNNScore")),
883  saveRecoSuperclusters_(ps.getParameter<bool>("saveRecoSuperclusters")),
884  saveTICLCandidate_(ps.getParameter<bool>("saveSimTICLCandidate")),
885  saveSimTICLCandidate_(ps.getParameter<bool>("saveSimTICLCandidate")),
886  saveTracks_(ps.getParameter<bool>("saveTracks")) {
887  std::string detectorName_ = (detector_ == "HFNose") ? "HGCalHFNoseSensitive" : "HGCalEESensitive";
888  hdc_token_ =
889  esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(edm::ESInputTag("", detectorName_));
890 
891  for (edm::ParameterSet const& tracksterPset : tracksters_parameterSets_) {
892  tracksters_token_.push_back(
893  consumes<std::vector<ticl::Trackster>>(tracksterPset.getParameter<edm::InputTag>("inputTag")));
894  tracksters_dumperHelpers_.emplace_back(
895  TracksterDumperHelper::tracksterTypeFromString(tracksterPset.getParameter<std::string>("tracksterType")));
896  }
897 
898  for (edm::ParameterSet const& associationPset : associations_parameterSets_) {
899  associations_recoToSim_token_.push_back(consumes<TracksterToTracksterMap>(
900  edm::InputTag(associationPset.getParameter<edm::InputTag>("associatorRecoToSimInputTag"))));
901  associations_simToReco_token_.push_back(consumes<TracksterToTracksterMap>(
902  edm::InputTag(associationPset.getParameter<edm::InputTag>("associatorSimToRecoInputTag"))));
903  }
904 };
905 
907 
909  detectorTools_ = std::make_unique<DetectorTools>(es.getData(hdc_token_),
913 }
914 
915 // Define tree and branches
918 
919  // Trackster trees
920  for (unsigned int i = 0; i < tracksters_parameterSets_.size(); i++) {
921  edm::ParameterSet const& tracksterPset = tracksters_parameterSets_[i];
922  TTree* tree =
923  fs->make<TTree>(tracksterPset.getParameter<std::string>("treeName").c_str(),
924  ("Tracksters : " + tracksterPset.getParameter<std::string>("treeName") +
925  " (InputTag : " + tracksterPset.getParameter<edm::InputTag>("inputTag").encode() + ")")
926  .c_str());
927  tracksters_trees.push_back(tree);
929  }
930  if (saveLCs_) {
931  cluster_tree_ = fs->make<TTree>("clusters", "TICL tracksters");
932  cluster_tree_->Branch("event", &eventId_);
933  cluster_tree_->Branch("seedID", &cluster_seedID);
934  cluster_tree_->Branch("energy", &cluster_energy);
935  cluster_tree_->Branch("correctedEnergy", &cluster_correctedEnergy);
936  cluster_tree_->Branch("correctedEnergyUncertainty", &cluster_correctedEnergyUncertainty);
937  cluster_tree_->Branch("position_x", &cluster_position_x);
938  cluster_tree_->Branch("position_y", &cluster_position_y);
939  cluster_tree_->Branch("position_z", &cluster_position_z);
940  cluster_tree_->Branch("position_eta", &cluster_position_eta);
941  cluster_tree_->Branch("position_phi", &cluster_position_phi);
942  cluster_tree_->Branch("cluster_layer_id", &cluster_layer_id);
943  cluster_tree_->Branch("cluster_type", &cluster_type);
944  cluster_tree_->Branch("cluster_time", &cluster_time);
945  cluster_tree_->Branch("cluster_timeErr", &cluster_timeErr);
946  cluster_tree_->Branch("cluster_number_of_hits", &cluster_number_of_hits);
947  }
948  if (saveTICLCandidate_) {
949  candidate_tree_ = fs->make<TTree>("candidates", "TICL candidates");
950  candidate_tree_->Branch("event", &eventId_);
951  candidate_tree_->Branch("NCandidates", &nCandidates);
952  candidate_tree_->Branch("candidate_charge", &candidate_charge);
953  candidate_tree_->Branch("candidate_pdgId", &candidate_pdgId);
954  candidate_tree_->Branch("candidate_id_probabilities", &candidate_id_probabilities);
955  candidate_tree_->Branch("candidate_time", &candidate_time);
956  candidate_tree_->Branch("candidate_timeErr", &candidate_time_err);
957  candidate_tree_->Branch("candidate_energy", &candidate_energy);
958  candidate_tree_->Branch("candidate_raw_energy", &candidate_raw_energy);
959  candidate_tree_->Branch("candidate_px", &candidate_px);
960  candidate_tree_->Branch("candidate_py", &candidate_py);
961  candidate_tree_->Branch("candidate_pz", &candidate_pz);
962  candidate_tree_->Branch("track_in_candidate", &track_in_candidate);
963  candidate_tree_->Branch("tracksters_in_candidate", &tracksters_in_candidate);
964  }
966  superclustering_tree_ = fs->make<TTree>("superclustering", "Superclustering in HGCAL CE-E");
967  superclustering_tree_->Branch("event", &eventId_);
968  }
969  if (saveSuperclustering_) {
970  superclustering_tree_->Branch("linkedResultTracksters", &superclustering_linkedResultTracksters);
971  }
973  superclustering_tree_->Branch("recoSuperCluster_rawEnergy", &recoSuperCluster_rawEnergy);
974  superclustering_tree_->Branch("recoSuperCluster_energy", &recoSuperCluster_energy);
975  superclustering_tree_->Branch("recoSuperCluster_correctedEnergy", &recoSuperCluster_correctedEnergy);
976  superclustering_tree_->Branch("recoSuperCluster_position_x", &recoSuperCluster_position_x);
977  superclustering_tree_->Branch("recoSuperCluster_position_y", &recoSuperCluster_position_y);
978  superclustering_tree_->Branch("recoSuperCluster_position_z", &recoSuperCluster_position_z);
979  superclustering_tree_->Branch("recoSuperCluster_position_eta", &recoSuperCluster_position_eta);
980  superclustering_tree_->Branch("recoSuperCluster_position_phi", &recoSuperCluster_position_phi);
981  superclustering_tree_->Branch("recoSuperCluster_seedTs", &recoSuperCluster_seedTs);
982  superclustering_tree_->Branch("recoSuperCluster_constituentTs", &recoSuperCluster_constituentTs);
983  }
984 
985  if (associations_parameterSets_.size() > 0) {
986  associations_tree_ = fs->make<TTree>("associations", "Associations");
987  associations_tree_->Branch("event", &eventId_);
988  }
989  for (unsigned int i = 0; i < associations_parameterSets_.size(); i++) {
991  associations_parameterSets_[i].getParameter<std::string>("branchName"),
992  associations_parameterSets_[i].getParameter<std::string>("suffix"));
993  }
994 
995  if (saveTracks_) {
996  tracks_tree_ = fs->make<TTree>("tracks", "Tracks");
997  tracks_tree_->Branch("event", &eventId_);
998  tracks_tree_->Branch("track_id", &track_id);
999  tracks_tree_->Branch("track_hgcal_x", &track_hgcal_x);
1000  tracks_tree_->Branch("track_hgcal_y", &track_hgcal_y);
1001  tracks_tree_->Branch("track_hgcal_z", &track_hgcal_z);
1002  tracks_tree_->Branch("track_hgcal_eta", &track_hgcal_eta);
1003  tracks_tree_->Branch("track_hgcal_phi", &track_hgcal_phi);
1004  tracks_tree_->Branch("track_hgcal_pt", &track_hgcal_pt);
1005  tracks_tree_->Branch("track_pt", &track_pt);
1006  tracks_tree_->Branch("track_missing_outer_hits", &track_missing_outer_hits);
1007  tracks_tree_->Branch("track_missing_inner_hits", &track_missing_inner_hits);
1008  tracks_tree_->Branch("track_quality", &track_quality);
1009  tracks_tree_->Branch("track_charge", &track_charge);
1010  tracks_tree_->Branch("track_time", &track_time);
1011  tracks_tree_->Branch("track_time_quality", &track_time_quality);
1012  tracks_tree_->Branch("track_time_err", &track_time_err);
1013  tracks_tree_->Branch("track_beta", &track_beta);
1014  tracks_tree_->Branch("track_time_mtd", &track_time_mtd);
1015  tracks_tree_->Branch("track_time_mtd_err", &track_time_mtd_err);
1016  tracks_tree_->Branch("track_pos_mtd", &track_pos_mtd);
1017  tracks_tree_->Branch("track_nhits", &track_nhits);
1018  tracks_tree_->Branch("track_isMuon", &track_isMuon);
1019  tracks_tree_->Branch("track_isTrackerMuon", &track_isTrackerMuon);
1020  }
1021 
1022  if (saveSimTICLCandidate_) {
1023  simTICLCandidate_tree = fs->make<TTree>("simTICLCandidate", "Sim TICL Candidate");
1024  simTICLCandidate_tree->Branch("event", &eventId_);
1025  simTICLCandidate_tree->Branch("simTICLCandidate_raw_energy", &simTICLCandidate_raw_energy);
1026  simTICLCandidate_tree->Branch("simTICLCandidate_regressed_energy", &simTICLCandidate_regressed_energy);
1027  simTICLCandidate_tree->Branch("simTICLCandidate_simTracksterCPIndex", &simTICLCandidate_simTracksterCPIndex);
1028  simTICLCandidate_tree->Branch("simTICLCandidate_boundaryX", &simTICLCandidate_boundaryX);
1029  simTICLCandidate_tree->Branch("simTICLCandidate_boundaryY", &simTICLCandidate_boundaryY);
1030  simTICLCandidate_tree->Branch("simTICLCandidate_boundaryZ", &simTICLCandidate_boundaryZ);
1031  simTICLCandidate_tree->Branch("simTICLCandidate_boundaryPx", &simTICLCandidate_boundaryPx);
1032  simTICLCandidate_tree->Branch("simTICLCandidate_boundaryPy", &simTICLCandidate_boundaryPy);
1033  simTICLCandidate_tree->Branch("simTICLCandidate_boundaryPz", &simTICLCandidate_boundaryPz);
1034  simTICLCandidate_tree->Branch("simTICLCandidate_time", &simTICLCandidate_time);
1035  simTICLCandidate_tree->Branch("simTICLCandidate_caloParticleMass", &simTICLCandidate_caloParticleMass);
1036  simTICLCandidate_tree->Branch("simTICLCandidate_pdgId", &simTICLCandidate_pdgId);
1037  simTICLCandidate_tree->Branch("simTICLCandidate_charge", &simTICLCandidate_charge);
1038  simTICLCandidate_tree->Branch("simTICLCandidate_track_in_candidate", &simTICLCandidate_track_in_candidate);
1039  }
1040 }
1041 
1043  eventId_ = event.id();
1044  clearVariables();
1045 
1046  edm::Handle<std::vector<ticl::Trackster>> tracksters_in_candidate_handle;
1047  event.getByToken(tracksters_in_candidate_token_, tracksters_in_candidate_handle);
1048 
1049  //get all the layer clusters
1051  event.getByToken(layer_clusters_token_, layer_clusters_h);
1052  const auto& clusters = *layer_clusters_h;
1053 
1055  event.getByToken(clustersTime_token_, clustersTime_h);
1056  const auto& layerClustersTimes = *clustersTime_h;
1057 
1058  //TICL Candidate
1060  event.getByToken(ticl_candidates_token_, candidates_h);
1061  const auto& ticlcandidates = *candidates_h;
1062  edm::Handle<std::vector<ticl::Trackster>> ticlcandidates_tracksters_h =
1063  event.getHandle(ticl_candidates_tracksters_token_);
1064 
1065  //Track
1067  event.getByToken(tracks_token_, tracks_h);
1068  const auto& tracks = *tracks_h;
1069 
1070  edm::Handle<edm::ValueMap<float>> trackTime_h;
1071  event.getByToken(tracks_time_token_, trackTime_h);
1072  const auto& trackTime = *trackTime_h;
1073 
1074  edm::Handle<edm::ValueMap<float>> trackTimeErr_h;
1075  event.getByToken(tracks_time_err_token_, trackTimeErr_h);
1076  const auto& trackTimeErr = *trackTimeErr_h;
1077 
1078  edm::Handle<edm::ValueMap<float>> trackBeta_h;
1079  event.getByToken(tracks_beta_token_, trackBeta_h);
1080  const auto& trackBeta = *trackBeta_h;
1081 
1082  edm::Handle<edm::ValueMap<float>> trackTimeQual_h;
1083  event.getByToken(tracks_time_quality_token_, trackTimeQual_h);
1084  const auto& trackTimeQual = *trackTimeQual_h;
1085 
1086  edm::Handle<edm::ValueMap<float>> trackTimeMtd_h;
1087  event.getByToken(tracks_time_mtd_token_, trackTimeMtd_h);
1088  const auto& trackTimeMtd = *trackTimeMtd_h;
1089 
1090  edm::Handle<edm::ValueMap<float>> trackTimeMtdErr_h;
1091  event.getByToken(tracks_time_mtd_err_token_, trackTimeMtdErr_h);
1092  const auto& trackTimeMtdErr = *trackTimeMtdErr_h;
1093 
1095  event.getByToken(tracks_pos_mtd_token_, trackPosMtd_h);
1096  const auto& trackPosMtd = *trackPosMtd_h;
1097 
1098  // superclustering
1099  if (saveSuperclustering_) // To support running with Mustache
1101 
1102  // muons
1104  event.getByToken(muons_token_, muons_h);
1105  auto& muons = *muons_h;
1106 
1107  // recoSuperClusters
1108  if (saveRecoSuperclusters_) {
1109  reco::SuperClusterCollection const& recoSuperClusters = event.get(recoSuperClusters_token);
1110  // reco::CaloClusterCollection const& recoCaloClusters = event.get(recoSuperClusters_caloClusters_token);
1111  std::vector<ticl::Trackster> const& recoSuperClusters_sourceTracksters =
1113 
1114  // Map for fast lookup of hit to trackster index in recoSuperClusters_sourceTracksters
1115  std::unordered_map<DetId, unsigned> hitToTracksterMap;
1116 
1117  for (unsigned ts_id = 0; ts_id < recoSuperClusters_sourceTracksters.size(); ts_id++) {
1118  for (unsigned int lc_index : recoSuperClusters_sourceTracksters[ts_id].vertices()) {
1119  for (auto [detId, fraction] : clusters[lc_index].hitsAndFractions()) {
1120  bool insertionSucceeded = hitToTracksterMap.emplace(detId, ts_id).second;
1121  assert(insertionSucceeded && "TICLDumper found tracksters sharing rechits");
1122  }
1123  }
1124  }
1125 
1126  for (auto const& recoSc : recoSuperClusters) {
1127  recoSuperCluster_rawEnergy.push_back(recoSc.rawEnergy());
1128  recoSuperCluster_energy.push_back(recoSc.energy());
1129  recoSuperCluster_correctedEnergy.push_back(recoSc.correctedEnergy());
1130  recoSuperCluster_position_x.push_back(recoSc.position().x());
1131  recoSuperCluster_position_y.push_back(recoSc.position().y());
1132  recoSuperCluster_position_z.push_back(recoSc.position().z());
1133  recoSuperCluster_position_eta.push_back(recoSc.position().eta());
1134  recoSuperCluster_position_phi.push_back(recoSc.position().phi());
1135 
1136  // Finding the trackster that was used to create the CaloCluster, using the DetId of a hit (we assume there is no sharing of rechits between tracksters)
1137 
1138  // Seed trackster of the supercluster : Using the DetId of the seed rechit of the seed CaloCluster
1139  recoSuperCluster_seedTs.push_back(hitToTracksterMap.at(recoSc.seed()->seed()));
1140  recoSuperCluster_constituentTs.emplace_back();
1141  for (edm::Ptr<reco::CaloCluster> const& caloClusterPtr : recoSc.clusters()) {
1142  // Using the DetId of the seed rechit of the CaloCluster
1143  recoSuperCluster_constituentTs.back().push_back(hitToTracksterMap.at(caloClusterPtr->seed()));
1144  }
1145  }
1146  }
1147 
1148  edm::Handle<std::vector<TICLCandidate>> simTICLCandidates_h;
1149  event.getByToken(simTICLCandidate_token_, simTICLCandidates_h);
1150  const auto& simTICLCandidates = *simTICLCandidates_h;
1151 
1152  edm::Handle<std::vector<CaloParticle>> caloparticles_h;
1153  event.getByToken(caloparticles_token_, caloparticles_h);
1154 
1155  auto simclusters_h = event.getHandle(simclusters_token_);
1156 
1157  nclusters_ = clusters.size();
1158 
1159  // Save all the trackster collections
1160  for (unsigned int i = 0; i < tracksters_dumperHelpers_.size(); i++) {
1161  edm::Handle<std::vector<ticl::Trackster>> tracksters_handle;
1162  std::vector<ticl::Trackster> const& tracksters = event.get<std::vector<ticl::Trackster>>(tracksters_token_[i]);
1163  tracksters_dumperHelpers_[i].fillFromEvent(
1164  tracksters, clusters, layerClustersTimes, *detectorTools_, simclusters_h, caloparticles_h, tracks);
1165  tracksters_trees[i]->Fill();
1166  }
1167 
1168  const auto& simTrackstersSC_h = event.getHandle(simTracksters_SC_token_);
1169  simTICLCandidate_track_in_candidate.resize(simTICLCandidates.size(), -1);
1170  for (size_t i = 0; i < simTICLCandidates.size(); ++i) {
1171  auto const& cand = simTICLCandidates[i];
1172 
1173  simTICLCandidate_raw_energy.push_back(cand.rawEnergy());
1174  simTICLCandidate_regressed_energy.push_back(cand.p4().energy());
1175  simTICLCandidate_pdgId.push_back(cand.pdgId());
1176  simTICLCandidate_charge.push_back(cand.charge());
1177  simTICLCandidate_time.push_back(cand.time());
1178  std::vector<int> tmpIdxVec;
1179  for (auto const& simTS : cand.tracksters()) {
1180  auto trackster_idx = simTS.get() - (edm::Ptr<ticl::Trackster>(simTrackstersSC_h, 0)).get();
1181  tmpIdxVec.push_back(trackster_idx);
1182  }
1183  simTICLCandidate_simTracksterCPIndex.push_back(tmpIdxVec);
1184  tmpIdxVec.clear();
1185  auto const& trackPtr = cand.trackPtr();
1186  if (!trackPtr.isNull()) {
1187  auto const& track = *trackPtr;
1188  int iSide = int(track.eta() > 0);
1189  int tk_idx = trackPtr.get() - (edm::Ptr<reco::Track>(tracks_h, 0)).get();
1191 
1192  const auto& fts = trajectoryStateTransform::outerFreeState((track), &detectorTools_->bfield);
1193  // to the HGCal front
1194  const auto& tsos = detectorTools_->propagator.propagate(fts, detectorTools_->firstDisk_[iSide]->surface());
1195  if (tsos.isValid()) {
1196  const auto& globalPos = tsos.globalPosition();
1197  const auto& globalMom = tsos.globalMomentum();
1198  simTICLCandidate_boundaryX.push_back(globalPos.x());
1199  simTICLCandidate_boundaryY.push_back(globalPos.y());
1200  simTICLCandidate_boundaryZ.push_back(globalPos.z());
1201  simTICLCandidate_boundaryPx.push_back(globalMom.x());
1202  simTICLCandidate_boundaryPy.push_back(globalMom.y());
1203  simTICLCandidate_boundaryPz.push_back(globalMom.z());
1204  } else {
1205  simTICLCandidate_boundaryX.push_back(-999);
1206  simTICLCandidate_boundaryY.push_back(-999);
1207  simTICLCandidate_boundaryZ.push_back(-999);
1208  simTICLCandidate_boundaryPx.push_back(-999);
1209  simTICLCandidate_boundaryPy.push_back(-999);
1210  simTICLCandidate_boundaryPz.push_back(-999);
1211  }
1212  } else {
1213  simTICLCandidate_boundaryX.push_back(-999);
1214  simTICLCandidate_boundaryY.push_back(-999);
1215  simTICLCandidate_boundaryZ.push_back(-999);
1216  simTICLCandidate_boundaryPx.push_back(-999);
1217  simTICLCandidate_boundaryPy.push_back(-999);
1218  simTICLCandidate_boundaryPz.push_back(-999);
1219  }
1220  }
1221 
1222  int c_id = 0;
1223 
1224  for (auto cluster_iterator = clusters.begin(); cluster_iterator != clusters.end(); ++cluster_iterator) {
1225  auto lc_seed = cluster_iterator->seed();
1226  cluster_seedID.push_back(lc_seed);
1227  cluster_energy.push_back(cluster_iterator->energy());
1228  cluster_correctedEnergy.push_back(cluster_iterator->correctedEnergy());
1229  cluster_correctedEnergyUncertainty.push_back(cluster_iterator->correctedEnergyUncertainty());
1230  cluster_position_x.push_back(cluster_iterator->x());
1231  cluster_position_y.push_back(cluster_iterator->y());
1232  cluster_position_z.push_back(cluster_iterator->z());
1233  cluster_position_eta.push_back(cluster_iterator->eta());
1234  cluster_position_phi.push_back(cluster_iterator->phi());
1235  auto haf = cluster_iterator->hitsAndFractions();
1236  auto layerId = detectorTools_->rhtools.getLayerWithOffset(haf[0].first);
1237  cluster_layer_id.push_back(layerId);
1238  uint32_t number_of_hits = cluster_iterator->hitsAndFractions().size();
1239  cluster_number_of_hits.push_back(number_of_hits);
1240  cluster_type.push_back(detectorTools_->rhtools.getCellType(lc_seed));
1241  cluster_timeErr.push_back(layerClustersTimes.get(c_id).second);
1242  cluster_time.push_back(layerClustersTimes.get(c_id).first);
1243  c_id += 1;
1244  }
1245 
1246  tracksters_in_candidate.resize(ticlcandidates.size());
1247  track_in_candidate.resize(ticlcandidates.size(), -1);
1248  nCandidates = ticlcandidates.size();
1249  for (int i = 0; i < static_cast<int>(ticlcandidates.size()); ++i) {
1250  const auto& candidate = ticlcandidates[i];
1251  candidate_charge.push_back(candidate.charge());
1252  candidate_pdgId.push_back(candidate.pdgId());
1253  candidate_energy.push_back(candidate.energy());
1254  candidate_raw_energy.push_back(candidate.rawEnergy());
1255  candidate_px.push_back(candidate.px());
1256  candidate_py.push_back(candidate.py());
1257  candidate_pz.push_back(candidate.pz());
1258  candidate_time.push_back(candidate.time());
1259  candidate_time_err.push_back(candidate.timeError());
1260  std::vector<float> id_probs;
1261  for (int j = 0; j < 8; j++) {
1263  id_probs.push_back(candidate.id_probability(type));
1264  }
1265  candidate_id_probabilities.push_back(id_probs);
1266 
1267  auto trackster_ptrs = candidate.tracksters();
1268  auto track_ptr = candidate.trackPtr();
1269  for (const auto& ts_ptr : trackster_ptrs) {
1270  auto ts_idx = ts_ptr.get() - (edm::Ptr<ticl::Trackster>(tracksters_in_candidate_handle, 0)).get();
1271  tracksters_in_candidate[i].push_back(ts_idx);
1272  }
1273  if (track_ptr.isNull())
1274  continue;
1275  int tk_idx = track_ptr.get() - (edm::Ptr<reco::Track>(tracks_h, 0)).get();
1276  track_in_candidate[i] = tk_idx;
1277  }
1278 
1279  // trackster to simTrackster associations
1280  for (unsigned int i = 0; i < associations_dumperHelpers_.size(); i++) {
1282  event.get(associations_simToReco_token_[i]));
1283  }
1284  if (associations_dumperHelpers_.size() > 0)
1285  associations_tree_->Fill();
1286 
1287  //Tracks
1288  for (size_t i = 0; i < tracks.size(); i++) {
1289  const auto& track = tracks[i];
1290  reco::TrackRef trackref = reco::TrackRef(tracks_h, i);
1291  int iSide = int(track.eta() > 0);
1292  const auto& fts = trajectoryStateTransform::outerFreeState((track), &detectorTools_->bfield);
1293  // to the HGCal front
1294  const auto& tsos = detectorTools_->propagator.propagate(fts, detectorTools_->firstDisk_[iSide]->surface());
1295  if (tsos.isValid()) {
1296  const auto& globalPos = tsos.globalPosition();
1297  const auto& globalMom = tsos.globalMomentum();
1298  track_id.push_back(i);
1299  track_hgcal_x.push_back(globalPos.x());
1300  track_hgcal_y.push_back(globalPos.y());
1301  track_hgcal_z.push_back(globalPos.z());
1302  track_hgcal_eta.push_back(globalPos.eta());
1303  track_hgcal_phi.push_back(globalPos.phi());
1304  track_hgcal_px.push_back(globalMom.x());
1305  track_hgcal_py.push_back(globalMom.y());
1306  track_hgcal_pz.push_back(globalMom.z());
1307  track_hgcal_pt.push_back(globalMom.perp());
1308  track_pt.push_back(track.pt());
1309  track_quality.push_back(track.quality(reco::TrackBase::highPurity));
1310  track_missing_outer_hits.push_back(track.missingOuterHits());
1311  track_missing_inner_hits.push_back(track.missingInnerHits());
1312  track_charge.push_back(track.charge());
1313  track_time.push_back(trackTime[trackref]);
1314  track_time_quality.push_back(trackTimeQual[trackref]);
1315  track_time_err.push_back(trackTimeErr[trackref]);
1316  track_beta.push_back(trackBeta[trackref]);
1317  track_time_mtd.push_back(trackTimeMtd[trackref]);
1318  track_time_mtd_err.push_back(trackTimeMtdErr[trackref]);
1319  track_pos_mtd.push_back(trackPosMtd[trackref]);
1320  track_nhits.push_back(tracks[i].recHitsSize());
1321  int muId = PFMuonAlgo::muAssocToTrack(trackref, *muons_h);
1322  if (muId != -1) {
1323  const reco::MuonRef muonref = reco::MuonRef(muons_h, muId);
1324  track_isMuon.push_back(PFMuonAlgo::isMuon(muonref));
1325  track_isTrackerMuon.push_back(muons[muId].isTrackerMuon());
1326  } else {
1327  track_isMuon.push_back(-1);
1328  track_isTrackerMuon.push_back(-1);
1329  }
1330  }
1331  }
1332 
1333  if (saveLCs_)
1334  cluster_tree_->Fill();
1335  if (saveTICLCandidate_)
1336  candidate_tree_->Fill();
1338  superclustering_tree_->Fill();
1339  if (saveTracks_)
1340  tracks_tree_->Fill();
1342  simTICLCandidate_tree->Fill();
1343 }
1344 
1346 
1349 
1350  // Settings for dumping trackster collections
1351  edm::ParameterSetDescription tracksterDescValidator;
1352  tracksterDescValidator.add<std::string>("treeName")
1353  ->setComment("Name of the output tree for the trackster collection");
1354  tracksterDescValidator.add<edm::InputTag>("inputTag")->setComment("Input tag for the trackster collection to write");
1355  tracksterDescValidator.ifValue(
1357  "tracksterType",
1358  "Trackster",
1359  true,
1360  edm::Comment("Type of trackster. Trackster=regular trackster (from RECO). SimTracksterCP=Simtrackster "
1361  "from CaloParticle. SimTracksterSC=Simtrackster from SimCluster")),
1362  edm::allowedValues<std::string>("Trackster", "SimTracksterCP", "SimTracksterSC"));
1363  desc.addVPSet("tracksterCollections", tracksterDescValidator)->setComment("Trackster collections to dump");
1364 
1365  desc.add<edm::InputTag>("trackstersInCand", edm::InputTag("ticlTrackstersCLUE3DHigh"));
1366 
1367  desc.add<edm::InputTag>("layerClusters", edm::InputTag("hgcalMergeLayerClusters"));
1368  desc.add<edm::InputTag>("layer_clustersTime", edm::InputTag("hgcalMergeLayerClusters", "timeLayerCluster"));
1369  desc.add<edm::InputTag>("ticlcandidates", edm::InputTag("ticlTrackstersMerge"));
1370  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
1371  desc.add<edm::InputTag>("tracksTime", edm::InputTag("tofPID:t0"));
1372  desc.add<edm::InputTag>("tracksTimeQual", edm::InputTag("mtdTrackQualityMVA:mtdQualMVA"));
1373  desc.add<edm::InputTag>("tracksTimeErr", edm::InputTag("tofPID:sigmat0"));
1374  desc.add<edm::InputTag>("tracksBeta", edm::InputTag("trackExtenderWithMTD:generalTrackBeta"));
1375  desc.add<edm::InputTag>("tracksTimeMtd", edm::InputTag("trackExtenderWithMTD:generalTracktmtd"));
1376  desc.add<edm::InputTag>("tracksTimeMtdErr", edm::InputTag("trackExtenderWithMTD:generalTracksigmatmtd"));
1377  desc.add<edm::InputTag>("tracksPosMtd", edm::InputTag("trackExtenderWithMTD:generalTrackmtdpos"));
1378  desc.add<edm::InputTag>("muons", edm::InputTag("muons1stStep"));
1379  desc.add<edm::InputTag>("superclustering", edm::InputTag("ticlTracksterLinksSuperclusteringDNN"));
1380  desc.add<edm::InputTag>("recoSuperClusters", edm::InputTag("particleFlowSuperClusterHGCal"))
1381  ->setComment(
1382  "egamma supercluster collection (either from PFECALSuperClusterProducer for Mustache, or from "
1383  "TICL->Egamma converter in case of TICL DNN superclusters)");
1384  desc.add<edm::InputTag>("recoSuperClusters_sourceTracksterCollection", edm::InputTag("ticlTrackstersMerge"))
1385  ->setComment(
1386  "Trackster collection used to produce the reco::SuperCluster, used to provide a mapping back to the "
1387  "tracksters used in superclusters");
1388 
1389  desc.add<edm::InputTag>("simtrackstersSC", edm::InputTag("ticlSimTracksters"))
1390  ->setComment("SimTrackster from CaloParticle collection to use for simTICLcandidates");
1391  desc.add<edm::InputTag>("simTICLCandidates", edm::InputTag("ticlSimTracksters"));
1392 
1393  // Settings for dumping trackster associators (recoToSim & simToReco)
1394  edm::ParameterSetDescription associatorDescValidator;
1395  associatorDescValidator.add<std::string>("branchName")->setComment("Name of the output branches in the tree");
1396  associatorDescValidator.add<std::string>("suffix")->setComment("Should be CP or SC (for the output branch name)");
1397  associatorDescValidator.add<edm::InputTag>("associatorRecoToSimInputTag")
1398  ->setComment("Input tag for the RecoToSim associator to dump");
1399  associatorDescValidator.add<edm::InputTag>("associatorSimToRecoInputTag")
1400  ->setComment("Input tag for the SimToReco associator to dump");
1401  desc.addVPSet("associators", associatorDescValidator)->setComment("Tracksters to SimTracksters associators to dump");
1402 
1403  desc.add<edm::InputTag>("simclusters", edm::InputTag("mix", "MergedCaloTruth"));
1404  desc.add<edm::InputTag>("caloparticles", edm::InputTag("mix", "MergedCaloTruth"));
1405  desc.add<std::string>("detector", "HGCAL");
1406  desc.add<std::string>("propagator", "PropagatorWithMaterial");
1407 
1408  desc.add<bool>("saveLCs", true);
1409  desc.add<bool>("saveTICLCandidate", true);
1410  desc.add<bool>("saveSimTICLCandidate", true);
1411  desc.add<bool>("saveTracks", true);
1412  desc.add<bool>("saveSuperclustering", true);
1413  desc.add<bool>("saveRecoSuperclusters", true)
1414  ->setComment("Save superclustering Egamma collections (as reco::SuperCluster)");
1415  descriptions.add("ticlDumper", desc);
1416 }
1417 
size
Write out results.
double waferZ(int layer, bool reco) const
std::vector< float > simtrackster_timeBoundary
Definition: TICLDumper.cc:452
const edm::EDGetTokenT< reco::SuperClusterCollection > recoSuperClusters_token
Definition: TICLDumper.cc:599
std::vector< TTree * > tracksters_trees
TTree for each trackster collection to dump.
Definition: TICLDumper.cc:571
std::vector< float > trackster_eVector0_z
Definition: TICLDumper.cc:440
std::vector< float > cluster_timeErr
Definition: TICLDumper.cc:703
std::vector< float > simtrackster_track_boundaryPy
Definition: TICLDumper.cc:467
static DiskPointer build(Args &&... args)
Definition: BoundDisk.h:38
const Propagator & propagator
Definition: TICLDumper.cc:105
const edm::EDGetTokenT< std::vector< double > > hgcaltracks_eta_token_
Definition: TICLDumper.cc:590
std::vector< edm::EDGetTokenT< std::vector< ticl::Trackster > > > tracksters_token_
a token for each trackster collection to dump
Definition: TICLDumper.cc:568
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometry_token_
Definition: TICLDumper.cc:620
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
static int muAssocToTrack(const reco::TrackRef &trackref, const reco::MuonCollection &muons)
Definition: PFMuonAlgo.cc:479
std::vector< float > cluster_position_x
Definition: TICLDumper.cc:695
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void initTree(TTree *trackster_tree_, edm::EventID *eventId_)
Definition: TICLDumper.cc:134
std::vector< std::vector< float > > simToReco_score
Definition: TICLDumper.cc:544
std::vector< int > simTICLCandidate_charge
Definition: TICLDumper.cc:672
std::vector< float > simtrackster_track_boundaryEta
Definition: TICLDumper.cc:464
std::vector< float > simtrackster_trackTime
Definition: TICLDumper.cc:451
TTree * cluster_tree_
Definition: TICLDumper.cc:733
Definition: helper.py:1
std::vector< TracksterToSimTracksterAssociationHelper > associations_dumperHelpers_
the dumper helpers for each association map to dump
Definition: TICLDumper.cc:613
std::vector< float > trackster_EV2
Definition: TICLDumper.cc:436
std::vector< double > candidate_py
Definition: TICLDumper.cc:682
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::vector< std::vector< float > > trackster_vertices_time
Definition: TICLDumper.cc:475
const edm::EDGetTokenT< std::vector< double > > hgcaltracks_py_token_
Definition: TICLDumper.cc:593
DetectorTools(const HGCalDDDConstants &hgcons, const CaloGeometry &geom, const MagneticField &bfieldH, const Propagator &propH)
Definition: TICLDumper.cc:69
bool saveSuperclustering_
Definition: TICLDumper.cc:628
std::vector< float > simtrackster_track_boundaryPx
Definition: TICLDumper.cc:466
std::vector< float > simTICLCandidate_raw_energy
Definition: TICLDumper.cc:660
void endRun(edm::Run const &iEvent, edm::EventSetup const &) override
Definition: TICLDumper.cc:561
TracksterDumperHelper(TracksterType tracksterType=TracksterType::Trackster)
Definition: TICLDumper.cc:128
const edm::EDGetTokenT< edm::ValueMap< float > > tracks_beta_token_
Definition: TICLDumper.cc:583
std::vector< float > trackster_sigmaPCA3
Definition: TICLDumper.cc:443
const edm::EDGetTokenT< edm::ValueMap< GlobalPoint > > tracks_pos_mtd_token_
Definition: TICLDumper.cc:586
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:48
std::vector< edm::EDGetTokenT< TracksterToTracksterMap > > associations_simToReco_token_
The tokens for each assocation.
Definition: TICLDumper.cc:610
std::vector< float > simtrackster_boundaryPy
Definition: TICLDumper.cc:459
std::vector< double > recoSuperCluster_energy
Definition: TICLDumper.cc:648
std::vector< double > recoSuperCluster_position_x
Definition: TICLDumper.cc:650
std::vector< std::vector< uint32_t > > tracksters_in_candidate
Definition: TICLDumper.cc:687
std::vector< float > cluster_position_y
Definition: TICLDumper.cc:696
std::vector< std::vector< float > > trackster_vertices_multiplicity
Definition: TICLDumper.cc:480
std::string encode() const
Definition: InputTag.cc:159
const edm::EDGetTokenT< std::vector< std::vector< unsigned int > > > superclustering_linkedResultTracksters_token
Definition: TICLDumper.cc:598
std::vector< std::vector< float > > trackster_vertices_y
Definition: TICLDumper.cc:473
void endJob() override
Definition: TICLDumper.cc:1345
std::vector< float > cluster_correctedEnergy
Definition: TICLDumper.cc:693
std::vector< float > trackster_eVector0_x
Definition: TICLDumper.cc:438
std::vector< float > trackster_raw_pt
Definition: TICLDumper.cc:430
std::vector< float > track_beta
Definition: TICLDumper.cc:725
std::vector< uint32_t > cluster_seedID
Definition: TICLDumper.cc:691
const edm::EDGetTokenT< reco::CaloClusterCollection > recoSuperClusters_caloClusters_token
Definition: TICLDumper.cc:600
std::vector< double > Vec
Definition: TICLDumper.cc:554
std::vector< float > cluster_position_z
Definition: TICLDumper.cc:697
std::vector< int > track_quality
Definition: TICLDumper.cc:718
std::vector< float > track_hgcal_y
Definition: TICLDumper.cc:709
bool saveRecoSuperclusters_
Definition: TICLDumper.cc:630
std::vector< unsigned int > track_id
Definition: TICLDumper.cc:707
const edm::EDGetTokenT< std::vector< TICLCandidate > > ticl_candidates_token_
Definition: TICLDumper.cc:575
std::vector< std::vector< float > > trackster_vertices_energy
Definition: TICLDumper.cc:477
std::vector< double > recoSuperCluster_position_z
Definition: TICLDumper.cc:652
std::vector< float > simtrackster_track_boundaryY
Definition: TICLDumper.cc:462
std::vector< float > simTICLCandidate_boundaryY
Definition: TICLDumper.cc:664
std::vector< double > recoSuperCluster_rawEnergy
Definition: TICLDumper.cc:647
TTree * superclustering_tree_
Definition: TICLDumper.cc:735
const edm::EDGetTokenT< std::vector< ticl::Trackster > > simTracksters_SC_token_
Definition: TICLDumper.cc:603
const edm::EDGetTokenT< edm::ValueMap< float > > tracks_time_quality_token_
Definition: TICLDumper.cc:581
void clearVariables()
Definition: TICLDumper.cc:740
std::vector< float > cluster_energy
Definition: TICLDumper.cc:692
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagator_token_
Definition: TICLDumper.cc:624
void fillFromEvent(std::vector< ticl::Trackster > const &tracksters, std::vector< reco::CaloCluster > const &clusters, edm::ValueMap< std::pair< float, float >> const &layerClustersTimes, DetectorTools const &detectorTools, edm::Handle< std::vector< SimCluster >> simClusters_h, edm::Handle< std::vector< CaloParticle >> caloparticles_h, std::vector< reco::Track > const &tracks)
Definition: TICLDumper.cc:255
std::vector< int > candidate_charge
Definition: TICLDumper.cc:677
std::vector< float > track_hgcal_pz
Definition: TICLDumper.cc:713
std::vector< std::vector< float > > trackster_vertices_correctedEnergy
Definition: TICLDumper.cc:478
std::vector< std::vector< float > > trackster_vertices_correctedEnergyUncertainty
Definition: TICLDumper.cc:479
TracksterType tracksterType_
Definition: TICLDumper.cc:421
std::vector< std::vector< float > > trackster_id_probabilities
Definition: TICLDumper.cc:470
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
static TracksterType tracksterTypeFromString(std::string str)
Definition: TICLDumper.cc:117
assert(be >=bs)
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
void beginJob() override
Definition: TICLDumper.cc:916
std::vector< std::vector< uint32_t > > recoToSim
Definition: TICLDumper.cc:540
std::vector< float > candidate_time
Definition: TICLDumper.cc:684
std::unique_ptr< DetectorTools > detectorTools_
Definition: TICLDumper.cc:626
std::vector< std::vector< float > > simToReco_sharedE
Definition: TICLDumper.cc:545
std::vector< float > trackster_sigmaPCA2
Definition: TICLDumper.cc:442
std::vector< float > track_hgcal_px
Definition: TICLDumper.cc:711
TTree * candidate_tree_
Definition: TICLDumper.cc:734
std::vector< std::vector< uint32_t > > trackster_vertices_indexes
Definition: TICLDumper.cc:471
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< unsigned int > cluster_layer_id
Definition: TICLDumper.cc:700
std::vector< float > candidate_energy
Definition: TICLDumper.cc:679
std::vector< int > track_charge
Definition: TICLDumper.cc:721
std::vector< std::vector< float > > trackster_vertices_timeErr
Definition: TICLDumper.cc:476
std::vector< int > simTICLCandidate_track_in_candidate
Definition: TICLDumper.cc:673
std::vector< float > trackster_barycenter_z
Definition: TICLDumper.cc:434
std::vector< float > track_hgcal_eta
Definition: TICLDumper.cc:714
std::vector< int > cluster_type
Definition: TICLDumper.cc:701
const edm::EDGetTokenT< std::vector< CaloParticle > > caloparticles_token_
Definition: TICLDumper.cc:618
hgcal::RecHitTools rhtools
Definition: TICLDumper.cc:103
std::vector< float > trackster_barycenter_y
Definition: TICLDumper.cc:433
const edm::EDGetTokenT< edm::ValueMap< float > > tracks_time_token_
Definition: TICLDumper.cc:580
size_t nCandidates
Definition: TICLDumper.cc:676
int iEvent
Definition: GenABIO.cc:224
std::vector< float > simTICLCandidate_boundaryZ
Definition: TICLDumper.cc:665
const edm::EDGetTokenT< std::vector< ticl::Trackster > > tracksters_in_candidate_token_
Definition: TICLDumper.cc:573
GlobalPoint globalPosition() const
std::vector< float > simtrackster_regressed_pt
Definition: TICLDumper.cc:448
std::vector< float > track_hgcal_z
Definition: TICLDumper.cc:710
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TICLDumper.cc:1042
std::vector< float > trackster_barycenter_phi
Definition: TICLDumper.cc:445
Definition: Muon.py:1
std::vector< float > trackster_barycenter_eta
Definition: TICLDumper.cc:444
std::vector< std::vector< uint32_t > > recoSuperCluster_constituentTs
Indices to all tracksters inside the supercluster (same)
Definition: TICLDumper.cc:658
std::vector< int > track_missing_outer_hits
Definition: TICLDumper.cc:719
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
std::vector< double > recoSuperCluster_position_y
Definition: TICLDumper.cc:651
void fillFromEvent(TracksterToTracksterMap const &recoToSimMap, TracksterToTracksterMap const &simToRecoMap)
Definition: TICLDumper.cc:509
std::vector< float > track_hgcal_phi
Definition: TICLDumper.cc:715
std::vector< float > cluster_time
Definition: TICLDumper.cc:702
std::vector< float > simTICLCandidate_boundaryPy
Definition: TICLDumper.cc:667
std::vector< double > track_time
Definition: TICLDumper.cc:722
std::vector< float > simtrackster_boundaryZ
Definition: TICLDumper.cc:455
std::vector< double > candidate_pz
Definition: TICLDumper.cc:683
std::vector< float > simtrackster_boundaryPx
Definition: TICLDumper.cc:458
std::vector< float > simtrackster_track_boundaryZ
Definition: TICLDumper.cc:463
TTree * associations_tree_
Definition: TICLDumper.cc:615
Transition
Definition: Transition.h:12
bool saveTICLCandidate_
Definition: TICLDumper.cc:631
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
Definition: MuonFwd.h:13
std::vector< float > simtrackster_boundaryX
Definition: TICLDumper.cc:453
std::vector< float > trackster_sigmaPCA1
Definition: TICLDumper.cc:441
std::vector< float > simtrackster_boundaryY
Definition: TICLDumper.cc:454
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< std::vector< uint32_t > > simToReco
Definition: TICLDumper.cc:543
std::vector< float > simtrackster_boundaryPhi
Definition: TICLDumper.cc:457
std::vector< float > simTICLCandidate_boundaryPx
Definition: TICLDumper.cc:666
std::vector< float > simTICLCandidate_boundaryX
Definition: TICLDumper.cc:663
std::vector< double > candidate_px
Definition: TICLDumper.cc:681
std::vector< double > recoSuperCluster_correctedEnergy
Definition: TICLDumper.cc:649
const edm::EDGetTokenT< std::vector< double > > hgcaltracks_x_token_
Definition: TICLDumper.cc:587
std::vector< float > trackster_timeError
Definition: TICLDumper.cc:426
edm::EventID eventId_
Definition: TICLDumper.cc:641
unsigned int nClusters
Definition: TICLDumper.cc:424
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const edm::EDGetTokenT< std::vector< double > > hgcaltracks_z_token_
Definition: TICLDumper.cc:589
std::vector< float > track_hgcal_pt
Definition: TICLDumper.cc:716
std::vector< int > simTICLCandidate_pdgId
Definition: TICLDumper.cc:671
TICLDumper(const edm::ParameterSet &)
Definition: TICLDumper.cc:836
const edm::EDGetTokenT< std::vector< double > > hgcaltracks_px_token_
Definition: TICLDumper.cc:592
std::vector< std::vector< float > > recoToSim_sharedE
Definition: TICLDumper.cc:542
std::vector< float > trackster_EV3
Definition: TICLDumper.cc:437
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TICLDumper.cc:1347
const std::vector< edm::ParameterSet > associations_parameterSets_
A parameter set for each associator collection to dump (with treeName, etc)
Definition: TICLDumper.cc:608
std::vector< float > track_time_quality
Definition: TICLDumper.cc:723
const std::string propName_
Definition: TICLDumper.cc:622
std::pair< double, double > rangeR(double z, bool reco) const
bool saveLCs_
Definition: TICLDumper.cc:627
std::vector< std::vector< float > > trackster_vertices_x
Definition: TICLDumper.cc:472
TTree * tracks_tree_
Definition: TICLDumper.cc:736
const edm::EDGetTokenT< std::vector< ticl::Trackster > > ticl_candidates_tracksters_token_
trackster collection used by TICLCandidate
Definition: TICLDumper.cc:577
std::vector< float > trackster_time
Definition: TICLDumper.cc:425
std::vector< float > trackster_raw_em_pt
Definition: TICLDumper.cc:431
std::vector< float > trackster_EV1
Definition: TICLDumper.cc:435
std::vector< float > simTICLCandidate_regressed_energy
Definition: TICLDumper.cc:661
std::vector< std::vector< float > > trackster_vertices_z
Definition: TICLDumper.cc:474
std::vector< float > trackster_raw_em_energy
Definition: TICLDumper.cc:429
const edm::EDGetTokenT< std::vector< bool > > tracks_mask_token_
Definition: TICLDumper.cc:579
std::vector< int > simtrackster_pdgID
Definition: TICLDumper.cc:449
std::vector< float > simTICLCandidate_caloParticleMass
Definition: TICLDumper.cc:669
bool saveSuperclusteringDNNScore_
Definition: TICLDumper.cc:629
std::vector< uint32_t > recoSuperCluster_seedTs
Index to seed trackster (into the trackster collection used to make superclusters, given by config recoSuperClusters_sourceTracksterCollection)
Definition: TICLDumper.cc:656
std::vector< float > simtrackster_track_boundaryPhi
Definition: TICLDumper.cc:465
const edm::EDGetTokenT< std::vector< int > > tracksterSeeds_token_
Definition: TICLDumper.cc:597
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: TICLDumper.cc:908
edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > hdc_token_
Definition: TICLDumper.cc:625
bool saveTracks_
Definition: TICLDumper.cc:633
const edm::EDGetTokenT< std::vector< double > > hgcaltracks_y_token_
Definition: TICLDumper.cc:588
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
std::vector< float > trackster_eVector0_y
Definition: TICLDumper.cc:439
const edm::EDGetTokenT< std::vector< ticl::Trackster > > recoSuperClusters_sourceTracksters_token
Definition: TICLDumper.cc:601
const edm::EDGetTokenT< edm::ValueMap< float > > tracks_time_mtd_token_
Definition: TICLDumper.cc:584
std::unique_ptr< GeomDet > interfaceDisk_[2]
Definition: TICLDumper.cc:102
void add(std::string const &label, ParameterSetDescription const &psetDescription)
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:152
std::unique_ptr< GeomDet > firstDisk_[2]
Definition: TICLDumper.cc:101
std::vector< TracksterDumperHelper > tracksters_dumperHelpers_
the dumper helpers for each trackster collection to dump
Definition: TICLDumper.cc:570
std::vector< float > cluster_position_eta
Definition: TICLDumper.cc:698
std::vector< float > track_pt
Definition: TICLDumper.cc:717
unsigned int nclusters_
Definition: TICLDumper.cc:642
std::vector< std::vector< float > > candidate_id_probabilities
Definition: TICLDumper.cc:686
std::vector< int > track_isTrackerMuon
Definition: TICLDumper.cc:731
std::vector< int > simtrackster_trackIdx
Definition: TICLDumper.cc:450
std::vector< float > simtrackster_track_boundaryPz
Definition: TICLDumper.cc:468
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:79
ticl::Vector Vector
Definition: TICLDumper.cc:553
std::vector< std::vector< int > > simTICLCandidate_simTracksterCPIndex
Definition: TICLDumper.cc:662
std::vector< double > recoSuperCluster_position_phi
Definition: TICLDumper.cc:654
std::vector< float > track_hgcal_py
Definition: TICLDumper.cc:712
bool saveSimTICLCandidate_
Definition: TICLDumper.cc:632
std::vector< int > track_in_candidate
Definition: TICLDumper.cc:688
math::XYZVectorF Vector
Definition: Common.h:42
std::vector< float > track_time_err
Definition: TICLDumper.cc:724
std::vector< int > track_isMuon
Definition: TICLDumper.cc:730
fixed size matrix
unsigned int nTracksters
Definition: TICLDumper.cc:423
HLT enums.
std::vector< float > candidate_raw_energy
Definition: TICLDumper.cc:680
const edm::EDGetTokenT< edm::ValueMap< float > > tracks_time_mtd_err_token_
Definition: TICLDumper.cc:585
std::vector< edm::EDGetTokenT< TracksterToTracksterMap > > associations_recoToSim_token_
Definition: TICLDumper.cc:611
std::vector< float > cluster_correctedEnergyUncertainty
Definition: TICLDumper.cc:694
std::vector< float > trackster_barycenter_x
Definition: TICLDumper.cc:432
std::vector< int > candidate_pdgId
Definition: TICLDumper.cc:678
Definition: Common.h:10
std::vector< float > track_time_mtd_err
Definition: TICLDumper.cc:727
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
Definition: TICLDumper.cc:596
const edm::EDGetTokenT< edm::ValueMap< float > > tracks_time_err_token_
Definition: TICLDumper.cc:582
std::vector< double > recoSuperCluster_position_eta
Definition: TICLDumper.cc:653
const edm::EDGetTokenT< std::vector< double > > hgcaltracks_phi_token_
Definition: TICLDumper.cc:591
std::vector< int > track_nhits
Definition: TICLDumper.cc:729
std::vector< float > simtrackster_boundaryEta
Definition: TICLDumper.cc:456
const edm::EDGetTokenT< std::vector< TICLCandidate > > simTICLCandidate_token_
Definition: TICLDumper.cc:604
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bfield_token_
Definition: TICLDumper.cc:623
std::vector< int > track_missing_inner_hits
Definition: TICLDumper.cc:720
const MagneticField & bfield
Definition: TICLDumper.cc:104
std::vector< float > track_hgcal_x
Definition: TICLDumper.cc:708
std::vector< float > trackster_raw_energy
Definition: TICLDumper.cc:428
std::vector< GlobalPoint > track_pos_mtd
Definition: TICLDumper.cc:728
std::vector< float > track_time_mtd
Definition: TICLDumper.cc:726
const HGCalDDDConstants & hgcons
Definition: TICLDumper.cc:100
Definition: tree.py:1
std::vector< uint32_t > cluster_number_of_hits
Definition: TICLDumper.cc:704
TTree * simTICLCandidate_tree
Definition: TICLDumper.cc:737
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > layer_clusters_token_
Definition: TICLDumper.cc:574
std::vector< float > candidate_time_err
Definition: TICLDumper.cc:685
#define str(s)
const edm::EDGetTokenT< std::vector< double > > hgcaltracks_pz_token_
Definition: TICLDumper.cc:594
FreeTrajectoryState outerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
std::vector< std::vector< unsigned int > > superclustering_linkedResultTracksters
Definition: TICLDumper.cc:645
const std::vector< edm::ParameterSet > tracksters_parameterSets_
A parameter set for each trackster collection to dump (giving tree name, etc)
Definition: TICLDumper.cc:566
const edm::EDGetTokenT< std::vector< reco::Track > > tracks_token_
Definition: TICLDumper.cc:578
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometry_token_
Definition: TICLDumper.cc:602
~TICLDumper() override
Definition: TICLDumper.cc:906
void initTree(TTree *tree, std::string branchPrefix, std::string branchSuffix)
Definition: TICLDumper.cc:491
const edm::EDGetTokenT< std::vector< reco::Muon > > muons_token_
Definition: TICLDumper.cc:595
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:76
std::vector< float > simTICLCandidate_time
Definition: TICLDumper.cc:670
TTree * tree_
Definition: TICLDumper.cc:636
Definition: event.py:1
std::vector< std::vector< float > > recoToSim_score
Definition: TICLDumper.cc:541
Definition: Run.h:45
std::vector< float > cluster_position_phi
Definition: TICLDumper.cc:699
std::vector< float > trackster_regressed_energy
Definition: TICLDumper.cc:427
std::vector< float > simtrackster_track_boundaryX
Definition: TICLDumper.cc:461
std::vector< float > simtrackster_boundaryPz
Definition: TICLDumper.cc:460
const edm::EDGetTokenT< std::vector< SimCluster > > simclusters_token_
Definition: TICLDumper.cc:617
const std::string detector_
Definition: TICLDumper.cc:621
std::vector< float > simTICLCandidate_boundaryPz
Definition: TICLDumper.cc:668