38 #include "combination.hpp" 44 #define docast(x,y) dynamic_cast<x>(y) 45 #define LOGVERB(x) edm::LogVerbatim(x) 46 #define LOGWARN(x) edm::LogWarning(x) 47 #define LOGERR(x) edm::LogError(x) 48 #define LOGDRESSED(x) edm::LogInfo(x) 50 #define docast(x,y) reinterpret_cast<x>(y) 51 #define LOGVERB(x) LogTrace(x) 52 #define LOGWARN(x) edm::LogWarning(x) 53 #define LOGERR(x) edm::LogError(x) 54 #define LOGDRESSED(x) LogDebug(x) 64 typedef std::pair<CaloClusterPtr::key_type,CaloClusterPtr> EEtoPSElement;
72 class SeedMatchesToProtoObject {
78 if( scfromseed_.isNonnull() )
86 if( scfromseed_.isNull() || !po.
parentSC )
return false;
99 template<
bool useConvs=false>
105 const float EoPin_cut = 1.0e6) {
114 &(block->elements()[
key]));
116 const ClusterElement* elemasclus =
117 reinterpret_cast<const ClusterElement*
>(&(block->elements()[
test]));
118 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
119 float trk_pin = elemasgsf->
Pin().P();
120 if( cluster_e / trk_pin > EoPin_cut ) {
122 <<
"GSF track failed EoP cut to match with cluster!";
132 &(block->elements()[
key]));
134 const ClusterElement* elemasclus =
135 reinterpret_cast<const ClusterElement*
>(&(block->elements()[
test]));
136 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
139 if( cluster_e / trk_pin > EoPin_cut ) {
141 <<
"KF track failed EoP cut to match with cluster!";
153 if( dist == -1.0
f )
return false;
154 std::multimap<double, unsigned> dists_to_val;
155 block->associatedElements(test,block->linkData(),dists_to_val,keytype,
158 for(
const auto& valdist : dists_to_val ) {
159 const size_t idx = valdist.second;
166 &(block->elements()[
idx]));
167 if( !useConvs && elemasgsf->
trackType(ConvType) )
return false;
169 const ClusterElement* elemasclus =
170 docast(
const ClusterElement*,&(block->elements()[
test]));
171 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
172 float trk_pin = elemasgsf->
Pin().P();
173 if( cluster_e / trk_pin > EoPin_cut )
continue;
181 &(block->elements()[
idx]));
182 if( !useConvs && elemaskf->
trackType(ConvType) )
return false;
184 const ClusterElement* elemasclus =
185 reinterpret_cast<const ClusterElement*
>(&(block->elements()[
test]));
186 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
189 if( cluster_e / trk_pin > EoPin_cut )
continue;
196 if( valdist.first < dist && idx != key ) {
198 <<
"key element of type " << keytype
199 <<
" is closer to another element of type" << valtype
213 const ClusterElement* elemascluster =
docast(
const ClusterElement*,e.first);
216 return ( gsf_eta_diff <= 0.3 && cRef->energy()/comp->
Pout().t() <= 5 );
219 bool isConversionTrack(
const PFFlaggedElement& e)
231 struct NotCloserToOther {
234 const float EoPin_cut;
237 const float EoPcut=1.0e6):
comp(e),
241 bool operator () (
const PFFlaggedElement& e) {
242 if( !e.second || valtype != e.first->type() )
return false;
243 return elementNotCloserToOther<useConv>(
block,
244 keytype,comp->
index(),
245 valtype,e.first->index(),
250 struct LesserByDistance {
259 bool operator () (
const PFFlaggedElement& e1,
260 const PFFlaggedElement& e2) {
261 double dist1 = block->dist(comp->
index(),
265 double dist2 = block->dist(comp->
index(),
269 dist1 = ( dist1 == -1.0 ? 1e6 : dist1 );
270 dist2 = ( dist2 == -1.0 ? 1e6 : dist2 );
271 return dist1 < dist2;
281 <<
"cannot merge, both have GSFs!" << std::endl;
286 if(RO1.
ecalclusters.front().first->clusterRef()->layer() !=
287 RO2.
ecalclusters.front().first->clusterRef()->layer() ) {
289 <<
"cannot merge, different ECAL types!" << std::endl;
299 elementNotCloserToOther(blk,
300 cluster.first->type(),
301 cluster.first->
index(),
302 primgsf.first->type(),
303 primgsf.first->index());
306 <<
"merged by cluster to primary GSF" << std::endl;
310 <<
"cluster to primary GSF failed since" 311 <<
" cluster closer to another GSF" << std::endl;
316 elementNotCloserToOther(blk,
317 cluster.first->type(),
318 cluster.first->
index(),
319 primkf.first->type(),
320 primkf.first->index());
323 <<
"merged by cluster to primary KF" << std::endl;
329 elementNotCloserToOther(blk,
330 cluster.first->type(),
331 cluster.first->
index(),
332 secdkf.first->type(),
333 secdkf.first->index());
336 <<
"merged by cluster to secondary KF" << std::endl;
341 for(
const auto& brem : RO2.
brems ) {
342 not_closer = elementNotCloserToOther(blk,
343 cluster.first->type(),
344 cluster.first->
index(),
346 brem.first->index());
349 <<
"merged by cluster to brem KF" << std::endl;
358 elementNotCloserToOther(blk,
359 primgsf.first->type(),
360 primgsf.first->
index(),
361 secdkf.first->type(),
362 secdkf.first->index());
365 <<
"merged by GSF to secondary KF" << std::endl;
374 elementNotCloserToOther(blk,
375 primkf.first->type(),
376 primkf.first->
index(),
377 secdkf.first->type(),
378 secdkf.first->index());
381 <<
"merged by primary KF to secondary KF" << std::endl;
390 elementNotCloserToOther<true>(blk,
391 secdkf1.first->type(),
392 secdkf1.first->
index(),
393 secdkf2.first->type(),
394 secdkf2.first->index());
397 <<
"merged by secondary KF to secondary KF" << std::endl;
407 const bool result = ( isROLinkedByClusterOrTrack(comp,ro) || isROLinkedByClusterOrTrack(ro,comp) );
411 std::vector<const ClusterElement*>
413 std::vector<PFFlaggedElement>& ecals) {
414 std::vector<const ClusterElement*> cluster_list;
415 auto sccl = scref->clustersBegin();
416 auto scend = scref->clustersEnd();
417 auto pfc = ecals.begin();
418 auto pfcend = ecals.end();
419 for( ; sccl != scend; ++sccl ) {
420 std::vector<const ClusterElement*> matched_pfcs;
421 const double eg_energy = (*sccl)->energy();
423 for( pfc = ecals.begin(); pfc != pfcend; ++pfc ) {
424 const ClusterElement *pfcel =
425 docast(
const ClusterElement*, pfc->first);
430 if( matched && pfcel->clusterRef()->energy() < 1.2*scref->energy()) {
431 matched_pfcs.push_back(pfcel);
434 std::sort(matched_pfcs.begin(),matched_pfcs.end());
436 double min_residual = 1e6;
437 std::vector<const ClusterElement*> best_comb;
438 for(
size_t i = 1;
i <= matched_pfcs.size(); ++
i ) {
443 double energy = std::accumulate(matched_pfcs.begin(),
444 matched_pfcs.begin()+
i,
447 const ClusterElement*
c)
448 {
return a +
c->clusterRef()->energy(); });
449 const double resid =
std::abs(energy - eg_energy);
450 if( resid < min_residual ) {
452 best_comb.reserve(
i);
453 min_residual = resid;
454 best_comb.insert(best_comb.begin(),
455 matched_pfcs.begin(),
456 matched_pfcs.begin()+
i);
459 matched_pfcs.begin()+
i,
460 matched_pfcs.end()));
462 for(
const auto& clelem : best_comb ) {
463 if(
std::find(cluster_list.begin(),cluster_list.end(),clelem) ==
464 cluster_list.end() ) {
465 cluster_list.push_back(clelem);
471 bool addPFClusterToROSafe(
const ClusterElement*
cl,
480 if( clayer == blayer ) {
497 *kfCluster =
nullptr, *gsfCluster_noassc =
nullptr;
499 int nBremClusters = 0;
501 float mDist_gsf(maxDist), mDist_gsf_noassc(maxDist), mDist_kf(maxDist);
504 const bool hasclu = elementNotCloserToOther(parent,
507 cluster.first->type(),
508 cluster.first->index());
510 std::abs(cluster.first->clusterRef()->positionREP().eta() -
511 gsf.first->positionAtECALEntrance().eta());
514 cluster.first->clusterRef()->positionREP().phi() -
515 gsf.first->positionAtECALEntrance().phi()));
516 const float dist = std::hypot(deta,dphi);
517 if( hasclu && dist < mDist_gsf ) {
518 gsfCluster = cluster.first;
520 }
else if ( dist < mDist_gsf_noassc ) {
521 gsfCluster_noassc = cluster.first;
522 mDist_gsf_noassc = dist;
526 const bool hasclu = elementNotCloserToOther(parent,
529 cluster.first->type(),
530 cluster.first->index());
531 const float dist = parent->dist(cluster.first->index(),
535 if( hasclu && dist < mDist_kf ) {
536 kfCluster = cluster.first;
540 for(
const auto& brem : RO.
brems ) {
541 const bool hasclu = elementNotCloserToOther(parent,
544 cluster.first->type(),
545 cluster.first->index());
550 brem.first->indTrajPoint() - 2) ) {
551 firstBrem = brem.first;
554 ( lastBrem->indTrajPoint() - 2 <
555 brem.first->indTrajPoint() - 2) ) {
556 lastBrem = brem.first;
557 bremCluster = cluster.first;
562 if( !gsfCluster && !kfCluster && !bremCluster ) {
563 gsfCluster = gsfCluster_noassc;
569 }
else if ( kfCluster ) {
572 if( bremCluster && !gsfCluster && !kfCluster ) {
577 if( bremCluster == gsfCluster ) RO.
lateBrem = 1;
599 unsigned int trackIndex)
606 const float chi2 = elements[trackIndex].trackRef()->chi2()/elements[trackIndex].trackRef()->ndof();
607 const float nlost = elements[trackIndex].trackRef()->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
608 const float nLayers = elements[trackIndex].trackRef()->hitPattern().trackerLayersWithMeasurement();
609 const float trackPt = elements[trackIndex].trackRef()->pt();
610 const float stip = elements[trackIndex].trackRefPF()->STIP();
614 std::multimap<double, unsigned int> ecalAssoTrack;
619 std::multimap<double, unsigned int> hcalAssoTrack;
624 if(!ecalAssoTrack.empty())
626 for (
auto & itecal : ecalAssoTrack)
628 linkedE = linkedE+elements[itecal.second].clusterRef()->energy();
631 if(!hcalAssoTrack.empty())
633 for (
auto & ithcal : hcalAssoTrack)
635 linkedH = linkedH+elements[ithcal.second].clusterRef()->energy();
638 const float eOverPt = linkedE / elements[trackIndex].trackRef()->pt();
639 const float hOverPt = linkedH / elements[trackIndex].trackRef()->pt();
640 GlobalVector rvtx(elements[trackIndex].trackRef()->innerPosition().
X()-primaryVtx.
x(),
641 elements[trackIndex].trackRef()->innerPosition().Y()-primaryVtx.
y(),
642 elements[trackIndex].trackRef()->innerPosition().Z()-primaryVtx.
z());
643 double vtxPhi = rvtx.
phi();
645 float delPhi = fabs(
deltaPhi(vtxPhi, elements[trackIndex].trackRef()->innerMomentum().
Phi()));
648 hOverPt,
trackPt, stip, nlost };
654 switch( pfbe.
type() ) {
658 std::multimap<double,unsigned> tks;
664 for(
const auto& tk : tks ) {
683 <<
"Resetting PFEGammaAlgo for new block and running!" << std::endl;
691 LOGVERB(
"PFEGammaAlgo") <<
"Splaying block" << std::endl;
694 if(
isMuon(pfelement) )
continue;
697 const size_t itype = (size_t)pfelement.type();
704 std::stringstream splayout;
705 for(
size_t itype = 0; itype <
_splayedblock.size(); ++itype ) {
706 splayout <<
"\tType: " << itype <<
" indices: ";
708 splayout << flaggedelement.first->index() <<
' ';
710 if( itype !=
_splayedblock.size() - 1 ) splayout << std::endl;
712 LOGVERB(
"PFEGammaAlgo") << splayout.str();
749 <<
"Dumping after GSF and KF Track (Primary) Linking : " << std::endl;
756 <<
"Dumping after first merging operation : " << std::endl;
762 for(
auto& RO : _refinableObjects ) {
773 <<
"Dumping after ECAL to Track (Secondary) Linking : " << std::endl;
780 <<
"There are " << _refinableObjects.size()
781 <<
" after the 2nd merging step." << std::endl;
785 for(
auto& RO : _refinableObjects ) {
792 std::sort(RO.ecalclusters.begin(), RO.ecalclusters.end(),
795 {
return ( a.first->clusterRef()->correctedEnergy() >
796 b.first->clusterRef()->correctedEnergy() ) ; });
797 setROElectronCluster(RO);
801 <<
"There are " << _refinableObjects.size()
802 <<
" after the unlinking and vetos step." << std::endl;
817 <<
"creating SC-based proto-object" << std::endl
818 <<
"\tSC at index: " << element.first->index()
819 <<
" has type: " << element.first->type() << std::endl;
820 element.second =
false;
853 <<
"creating GSF-based proto-object" << std::endl
854 <<
"\tGSF at index: " << element.first->index()
855 <<
" has type: " << element.first->type() << std::endl;
861 element.second =
false;
876 std::stringstream gsf_err;
877 elementAsGSF->
Dump(gsf_err,
"\t");
879 <<
"Found a GSF track with no seed! This should not happen!" 880 << std::endl << gsf_err.str() << std::endl;
884 element.second =
false;
886 fromGSF.
primaryGSFs.emplace_back(elementAsGSF,
true);
893 if( dist == 0.001
f ) {
896 fromGSF.
brems.emplace_back(eAsBrem,
true);
897 fromGSF.
localMap.emplace_back(eAsBrem,elementAsGSF);
898 fromGSF.
localMap.emplace_back(elementAsGSF,eAsBrem);
909 <<
"GSF-based proto-object is ECAL driven, merging SC-cand" 916 SeedMatchesToProtoObject sctoseedmatch(fromGSF.
electronSeed);
920 auto clusmatch = std::find_if(objsbegin,objsend,sctoseedmatch);
921 if( clusmatch != objsend ) {
922 fromGSF.
parentSC = clusmatch->parentSC;
932 <<
"Encountered the known GSF-SC splitting bug " 933 <<
" in PFBlockAlgo! We should really fix this!" << std::endl;
935 std::stringstream gsf_err;
936 elementAsGSF->
Dump(gsf_err,
"\t");
938 <<
"Expected SuperCluster from ECAL driven GSF seed " 939 <<
"was not found in the block!" << std::endl
940 << gsf_err.str() << std::endl;
964 std::vector<PFClusterFlaggedElement>& ecalclusters,
966 ecalclusters.clear();
969 <<
"Pointer to SC element: 0x" 970 << std::hex << thesc <<
std::dec << std::endl
971 <<
"cleared ecalclusters and ecal2ps!" << std::endl;
976 if( ecalbegin == ecalend && hgcalbegin == hgcalend ) {
977 LOGERR(
"PFEGammaAlgo::unwrapSuperCluster()")
978 <<
"There are no ECAL elements in a block with imported SC!" 979 <<
" This is a bug we should fix this!" 987 <<
"SuperCluster pointed to by block element is null!" 991 <<
"Got a valid super cluster ref! 0x" 992 << std::hex << scref.
get() <<
std::dec << std::endl;
993 const size_t nscclusters = scref->clustersSize();
994 const size_t nscpsclusters = scref->preshowerClustersSize();
995 size_t npfpsclusters = 0;
996 size_t npfclusters = 0;
998 <<
"Precalculated cluster multiplicities: " 999 << nscclusters <<
' ' << nscpsclusters << std::endl;
1000 NotCloserToOther<reco::PFBlockElement::SC,reco::PFBlockElement::ECAL>
1002 NotCloserToOther<reco::PFBlockElement::SC,reco::PFBlockElement::HGCAL>
1004 auto ecalfirstnotinsc = std::partition(ecalbegin,ecalend,ecalClustersInSC);
1005 auto hgcalfirstnotinsc = std::partition(hgcalbegin,hgcalend,hgcalClustersInSC);
1017 if( ecalfirstnotinsc == ecalbegin &&
1018 hgcalfirstnotinsc == hgcalbegin) {
1019 LOGERR(
"PFEGammaAlgo::unwrapSuperCluster()")
1020 <<
"No associated block elements to SuperCluster!" 1021 <<
" This is a bug we should fix!" 1028 if( is_pf_sc && nscclusters != npfclusters ) {
1029 std::stringstream sc_err;
1030 thesc->
Dump(sc_err,
"\t");
1032 <<
"The number of found ecal elements (" 1033 << nscclusters <<
") in block is not the same as" 1034 <<
" the number of ecal PF clusters reported by the PFSuperCluster" 1035 <<
" itself (" << npfclusters
1036 <<
")! This should not happen!" << std::endl
1037 << sc_err.str() << std::endl;
1039 for(
auto ecalitr = ecalbegin; ecalitr != ecalfirstnotinsc; ++ecalitr ) {
1045 if(!is_pf_sc &&
std::find(safePFClusters.begin(),safePFClusters.end(),elemascluster) ==
1046 safePFClusters.end() )
continue;
1049 ecalclusters.emplace_back(elemascluster,
true);
1051 ecalitr->second =
false;
1055 auto emplaceresult = ecal2ps.emplace(elemascluster,
1056 ClusterMap::mapped_type());
1057 if( !emplaceresult.second ) {
1058 std::stringstream clus_err;
1059 elemascluster->
Dump(clus_err,
"\t");
1061 <<
"List of pointers to ECAL block elements contains non-unique items!" 1062 <<
" This is very bad!" << std::endl
1063 <<
"cluster ptr = 0x" << std::hex << elemascluster <<
std::dec 1064 << std::endl << clus_err.str() << std::endl;
1066 ClusterMap::mapped_type& eslist = emplaceresult.first->second;
1070 for(
auto hgcalitr = hgcalbegin; hgcalitr != hgcalfirstnotinsc; ++hgcalitr ) {
1076 if(!is_pf_sc &&
std::find(safePFClusters.begin(),safePFClusters.end(),elemascluster) ==
1077 safePFClusters.end() )
continue;
1080 ecalclusters.emplace_back(elemascluster,
true);
1082 hgcalitr->second =
false;
1100 <<
" Unwrapped SC has " << npfclusters <<
" ECAL sub-clusters" 1101 <<
" and " << npfpsclusters <<
" PreShower layers 1 & 2 clusters!" 1108 ClusterMap::mapped_type& eslist) {
1111 EEtoPSElement ecalkey(clusptr.
key(),clusptr);
1112 auto assc_ps = std::equal_range(
eetops_->cbegin(),
1115 [](
const EEtoPSElement&
a,
const EEtoPSElement&
b){
return a.first <
b.first;});
1118 for(
auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl ) {
1119 if( pscl->second == temp ) {
1120 const ClusterElement* pstemp =
1121 docast(
const ClusterElement*,ps1.first);
1122 eslist.emplace_back(pstemp,
true);
1128 for(
auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl ) {
1129 if( pscl->second == temp ) {
1130 const ClusterElement* pstemp =
1131 docast(
const ClusterElement*,ps2.first);
1132 eslist.emplace_back(pstemp,
true);
1136 return eslist.size();
1144 <<
" refinable objects for this block: " << std::endl;
1146 std::stringstream
info;
1147 info <<
"Refinable Object:" << std::endl;
1149 info <<
"\tSuperCluster element attached to object:" << std::endl
1151 ro.parentSC->Dump(info,
"\t");
1154 if( ro.electronSeed.isNonnull() ) {
1155 info <<
"\tGSF element attached to object:" << std::endl;
1156 ro.primaryGSFs.front().first->Dump(info,
"\t");
1158 info <<
"firstBrem : " << ro.firstBrem
1159 <<
" lateBrem : " << ro.lateBrem
1160 <<
" nBrems with cluster : " << ro.nBremsWithClusters
1162 if( ro.electronClusters.size() && ro.electronClusters[0] ) {
1163 info <<
"electron cluster : ";
1164 ro.electronClusters[0]->Dump(info,
"\t");
1167 info <<
" no electron cluster." << std::endl;
1170 if( ro.primaryKFs.size() ) {
1171 info <<
"\tPrimary KF tracks attached to object: " << std::endl;
1172 for(
const auto& kf : ro.primaryKFs ) {
1173 kf.first->Dump(info,
"\t");
1177 if( ro.secondaryKFs.size() ) {
1178 info <<
"\tSecondary KF tracks attached to object: " << std::endl;
1179 for(
const auto& kf : ro.secondaryKFs ) {
1180 kf.first->Dump(info,
"\t");
1184 if( ro.brems.size() ) {
1185 info <<
"\tBrem tangents attached to object: " << std::endl;
1186 for(
const auto& brem : ro.brems ) {
1187 brem.first->Dump(info,
"\t");
1191 if( ro.ecalclusters.size() ) {
1192 info <<
"\tECAL clusters attached to object: " << std::endl;
1193 for(
const auto& clus : ro.ecalclusters ) {
1194 clus.first->Dump(info,
"\t");
1196 if( ro.ecal2ps.find(clus.first) != ro.ecal2ps.end() ) {
1197 for(
const auto& psclus : ro.ecal2ps.at(clus.first) ) {
1198 info <<
"\t\t Attached PS Cluster: ";
1199 psclus.first->Dump(info,
"");
1213 typedef std::multimap<double, unsigned> MatchedMap;
1217 MatchedMap matchedGSFs, matchedECALs;
1218 std::unordered_map<GsfTrackElementPtr,MatchedMap> gsf_ecal_cache;
1220 matchedGSFs.clear();
1225 if( matchedGSFs.empty() ) {
1230 std::partial_sort(ecalbegin,ecalbegin+1,ecalend,closestTrackToECAL);
1233 const float dist =
_currentblock->dist(kftrack.first->index(),
1234 closestECAL.first->index(),
1240 closestECAL.first->index(),
1243 if( dist_sc != -1.0
f) { inSC =
true;
break; }
1246 if( dist != -1.0
f && closestECAL.second ) {
1247 bool gsflinked =
false;
1249 for(
const auto& gsfflag :
_splayedblock[reco::PFBlockElement::GSF]) {
1256 if( !gsf_ecal_cache.count(elemasgsf) ) {
1257 matchedECALs.clear();
1262 gsf_ecal_cache.emplace(elemasgsf,matchedECALs);
1263 MatchedMap().swap(matchedECALs);
1265 const MatchedMap& ecal_matches = gsf_ecal_cache[elemasgsf];
1266 if( !ecal_matches.empty() ) {
1267 if( ecal_matches.begin()->second == closestECAL.first->index() ) {
1273 if( !gsflinked && !inSC) {
1280 trackref->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1281 bool fromprimaryvertex =
false;
1285 fromprimaryvertex =
true;
1291 closestECAL.second =
false;
1301 if( ROs.size() < 2 )
return;
1302 bool check_for_merge =
true;
1303 while( check_for_merge ) {
1308 for(
auto it1 = ROs.begin(); it1 != ROs.end(); ++it1 ) {
1309 auto find_start = it1; ++find_start;
1310 auto has_merge = std::find_if(find_start,ROs.end(),
1311 std::bind(testIfROMergableByLink, _1, *it1));
1312 if( has_merge != ROs.end() && it1 != ROs.begin() ) {
1318 auto mergestart = ROs.begin(); ++mergestart;
1319 auto nomerge = std::partition(mergestart,ROs.end(),
1320 std::bind(testIfROMergableByLink, _1, thefront));
1321 if( nomerge != mergestart ) {
1322 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink()")
1324 <<
" to merge by links to the front!" << std::endl;
1325 for(
auto roToMerge = mergestart; roToMerge != nomerge; ++roToMerge) {
1328 if( !thefront.
ecalclusters.empty() && !roToMerge->ecalclusters.empty() ) {
1329 if( thefront.
ecalclusters.front().first->clusterRef()->layer() !=
1330 roToMerge->ecalclusters.front().first->clusterRef()->layer() ) {
1331 LOGWARN(
"PFEGammaAlgo::mergeROsByAnyLink")
1332 <<
"Tried to merge EB and EE clusters! Skipping!";
1333 ROs.push_back(*roToMerge);
1339 roToMerge->ecalclusters.begin(),
1340 roToMerge->ecalclusters.end());
1341 thefront.
ecal2ps.insert(roToMerge->ecal2ps.begin(),
1342 roToMerge->ecal2ps.end());
1344 roToMerge->secondaryKFs.begin(),
1345 roToMerge->secondaryKFs.end());
1348 roToMerge->localMap.begin(),
1349 roToMerge->localMap.end());
1351 if( !thefront.
parentSC && roToMerge->parentSC ) {
1352 thefront.
parentSC = roToMerge->parentSC;
1355 roToMerge->electronSeed.isNonnull() ) {
1358 roToMerge->primaryGSFs.begin(),
1359 roToMerge->primaryGSFs.end());
1361 roToMerge->primaryKFs.begin(),
1362 roToMerge->primaryKFs.end());
1364 roToMerge->brems.begin(),
1365 roToMerge->brems.end());
1368 thefront.
firstBrem = roToMerge->firstBrem;
1369 thefront.
lateBrem = roToMerge->lateBrem;
1371 roToMerge->electronSeed.isNonnull()) {
1372 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink")
1373 <<
"Need to implement proper merging of two gsf candidates!" 1377 ROs.erase(mergestart,nomerge);
1379 ROs.push_back(ROs.front());
1382 check_for_merge =
false;
1385 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink()")
1386 <<
"After merging by links there are: " << ROs.size()
1387 <<
" refinable EGamma objects!" << std::endl;
1405 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::TRACK>
1408 auto notlinked = std::partition(KFbegin,KFend,gsfTrackToKFs);
1410 for(
auto kft = KFbegin; kft != notlinked; ++kft ) {
1417 kft->second =
false;
1419 RO.
localMap.emplace_back(seedtk,elemaskf);
1420 RO.
localMap.emplace_back(elemaskf,seedtk);
1421 }
else if ( elemaskf->
trackType(convType) ) {
1422 kft->second =
false;
1424 RO.
localMap.emplace_back(seedtk,elemaskf);
1425 RO.
localMap.emplace_back(elemaskf,seedtk);
1442 throw cms::Exception(
"PFEGammaAlgo::linkRefinableObjectPrimaryKFsToSecondaryKFs()")
1443 <<
"A KF track from conversion has been assigned as a primary!!" 1446 NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::TRACK,true>
1449 auto notlinked = std::partition(KFbegin,KFend,kfTrackToKFs);
1451 for(
auto kft = KFbegin; kft != notlinked; ++kft ) {
1457 kft->second =
false;
1459 RO.
localMap.emplace_back(primkf,elemaskf);
1460 RO.
localMap.emplace_back(elemaskf,primkf);
1476 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::ECAL>
1478 auto eoverp_test = std::bind(compatibleEoPOut, _1, primgsf.first);
1480 auto notmatched_blk = std::partition(ECALbegin,ECALend,gsfTracksToECALs);
1481 notmatched_blk = std::partition(ECALbegin,notmatched_blk,eoverp_test);
1483 auto notmatched_sc = std::partition(RO.
ecalclusters.begin(),
1486 notmatched_sc = std::partition(RO.
ecalclusters.begin(),
1494 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1495 <<
"Found a cluster already in RO by GSF extrapolation" 1496 <<
" at ECAL surface!" << std::endl
1497 << *elemascluster << std::endl;
1499 RO.
localMap.emplace_back(primgsf.first,temp.first);
1500 RO.
localMap.emplace_back(temp.first,primgsf.first);
1503 for(
auto ecal = ECALbegin;
ecal != notmatched_blk; ++
ecal ) {
1506 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1507 <<
"Found a cluster not already in RO by GSF extrapolation" 1508 <<
" at ECAL surface!" << std::endl
1509 << *elemascluster << std::endl;
1510 if( addPFClusterToROSafe(elemascluster,RO) ) {
1512 RO.
localMap.emplace_back(primgsf.first,elemascluster);
1513 RO.
localMap.emplace_back(elemascluster,primgsf.first);
1514 ecal->second =
false;
1527 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::HCAL>
1529 auto notmatched = std::partition(HCALbegin,HCALend,gsfTracksToHCALs);
1530 for(
auto hcal = HCALbegin;
hcal != notmatched; ++
hcal ) {
1534 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1535 <<
"Found an HCAL cluster associated to GSF extrapolation" 1538 RO.
localMap.emplace_back(primgsf.first,temp.first);
1539 RO.
localMap.emplace_back(temp.first,primgsf.first);
1540 hcal->second =
false;
1556 std::vector<PFClusterFlaggedElement>& currentECAL = RO.
ecalclusters;
1559 NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::ECAL>
1561 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::ECAL>
1564 auto notmatched_sc = std::partition(currentECAL.begin(),
1568 notmatched_sc = std::partition(currentECAL.begin(),
1571 for(
auto ecalitr = currentECAL.begin(); ecalitr != notmatched_sc;
1577 LOGDRESSED(
"PFEGammaAlgo::linkKFTracktoECAL()")
1578 <<
"Found a cluster already in RO by KF extrapolation" 1579 <<
" at ECAL surface!" << std::endl
1580 << *elemascluster << std::endl;
1581 RO.
localMap.emplace_back(elemascluster,kfflagged.first);
1582 RO.
localMap.emplace_back(kfflagged.first,elemascluster);
1585 auto notmatched_blk = std::partition(ECALbegin,ECALend,kfTrackToECALs);
1587 notmatched_blk = std::partition(ECALbegin,notmatched_blk,kfTrackGSFToECALs);
1588 for(
auto ecalitr = ECALbegin; ecalitr != notmatched_blk; ++ecalitr ) {
1591 if( addPFClusterToROSafe(elemascluster,RO) ) {
1593 ecalitr->second =
false;
1595 LOGDRESSED(
"PFEGammaAlgo::linkKFTracktoECAL()")
1596 <<
"Found a cluster not in RO by KF extrapolation" 1597 <<
" at ECAL surface!" << std::endl
1598 << *elemascluster << std::endl;
1599 RO.
localMap.emplace_back(elemascluster,kfflagged.first);
1600 RO.
localMap.emplace_back(kfflagged.first,elemascluster);
1607 if( RO.
brems.empty() )
return;
1610 int lastBremTrajPos = -1;
1611 for(
auto& bremflagged : RO.
brems ) {
1612 bool has_clusters =
false;
1613 TrajPos = (bremflagged.first->indTrajPoint())-2;
1616 NotCloserToOther<reco::PFBlockElement::BREM,reco::PFBlockElement::ECAL>
1621 auto notmatched_rsc = std::partition(RSCBegin,RSCEnd,BremToECALs);
1622 for(
auto ecal = RSCBegin;
ecal != notmatched_rsc; ++
ecal ) {
1624 std::abs(
ecal->first->clusterRef()->positionREP().eta() -
1625 bremflagged.first->positionAtECALEntrance().eta() );
1626 if( deta < 0.015 ) {
1627 has_clusters =
true;
1628 if( lastBremTrajPos == -1 || lastBremTrajPos < TrajPos ) {
1629 lastBremTrajPos = TrajPos;
1631 if( FirstBrem == -1 || TrajPos < FirstBrem ) {
1632 FirstBrem = TrajPos;
1636 <<
"Found a cluster already in SC linked to brem extrapolation" 1637 <<
" at ECAL surface!" << std::endl;
1638 RO.
localMap.emplace_back(
ecal->first,bremflagged.first);
1639 RO.
localMap.emplace_back(bremflagged.first,
ecal->first);
1643 auto notmatched_block = std::partition(ECALbegin,ECALend,BremToECALs);
1644 for(
auto ecal = ECALbegin;
ecal != notmatched_block; ++
ecal ) {
1646 std::abs(
ecal->first->clusterRef()->positionREP().eta() -
1647 bremflagged.first->positionAtECALEntrance().eta() );
1648 if( deta < 0.015 ) {
1649 has_clusters =
true;
1650 if( lastBremTrajPos == -1 || lastBremTrajPos < TrajPos ) {
1651 lastBremTrajPos = TrajPos;
1653 if( FirstBrem == -1 || TrajPos < FirstBrem ) {
1655 FirstBrem = TrajPos;
1660 if( addPFClusterToROSafe(elemasclus,RO) ) {
1663 RO.
localMap.emplace_back(
ecal->first,bremflagged.first);
1664 RO.
localMap.emplace_back(bremflagged.first,
ecal->first);
1665 ecal->second =
false;
1667 <<
"Found a cluster not already associated by brem extrapolation" 1668 <<
" at ECAL surface!" << std::endl;
1686 auto ronotconv = std::partition(BeginROskfs,EndROskfs,isConversionTrack);
1688 for(
size_t idx = 0;
idx < convkfs_end; ++
idx ) {
1689 const std::vector<PFKFFlaggedElement>& secKFs = RO.
secondaryKFs;
1694 auto notmatched = std::partition(KFbegin,KFend,TracksToTracks);
1695 notmatched = std::partition(KFbegin,notmatched,isConversionTrack);
1696 for(
auto kf = KFbegin; kf != notmatched; ++kf ) {
1700 RO.
localMap.emplace_back(secKFs[
idx].first,kf->first);
1701 RO.
localMap.emplace_back(kf->first,secKFs[
idx].first);
1717 auto notmatchedkf = std::partition(KFbegin,KFend,ECALToTracks);
1718 auto notconvkf = std::partition(KFbegin,notmatchedkf,isConversionTrack);
1720 for(
auto kf = KFbegin; kf != notconvkf; ++kf ) {
1729 for(
auto kf = notconvkf; kf != notmatchedkf; ++kf ) {
1732 kf->first->
index());
1756 auto notmatched = std::partition(ECALbegin,ECALend,TracksToECALwithCut);
1757 for(
auto ecal = ECALbegin;
ecal != notmatched; ++
ecal ) {
1760 if( addPFClusterToROSafe(elemascluster,RO) ) {
1764 ecal->second =
false;
1772 const std::list<PFEGammaAlgo::ProtoEGObject>& ROs,
1779 egcands.reserve(ROs.size());
1780 egxs.reserve(ROs.size());
1782 for(
auto& RO : ROs ) {
1783 if( RO.ecalclusters.empty() &&
1788 if( !RO.primaryGSFs.empty() || !RO.primaryKFs.empty() ) {
1793 if( !RO.primaryKFs.empty() ) {
1794 cand.
setCharge(RO.primaryKFs[0].first->trackRef()->charge());
1796 cand.
setTrackRef(RO.primaryKFs[0].first->trackRef());
1799 if( !RO.primaryGSFs.empty() ) {
1800 cand.
setCharge(RO.primaryGSFs[0].first->GsftrackRef()->chargeMode());
1813 for(
const auto& bremflagged : RO.brems ) {
1818 for(
const auto&
ecal : RO.ecalclusters ) {
1821 if( RO.ecal2ps.count(clus) ) {
1822 for(
auto& ps : RO.ecal2ps.at(clus) ) {
1829 for(
const auto& secdkf : RO.secondaryKFs ) {
1833 bool no_conv_ref =
true;
1834 for(
const auto& convref : convrefs ) {
1835 if( convref.isNonnull() && convref.isAvailable() ) {
1837 no_conv_ref =
false;
1844 const auto &mvavalmapped = RO.singleLegConversionMvaMap.find(kf);
1847 float mvaval = ( mvavalmapped != RO.singleLegConversionMvaMap.end() ?
1848 mvavalmapped->second :
1861 float trkTime = 0, trkTimeErr = -1;
1862 if (!RO.primaryGSFs.empty() && RO.primaryGSFs[0].first->isTimeValid()) {
1863 trkTime = RO.primaryGSFs[0].first->time();
1864 trkTimeErr = RO.primaryGSFs[0].first->timeError();
1865 }
else if (!RO.primaryKFs.empty() && RO.primaryKFs[0].first->isTimeValid()) {
1866 trkTime = RO.primaryKFs[0].first->time();
1867 trkTimeErr = RO.primaryKFs[0].first->timeError();
1869 if (trkTimeErr >= 0) {
1870 cand.
setTime( trkTime, trkTimeErr );
1878 const double scE = the_sc.
energy();
1882 egDir = egDir.Unit();
1891 !RO.primaryGSFs.empty() ) {
1895 gref->pzMode(),gref->pMode());
1899 !RO.primaryKFs.empty() ) {
1909 xtra.
setMVA(eleMVAValue);
1911 egcands.push_back(cand);
1912 egxs.push_back(xtra);
1933 const double eInGsf = std::hypot(refGsf->pMode(),mEl);
1934 double dEtGsfEcal = 1e6;
1936 const double eneHcalGsf = std::accumulate(
1941 {
return a +
b.first->clusterRef()->energy(); }
1945 refKf = ro.
primaryKFs.front().first->trackRef();
1947 const double eOutGsf = gsfElement->
Pout().t();
1949 double firstEcalGsfEnergy {0.0};
1950 double otherEcalGsfEnergy {0.0};
1951 double ecalBremEnergy {0.0};
1953 std::vector<const reco::PFCluster*> gsfCluster;
1956 const double cenergy =
ecal.first->clusterRef()->correctedEnergy();
1961 bool hasbrem =
false;
1962 for(
const auto& brem : ro.
brems )
1972 ecalBremEnergy += cenergy;
1976 if( hasgsf ) otherEcalGsfEnergy += cenergy;
1977 if( haskf ) ecalBremEnergy += cenergy;
1978 if( !(hasgsf || haskf) ) otherEcalGsfEnergy += cenergy;
1986 firstEcalGsfEnergy = cref->correctedEnergy();
1987 dEtGsfEcal = cref->positionREP().eta() - etaOutGsf;
1988 gsfCluster.push_back(&*cref);
1994 float firstBrem {-1.0f};
1995 float earlyBrem {-1.0f};
1996 float lateBrem {-1.0f};
2000 earlyBrem = ro.
firstBrem < 4 ? 1.0f : 0.0f;
2001 lateBrem = ro.
lateBrem == 1 ? 1.0f : 0.0f;
2005 if( firstEcalGsfEnergy > 0.0 )
2011 const float ptGsf = refGsf->ptMode();
2012 const float etaGsf = refGsf->etaMode();
2014 const double ptModeErrorGsf = refGsf->ptModeError();
2015 float ptModeErrOverPtGsf = (ptModeErrorGsf > 0. ? ptModeErrorGsf/ptGsf : 1.0);
2016 float chi2Gsf = refGsf->normalizedChi2();
2017 float dPtOverPtGsf = (ptGsf - gsfElement->
Pout().pt())/ptGsf;
2019 float nHitKf = refKf.
isNonnull() ? refKf->hitPattern().trackerLayersWithMeasurement() : 0;
2020 float chi2Kf = refKf.
isNonnull() ? refKf->normalizedChi2() : -0.01;
2023 float eTotPinMode = (firstEcalGsfEnergy+otherEcalGsfEnergy+ecalBremEnergy)/ eInGsf;
2024 float eGsfPoutMode = firstEcalGsfEnergy / eOutGsf;
2025 float eTotBremPinPoutMode = (ecalBremEnergy + otherEcalGsfEnergy) / (eInGsf - eOutGsf);
2026 float dEtaGsfEcalClust =
std::abs(dEtGsfEcal);
2027 float logSigmaEtaEta =
std::log(sigmaEtaEta);
2028 float hOverHe = eneHcalGsf/(eneHcalGsf + firstEcalGsfEnergy);
2035 dPtOverPtGsf = std::clamp(dPtOverPtGsf, -0.2
f, 1.0
f);
2036 ptModeErrOverPtGsf =
std::min(ptModeErrOverPtGsf,0.3
f);
2039 eTotPinMode = std::clamp(eTotPinMode,0.0
f, 5.0
f);
2040 eGsfPoutMode = std::clamp(eGsfPoutMode,0.0
f, 5.0
f);
2041 eTotBremPinPoutMode = std::clamp(eTotBremPinPoutMode,0.0
f, 5.0
f);
2042 dEtaGsfEcalClust =
std::min(dEtaGsfEcalClust,0.1
f);
2043 logSigmaEtaEta =
std::max(logSigmaEtaEta,-14.0
f);
2076 float vars[] = {
std::log(ptGsf), etaGsf, ptModeErrOverPtGsf, dPtOverPtGsf, chi2Gsf,
2077 nHitKf, chi2Kf, eTotPinMode, eGsfPoutMode, eTotBremPinPoutMode,
2078 dEtaGsfEcalClust, logSigmaEtaEta, hOverHe, lateBrem, firstBrem };
2080 return hoc->
gbrEle_->GetAdaBoostClassifier(vars);
2097 auto notmatchedkf = std::partition(KFbegin,KFend,ECALToTracks);
2098 auto notconvkf = std::partition(KFbegin,notmatchedkf,isConversionTrack);
2100 for(
auto kf = notconvkf; kf != notmatchedkf; ++kf ) {
2120 std::vector<const reco::PFCluster*> bare_ptrs;
2123 rawSCEnergy(0), corrSCEnergy(0), corrPSEnergy(0),
2124 PS1_clus_sum(0), PS2_clus_sum(0),
2125 ePS1(0), ePS2(0), ps1_energy(0.0), ps2_energy(0.0);
2126 int condP1(1), condP2(1);
2132 edm::refToPtr<reco::PFClusterCollection>(clus.first->clusterRef());
2133 bare_ptrs.push_back(clusptr.
get());
2135 const double cluseraw = clusptr->
energy();
2138 posX += cluseraw * cluspos.X();
2139 posY += cluseraw * cluspos.Y();
2140 posZ += cluseraw * cluspos.Z();
2142 if( isEE && RO.
ecal2ps.count(clus.first)) {
2145 condP1 = condP2 = 1;
2147 const auto& psclusters = RO.
ecal2ps.at(clus.first);
2149 for(
auto i_ps = psclusters.begin(); i_ps != psclusters.end(); ++i_ps) {
2150 const PFClusterRef& psclus = i_ps->first->clusterRef();
2152 auto const& recH_Frac = psclus->recHitFractions();
2154 switch( psclus->layer() ) {
2156 for (
auto const& recH : recH_Frac){
2157 ESDetId strip1 = recH.recHitRef()->detId();
2162 if(status_p1->getStatusCode() == 0) condP1 = 0;
2167 for (
auto const& recH : recH_Frac){
2168 ESDetId strip2 = recH.recHitRef()->detId();
2171 if(status_p2->getStatusCode() == 0) condP2 = 0;
2181 {
return a + (
type == b.first->type())*b.first->clusterRef()->energy(); };
2183 PS1_clus_sum = std::accumulate(psclusters.begin(),psclusters.end(),
2185 PS2_clus_sum = std::accumulate(psclusters.begin(),psclusters.end(),
2188 if(condP1 == 1) ePS1 = -1.;
2189 if(condP2 == 1) ePS2 = -1.;
2193 PS1_clus_sum,PS2_clus_sum,
2197 if(ePS1 == -1.) ePS1 = 0;
2198 if(ePS2 == -1.) ePS2 = 0;
2200 rawSCEnergy += cluseraw;
2201 corrSCEnergy += cluscalibe;
2204 corrPSEnergy += ePS1 + ePS2;
2206 posX /= rawSCEnergy;
2207 posY /= rawSCEnergy;
2208 posZ /= rawSCEnergy;
2214 edm::refToPtr<reco::PFClusterCollection>(RO.
ecalclusters.front().
2215 first->clusterRef());
2223 edm::refToPtr<reco::PFClusterCollection>(clus.first->clusterRef());
2226 for(
auto& hit_and_fraction : hits_and_fractions ) {
2230 if( RO.
ecal2ps.count(clus.first) ) {
2231 const auto& cluspsassociation = RO.
ecal2ps.at(clus.first);
2235 for(
const auto& pscluselem : cluspsassociation ) {
2237 edm::refToPtr<reco::PFClusterCollection>(pscluselem.first->
2248 throw cms::Exception(
"PFECALSuperClusterAlgo::buildSuperCluster")
2249 <<
"Found a PS cluster matched to more than one EE cluster!" 2250 << std::endl << std::hex << psclus.
get() <<
" == " 2251 << found_pscluster->get() <<
std::dec << std::endl;
2274 const double Pin_gsf = RO.
primaryGSFs.front().first->GsftrackRef()->pMode();
2275 const double gsfOuterEta =
2276 RO.
primaryGSFs.front().first->positionAtECALEntrance().Eta();
2277 double tot_ecal= 0.0;
2278 std::vector<double> min_brem_dists;
2279 std::vector<double> closest_brem_eta;
2282 tot_ecal +=
ecal.first->clusterRef()->correctedEnergy();
2285 double min_brem_dist = 5000.0;
2286 double eta = -999.0;
2287 for(
const auto& brem : RO.
brems ) {
2289 ecal.first->index(),
2292 if( dist < min_brem_dist && dist != -1.0
f ) {
2293 min_brem_dist = dist;
2294 eta = brem.first->positionAtECALEntrance().Eta();
2297 min_brem_dists.push_back(min_brem_dist);
2298 closest_brem_eta.push_back(eta);
2306 const float secpin = secd_kf->first->trackRef()->p();
2307 bool remove_this_kf =
false;
2311 const float minbremdist = min_brem_dists[bremidx];
2312 const double ecalenergy =
ecal->first->clusterRef()->correctedEnergy();
2313 const double Epin = ecalenergy/secpin;
2314 const double detaGsf =
2315 std::abs(gsfOuterEta -
ecal->first->clusterRef()->positionREP().Eta());
2316 const double detaBrem =
2317 std::abs(closest_brem_eta[bremidx] -
2318 ecal->first->clusterRef()->positionREP().Eta());
2325 const float tkdist =
_currentblock->dist(secd_kf->first->index(),
2326 ecal->first->index(),
2333 if( Epin > 3 && kf_matched != RO.
localMap.end() &&
2334 tkdist != -1.0f && tkdist < minbremdist &&
2335 detaGsf > 0.05 && detaBrem > 0.015) {
2336 double res_with =
std::abs((tot_ecal-Pin_gsf)/Pin_gsf);
2337 double res_without =
std::abs((tot_ecal-ecalenergy-Pin_gsf)/Pin_gsf);
2338 if(res_without < res_with) {
2340 <<
" REJECTED_RES totenergy " << tot_ecal
2341 <<
" Pin_gsf " << Pin_gsf
2342 <<
" cluster to secondary " << ecalenergy
2343 <<
" res_with " << res_with
2344 <<
" res_without " << res_without << std::endl;
2345 tot_ecal -= ecalenergy;
2346 remove_this_kf =
true;
2352 if( remove_this_kf ) {
2361 bool removeFreeECAL,
2362 bool removeSCEcal) {
2363 std::vector<bool> cluster_in_sc;
2370 bool remove_this_kf =
false;
2371 NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::HCAL>
2376 const float secpin = trkRef->p();
2378 for(
auto ecal = ecal_begin;
ecal != ecal_end; ++
ecal ) {
2379 const double ecalenergy =
ecal->first->clusterRef()->correctedEnergy();
2382 if( cluster_in_sc.size() < clus_idx + 1) {
2386 ecal->first->index(),
2390 cluster_in_sc.push_back(dist != -1.0
f);
2401 if( kf_matched != RO.
localMap.end() ) {
2402 auto hcal_matched = std::partition(hcal_begin,hcal_end,tracksToHCALs);
2403 for(
auto hcalclus = hcal_begin;
2404 hcalclus != hcal_matched;
2408 const double hcalenergy = clusthcal->
clusterRef()->energy();
2409 const double hpluse = ecalenergy+hcalenergy;
2410 const bool isHoHE = ( (hcalenergy / hpluse ) > 0.1 && goodTrack );
2411 const bool isHoE = ( hcalenergy > ecalenergy );
2412 const bool isPoHE = ( secpin > hpluse );
2413 if( cluster_in_sc[clus_idx] ) {
2414 if(isHoE || isPoHE) {
2416 <<
"REJECTED TRACK FOR H/E or P/(H+E), CLUSTER IN SC" 2417 <<
" H/H+E " << (hcalenergy / hpluse)
2418 <<
" H/E " << (hcalenergy > ecalenergy)
2419 <<
" P/(H+E) " << (secpin/hpluse)
2420 <<
" HCAL ENE " << hcalenergy
2421 <<
" ECAL ENE " << ecalenergy
2422 <<
" secPIN " << secpin
2423 <<
" Algo Track " << trkRef->algo() << std::endl;
2424 remove_this_kf =
true;
2429 <<
"REJECTED TRACK FOR H/H+E, CLUSTER NOT IN SC" 2430 <<
" H/H+E " << (hcalenergy / hpluse)
2431 <<
" H/E " << (hcalenergy > ecalenergy)
2432 <<
" P/(H+E) " << (secpin/hpluse)
2433 <<
" HCAL ENE " << hcalenergy
2434 <<
" ECAL ENE " << ecalenergy
2435 <<
" secPIN " << secpin
2436 <<
" Algo Track " <<trkRef->algo() << std::endl;
2437 remove_this_kf =
true;
2443 if( remove_this_kf ) {
2454 bool isPrimary =
false;
2460 PFRecTrackRef kfPfRef_fromGsf = (*gsfPfRef).kfPFRecTrackRef();
2465 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
std::vector< std::pair< unsigned int, unsigned int > > fifthStepKfTrack_
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
edm::Handle< reco::PFCluster::EEtoPSAssociation > eetops_
void setCharge(Charge q) final
set electric charge
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void RunPFEG(const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &blockRef)
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)
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 &)
std::vector< std::pair< unsigned int, unsigned int > > convGsfTrack_
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 &)