37 #include "combination.hpp" 43 #define docast(x,y) dynamic_cast<x>(y) 44 #define LOGVERB(x) edm::LogVerbatim(x) 45 #define LOGWARN(x) edm::LogWarning(x) 46 #define LOGERR(x) edm::LogError(x) 47 #define LOGDRESSED(x) edm::LogInfo(x) 49 #define docast(x,y) reinterpret_cast<x>(y) 50 #define LOGVERB(x) LogTrace(x) 51 #define LOGWARN(x) edm::LogWarning(x) 52 #define LOGERR(x) edm::LogError(x) 53 #define LOGDRESSED(x) LogDebug(x) 63 typedef std::pair<CaloClusterPtr::key_type,CaloClusterPtr> EEtoPSElement;
71 class SeedMatchesToProtoObject {
77 if( scfromseed_.isNonnull() )
85 if( scfromseed_.isNull() || !po.
parentSC )
return false;
98 template<
bool useConvs=false>
104 const float EoPin_cut = 1.0e6) {
113 &(block->elements()[
key]));
115 const ClusterElement* elemasclus =
116 reinterpret_cast<const ClusterElement*
>(&(block->elements()[
test]));
117 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
118 float trk_pin = elemasgsf->
Pin().P();
119 if( cluster_e / trk_pin > EoPin_cut ) {
121 <<
"GSF track failed EoP cut to match with cluster!";
131 &(block->elements()[
key]));
133 const ClusterElement* elemasclus =
134 reinterpret_cast<const ClusterElement*
>(&(block->elements()[
test]));
135 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
138 if( cluster_e / trk_pin > EoPin_cut ) {
140 <<
"KF track failed EoP cut to match with cluster!";
152 if( dist == -1.0
f )
return false;
153 std::multimap<double, unsigned> dists_to_val;
154 block->associatedElements(test,block->linkData(),dists_to_val,keytype,
157 for(
const auto& valdist : dists_to_val ) {
158 const size_t idx = valdist.second;
165 &(block->elements()[
idx]));
166 if( !useConvs && elemasgsf->
trackType(ConvType) )
return false;
168 const ClusterElement* elemasclus =
169 docast(
const ClusterElement*,&(block->elements()[
test]));
170 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
171 float trk_pin = elemasgsf->
Pin().P();
172 if( cluster_e / trk_pin > EoPin_cut )
continue;
180 &(block->elements()[
idx]));
181 if( !useConvs && elemaskf->
trackType(ConvType) )
return false;
183 const ClusterElement* elemasclus =
184 reinterpret_cast<const ClusterElement*
>(&(block->elements()[
test]));
185 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
188 if( cluster_e / trk_pin > EoPin_cut )
continue;
195 if( valdist.first < dist && idx != key ) {
197 <<
"key element of type " << keytype
198 <<
" is closer to another element of type" << valtype
212 const ClusterElement* elemascluster =
docast(
const ClusterElement*,e.first);
215 return ( gsf_eta_diff <= 0.3 && cRef->energy()/comp->
Pout().t() <= 5 );
218 bool isConversionTrack(
const PFFlaggedElement& e)
230 struct NotCloserToOther {
233 const float EoPin_cut;
236 const float EoPcut=1.0e6):
comp(e),
240 bool operator () (
const PFFlaggedElement& e) {
241 if( !e.second || valtype != e.first->type() )
return false;
242 return elementNotCloserToOther<useConv>(
block,
243 keytype,comp->
index(),
244 valtype,e.first->index(),
249 struct LesserByDistance {
258 bool operator () (
const PFFlaggedElement& e1,
259 const PFFlaggedElement& e2) {
260 double dist1 = block->dist(comp->
index(),
264 double dist2 = block->dist(comp->
index(),
268 dist1 = ( dist1 == -1.0 ? 1e6 : dist1 );
269 dist2 = ( dist2 == -1.0 ? 1e6 : dist2 );
270 return dist1 < dist2;
280 <<
"cannot merge, both have GSFs!" << std::endl;
285 if(RO1.
ecalclusters.front().first->clusterRef()->layer() !=
286 RO2.
ecalclusters.front().first->clusterRef()->layer() ) {
288 <<
"cannot merge, different ECAL types!" << std::endl;
298 elementNotCloserToOther(blk,
299 cluster.first->type(),
300 cluster.first->
index(),
301 primgsf.first->type(),
302 primgsf.first->index());
305 <<
"merged by cluster to primary GSF" << std::endl;
309 <<
"cluster to primary GSF failed since" 310 <<
" cluster closer to another GSF" << std::endl;
315 elementNotCloserToOther(blk,
316 cluster.first->type(),
317 cluster.first->
index(),
318 primkf.first->type(),
319 primkf.first->index());
322 <<
"merged by cluster to primary KF" << std::endl;
328 elementNotCloserToOther(blk,
329 cluster.first->type(),
330 cluster.first->
index(),
331 secdkf.first->type(),
332 secdkf.first->index());
335 <<
"merged by cluster to secondary KF" << std::endl;
340 for(
const auto& brem : RO2.
brems ) {
341 not_closer = elementNotCloserToOther(blk,
342 cluster.first->type(),
343 cluster.first->
index(),
345 brem.first->index());
348 <<
"merged by cluster to brem KF" << std::endl;
357 elementNotCloserToOther(blk,
358 primgsf.first->type(),
359 primgsf.first->
index(),
360 secdkf.first->type(),
361 secdkf.first->index());
364 <<
"merged by GSF to secondary KF" << std::endl;
373 elementNotCloserToOther(blk,
374 primkf.first->type(),
375 primkf.first->
index(),
376 secdkf.first->type(),
377 secdkf.first->index());
380 <<
"merged by primary KF to secondary KF" << std::endl;
389 elementNotCloserToOther<true>(blk,
390 secdkf1.first->type(),
391 secdkf1.first->
index(),
392 secdkf2.first->type(),
393 secdkf2.first->index());
396 <<
"merged by secondary KF to secondary KF" << std::endl;
406 const bool result = ( isROLinkedByClusterOrTrack(comp,ro) || isROLinkedByClusterOrTrack(ro,comp) );
410 std::vector<const ClusterElement*>
412 std::vector<PFFlaggedElement>& ecals) {
413 std::vector<const ClusterElement*> cluster_list;
414 auto sccl = scref->clustersBegin();
415 auto scend = scref->clustersEnd();
416 auto pfc = ecals.begin();
417 auto pfcend = ecals.end();
418 for( ; sccl != scend; ++sccl ) {
419 std::vector<const ClusterElement*> matched_pfcs;
420 const double eg_energy = (*sccl)->energy();
422 for( pfc = ecals.begin(); pfc != pfcend; ++pfc ) {
423 const ClusterElement *pfcel =
424 docast(
const ClusterElement*, pfc->first);
429 if( matched && pfcel->clusterRef()->energy() < 1.2*scref->energy()) {
430 matched_pfcs.push_back(pfcel);
433 std::sort(matched_pfcs.begin(),matched_pfcs.end());
435 double min_residual = 1e6;
436 std::vector<const ClusterElement*> best_comb;
437 for(
size_t i = 1;
i <= matched_pfcs.size(); ++
i ) {
442 double energy = std::accumulate(matched_pfcs.begin(),
443 matched_pfcs.begin()+
i,
446 const ClusterElement*
c)
447 {
return a +
c->clusterRef()->energy(); });
448 const double resid =
std::abs(energy - eg_energy);
449 if( resid < min_residual ) {
451 best_comb.reserve(
i);
452 min_residual = resid;
453 best_comb.insert(best_comb.begin(),
454 matched_pfcs.begin(),
455 matched_pfcs.begin()+
i);
458 matched_pfcs.begin()+
i,
459 matched_pfcs.end()));
461 for(
const auto& clelem : best_comb ) {
462 if(
std::find(cluster_list.begin(),cluster_list.end(),clelem) ==
463 cluster_list.end() ) {
464 cluster_list.push_back(clelem);
470 bool addPFClusterToROSafe(
const ClusterElement*
cl,
479 if( clayer == blayer ) {
496 *kfCluster =
nullptr, *gsfCluster_noassc =
nullptr;
498 int nBremClusters = 0;
500 float mDist_gsf(maxDist), mDist_gsf_noassc(maxDist), mDist_kf(maxDist);
503 const bool hasclu = elementNotCloserToOther(parent,
506 cluster.first->type(),
507 cluster.first->index());
509 std::abs(cluster.first->clusterRef()->positionREP().eta() -
510 gsf.first->positionAtECALEntrance().eta());
513 cluster.first->clusterRef()->positionREP().phi() -
514 gsf.first->positionAtECALEntrance().phi()));
515 const float dist = std::hypot(deta,dphi);
516 if( hasclu && dist < mDist_gsf ) {
517 gsfCluster = cluster.first;
519 }
else if ( dist < mDist_gsf_noassc ) {
520 gsfCluster_noassc = cluster.first;
521 mDist_gsf_noassc = dist;
525 const bool hasclu = elementNotCloserToOther(parent,
528 cluster.first->type(),
529 cluster.first->index());
530 const float dist = parent->dist(cluster.first->index(),
534 if( hasclu && dist < mDist_kf ) {
535 kfCluster = cluster.first;
539 for(
const auto& brem : RO.
brems ) {
540 const bool hasclu = elementNotCloserToOther(parent,
543 cluster.first->type(),
544 cluster.first->index());
549 brem.first->indTrajPoint() - 2) ) {
550 firstBrem = brem.first;
553 ( lastBrem->indTrajPoint() - 2 <
554 brem.first->indTrajPoint() - 2) ) {
555 lastBrem = brem.first;
556 bremCluster = cluster.first;
561 if( !gsfCluster && !kfCluster && !bremCluster ) {
562 gsfCluster = gsfCluster_noassc;
568 }
else if ( kfCluster ) {
571 if( bremCluster && !gsfCluster && !kfCluster ) {
576 if( bremCluster == gsfCluster ) RO.
lateBrem = 1;
588 unsigned int trackIndex)
595 const float chi2 = elements[trackIndex].trackRef()->chi2()/elements[trackIndex].trackRef()->ndof();
596 const float nlost = elements[trackIndex].trackRef()->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
597 const float nLayers = elements[trackIndex].trackRef()->hitPattern().trackerLayersWithMeasurement();
598 const float trackPt = elements[trackIndex].trackRef()->pt();
599 const float stip = elements[trackIndex].trackRefPF()->STIP();
603 std::multimap<double, unsigned int> ecalAssoTrack;
608 std::multimap<double, unsigned int> hcalAssoTrack;
613 if(!ecalAssoTrack.empty())
615 for (
auto & itecal : ecalAssoTrack)
617 linkedE = linkedE+elements[itecal.second].clusterRef()->energy();
620 if(!hcalAssoTrack.empty())
622 for (
auto & ithcal : hcalAssoTrack)
624 linkedH = linkedH+elements[ithcal.second].clusterRef()->energy();
627 const float eOverPt = linkedE / elements[trackIndex].trackRef()->pt();
628 const float hOverPt = linkedH / elements[trackIndex].trackRef()->pt();
629 GlobalVector rvtx(elements[trackIndex].trackRef()->innerPosition().
X()-primaryVtx.
x(),
630 elements[trackIndex].trackRef()->innerPosition().Y()-primaryVtx.
y(),
631 elements[trackIndex].trackRef()->innerPosition().Z()-primaryVtx.
z());
632 double vtxPhi = rvtx.
phi();
634 float delPhi = fabs(
deltaPhi(vtxPhi, elements[trackIndex].trackRef()->innerMomentum().
Phi()));
637 hOverPt,
trackPt, stip, nlost };
643 switch( pfbe.
type() ) {
647 std::multimap<double,unsigned> tks;
653 for(
const auto& tk : tks ) {
672 <<
"Resetting PFEGammaAlgo for new block and running!" << std::endl;
680 LOGVERB(
"PFEGammaAlgo") <<
"Splaying block" << std::endl;
683 if(
isMuon(pfelement) )
continue;
686 const size_t itype = (size_t)pfelement.type();
693 std::stringstream splayout;
694 for(
size_t itype = 0; itype <
_splayedblock.size(); ++itype ) {
695 splayout <<
"\tType: " << itype <<
" indices: ";
697 splayout << flaggedelement.first->index() <<
' ';
699 if( itype !=
_splayedblock.size() - 1 ) splayout << std::endl;
701 LOGVERB(
"PFEGammaAlgo") << splayout.str();
738 <<
"Dumping after GSF and KF Track (Primary) Linking : " << std::endl;
745 <<
"Dumping after first merging operation : " << std::endl;
751 for(
auto& RO : _refinableObjects ) {
762 <<
"Dumping after ECAL to Track (Secondary) Linking : " << std::endl;
769 <<
"There are " << _refinableObjects.size()
770 <<
" after the 2nd merging step." << std::endl;
774 for(
auto& RO : _refinableObjects ) {
781 std::sort(RO.ecalclusters.begin(), RO.ecalclusters.end(),
784 {
return ( a.first->clusterRef()->correctedEnergy() >
785 b.first->clusterRef()->correctedEnergy() ) ; });
786 setROElectronCluster(RO);
790 <<
"There are " << _refinableObjects.size()
791 <<
" after the unlinking and vetos step." << std::endl;
806 <<
"creating SC-based proto-object" << std::endl
807 <<
"\tSC at index: " << element.first->index()
808 <<
" has type: " << element.first->type() << std::endl;
809 element.second =
false;
842 <<
"creating GSF-based proto-object" << std::endl
843 <<
"\tGSF at index: " << element.first->index()
844 <<
" has type: " << element.first->type() << std::endl;
850 element.second =
false;
865 std::stringstream gsf_err;
866 elementAsGSF->
Dump(gsf_err,
"\t");
868 <<
"Found a GSF track with no seed! This should not happen!" 869 << std::endl << gsf_err.str() << std::endl;
873 element.second =
false;
875 fromGSF.
primaryGSFs.emplace_back(elementAsGSF,
true);
882 if( dist == 0.001
f ) {
885 fromGSF.
brems.emplace_back(eAsBrem,
true);
886 fromGSF.
localMap.emplace_back(eAsBrem,elementAsGSF);
887 fromGSF.
localMap.emplace_back(elementAsGSF,eAsBrem);
898 <<
"GSF-based proto-object is ECAL driven, merging SC-cand" 905 SeedMatchesToProtoObject sctoseedmatch(fromGSF.
electronSeed);
909 auto clusmatch = std::find_if(objsbegin,objsend,sctoseedmatch);
910 if( clusmatch != objsend ) {
911 fromGSF.
parentSC = clusmatch->parentSC;
921 <<
"Encountered the known GSF-SC splitting bug " 922 <<
" in PFBlockAlgo! We should really fix this!" << std::endl;
924 std::stringstream gsf_err;
925 elementAsGSF->
Dump(gsf_err,
"\t");
927 <<
"Expected SuperCluster from ECAL driven GSF seed " 928 <<
"was not found in the block!" << std::endl
929 << gsf_err.str() << std::endl;
953 std::vector<PFClusterFlaggedElement>& ecalclusters,
955 ecalclusters.clear();
958 <<
"Pointer to SC element: 0x" 959 << std::hex << thesc <<
std::dec << std::endl
960 <<
"cleared ecalclusters and ecal2ps!" << std::endl;
965 if( ecalbegin == ecalend && hgcalbegin == hgcalend ) {
966 LOGERR(
"PFEGammaAlgo::unwrapSuperCluster()")
967 <<
"There are no ECAL elements in a block with imported SC!" 968 <<
" This is a bug we should fix this!" 976 <<
"SuperCluster pointed to by block element is null!" 980 <<
"Got a valid super cluster ref! 0x" 981 << std::hex << scref.
get() <<
std::dec << std::endl;
982 const size_t nscclusters = scref->clustersSize();
983 const size_t nscpsclusters = scref->preshowerClustersSize();
984 size_t npfpsclusters = 0;
985 size_t npfclusters = 0;
987 <<
"Precalculated cluster multiplicities: " 988 << nscclusters <<
' ' << nscpsclusters << std::endl;
989 NotCloserToOther<reco::PFBlockElement::SC,reco::PFBlockElement::ECAL>
991 NotCloserToOther<reco::PFBlockElement::SC,reco::PFBlockElement::HGCAL>
993 auto ecalfirstnotinsc = std::partition(ecalbegin,ecalend,ecalClustersInSC);
994 auto hgcalfirstnotinsc = std::partition(hgcalbegin,hgcalend,hgcalClustersInSC);
1006 if( ecalfirstnotinsc == ecalbegin &&
1007 hgcalfirstnotinsc == hgcalbegin) {
1008 LOGERR(
"PFEGammaAlgo::unwrapSuperCluster()")
1009 <<
"No associated block elements to SuperCluster!" 1010 <<
" This is a bug we should fix!" 1017 if( is_pf_sc && nscclusters != npfclusters ) {
1018 std::stringstream sc_err;
1019 thesc->
Dump(sc_err,
"\t");
1021 <<
"The number of found ecal elements (" 1022 << nscclusters <<
") in block is not the same as" 1023 <<
" the number of ecal PF clusters reported by the PFSuperCluster" 1024 <<
" itself (" << npfclusters
1025 <<
")! This should not happen!" << std::endl
1026 << sc_err.str() << std::endl;
1028 for(
auto ecalitr = ecalbegin; ecalitr != ecalfirstnotinsc; ++ecalitr ) {
1034 if(!is_pf_sc &&
std::find(safePFClusters.begin(),safePFClusters.end(),elemascluster) ==
1035 safePFClusters.end() )
continue;
1038 ecalclusters.emplace_back(elemascluster,
true);
1040 ecalitr->second =
false;
1044 auto emplaceresult = ecal2ps.emplace(elemascluster,
1045 ClusterMap::mapped_type());
1046 if( !emplaceresult.second ) {
1047 std::stringstream clus_err;
1048 elemascluster->
Dump(clus_err,
"\t");
1050 <<
"List of pointers to ECAL block elements contains non-unique items!" 1051 <<
" This is very bad!" << std::endl
1052 <<
"cluster ptr = 0x" << std::hex << elemascluster <<
std::dec 1053 << std::endl << clus_err.str() << std::endl;
1055 ClusterMap::mapped_type& eslist = emplaceresult.first->second;
1059 for(
auto hgcalitr = hgcalbegin; hgcalitr != hgcalfirstnotinsc; ++hgcalitr ) {
1065 if(!is_pf_sc &&
std::find(safePFClusters.begin(),safePFClusters.end(),elemascluster) ==
1066 safePFClusters.end() )
continue;
1069 ecalclusters.emplace_back(elemascluster,
true);
1071 hgcalitr->second =
false;
1089 <<
" Unwrapped SC has " << npfclusters <<
" ECAL sub-clusters" 1090 <<
" and " << npfpsclusters <<
" PreShower layers 1 & 2 clusters!" 1097 ClusterMap::mapped_type& eslist) {
1100 EEtoPSElement ecalkey(clusptr.
key(),clusptr);
1101 auto assc_ps = std::equal_range(
eetops_->cbegin(),
1104 [](
const EEtoPSElement&
a,
const EEtoPSElement&
b){
return a.first <
b.first;});
1107 for(
auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl ) {
1108 if( pscl->second == temp ) {
1109 const ClusterElement* pstemp =
1110 docast(
const ClusterElement*,ps1.first);
1111 eslist.emplace_back(pstemp,
true);
1117 for(
auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl ) {
1118 if( pscl->second == temp ) {
1119 const ClusterElement* pstemp =
1120 docast(
const ClusterElement*,ps2.first);
1121 eslist.emplace_back(pstemp,
true);
1125 return eslist.size();
1133 <<
" refinable objects for this block: " << std::endl;
1135 std::stringstream
info;
1136 info <<
"Refinable Object:" << std::endl;
1138 info <<
"\tSuperCluster element attached to object:" << std::endl
1140 ro.parentSC->Dump(info,
"\t");
1143 if( ro.electronSeed.isNonnull() ) {
1144 info <<
"\tGSF element attached to object:" << std::endl;
1145 ro.primaryGSFs.front().first->Dump(info,
"\t");
1147 info <<
"firstBrem : " << ro.firstBrem
1148 <<
" lateBrem : " << ro.lateBrem
1149 <<
" nBrems with cluster : " << ro.nBremsWithClusters
1151 if( ro.electronClusters.size() && ro.electronClusters[0] ) {
1152 info <<
"electron cluster : ";
1153 ro.electronClusters[0]->Dump(info,
"\t");
1156 info <<
" no electron cluster." << std::endl;
1159 if( ro.primaryKFs.size() ) {
1160 info <<
"\tPrimary KF tracks attached to object: " << std::endl;
1161 for(
const auto& kf : ro.primaryKFs ) {
1162 kf.first->Dump(info,
"\t");
1166 if( ro.secondaryKFs.size() ) {
1167 info <<
"\tSecondary KF tracks attached to object: " << std::endl;
1168 for(
const auto& kf : ro.secondaryKFs ) {
1169 kf.first->Dump(info,
"\t");
1173 if( ro.brems.size() ) {
1174 info <<
"\tBrem tangents attached to object: " << std::endl;
1175 for(
const auto& brem : ro.brems ) {
1176 brem.first->Dump(info,
"\t");
1180 if( ro.ecalclusters.size() ) {
1181 info <<
"\tECAL clusters attached to object: " << std::endl;
1182 for(
const auto& clus : ro.ecalclusters ) {
1183 clus.first->Dump(info,
"\t");
1185 if( ro.ecal2ps.find(clus.first) != ro.ecal2ps.end() ) {
1186 for(
const auto& psclus : ro.ecal2ps.at(clus.first) ) {
1187 info <<
"\t\t Attached PS Cluster: ";
1188 psclus.first->Dump(info,
"");
1202 typedef std::multimap<double, unsigned> MatchedMap;
1206 MatchedMap matchedGSFs, matchedECALs;
1207 std::unordered_map<GsfTrackElementPtr,MatchedMap> gsf_ecal_cache;
1209 matchedGSFs.clear();
1214 if( matchedGSFs.empty() ) {
1219 std::partial_sort(ecalbegin,ecalbegin+1,ecalend,closestTrackToECAL);
1222 const float dist =
_currentblock->dist(kftrack.first->index(),
1223 closestECAL.first->index(),
1229 closestECAL.first->index(),
1232 if( dist_sc != -1.0
f) { inSC =
true;
break; }
1235 if( dist != -1.0
f && closestECAL.second ) {
1236 bool gsflinked =
false;
1238 for(
const auto& gsfflag :
_splayedblock[reco::PFBlockElement::GSF]) {
1245 if( !gsf_ecal_cache.count(elemasgsf) ) {
1246 matchedECALs.clear();
1251 gsf_ecal_cache.emplace(elemasgsf,matchedECALs);
1252 MatchedMap().swap(matchedECALs);
1254 const MatchedMap& ecal_matches = gsf_ecal_cache[elemasgsf];
1255 if( !ecal_matches.empty() ) {
1256 if( ecal_matches.begin()->second == closestECAL.first->index() ) {
1262 if( !gsflinked && !inSC) {
1269 trackref->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1270 bool fromprimaryvertex =
false;
1274 fromprimaryvertex =
true;
1280 closestECAL.second =
false;
1290 if( ROs.size() < 2 )
return;
1291 bool check_for_merge =
true;
1292 while( check_for_merge ) {
1297 for(
auto it1 = ROs.begin(); it1 != ROs.end(); ++it1 ) {
1298 auto find_start = it1; ++find_start;
1299 auto has_merge = std::find_if(find_start,ROs.end(),
1300 std::bind(testIfROMergableByLink, _1, *it1));
1301 if( has_merge != ROs.end() && it1 != ROs.begin() ) {
1307 auto mergestart = ROs.begin(); ++mergestart;
1308 auto nomerge = std::partition(mergestart,ROs.end(),
1309 std::bind(testIfROMergableByLink, _1, thefront));
1310 if( nomerge != mergestart ) {
1311 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink()")
1313 <<
" to merge by links to the front!" << std::endl;
1314 for(
auto roToMerge = mergestart; roToMerge != nomerge; ++roToMerge) {
1317 if( !thefront.
ecalclusters.empty() && !roToMerge->ecalclusters.empty() ) {
1318 if( thefront.
ecalclusters.front().first->clusterRef()->layer() !=
1319 roToMerge->ecalclusters.front().first->clusterRef()->layer() ) {
1320 LOGWARN(
"PFEGammaAlgo::mergeROsByAnyLink")
1321 <<
"Tried to merge EB and EE clusters! Skipping!";
1322 ROs.push_back(*roToMerge);
1328 roToMerge->ecalclusters.begin(),
1329 roToMerge->ecalclusters.end());
1330 thefront.
ecal2ps.insert(roToMerge->ecal2ps.begin(),
1331 roToMerge->ecal2ps.end());
1333 roToMerge->secondaryKFs.begin(),
1334 roToMerge->secondaryKFs.end());
1337 roToMerge->localMap.begin(),
1338 roToMerge->localMap.end());
1340 if( !thefront.
parentSC && roToMerge->parentSC ) {
1341 thefront.
parentSC = roToMerge->parentSC;
1344 roToMerge->electronSeed.isNonnull() ) {
1347 roToMerge->primaryGSFs.begin(),
1348 roToMerge->primaryGSFs.end());
1350 roToMerge->primaryKFs.begin(),
1351 roToMerge->primaryKFs.end());
1353 roToMerge->brems.begin(),
1354 roToMerge->brems.end());
1357 thefront.
firstBrem = roToMerge->firstBrem;
1358 thefront.
lateBrem = roToMerge->lateBrem;
1360 roToMerge->electronSeed.isNonnull()) {
1361 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink")
1362 <<
"Need to implement proper merging of two gsf candidates!" 1366 ROs.erase(mergestart,nomerge);
1368 ROs.push_back(ROs.front());
1371 check_for_merge =
false;
1374 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink()")
1375 <<
"After merging by links there are: " << ROs.size()
1376 <<
" refinable EGamma objects!" << std::endl;
1394 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::TRACK>
1397 auto notlinked = std::partition(KFbegin,KFend,gsfTrackToKFs);
1399 for(
auto kft = KFbegin; kft != notlinked; ++kft ) {
1406 kft->second =
false;
1408 RO.
localMap.emplace_back(seedtk,elemaskf);
1409 RO.
localMap.emplace_back(elemaskf,seedtk);
1410 }
else if ( elemaskf->
trackType(convType) ) {
1411 kft->second =
false;
1413 RO.
localMap.emplace_back(seedtk,elemaskf);
1414 RO.
localMap.emplace_back(elemaskf,seedtk);
1431 throw cms::Exception(
"PFEGammaAlgo::linkRefinableObjectPrimaryKFsToSecondaryKFs()")
1432 <<
"A KF track from conversion has been assigned as a primary!!" 1435 NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::TRACK,true>
1438 auto notlinked = std::partition(KFbegin,KFend,kfTrackToKFs);
1440 for(
auto kft = KFbegin; kft != notlinked; ++kft ) {
1446 kft->second =
false;
1448 RO.
localMap.emplace_back(primkf,elemaskf);
1449 RO.
localMap.emplace_back(elemaskf,primkf);
1465 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::ECAL>
1467 auto eoverp_test = std::bind(compatibleEoPOut, _1, primgsf.first);
1469 auto notmatched_blk = std::partition(ECALbegin,ECALend,gsfTracksToECALs);
1470 notmatched_blk = std::partition(ECALbegin,notmatched_blk,eoverp_test);
1472 auto notmatched_sc = std::partition(RO.
ecalclusters.begin(),
1475 notmatched_sc = std::partition(RO.
ecalclusters.begin(),
1483 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1484 <<
"Found a cluster already in RO by GSF extrapolation" 1485 <<
" at ECAL surface!" << std::endl
1486 << *elemascluster << std::endl;
1488 RO.
localMap.emplace_back(primgsf.first,temp.first);
1489 RO.
localMap.emplace_back(temp.first,primgsf.first);
1492 for(
auto ecal = ECALbegin;
ecal != notmatched_blk; ++
ecal ) {
1495 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1496 <<
"Found a cluster not already in RO by GSF extrapolation" 1497 <<
" at ECAL surface!" << std::endl
1498 << *elemascluster << std::endl;
1499 if( addPFClusterToROSafe(elemascluster,RO) ) {
1501 RO.
localMap.emplace_back(primgsf.first,elemascluster);
1502 RO.
localMap.emplace_back(elemascluster,primgsf.first);
1503 ecal->second =
false;
1516 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::HCAL>
1518 auto notmatched = std::partition(HCALbegin,HCALend,gsfTracksToHCALs);
1519 for(
auto hcal = HCALbegin;
hcal != notmatched; ++
hcal ) {
1523 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1524 <<
"Found an HCAL cluster associated to GSF extrapolation" 1527 RO.
localMap.emplace_back(primgsf.first,temp.first);
1528 RO.
localMap.emplace_back(temp.first,primgsf.first);
1529 hcal->second =
false;
1545 std::vector<PFClusterFlaggedElement>& currentECAL = RO.
ecalclusters;
1548 NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::ECAL>
1550 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::ECAL>
1553 auto notmatched_sc = std::partition(currentECAL.begin(),
1557 notmatched_sc = std::partition(currentECAL.begin(),
1560 for(
auto ecalitr = currentECAL.begin(); ecalitr != notmatched_sc;
1566 LOGDRESSED(
"PFEGammaAlgo::linkKFTracktoECAL()")
1567 <<
"Found a cluster already in RO by KF extrapolation" 1568 <<
" at ECAL surface!" << std::endl
1569 << *elemascluster << std::endl;
1570 RO.
localMap.emplace_back(elemascluster,kfflagged.first);
1571 RO.
localMap.emplace_back(kfflagged.first,elemascluster);
1574 auto notmatched_blk = std::partition(ECALbegin,ECALend,kfTrackToECALs);
1576 notmatched_blk = std::partition(ECALbegin,notmatched_blk,kfTrackGSFToECALs);
1577 for(
auto ecalitr = ECALbegin; ecalitr != notmatched_blk; ++ecalitr ) {
1580 if( addPFClusterToROSafe(elemascluster,RO) ) {
1582 ecalitr->second =
false;
1584 LOGDRESSED(
"PFEGammaAlgo::linkKFTracktoECAL()")
1585 <<
"Found a cluster not in RO by KF extrapolation" 1586 <<
" at ECAL surface!" << std::endl
1587 << *elemascluster << std::endl;
1588 RO.
localMap.emplace_back(elemascluster,kfflagged.first);
1589 RO.
localMap.emplace_back(kfflagged.first,elemascluster);
1596 if( RO.
brems.empty() )
return;
1599 int lastBremTrajPos = -1;
1600 for(
auto& bremflagged : RO.
brems ) {
1601 bool has_clusters =
false;
1602 TrajPos = (bremflagged.first->indTrajPoint())-2;
1605 NotCloserToOther<reco::PFBlockElement::BREM,reco::PFBlockElement::ECAL>
1610 auto notmatched_rsc = std::partition(RSCBegin,RSCEnd,BremToECALs);
1611 for(
auto ecal = RSCBegin;
ecal != notmatched_rsc; ++
ecal ) {
1613 std::abs(
ecal->first->clusterRef()->positionREP().eta() -
1614 bremflagged.first->positionAtECALEntrance().eta() );
1615 if( deta < 0.015 ) {
1616 has_clusters =
true;
1617 if( lastBremTrajPos == -1 || lastBremTrajPos < TrajPos ) {
1618 lastBremTrajPos = TrajPos;
1620 if( FirstBrem == -1 || TrajPos < FirstBrem ) {
1621 FirstBrem = TrajPos;
1625 <<
"Found a cluster already in SC linked to brem extrapolation" 1626 <<
" at ECAL surface!" << std::endl;
1627 RO.
localMap.emplace_back(
ecal->first,bremflagged.first);
1628 RO.
localMap.emplace_back(bremflagged.first,
ecal->first);
1632 auto notmatched_block = std::partition(ECALbegin,ECALend,BremToECALs);
1633 for(
auto ecal = ECALbegin;
ecal != notmatched_block; ++
ecal ) {
1635 std::abs(
ecal->first->clusterRef()->positionREP().eta() -
1636 bremflagged.first->positionAtECALEntrance().eta() );
1637 if( deta < 0.015 ) {
1638 has_clusters =
true;
1639 if( lastBremTrajPos == -1 || lastBremTrajPos < TrajPos ) {
1640 lastBremTrajPos = TrajPos;
1642 if( FirstBrem == -1 || TrajPos < FirstBrem ) {
1644 FirstBrem = TrajPos;
1649 if( addPFClusterToROSafe(elemasclus,RO) ) {
1652 RO.
localMap.emplace_back(
ecal->first,bremflagged.first);
1653 RO.
localMap.emplace_back(bremflagged.first,
ecal->first);
1654 ecal->second =
false;
1656 <<
"Found a cluster not already associated by brem extrapolation" 1657 <<
" at ECAL surface!" << std::endl;
1675 auto ronotconv = std::partition(BeginROskfs,EndROskfs,isConversionTrack);
1677 for(
size_t idx = 0;
idx < convkfs_end; ++
idx ) {
1678 const std::vector<PFKFFlaggedElement>& secKFs = RO.
secondaryKFs;
1683 auto notmatched = std::partition(KFbegin,KFend,TracksToTracks);
1684 notmatched = std::partition(KFbegin,notmatched,isConversionTrack);
1685 for(
auto kf = KFbegin; kf != notmatched; ++kf ) {
1689 RO.
localMap.emplace_back(secKFs[
idx].first,kf->first);
1690 RO.
localMap.emplace_back(kf->first,secKFs[
idx].first);
1706 auto notmatchedkf = std::partition(KFbegin,KFend,ECALToTracks);
1707 auto notconvkf = std::partition(KFbegin,notmatchedkf,isConversionTrack);
1709 for(
auto kf = KFbegin; kf != notconvkf; ++kf ) {
1718 for(
auto kf = notconvkf; kf != notmatchedkf; ++kf ) {
1721 kf->first->
index());
1745 auto notmatched = std::partition(ECALbegin,ECALend,TracksToECALwithCut);
1746 for(
auto ecal = ECALbegin;
ecal != notmatched; ++
ecal ) {
1749 if( addPFClusterToROSafe(elemascluster,RO) ) {
1751 RO.
localMap.emplace_back(skf.first,elemascluster);
1752 RO.
localMap.emplace_back(elemascluster,skf.first);
1753 ecal->second =
false;
1761 const std::list<PFEGammaAlgo::ProtoEGObject>& ROs,
1768 egcands.reserve(ROs.size());
1769 egxs.reserve(ROs.size());
1771 for(
auto& RO : ROs ) {
1772 if( RO.ecalclusters.empty() &&
1777 if( !RO.primaryGSFs.empty() || !RO.primaryKFs.empty() ) {
1782 if( !RO.primaryKFs.empty() ) {
1783 cand.
setCharge(RO.primaryKFs[0].first->trackRef()->charge());
1785 cand.
setTrackRef(RO.primaryKFs[0].first->trackRef());
1788 if( !RO.primaryGSFs.empty() ) {
1789 cand.
setCharge(RO.primaryGSFs[0].first->GsftrackRef()->chargeMode());
1802 for(
const auto& bremflagged : RO.brems ) {
1807 for(
const auto&
ecal : RO.ecalclusters ) {
1810 if( RO.ecal2ps.count(clus) ) {
1811 for(
auto& ps : RO.ecal2ps.at(clus) ) {
1818 for(
const auto& secdkf : RO.secondaryKFs ) {
1822 bool no_conv_ref =
true;
1823 for(
const auto& convref : convrefs ) {
1824 if( convref.isNonnull() && convref.isAvailable() ) {
1826 no_conv_ref =
false;
1833 const auto &mvavalmapped = RO.singleLegConversionMvaMap.find(kf);
1836 float mvaval = ( mvavalmapped != RO.singleLegConversionMvaMap.end() ?
1837 mvavalmapped->second :
1850 float trkTime = 0, trkTimeErr = -1;
1851 if (!RO.primaryGSFs.empty() && RO.primaryGSFs[0].first->isTimeValid()) {
1852 trkTime = RO.primaryGSFs[0].first->time();
1853 trkTimeErr = RO.primaryGSFs[0].first->timeError();
1854 }
else if (!RO.primaryKFs.empty() && RO.primaryKFs[0].first->isTimeValid()) {
1855 trkTime = RO.primaryKFs[0].first->time();
1856 trkTimeErr = RO.primaryKFs[0].first->timeError();
1858 if (trkTimeErr >= 0) {
1859 cand.
setTime( trkTime, trkTimeErr );
1867 const double scE = the_sc.
energy();
1871 egDir = egDir.Unit();
1880 !RO.primaryGSFs.empty() ) {
1884 gref->pzMode(),gref->pMode());
1888 !RO.primaryKFs.empty() ) {
1898 xtra.
setMVA(eleMVAValue);
1900 egcands.push_back(cand);
1901 egxs.push_back(xtra);
1922 const double eInGsf = std::hypot(refGsf->pMode(),mEl);
1923 double dEtGsfEcal = 1e6;
1925 const double eneHcalGsf = std::accumulate(
1930 {
return a +
b.first->clusterRef()->energy(); }
1934 refKf = ro.
primaryKFs.front().first->trackRef();
1936 const double eOutGsf = gsfElement->
Pout().t();
1938 double firstEcalGsfEnergy {0.0};
1939 double otherEcalGsfEnergy {0.0};
1940 double ecalBremEnergy {0.0};
1942 std::vector<const reco::PFCluster*> gsfCluster;
1945 const double cenergy =
ecal.first->clusterRef()->correctedEnergy();
1950 bool hasbrem =
false;
1951 for(
const auto& brem : ro.
brems )
1961 ecalBremEnergy += cenergy;
1965 if( hasgsf ) otherEcalGsfEnergy += cenergy;
1966 if( haskf ) ecalBremEnergy += cenergy;
1967 if( !(hasgsf || haskf) ) otherEcalGsfEnergy += cenergy;
1975 firstEcalGsfEnergy = cref->correctedEnergy();
1976 dEtGsfEcal = cref->positionREP().eta() - etaOutGsf;
1977 gsfCluster.push_back(cref.
get());
1983 float firstBrem {-1.0f};
1984 float earlyBrem {-1.0f};
1985 float lateBrem {-1.0f};
1989 earlyBrem = ro.
firstBrem < 4 ? 1.0f : 0.0f;
1990 lateBrem = ro.
lateBrem == 1 ? 1.0f : 0.0f;
1994 if( firstEcalGsfEnergy > 0.0 )
2000 const float ptGsf = refGsf->ptMode();
2001 const float etaGsf = refGsf->etaMode();
2003 const double ptModeErrorGsf = refGsf->ptModeError();
2004 float ptModeErrOverPtGsf = (ptModeErrorGsf > 0. ? ptModeErrorGsf/ptGsf : 1.0);
2005 float chi2Gsf = refGsf->normalizedChi2();
2006 float dPtOverPtGsf = (ptGsf - gsfElement->
Pout().pt())/ptGsf;
2008 float nHitKf = refKf.
isNonnull() ? refKf->hitPattern().trackerLayersWithMeasurement() : 0;
2009 float chi2Kf = refKf.
isNonnull() ? refKf->normalizedChi2() : -0.01;
2012 float eTotPinMode = (firstEcalGsfEnergy+otherEcalGsfEnergy+ecalBremEnergy)/ eInGsf;
2013 float eGsfPoutMode = firstEcalGsfEnergy / eOutGsf;
2014 float eTotBremPinPoutMode = (ecalBremEnergy + otherEcalGsfEnergy) / (eInGsf - eOutGsf);
2015 float dEtaGsfEcalClust =
std::abs(dEtGsfEcal);
2016 float logSigmaEtaEta =
std::log(sigmaEtaEta);
2017 float hOverHe = eneHcalGsf/(eneHcalGsf + firstEcalGsfEnergy);
2024 dPtOverPtGsf = std::clamp(dPtOverPtGsf, -0.2
f, 1.0
f);
2025 ptModeErrOverPtGsf =
std::min(ptModeErrOverPtGsf,0.3
f);
2028 eTotPinMode = std::clamp(eTotPinMode,0.0
f, 5.0
f);
2029 eGsfPoutMode = std::clamp(eGsfPoutMode,0.0
f, 5.0
f);
2030 eTotBremPinPoutMode = std::clamp(eTotBremPinPoutMode,0.0
f, 5.0
f);
2031 dEtaGsfEcalClust =
std::min(dEtaGsfEcalClust,0.1
f);
2032 logSigmaEtaEta =
std::max(logSigmaEtaEta,-14.0
f);
2065 float vars[] = {
std::log(ptGsf), etaGsf, ptModeErrOverPtGsf, dPtOverPtGsf, chi2Gsf,
2066 nHitKf, chi2Kf, eTotPinMode, eGsfPoutMode, eTotBremPinPoutMode,
2067 dEtaGsfEcalClust, logSigmaEtaEta, hOverHe, lateBrem, firstBrem };
2069 return hoc->
gbrEle_->GetAdaBoostClassifier(vars);
2086 auto notmatchedkf = std::partition(KFbegin,KFend,ECALToTracks);
2087 auto notconvkf = std::partition(KFbegin,notmatchedkf,isConversionTrack);
2089 for(
auto kf = notconvkf; kf != notmatchedkf; ++kf ) {
2109 std::vector<const reco::PFCluster*> bare_ptrs;
2112 rawSCEnergy(0), corrSCEnergy(0), corrPSEnergy(0),
2113 PS1_clus_sum(0), PS2_clus_sum(0),
2114 ePS1(0), ePS2(0), ps1_energy(0.0), ps2_energy(0.0);
2115 int condP1(1), condP2(1);
2121 edm::refToPtr<reco::PFClusterCollection>(clus.first->clusterRef());
2122 bare_ptrs.push_back(clusptr.
get());
2124 const double cluseraw = clusptr->
energy();
2127 posX += cluseraw * cluspos.X();
2128 posY += cluseraw * cluspos.Y();
2129 posZ += cluseraw * cluspos.Z();
2131 if( isEE && RO.
ecal2ps.count(clus.first)) {
2134 condP1 = condP2 = 1;
2136 const auto& psclusters = RO.
ecal2ps.at(clus.first);
2138 for(
auto i_ps = psclusters.begin(); i_ps != psclusters.end(); ++i_ps) {
2139 const PFClusterRef& psclus = i_ps->first->clusterRef();
2141 auto const& recH_Frac = psclus->recHitFractions();
2143 switch( psclus->layer() ) {
2145 for (
auto const& recH : recH_Frac){
2146 ESDetId strip1 = recH.recHitRef()->detId();
2151 if(status_p1->getStatusCode() == 0) condP1 = 0;
2156 for (
auto const& recH : recH_Frac){
2157 ESDetId strip2 = recH.recHitRef()->detId();
2160 if(status_p2->getStatusCode() == 0) condP2 = 0;
2170 {
return a + (
type == b.first->type())*b.first->clusterRef()->energy(); };
2172 PS1_clus_sum = std::accumulate(psclusters.begin(),psclusters.end(),
2174 PS2_clus_sum = std::accumulate(psclusters.begin(),psclusters.end(),
2177 if(condP1 == 1) ePS1 = -1.;
2178 if(condP2 == 1) ePS2 = -1.;
2182 PS1_clus_sum,PS2_clus_sum,
2186 if(ePS1 == -1.) ePS1 = 0;
2187 if(ePS2 == -1.) ePS2 = 0;
2189 rawSCEnergy += cluseraw;
2190 corrSCEnergy += cluscalibe;
2193 corrPSEnergy += ePS1 + ePS2;
2195 posX /= rawSCEnergy;
2196 posY /= rawSCEnergy;
2197 posZ /= rawSCEnergy;
2203 edm::refToPtr<reco::PFClusterCollection>(RO.
ecalclusters.front().
2204 first->clusterRef());
2212 edm::refToPtr<reco::PFClusterCollection>(clus.first->clusterRef());
2215 for(
auto& hit_and_fraction : hits_and_fractions ) {
2219 if( RO.
ecal2ps.count(clus.first) ) {
2220 const auto& cluspsassociation = RO.
ecal2ps.at(clus.first);
2224 for(
const auto& pscluselem : cluspsassociation ) {
2226 edm::refToPtr<reco::PFClusterCollection>(pscluselem.first->
2237 throw cms::Exception(
"PFECALSuperClusterAlgo::buildSuperCluster")
2238 <<
"Found a PS cluster matched to more than one EE cluster!" 2239 << std::endl << std::hex << psclus.
get() <<
" == " 2240 << found_pscluster->get() <<
std::dec << std::endl;
2263 const double Pin_gsf = RO.
primaryGSFs.front().first->GsftrackRef()->pMode();
2264 const double gsfOuterEta =
2265 RO.
primaryGSFs.front().first->positionAtECALEntrance().Eta();
2266 double tot_ecal= 0.0;
2267 std::vector<double> min_brem_dists;
2268 std::vector<double> closest_brem_eta;
2271 tot_ecal +=
ecal.first->clusterRef()->correctedEnergy();
2274 double min_brem_dist = 5000.0;
2275 double eta = -999.0;
2276 for(
const auto& brem : RO.
brems ) {
2278 ecal.first->index(),
2281 if( dist < min_brem_dist && dist != -1.0
f ) {
2282 min_brem_dist = dist;
2283 eta = brem.first->positionAtECALEntrance().Eta();
2286 min_brem_dists.push_back(min_brem_dist);
2287 closest_brem_eta.push_back(eta);
2295 const float secpin = secd_kf->first->trackRef()->p();
2296 bool remove_this_kf =
false;
2300 const float minbremdist = min_brem_dists[bremidx];
2301 const double ecalenergy =
ecal->first->clusterRef()->correctedEnergy();
2302 const double Epin = ecalenergy/secpin;
2303 const double detaGsf =
2304 std::abs(gsfOuterEta -
ecal->first->clusterRef()->positionREP().Eta());
2305 const double detaBrem =
2306 std::abs(closest_brem_eta[bremidx] -
2307 ecal->first->clusterRef()->positionREP().Eta());
2314 const float tkdist =
_currentblock->dist(secd_kf->first->index(),
2315 ecal->first->index(),
2322 if( Epin > 3 && kf_matched != RO.
localMap.end() &&
2323 tkdist != -1.0f && tkdist < minbremdist &&
2324 detaGsf > 0.05 && detaBrem > 0.015) {
2325 double res_with =
std::abs((tot_ecal-Pin_gsf)/Pin_gsf);
2326 double res_without =
std::abs((tot_ecal-ecalenergy-Pin_gsf)/Pin_gsf);
2327 if(res_without < res_with) {
2329 <<
" REJECTED_RES totenergy " << tot_ecal
2330 <<
" Pin_gsf " << Pin_gsf
2331 <<
" cluster to secondary " << ecalenergy
2332 <<
" res_with " << res_with
2333 <<
" res_without " << res_without << std::endl;
2334 tot_ecal -= ecalenergy;
2335 remove_this_kf =
true;
2341 if( remove_this_kf ) {
2350 bool removeFreeECAL,
2351 bool removeSCEcal) {
2352 std::vector<bool> cluster_in_sc;
2359 bool remove_this_kf =
false;
2360 NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::HCAL>
2365 const float secpin = trkRef->p();
2367 for(
auto ecal = ecal_begin;
ecal != ecal_end; ++
ecal ) {
2368 const double ecalenergy =
ecal->first->clusterRef()->correctedEnergy();
2371 if( cluster_in_sc.size() < clus_idx + 1) {
2375 ecal->first->index(),
2379 cluster_in_sc.push_back(dist != -1.0
f);
2390 if( kf_matched != RO.
localMap.end() ) {
2391 auto hcal_matched = std::partition(hcal_begin,hcal_end,tracksToHCALs);
2392 for(
auto hcalclus = hcal_begin;
2393 hcalclus != hcal_matched;
2397 const double hcalenergy = clusthcal->
clusterRef()->energy();
2398 const double hpluse = ecalenergy+hcalenergy;
2399 const bool isHoHE = ( (hcalenergy / hpluse ) > 0.1 && goodTrack );
2400 const bool isHoE = ( hcalenergy > ecalenergy );
2401 const bool isPoHE = ( secpin > hpluse );
2402 if( cluster_in_sc[clus_idx] ) {
2403 if(isHoE || isPoHE) {
2405 <<
"REJECTED TRACK FOR H/E or P/(H+E), CLUSTER IN SC" 2406 <<
" H/H+E " << (hcalenergy / hpluse)
2407 <<
" H/E " << (hcalenergy > ecalenergy)
2408 <<
" P/(H+E) " << (secpin/hpluse)
2409 <<
" HCAL ENE " << hcalenergy
2410 <<
" ECAL ENE " << ecalenergy
2411 <<
" secPIN " << secpin
2412 <<
" Algo Track " << trkRef->algo() << std::endl;
2413 remove_this_kf =
true;
2418 <<
"REJECTED TRACK FOR H/H+E, CLUSTER NOT IN SC" 2419 <<
" H/H+E " << (hcalenergy / hpluse)
2420 <<
" H/E " << (hcalenergy > ecalenergy)
2421 <<
" P/(H+E) " << (secpin/hpluse)
2422 <<
" HCAL ENE " << hcalenergy
2423 <<
" ECAL ENE " << ecalenergy
2424 <<
" secPIN " << secpin
2425 <<
" Algo Track " <<trkRef->algo() << std::endl;
2426 remove_this_kf =
true;
2432 if( remove_this_kf ) {
2443 bool isPrimary =
false;
2449 PFRecTrackRef kfPfRef_fromGsf = (*gsfPfRef).kfPFRecTrackRef();
2454 if(kfref == kfref_fromGsf)
const SuperClusterRef & superClusterRef() const
const math::XYZTLorentzVector & Pout() const
Abstract base class for a PFBlock element (track, cluster...)
const math::XYZPoint & position() const
cluster centroid position
CaloCluster_iterator preshowerClustersBegin() const
fist iterator over PreshowerCluster constituents
const reco::GsfTrackRef & GsftrackRef() const
std::vector< PFClusterFlaggedElement > ecalclusters
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
bool isNonnull() const
Checks for non-null.
void setSuperClusterRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
double correctedEnergy() const
reco::SuperClusterCollection refinedscs_
void addHitAndFraction(DetId id, float fraction)
reco::PFBlockRef parentBlock
void Dump(std::ostream &out=std::cout, const char *tab=" ") const override
print the object inside the element
void unlinkRefinableObjectKFandECALWithBadEoverP(ProtoEGObject &)
trackRef_iterator tracks_end() const
last iterator over tracks
static bool isMuon(const reco::PFBlockElement &elt)
void setPositionAtECALEntrance(const math::XYZPointF &pos)
set position at ECAL entrance
void setGsfElectronClusterRef(const reco::PFBlockRef &blk, const reco::PFBlockElementCluster &ref)
set gsf electron cluster ref
const PFClusterRef & clusterRef() const override
void addSingleLegConvTrackRefMva(const std::pair< reco::TrackRef, float > &trackrefmva)
add Single Leg Conversion TrackRef
void setPreshowerEnergyPlane2(double preshowerEnergy2)
std::pair< const PFClusterElement *, bool > PFClusterFlaggedElement
const self & getMap() const
T const * get() const
Returns C++ pointer to the item.
double y() const
y coordinate
void setHadEnergy(float val)
set the had energy. The cluster energies should be entered before
const math::XYZPointF & positionAtECALEntrance() const
std::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration
const reco::TrackRef & trackRef() const override
void Dump(std::ostream &out=std::cout, const char *tab=" ") const override
print the object inside the element
const ConversionRefVector & convRefs() const override
std::map< unsigned int, Link > LinkData
Geom::Phi< T > phi() const
double pflowPhiWidth() const
std::vector< PFClusterFlaggedElement > hcalClusters
bool isPrimaryTrack(const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
bool trackType(TrackType trType) const override
void linkRefinableObjectPrimaryGSFTrackToECAL(ProtoEGObject &)
const GsfPFRecTrackRef & GsftrackRefPF() const
const edm::OwnVector< reco::PFBlockElement > & elements() const
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
void linkRefinableObjectECALToSingleLegConv(const pfEGHelpers::HeavyObjectCache *hoc, ProtoEGObject &)
std::vector< const PFClusterElement * > electronClusters
unsigned int index
index type
const LinkData & linkData() const
std::vector< std::vector< PFFlaggedElement > > _splayedblock
void setSeed(const CaloClusterPtr &r)
list of used xtals by DetId // now inherited by CaloCluster
const math::XYZTLorentzVector & Pin() const
std::pair< const PFGSFElement *, bool > PFGSFFlaggedElement
edm::Ptr< CaloCluster > CaloClusterPtr
void linkRefinableObjectBremTangentsToECAL(ProtoEGObject &)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
const reco::Vertex * primaryVtx
unsigned int indTrajPoint() 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
std::pair< const reco::PFBlockElement *, bool > PFFlaggedElement
void setPhiWidth(double pw)
const Point & position() const
position
double pflowEtaWidth() const
std::pair< const PFSCElement *, bool > PFSCFlaggedElement
const math::XYZPointF & positionAtECALEntrance() const
void setCharge(Charge q) final
set electric charge
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void set_mva_e_pi(float mvaNI)
std::vector< PFKFFlaggedElement > secondaryKFs
static double delPhi(const double phi1, const double phi2)
void setEtaWidth(double ew)
void setSigmaEtaEta(float val)
set the sigmaetaeta
void dumpCurrentRefinableObjects() const
Container::value_type value_type
void initializeProtoCands(std::list< ProtoEGObject > &)
void linkRefinableObjectPrimaryKFsToSecondaryKFs(ProtoEGObject &)
bool unwrapSuperCluster(const reco::PFBlockElementSuperCluster *, std::vector< PFClusterFlaggedElement > &, ClusterMap &)
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
double pflowSigmaEtaEta() const
bool fromPFSuperCluster() const
void setCorrectedEnergy(double cenergy)
void addElementInBlock(const reco::PFBlockRef &blockref, unsigned elementIndex)
add an element to the current PFCandidate
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
reco::PFCluster::EEtoPSAssociation EEtoPSAssociation
PFEGammaAlgo(const PFEGConfigInfo &)
bool produceEGCandsWithNoSuperCluster
const PFSCElement * parentSC
bool trackType(TrackType trType) const override
std::vector< reco::PFCandidateEGammaExtra > PFCandidateEGammaExtraCollection
collection of PFCandidateEGammaExtras
const_iterator find(uint32_t rawId) const
std::vector< PFBremFlaggedElement > brems
void setEarlyBrem(float val)
set EarlyBrem
Abs< T >::type abs(const T &t)
double z() const
z coordinate
void setGsfTrackPout(const math::XYZTLorentzVector &pout)
set the pout (not trivial to get from the GSF track)
double energy() const
cluster energy
T const * get() const
Returns C++ pointer to the item.
std::list< ProtoEGObject > _refinableObjects
KFValMap singleLegConversionMvaMap
bool isNull() const
Checks for null.
void Dump(std::ostream &out=std::cout, const char *tab=" ") const override
print the object inside the element
reco::PFCandidateEGammaExtraCollection outcandsextra_
double energy() const
cluster energy
void linkKFTrackToECAL(const PFKFFlaggedElement &, ProtoEGObject &)
bool isNonnull() const
Checks for non-null.
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
reco::PFBlock::LinkData _currentlinks
void buildAndRefineEGObjects(const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &block)
reco::PFCluster::EEtoPSAssociation const * eetops_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
double x() const
x coordinate
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
bool isMuon(const reco::PFBlockElement &)
void fillExtraInfo(const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
float calculateEleMVA(const pfEGHelpers::HeavyObjectCache *hoc, const ProtoEGObject &, reco::PFCandidateEGammaExtra &) const
bool applyCrackCorrections
void setDeltaEta(float val)
set the delta eta
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
reco::ElectronSeedRef electronSeed
float evaluateSingleLegMVA(const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &blockref, const reco::Vertex &primaryVtx, unsigned int trackIndex)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void associatedElements(unsigned i, const LinkData &linkData, std::multimap< double, unsigned > &sortedAssociates, reco::PFBlockElement::Type type=PFBlockElement::NONE, LinkTest test=LINKTEST_RECHIT) const
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
void addConversionRef(const reco::ConversionRef &convref)
add Conversions from PF
std::vector< Item >::const_iterator const_iterator
std::vector< PFKFFlaggedElement > primaryKFs
std::unordered_map< const PFClusterElement *, std::vector< PFClusterFlaggedElement > > ClusterMap
void addCluster(const CaloClusterPtr &r)
add reference to constituent BasicCluster
void fillPFCandidates(const pfEGHelpers::HeavyObjectCache *hoc, const std::list< ProtoEGObject > &, reco::PFCandidateCollection &, reco::PFCandidateEGammaExtraCollection &)
void removeOrLinkECALClustersToKFTracks()
Particle reconstructed by the particle flow algorithm.
reco::SuperCluster buildRefinedSuperCluster(const ProtoEGObject &)
void unlinkRefinableObjectKFandECALMatchedToHCAL(ProtoEGObject &, bool removeFreeECAL=false, bool removeSCECAL=false)
std::pair< const PFKFElement *, bool > PFKFFlaggedElement
void mergeROsByAnyLink(std::list< ProtoEGObject > &)
const PFRecTrackRef & trackRefPF() const override
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
int attachPSClusters(const PFClusterElement *, ClusterMap::mapped_type &)
void linkRefinableObjectKFTracksToECAL(ProtoEGObject &)
void setKfTrackRef(const reco::TrackRef &ref)
set kf track reference
const CaloClusterPtr & seed() const
seed BasicCluster
void setMVA(float val)
set the result (mostly for debugging)
void linkRefinableObjectSecondaryKFsToECAL(ProtoEGObject &)
void setLateBrem(float val)
set LateBrem
trackRef_iterator tracks_begin() const
first iterator over tracks
void linkRefinableObjectConvSecondaryKFsToSecondaryKFs(ProtoEGObject &)
void setTrackRef(const reco::TrackRef &ref)
set track reference
reco::PFCandidateCollection outcands_
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
void setTime(float time, float timeError=0.f)
the timing information
void setPdgId(int pdgId) final
void setPreshowerEnergyPlane1(double preshowerEnergy1)
std::vector< PFGSFFlaggedElement > primaryGSFs
const std::unique_ptr< const GBRForest > gbrEle_
void setP4(const LorentzVector &p4) final
set 4-momentum
const ESChannelStatus * channelStatus_
CaloCluster_iterator preshowerClustersEnd() const
last iterator over PreshowerCluster constituents
void addExtraNonConvTrack(const reco::PFBlockRef &blk, const reco::PFBlockElementTrack &tkref)
track counting for electrons and photons
void setPreshowerEnergy(double preshowerEnergy)
const std::unique_ptr< const GBRForest > gbrSingleLeg_
void linkRefinableObjectPrimaryGSFTrackToHCAL(ProtoEGObject &)