48 #include "Math/Transform3D.h"
73 : orig(_orig), idx_block(_idx_block), idx_elem(_idx_elem){};
77 for (
unsigned int i = 0;
i < vec.size();
i++) {
78 const auto& elem = vec.at(
i);
80 const auto& ref = elem.orig.trackRef();
82 if (ref.key() ==
r.key()) {
86 const auto& ref = elem.orig.trackRefPF();
87 if (ref.isNonnull()) {
88 const auto& ref2 = ref->trackRef();
90 if (ref2.key() ==
r.key()) {
100 const map<uint64_t, double>&
simhits,
101 const map<uint64_t, double>& rechits_energy,
105 for (
const auto& rh :
rechits) {
106 for (
const auto& sh :
simhits) {
107 if (rh.first == sh.first) {
109 ret += rechits_energy.at(rh.first) * sh.second;
132 void endJob()
override;
137 pair<vector<ElementWithIndex>, vector<tuple<int, int, float>>> processBlocks(
138 const std::vector<reco::PFBlock>& pfBlocks);
140 void associateClusterToSimCluster(
const vector<ElementWithIndex>& all_elements);
142 void clearVariables();
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"));
292 geometryToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>(
edm::ESInputTag{});
293 topologyToken_ = esConsumes<HcalTopology, HcalRecNumberingRecord>(
edm::ESInputTag{});
297 fs->
make<TH1F>(
"total",
"total", 100, 0, 5.);
299 t_ = fs->
make<TTree>(
"pftree",
"pftree");
302 t_->Branch(
"event", &ev_event_);
303 t_->Branch(
"lumi", &ev_lumi_);
304 t_->Branch(
"run", &ev_run_);
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_);
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_);
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_);
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_);
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_);
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_);
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_);
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_);
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_);
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);
419 trackingparticle_to_element.clear();
420 simcluster_to_element.clear();
421 simcluster_to_element_cmp.clear();
422 element_to_candidate.clear();
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();
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();
458 simhit_frac_.clear();
463 simhit_subdet_.clear();
466 simhit_idx_simcluster_.clear();
467 simhit_detid_.clear();
474 rechit_subdet_.clear();
477 rechit_idx_element_.clear();
478 rechit_detid_.clear();
483 simtrack_idx_simcluster_.clear();
484 simtrack_pid_.clear();
496 gen_daughters_.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();
515 element_distance_i_.clear();
516 element_distance_j_.clear();
517 element_distance_d_.clear();
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();
533 bool present =
false;
539 present = geom_sd->
present(
id);
551 auto& pG = iSetup.
getData(geometryToken_);
553 auto&
pT = iSetup.
getData(topologyToken_);
558 iEvent.getByToken(trackingParticles_, trackingParticlesHandle);
562 iEvent.getByToken(caloParticles_, caloParticlesHandle);
567 iEvent.getByToken(tracks_recotosim_, recotosimCollection);
568 const auto recotosim = *recotosimCollection;
571 iEvent.getByToken(tracks_, trackHandle);
575 iEvent.getByToken(genParticles_, genParticlesHandle);
576 for (std::vector<reco::GenParticle>::const_iterator it_p = genParticlesHandle->begin();
577 it_p != genParticlesHandle->end();
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());
597 iEvent.getByToken(pfCandidates_, pfCandidatesHandle);
598 std::vector<reco::PFCandidate>
pfCandidates = *pfCandidatesHandle;
601 iEvent.getByToken(pfBlocks_, pfBlocksHandle);
602 std::vector<reco::PFBlock> pfBlocks = *pfBlocksHandle;
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());
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));
624 if (idx_in_all_elements == -1) {
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));
643 int idx_simcluster = 0;
645 for (
unsigned long ncaloparticle = 0; ncaloparticle <
caloParticles.size(); ncaloparticle++) {
650 for (
const auto& simcluster :
cp.simClusters()) {
652 map<uint64_t, double> detid_energy;
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());
663 simcluster_px_.push_back(simcluster->p4().x());
664 simcluster_py_.push_back(simcluster->p4().y());
665 simcluster_pz_.push_back(simcluster->p4().z());
667 for (
const auto&
hf : simcluster->hits_and_fractions()) {
671 const auto&
pos = getHitPosition(
id);
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();
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;
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());
706 if (simtrack.eventId() == simtrack2.eventId() && simtrack.trackId() == simtrack2.trackId()) {
707 simcluster_to_trackingparticle = itp;
714 simcluster_detids_.push_back(detid_energy);
715 simcluster_idx_trackingparticle_.push_back(simcluster_to_trackingparticle);
721 associateClusterToSimCluster(all_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;
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;
746 const auto& matched_pftrack = orig.trackRefPF();
747 if (matched_pftrack.isNonnull()) {
750 if (atHCAL.isValid()) {
751 eta_hcal = atHCAL.positionREP().eta();
752 phi_hcal = atHCAL.positionREP().phi();
754 if (atECAL.isValid()) {
755 eta_ecal = atECAL.positionREP().eta();
756 phi_ecal = atECAL.positionREP().phi();
766 energy = ref->pt() * cosh(ref->eta());
771 const auto& ref = orig2->GsftrackRef();
772 if (ref.isNonnull()) {
779 energy = ref->pt() * cosh(ref->eta());
780 trajpoint = orig2->indTrajPoint();
786 const auto& ref = orig2->GsftrackRef();
787 if (ref.isNonnull()) {
794 energy = ref->pt() * cosh(ref->eta());
801 if (ref.isNonnull()) {
804 px = ref->position().x();
805 py = ref->position().y();
806 pz = ref->position().z();
808 layer = ref->layer();
809 depth = ref->depth();
813 if (clref.isNonnull()) {
816 px = clref->position().x();
817 py = clref->position().y();
818 pz = clref->position().z();
823 for (
const auto&
t : trackingparticle_to_element) {
824 if (
t.second == (
int)ielem) {
825 tps.push_back(
t.first);
829 for (
const auto&
t : simcluster_to_element) {
830 if (
t.second == (
int)ielem) {
831 scs.push_back(
t.first);
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);
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());
865 for (
const auto& el :
cand.elementsInBlocks()) {
866 const auto idx_block = el.first.index();
867 unsigned idx_element_in_block = el.second;
870 for (
const auto& elem_with_index : all_elements) {
872 if (elem_with_index.idx_block == idx_block && elem_with_index.idx_elem == idx_element_in_block) {
877 element_to_candidate.push_back(make_pair(ielem, icandidate));
884 cout <<
"all_elements=" << all_elements.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;
890 ev_event_ =
iEvent.id().event();
891 ev_lumi_ =
iEvent.id().luminosityBlock();
892 ev_run_ =
iEvent.id().run();
899 for (
unsigned long ntrackingparticle = 0; ntrackingparticle <
trackingParticles.size(); ntrackingparticle++) {
905 if (!
tp.decayVertices().empty()) {
906 vtx =
tp.decayVertices().at(0)->position();
908 auto orig_vtx =
tp.vertex();
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());
924 trackingparticle_ovx_.push_back(orig_vtx.x());
925 trackingparticle_ovy_.push_back(orig_vtx.y());
926 trackingparticle_ovz_.push_back(orig_vtx.z());
928 trackingparticle_pid_.push_back(
tp.pdgId());
934 int k = (
n * (
n - 1) / 2) - (
n -
i) * ((
n -
i) - 1) / 2 +
j -
i - 1;
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);
945 const std::vector<reco::PFBlock>& pfBlocks) {
946 vector<ElementWithIndex>
ret;
947 vector<tuple<int, int, float>> distances;
951 for (
const auto&
block : pfBlocks) {
953 const auto& linkdata =
block.linkData();
956 for (
const auto&
link : linkdata) {
957 const auto vecidx =
link.first;
958 const auto dist =
link.second.distance;
960 cout <<
"block " << iblock <<
" " << ielem <<
" " << vecidx <<
" " << ij.first <<
" " << ij.second <<
" " << dist
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));
967 for (
const auto& elem :
block.elements()) {
969 ret.push_back(elem_index);
974 return make_pair(
ret, distances);
979 vector<map<uint64_t, double>> detids_elements;
980 map<uint64_t, double> rechits_energy_all;
983 for (
const auto& elem : all_elements) {
984 map<uint64_t, double> detids;
985 const auto&
type = elem.orig.type();
990 const auto& clref = elem.orig.clusterRef();
991 assert(clref.isNonnull());
992 const auto& cluster = *clref;
995 const vector<reco::PFRecHitFraction>& rechit_fracs = cluster.recHitFractions();
996 for (
const auto& rh : rechit_fracs) {
998 if (detids.find(pfrh.
detId()) != detids.end()) {
1009 const auto&
pos = getHitPosition(
id);
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();
1030 assert(clref.isNonnull());
1031 const auto& cluster = *clref;
1034 const auto& rechit_fracs = cluster.hitsAndFractions();
1035 for (
const auto& rh : rechit_fracs) {
1036 if (detids.find(rh.first.rawId()) != detids.end()) {
1039 detids[rh.first.rawId()] += rh.second;
1040 const auto id = rh.first;
1047 const auto&
pos = getHitPosition(
id);
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;
1067 detids_elements.push_back(detids);
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;
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;
1088 double cmp =
detid_compare(detids, simcluster_detids, rechits_energy_all,
false);
1090 simcluster_to_element.push_back(make_pair(isimcluster, ielement));
1091 simcluster_to_element_cmp.push_back((
float)
cmp);
1108 aField_ = &(*magfield);