48 #include "Math/Transform3D.h"
74 : orig(_orig), idx_block(_idx_block), idx_elem(_idx_elem){};
79 for (
unsigned int i = 0;
i < vec.size();
i++) {
80 const auto& elem = vec.at(
i);
82 const auto& ref = elem.orig.trackRef();
83 if (ref.isNonnull() && ref->extra().isNonnull()) {
84 if (ref.key() == r.
key()) {
96 for (
const auto& rh : rechits) {
97 for (
const auto& sh : simhits) {
98 if (rh.first == sh.first) {
100 ret += rh.second * sh.second;
123 void endJob()
override;
128 pair<vector<ElementWithIndex>, vector<tuple<int, int, float>>> processBlocks(
129 const std::vector<reco::PFBlock>& pfBlocks);
131 void associateClusterToSimCluster(
const vector<ElementWithIndex>& all_elements);
133 void clearVariables();
283 tracks_recotosim_ = consumes<reco::RecoToSimCollection>(
edm::InputTag(
"trackingParticleRecoTrackAsssociation"));
284 trackingParticles_ = consumes<edm::View<TrackingParticle>>(
edm::InputTag(
"mix",
"MergedTrackTruth"));
285 caloParticles_ = consumes<edm::View<CaloParticle>>(
edm::InputTag(
"mix",
"MergedCaloTruth"));
286 genParticles_ = consumes<std::vector<reco::GenParticle>>(
edm::InputTag(
"genParticles"));
287 pfBlocks_ = consumes<std::vector<reco::PFBlock>>(
edm::InputTag(
"particleFlowBlock"));
288 pfCandidates_ = consumes<std::vector<reco::PFCandidate>>(
edm::InputTag(
"particleFlow"));
289 tracks_ = consumes<edm::View<reco::Track>>(
edm::InputTag(
"generalTracks"));
292 geometryToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>(
edm::ESInputTag{});
293 topologyToken_ = esConsumes<HcalTopology, HcalRecNumberingRecord>(
edm::ESInputTag{});
294 magFieldToken_ = esConsumes<edm::Transition::BeginRun>();
295 hcalDDDrecToken_ = esConsumes<edm::Transition::BeginRun>();
299 fs->
make<TH1F>(
"total",
"total", 100, 0, 5.);
301 t_ = fs->
make<TTree>(
"pftree",
"pftree");
304 t_->Branch(
"event", &ev_event_);
305 t_->Branch(
"lumi", &ev_lumi_);
306 t_->Branch(
"run", &ev_run_);
308 t_->Branch(
"trackingparticle_eta", &trackingparticle_eta_);
309 t_->Branch(
"trackingparticle_phi", &trackingparticle_phi_);
310 t_->Branch(
"trackingparticle_pt", &trackingparticle_pt_);
311 t_->Branch(
"trackingparticle_px", &trackingparticle_px_);
312 t_->Branch(
"trackingparticle_py", &trackingparticle_py_);
313 t_->Branch(
"trackingparticle_pz", &trackingparticle_pz_);
314 t_->Branch(
"trackingparticle_energy", &trackingparticle_energy_);
315 t_->Branch(
"trackingparticle_dvx", &trackingparticle_dvx_);
316 t_->Branch(
"trackingparticle_dvy", &trackingparticle_dvy_);
317 t_->Branch(
"trackingparticle_dvz", &trackingparticle_dvz_);
318 t_->Branch(
"trackingparticle_bx", &trackingparticle_bx_);
319 t_->Branch(
"trackingparticle_ev", &trackingparticle_ev_);
320 t_->Branch(
"trackingparticle_pid", &trackingparticle_pid_);
322 t_->Branch(
"simcluster_eta", &simcluster_eta_);
323 t_->Branch(
"simcluster_phi", &simcluster_phi_);
324 t_->Branch(
"simcluster_pt", &simcluster_pt_);
325 t_->Branch(
"simcluster_px", &simcluster_px_);
326 t_->Branch(
"simcluster_py", &simcluster_py_);
327 t_->Branch(
"simcluster_pz", &simcluster_pz_);
328 t_->Branch(
"simcluster_energy", &simcluster_energy_);
329 t_->Branch(
"simcluster_bx", &simcluster_bx_);
330 t_->Branch(
"simcluster_ev", &simcluster_ev_);
331 t_->Branch(
"simcluster_pid", &simcluster_pid_);
332 t_->Branch(
"simcluster_idx_trackingparticle", &simcluster_idx_trackingparticle_);
333 t_->Branch(
"simcluster_nhits", &simcluster_nhits_);
336 t_->Branch(
"simhit_frac", &simhit_frac_);
337 t_->Branch(
"simhit_x", &simhit_x_);
338 t_->Branch(
"simhit_y", &simhit_y_);
339 t_->Branch(
"simhit_z", &simhit_z_);
340 t_->Branch(
"simhit_det", &simhit_det_);
341 t_->Branch(
"simhit_subdet", &simhit_subdet_);
342 t_->Branch(
"simhit_eta", &simhit_eta_);
343 t_->Branch(
"simhit_phi", &simhit_phi_);
344 t_->Branch(
"simhit_idx_simcluster", &simhit_idx_simcluster_);
345 t_->Branch(
"simhit_detid", &simhit_detid_);
347 t_->Branch(
"rechit_e", &rechit_e_);
348 t_->Branch(
"rechit_x", &rechit_x_);
349 t_->Branch(
"rechit_y", &rechit_y_);
350 t_->Branch(
"rechit_z", &rechit_z_);
351 t_->Branch(
"rechit_det", &rechit_det_);
352 t_->Branch(
"rechit_subdet", &rechit_subdet_);
353 t_->Branch(
"rechit_eta", &rechit_eta_);
354 t_->Branch(
"rechit_phi", &rechit_phi_);
355 t_->Branch(
"rechit_idx_element", &rechit_idx_element_);
356 t_->Branch(
"rechit_detid", &rechit_detid_);
359 t_->Branch(
"simtrack_x", &simtrack_x_);
360 t_->Branch(
"simtrack_y", &simtrack_y_);
361 t_->Branch(
"simtrack_z", &simtrack_z_);
362 t_->Branch(
"simtrack_idx_simcluster_", &simtrack_idx_simcluster_);
363 t_->Branch(
"simtrack_pid", &simtrack_pid_);
365 t_->Branch(
"gen_eta", &gen_eta_);
366 t_->Branch(
"gen_phi", &gen_phi_);
367 t_->Branch(
"gen_pt", &gen_pt_);
368 t_->Branch(
"gen_px", &gen_px_);
369 t_->Branch(
"gen_py", &gen_py_);
370 t_->Branch(
"gen_pz", &gen_pz_);
371 t_->Branch(
"gen_energy", &gen_energy_);
372 t_->Branch(
"gen_charge", &gen_charge_);
373 t_->Branch(
"gen_pdgid", &gen_pdgid_);
374 t_->Branch(
"gen_status", &gen_status_);
375 t_->Branch(
"gen_daughters", &gen_daughters_);
378 t_->Branch(
"element_pt", &element_pt_);
379 t_->Branch(
"element_px", &element_px_);
380 t_->Branch(
"element_py", &element_py_);
381 t_->Branch(
"element_pz", &element_pz_);
382 t_->Branch(
"element_deltap", &element_deltap_);
383 t_->Branch(
"element_sigmadeltap", &element_sigmadeltap_);
384 t_->Branch(
"element_eta", &element_eta_);
385 t_->Branch(
"element_phi", &element_phi_);
386 t_->Branch(
"element_energy", &element_energy_);
387 t_->Branch(
"element_eta_ecal", &element_eta_ecal_);
388 t_->Branch(
"element_phi_ecal", &element_phi_ecal_);
389 t_->Branch(
"element_eta_hcal", &element_eta_hcal_);
390 t_->Branch(
"element_phi_hcal", &element_phi_hcal_);
391 t_->Branch(
"element_charge", &element_charge_);
392 t_->Branch(
"element_type", &element_type_);
393 t_->Branch(
"element_layer", &element_layer_);
394 t_->Branch(
"element_depth", &element_depth_);
395 t_->Branch(
"element_trajpoint", &element_trajpoint_);
396 t_->Branch(
"element_muon_dt_hits", &element_muon_dt_hits_);
397 t_->Branch(
"element_muon_csc_hits", &element_muon_csc_hits_);
400 t_->Branch(
"element_distance_i", &element_distance_i_);
401 t_->Branch(
"element_distance_j", &element_distance_j_);
402 t_->Branch(
"element_distance_d", &element_distance_d_);
404 t_->Branch(
"pfcandidate_eta", &pfcandidate_eta_);
405 t_->Branch(
"pfcandidate_phi", &pfcandidate_phi_);
406 t_->Branch(
"pfcandidate_pt", &pfcandidate_pt_);
407 t_->Branch(
"pfcandidate_px", &pfcandidate_px_);
408 t_->Branch(
"pfcandidate_py", &pfcandidate_py_);
409 t_->Branch(
"pfcandidate_pz", &pfcandidate_pz_);
410 t_->Branch(
"pfcandidate_energy", &pfcandidate_energy_);
411 t_->Branch(
"pfcandidate_pdgid", &pfcandidate_pdgid_);
414 t_->Branch(
"trackingparticle_to_element", &trackingparticle_to_element);
415 t_->Branch(
"simcluster_to_element", &simcluster_to_element);
416 t_->Branch(
"simcluster_to_element_cmp", &simcluster_to_element_cmp);
417 t_->Branch(
"element_to_candidate", &element_to_candidate);
427 trackingparticle_to_element.clear();
428 simcluster_to_element.clear();
429 simcluster_to_element_cmp.clear();
430 element_to_candidate.clear();
432 trackingparticle_eta_.clear();
433 trackingparticle_phi_.clear();
434 trackingparticle_pt_.clear();
435 trackingparticle_px_.clear();
436 trackingparticle_py_.clear();
437 trackingparticle_pz_.clear();
438 trackingparticle_energy_.clear();
439 trackingparticle_dvx_.clear();
440 trackingparticle_dvy_.clear();
441 trackingparticle_dvz_.clear();
442 trackingparticle_bx_.clear();
443 trackingparticle_ev_.clear();
444 trackingparticle_ovx_.clear();
445 trackingparticle_ovy_.clear();
446 trackingparticle_ovz_.clear();
447 trackingparticle_exx_.clear();
448 trackingparticle_exy_.clear();
449 trackingparticle_mother_.clear();
450 trackingparticle_pid_.clear();
452 simcluster_eta_.clear();
453 simcluster_phi_.clear();
454 simcluster_pt_.clear();
455 simcluster_energy_.clear();
456 simcluster_pid_.clear();
457 simcluster_detids_.clear();
458 simcluster_bx_.clear();
459 simcluster_ev_.clear();
460 simcluster_px_.clear();
461 simcluster_py_.clear();
462 simcluster_pz_.clear();
463 simcluster_idx_trackingparticle_.clear();
464 simcluster_nhits_.clear();
467 simhit_frac_.clear();
472 simhit_subdet_.clear();
475 simhit_idx_simcluster_.clear();
476 simhit_detid_.clear();
483 rechit_subdet_.clear();
486 rechit_idx_element_.clear();
487 rechit_detid_.clear();
493 simtrack_idx_simcluster_.clear();
494 simtrack_pid_.clear();
506 gen_daughters_.clear();
512 element_deltap_.clear();
513 element_sigmadeltap_.clear();
514 element_eta_.clear();
515 element_phi_.clear();
516 element_energy_.clear();
517 element_eta_ecal_.clear();
518 element_phi_ecal_.clear();
519 element_eta_hcal_.clear();
520 element_phi_hcal_.clear();
521 element_charge_.clear();
522 element_type_.clear();
523 element_layer_.clear();
524 element_depth_.clear();
525 element_trajpoint_.clear();
526 element_muon_dt_hits_.clear();
527 element_muon_csc_hits_.clear();
529 element_distance_i_.clear();
530 element_distance_j_.clear();
531 element_distance_d_.clear();
533 pfcandidate_eta_.clear();
534 pfcandidate_phi_.clear();
535 pfcandidate_pt_.clear();
536 pfcandidate_px_.clear();
537 pfcandidate_py_.clear();
538 pfcandidate_pz_.clear();
539 pfcandidate_energy_.clear();
540 pfcandidate_pdgid_.clear();
547 bool present =
false;
553 present = geom_sd->
present(
id);
565 auto& pG = iSetup.
getData(geometryToken_);
567 auto&
pT = iSetup.
getData(topologyToken_);
572 iEvent.
getByToken(trackingParticles_, trackingParticlesHandle);
576 iEvent.
getByToken(caloParticles_, caloParticlesHandle);
581 iEvent.
getByToken(tracks_recotosim_, recotosimCollection);
582 const auto recotosim = *recotosimCollection;
589 iEvent.
getByToken(genParticles_, genParticlesHandle);
590 for (std::vector<reco::GenParticle>::const_iterator it_p = genParticlesHandle->begin();
591 it_p != genParticlesHandle->end();
593 gen_eta_.push_back(it_p->eta());
594 gen_phi_.push_back(it_p->phi());
595 gen_pt_.push_back(it_p->pt());
596 gen_px_.push_back(it_p->px());
597 gen_py_.push_back(it_p->py());
598 gen_pz_.push_back(it_p->pz());
599 gen_energy_.push_back(it_p->energy());
600 gen_charge_.push_back(it_p->charge());
601 gen_pdgid_.push_back(it_p->pdgId());
602 gen_status_.push_back(it_p->status());
603 std::vector<int> daughters(it_p->daughterRefVector().size(), 0);
604 for (
unsigned j = 0;
j < it_p->daughterRefVector().size(); ++
j) {
605 daughters[
j] =
static_cast<int>(it_p->daughterRefVector().at(
j).key());
607 gen_daughters_.push_back(daughters);
611 iEvent.
getByToken(pfCandidates_, pfCandidatesHandle);
612 std::vector<reco::PFCandidate>
pfCandidates = *pfCandidatesHandle;
616 std::vector<reco::PFBlock> pfBlocks = *pfBlocksHandle;
619 const auto& all_elements_distances = processBlocks(pfBlocks);
620 const auto& all_elements = all_elements_distances.first;
621 const auto& all_distances = all_elements_distances.second;
622 assert(!all_elements.empty());
624 for (
const auto&
d : all_distances) {
625 element_distance_i_.push_back(get<0>(
d));
626 element_distance_j_.push_back(get<1>(
d));
627 element_distance_d_.push_back(get<2>(
d));
633 const auto vec_idx_in_all_elements =
find_element_ref(all_elements, trackref);
636 if (vec_idx_in_all_elements.empty()) {
640 if (recotosim.find(trackref) != recotosim.end()) {
641 const auto& tps = recotosim[trackref];
642 for (
const auto&
tp : tps) {
644 for (
auto idx_in_all_elements : vec_idx_in_all_elements) {
645 trackingparticle_to_element.emplace_back(tpr.
key(), idx_in_all_elements);
651 processTrackingParticles(trackingParticles, trackingParticlesHandle);
653 int idx_simcluster = 0;
655 for (
unsigned long ncaloparticle = 0; ncaloparticle < caloParticles.
size(); ncaloparticle++) {
656 const auto&
cp = caloParticles.
at(ncaloparticle);
660 for (
const auto& simcluster :
cp.simClusters()) {
662 map<uint64_t, double> detid_energy;
664 simcluster_nhits_.push_back(nhits);
665 simcluster_eta_.push_back(simcluster->p4().eta());
666 simcluster_phi_.push_back(simcluster->p4().phi());
667 simcluster_pt_.push_back(simcluster->p4().pt());
668 simcluster_energy_.push_back(simcluster->energy());
669 simcluster_pid_.push_back(simcluster->pdgId());
670 simcluster_bx_.push_back(simcluster->eventId().bunchCrossing());
671 simcluster_ev_.push_back(simcluster->eventId().event());
673 simcluster_px_.push_back(simcluster->p4().x());
674 simcluster_py_.push_back(simcluster->p4().y());
675 simcluster_pz_.push_back(simcluster->p4().z());
677 for (
const auto& hf : simcluster->hits_and_fractions()) {
681 const auto& pos = getHitPosition(
id);
684 const float x = pos.x();
685 const float y = pos.y();
686 const float z = pos.z();
687 const float eta = pos.eta();
688 const float phi = pos.phi();
690 simhit_frac_.push_back(hf.second);
691 simhit_x_.push_back(x);
692 simhit_y_.push_back(y);
693 simhit_z_.push_back(z);
694 simhit_det_.push_back(
id.det());
695 simhit_subdet_.push_back(
id.subdetId());
696 simhit_eta_.push_back(eta);
697 simhit_phi_.push_back(phi);
698 simhit_idx_simcluster_.push_back(idx_simcluster);
699 simhit_detid_.push_back(
id.rawId());
700 detid_energy[
id.rawId()] += hf.second;
704 int simcluster_to_trackingparticle = -1;
705 for (
const auto& simtrack : simcluster->g4Tracks()) {
706 simtrack_x_.push_back(simtrack.trackerSurfacePosition().x());
707 simtrack_y_.push_back(simtrack.trackerSurfacePosition().y());
708 simtrack_z_.push_back(simtrack.trackerSurfacePosition().z());
709 simtrack_idx_simcluster_.push_back(idx_simcluster);
710 simtrack_pid_.push_back(simtrack.type());
712 for (
unsigned int itp = 0; itp < trackingParticles.
size(); itp++) {
713 const auto& simtrack2 = trackingParticles.
at(itp).g4Tracks().at(0);
715 if (simtrack.eventId() == simtrack2.eventId() && simtrack.trackId() == simtrack2.trackId()) {
716 simcluster_to_trackingparticle = itp;
723 simcluster_detids_.push_back(detid_energy);
724 simcluster_idx_trackingparticle_.push_back(simcluster_to_trackingparticle);
730 associateClusterToSimCluster(all_elements);
733 for (
unsigned int ielem = 0; ielem < all_elements.size(); ielem++) {
734 const auto& elem = all_elements.at(ielem);
735 const auto& orig = elem.orig;
740 float sigmadeltap = 0.0;
747 float trajpoint = 0.0;
748 float eta_ecal = 0.0;
749 float phi_ecal = 0.0;
750 float eta_hcal = 0.0;
751 float phi_hcal = 0.0;
755 float muon_dt_hits = 0.0;
756 float muon_csc_hits = 0.0;
759 const auto& matched_pftrack = orig.trackRefPF();
760 if (matched_pftrack.isNonnull()) {
763 if (atHCAL.isValid()) {
764 eta_hcal = atHCAL.positionREP().eta();
765 phi_hcal = atHCAL.positionREP().phi();
767 if (atECAL.isValid()) {
768 eta_ecal = atECAL.positionREP().eta();
769 phi_ecal = atECAL.positionREP().phi();
780 charge = ref->charge();
786 muon_dt_hits = standAloneMu->hitPattern().numberOfValidMuonDTHits();
787 muon_csc_hits = standAloneMu->hitPattern().numberOfValidMuonCSCHits();
793 const auto& ref = orig2->GsftrackRef();
794 if (ref.isNonnull()) {
795 deltap = orig2->DeltaP();
796 sigmadeltap = orig2->SigmaDeltaP();
804 trajpoint = orig2->indTrajPoint();
805 charge = ref->charge();
810 const auto& vec = orig2->Pin();
817 energy = vec.energy();
818 if (!orig2->GsftrackRefPF().isNull()) {
819 charge = orig2->GsftrackRefPF()->charge();
826 if (ref.isNonnull()) {
829 px = ref->position().x();
830 py = ref->position().y();
831 pz = ref->position().z();
832 energy = ref->energy();
833 layer = ref->layer();
834 depth = ref->depth();
838 if (clref.isNonnull()) {
841 px = clref->position().x();
842 py = clref->position().y();
843 pz = clref->position().z();
844 energy = clref->energy();
848 for (
const auto&
t : trackingparticle_to_element) {
849 if (
t.second == (
int)ielem) {
850 tps.push_back(
t.first);
854 for (
const auto&
t : simcluster_to_element) {
855 if (
t.second == (
int)ielem) {
856 scs.push_back(
t.first);
860 element_pt_.push_back(pt);
861 element_px_.push_back(px);
862 element_py_.push_back(py);
863 element_pz_.push_back(pz);
864 element_deltap_.push_back(deltap);
865 element_sigmadeltap_.push_back(sigmadeltap);
866 element_eta_.push_back(eta);
867 element_phi_.push_back(phi);
868 element_energy_.push_back(energy);
869 element_eta_ecal_.push_back(eta_ecal);
870 element_phi_ecal_.push_back(phi_ecal);
871 element_eta_hcal_.push_back(eta_hcal);
872 element_phi_hcal_.push_back(phi_hcal);
873 element_charge_.push_back(charge);
874 element_type_.push_back(type);
875 element_layer_.push_back(layer);
876 element_depth_.push_back(depth);
877 element_trajpoint_.push_back(trajpoint);
878 element_muon_dt_hits_.push_back(muon_dt_hits);
879 element_muon_csc_hits_.push_back(muon_csc_hits);
884 for (
const auto& cand : pfCandidates) {
885 pfcandidate_eta_.push_back(cand.eta());
886 pfcandidate_phi_.push_back(cand.phi());
887 pfcandidate_pt_.push_back(cand.pt());
888 pfcandidate_px_.push_back(cand.px());
889 pfcandidate_py_.push_back(cand.py());
890 pfcandidate_pz_.push_back(cand.pz());
891 pfcandidate_energy_.push_back(cand.energy());
892 pfcandidate_pdgid_.push_back(cand.pdgId());
894 for (
const auto& el : cand.elementsInBlocks()) {
895 const auto idx_block = el.first.
index();
896 unsigned idx_element_in_block = el.second;
899 for (
const auto& elem_with_index : all_elements) {
901 if (elem_with_index.idx_block == idx_block && elem_with_index.idx_elem == idx_element_in_block) {
906 element_to_candidate.push_back(make_pair(ielem, icandidate));
912 ev_event_ = iEvent.
id().
event();
914 ev_run_ = iEvent.
id().
run();
921 for (
unsigned long ntrackingparticle = 0; ntrackingparticle < trackingParticles.
size(); ntrackingparticle++) {
922 const auto&
tp = trackingParticles.
at(ntrackingparticle);
927 if (!
tp.decayVertices().empty()) {
928 vtx =
tp.decayVertices().at(0)->position();
930 auto orig_vtx =
tp.vertex();
933 trackingparticle_eta_.push_back(
tp.p4().eta());
934 trackingparticle_phi_.push_back(
tp.p4().phi());
935 trackingparticle_pt_.push_back(
tp.p4().pt());
936 trackingparticle_px_.push_back(
tp.p4().px());
937 trackingparticle_py_.push_back(
tp.p4().py());
938 trackingparticle_pz_.push_back(
tp.p4().pz());
939 trackingparticle_energy_.push_back(
tp.p4().energy());
940 trackingparticle_dvx_.push_back(vtx.x());
941 trackingparticle_dvy_.push_back(vtx.y());
942 trackingparticle_dvz_.push_back(vtx.z());
943 trackingparticle_bx_.push_back(
tp.eventId().bunchCrossing());
944 trackingparticle_ev_.push_back(
tp.eventId().event());
946 trackingparticle_ovx_.push_back(orig_vtx.x());
947 trackingparticle_ovy_.push_back(orig_vtx.y());
948 trackingparticle_ovz_.push_back(orig_vtx.z());
950 trackingparticle_pid_.push_back(
tp.pdgId());
956 int k = (n * (n - 1) / 2) - (n -
i) * ((n - i) - 1) / 2 + j - i - 1;
961 int i = n - 2 - floor(
sqrt(-8 * k + 4 * n * (n - 1) - 7) / 2.0 - 0.5);
962 int j = k + i + 1 - n * (n - 1) / 2 + (n - i) * ((n -
i) - 1) / 2;
963 return make_pair(i, j);
967 const std::vector<reco::PFBlock>& pfBlocks) {
968 vector<ElementWithIndex>
ret;
969 vector<tuple<int, int, float>> distances;
973 for (
const auto&
block : pfBlocks) {
975 const auto& linkdata =
block.linkData();
978 for (
const auto&
link : linkdata) {
979 const auto vecidx =
link.first;
980 const auto dist =
link.second.distance;
982 auto globalindex_i = ij.first + ret.size();
983 auto globalindex_j = ij.second + ret.size();
984 distances.push_back(make_tuple(globalindex_i, globalindex_j, dist));
987 for (
const auto& elem :
block.elements()) {
989 ret.push_back(elem_index);
994 return make_pair(ret, distances);
999 vector<map<uint64_t, double>> detids_elements;
1000 map<uint64_t, double> rechits_energy_all;
1002 int idx_element = 0;
1003 for (
const auto& elem : all_elements) {
1004 map<uint64_t, double> detids;
1005 const auto&
type = elem.orig.type();
1010 const auto& clref = elem.orig.clusterRef();
1011 assert(clref.isNonnull());
1012 const auto& cluster = *clref;
1015 const vector<reco::PFRecHitFraction>& rechit_fracs = cluster.recHitFractions();
1016 for (
const auto& rh : rechit_fracs) {
1018 if (detids.find(pfrh.
detId()) != detids.end()) {
1021 detids[pfrh.
detId()] += pfrh.
energy() * rh.fraction();
1029 const auto& pos = getHitPosition(
id);
1036 rechit_x_.push_back(x);
1037 rechit_y_.push_back(y);
1038 rechit_z_.push_back(z);
1039 rechit_det_.push_back(
id.det());
1040 rechit_subdet_.push_back(
id.subdetId());
1041 rechit_eta_.push_back(eta);
1042 rechit_phi_.push_back(phi);
1043 rechit_e_.push_back(pfrh.
energy() * rh.fraction());
1044 rechit_idx_element_.push_back(idx_element);
1045 rechit_detid_.push_back(
id.rawId());
1046 rechits_energy_all[
id.rawId()] += pfrh.
energy() * rh.fraction();
1050 assert(clref.isNonnull());
1051 const auto& cluster = *clref;
1054 const auto& rechit_fracs = cluster.hitsAndFractions();
1055 for (
const auto& rh : rechit_fracs) {
1056 if (detids.find(rh.first.rawId()) != detids.end()) {
1059 detids[rh.first.rawId()] += cluster.energy() * rh.second;
1060 const auto id = rh.first;
1067 const auto& pos = getHitPosition(
id);
1074 rechit_x_.push_back(x);
1075 rechit_y_.push_back(y);
1076 rechit_z_.push_back(z);
1077 rechit_det_.push_back(
id.det());
1078 rechit_subdet_.push_back(
id.subdetId());
1079 rechit_eta_.push_back(eta);
1080 rechit_phi_.push_back(phi);
1081 rechit_e_.push_back(rh.second);
1082 rechit_idx_element_.push_back(idx_element);
1083 rechit_detid_.push_back(
id.rawId());
1084 rechits_energy_all[
id.rawId()] += cluster.energy() * rh.second;
1087 detids_elements.push_back(detids);
1093 for (
const auto& detids : detids_elements) {
1094 int isimcluster = 0;
1095 if (!detids.empty()) {
1096 double sum_e_tot = 0.0;
1097 for (
const auto&
c : detids) {
1098 sum_e_tot +=
c.second;
1101 for (
const auto& simcluster_detids : simcluster_detids_) {
1102 double sum_e_tot_sc = 0.0;
1103 for (
const auto&
c : simcluster_detids) {
1104 sum_e_tot_sc +=
c.second;
1110 simcluster_to_element.push_back(make_pair(isimcluster, ielement));
1111 simcluster_to_element_cmp.push_back((
float)cmp);
1121 hcons = &es.
getData(hcalDDDrecToken_);
1122 aField_ = &es.
getData(magFieldToken_);
vector< int > element_charge_
static const std::string kSharedResource
vector< uint64_t > rechit_detid_
vector< float > pfcandidate_pz_
EventNumber_t event() const
vector< float > pfcandidate_px_
Abstract base class for a PFBlock element (track, cluster...)
T getUntrackedParameter(std::string const &, T const &) const
tuple ret
prodAgent to be discontinued
vector< int > simtrack_pid_
const edm::EventSetup & c
bool isNonnull() const
Checks for non-null.
vector< int > element_distance_j_
vector< float > element_pz_
vector< int > simcluster_ev_
vector< float > element_phi_
vector< float > gen_energy_
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
uint16_t *__restrict__ id
void endRun(edm::Run const &iEvent, edm::EventSetup const &) override
vector< int > simcluster_bx_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
unsigned detId() const
rechit detId
vector< float > simhit_phi_
vector< float > element_trajpoint_
vector< float > rechit_subdet_
#define DEFINE_FWK_MODULE(type)
vector< float > simcluster_px_
vector< float > rechit_e_
Global3DPoint GlobalPoint
vector< float > trackingparticle_phi_
vector< float > simcluster_eta_
vector< float > element_py_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned long long EventNumber_t
vector< float > element_eta_
ElementWithIndex(const reco::PFBlockElement &_orig, size_t _idx_block, size_t _idx_elem)
vector< int > gen_charge_
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
T * make(const Args &...args) const
make new ROOT object
auto const & tracks
cannot be loose
key_type key() const
Accessor for product key.
vector< int > simhit_idx_simcluster_
vector< int > simtrack_idx_simcluster_
vector< float > trackingparticle_eta_
vector< int > element_layer_
LuminosityBlockNumber_t luminosityBlock() const
unsigned int LuminosityBlockNumber_t
vector< float > rechit_det_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
vector< float > element_sigmadeltap_
vector< float > simcluster_py_
vector< float > trackingparticle_ovz_
vector< float > rechit_y_
const reco::PFBlockElement & orig
constexpr std::array< uint8_t, layerIndexSize > layer
void analyze(const edm::Event &, const edm::EventSetup &) override
bool getData(T &iHolder) const
virtual bool present(const DetId &id) const
is this detid present in the geometry?
MagneticField const * aField_
vector< int > trackingparticle_bx_
vector< float > element_pt_
vector< float > element_eta_ecal_
void addDefault(ParameterSetDescription const &psetDescription)
vector< float > simhit_z_
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
vector< int > trackingparticle_mother_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
vector< float > trackingparticle_exy_
edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticles_
vector< float > simtrack_x_
vector< float > trackingparticle_pt_
vector< float > simhit_y_
vector< float > trackingparticle_dvx_
vector< float > element_depth_
vector< float > simcluster_energy_
vector< int > find_element_ref(const vector< ElementWithIndex > &vec, const edm::RefToBase< reco::Track > &r)
vector< float > pfcandidate_phi_
edm::EDGetTokenT< edm::View< reco::Track > > tracks_
edm::EDGetTokenT< std::vector< reco::PFBlock > > pfBlocks_
vector< float > trackingparticle_ovy_
float energy() const
rechit energy
vector< vector< int > > gen_daughters_
vector< pair< int, int > > element_to_candidate
vector< float > pfcandidate_eta_
vector< float > trackingparticle_energy_
vector< float > trackingparticle_py_
vector< float > simcluster_phi_
vector< float > pfcandidate_pt_
vector< float > pfcandidate_py_
GlobalPoint getHitPosition(const DetId &id)
vector< int > element_distance_i_
vector< float > trackingparticle_exx_
vector< float > element_muon_csc_hits_
vector< float > rechit_phi_
vector< float > simhit_x_
vector< int > trackingparticle_pid_
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pfCandidates_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
vector< int > simcluster_pid_
vector< int > simhit_det_
vector< int > simhit_subdet_
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.
vector< float > element_energy_
ROOT::Math::Transform3D::Point Point
edm::EventNumber_t ev_event_
double detid_compare(const map< uint64_t, double > &rechits, const map< uint64_t, double > &simhits)
edm::LuminosityBlockNumber_t ev_lumi_
vector< float > element_px_
vector< float > element_deltap_
void processTrackingParticles(const edm::View< TrackingParticle > &trackingParticles, edm::Handle< edm::View< TrackingParticle >> &trackingParticlesHandle)
const HcalDDDRecConstants * hcons
edm::EDGetTokenT< edm::View< TrackingParticle > > trackingParticles_
vector< int > gen_status_
edm::EDGetTokenT< edm::View< CaloParticle > > caloParticles_
vector< float > element_phi_hcal_
vector< float > trackingparticle_dvz_
vector< int > trackingparticle_ev_
pair< int, int > get_triu_vector_index(int k, int n)
vector< int > element_type_
vector< std::map< uint64_t, double > > simcluster_detids_
edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > hcalDDDrecToken_
vector< float > simhit_frac_
const_reference at(size_type pos) const
vector< pair< int, int > > simcluster_to_element
vector< float > rechit_z_
vector< float > simcluster_pt_
vector< float > simcluster_pz_
vector< float > simtrack_y_
vector< int > pfcandidate_pdgid_
vector< float > pfcandidate_energy_
vector< float > rechit_x_
vector< float > trackingparticle_dvy_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
edm::EDGetTokenT< reco::RecoToSimCollection > tracks_recotosim_
vector< float > trackingparticle_px_
vector< float > simhit_eta_
vector< float > element_muon_dt_hits_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topologyToken_
vector< pair< int, int > > trackingparticle_to_element
vector< float > element_phi_ecal_
vector< float > trackingparticle_ovx_
pair< vector< ElementWithIndex >, vector< tuple< int, int, float > > > processBlocks(const std::vector< reco::PFBlock > &pfBlocks)
vector< float > simtrack_z_
vector< float > simcluster_to_element_cmp
vector< float > rechit_eta_
vector< float > trackingparticle_pz_
int get_index_triu_vector(int i, int j, int n)
vector< int > simcluster_idx_trackingparticle_
vector< int > simcluster_nhits_
vector< int > rechit_idx_element_
void associateClusterToSimCluster(const vector< ElementWithIndex > &all_elements)
vector< float > element_eta_hcal_
vector< uint64_t > simhit_detid_
vector< float > element_distance_d_