CMS 3D CMS Logo

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