CMS 3D CMS Logo

PFAnalysis.cc
Go to the documentation of this file.
1 // Based on RecoNtuple/HGCalAnalysis with modifications for PF
2 //
3 // user include files
6 
10 
12 
36 
40 
46 
48 #include "Math/Transform3D.h"
52 
55 #include "TH1F.h"
56 #include "TVector2.h"
57 #include "TTree.h"
58 
59 #include <map>
60 #include <set>
61 #include <string>
62 #include <vector>
63 #include <set>
64 
65 using namespace std;
66 
68 public:
70  size_t idx_block;
71  size_t idx_elem;
72  ElementWithIndex(const reco::PFBlockElement& _orig, size_t _idx_block, size_t _idx_elem)
73  : orig(_orig), idx_block(_idx_block), idx_elem(_idx_elem){};
74 };
75 
76 int find_element_ref(const vector<ElementWithIndex>& vec, const edm::RefToBase<reco::Track>& r) {
77  for (unsigned int i = 0; i < vec.size(); i++) {
78  const auto& elem = vec.at(i);
79  if (elem.orig.type() == reco::PFBlockElement::TRACK) {
80  const auto& ref = elem.orig.trackRef();
81  assert(ref.isNonnull());
82  if (ref.key() == r.key()) {
83  return i;
84  }
85  } else if (elem.orig.type() == reco::PFBlockElement::BREM) {
86  const auto& ref = elem.orig.trackRefPF();
87  if (ref.isNonnull()) {
88  const auto& ref2 = ref->trackRef();
89  assert(ref2.isNonnull());
90  if (ref2.key() == r.key()) {
91  return i;
92  }
93  }
94  }
95  }
96  return -1;
97 }
98 
99 double detid_compare(const map<uint64_t, double>& rechits,
100  const map<uint64_t, double>& simhits,
101  const map<uint64_t, double>& rechits_energy,
102  bool print) {
103  double ret = 0.0;
104 
105  for (const auto& rh : rechits) {
106  for (const auto& sh : simhits) {
107  if (rh.first == sh.first) {
108  //rechit energy times simhit fraction
109  ret += rechits_energy.at(rh.first) * sh.second;
110  break;
111  }
112  }
113  }
114  return ret;
115 }
116 
117 class PFAnalysis : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
118 public:
120 
121  PFAnalysis();
122  explicit PFAnalysis(const edm::ParameterSet&);
123  ~PFAnalysis() override;
124 
125  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
126  void beginRun(edm::Run const& iEvent, edm::EventSetup const&) override;
127  void endRun(edm::Run const& iEvent, edm::EventSetup const&) override;
128 
129 private:
130  void beginJob() override;
131  void analyze(const edm::Event&, const edm::EventSetup&) override;
132  void endJob() override;
133 
134  void processTrackingParticles(const edm::View<TrackingParticle>& trackingParticles,
135  edm::Handle<edm::View<TrackingParticle>>& trackingParticlesHandle);
136 
137  pair<vector<ElementWithIndex>, vector<tuple<int, int, float>>> processBlocks(
138  const std::vector<reco::PFBlock>& pfBlocks);
139 
140  void associateClusterToSimCluster(const vector<ElementWithIndex>& all_elements);
141 
142  void clearVariables();
143 
144  GlobalPoint getHitPosition(const DetId& id);
145  // ----------member data ---------------------------
146 
154 
155  TTree* t_;
156 
160 
161  vector<float> trackingparticle_eta_;
162  vector<float> trackingparticle_phi_;
163  vector<float> trackingparticle_pt_;
164  vector<float> trackingparticle_px_;
165  vector<float> trackingparticle_py_;
166  vector<float> trackingparticle_pz_;
168  vector<float> trackingparticle_dvx_;
169  vector<float> trackingparticle_dvy_;
170  vector<float> trackingparticle_dvz_;
171  vector<int> trackingparticle_bx_;
172  vector<int> trackingparticle_ev_;
173  vector<float> trackingparticle_ovx_;
174  vector<float> trackingparticle_ovy_;
175  vector<float> trackingparticle_ovz_;
176  vector<float> trackingparticle_exx_;
177  vector<float> trackingparticle_exy_;
180 
181  vector<float> simcluster_eta_;
182  vector<float> simcluster_phi_;
183  vector<float> simcluster_pt_;
184  vector<float> simcluster_energy_;
185  vector<float> simcluster_px_;
186  vector<float> simcluster_py_;
187  vector<float> simcluster_pz_;
188  vector<int> simcluster_bx_;
189  vector<int> simcluster_ev_;
190  vector<int> simcluster_pid_;
192  vector<int> simcluster_nhits_;
193  vector<std::map<uint64_t, double>> simcluster_detids_;
194 
195  vector<float> simhit_frac_;
196  vector<float> simhit_x_;
197  vector<float> simhit_y_;
198  vector<float> simhit_z_;
199  vector<float> simhit_eta_;
200  vector<float> simhit_phi_;
201  vector<int> simhit_det_;
202  vector<int> simhit_subdet_;
204  vector<uint64_t> simhit_detid_;
205 
206  vector<float> rechit_e_;
207  vector<float> rechit_x_;
208  vector<float> rechit_y_;
209  vector<float> rechit_z_;
210  vector<float> rechit_det_;
211  vector<float> rechit_subdet_;
212  vector<float> rechit_eta_;
213  vector<float> rechit_phi_;
214  vector<int> rechit_idx_element_;
215  vector<uint64_t> rechit_detid_;
216 
217  vector<float> simtrack_x_;
218  vector<float> simtrack_y_;
219  vector<float> simtrack_z_;
221  vector<int> simtrack_pid_;
222 
223  vector<float> gen_eta_;
224  vector<float> gen_phi_;
225  vector<float> gen_pt_;
226  vector<float> gen_px_;
227  vector<float> gen_py_;
228  vector<float> gen_pz_;
229  vector<float> gen_energy_;
230  vector<int> gen_charge_;
231  vector<int> gen_pdgid_;
232  vector<int> gen_status_;
233  vector<vector<int>> gen_daughters_;
234 
235  vector<float> element_pt_;
236  vector<float> element_px_;
237  vector<float> element_py_;
238  vector<float> element_pz_;
239  vector<float> element_eta_;
240  vector<float> element_phi_;
241  vector<float> element_energy_;
242  vector<float> element_eta_ecal_;
243  vector<float> element_phi_ecal_;
244  vector<float> element_eta_hcal_;
245  vector<float> element_phi_hcal_;
246  vector<int> element_charge_;
247  vector<int> element_type_;
248  vector<int> element_layer_;
249  vector<float> element_depth_;
250  vector<float> element_trajpoint_;
251 
252  vector<int> element_distance_i_;
253  vector<int> element_distance_j_;
254  vector<float> element_distance_d_;
255 
256  vector<float> pfcandidate_eta_;
257  vector<float> pfcandidate_phi_;
258  vector<float> pfcandidate_pt_;
259  vector<float> pfcandidate_px_;
260  vector<float> pfcandidate_py_;
261  vector<float> pfcandidate_pz_;
262  vector<float> pfcandidate_energy_;
263  vector<int> pfcandidate_pdgid_;
264 
265  vector<pair<int, int>> trackingparticle_to_element;
266  vector<pair<int, int>> simcluster_to_element;
268  vector<pair<int, int>> element_to_candidate;
269 
270  // and also the magnetic field
272 
275 
279 };
280 
282 
284  tracks_recotosim_ = consumes<reco::RecoToSimCollection>(edm::InputTag("trackingParticleRecoTrackAsssociation"));
285  trackingParticles_ = consumes<edm::View<TrackingParticle>>(edm::InputTag("mix", "MergedTrackTruth"));
286  caloParticles_ = consumes<edm::View<CaloParticle>>(edm::InputTag("mix", "MergedCaloTruth"));
287  genParticles_ = consumes<std::vector<reco::GenParticle>>(edm::InputTag("genParticles"));
288  pfBlocks_ = consumes<std::vector<reco::PFBlock>>(edm::InputTag("particleFlowBlock"));
289  pfCandidates_ = consumes<std::vector<reco::PFCandidate>>(edm::InputTag("particleFlow"));
290  tracks_ = consumes<edm::View<reco::Track>>(edm::InputTag("generalTracks"));
291 
292  geometryToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>(edm::ESInputTag{});
293  topologyToken_ = esConsumes<HcalTopology, HcalRecNumberingRecord>(edm::ESInputTag{});
294 
295  usesResource(TFileService::kSharedResource);
297  fs->make<TH1F>("total", "total", 100, 0, 5.);
298 
299  t_ = fs->make<TTree>("pftree", "pftree");
300 
301  // event info
302  t_->Branch("event", &ev_event_);
303  t_->Branch("lumi", &ev_lumi_);
304  t_->Branch("run", &ev_run_);
305 
306  t_->Branch("trackingparticle_eta", &trackingparticle_eta_);
307  t_->Branch("trackingparticle_phi", &trackingparticle_phi_);
308  t_->Branch("trackingparticle_pt", &trackingparticle_pt_);
309  t_->Branch("trackingparticle_px", &trackingparticle_px_);
310  t_->Branch("trackingparticle_py", &trackingparticle_py_);
311  t_->Branch("trackingparticle_pz", &trackingparticle_pz_);
312  t_->Branch("trackingparticle_energy", &trackingparticle_energy_);
313  t_->Branch("trackingparticle_dvx", &trackingparticle_dvx_);
314  t_->Branch("trackingparticle_dvy", &trackingparticle_dvy_);
315  t_->Branch("trackingparticle_dvz", &trackingparticle_dvz_);
316  t_->Branch("trackingparticle_bx", &trackingparticle_bx_);
317  t_->Branch("trackingparticle_ev", &trackingparticle_ev_);
318  t_->Branch("trackingparticle_pid", &trackingparticle_pid_);
319 
320  t_->Branch("simcluster_eta", &simcluster_eta_);
321  t_->Branch("simcluster_phi", &simcluster_phi_);
322  t_->Branch("simcluster_pt", &simcluster_pt_);
323  t_->Branch("simcluster_px", &simcluster_px_);
324  t_->Branch("simcluster_py", &simcluster_py_);
325  t_->Branch("simcluster_pz", &simcluster_pz_);
326  t_->Branch("simcluster_energy", &simcluster_energy_);
327  t_->Branch("simcluster_bx", &simcluster_bx_);
328  t_->Branch("simcluster_ev", &simcluster_ev_);
329  t_->Branch("simcluster_pid", &simcluster_pid_);
330  t_->Branch("simcluster_idx_trackingparticle", &simcluster_idx_trackingparticle_);
331  t_->Branch("simcluster_nhits", &simcluster_nhits_);
332 
333  t_->Branch("simhit_frac", &simhit_frac_);
334  t_->Branch("simhit_x", &simhit_x_);
335  t_->Branch("simhit_y", &simhit_y_);
336  t_->Branch("simhit_z", &simhit_z_);
337  t_->Branch("simhit_det", &simhit_det_);
338  t_->Branch("simhit_subdet", &simhit_subdet_);
339  t_->Branch("simhit_eta", &simhit_eta_);
340  t_->Branch("simhit_phi", &simhit_phi_);
341  t_->Branch("simhit_idx_simcluster", &simhit_idx_simcluster_);
342  t_->Branch("simhit_detid", &simhit_detid_);
343 
344  t_->Branch("rechit_e", &rechit_e_);
345  t_->Branch("rechit_x", &rechit_x_);
346  t_->Branch("rechit_y", &rechit_y_);
347  t_->Branch("rechit_z", &rechit_z_);
348  t_->Branch("rechit_det", &rechit_det_);
349  t_->Branch("rechit_subdet", &rechit_subdet_);
350  t_->Branch("rechit_eta", &rechit_eta_);
351  t_->Branch("rechit_phi", &rechit_phi_);
352  t_->Branch("rechit_idx_element", &rechit_idx_element_);
353  t_->Branch("rechit_detid", &rechit_detid_);
354 
355  t_->Branch("simtrack_x", &simtrack_x_);
356  t_->Branch("simtrack_y", &simtrack_y_);
357  t_->Branch("simtrack_z", &simtrack_z_);
358  t_->Branch("simtrack_idx_simcluster_", &simtrack_idx_simcluster_);
359  t_->Branch("simtrack_pid", &simtrack_pid_);
360 
361  t_->Branch("gen_eta", &gen_eta_);
362  t_->Branch("gen_phi", &gen_phi_);
363  t_->Branch("gen_pt", &gen_pt_);
364  t_->Branch("gen_px", &gen_px_);
365  t_->Branch("gen_py", &gen_py_);
366  t_->Branch("gen_pz", &gen_pz_);
367  t_->Branch("gen_energy", &gen_energy_);
368  t_->Branch("gen_charge", &gen_charge_);
369  t_->Branch("gen_pdgid", &gen_pdgid_);
370  t_->Branch("gen_status", &gen_status_);
371  t_->Branch("gen_daughters", &gen_daughters_);
372 
373  //PF Elements
374  t_->Branch("element_pt", &element_pt_);
375  t_->Branch("element_px", &element_px_);
376  t_->Branch("element_py", &element_py_);
377  t_->Branch("element_pz", &element_pz_);
378  t_->Branch("element_eta", &element_eta_);
379  t_->Branch("element_phi", &element_phi_);
380  t_->Branch("element_energy", &element_energy_);
381  t_->Branch("element_eta_ecal", &element_eta_ecal_);
382  t_->Branch("element_phi_ecal", &element_phi_ecal_);
383  t_->Branch("element_eta_hcal", &element_eta_hcal_);
384  t_->Branch("element_phi_hcal", &element_phi_hcal_);
385  t_->Branch("element_charge", &element_charge_);
386  t_->Branch("element_type", &element_type_);
387  t_->Branch("element_layer", &element_layer_);
388  t_->Branch("element_depth", &element_depth_);
389  t_->Branch("element_trajpoint", &element_trajpoint_);
390 
391  //Distance matrix between PF elements
392  t_->Branch("element_distance_i", &element_distance_i_);
393  t_->Branch("element_distance_j", &element_distance_j_);
394  t_->Branch("element_distance_d", &element_distance_d_);
395 
396  t_->Branch("pfcandidate_eta", &pfcandidate_eta_);
397  t_->Branch("pfcandidate_phi", &pfcandidate_phi_);
398  t_->Branch("pfcandidate_pt", &pfcandidate_pt_);
399  t_->Branch("pfcandidate_px", &pfcandidate_px_);
400  t_->Branch("pfcandidate_py", &pfcandidate_py_);
401  t_->Branch("pfcandidate_pz", &pfcandidate_pz_);
402  t_->Branch("pfcandidate_energy", &pfcandidate_energy_);
403  t_->Branch("pfcandidate_pdgid", &pfcandidate_pdgid_);
404 
405  //Links between reco, gen and PFCandidate objects
406  t_->Branch("trackingparticle_to_element", &trackingparticle_to_element);
407  t_->Branch("simcluster_to_element", &simcluster_to_element);
408  t_->Branch("simcluster_to_element_cmp", &simcluster_to_element_cmp);
409  t_->Branch("element_to_candidate", &element_to_candidate);
410 } // constructor
411 
413 
415  ev_run_ = 0;
416  ev_lumi_ = 0;
417  ev_event_ = 0;
418 
419  trackingparticle_to_element.clear();
420  simcluster_to_element.clear();
421  simcluster_to_element_cmp.clear();
422  element_to_candidate.clear();
423 
424  trackingparticle_eta_.clear();
425  trackingparticle_phi_.clear();
426  trackingparticle_pt_.clear();
427  trackingparticle_px_.clear();
428  trackingparticle_py_.clear();
429  trackingparticle_pz_.clear();
430  trackingparticle_energy_.clear();
431  trackingparticle_dvx_.clear();
432  trackingparticle_dvy_.clear();
433  trackingparticle_dvz_.clear();
434  trackingparticle_bx_.clear();
435  trackingparticle_ev_.clear();
436  trackingparticle_ovx_.clear();
437  trackingparticle_ovy_.clear();
438  trackingparticle_ovz_.clear();
439  trackingparticle_exx_.clear();
440  trackingparticle_exy_.clear();
441  trackingparticle_mother_.clear();
442  trackingparticle_pid_.clear();
443 
444  simcluster_eta_.clear();
445  simcluster_phi_.clear();
446  simcluster_pt_.clear();
447  simcluster_energy_.clear();
448  simcluster_pid_.clear();
449  simcluster_detids_.clear();
450  simcluster_bx_.clear();
451  simcluster_ev_.clear();
452  simcluster_px_.clear();
453  simcluster_py_.clear();
454  simcluster_pz_.clear();
455  simcluster_idx_trackingparticle_.clear();
456  simcluster_nhits_.clear();
457 
458  simhit_frac_.clear();
459  simhit_x_.clear();
460  simhit_y_.clear();
461  simhit_z_.clear();
462  simhit_det_.clear();
463  simhit_subdet_.clear();
464  simhit_eta_.clear();
465  simhit_phi_.clear();
466  simhit_idx_simcluster_.clear();
467  simhit_detid_.clear();
468 
469  rechit_e_.clear();
470  rechit_x_.clear();
471  rechit_y_.clear();
472  rechit_z_.clear();
473  rechit_det_.clear();
474  rechit_subdet_.clear();
475  rechit_eta_.clear();
476  rechit_phi_.clear();
477  rechit_idx_element_.clear();
478  rechit_detid_.clear();
479 
480  simtrack_x_.clear();
481  simtrack_y_.clear();
482  simtrack_z_.clear();
483  simtrack_idx_simcluster_.clear();
484  simtrack_pid_.clear();
485 
486  gen_eta_.clear();
487  gen_phi_.clear();
488  gen_pt_.clear();
489  gen_px_.clear();
490  gen_py_.clear();
491  gen_pz_.clear();
492  gen_energy_.clear();
493  gen_charge_.clear();
494  gen_pdgid_.clear();
495  gen_status_.clear();
496  gen_daughters_.clear();
497 
498  element_pt_.clear();
499  element_px_.clear();
500  element_py_.clear();
501  element_pz_.clear();
502  element_eta_.clear();
503  element_phi_.clear();
504  element_energy_.clear();
505  element_eta_ecal_.clear();
506  element_phi_ecal_.clear();
507  element_eta_hcal_.clear();
508  element_phi_hcal_.clear();
509  element_charge_.clear();
510  element_type_.clear();
511  element_layer_.clear();
512  element_depth_.clear();
513  element_trajpoint_.clear();
514 
515  element_distance_i_.clear();
516  element_distance_j_.clear();
517  element_distance_d_.clear();
518 
519  pfcandidate_eta_.clear();
520  pfcandidate_phi_.clear();
521  pfcandidate_pt_.clear();
522  pfcandidate_px_.clear();
523  pfcandidate_py_.clear();
524  pfcandidate_pz_.clear();
525  pfcandidate_energy_.clear();
526  pfcandidate_pdgid_.clear();
527 
528 } //clearVariables
529 
532 
533  bool present = false;
534  if (((id.det() == DetId::Ecal &&
535  (id.subdetId() == EcalBarrel || id.subdetId() == EcalEndcap || id.subdetId() == EcalPreshower)) ||
536  (id.det() == DetId::Hcal && (id.subdetId() == HcalBarrel || id.subdetId() == HcalEndcap ||
537  id.subdetId() == HcalForward || id.subdetId() == HcalOuter)))) {
538  const CaloSubdetectorGeometry* geom_sd(geom->getSubdetectorGeometry(id.det(), id.subdetId()));
539  present = geom_sd->present(id);
540  if (present) {
541  const auto& cell = geom_sd->getGeometry(id);
542  ret = GlobalPoint(cell->getPosition());
543  }
544  }
545  return ret;
546 }
547 
549  clearVariables();
550 
551  auto& pG = iSetup.getData(geometryToken_);
552  geom = (CaloGeometry*)&pG;
553  auto& pT = iSetup.getData(topologyToken_);
554  hcal_topo = (HcalTopology*)&pT;
555 
556  //Simulated tracks, cleaned up by TrackingTruthAccumulator
557  edm::Handle<edm::View<TrackingParticle>> trackingParticlesHandle;
558  iEvent.getByToken(trackingParticles_, trackingParticlesHandle);
559  const edm::View<TrackingParticle>& trackingParticles = *trackingParticlesHandle;
560 
561  edm::Handle<edm::View<CaloParticle>> caloParticlesHandle;
562  iEvent.getByToken(caloParticles_, caloParticlesHandle);
563  const edm::View<CaloParticle>& caloParticles = *caloParticlesHandle;
564 
565  //Matches reco tracks to sim tracks (TrackingParticle)
566  edm::Handle<reco::RecoToSimCollection> recotosimCollection;
567  iEvent.getByToken(tracks_recotosim_, recotosimCollection);
568  const auto recotosim = *recotosimCollection;
569 
571  iEvent.getByToken(tracks_, trackHandle);
572  const edm::View<reco::Track>& tracks = *trackHandle;
573 
574  edm::Handle<std::vector<reco::GenParticle>> genParticlesHandle;
575  iEvent.getByToken(genParticles_, genParticlesHandle);
576  for (std::vector<reco::GenParticle>::const_iterator it_p = genParticlesHandle->begin();
577  it_p != genParticlesHandle->end();
578  ++it_p) {
579  gen_eta_.push_back(it_p->eta());
580  gen_phi_.push_back(it_p->phi());
581  gen_pt_.push_back(it_p->pt());
582  gen_px_.push_back(it_p->px());
583  gen_py_.push_back(it_p->py());
584  gen_pz_.push_back(it_p->pz());
585  gen_energy_.push_back(it_p->energy());
586  gen_charge_.push_back(it_p->charge());
587  gen_pdgid_.push_back(it_p->pdgId());
588  gen_status_.push_back(it_p->status());
589  std::vector<int> daughters(it_p->daughterRefVector().size(), 0);
590  for (unsigned j = 0; j < it_p->daughterRefVector().size(); ++j) {
591  daughters[j] = static_cast<int>(it_p->daughterRefVector().at(j).key());
592  }
593  gen_daughters_.push_back(daughters);
594  }
595 
596  edm::Handle<std::vector<reco::PFCandidate>> pfCandidatesHandle;
597  iEvent.getByToken(pfCandidates_, pfCandidatesHandle);
598  std::vector<reco::PFCandidate> pfCandidates = *pfCandidatesHandle;
599 
601  iEvent.getByToken(pfBlocks_, pfBlocksHandle);
602  std::vector<reco::PFBlock> pfBlocks = *pfBlocksHandle;
603 
604  //Collect all clusters, tracks and superclusters
605  const auto& all_elements_distances = processBlocks(pfBlocks);
606  const auto& all_elements = all_elements_distances.first;
607  const auto& all_distances = all_elements_distances.second;
608  assert(!all_elements.empty());
609  //assert(all_distances.size() > 0);
610  for (const auto& d : all_distances) {
611  element_distance_i_.push_back(get<0>(d));
612  element_distance_j_.push_back(get<1>(d));
613  element_distance_d_.push_back(get<2>(d));
614  }
615 
616  //We need to use the original reco::Track collection for track association
617  for (unsigned long ntrack = 0; ntrack < tracks.size(); ntrack++) {
618  edm::RefToBase<reco::Track> trackref(trackHandle, ntrack);
619 
620  //get the index of the track in the 'all_elements' collection that we use later
621  int idx_in_all_elements = find_element_ref(all_elements, trackref);
622 
623  //track was not used by PF, we skip as well
624  if (idx_in_all_elements == -1) {
625  continue;
626  }
627 
628  if (recotosim.find(trackref) != recotosim.end()) {
629  const auto& tps = recotosim[trackref];
630  for (const auto& tp : tps) {
632  trackingparticle_to_element.push_back(make_pair(tpr.key(), idx_in_all_elements));
633  //cout << "trackingparticle_to_element " << tpr.key() << " " << idx_in_all_elements << endl;
634  //cout << "track.eta=" << trackref->eta() << " track.phi=" << trackref->phi() << endl;
635  //cout << "elem.eta=" << all_elements[idx_in_all_elements].orig.trackRef()->eta();
636  //cout << " elem.phi=" << all_elements[idx_in_all_elements].orig.trackRef()->phi() << endl;
637  }
638  }
639  }
640 
641  processTrackingParticles(trackingParticles, trackingParticlesHandle);
642 
643  int idx_simcluster = 0;
644  //Fill genparticles from calorimeter hits
645  for (unsigned long ncaloparticle = 0; ncaloparticle < caloParticles.size(); ncaloparticle++) {
646  const auto& cp = caloParticles.at(ncaloparticle);
647  edm::RefToBase<CaloParticle> cpref(caloParticlesHandle, ncaloparticle);
648 
649  int nhits = 0;
650  for (const auto& simcluster : cp.simClusters()) {
651  //create a map of detId->energy of all the rechits in all the clusters of this SimCluster
652  map<uint64_t, double> detid_energy;
653 
654  simcluster_nhits_.push_back(nhits);
655  simcluster_eta_.push_back(simcluster->p4().eta());
656  simcluster_phi_.push_back(simcluster->p4().phi());
657  simcluster_pt_.push_back(simcluster->p4().pt());
658  simcluster_energy_.push_back(simcluster->energy());
659  simcluster_pid_.push_back(simcluster->pdgId());
660  simcluster_bx_.push_back(simcluster->eventId().bunchCrossing());
661  simcluster_ev_.push_back(simcluster->eventId().event());
662 
663  simcluster_px_.push_back(simcluster->p4().x());
664  simcluster_py_.push_back(simcluster->p4().y());
665  simcluster_pz_.push_back(simcluster->p4().z());
666 
667  for (const auto& hf : simcluster->hits_and_fractions()) {
668  DetId id(hf.first);
669 
670  if (id.det() == DetId::Hcal || id.det() == DetId::Ecal) {
671  const auto& pos = getHitPosition(id);
672  nhits += 1;
673 
674  const float x = pos.x();
675  const float y = pos.y();
676  const float z = pos.z();
677  const float eta = pos.eta();
678  const float phi = pos.phi();
679  //const float e = simcluster->energy() * hf.second;
680 
681  simhit_frac_.push_back(hf.second);
682  simhit_x_.push_back(x);
683  simhit_y_.push_back(y);
684  simhit_z_.push_back(z);
685  simhit_det_.push_back(id.det());
686  simhit_subdet_.push_back(id.subdetId());
687  simhit_eta_.push_back(eta);
688  simhit_phi_.push_back(phi);
689  simhit_idx_simcluster_.push_back(idx_simcluster);
690  simhit_detid_.push_back(id.rawId());
691  detid_energy[id.rawId()] += hf.second;
692  }
693  }
694 
695  int simcluster_to_trackingparticle = -1;
696  for (const auto& simtrack : simcluster->g4Tracks()) {
697  simtrack_x_.push_back(simtrack.trackerSurfacePosition().x());
698  simtrack_y_.push_back(simtrack.trackerSurfacePosition().y());
699  simtrack_z_.push_back(simtrack.trackerSurfacePosition().z());
700  simtrack_idx_simcluster_.push_back(idx_simcluster);
701  simtrack_pid_.push_back(simtrack.type());
702 
703  for (unsigned int itp = 0; itp < trackingParticles.size(); itp++) {
704  const auto& simtrack2 = trackingParticles.at(itp).g4Tracks().at(0);
705  //compare the two tracks, taking into account that both eventId and trackId need to be compared due to pileup
706  if (simtrack.eventId() == simtrack2.eventId() && simtrack.trackId() == simtrack2.trackId()) {
707  simcluster_to_trackingparticle = itp;
708  //we are satisfied with the first match, in practice there should not be more
709  break;
710  }
711  } //trackingParticles
712  } //simcluster tracks
713 
714  simcluster_detids_.push_back(detid_energy);
715  simcluster_idx_trackingparticle_.push_back(simcluster_to_trackingparticle);
716 
717  idx_simcluster += 1;
718  } //simclusters
719  } //caloParticles
720 
721  associateClusterToSimCluster(all_elements);
722 
723  //fill elements
724  for (unsigned int ielem = 0; ielem < all_elements.size(); ielem++) {
725  const auto& elem = all_elements.at(ielem);
726  const auto& orig = elem.orig;
727  reco::PFBlockElement::Type type = orig.type();
728 
729  float pt = 0.0;
730  float px = 0.0;
731  float py = 0.0;
732  float pz = 0.0;
733  float eta = 0.0;
734  float phi = 0.0;
735  float energy = 0.0;
736  float trajpoint = 0.0;
737  float eta_ecal = 0.0;
738  float phi_ecal = 0.0;
739  float eta_hcal = 0.0;
740  float phi_hcal = 0.0;
741  int charge = 0;
742  int layer = 0;
743  float depth = 0;
744 
746  const auto& matched_pftrack = orig.trackRefPF();
747  if (matched_pftrack.isNonnull()) {
748  const auto& atECAL = matched_pftrack->extrapolatedPoint(reco::PFTrajectoryPoint::ECALShowerMax);
749  const auto& atHCAL = matched_pftrack->extrapolatedPoint(reco::PFTrajectoryPoint::HCALEntrance);
750  if (atHCAL.isValid()) {
751  eta_hcal = atHCAL.positionREP().eta();
752  phi_hcal = atHCAL.positionREP().phi();
753  }
754  if (atECAL.isValid()) {
755  eta_ecal = atECAL.positionREP().eta();
756  phi_ecal = atECAL.positionREP().phi();
757  }
758  }
759  const auto& ref = ((const reco::PFBlockElementTrack*)&orig)->trackRef();
760  pt = ref->pt();
761  px = ref->px();
762  py = ref->py();
763  pz = ref->pz();
764  eta = ref->eta();
765  phi = ref->phi();
766  energy = ref->pt() * cosh(ref->eta());
767  charge = ref->charge();
768  } else if (type == reco::PFBlockElement::BREM) {
769  //requires to keep GsfPFRecTracks
770  const auto* orig2 = (const reco::PFBlockElementBrem*)&orig;
771  const auto& ref = orig2->GsftrackRef();
772  if (ref.isNonnull()) {
773  pt = ref->pt();
774  px = ref->px();
775  py = ref->py();
776  pz = ref->pz();
777  eta = ref->eta();
778  phi = ref->phi();
779  energy = ref->pt() * cosh(ref->eta());
780  trajpoint = orig2->indTrajPoint();
781  charge = ref->charge();
782  }
783  } else if (type == reco::PFBlockElement::GSF) {
784  //requires to keep GsfPFRecTracks
785  const auto* orig2 = (const reco::PFBlockElementGsfTrack*)&orig;
786  const auto& ref = orig2->GsftrackRef();
787  if (ref.isNonnull()) {
788  pt = ref->pt();
789  px = ref->px();
790  py = ref->py();
791  pz = ref->pz();
792  eta = ref->eta();
793  phi = ref->phi();
794  energy = ref->pt() * cosh(ref->eta());
795  }
800  const auto& ref = ((const reco::PFBlockElementCluster*)&orig)->clusterRef();
801  if (ref.isNonnull()) {
802  eta = ref->eta();
803  phi = ref->phi();
804  px = ref->position().x();
805  py = ref->position().y();
806  pz = ref->position().z();
807  energy = ref->energy();
808  layer = ref->layer();
809  depth = ref->depth();
810  }
811  } else if (type == reco::PFBlockElement::SC) {
812  const auto& clref = ((const reco::PFBlockElementSuperCluster*)&orig)->superClusterRef();
813  if (clref.isNonnull()) {
814  eta = clref->eta();
815  phi = clref->phi();
816  px = clref->position().x();
817  py = clref->position().y();
818  pz = clref->position().z();
819  energy = clref->energy();
820  }
821  }
822  vector<int> tps;
823  for (const auto& t : trackingparticle_to_element) {
824  if (t.second == (int)ielem) {
825  tps.push_back(t.first);
826  }
827  }
828  vector<int> scs;
829  for (const auto& t : simcluster_to_element) {
830  if (t.second == (int)ielem) {
831  scs.push_back(t.first);
832  }
833  }
834 
835  element_pt_.push_back(pt);
836  element_px_.push_back(px);
837  element_py_.push_back(py);
838  element_pz_.push_back(pz);
839  element_eta_.push_back(eta);
840  element_phi_.push_back(phi);
841  element_energy_.push_back(energy);
842  element_eta_ecal_.push_back(eta_ecal);
843  element_phi_ecal_.push_back(phi_ecal);
844  element_eta_hcal_.push_back(eta_hcal);
845  element_phi_hcal_.push_back(phi_hcal);
846  element_charge_.push_back(charge);
847  element_type_.push_back(type);
848  element_layer_.push_back(layer);
849  element_depth_.push_back(depth);
850  element_trajpoint_.push_back(trajpoint);
851  }
852 
853  //associate candidates to elements
854  int icandidate = 0;
855  for (const auto& cand : pfCandidates) {
856  pfcandidate_eta_.push_back(cand.eta());
857  pfcandidate_phi_.push_back(cand.phi());
858  pfcandidate_pt_.push_back(cand.pt());
859  pfcandidate_px_.push_back(cand.px());
860  pfcandidate_py_.push_back(cand.py());
861  pfcandidate_pz_.push_back(cand.pz());
862  pfcandidate_energy_.push_back(cand.energy());
863  pfcandidate_pdgid_.push_back(cand.pdgId());
864 
865  for (const auto& el : cand.elementsInBlocks()) {
866  const auto idx_block = el.first.index();
867  unsigned idx_element_in_block = el.second;
868 
869  int ielem = -1;
870  for (const auto& elem_with_index : all_elements) {
871  ielem += 1;
872  if (elem_with_index.idx_block == idx_block && elem_with_index.idx_elem == idx_element_in_block) {
873  break;
874  }
875  }
876  assert(ielem != -1);
877  element_to_candidate.push_back(make_pair(ielem, icandidate));
878  } //elements
879 
880  icandidate += 1;
881  } //pfCandidates
882 
883  cout << "trackingParticles=" << trackingParticles.size() << " caloParticles=" << caloParticles.size() << endl;
884  cout << "all_elements=" << all_elements.size() << endl;
885  cout << "pfCandidates=" << pfCandidates.size() << endl;
886  cout << "trackingparticle_to_element=" << trackingparticle_to_element.size()
887  << " simcluster_to_element=" << simcluster_to_element.size() << endl;
888  cout << "element_to_candidate=" << element_to_candidate.size() << endl;
889 
890  ev_event_ = iEvent.id().event();
891  ev_lumi_ = iEvent.id().luminosityBlock();
892  ev_run_ = iEvent.id().run();
893 
894  t_->Fill();
895 } //analyze
896 
898  edm::Handle<edm::View<TrackingParticle>>& trackingParticlesHandle) {
899  for (unsigned long ntrackingparticle = 0; ntrackingparticle < trackingParticles.size(); ntrackingparticle++) {
900  const auto& tp = trackingParticles.at(ntrackingparticle);
901  edm::RefToBase<TrackingParticle> tpref(trackingParticlesHandle, ntrackingparticle);
902 
903  math::XYZTLorentzVectorD vtx(0, 0, 0, 0);
904 
905  if (!tp.decayVertices().empty()) {
906  vtx = tp.decayVertices().at(0)->position();
907  }
908  auto orig_vtx = tp.vertex();
909 
910  // fill branches
911  trackingparticle_eta_.push_back(tp.p4().eta());
912  trackingparticle_phi_.push_back(tp.p4().phi());
913  trackingparticle_pt_.push_back(tp.p4().pt());
914  trackingparticle_px_.push_back(tp.p4().px());
915  trackingparticle_py_.push_back(tp.p4().py());
916  trackingparticle_pz_.push_back(tp.p4().pz());
917  trackingparticle_energy_.push_back(tp.p4().energy());
918  trackingparticle_dvx_.push_back(vtx.x());
919  trackingparticle_dvy_.push_back(vtx.y());
920  trackingparticle_dvz_.push_back(vtx.z());
921  trackingparticle_bx_.push_back(tp.eventId().bunchCrossing());
922  trackingparticle_ev_.push_back(tp.eventId().event());
923 
924  trackingparticle_ovx_.push_back(orig_vtx.x());
925  trackingparticle_ovy_.push_back(orig_vtx.y());
926  trackingparticle_ovz_.push_back(orig_vtx.z());
927 
928  trackingparticle_pid_.push_back(tp.pdgId());
929  }
930 }
931 
932 //https://stackoverflow.com/questions/27086195/linear-index-upper-triangular-matrix/27088560
933 int get_index_triu_vector(int i, int j, int n) {
934  int k = (n * (n - 1) / 2) - (n - i) * ((n - i) - 1) / 2 + j - i - 1;
935  return k;
936 }
937 
938 pair<int, int> get_triu_vector_index(int k, int n) {
939  int i = n - 2 - floor(sqrt(-8 * k + 4 * n * (n - 1) - 7) / 2.0 - 0.5);
940  int j = k + i + 1 - n * (n - 1) / 2 + (n - i) * ((n - i) - 1) / 2;
941  return make_pair(i, j);
942 }
943 
944 pair<vector<ElementWithIndex>, vector<tuple<int, int, float>>> PFAnalysis::processBlocks(
945  const std::vector<reco::PFBlock>& pfBlocks) {
946  vector<ElementWithIndex> ret;
947  vector<tuple<int, int, float>> distances;
948 
949  //Collect all the elements
950  int iblock = 0;
951  for (const auto& block : pfBlocks) {
952  int ielem = 0;
953  const auto& linkdata = block.linkData();
954 
955  //create a list of global element indices with distances
956  for (const auto& link : linkdata) {
957  const auto vecidx = link.first;
958  const auto dist = link.second.distance;
959  const auto& ij = get_triu_vector_index(vecidx, block.elements().size());
960  cout << "block " << iblock << " " << ielem << " " << vecidx << " " << ij.first << " " << ij.second << " " << dist
961  << endl;
962  auto globalindex_i = ij.first + ret.size();
963  auto globalindex_j = ij.second + ret.size();
964  distances.push_back(make_tuple(globalindex_i, globalindex_j, dist));
965  }
966 
967  for (const auto& elem : block.elements()) {
968  ElementWithIndex elem_index(elem, iblock, ielem);
969  ret.push_back(elem_index);
970  ielem += 1;
971  } //elements
972  iblock += 1;
973  } //blocks
974  return make_pair(ret, distances);
975 
976 } //processBlocks
977 
978 void PFAnalysis::associateClusterToSimCluster(const vector<ElementWithIndex>& all_elements) {
979  vector<map<uint64_t, double>> detids_elements;
980  map<uint64_t, double> rechits_energy_all;
981 
982  int idx_element = 0;
983  for (const auto& elem : all_elements) {
984  map<uint64_t, double> detids;
985  const auto& type = elem.orig.type();
986 
990  const auto& clref = elem.orig.clusterRef();
991  assert(clref.isNonnull());
992  const auto& cluster = *clref;
993 
994  //all rechits and the energy fractions in this cluster
995  const vector<reco::PFRecHitFraction>& rechit_fracs = cluster.recHitFractions();
996  for (const auto& rh : rechit_fracs) {
997  const reco::PFRecHit pfrh = *rh.recHitRef();
998  if (detids.find(pfrh.detId()) != detids.end()) {
999  continue;
1000  }
1001  detids[pfrh.detId()] += pfrh.energy();
1002  const auto id = DetId(pfrh.detId());
1003  float x = 0;
1004  float y = 0;
1005  float z = 0;
1006  float eta = 0;
1007  float phi = 0;
1008 
1009  const auto& pos = getHitPosition(id);
1010  x = pos.x();
1011  y = pos.y();
1012  z = pos.z();
1013  eta = pos.eta();
1014  phi = pos.phi();
1015 
1016  rechit_x_.push_back(x);
1017  rechit_y_.push_back(y);
1018  rechit_z_.push_back(z);
1019  rechit_det_.push_back(id.det());
1020  rechit_subdet_.push_back(id.subdetId());
1021  rechit_eta_.push_back(eta);
1022  rechit_phi_.push_back(phi);
1023  rechit_e_.push_back(pfrh.energy());
1024  rechit_idx_element_.push_back(idx_element);
1025  rechit_detid_.push_back(id.rawId());
1026  rechits_energy_all[id.rawId()] += pfrh.energy();
1027  } //rechit_fracs
1028  } else if (type == reco::PFBlockElement::SC) {
1029  const auto& clref = ((const reco::PFBlockElementSuperCluster*)&(elem.orig))->superClusterRef();
1030  assert(clref.isNonnull());
1031  const auto& cluster = *clref;
1032 
1033  //all rechits and the energy fractions in this cluster
1034  const auto& rechit_fracs = cluster.hitsAndFractions();
1035  for (const auto& rh : rechit_fracs) {
1036  if (detids.find(rh.first.rawId()) != detids.end()) {
1037  continue;
1038  }
1039  detids[rh.first.rawId()] += rh.second;
1040  const auto id = rh.first;
1041  float x = 0;
1042  float y = 0;
1043  float z = 0;
1044  float eta = 0;
1045  float phi = 0;
1046 
1047  const auto& pos = getHitPosition(id);
1048  x = pos.x();
1049  y = pos.y();
1050  z = pos.z();
1051  eta = pos.eta();
1052  phi = pos.phi();
1053 
1054  rechit_x_.push_back(x);
1055  rechit_y_.push_back(y);
1056  rechit_z_.push_back(z);
1057  rechit_det_.push_back(id.det());
1058  rechit_subdet_.push_back(id.subdetId());
1059  rechit_eta_.push_back(eta);
1060  rechit_phi_.push_back(phi);
1061  rechit_e_.push_back(rh.second);
1062  rechit_idx_element_.push_back(idx_element);
1063  rechit_detid_.push_back(id.rawId());
1064  rechits_energy_all[id.rawId()] += rh.second;
1065  } //rechit_fracs
1066  }
1067  detids_elements.push_back(detids);
1068  idx_element += 1;
1069  } //all_elements
1070 
1071  //associate elements (reco clusters) to simclusters
1072  int ielement = 0;
1073  for (const auto& detids : detids_elements) {
1074  int isimcluster = 0;
1075  if (!detids.empty()) {
1076  double sum_e_tot = 0.0;
1077  for (const auto& c : detids) {
1078  sum_e_tot += c.second;
1079  }
1080 
1081  for (const auto& simcluster_detids : simcluster_detids_) {
1082  double sum_e_tot_sc = 0.0;
1083  for (const auto& c : simcluster_detids) {
1084  sum_e_tot_sc += c.second;
1085  }
1086 
1087  //get the energy of the simcluster hits that matches detids of the rechits
1088  double cmp = detid_compare(detids, simcluster_detids, rechits_energy_all, false);
1089  if (cmp > 0) {
1090  simcluster_to_element.push_back(make_pair(isimcluster, ielement));
1091  simcluster_to_element_cmp.push_back((float)cmp);
1092  }
1093  isimcluster += 1;
1094  }
1095  } //element had rechits
1096  ielement += 1;
1097  } //rechit clusters
1098 }
1099 
1103 
1105  es.get<HcalRecNumberingRecord>().get(pHRNDC);
1106  hcons = &(*pHRNDC);
1107 
1108  aField_ = &(*magfield);
1109 }
1110 
1112 
1114 
1116 
1119  desc.setUnknown();
1120  descriptions.addDefault(desc);
1121 }
1122 
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:367
PFAnalysis::element_to_candidate
vector< pair< int, int > > element_to_candidate
Definition: PFAnalysis.cc:268
PFAnalysis::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: PFAnalysis.cc:548
ntrack
#define ntrack
PFAnalysis::pfCandidates_
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pfCandidates_
Definition: PFAnalysis.cc:152
Ecal2004TBTDCRanges_v1_cff.endRun
endRun
Definition: Ecal2004TBTDCRanges_v1_cff.py:4
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
bk::beginJob
void beginJob()
Definition: Breakpoints.cc:14
PFAnalysis::trackingparticle_bx_
vector< int > trackingparticle_bx_
Definition: PFAnalysis.cc:171
reco::PFBlockElement::HO
Definition: PFBlockElement.h:42
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
PFAnalysis::clearVariables
void clearVariables()
Definition: PFAnalysis.cc:414
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
PFAnalysis::trackingparticle_dvx_
vector< float > trackingparticle_dvx_
Definition: PFAnalysis.cc:168
PFAnalysis::simcluster_phi_
vector< float > simcluster_phi_
Definition: PFAnalysis.cc:182
EDAnalyzer.h
PFAnalysis::element_energy_
vector< float > element_energy_
Definition: PFAnalysis.cc:241
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
PFAnalysis::pfcandidate_py_
vector< float > pfcandidate_py_
Definition: PFAnalysis.cc:260
ElementWithIndex
Definition: PFAnalysis.cc:67
PFAnalysis::getHitPosition
GlobalPoint getHitPosition(const DetId &id)
Definition: PFAnalysis.cc:530
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
PFAnalysis::gen_eta_
vector< float > gen_eta_
Definition: PFAnalysis.cc:223
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
PFAnalysis::trackingparticle_exy_
vector< float > trackingparticle_exy_
Definition: PFAnalysis.cc:177
PFAnalysis::genParticles_
edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticles_
Definition: PFAnalysis.cc:147
PFAnalysis::simtrack_x_
vector< float > simtrack_x_
Definition: PFAnalysis.cc:217
PFAnalysis::trackingParticles_
edm::EDGetTokenT< edm::View< TrackingParticle > > trackingParticles_
Definition: PFAnalysis.cc:148
ESHandle.h
PFAnalysis::caloParticles_
edm::EDGetTokenT< edm::View< CaloParticle > > caloParticles_
Definition: PFAnalysis.cc:149
PFAnalysis::gen_pdgid_
vector< int > gen_pdgid_
Definition: PFAnalysis.cc:231
PFBlockElementCluster.h
reco::PFRecHit::energy
float energy() const
rechit energy
Definition: PFRecHit.h:99
PFCandidate.h
PFAnalysis::gen_px_
vector< float > gen_px_
Definition: PFAnalysis.cc:226
PFAnalysis::trackingparticle_py_
vector< float > trackingparticle_py_
Definition: PFAnalysis.cc:165
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
PFAnalysis::simhit_y_
vector< float > simhit_y_
Definition: PFAnalysis.cc:197
edm::Run
Definition: Run.h:45
deltaPhi.h
PFAnalysis::gen_pt_
vector< float > gen_pt_
Definition: PFAnalysis.cc:225
edm::EDGetTokenT
Definition: EDGetToken.h:33
PFAnalysis::element_depth_
vector< float > element_depth_
Definition: PFAnalysis.cc:249
PFAnalysis::trackingparticle_dvz_
vector< float > trackingparticle_dvz_
Definition: PFAnalysis.cc:170
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
PFAnalysis::simcluster_energy_
vector< float > simcluster_energy_
Definition: PFAnalysis.cc:184
PFAnalysis::pfcandidate_pt_
vector< float > pfcandidate_pt_
Definition: PFAnalysis.cc:258
PFAnalysis::ev_run_
edm::RunNumber_t ev_run_
Definition: PFAnalysis.cc:157
reco::PFBlockElementSuperCluster
Cluster Element.
Definition: PFBlockElementSuperCluster.h:15
PFAnalysis::Point
ROOT::Math::Transform3D::Point Point
Definition: PFAnalysis.cc:119
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
HcalTopology
Definition: HcalTopology.h:26
DetId::Hcal
Definition: DetId.h:28
reco::PFBlockElement::SC
Definition: PFBlockElement.h:41
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
TrackAssociation.h
PFAnalysis::simcluster_detids_
vector< std::map< uint64_t, double > > simcluster_detids_
Definition: PFAnalysis.cc:193
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PFAnalysis::element_px_
vector< float > element_px_
Definition: PFAnalysis.cc:236
BaseParticlePropagator.h
cms::cuda::assert
assert(be >=bs)
PFAnalysis::gen_status_
vector< int > gen_status_
Definition: PFAnalysis.cc:232
PFAnalysis::simcluster_pid_
vector< int > simcluster_pid_
Definition: PFAnalysis.cc:190
PFAnalysis::trackingparticle_dvy_
vector< float > trackingparticle_dvy_
Definition: PFAnalysis.cc:169
PFAnalysis::simhit_det_
vector< int > simhit_det_
Definition: PFAnalysis.cc:201
reco::PFBlockElement::HCAL
Definition: PFBlockElement.h:36
PFAnalysis::rechit_x_
vector< float > rechit_x_
Definition: PFAnalysis.cc:207
PFAnalysis::simhit_subdet_
vector< int > simhit_subdet_
Definition: PFAnalysis.cc:202
PFAnalysis::tracks_recotosim_
edm::EDGetTokenT< reco::RecoToSimCollection > tracks_recotosim_
Definition: PFAnalysis.cc:153
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
PFAnalysis::simhit_eta_
vector< float > simhit_eta_
Definition: PFAnalysis.cc:199
HcalBarrel
Definition: HcalAssistant.h:33
PFAnalysis::ev_event_
edm::EventNumber_t ev_event_
Definition: PFAnalysis.cc:159
PFAnalysis::topologyToken_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topologyToken_
Definition: PFAnalysis.cc:274
PFBlockElementBrem.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
PFAnalysis::element_distance_i_
vector< int > element_distance_i_
Definition: PFAnalysis.cc:252
PFAnalysis::trackingparticle_exx_
vector< float > trackingparticle_exx_
Definition: PFAnalysis.cc:176
EcalBarrel
Definition: EcalSubdetector.h:10
PFAnalysis::hcons
const HcalDDDRecConstants * hcons
Definition: PFAnalysis.cc:278
HcalGeometry.h
PFAnalysis::simcluster_pz_
vector< float > simcluster_pz_
Definition: PFAnalysis.cc:187
edm::Ref
Definition: AssociativeIterator.h:58
PFAnalysis::trackingparticle_pid_
vector< int > trackingparticle_pid_
Definition: PFAnalysis.cc:179
reco::PFBlockElement::Type
Type
Definition: PFBlockElement.h:30
ElementWithIndex::idx_elem
size_t idx_elem
Definition: PFAnalysis.cc:71
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
PFAnalysis::rechit_idx_element_
vector< int > rechit_idx_element_
Definition: PFAnalysis.cc:214
DetId
Definition: DetId.h:17
PFAnalysis::trackingparticle_px_
vector< float > trackingparticle_px_
Definition: PFAnalysis.cc:164
PFAnalysis::trackingparticle_ev_
vector< int > trackingparticle_ev_
Definition: PFAnalysis.cc:172
MakerMacros.h
Point
math::XYZPoint Point
Definition: TrackerDpgAnalysis.cc:106
CaloGeometry
Definition: CaloGeometry.h:21
PlaneBuilder.h
PFAnalysis::element_charge_
vector< int > element_charge_
Definition: PFAnalysis.cc:246
SimCluster.h
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
Track.h
PFAnalysis::pfcandidate_pz_
vector< float > pfcandidate_pz_
Definition: PFAnalysis.cc:261
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
PFAnalysis::element_type_
vector< int > element_type_
Definition: PFAnalysis.cc:247
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HFRecHit.h
PFAnalysis::ev_lumi_
edm::LuminosityBlockNumber_t ev_lumi_
Definition: PFAnalysis.cc:158
BPhysicsValidation_cfi.daughters
daughters
Definition: BPhysicsValidation_cfi.py:11
PFAnalysis::rechit_z_
vector< float > rechit_z_
Definition: PFAnalysis.cc:209
PFAnalysis::simtrack_z_
vector< float > simtrack_z_
Definition: PFAnalysis.cc:219
PFAnalysis::processTrackingParticles
void processTrackingParticles(const edm::View< TrackingParticle > &trackingParticles, edm::Handle< edm::View< TrackingParticle >> &trackingParticlesHandle)
Definition: PFAnalysis.cc:897
PFAnalysis::simhit_frac_
vector< float > simhit_frac_
Definition: PFAnalysis.cc:195
reco::PFBlockElement::TRACK
Definition: PFBlockElement.h:32
Service.h
PVValHelper::eta
Definition: PVValidationHelpers.h:69
PFAnalysis::trackingparticle_pz_
vector< float > trackingparticle_pz_
Definition: PFAnalysis.cc:166
PVValHelper::pT
Definition: PVValidationHelpers.h:70
PFAnalysis::simtrack_pid_
vector< int > simtrack_pid_
Definition: PFAnalysis.cc:221
ElementWithIndex::idx_block
size_t idx_block
Definition: PFAnalysis.cc:70
PFAnalysis::simtrack_y_
vector< float > simtrack_y_
Definition: PFAnalysis.cc:218
reco::PFTrajectoryPoint::ECALShowerMax
Definition: PFTrajectoryPoint.h:46
caloTruthCellsProducer_cfi.caloParticles
caloParticles
Definition: caloTruthCellsProducer_cfi.py:6
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PFAnalysis::simcluster_idx_trackingparticle_
vector< int > simcluster_idx_trackingparticle_
Definition: PFAnalysis.cc:191
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
PFAnalysis::element_phi_hcal_
vector< float > element_phi_hcal_
Definition: PFAnalysis.cc:245
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
PFCluster.h
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
CaloClusterFwd.h
HcalOuter
Definition: HcalAssistant.h:35
PFAnalysis::simcluster_ev_
vector< int > simcluster_ev_
Definition: PFAnalysis.cc:189
reco::PFBlockElementBrem
Track Element.
Definition: PFBlockElementBrem.h:17
PFAnalysis::simhit_detid_
vector< uint64_t > simhit_detid_
Definition: PFAnalysis.cc:204
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
PFAnalysis::~PFAnalysis
~PFAnalysis() override
Definition: PFAnalysis.cc:412
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
dqmdumpme.k
k
Definition: dqmdumpme.py:60
PFAnalysis::rechit_detid_
vector< uint64_t > rechit_detid_
Definition: PFAnalysis.cc:215
PFAnalysis::beginJob
void beginJob() override
Definition: PFAnalysis.cc:1113
PFAnalysis::trackingparticle_to_element
vector< pair< int, int > > trackingparticle_to_element
Definition: PFAnalysis.cc:265
Point3DBase< float, GlobalTag >
GsfElectron.h
nhits
Definition: HIMultiTrackSelector.h:42
PFAnalysis::trackingparticle_ovx_
vector< float > trackingparticle_ovx_
Definition: PFAnalysis.cc:173
PFAnalysis::endRun
void endRun(edm::Run const &iEvent, edm::EventSetup const &) override
Definition: PFAnalysis.cc:1111
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
PFAnalysis::gen_phi_
vector< float > gen_phi_
Definition: PFAnalysis.cc:224
PFAnalysis::simcluster_to_element
vector< pair< int, int > > simcluster_to_element
Definition: PFAnalysis.cc:266
PFAnalysis::simcluster_pt_
vector< float > simcluster_pt_
Definition: PFAnalysis.cc:183
CaloGeometryRecord.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
Vertex.h
PFAnalysis::pfcandidate_pdgid_
vector< int > pfcandidate_pdgid_
Definition: PFAnalysis.cc:263
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
PFAnalysis::pfcandidate_energy_
vector< float > pfcandidate_energy_
Definition: PFAnalysis.cc:262
TFileService.h
PFAnalysis::simcluster_nhits_
vector< int > simcluster_nhits_
Definition: PFAnalysis.cc:192
PFAnalysis::rechit_subdet_
vector< float > rechit_subdet_
Definition: PFAnalysis.cc:211
PFAnalysis::simhit_phi_
vector< float > simhit_phi_
Definition: PFAnalysis.cc:200
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::View
Definition: CaloClusterFwd.h:14
PFAnalysis::simcluster_px_
vector< float > simcluster_px_
Definition: PFAnalysis.cc:185
PFAnalysis::associateClusterToSimCluster
void associateClusterToSimCluster(const vector< ElementWithIndex > &all_elements)
Definition: PFAnalysis.cc:978
CaloSubdetectorGeometry.h
PFAnalysis::element_eta_hcal_
vector< float > element_eta_hcal_
Definition: PFAnalysis.cc:244
HLTBitAnalyser_cfi.simhits
simhits
SIM objects.
Definition: HLTBitAnalyser_cfi.py:21
edm::ParameterSet
Definition: ParameterSet.h:47
reco::PFBlockElement::HFEM
Definition: PFBlockElement.h:39
PFAnalysis::element_phi_
vector< float > element_phi_
Definition: PFAnalysis.cc:240
reco::PFBlockElement::GSF
Definition: PFBlockElement.h:37
Event.h
PFAnalysis::rechit_e_
vector< float > rechit_e_
Definition: PFAnalysis.cc:206
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
CaloSubdetectorGeometry::present
virtual bool present(const DetId &id) const
is this detid present in the geometry?
Definition: CaloSubdetectorGeometry.cc:40
PFAnalysis::element_phi_ecal_
vector< float > element_phi_ecal_
Definition: PFAnalysis.cc:243
PFAnalysis::gen_py_
vector< float > gen_py_
Definition: PFAnalysis.cc:227
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
PFAnalysis::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFAnalysis.cc:1117
HcalDetId.h
PFAnalysis::processBlocks
pair< vector< ElementWithIndex >, vector< tuple< int, int, float > > > processBlocks(const std::vector< reco::PFBlock > &pfBlocks)
Definition: PFAnalysis.cc:944
CaloParticle.h
muonClassificationByHits_cfi.trackingParticles
trackingParticles
Definition: muonClassificationByHits_cfi.py:28
PFAnalysis::simcluster_to_element_cmp
vector< float > simcluster_to_element_cmp
Definition: PFAnalysis.cc:267
PFAnalysis::rechit_eta_
vector< float > rechit_eta_
Definition: PFAnalysis.cc:212
HcalHitRelabeller.h
PFAnalysis::beginRun
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
Definition: PFAnalysis.cc:1100
reco::PFBlockElement::ECAL
Definition: PFBlockElement.h:35
reco::PFTrajectoryPoint::HCALEntrance
HCAL front face.
Definition: PFTrajectoryPoint.h:48
cand
Definition: decayParser.h:32
detid_compare
double detid_compare(const map< uint64_t, double > &rechits, const map< uint64_t, double > &simhits, const map< uint64_t, double > &rechits_energy, bool print)
Definition: PFAnalysis.cc:99
get_triu_vector_index
pair< int, int > get_triu_vector_index(int k, int n)
Definition: PFAnalysis.cc:938
edm::Service< TFileService >
reco::PFBlockElement::BREM
Definition: PFBlockElement.h:38
PFAnalysis::element_trajpoint_
vector< float > element_trajpoint_
Definition: PFAnalysis.cc:250
iEvent
int iEvent
Definition: GenABIO.cc:224
PFBlockElementSuperCluster.h
PFAnalysis::element_distance_j_
vector< int > element_distance_j_
Definition: PFAnalysis.cc:253
GsfTrack.h
PFAnalysis::simhit_idx_simcluster_
vector< int > simhit_idx_simcluster_
Definition: PFAnalysis.cc:203
get_index_triu_vector
int get_index_triu_vector(int i, int j, int n)
Definition: PFAnalysis.cc:933
PFAnalysis::gen_energy_
vector< float > gen_energy_
Definition: PFAnalysis.cc:229
PFAnalysis::simtrack_idx_simcluster_
vector< int > simtrack_idx_simcluster_
Definition: PFAnalysis.cc:220
PFAnalysis::element_distance_d_
vector< float > element_distance_d_
Definition: PFAnalysis.cc:254
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
MagneticField.h
PFAnalysis::gen_pz_
vector< float > gen_pz_
Definition: PFAnalysis.cc:228
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
reco::PFBlockElement::HFHAD
Definition: PFBlockElement.h:40
PFAnalysis::pfcandidate_px_
vector< float > pfcandidate_px_
Definition: PFAnalysis.cc:259
DetId::Ecal
Definition: DetId.h:27
get
#define get
PFAnalysis::element_eta_
vector< float > element_eta_
Definition: PFAnalysis.cc:239
PFAnalysis::simcluster_py_
vector< float > simcluster_py_
Definition: PFAnalysis.cc:186
edm::ESGetToken< CaloGeometry, CaloGeometryRecord >
PFAnalysis::simcluster_bx_
vector< int > simcluster_bx_
Definition: PFAnalysis.cc:188
reco::PFBlockElement
Abstract base class for a PFBlock element (track, cluster...)
Definition: PFBlockElement.h:26
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
alignCSCRings.r
r
Definition: alignCSCRings.py:93
reco::PFRecHit::detId
unsigned detId() const
rechit detId
Definition: PFRecHit.h:93
PFBlock.h
HcalForward
Definition: HcalAssistant.h:36
MagVolumeOutsideValidity.h
PFAnalysis::element_pz_
vector< float > element_pz_
Definition: PFAnalysis.cc:238
EcalPreshower
Definition: EcalSubdetector.h:10
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
TrackingParticle.h
CaloCellGeometry.h
reco::PFBlockElementGsfTrack
Track Element.
Definition: PFBlockElementGsfTrack.h:18
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
PFAnalysis::simcluster_eta_
vector< float > simcluster_eta_
Definition: PFAnalysis.cc:181
PFAnalysis::trackingparticle_phi_
vector< float > trackingparticle_phi_
Definition: PFAnalysis.cc:162
PFAnalysis::element_pt_
vector< float > element_pt_
Definition: PFAnalysis.cc:235
PFAnalysis::element_py_
vector< float > element_py_
Definition: PFAnalysis.cc:237
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
PFAnalysis::simhit_z_
vector< float > simhit_z_
Definition: PFAnalysis.cc:198
ElementWithIndex::ElementWithIndex
ElementWithIndex(const reco::PFBlockElement &_orig, size_t _idx_block, size_t _idx_elem)
Definition: PFAnalysis.cc:72
PFAnalysis::PFAnalysis
PFAnalysis()
Definition: PFAnalysis.cc:281
HcalEndcap
Definition: HcalAssistant.h:34
fileCollector.cmp
cmp
Definition: fileCollector.py:125
DetId.h
Frameworkfwd.h
PFAnalysis::trackingparticle_ovz_
vector< float > trackingparticle_ovz_
Definition: PFAnalysis.cc:175
PFAnalysis::gen_charge_
vector< int > gen_charge_
Definition: PFAnalysis.cc:230
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
reco::PFBlockElementCluster
Cluster Element.
Definition: PFBlockElementCluster.h:16
find_element_ref
int find_element_ref(const vector< ElementWithIndex > &vec, const edm::RefToBase< reco::Track > &r)
Definition: PFAnalysis.cc:76
CaloGeometry.h
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
PFAnalysis::endJob
void endJob() override
Definition: PFAnalysis.cc:1115
reco::PFBlockElementTrack
Track Element.
Definition: PFBlockElementTrack.h:17
PFAnalysis::aField_
MagneticField const * aField_
Definition: PFAnalysis.cc:271
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
edm::RefToBase< reco::Track >
HcalRecHitCollections.h
PFAnalysis::trackingparticle_eta_
vector< float > trackingparticle_eta_
Definition: PFAnalysis.cc:161
PFAnalysis::element_layer_
vector< int > element_layer_
Definition: PFAnalysis.cc:248
HcalDDDRecConstants
Definition: HcalDDDRecConstants.h:23
reco::PFRecHit
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
PFAnalysis::hcal_topo
HcalTopology * hcal_topo
Definition: PFAnalysis.cc:277
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
PFAnalysis::geom
CaloGeometry * geom
Definition: PFAnalysis.cc:276
ztail.d
d
Definition: ztail.py:151
PFAnalysis::geometryToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
Definition: PFAnalysis.cc:273
ElementWithIndex::orig
const reco::PFBlockElement & orig
Definition: PFAnalysis.cc:69
reco::PFBlockElement::PS1
Definition: PFBlockElement.h:33
PFAnalysis::pfBlocks_
edm::EDGetTokenT< std::vector< reco::PFBlock > > pfBlocks_
Definition: PFAnalysis.cc:151
PFAnalysis::pfcandidate_phi_
vector< float > pfcandidate_phi_
Definition: PFAnalysis.cc:257
ParameterSet.h
HepMCProduct.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PFAnalysis::gen_daughters_
vector< vector< int > > gen_daughters_
Definition: PFAnalysis.cc:233
edm::Event
Definition: Event.h:73
PFAnalysis::pfcandidate_eta_
vector< float > pfcandidate_eta_
Definition: PFAnalysis.cc:256
PFAnalysis::trackingparticle_pt_
vector< float > trackingparticle_pt_
Definition: PFAnalysis.cc:163
CommonMethods.cp
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
Definition: CommonMethods.py:192
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
MagneticField
Definition: MagneticField.h:19
PFAnalysis::trackingparticle_energy_
vector< float > trackingparticle_energy_
Definition: PFAnalysis.cc:167
PFAnalysis
Definition: PFAnalysis.cc:117
volumeBasedMagneticField_160812_cfi.magfield
magfield
Definition: volumeBasedMagneticField_160812_cfi.py:11
PFBlockElementGsfTrack.h
PFAnalysis::element_eta_ecal_
vector< float > element_eta_ecal_
Definition: PFAnalysis.cc:242
edm::InputTag
Definition: InputTag.h:15
PFAnalysis::rechit_det_
vector< float > rechit_det_
Definition: PFAnalysis.cc:210
PFBlockElementTrack.h
PFAnalysis::t_
TTree * t_
Definition: PFAnalysis.cc:155
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
reco::PFBlockElement::PS2
Definition: PFBlockElement.h:34
PFAnalysis::trackingparticle_mother_
vector< int > trackingparticle_mother_
Definition: PFAnalysis.cc:178
PFAnalysis::rechit_y_
vector< float > rechit_y_
Definition: PFAnalysis.cc:208
PFAnalysis::tracks_
edm::EDGetTokenT< edm::View< reco::Track > > tracks_
Definition: PFAnalysis.cc:150
PFAnalysis::trackingparticle_ovy_
vector< float > trackingparticle_ovy_
Definition: PFAnalysis.cc:174
PFAnalysis::rechit_phi_
vector< float > rechit_phi_
Definition: PFAnalysis.cc:213
PFAnalysis::simhit_x_
vector< float > simhit_x_
Definition: PFAnalysis.cc:196