31 #include "combination.hpp" 37 #define docast(x, y) dynamic_cast<x>(y) 38 #define LOGVERB(x) edm::LogVerbatim(x) 39 #define LOGWARN(x) edm::LogWarning(x) 40 #define LOGERR(x) edm::LogError(x) 41 #define LOGDRESSED(x) edm::LogInfo(x) 43 #define docast(x, y) static_cast<x>(y) 44 #define LOGVERB(x) LogTrace(x) 45 #define LOGWARN(x) edm::LogWarning(x) 46 #define LOGERR(x) edm::LogError(x) 47 #define LOGDRESSED(x) LogDebug(x) 57 typedef std::pair<CaloClusterPtr::key_type, CaloClusterPtr> EEtoPSElement;
60 class SeedMatchesToProtoObject {
65 if (scfromseed_.isNonnull()) {
71 if (scfromseed_.isNull() || !po.
parentSC)
84 template <
bool useConvs = false>
90 const float EoPin_cut = 1.0e6) {
92 auto elemkey = &(
block->elements()[
key]);
94 switch (elemkey->type()) {
98 const ClusterElement* elemasclus =
static_cast<const ClusterElement*
>(&(
block->elements()[
test]));
99 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
100 float trk_pin = elemasgsf->
Pin().P();
101 if (cluster_e / trk_pin > EoPin_cut) {
102 LOGDRESSED(
"elementNotCloserToOther") <<
"GSF track failed EoP cut to match with cluster!";
110 const ClusterElement* elemasclus =
static_cast<const ClusterElement*
>(&(
block->elements()[
test]));
111 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
113 if (cluster_e / trk_pin > EoPin_cut) {
114 LOGDRESSED(
"elementNotCloserToOther") <<
"KF track failed EoP cut to match with cluster!";
126 std::multimap<double, unsigned> dists_to_val;
129 for (
const auto& valdist : dists_to_val) {
130 const size_t idx = valdist.second;
136 if (!useConvs && elemasgsf->
trackType(ConvType))
139 const ClusterElement* elemasclus =
docast(
const ClusterElement*, &(
block->elements()[
test]));
140 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
141 float trk_pin = elemasgsf->
Pin().P();
142 if (cluster_e / trk_pin > EoPin_cut)
149 if (!useConvs && elemaskf->
trackType(ConvType))
152 const ClusterElement* elemasclus =
static_cast<const ClusterElement*
>(&(
block->elements()[
test]));
153 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
155 if (cluster_e / trk_pin > EoPin_cut)
162 if (valdist.first < dist &&
idx !=
key) {
164 <<
"key element of type " << keytype <<
" is closer to another element of type" << valtype << std::endl;
171 template <
class Element1,
class Element2>
172 bool compatibleEoPOut(
const Element1&
e,
const Element2&
comp) {
176 const ClusterElement& elemascluster =
docast(ClusterElement
const&,
e);
177 const float gsf_eta_diff =
std::abs(
comp.positionAtECALEntrance().eta() -
comp.Pout().eta());
179 return (gsf_eta_diff <= 0.3 && cRef->
energy() /
comp.Pout().t() <= 5);
184 template <PFBlockElement::Type keytype, PFBlockElement::Type valtype,
bool useConv = false>
186 struct NotCloserToOther {
189 const float EoPin_cut;
193 bool operator()(
const T&
e) {
194 if (!
e.flag() || valtype !=
e->type())
196 return elementNotCloserToOther<useConv>(
block, keytype,
comp->index(), valtype,
e->index(), EoPin_cut);
200 struct LesserByDistance {
210 dist1 = (dist1 == -1.0 ? 1e6 : dist1);
211 dist2 = (dist2 == -1.0 ? 1e6 : dist2);
212 return dist1 < dist2;
220 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"cannot merge, both have GSFs!" << std::endl;
226 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"cannot merge, different ECAL types!" << std::endl;
235 not_closer = elementNotCloserToOther(blk, cluster->type(), cluster->
index(), primgsf->type(), primgsf->index());
237 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"merged by cluster to primary GSF" << std::endl;
240 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"cluster to primary GSF failed since" 241 <<
" cluster closer to another GSF" << std::endl;
245 not_closer = elementNotCloserToOther(blk, cluster->type(), cluster->
index(), primkf->type(), primkf->index());
247 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"merged by cluster to primary KF" << std::endl;
252 not_closer = elementNotCloserToOther(blk, cluster->type(), cluster->
index(), secdkf->type(), secdkf->index());
254 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"merged by cluster to secondary KF" << std::endl;
259 for (
const auto& brem : RO2.
brems) {
260 not_closer = elementNotCloserToOther(blk, cluster->type(), cluster->
index(), brem->type(), brem->index());
262 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"merged by cluster to brem KF" << std::endl;
270 not_closer = elementNotCloserToOther(blk, primgsf->type(), primgsf->
index(), secdkf->type(), secdkf->index());
272 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"merged by GSF to secondary KF" << std::endl;
280 not_closer = elementNotCloserToOther(blk, primkf->type(), primkf->
index(), secdkf->type(), secdkf->index());
282 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"merged by primary KF to secondary KF" << std::endl;
291 elementNotCloserToOther<true>(blk, secdkf1->type(), secdkf1->
index(), secdkf2->type(), secdkf2->index());
293 LOGDRESSED(
"isROLinkedByClusterOrTrack") <<
"merged by secondary KF to secondary KF" << std::endl;
302 const bool result = (isROLinkedByClusterOrTrack(
comp, ro) || isROLinkedByClusterOrTrack(ro,
comp));
306 std::vector<const ClusterElement*> getSCAssociatedECALsSafe(
308 std::vector<const ClusterElement*> cluster_list;
309 auto sccl = scref->clustersBegin();
310 auto scend = scref->clustersEnd();
311 auto pfc = ecals.begin();
312 auto pfcend = ecals.end();
313 for (; sccl != scend; ++sccl) {
314 std::vector<const ClusterElement*> matched_pfcs;
315 const double eg_energy = (*sccl)->energy();
317 for (pfc = ecals.begin(); pfc != pfcend; ++pfc) {
318 const ClusterElement* pfcel =
docast(
const ClusterElement*, pfc->get());
322 if (
matched && pfcel->clusterRef()->energy() < 1.2 * scref->energy()) {
323 matched_pfcs.push_back(pfcel);
326 std::sort(matched_pfcs.begin(), matched_pfcs.end());
328 double min_residual = 1e6;
329 std::vector<const ClusterElement*> best_comb;
330 for (
size_t i = 1;
i <= matched_pfcs.size(); ++
i) {
335 double energy = std::accumulate(
336 matched_pfcs.begin(), matched_pfcs.begin() +
i, 0.0, [](
const double a,
const ClusterElement*
c) {
337 return a +
c->clusterRef()->energy();
340 if (resid < min_residual) {
342 best_comb.reserve(
i);
343 min_residual = resid;
344 best_comb.insert(best_comb.begin(), matched_pfcs.begin(), matched_pfcs.begin() +
i);
348 for (
const auto& clelem : best_comb) {
349 if (
std::find(cluster_list.begin(), cluster_list.end(), clelem) == cluster_list.end()) {
350 cluster_list.push_back(clelem);
363 if (clayer == blayer) {
381 *gsfCluster_noassc =
nullptr;
383 int nBremClusters = 0;
389 elementNotCloserToOther(
parent,
gsf->type(),
gsf->index(), cluster->type(), cluster->index());
390 const float deta =
std::abs(cluster->clusterRef()->positionREP().eta() -
gsf->positionAtECALEntrance().eta());
392 TVector2::Phi_mpi_pi(cluster->clusterRef()->positionREP().phi() -
gsf->positionAtECALEntrance().phi()));
394 if (hasclu && dist < mDist_gsf) {
395 gsfCluster = cluster.get();
397 }
else if (dist < mDist_gsf_noassc) {
398 gsfCluster_noassc = cluster.get();
399 mDist_gsf_noassc = dist;
403 const bool hasclu = elementNotCloserToOther(
parent, kf->type(), kf->index(), cluster->type(), cluster->index());
405 if (hasclu && dist < mDist_kf) {
406 kfCluster = cluster.get();
410 for (
const auto& brem : RO.
brems) {
412 elementNotCloserToOther(
parent, brem->type(), brem->index(), cluster->type(), cluster->index());
415 if (!firstBrem || (firstBrem->
indTrajPoint() - 2 > brem->indTrajPoint() - 2)) {
418 if (!lastBrem || (lastBrem->indTrajPoint() - 2 < brem->indTrajPoint() - 2)) {
420 bremCluster = cluster.get();
425 if (!gsfCluster && !kfCluster && !bremCluster) {
426 gsfCluster = gsfCluster_noassc;
432 }
else if (kfCluster) {
435 if (bremCluster && !gsfCluster && !kfCluster) {
440 if (bremCluster == gsfCluster)
452 : gbrForests_(gbrForests),
456 channelStatus_(channelStatus) {
462 unsigned int trackIndex) {
468 const float chi2 =
elements[trackIndex].trackRef()->chi2() /
elements[trackIndex].trackRef()->ndof();
469 const float nlost =
elements[trackIndex].trackRef()->missingInnerHits();
470 const float nLayers =
elements[trackIndex].trackRef()->hitPattern().trackerLayersWithMeasurement();
472 const float stip =
elements[trackIndex].trackRefPF()->STIP();
476 std::multimap<double, unsigned int> ecalAssoTrack;
477 block.associatedElements(
479 std::multimap<double, unsigned int> hcalAssoTrack;
480 block.associatedElements(
482 if (!ecalAssoTrack.empty()) {
483 for (
auto& itecal : ecalAssoTrack) {
484 linkedE = linkedE +
elements[itecal.second].clusterRef()->energy();
487 if (!hcalAssoTrack.empty()) {
488 for (
auto& ithcal : hcalAssoTrack) {
489 linkedH = linkedH +
elements[ithcal.second].clusterRef()->energy();
492 const float eOverPt = linkedE /
elements[trackIndex].trackRef()->pt();
493 const float hOverPt = linkedH /
elements[trackIndex].trackRef()->pt();
495 elements[trackIndex].trackRef()->innerPosition().Y() - primaryVtx.
y(),
496 elements[trackIndex].trackRef()->innerPosition().Z() - primaryVtx.
z());
497 double vtxPhi = rvtx.
phi();
507 switch (pfbe.
type()) {
510 std::multimap<double, unsigned> tks;
513 for (
const auto& tk : tks) {
529 LOGVERB(
"PFEGammaAlgo") <<
"Resetting PFEGammaAlgo for new block and running!" << std::endl;
537 std::list<ProtoEGObject> refinableObjects;
545 LOGVERB(
"PFEGammaAlgo") <<
"Splaying block" << std::endl;
552 const size_t itype = (size_t)pfelement.type();
560 std::stringstream splayout;
561 for (
size_t itype = 0; itype <
_splayedblock.size(); ++itype) {
562 splayout <<
"\tType: " << itype <<
" indices: ";
564 splayout << flaggedelement->index() <<
' ';
567 splayout << std::endl;
569 LOGVERB(
"PFEGammaAlgo") << splayout.str();
577 LOGDRESSED(
"PFEGammaAlgo") <<
"Initialized " << refinableObjects.size() <<
" proto-EGamma objects" << std::endl;
588 for (
auto& RO : refinableObjects) {
603 LOGDRESSED(
"PFEGammaAlgo") <<
"Dumping after GSF and KF Track (Primary) Linking : " << std::endl;
609 LOGDRESSED(
"PFEGammaAlgo") <<
"Dumping after first merging operation : " << std::endl;
615 for (
auto& RO : refinableObjects) {
625 LOGDRESSED(
"PFEGammaAlgo") <<
"Dumping after ECAL to Track (Secondary) Linking : " << std::endl;
631 LOGDRESSED(
"PFEGammaAlgo") <<
"There are " << refinableObjects.size() <<
" after the 2nd merging step." << std::endl;
635 for (
auto& RO : refinableObjects) {
642 std::sort(RO.ecalclusters.begin(), RO.ecalclusters.end(), [](
auto const&
a,
auto const&
b) {
643 return (
a->clusterRef()->correctedEnergy() >
b->clusterRef()->correctedEnergy());
645 setROElectronCluster(RO);
648 LOGDRESSED(
"PFEGammaAlgo") <<
"There are " << refinableObjects.size() <<
" after the unlinking and vetos step." 661 LOGDRESSED(
"PFEGammaAlgo") <<
"creating SC-based proto-object" << std::endl
662 <<
"\tSC at index: " << element->index() <<
" has type: " << element->type()
664 element.setFlag(
false);
687 egobjs.insert(egobjs.end(), fromSC);
695 LOGDRESSED(
"PFEGammaAlgo") <<
"creating GSF-based proto-object" << std::endl
696 <<
"\tGSF at index: " << element->index() <<
" has type: " << element->type()
702 element.setFlag(
false);
715 std::stringstream gsf_err;
716 elementAsGSF->
Dump(gsf_err,
"\t");
718 <<
"Found a GSF track with no seed! This should not happen!" << std::endl
719 << gsf_err.str() << std::endl;
723 element.setFlag(
false);
730 if (dist == 0.001
f) {
732 fromGSF.
brems.push_back(eAsBrem);
743 LOGDRESSED(
"PFEGammaAlgo") <<
"GSF-based proto-object is ECAL driven, merging SC-cand" << std::endl;
747 SeedMatchesToProtoObject sctoseedmatch(fromGSF.
electronSeed);
748 auto objsbegin = egobjs.begin();
749 auto objsend = egobjs.end();
751 auto clusmatch = std::find_if(objsbegin, objsend, sctoseedmatch);
752 if (clusmatch != objsend) {
753 fromGSF.
parentSC = clusmatch->parentSC;
756 egobjs.erase(clusmatch);
761 LOGDRESSED(
"PFEGammaAlgo") <<
"Encountered the known GSF-SC splitting bug " 762 <<
" in PFBlockAlgo! We should really fix this!" << std::endl;
764 std::stringstream gsf_err;
765 elementAsGSF->
Dump(gsf_err,
"\t");
767 <<
"Expected SuperCluster from ECAL driven GSF seed " 768 <<
"was not found in the block!" << std::endl
769 << gsf_err.str() << std::endl;
773 egobjs.insert(egobjs.end(), fromGSF);
780 ecalclusters.clear();
782 LOGVERB(
"PFEGammaAlgo") <<
"Pointer to SC element: 0x" << std::hex << thesc <<
std::dec << std::endl
783 <<
"cleared ecalclusters and ecal2ps!" << std::endl;
788 if (ecalbegin == ecalend && hgcalbegin == hgcalend) {
789 LOGERR(
"PFEGammaAlgo::unwrapSuperCluster()") <<
"There are no ECAL elements in a block with imported SC!" 790 <<
" This is a bug we should fix this!" << std::endl;
797 <<
"SuperCluster pointed to by block element is null!" << std::endl;
799 LOGDRESSED(
"PFEGammaAlgo") <<
"Got a valid super cluster ref! 0x" << std::hex << scref.
get() <<
std::dec << std::endl;
800 const size_t nscclusters = scref->clustersSize();
801 const size_t nscpsclusters = scref->preshowerClustersSize();
802 size_t npfpsclusters = 0;
803 size_t npfclusters = 0;
804 LOGDRESSED(
"PFEGammaAlgo") <<
"Precalculated cluster multiplicities: " << nscclusters <<
' ' << nscpsclusters
806 NotCloserToOther<reco::PFBlockElement::SC, reco::PFBlockElement::ECAL> ecalClustersInSC(
_currentblock, thesc);
807 NotCloserToOther<reco::PFBlockElement::SC, reco::PFBlockElement::HGCAL> hgcalClustersInSC(
_currentblock, thesc);
808 auto ecalfirstnotinsc =
std::partition(ecalbegin, ecalend, ecalClustersInSC);
809 auto hgcalfirstnotinsc =
std::partition(hgcalbegin, hgcalend, hgcalClustersInSC);
819 std::vector<const ClusterElement*> safePFClusters =
820 is_pf_sc ? std::vector<const ClusterElement*>()
823 if (ecalfirstnotinsc == ecalbegin && hgcalfirstnotinsc == hgcalbegin) {
824 LOGERR(
"PFEGammaAlgo::unwrapSuperCluster()") <<
"No associated block elements to SuperCluster!" 825 <<
" This is a bug we should fix!" << std::endl;
831 if (is_pf_sc && nscclusters != npfclusters) {
832 std::stringstream sc_err;
833 thesc->
Dump(sc_err,
"\t");
835 <<
"The number of found ecal elements (" << nscclusters <<
") in block is not the same as" 836 <<
" the number of ecal PF clusters reported by the PFSuperCluster" 837 <<
" itself (" << npfclusters <<
")! This should not happen!" << std::endl
838 << sc_err.str() << std::endl;
840 for (
auto ecalitr = ecalbegin; ecalitr != ecalfirstnotinsc; ++ecalitr) {
845 if (!is_pf_sc &&
std::find(safePFClusters.begin(), safePFClusters.end(), elemascluster) == safePFClusters.end())
849 ecalclusters.emplace_back(elemascluster,
true);
851 ecalitr->setFlag(
false);
855 auto emplaceresult = ecal2ps.emplace(elemascluster, ClusterMap::mapped_type());
856 if (!emplaceresult.second) {
857 std::stringstream clus_err;
858 elemascluster->
Dump(clus_err,
"\t");
860 <<
"List of pointers to ECAL block elements contains non-unique items!" 861 <<
" This is very bad!" << std::endl
862 <<
"cluster ptr = 0x" << std::hex << elemascluster <<
std::dec << std::endl
863 << clus_err.str() << std::endl;
865 ClusterMap::mapped_type& eslist = emplaceresult.first->second;
869 for (
auto hgcalitr = hgcalbegin; hgcalitr != hgcalfirstnotinsc; ++hgcalitr) {
874 if (!is_pf_sc &&
std::find(safePFClusters.begin(), safePFClusters.end(), elemascluster) == safePFClusters.end())
878 ecalclusters.emplace_back(elemascluster,
true);
880 hgcalitr->setFlag(
false);
897 LOGDRESSED(
"PFEGammaAlgo") <<
" Unwrapped SC has " << npfclusters <<
" ECAL sub-clusters" 898 <<
" and " << npfpsclusters <<
" PreShower layers 1 & 2 clusters!" << std::endl;
906 EEtoPSElement ecalkey(clusptr.
key(), clusptr);
908 std::equal_range(
eetops_.cbegin(),
eetops_.cend(), ecalkey, [](
const EEtoPSElement&
a,
const EEtoPSElement&
b) {
909 return a.first <
b.first;
913 for (
auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl) {
914 if (pscl->second ==
temp) {
915 const ClusterElement* pstemp =
docast(
const ClusterElement*, ps1.get());
916 eslist.emplace_back(pstemp);
922 for (
auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl) {
923 if (pscl->second ==
temp) {
924 const ClusterElement* pstemp =
docast(
const ClusterElement*, ps2.get());
925 eslist.emplace_back(pstemp);
929 return eslist.size();
936 <<
"Dumping " << refinableObjects.size() <<
" refinable objects for this block: " << std::endl;
937 for (
const auto& ro : refinableObjects) {
938 std::stringstream
info;
939 info <<
"Refinable Object:" << std::endl;
941 info <<
"\tSuperCluster element attached to object:" << std::endl <<
'\t';
942 ro.parentSC->Dump(
info,
"\t");
945 if (ro.electronSeed.isNonnull()) {
946 info <<
"\tGSF element attached to object:" << std::endl;
947 ro.primaryGSFs.front()->Dump(
info,
"\t");
949 info <<
"firstBrem : " << ro.firstBrem <<
" lateBrem : " << ro.lateBrem
950 <<
" nBrems with cluster : " << ro.nBremsWithClusters << std::endl;
952 if (ro.electronClusters.size() && ro.electronClusters[0]) {
953 info <<
"electron cluster : ";
954 ro.electronClusters[0]->Dump(
info,
"\t");
957 info <<
" no electron cluster." << std::endl;
960 if (ro.primaryKFs.size()) {
961 info <<
"\tPrimary KF tracks attached to object: " << std::endl;
962 for (
const auto& kf : ro.primaryKFs) {
963 kf->Dump(
info,
"\t");
967 if (ro.secondaryKFs.size()) {
968 info <<
"\tSecondary KF tracks attached to object: " << std::endl;
969 for (
const auto& kf : ro.secondaryKFs) {
970 kf->Dump(
info,
"\t");
974 if (ro.brems.size()) {
975 info <<
"\tBrem tangents attached to object: " << std::endl;
976 for (
const auto& brem : ro.brems) {
977 brem->Dump(
info,
"\t");
981 if (ro.ecalclusters.size()) {
982 info <<
"\tECAL clusters attached to object: " << std::endl;
983 for (
const auto& clus : ro.ecalclusters) {
984 clus->Dump(
info,
"\t");
986 if (ro.ecal2ps.find(clus) != ro.ecal2ps.end()) {
987 for (
const auto& psclus : ro.ecal2ps.at(clus)) {
988 info <<
"\t\t Attached PS Cluster: ";
989 psclus->Dump(
info,
"");
1002 typedef std::multimap<double, unsigned> MatchedMap;
1006 MatchedMap matchedGSFs, matchedECALs;
1007 std::unordered_map<GsfTrackElementPtr, MatchedMap> gsf_ecal_cache;
1009 matchedGSFs.clear();
1012 if (matchedGSFs.empty()) {
1016 std::partial_sort(ecalbegin, ecalbegin + 1, ecalend, closestTrackToECAL);
1024 if (dist_sc != -1.0
f) {
1030 if (dist != -1.0
f && closestECAL.flag()) {
1031 bool gsflinked =
false;
1039 if (!gsf_ecal_cache.count(elemasgsf)) {
1040 matchedECALs.clear();
1046 gsf_ecal_cache.emplace(elemasgsf, matchedECALs);
1047 MatchedMap().swap(matchedECALs);
1049 const MatchedMap& ecal_matches = gsf_ecal_cache[elemasgsf];
1050 if (!ecal_matches.empty()) {
1051 if (ecal_matches.begin()->second == closestECAL->index()) {
1057 if (!gsflinked && !inSC) {
1062 const int nexhits = trackref->missingInnerHits();
1063 bool fromprimaryvertex =
false;
1066 fromprimaryvertex =
true;
1073 nexhits == 0 && fromprimaryvertex) {
1074 closestECAL.setFlag(
false);
1085 bool check_for_merge =
true;
1086 while (check_for_merge) {
1091 for (
auto it1 = ROs.begin(); it1 != ROs.end(); ++it1) {
1092 auto find_start = it1;
1094 auto has_merge = std::find_if(find_start, ROs.end(), std::bind(testIfROMergableByLink, _1, *it1));
1095 if (has_merge != ROs.end() && it1 != ROs.begin()) {
1101 auto mergestart = ROs.begin();
1103 auto nomerge =
std::partition(mergestart, ROs.end(), std::bind(testIfROMergableByLink, _1, thefront));
1104 if (nomerge != mergestart) {
1105 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink()")
1106 <<
"Found objects " <<
std::distance(mergestart, nomerge) <<
" to merge by links to the front!" << std::endl;
1107 for (
auto roToMerge = mergestart; roToMerge != nomerge; ++roToMerge) {
1110 if (!thefront.
ecalclusters.empty() && !roToMerge->ecalclusters.empty()) {
1111 if (thefront.
ecalclusters.front()->clusterRef()->layer() !=
1112 roToMerge->ecalclusters.front()->clusterRef()->layer()) {
1113 LOGWARN(
"PFEGammaAlgo::mergeROsByAnyLink") <<
"Tried to merge EB and EE clusters! Skipping!";
1114 ROs.push_back(*roToMerge);
1120 thefront.
ecalclusters.end(), roToMerge->ecalclusters.begin(), roToMerge->ecalclusters.end());
1121 thefront.
ecal2ps.insert(roToMerge->ecal2ps.begin(), roToMerge->ecal2ps.end());
1123 thefront.
secondaryKFs.end(), roToMerge->secondaryKFs.begin(), roToMerge->secondaryKFs.end());
1127 if (!thefront.
parentSC && roToMerge->parentSC) {
1128 thefront.
parentSC = roToMerge->parentSC;
1133 thefront.
primaryGSFs.end(), roToMerge->primaryGSFs.begin(), roToMerge->primaryGSFs.end());
1135 thefront.
primaryKFs.end(), roToMerge->primaryKFs.begin(), roToMerge->primaryKFs.end());
1136 thefront.
brems.insert(thefront.
brems.end(), roToMerge->brems.begin(), roToMerge->brems.end());
1139 thefront.
firstBrem = roToMerge->firstBrem;
1140 thefront.
lateBrem = roToMerge->lateBrem;
1142 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink")
1143 <<
"Need to implement proper merging of two gsf candidates!" << std::endl;
1146 ROs.erase(mergestart, nomerge);
1148 ROs.push_back(ROs.front());
1151 check_for_merge =
false;
1154 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink()")
1155 <<
"After merging by links there are: " << ROs.size() <<
" refinable EGamma objects!" << std::endl;
1173 NotCloserToOther<reco::PFBlockElement::GSF, reco::PFBlockElement::TRACK> gsfTrackToKFs(
_currentblock, seedtk);
1177 for (
auto kft = KFbegin; kft != notlinked; ++kft) {
1182 kft->setFlag(
false);
1185 }
else if (elemaskf->
trackType(convType)) {
1186 kft->setFlag(
false);
1202 if (primkf->trackType(convType)) {
1203 throw cms::Exception(
"PFEGammaAlgo::linkRefinableObjectPrimaryKFsToSecondaryKFs()")
1204 <<
"A KF track from conversion has been assigned as a primary!!" << std::endl;
1206 NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::TRACK, true> kfTrackToKFs(
_currentblock,
1211 for (
auto kft = KFbegin; kft != notlinked; ++kft) {
1216 kft->setFlag(
false);
1233 NotCloserToOther<reco::PFBlockElement::GSF, reco::PFBlockElement::ECAL> gsfTracksToECALs(
_currentblock, primgsf);
1235 auto notmatched_blk =
std::partition(ECALbegin, ECALend, gsfTracksToECALs);
1237 std::partition(ECALbegin, notmatched_blk, [&primgsf](
auto const&
x) {
return compatibleEoPOut(*
x, *primgsf); });
1241 RO.
ecalclusters.begin(), notmatched_sc, [&primgsf](
auto const&
x) {
return compatibleEoPOut(*
x, *primgsf); });
1246 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()") <<
"Found a cluster already in RO by GSF extrapolation" 1247 <<
" at ECAL surface!" << std::endl
1248 << *elemascluster << std::endl;
1253 for (
auto ecal = ECALbegin;
ecal != notmatched_blk; ++
ecal) {
1255 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()") <<
"Found a cluster not already in RO by GSF extrapolation" 1256 <<
" at ECAL surface!" << std::endl
1257 << *elemascluster << std::endl;
1258 if (addPFClusterToROSafe(elemascluster, RO)) {
1261 ecal->setFlag(
false);
1274 NotCloserToOther<reco::PFBlockElement::GSF, reco::PFBlockElement::HCAL> gsfTracksToHCALs(
_currentblock, primgsf);
1275 auto notmatched =
std::partition(HCALbegin, HCALend, gsfTracksToHCALs);
1276 for (
auto hcal = HCALbegin;
hcal != notmatched; ++
hcal) {
1279 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1280 <<
"Found an HCAL cluster associated to GSF extrapolation" << std::endl;
1283 hcal->setFlag(
false);
1299 std::vector<FlaggedPtr<const PFClusterElement>>& currentECAL = RO.
ecalclusters;
1302 NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::ECAL> kfTrackToECALs(
_currentblock, kfflagged);
1303 NotCloserToOther<reco::PFBlockElement::GSF, reco::PFBlockElement::ECAL> kfTrackGSFToECALs(
_currentblock, kfflagged);
1305 auto notmatched_sc =
std::partition(currentECAL.begin(), currentECAL.end(), kfTrackToECALs);
1307 notmatched_sc =
std::partition(currentECAL.begin(), notmatched_sc, kfTrackGSFToECALs);
1308 for (
auto ecalitr = currentECAL.begin(); ecalitr != notmatched_sc; ++ecalitr) {
1312 LOGDRESSED(
"PFEGammaAlgo::linkKFTracktoECAL()") <<
"Found a cluster already in RO by KF extrapolation" 1313 <<
" at ECAL surface!" << std::endl
1314 << *elemascluster << std::endl;
1318 auto notmatched_blk =
std::partition(ECALbegin, ECALend, kfTrackToECALs);
1320 notmatched_blk =
std::partition(ECALbegin, notmatched_blk, kfTrackGSFToECALs);
1321 for (
auto ecalitr = ECALbegin; ecalitr != notmatched_blk; ++ecalitr) {
1323 if (addPFClusterToROSafe(elemascluster, RO)) {
1325 ecalitr->setFlag(
false);
1327 LOGDRESSED(
"PFEGammaAlgo::linkKFTracktoECAL()") <<
"Found a cluster not in RO by KF extrapolation" 1328 <<
" at ECAL surface!" << std::endl
1329 << *elemascluster << std::endl;
1336 if (RO.
brems.empty())
1340 int lastBremTrajPos = -1;
1341 for (
auto& brem : RO.
brems) {
1342 bool has_clusters =
false;
1343 TrajPos = (brem->indTrajPoint()) - 2;
1346 NotCloserToOther<reco::PFBlockElement::BREM, reco::PFBlockElement::ECAL> BremToECALs(
_currentblock, brem);
1350 auto notmatched_rsc =
std::partition(RSCBegin, RSCEnd, BremToECALs);
1351 for (
auto ecal = RSCBegin;
ecal != notmatched_rsc; ++
ecal) {
1352 float deta =
std::abs((*ecal)->clusterRef()->positionREP().eta() - brem->positionAtECALEntrance().eta());
1354 has_clusters =
true;
1355 if (lastBremTrajPos == -1 || lastBremTrajPos < TrajPos) {
1356 lastBremTrajPos = TrajPos;
1358 if (FirstBrem == -1 || TrajPos < FirstBrem) {
1359 FirstBrem = TrajPos;
1362 LOGDRESSED(
"PFEGammaAlgo::linkBremToECAL()") <<
"Found a cluster already in SC linked to brem extrapolation" 1363 <<
" at ECAL surface!" << std::endl;
1368 auto notmatched_block =
std::partition(ECALbegin, ECALend, BremToECALs);
1369 for (
auto ecal = ECALbegin;
ecal != notmatched_block; ++
ecal) {
1370 float deta =
std::abs((*ecal)->clusterRef()->positionREP().eta() - brem->positionAtECALEntrance().eta());
1372 has_clusters =
true;
1373 if (lastBremTrajPos == -1 || lastBremTrajPos < TrajPos) {
1374 lastBremTrajPos = TrajPos;
1376 if (FirstBrem == -1 || TrajPos < FirstBrem) {
1378 FirstBrem = TrajPos;
1382 if (addPFClusterToROSafe(elemasclus, RO)) {
1386 ecal->setFlag(
false);
1387 LOGDRESSED(
"PFEGammaAlgo::linkBremToECAL()") <<
"Found a cluster not already associated by brem extrapolation" 1388 <<
" at ECAL surface!" << std::endl;
1405 auto ronotconv =
std::partition(BeginROskfs, EndROskfs, [](
auto const&
x) {
return x->trackType(ConvType); });
1407 for (
size_t idx = 0;
idx < convkfs_end; ++
idx) {
1408 auto const& secKFs =
1410 NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::TRACK, true> TracksToTracks(
_currentblock,
1412 auto notmatched =
std::partition(KFbegin, KFend, TracksToTracks);
1413 notmatched =
std::partition(KFbegin, notmatched, [](
auto const&
x) {
return x->trackType(ConvType); });
1414 for (
auto kf = KFbegin; kf != notmatched; ++kf) {
1427 NotCloserToOther<reco::PFBlockElement::ECAL, reco::PFBlockElement::TRACK, true> ECALToTracks(
_currentblock,
1429 auto notmatchedkf =
std::partition(KFbegin, KFend, ECALToTracks);
1430 auto notconvkf =
std::partition(KFbegin, notmatchedkf, [](
auto const&
x) {
return x->trackType(ConvType); });
1432 for (
auto kf = KFbegin; kf != notconvkf; ++kf) {
1439 for (
auto kf = notconvkf; kf != notmatchedkf; ++kf) {
1457 NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::ECAL, false> TracksToECALwithCut(
1459 auto notmatched =
std::partition(ECALbegin, ECALend, TracksToECALwithCut);
1460 for (
auto ecal = ECALbegin;
ecal != notmatched; ++
ecal) {
1462 if (addPFClusterToROSafe(elemascluster, RO)) {
1465 ecal->setFlag(
false);
1475 output.candidates.reserve(ROs.size());
1476 output.candidateExtras.reserve(ROs.size());
1477 output.refinedSuperClusters.reserve(ROs.size());
1479 for (
auto& RO : ROs) {
1485 if (!RO.primaryGSFs.empty() || !RO.primaryKFs.empty()) {
1490 if (!RO.primaryKFs.empty()) {
1491 cand.setCharge(RO.primaryKFs[0]->trackRef()->charge());
1493 cand.setTrackRef(RO.primaryKFs[0]->trackRef());
1494 cand.setVertex(RO.primaryKFs[0]->trackRef()->vertex());
1497 if (!RO.primaryGSFs.empty()) {
1498 cand.setCharge(RO.primaryGSFs[0]->GsftrackRef()->chargeMode());
1500 cand.setGsfTrackRef(RO.primaryGSFs[0]->GsftrackRef());
1501 cand.setVertex(RO.primaryGSFs[0]->GsftrackRef()->vertex());
1507 cand.setSuperClusterRef(RO.parentSC->superClusterRef());
1512 for (
const auto& brem : RO.brems) {
1516 for (
const auto&
ecal : RO.ecalclusters) {
1519 if (RO.ecal2ps.count(clus)) {
1520 for (
auto& psclus : RO.ecal2ps.at(clus)) {
1526 for (
const auto& kf : RO.secondaryKFs) {
1529 bool no_conv_ref =
true;
1530 for (
const auto& convref : convrefs) {
1531 if (convref.isNonnull() && convref.isAvailable()) {
1533 no_conv_ref =
false;
1540 const auto& mvavalmapped = RO.singleLegConversionMvaMap.find(kf);
1543 float mvaval = (mvavalmapped != RO.singleLegConversionMvaMap.end()
1544 ? mvavalmapped->second
1555 float trkTime = 0, trkTimeErr = -1;
1556 if (!RO.primaryGSFs.empty() && RO.primaryGSFs[0]->isTimeValid()) {
1557 trkTime = RO.primaryGSFs[0]->time();
1558 trkTimeErr = RO.primaryGSFs[0]->timeError();
1559 }
else if (!RO.primaryKFs.empty() && RO.primaryKFs[0]->isTimeValid()) {
1560 trkTime = RO.primaryKFs[0]->time();
1561 trkTimeErr = RO.primaryKFs[0]->timeError();
1563 if (trkTimeErr >= 0) {
1564 cand.setTime(trkTime, trkTimeErr);
1572 const double scE = the_sc.
energy();
1576 egDir = egDir.Unit();
1579 cand.setPositionAtECALEntrance(ecalPOS_f);
1586 cand.setPositionAtECALEntrance(
gsf->positionAtECALEntrance());
1592 cand.setPositionAtECALEntrance(kf->positionAtECALEntrance());
1597 xtra.
setMVA(eleMVAValue);
1598 cand.set_mva_e_pi(eleMVAValue);
1600 output.candidateExtras.push_back(xtra);
1618 const double eInGsf =
std::hypot(refGsf->pMode(), mEl);
1619 double dEtGsfEcal = 1e6;
1621 const double eneHcalGsf =
1623 return a +
b->clusterRef()->energy();
1628 const double eOutGsf = gsfElement->
Pout().t();
1630 double firstEcalGsfEnergy{0.0};
1631 double otherEcalGsfEnergy{0.0};
1632 double ecalBremEnergy{0.0};
1634 std::vector<const reco::PFCluster*> gsfCluster;
1636 const double cenergy =
ecal->clusterRef()->correctedEnergy();
1639 bool hasbrem =
false;
1640 for (
const auto& brem : ro.
brems) {
1646 ecalBremEnergy += cenergy;
1650 otherEcalGsfEnergy += cenergy;
1652 ecalBremEnergy += cenergy;
1653 if (!(hasgsf || haskf))
1654 otherEcalGsfEnergy += cenergy;
1661 firstEcalGsfEnergy = cref->correctedEnergy();
1662 dEtGsfEcal = cref->positionREP().eta() - etaOutGsf;
1663 gsfCluster.push_back(cref.
get());
1669 float firstBrem{-1.0f};
1670 float earlyBrem{-1.0f};
1671 float lateBrem{-1.0f};
1674 earlyBrem = ro.
firstBrem < 4 ? 1.0f : 0.0f;
1675 lateBrem = ro.
lateBrem == 1 ? 1.0f : 0.0f;
1679 if (firstEcalGsfEnergy > 0.0) {
1680 if (refGsf.isNonnull()) {
1683 const float ptGsf = refGsf->ptMode();
1684 const float etaGsf = refGsf->etaMode();
1686 const double ptModeErrorGsf = refGsf->ptModeError();
1687 float ptModeErrOverPtGsf = (ptModeErrorGsf > 0. ? ptModeErrorGsf / ptGsf : 1.0);
1688 float chi2Gsf = refGsf->normalizedChi2();
1689 float dPtOverPtGsf = (ptGsf - gsfElement->
Pout().pt()) / ptGsf;
1691 float nHitKf = refKf.
isNonnull() ? refKf->hitPattern().trackerLayersWithMeasurement() : 0;
1692 float chi2Kf = refKf.
isNonnull() ? refKf->normalizedChi2() : -0.01;
1695 float eTotPinMode = (firstEcalGsfEnergy + otherEcalGsfEnergy + ecalBremEnergy) / eInGsf;
1696 float eGsfPoutMode = firstEcalGsfEnergy / eOutGsf;
1697 float eTotBremPinPoutMode = (ecalBremEnergy + otherEcalGsfEnergy) / (eInGsf - eOutGsf);
1698 float dEtaGsfEcalClust =
std::abs(dEtGsfEcal);
1700 float hOverHe = eneHcalGsf / (eneHcalGsf + firstEcalGsfEnergy);
1707 dPtOverPtGsf = std::clamp(dPtOverPtGsf, -0.2
f, 1.0
f);
1708 ptModeErrOverPtGsf =
std::min(ptModeErrOverPtGsf, 0.3
f);
1711 eTotPinMode = std::clamp(eTotPinMode, 0.0
f, 5.0
f);
1712 eGsfPoutMode = std::clamp(eGsfPoutMode, 0.0
f, 5.0
f);
1713 eTotBremPinPoutMode = std::clamp(eTotBremPinPoutMode, 0.0
f, 5.0
f);
1714 dEtaGsfEcalClust =
std::min(dEtaGsfEcalClust, 0.1
f);
1715 logSigmaEtaEta =
std::max(logSigmaEtaEta, -14.0
f);
1757 eTotBremPinPoutMode,
1776 NotCloserToOther<reco::PFBlockElement::ECAL, reco::PFBlockElement::TRACK, true> ECALToTracks(
_currentblock,
1778 auto notmatchedkf =
std::partition(KFbegin, KFend, ECALToTracks);
1779 auto notconvkf =
std::partition(KFbegin, notmatchedkf, [](
auto const&
x) {
return x->trackType(ConvType); });
1781 for (
auto kf = notconvkf; kf != notmatchedkf; ++kf) {
1798 std::vector<const reco::PFCluster*> bare_ptrs;
1800 double posX(0),
posY(0), posZ(0), rawSCEnergy(0), corrSCEnergy(0), corrPSEnergy(0), ps1_energy(0.0), ps2_energy(0.0);
1805 auto clusptr = edm::refToPtr<reco::PFClusterCollection>(clus->clusterRef());
1806 bare_ptrs.push_back(clusptr.get());
1808 const double cluseraw = clusptr->energy();
1809 double cluscalibe = clusptr->correctedEnergy();
1811 posX += cluseraw * cluspos.X();
1812 posY += cluseraw * cluspos.Y();
1813 posZ += cluseraw * cluspos.Z();
1815 if (isEE && RO.
ecal2ps.count(clus.get())) {
1816 const auto& psclusters = RO.
ecal2ps.at(clus.get());
1818 std::vector<reco::PFCluster const*> psClusterPointers;
1819 psClusterPointers.reserve(psclusters.size());
1820 for (
auto const& psc : psclusters) {
1821 psClusterPointers.push_back(psc->clusterRef().get());
1826 ePS1 = calibratedEnergies.ps1Energy;
1827 ePS2 = calibratedEnergies.ps2Energy;
1834 rawSCEnergy += cluseraw;
1835 corrSCEnergy += cluscalibe;
1838 corrPSEnergy += ePS1 + ePS2;
1840 posX /= rawSCEnergy;
1841 posY /= rawSCEnergy;
1842 posZ /= rawSCEnergy;
1847 auto clusptr = edm::refToPtr<reco::PFClusterCollection>(RO.
ecalclusters.front()->clusterRef());
1854 clusptr = edm::refToPtr<reco::PFClusterCollection>(clus->clusterRef());
1856 auto& hits_and_fractions = clusptr->hitsAndFractions();
1857 for (
auto& hit_and_fraction : hits_and_fractions) {
1861 if (RO.
ecal2ps.count(clus.get())) {
1862 const auto& cluspsassociation = RO.
ecal2ps.at(clus.get());
1866 for (
const auto& pscluselem : cluspsassociation) {
1869 auto found_pscluster =
1876 throw cms::Exception(
"PFECALSuperClusterAlgo::buildSuperCluster")
1877 <<
"Found a PS cluster matched to more than one EE cluster!" << std::endl
1878 << std::hex << psclus.
get() <<
" == " << found_pscluster->get() <<
std::dec << std::endl;
1901 const double Pin_gsf = RO.
primaryGSFs.front()->GsftrackRef()->pMode();
1902 const double gsfOuterEta = RO.
primaryGSFs.front()->positionAtECALEntrance().Eta();
1903 double tot_ecal = 0.0;
1904 std::vector<double> min_brem_dists;
1905 std::vector<double> closest_brem_eta;
1908 tot_ecal +=
ecal->clusterRef()->correctedEnergy();
1911 double min_brem_dist = 5000.0;
1912 double eta = -999.0;
1913 for (
const auto& brem : RO.
brems) {
1915 if (dist < min_brem_dist && dist != -1.0
f) {
1916 min_brem_dist = dist;
1917 eta = brem->positionAtECALEntrance().Eta();
1920 min_brem_dists.push_back(min_brem_dist);
1921 closest_brem_eta.push_back(
eta);
1928 const float secpin = (*secd_kf)->trackRef()->p();
1929 bool remove_this_kf =
false;
1932 const float minbremdist = min_brem_dists[bremidx];
1933 const double ecalenergy = (*ecal)->clusterRef()->correctedEnergy();
1934 const double Epin = ecalenergy / secpin;
1935 const double detaGsf =
std::abs(gsfOuterEta - (*ecal)->clusterRef()->positionREP().Eta());
1936 const double detaBrem =
std::abs(closest_brem_eta[bremidx] - (*ecal)->clusterRef()->positionREP().Eta());
1940 const float tkdist =
1946 if (Epin > 3 && kf_matched && tkdist != -1.0
f && tkdist < minbremdist && detaGsf > 0.05 && detaBrem > 0.015) {
1947 double res_with =
std::abs((tot_ecal - Pin_gsf) / Pin_gsf);
1948 double res_without =
std::abs((tot_ecal - ecalenergy - Pin_gsf) / Pin_gsf);
1949 if (res_without < res_with) {
1950 LOGDRESSED(
"PFEGammaAlgo") <<
" REJECTED_RES totenergy " << tot_ecal <<
" Pin_gsf " << Pin_gsf
1951 <<
" cluster to secondary " << ecalenergy <<
" res_with " << res_with
1952 <<
" res_without " << res_without << std::endl;
1953 tot_ecal -= ecalenergy;
1954 remove_this_kf =
true;
1961 if (remove_this_kf) {
1970 bool removeFreeECAL,
1971 bool removeSCEcal) {
1972 std::vector<bool> cluster_in_sc;
1978 bool remove_this_kf =
false;
1979 NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::HCAL> tracksToHCALs(
_currentblock, *secd_kf);
1983 const float secpin = trkRef->p();
1985 for (
auto ecal = ecal_begin;
ecal != ecal_end; ++
ecal) {
1986 const double ecalenergy = (*ecal)->clusterRef()->correctedEnergy();
1989 if (cluster_in_sc.size() < clus_idx + 1) {
1994 cluster_in_sc.push_back(dist != -1.0
f);
2002 auto hcal_matched =
std::partition(hcal_begin, hcal_end, tracksToHCALs);
2003 for (
auto hcalclus = hcal_begin; hcalclus != hcal_matched; ++hcalclus) {
2005 const double hcalenergy = clusthcal->
clusterRef()->energy();
2006 const double hpluse = ecalenergy + hcalenergy;
2007 const bool isHoHE = ((hcalenergy / hpluse) > 0.1 &&
goodTrack);
2008 const bool isHoE = (hcalenergy > ecalenergy);
2009 const bool isPoHE = (secpin > hpluse);
2010 if (cluster_in_sc[clus_idx]) {
2011 if (isHoE || isPoHE) {
2012 LOGDRESSED(
"PFEGammaAlgo") <<
"REJECTED TRACK FOR H/E or P/(H+E), CLUSTER IN SC" 2013 <<
" H/H+E " << (hcalenergy / hpluse) <<
" H/E " << (hcalenergy > ecalenergy)
2014 <<
" P/(H+E) " << (secpin / hpluse) <<
" HCAL ENE " << hcalenergy
2015 <<
" ECAL ENE " << ecalenergy <<
" secPIN " << secpin <<
" Algo Track " 2016 << trkRef->algo() << std::endl;
2017 remove_this_kf =
true;
2021 LOGDRESSED(
"PFEGammaAlgo") <<
"REJECTED TRACK FOR H/H+E, CLUSTER NOT IN SC" 2022 <<
" H/H+E " << (hcalenergy / hpluse) <<
" H/E " << (hcalenergy > ecalenergy)
2023 <<
" P/(H+E) " << (secpin / hpluse) <<
" HCAL ENE " << hcalenergy
2024 <<
" ECAL ENE " << ecalenergy <<
" secPIN " << secpin <<
" Algo Track " 2025 << trkRef->algo() << std::endl;
2026 remove_this_kf =
true;
2032 if (remove_this_kf) {
2047 PFRecTrackRef kfPfRef_fromGsf = (*gsfPfRef).kfPFRecTrackRef();
2052 if (kfref == kfref_fromGsf)
const math::XYZPoint & position() const
cluster centroid position
reco::PFCluster::EEtoPSAssociation const & eetops_
Log< level::Info, true > LogVerbatim
std::vector< PFGSFElement const * > primaryGSFs
Abstract base class for a PFBlock element (track, cluster...)
float evaluateSingleLegMVA(const reco::PFBlockRef &blockref, const reco::Vertex &primaryVtx, unsigned int trackIndex)
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
GBRForests const & gbrForests_
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
void setSuperClusterRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
PFEGammaAlgo(const PFEGConfigInfo &, GBRForests const &gbrForests, EEtoPSAssociation const &eetops, ESEEIntercalibConstants const &esEEInterCalib, ESChannelStatus const &channelStatus, reco::Vertex const &primaryVertex)
bool unwrapSuperCluster(const reco::PFBlockElementSuperCluster *, std::vector< FlaggedPtr< const PFClusterElement >> &, ClusterMap &)
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
unsigned int indTrajPoint() const
void addHitAndFraction(DetId id, float fraction)
reco::PFBlockRef parentBlock
void unlinkRefinableObjectKFandECALWithBadEoverP(ProtoEGObject &)
double z() const
z coordinate
const math::XYZPointF & positionAtECALEntrance() const
bool isPrimary(const SimTrack &simTrk, const PSimHit *simHit)
static bool isMuon(const reco::PFBlockElement &elt)
void setGsfElectronClusterRef(const reco::PFBlockRef &blk, const reco::PFBlockElementCluster &ref)
set gsf electron cluster ref
void dumpCurrentRefinableObjects() const
double pflowPhiWidth() const
void addSingleLegConvTrackRefMva(const std::pair< reco::TrackRef, float > &trackrefmva)
add Single Leg Conversion TrackRef
void setPreshowerEnergyPlane2(double preshowerEnergy2)
const Point & position() const
position
void setHadEnergy(float val)
set the had energy. The cluster energies should be entered before
Geom::Phi< T > phi() const
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
float calculateEleMVA(const ProtoEGObject &, reco::PFCandidateEGammaExtra &) const
reco::Vertex const & primaryVertex_
bool isPrimaryTrack(const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
double pflowEtaWidth() const
void linkRefinableObjectPrimaryGSFTrackToECAL(ProtoEGObject &)
const SuperClusterRef & superClusterRef() const
bool isNonnull() const
Checks for non-null.
std::map< unsigned int, Link > LinkData
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
CaloCluster_iterator preshowerClustersBegin() const
fist iterator over PreshowerCluster constituents
double pflowSigmaEtaEta() const
std::vector< const PFClusterElement * > electronClusters
unsigned int index
index type
void setSeed(const CaloClusterPtr &r)
list of used xtals by DetId // now inherited by CaloCluster
void initAlphaGamma_ESplanes_fromDB(const ESEEIntercalibConstants *esEEInterCalib)
const reco::GsfTrackRef & GsftrackRef() const
edm::Ptr< CaloCluster > CaloClusterPtr
void linkRefinableObjectBremTangentsToECAL(ProtoEGObject &)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
CalibratedEndcapPFClusterEnergies calibrateEndcapClusterEnergies(reco::PFCluster const &eeCluster, std::vector< reco::PFCluster const *> const &psClusterPointers, ESChannelStatus const &channelStatus, bool applyCrackCorrections) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
reco::PFBlockRef _currentblock
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
void setPhiWidth(double pw)
bool fromPFSuperCluster() const
trackRef_iterator tracks_end() const
last iterator over tracks
void swap(Association< C > &lhs, Association< C > &rhs)
PFEGConfigInfo const & cfg_
const std::unique_ptr< const GBRForest > singleLeg_
void linkRefinableObjectECALToSingleLegConv(ProtoEGObject &)
std::vector< PFKFElement const * > primaryKFs
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
static double delPhi(const double phi1, const double phi2)
void setEtaWidth(double ew)
void concatenate(CommutativePairs< T > const &other)
Add the pairs from another CommutativePairs to this.
void setSigmaEtaEta(float val)
set the sigmaetaeta
void initializeProtoCands(std::list< ProtoEGObject > &)
bool contains(T const &a, T const &b) const
void linkRefinableObjectPrimaryKFsToSecondaryKFs(ProtoEGObject &)
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
void setCorrectedEnergy(double cenergy)
std::vector< PFKFElement const * > secondaryKFs
reco::PFCluster::EEtoPSAssociation EEtoPSAssociation
bool trackType(TrackType trType) const override
bool isNonnull() const
Checks for non-null.
bool produceEGCandsWithNoSuperCluster
const PFSCElement * parentSC
std::vector< FlaggedPtr< const PFClusterElement > > ecalclusters
void setEarlyBrem(float val)
set EarlyBrem
Abs< T >::type abs(const T &t)
void setGsfTrackPout(const math::XYZTLorentzVector &pout)
set the pout (not trivial to get from the GSF track)
void insert(T const &a, T const &b)
trackRef_iterator tracks_begin() const
first iterator over tracks
key
prepare the HTCondor submission files and eventually submit them
std::vector< PFBremElement const * > brems
double x() const
x coordinate
CaloCluster_iterator preshowerClustersEnd() const
last iterator over PreshowerCluster constituents
void linkKFTrackToECAL(PFKFElement const *, ProtoEGObject &)
bool isNull() const
Checks for null.
KFValMap singleLegConversionMvaMap
double y() const
y coordinate
T const * get() const
Returns C++ pointer to the item.
const PFClusterRef & clusterRef() const override
CommutativePairs< const reco::PFBlockElement * > localMap
double energy() const
cluster energy
std::unordered_map< PFClusterElement const *, std::vector< PFClusterElement const * > > ClusterMap
reco::PFBlock::LinkData _currentlinks
void Dump(std::ostream &out=std::cout, const char *tab=" ") const override
print the object inside the element
bool trackType(TrackType trType) const override
bool isMuon(const reco::PFBlockElement &)
void fillExtraInfo(const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
bool applyCrackCorrections
void setDeltaEta(float val)
set the delta eta
reco::ElectronSeedRef electronSeed
const math::XYZTLorentzVector & Pout() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
EgammaObjects operator()(const reco::PFBlockRef &block)
XYZPointD XYZPoint
point in space with cartesian internal representation
void addPreshowerCluster(const CaloClusterPtr &r)
add reference to constituent BasicCluster
void linkRefinableObjectGSFTracksToKFs(ProtoEGObject &)
void setSuperClusterPFECALRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
const reco::TrackRef & trackRef() const override
void addConversionRef(const reco::ConversionRef &convref)
add Conversions from PF
void addCluster(const CaloClusterPtr &r)
add reference to constituent BasicCluster
const CaloClusterPtr & seed() const
seed BasicCluster
void removeOrLinkECALClustersToKFTracks()
Particle reconstructed by the particle flow algorithm.
reco::SuperCluster buildRefinedSuperCluster(const ProtoEGObject &)
EgammaObjects fillPFCandidates(const std::list< ProtoEGObject > &)
void unlinkRefinableObjectKFandECALMatchedToHCAL(ProtoEGObject &, bool removeFreeECAL=false, bool removeSCECAL=false)
void Dump(std::ostream &out=std::cout, const char *tab=" ") const override
print the object inside the element
const GsfPFRecTrackRef & GsftrackRefPF() const
std::vector< PFClusterElement const * > hcalClusters
T const * get() const
Returns C++ pointer to the item.
void mergeROsByAnyLink(std::list< ProtoEGObject > &)
std::vector< std::vector< FlaggedPtr< const reco::PFBlockElement > > > _splayedblock
PFEnergyCalibration thePFEnergyCalibration_
int attachPSClusters(const PFClusterElement *, ClusterMap::mapped_type &)
void linkRefinableObjectKFTracksToECAL(ProtoEGObject &)
void setKfTrackRef(const reco::TrackRef &ref)
set kf track reference
const std::unique_ptr< const GBRForest > ele_
void setMVA(float val)
set the result (mostly for debugging)
const PFRecTrackRef & trackRefPF() const override
void linkRefinableObjectSecondaryKFsToECAL(ProtoEGObject &)
void setLateBrem(float val)
set LateBrem
void linkRefinableObjectConvSecondaryKFsToSecondaryKFs(ProtoEGObject &)
void Dump(std::ostream &out=std::cout, const char *tab=" ") const override
print the object inside the element
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
primaryVertex
hltOfflineBeamSpot for HLTMON
void setPreshowerEnergyPlane1(double preshowerEnergy1)
void addExtraNonConvTrack(const reco::PFBlockRef &blk, const reco::PFBlockElementTrack &tkref)
track counting for electrons and photons
ESChannelStatus const & channelStatus_
void setPreshowerEnergy(double preshowerEnergy)
void linkRefinableObjectPrimaryGSFTrackToHCAL(ProtoEGObject &)
const math::XYZTLorentzVector & Pin() const