30 #include "combination.hpp"
36 #define docast(x,y) dynamic_cast<x>(y)
37 #define LOGVERB(x) edm::LogVerbatim(x)
38 #define LOGWARN(x) edm::LogWarning(x)
39 #define LOGERR(x) edm::LogError(x)
40 #define LOGDRESSED(x) edm::LogInfo(x)
42 #define docast(x,y) reinterpret_cast<x>(y)
43 #define LOGVERB(x) LogTrace(x)
44 #define LOGWARN(x) edm::LogWarning(x)
45 #define LOGERR(x) edm::LogError(x)
46 #define LOGDRESSED(x) LogDebug(x)
55 typedef std::pair<CaloClusterPtr::key_type,CaloClusterPtr> EEtoPSElement;
63 typedef std::unary_function<
const ClusterFlaggedElement&,
66 typedef std::unary_function<
const PFFlaggedElement&,
67 bool> PFFlaggedElementMatcher;
68 typedef std::binary_function<
const PFFlaggedElement&,
69 const PFFlaggedElement&,
70 bool> PFFlaggedElementSorter;
73 bool> PFElementMatcher;
78 typedef std::unary_function<PFFlaggedElement&,
79 ClusterFlaggedElement> ClusterElementConverter;
81 struct SumPSEnergy :
public std::binary_function<double,
82 const ClusterFlaggedElement&,
86 double operator()(
double a,
87 const ClusterFlaggedElement&
b) {
89 return a + (_thetype == b.first->type())*b.first->clusterRef()->energy();
93 bool comparePSMapByKey(
const EEtoPSElement&
a,
94 const EEtoPSElement&
b) {
95 return a.first < b.first;
98 struct UsableElementToPSCluster :
public ClusterElementConverter {
99 ClusterFlaggedElement operator () (PFFlaggedElement&
elem) {
100 const ClusterElement* pselemascluster =
101 docast(
const ClusterElement*,elem.first);
104 std::stringstream ps_err;
105 pselemascluster->Dump(ps_err,
"\t");
107 <<
"This element is not a PS cluster!" << std::endl
108 << ps_err.str() << std::endl;
110 if( elem.second ==
false ) {
111 std::stringstream ps_err;
112 pselemascluster->Dump(ps_err,
"\t");
114 <<
"PS Cluster matched to EE is already used! "
115 <<
"This should be impossible!" << std::endl
116 << ps_err.str() << std::endl;
119 return std::make_pair(pselemascluster,
true);
123 struct SeedMatchesToSCElement :
public PFFlaggedElementMatcher {
128 bool operator() (
const PFFlaggedElement&
elem) {
129 const SCElement* scelem =
docast(
const SCElement*,elem.first);
130 if( _scfromseed.isNull() || !elem.second || !scelem)
return false;
131 return ( _scfromseed->seed()->seed() ==
132 scelem->superClusterRef()->seed()->seed() );
136 struct SCSubClusterMatchesToElement :
public PFFlaggedElementMatcher {
142 bool operator() (
const PFFlaggedElement&
elem) {
143 const ClusterElement* cluselem =
144 docast(
const ClusterElement*,elem.first);
145 if( !elem.second || !cluselem)
return false;
147 for( ; cl !=
end; ++
cl ) {
148 if((*cl)->seed() == cluselem->clusterRef()->seed()) {
156 struct SeedMatchesToProtoObject :
public POMatcher {
162 if( _scfromseed.isNonnull() ) {
167 bool operator() (
const PFEGammaAlgo::ProtoEGObject& po) {
168 if( _scfromseed.isNull() || !po.
parentSC )
return false;
170 return ( _scfromseed->seed() ==
173 return ( _scfromseed->seed()->seed() ==
178 template<
bool useConvs=false>
184 const float EoPin_cut = 1.0e6) {
193 &(block->elements()[
key]));
195 const ClusterElement* elemasclus =
196 reinterpret_cast<const ClusterElement*
>(&(block->elements()[
test]));
197 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
198 float trk_pin = elemasgsf->
Pin().P();
199 if( cluster_e / trk_pin > EoPin_cut )
return false;
207 &(block->elements()[
key]));
209 const ClusterElement* elemasclus =
210 reinterpret_cast<const ClusterElement*
>(&(block->elements()[
test]));
211 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
214 if( cluster_e / trk_pin > EoPin_cut )
return false;
224 if( dist == -1.0
f )
return false;
225 std::multimap<double, unsigned> dists_to_val;
226 block->associatedElements(test,block->linkData(),dists_to_val,keytype,
228 for(
const auto& valdist : dists_to_val ) {
229 const size_t idx = valdist.second;
236 &(block->elements()[
idx]));
237 if( !useConvs && elemasgsf->
trackType(ConvType) )
return false;
239 const ClusterElement* elemasclus =
240 docast(
const ClusterElement*,&(block->elements()[
test]));
241 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
242 float trk_pin = elemasgsf->
Pin().P();
243 if( cluster_e / trk_pin > EoPin_cut )
continue;
251 &(block->elements()[
idx]));
252 if( !useConvs && elemaskf->
trackType(ConvType) )
return false;
254 const ClusterElement* elemasclus =
255 reinterpret_cast<const ClusterElement*
>(&(block->elements()[
test]));
256 float cluster_e = elemasclus->clusterRef()->correctedEnergy();
259 if( cluster_e / trk_pin > EoPin_cut )
continue;
266 if( valdist.first < dist && idx != key ) {
273 struct CompatibleEoPOut :
public PFFlaggedElementMatcher {
276 bool operator()(
const PFFlaggedElement&
e)
const {
278 const ClusterElement* elemascluster =
279 docast(
const ClusterElement*,e.first);
280 const float gsf_eta_diff =
std::abs(
comp->positionAtECALEntrance().eta()-
283 return ( gsf_eta_diff <= 0.3 && cRef->
energy()/
comp->Pout().t() <= 5 );
287 template<
class TrackElementType>
288 struct IsConversionTrack : PFFlaggedElementMatcher {
289 bool operator()(
const PFFlaggedElement&
e) {
292 const TrackElementType* elemastrk =
293 docast(
const TrackElementType*,e.first);
294 return elemastrk->trackType(ConvType);
301 struct NotCloserToOther :
public PFFlaggedElementMatcher {
302 const reco::PFBlockElement*
comp;
305 const float EoPin_cut;
308 const PFFlaggedElement*
e,
309 const float EoPcut=1.0e6):
comp(e->first),
316 const reco::PFBlockElement* e,
317 const float EoPcut=1.0e6):
comp(e),
322 bool operator () (
const PFFlaggedElement& e) {
323 if( !e.second || valtype != e.first->type() )
return false;
324 return elementNotCloserToOther<useConv>(
block,
325 keytype,
comp->index(),
326 valtype,e.first->index(),
331 struct LesserByDistance :
public PFFlaggedElementSorter {
332 const reco::PFBlockElement*
comp;
337 const PFFlaggedElement*
e):
comp(e->first),
342 const reco::PFBlockElement* e):
comp(e),
345 bool operator () (
const PFFlaggedElement&
e1,
346 const PFFlaggedElement&
e2) {
347 double dist1 = block->dist(
comp->index(),
351 double dist2 = block->dist(
comp->index(),
355 dist1 = ( dist1 == -1.0 ? 1e6 : dist1 );
356 dist2 = ( dist2 == -1.0 ? 1e6 : dist2 );
357 return dist1 < dist2;
361 bool isROLinkedByClusterOrTrack(
const PFEGammaAlgo::ProtoEGObject& RO1,
362 const PFEGammaAlgo::ProtoEGObject& RO2 ) {
368 if(RO1.
ecalclusters.front().first->clusterRef()->layer() !=
369 RO2.
ecalclusters.front().first->clusterRef()->layer() ) {
379 elementNotCloserToOther(blk,
380 cluster.first->type(),
381 cluster.first->
index(),
382 primgsf.first->type(),
383 primgsf.first->index());
384 if( not_closer )
return true;
388 elementNotCloserToOther(blk,
389 cluster.first->type(),
390 cluster.first->
index(),
391 primkf.first->type(),
392 primkf.first->index());
393 if( not_closer )
return true;
397 elementNotCloserToOther(blk,
398 cluster.first->type(),
399 cluster.first->
index(),
400 secdkf.first->type(),
401 secdkf.first->index());
402 if( not_closer )
return true;
405 for(
const auto& brem : RO2.
brems ) {
406 not_closer = elementNotCloserToOther(blk,
407 cluster.first->type(),
408 cluster.first->
index(),
410 brem.first->index());
411 if( not_closer )
return true;
418 elementNotCloserToOther(blk,
419 primgsf.first->type(),
420 primgsf.first->
index(),
421 secdkf.first->type(),
422 secdkf.first->index());
423 if( not_closer )
return true;
430 elementNotCloserToOther(blk,
431 primkf.first->type(),
432 primkf.first->
index(),
433 secdkf.first->type(),
434 secdkf.first->index());
435 if( not_closer )
return true;
442 elementNotCloserToOther<true>(blk,
443 secdkf1.first->type(),
444 secdkf1.first->
index(),
445 secdkf2.first->type(),
446 secdkf2.first->index());
447 if( not_closer )
return true;
453 struct TestIfROMergableByLink :
public POMatcher {
454 const PFEGammaAlgo::ProtoEGObject&
comp;
455 TestIfROMergableByLink(
const PFEGammaAlgo::ProtoEGObject& RO) :
457 bool operator() (
const PFEGammaAlgo::ProtoEGObject& ro) {
458 return ( isROLinkedByClusterOrTrack(
comp,ro) ||
459 isROLinkedByClusterOrTrack(ro,
comp) );
463 std::vector<const ClusterElement*>
465 std::vector<PFFlaggedElement>& ecals) {
466 std::vector<const ClusterElement*> cluster_list;
467 auto sccl = scref->clustersBegin();
468 auto scend = scref->clustersEnd();
469 auto pfc = ecals.begin();
470 auto pfcend = ecals.end();
471 for( ; sccl != scend; ++sccl ) {
472 std::vector<const ClusterElement*> matched_pfcs;
473 const double eg_energy = (*sccl)->energy();
475 for( pfc = ecals.begin(); pfc != pfcend; ++pfc ) {
476 const ClusterElement *pfcel =
477 docast(
const ClusterElement*, pfc->first);
482 if( matched && pfcel->clusterRef()->energy() < 1.2*scref->energy()) {
483 matched_pfcs.push_back(pfcel);
486 std::sort(matched_pfcs.begin(),matched_pfcs.end());
488 double min_residual = 1e6;
489 std::vector<const ClusterElement*> best_comb;
490 for(
size_t i = 1;
i <= matched_pfcs.size(); ++
i ) {
495 double energy = std::accumulate(matched_pfcs.begin(),
496 matched_pfcs.begin()+
i,
499 const ClusterElement*
c)
500 {
return a +
c->clusterRef()->energy(); });
501 const double resid =
std::abs(energy - eg_energy);
502 if( resid < min_residual ) {
504 best_comb.reserve(
i);
505 min_residual = resid;
506 best_comb.insert(best_comb.begin(),
507 matched_pfcs.begin(),
508 matched_pfcs.begin()+
i);
511 matched_pfcs.begin()+
i,
512 matched_pfcs.end()));
514 for(
const auto& clelem : best_comb ) {
516 if(
std::find(cluster_list.begin(),cluster_list.end(),clelem) ==
517 cluster_list.end() ) {
518 cluster_list.push_back(clelem);
524 bool addPFClusterToROSafe(
const ClusterElement*
cl,
525 PFEGammaAlgo::ProtoEGObject& RO) {
533 if( clayer == blayer ) {
543 void setROElectronCluster(PFEGammaAlgo::ProtoEGObject& RO) {
550 *kfCluster =
NULL, *gsfCluster_noassc =
NULL;
552 int nBremClusters = 0;
554 float mDist_gsf(maxDist), mDist_gsf_noassc(maxDist), mDist_kf(maxDist);
557 const bool hasclu = elementNotCloserToOther(parent,
560 cluster.first->type(),
561 cluster.first->index());
563 std::abs(cluster.first->clusterRef()->positionREP().eta() -
564 gsf.first->positionAtECALEntrance().eta());
567 cluster.first->clusterRef()->positionREP().phi() -
568 gsf.first->positionAtECALEntrance().phi()));
569 const float dist = std::hypot(deta,dphi);
570 if( hasclu && dist < mDist_gsf ) {
571 gsfCluster = cluster.first;
573 }
else if ( dist < mDist_gsf_noassc ) {
574 gsfCluster_noassc = cluster.first;
575 mDist_gsf_noassc = dist;
579 const bool hasclu = elementNotCloserToOther(parent,
582 cluster.first->type(),
583 cluster.first->index());
584 const float dist = parent->dist(cluster.first->index(),
588 if( hasclu && dist < mDist_kf ) {
589 kfCluster = cluster.first;
593 for(
const auto& brem : RO.
brems ) {
594 const bool hasclu = elementNotCloserToOther(parent,
597 cluster.first->type(),
598 cluster.first->index());
603 brem.first->indTrajPoint() - 2) ) {
604 firstBrem = brem.first;
607 ( lastBrem->indTrajPoint() - 2 <
608 brem.first->indTrajPoint() - 2) ) {
609 lastBrem = brem.first;
610 bremCluster = cluster.first;
615 if( !gsfCluster && !kfCluster && !bremCluster ) {
616 gsfCluster = gsfCluster_noassc;
622 }
else if ( kfCluster ) {
625 if( bremCluster && !gsfCluster && !kfCluster ) {
630 if( bremCluster == gsfCluster ) RO.
lateBrem = 1;
640 nlost(0.0), nlayers(0.0),
641 chi2(0.0), STIP(0.0), del_phi(0.0),HoverPt(0.0), EoverPt(0.0), track_pt(0.0),
643 CrysPhi_(0.0), CrysEta_(0.0), VtxZ_(0.0), ClusPhi_(0.0), ClusEta_(0.0),
644 ClusR9_(0.0), Clus5x5ratio_(0.0), PFCrysEtaCrack_(0.0), logPFClusE_(0.0), e3x3_(0.0),
645 CrysIPhi_(0), CrysIEta_(0),
646 CrysX_(0.0), CrysY_(0.0),
648 eSeed_(0.0), e1x3_(0.0),e3x1_(0.0), e1x5_(0.0), e2x5Top_(0.0), e2x5Bottom_(0.0), e2x5Left_(0.0), e2x5Right_(0.0),
649 etop_(0.0), ebottom_(0.0), eleft_(0.0), eright_(0.0),
651 PFPhoEta_(0.0), PFPhoPhi_(0.0), PFPhoR9_(0.0), PFPhoR9Corr_(0.0), SCPhiWidth_(0.0), SCEtaWidth_(0.0),
652 PFPhoEt_(0.0), RConv_(0.0), PFPhoEtCorr_(0.0), PFPhoE_(0.0), PFPhoECorr_(0.0), MustE_(0.0), E3x3_(0.0),
653 dEta_(0.0), dPhi_(0.0), LowClusE_(0.0), RMSAll_(0.0), RMSMust_(0.0), nPFClus_(0.0),
654 TotPS1_(0.0), TotPS2_(0.0),
656 x0inner_(0.0), x0middle_(0.0), x0outer_(0.0),
657 excluded_(0.0), Mustache_EtRatio_(0.0), Mustache_Et_out_(0.0)
696 TFile *XO_File =
new TFile(
cfg_.
X0_Map.c_str(),
"READ");
697 X0_sum = (TH2D*)XO_File->Get(
"TrackerSum");
698 X0_inner = (TH2D*)XO_File->Get(
"Inner");
699 X0_middle = (TH2D*)XO_File->Get(
"Middle");
700 X0_outer = (TH2D*)XO_File->Get(
"Outer");
705 std::vector<bool>& active) {
722 unsigned int track_index) {
723 bool convtkfound=
false;
729 chi2=elements[track_index].trackRef()->chi2()/elements[track_index].trackRef()->ndof();
730 nlost=elements[track_index].trackRef()->trackerExpectedHitsInner().numberOfLostHits();
731 nlayers=elements[track_index].trackRef()->hitPattern().trackerLayersWithMeasurement();
732 track_pt=elements[track_index].trackRef()->pt();
733 STIP=elements[track_index].trackRefPF()->STIP();
737 std::multimap<double, unsigned int> ecalAssoTrack;
742 std::multimap<double, unsigned int> hcalAssoTrack;
747 if(ecalAssoTrack.size() > 0) {
748 for(std::multimap<double, unsigned int>::iterator itecal = ecalAssoTrack.begin();
749 itecal != ecalAssoTrack.end(); ++itecal) {
750 linked_e=linked_e+elements[itecal->second].clusterRef()->energy();
753 if(hcalAssoTrack.size() > 0) {
754 for(std::multimap<double, unsigned int>::iterator ithcal = hcalAssoTrack.begin();
755 ithcal != hcalAssoTrack.end(); ++ithcal) {
756 linked_h=linked_h+elements[ithcal->second].clusterRef()->energy();
759 EoverPt=linked_e/elements[track_index].trackRef()->pt();
760 HoverPt=linked_h/elements[track_index].trackRef()->pt();
761 GlobalVector rvtx(elements[track_index].trackRef()->innerPosition().
X()-primaryvtx.
x(),
762 elements[track_index].trackRef()->innerPosition().Y()-primaryvtx.
y(),
763 elements[track_index].trackRef()->innerPosition().Z()-primaryvtx.
z());
764 double vtx_phi=rvtx.
phi();
766 del_phi=fabs(
deltaPhi(vtx_phi, elements[track_index].trackRef()->innerMomentum().
Phi()));
773 switch( pfbe.
type() ) {
777 std::multimap<double,unsigned> tks;
783 for(
const auto& tk : tks ) {
801 <<
"Resetting PFEGammaAlgo for new block and running!" << std::endl;
811 LOGVERB(
"PFEGammaAlgo") <<
"Splaying block" << std::endl;
814 if(
isAMuon(pfelement) )
continue;
815 const size_t itype = (size_t)pfelement.type();
817 _splayedblock[itype].push_back(std::make_pair(&pfelement,
true));
822 std::stringstream splayout;
823 for(
size_t itype = 0; itype <
_splayedblock.size(); ++itype ) {
824 splayout <<
"\tType: " << itype <<
" indices: ";
826 splayout << flaggedelement.first->index() <<
' ';
828 if( itype !=
_splayedblock.size() - 1 ) splayout << std::endl;
830 LOGVERB(
"PFEGammaAlgo") << splayout.str();
867 <<
"Dumping after GSF and KF Track (Primary) Linking : " << std::endl;
874 <<
"Dumping after first merging operation : " << std::endl;
880 for(
auto& RO : _refinableObjects ) {
891 <<
"Dumping after ECAL to Track (Secondary) Linking : " << std::endl;
898 <<
"There are " << _refinableObjects.size()
899 <<
" after the 2nd merging step." << std::endl;
903 for(
auto& RO : _refinableObjects ) {
910 std::sort(RO.ecalclusters.begin(), RO.ecalclusters.end(),
913 {
return ( a.first->clusterRef()->correctedEnergy() >
914 b.first->clusterRef()->correctedEnergy() ) ; });
915 setROElectronCluster(RO);
919 <<
"There are " << _refinableObjects.size()
920 <<
" after the unlinking and vetos step." << std::endl;
935 <<
"creating SC-based proto-object" << std::endl
936 <<
"\tSC at index: " << element.first->index()
937 <<
" has type: " << element.first->type() << std::endl;
938 element.second =
false;
954 std::list<ProtoEGObject>::iterator objsbegin, objsend;
957 <<
"creating GSF-based proto-object" << std::endl
958 <<
"\tGSF at index: " << element.first->index()
959 <<
" has type: " << element.first->type() << std::endl;
965 element.second =
false;
980 std::stringstream gsf_err;
981 elementAsGSF->
Dump(gsf_err,
"\t");
983 <<
"Found a GSF track with no seed! This should not happen!"
984 << std::endl << gsf_err.str() << std::endl;
988 element.second =
false;
990 fromGSF.
primaryGSFs.push_back(std::make_pair(elementAsGSF,
true));
997 if( dist == 0.001
f ) {
1000 fromGSF.
brems.push_back(std::make_pair(eAsBrem,
true));
1003 brem.second =
false;
1013 <<
"GSF-based proto-object is ECAL driven, merging SC-cand"
1020 SeedMatchesToProtoObject sctoseedmatch(fromGSF.
electronSeed);
1024 auto clusmatch = std::find_if(objsbegin,objsend,sctoseedmatch);
1025 if( clusmatch != objsend ) {
1026 fromGSF.
parentSC = clusmatch->parentSC;
1027 fromGSF.
ecalclusters = std::move(clusmatch->ecalclusters);
1028 fromGSF.
ecal2ps = std::move(clusmatch->ecal2ps);
1036 <<
"Encountered the known GSF-SC splitting bug "
1037 <<
" in PFBlockAlgo! We should really fix this!" << std::endl;
1039 std::stringstream gsf_err;
1040 elementAsGSF->
Dump(gsf_err,
"\t");
1042 <<
"Expected SuperCluster from ECAL driven GSF seed "
1043 <<
"was not found in the block!" << std::endl
1044 << gsf_err.str() << std::endl;
1053 std::vector<PFClusterFlaggedElement>& ecalclusters,
1055 ecalclusters.clear();
1058 <<
"Pointer to SC element: 0x"
1059 << std::hex << thesc << std::dec << std::endl
1060 <<
"cleared ecalclusters and ecal2ps!" << std::endl;
1063 if( ecalbegin == ecalend ) {
1064 LOGERR(
"PFEGammaAlgo::unwrapSuperCluster()")
1065 <<
"There are no ECAL elements in a block with imported SC!"
1066 <<
" This is a bug we should fix this!"
1074 <<
"SuperCluster pointed to by block element is null!"
1078 <<
"Got a valid super cluster ref! 0x"
1079 << std::hex << scref.
get() << std::dec << std::endl;
1080 const size_t nscclusters = scref->clustersSize();
1081 const size_t nscpsclusters = scref->preshowerClustersSize();
1082 size_t npfpsclusters = 0;
1083 size_t npfclusters = 0;
1085 <<
"Precalculated cluster multiplicities: "
1086 << nscclusters <<
' ' << nscpsclusters << std::endl;
1087 NotCloserToOther<reco::PFBlockElement::SC,reco::PFBlockElement::ECAL>
1089 auto firstnotinsc = std::partition(ecalbegin,ecalend,ecalClustersInSC);
1098 if( firstnotinsc == ecalbegin ) {
1099 LOGERR(
"PFEGammaAlgo::unwrapSuperCluster()")
1100 <<
"No associated block elements to SuperCluster!"
1101 <<
" This is a bug we should fix!"
1105 npfclusters = std::distance(ecalbegin,firstnotinsc);
1108 if( is_pf_sc && nscclusters != npfclusters ) {
1109 std::stringstream sc_err;
1110 thesc->
Dump(sc_err,
"\t");
1112 <<
"The number of found ecal elements ("
1113 << nscclusters <<
") in block is not the same as"
1114 <<
" the number of ecal PF clusters reported by the PFSuperCluster"
1115 <<
" itself (" << npfclusters
1116 <<
")! This should not happen!" << std::endl
1117 << sc_err.str() << std::endl;
1119 for(
auto ecalitr = ecalbegin; ecalitr != firstnotinsc; ++ecalitr ) {
1125 if(!is_pf_sc &&
std::find(safePFClusters.begin(),safePFClusters.end(),elemascluster) ==
1126 safePFClusters.end() )
continue;
1129 ecalclusters.push_back(std::make_pair(elemascluster,
true));
1131 ecalitr->second =
false;
1135 auto emplaceresult = ecal2ps.emplace(elemascluster,
1136 ClusterMap::mapped_type());
1137 if( !emplaceresult.second ) {
1138 std::stringstream clus_err;
1139 elemascluster->
Dump(clus_err,
"\t");
1141 <<
"List of pointers to ECAL block elements contains non-unique items!"
1142 <<
" This is very bad!" << std::endl
1143 <<
"cluster ptr = 0x" << std::hex << elemascluster << std::dec
1144 << std::endl << clus_err.str() << std::endl;
1146 ClusterMap::mapped_type& eslist = emplaceresult.first->second;
1165 <<
" Unwrapped SC has " << npfclusters <<
" ECAL sub-clusters"
1166 <<
" and " << npfpsclusters <<
" PreShower layers 1 & 2 clusters!"
1174 ClusterMap::mapped_type& eslist) {
1177 EEtoPSElement ecalkey = std::make_pair(clusptr.
key(),clusptr);
1178 auto assc_ps = std::equal_range(
eetops_->cbegin(),
1184 for(
auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl ) {
1185 if( pscl->second == temp ) {
1186 const ClusterElement* pstemp =
1187 docast(
const ClusterElement*,ps1.first);
1194 for(
auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl ) {
1195 if( pscl->second == temp ) {
1196 const ClusterElement* pstemp =
1197 docast(
const ClusterElement*,ps2.first);
1202 return eslist.size();
1210 <<
" refinable objects for this block: " << std::endl;
1212 std::stringstream
info;
1213 info <<
"Refinable Object:" << std::endl;
1215 info <<
"\tSuperCluster element attached to object:" << std::endl
1217 ro.parentSC->Dump(info,
"\t");
1220 if( ro.electronSeed.isNonnull() ) {
1221 info <<
"\tGSF element attached to object:" << std::endl;
1222 ro.primaryGSFs.front().first->Dump(info,
"\t");
1224 info <<
"firstBrem : " << ro.firstBrem
1225 <<
" lateBrem : " << ro.lateBrem
1226 <<
" nBrems with cluster : " << ro.nBremsWithClusters
1228 if( ro.electronClusters.size() && ro.electronClusters[0] ) {
1229 info <<
"electron cluster : ";
1230 ro.electronClusters[0]->Dump(info,
"\t");
1233 info <<
" no electron cluster." << std::endl;
1236 if( ro.primaryKFs.size() ) {
1237 info <<
"\tPrimary KF tracks attached to object: " << std::endl;
1238 for(
const auto& kf : ro.primaryKFs ) {
1239 kf.first->Dump(info,
"\t");
1243 if( ro.secondaryKFs.size() ) {
1244 info <<
"\tSecondary KF tracks attached to object: " << std::endl;
1245 for(
const auto& kf : ro.secondaryKFs ) {
1246 kf.first->Dump(info,
"\t");
1250 if( ro.brems.size() ) {
1251 info <<
"\tBrem tangents attached to object: " << std::endl;
1252 for(
const auto& brem : ro.brems ) {
1253 brem.first->Dump(info,
"\t");
1257 if( ro.ecalclusters.size() ) {
1258 info <<
"\tECAL clusters attached to object: " << std::endl;
1259 for(
const auto& clus : ro.ecalclusters ) {
1260 clus.first->Dump(info,
"\t");
1262 if( ro.ecal2ps.find(clus.first) != ro.ecal2ps.end() ) {
1263 for(
const auto& psclus : ro.ecal2ps.at(clus.first) ) {
1264 info <<
"\t\t Attached PS Cluster: ";
1265 psclus.first->Dump(info,
"");
1281 std::multimap<double, unsigned> matchedGSFs, matchedECALs;
1283 matchedGSFs.clear();
1288 if( !matchedGSFs.size() ) {
1293 std::partial_sort(ecalbegin,ecalbegin+1,ecalend,closestTrackToECAL);
1296 const float dist =
_currentblock->dist(kftrack.first->index(),
1297 closestECAL.first->index(),
1303 closestECAL.first->index(),
1306 if( dist_sc != -1.0
f) { inSC =
true;
break; }
1309 if( dist != -1.0
f && closestECAL.second ) {
1310 bool gsflinked =
false;
1312 for(
const auto& gsfflag :
_splayedblock[reco::PFBlockElement::GSF]) {
1318 matchedECALs.clear();
1323 if( matchedECALs.size() ) {
1324 if( matchedECALs.begin()->second == closestECAL.first->index() ) {
1330 if( !gsflinked && !inSC) {
1335 const unsigned Algo = trackref->algo();
1337 trackref->trackerExpectedHitsInner().numberOfLostHits();
1338 bool fromprimaryvertex =
false;
1342 fromprimaryvertex =
true;
1347 if( Algo < 9 && nexhits == 0 && fromprimaryvertex ) {
1348 closestECAL.second =
false;
1361 if( ROs.size() < 2 )
return;
1362 bool check_for_merge =
true;
1363 while( check_for_merge ) {
1365 TestIfROMergableByLink mergeTest(thefront);
1366 auto mergestart = ROs.begin(); ++mergestart;
1367 auto nomerge = std::partition(mergestart,ROs.end(),mergeTest);
1368 if( nomerge != mergestart ) {
1369 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink()")
1370 <<
"Found objects to merge by links to the front!" << std::endl;
1371 for(
auto roToMerge = mergestart; roToMerge != nomerge; ++roToMerge) {
1373 roToMerge->ecalclusters.begin(),
1374 roToMerge->ecalclusters.end());
1375 thefront.
ecal2ps.insert(roToMerge->ecal2ps.begin(),
1376 roToMerge->ecal2ps.end());
1378 roToMerge->secondaryKFs.begin(),
1379 roToMerge->secondaryKFs.end());
1382 roToMerge->localMap.begin(),
1383 roToMerge->localMap.end());
1385 if( !thefront.
parentSC && roToMerge->parentSC ) {
1386 thefront.
parentSC = roToMerge->parentSC;
1389 roToMerge->electronSeed.isNonnull() ) {
1392 roToMerge->primaryGSFs.begin(),
1393 roToMerge->primaryGSFs.end());
1395 roToMerge->primaryKFs.begin(),
1396 roToMerge->primaryKFs.end());
1398 roToMerge->brems.begin(),
1399 roToMerge->brems.end());
1402 thefront.
firstBrem = roToMerge->firstBrem;
1403 thefront.
lateBrem = roToMerge->lateBrem;
1405 roToMerge->electronSeed.isNonnull()) {
1406 LOGWARN(
"PFEGammaAlgo::mergeROsByAnyLink")
1407 <<
"Need to implement proper merging of two gsf candidates!"
1411 ROs.erase(mergestart,nomerge);
1413 ROs.push_back(ROs.front());
1416 check_for_merge =
false;
1419 LOGDRESSED(
"PFEGammaAlgo::mergeROsByAnyLink()")
1420 <<
"After merging by links there are: " << ROs.size()
1421 <<
" refinable EGamma objects!" << std::endl;
1439 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::TRACK>
1442 auto notlinked = std::partition(KFbegin,KFend,gsfTrackToKFs);
1444 for(
auto kft = KFbegin; kft != notlinked; ++kft ) {
1451 kft->second =
false;
1452 RO.
primaryKFs.push_back(std::make_pair(elemaskf,
true));
1455 }
else if ( elemaskf->
trackType(convType) ) {
1456 kft->second =
false;
1457 RO.
secondaryKFs.push_back(std::make_pair(elemaskf,
true));
1476 throw cms::Exception(
"PFEGammaAlgo::linkRefinableObjectPrimaryKFsToSecondaryKFs()")
1477 <<
"A KF track from conversion has been assigned as a primary!!"
1480 NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::TRACK,true>
1483 auto notlinked = std::partition(KFbegin,KFend,kfTrackToKFs);
1485 for(
auto kft = KFbegin; kft != notlinked; ++kft ) {
1491 kft->second =
false;
1492 RO.
secondaryKFs.push_back(std::make_pair(elemaskf,
true));
1510 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::ECAL>
1512 CompatibleEoPOut eoverp_test(primgsf.first);
1514 auto notmatched_blk = std::partition(ECALbegin,ECALend,gsfTracksToECALs);
1515 notmatched_blk = std::partition(ECALbegin,notmatched_blk,eoverp_test);
1517 auto notmatched_sc = std::partition(RO.
ecalclusters.begin(),
1520 notmatched_sc = std::partition(RO.
ecalclusters.begin(),
1528 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1529 <<
"Found a cluster already in RO by GSF extrapolation"
1530 <<
" at ECAL surface!" << std::endl
1531 << *elemascluster << std::endl;
1537 for(
auto ecal = ECALbegin;
ecal != notmatched_blk; ++
ecal ) {
1540 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1541 <<
"Found a cluster not already in RO by GSF extrapolation"
1542 <<
" at ECAL surface!" << std::endl
1543 << *elemascluster << std::endl;
1544 if( addPFClusterToROSafe(elemascluster,RO) ) {
1548 ecal->second =
false;
1561 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::HCAL>
1563 CompatibleEoPOut eoverp_test(primgsf.first);
1564 auto notmatched = std::partition(HCALbegin,HCALend,gsfTracksToHCALs);
1565 for(
auto hcal = HCALbegin;
hcal != notmatched; ++
hcal ) {
1569 LOGDRESSED(
"PFEGammaAlgo::linkGSFTracktoECAL()")
1570 <<
"Found an HCAL cluster associated to GSF extrapolation"
1575 hcal->second =
false;
1591 std::vector<PFClusterFlaggedElement>& currentECAL = RO.
ecalclusters;
1594 NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::ECAL>
1596 NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::ECAL>
1599 auto notmatched_sc = std::partition(currentECAL.begin(),
1603 notmatched_sc = std::partition(currentECAL.begin(),
1606 for(
auto ecalitr = currentECAL.begin(); ecalitr != notmatched_sc;
1612 LOGDRESSED(
"PFEGammaAlgo::linkKFTracktoECAL()")
1613 <<
"Found a cluster already in RO by KF extrapolation"
1614 <<
" at ECAL surface!" << std::endl
1615 << *elemascluster << std::endl;
1622 auto notmatched_blk = std::partition(ECALbegin,ECALend,kfTrackToECALs);
1624 notmatched_blk = std::partition(ECALbegin,notmatched_blk,kfTrackGSFToECALs);
1625 for(
auto ecalitr = ECALbegin; ecalitr != notmatched_blk; ++ecalitr ) {
1628 if( addPFClusterToROSafe(elemascluster,RO) ) {
1630 ecalitr->second =
false;
1632 LOGDRESSED(
"PFEGammaAlgo::linkKFTracktoECAL()")
1633 <<
"Found a cluster not in RO by KF extrapolation"
1634 <<
" at ECAL surface!" << std::endl
1635 << *elemascluster << std::endl;
1646 if( !RO.
brems.size() )
return;
1649 int lastBremTrajPos = -1;
1650 for(
auto& bremflagged : RO.
brems ) {
1651 bool has_clusters =
false;
1652 TrajPos = (bremflagged.first->indTrajPoint())-2;
1655 NotCloserToOther<reco::PFBlockElement::BREM,reco::PFBlockElement::ECAL>
1660 auto notmatched_rsc = std::partition(RSCBegin,RSCEnd,BremToECALs);
1661 for(
auto ecal = RSCBegin;
ecal != notmatched_rsc; ++
ecal ) {
1663 std::abs(
ecal->first->clusterRef()->positionREP().eta() -
1664 bremflagged.first->positionAtECALEntrance().eta() );
1665 if( deta < 0.015 ) {
1666 has_clusters =
true;
1667 if( lastBremTrajPos == -1 || lastBremTrajPos < TrajPos ) {
1668 lastBremTrajPos = TrajPos;
1670 if( FirstBrem == -1 || TrajPos < FirstBrem ) {
1671 FirstBrem = TrajPos;
1675 <<
"Found a cluster already in SC linked to brem extrapolation"
1676 <<
" at ECAL surface!" << std::endl;
1682 auto notmatched_block = std::partition(ECALbegin,ECALend,BremToECALs);
1683 for(
auto ecal = ECALbegin;
ecal != notmatched_block; ++
ecal ) {
1685 std::abs(
ecal->first->clusterRef()->positionREP().eta() -
1686 bremflagged.first->positionAtECALEntrance().eta() );
1687 if( deta < 0.015 ) {
1688 has_clusters =
true;
1689 if( lastBremTrajPos == -1 || lastBremTrajPos < TrajPos ) {
1690 lastBremTrajPos = TrajPos;
1692 if( FirstBrem == -1 || TrajPos < FirstBrem ) {
1694 FirstBrem = TrajPos;
1699 if( addPFClusterToROSafe(elemasclus,RO) ) {
1704 ecal->second =
false;
1706 <<
"Found a cluster not already associated by brem extrapolation"
1707 <<
" at ECAL surface!" << std::endl;
1721 IsConversionTrack<reco::PFBlockElementTrack> isConvKf;
1726 auto ronotconv = std::partition(BeginROskfs,EndROskfs,isConvKf);
1727 size_t convkfs_end = std::distance(BeginROskfs,ronotconv);
1728 for(
size_t idx = 0;
idx < convkfs_end; ++
idx ) {
1734 auto notmatched = std::partition(KFbegin,KFend,TracksToTracks);
1735 notmatched = std::partition(KFbegin,notmatched,isConvKf);
1736 for(
auto kf = KFbegin; kf != notmatched; ++kf ) {
1739 RO.
secondaryKFs.push_back( std::make_pair(elemaskf,
true) );
1749 IsConversionTrack<reco::PFBlockElementTrack> isConvKf;
1757 auto notmatchedkf = std::partition(KFbegin,KFend,ECALToTracks);
1758 auto notconvkf = std::partition(KFbegin,notmatchedkf,isConvKf);
1760 for(
auto kf = KFbegin; kf != notconvkf; ++kf ) {
1763 RO.
secondaryKFs.push_back( std::make_pair(elemaskf,
true) );
1769 for(
auto kf = notconvkf; kf != notmatchedkf; ++kf ) {
1771 kf->first->
index()) ) {
1774 RO.
secondaryKFs.push_back( std::make_pair(elemaskf,
true) );
1792 auto notmatched = std::partition(ECALbegin,ECALend,TracksToECALwithCut);
1793 for(
auto ecal = ECALbegin;
ecal != notmatched; ++
ecal ) {
1796 if( addPFClusterToROSafe(elemascluster,RO) ) {
1800 ecal->second =
false;
1814 egcands.reserve(ROs.size());
1815 egxs.reserve(ROs.size());
1817 for(
auto& RO : ROs ) {
1818 if( RO.ecalclusters.size() == 0 &&
1823 if( RO.primaryGSFs.size() || RO.primaryKFs.size() ) {
1828 if( RO.primaryKFs.size() ) {
1829 cand.
setCharge(RO.primaryKFs[0].first->trackRef()->charge());
1831 cand.
setTrackRef(RO.primaryKFs[0].first->trackRef());
1834 if( RO.primaryGSFs.size() ) {
1835 cand.
setCharge(RO.primaryGSFs[0].first->GsftrackRef()->chargeMode());
1848 for(
const auto& bremflagged : RO.brems ) {
1853 for(
const auto&
ecal : RO.ecalclusters ) {
1856 for(
auto& ps : RO.ecal2ps.at(clus) ) {
1862 for(
const auto& secdkf : RO.secondaryKFs ) {
1883 const double scE = the_sc.
energy();
1887 egDir = egDir.Unit();
1896 RO.primaryGSFs.size() ) {
1900 gref->pzMode(),gref->pMode());
1904 RO.primaryKFs.size() ) {
1914 xtra.
setMVA(ele_mva_value);
1916 egcands.push_back(cand);
1917 egxs.push_back(xtra);
1931 const double Ein_gsf = std::hypot(RefGSF->pMode(),m_el);
1932 double deta_gsfecal = 1e6;
1933 double sigmaEtaEta = 1
e-14;
1934 const double Ene_hcalgsf = std::accumulate(RO.
hcalClusters.begin(),
1939 {
return a +
b.first->clusterRef()->energy(); }
1942 RefKF = RO.
primaryKFs.front().first->trackRef();
1944 const double Eout_gsf = gsfElement->
Pout().t();
1946 double FirstEcalGsfEnergy(0.0), OtherEcalGsfEnergy(0.0), EcalBremEnergy(0.0);
1948 std::vector<const reco::PFCluster*> gsfcluster;
1950 const double cenergy =
ecal.first->clusterRef()->correctedEnergy();
1959 bool hasbrem =
false;
1960 for(
const auto& brem : RO.
brems ) {
1968 EcalBremEnergy += cenergy;
1971 if( hasgsf ) OtherEcalGsfEnergy += cenergy;
1972 if( haskf ) EcalBremEnergy += cenergy;
1973 if( !(hasgsf || haskf) ) OtherEcalGsfEnergy += cenergy;
1980 FirstEcalGsfEnergy = cref->correctedEnergy();
1981 deta_gsfecal = cref->positionREP().eta() - Etaout_gsf;
1982 gsfcluster.push_back(&*cref);
1998 if( FirstEcalGsfEnergy > 0.0 ) {
2002 const float Pt_gsf = RefGSF->ptMode();
2006 const double ptModeErrorGsf = RefGSF->ptModeError();
2007 dPtOverPt_gsf = (ptModeErrorGsf > 0. ? ptModeErrorGsf/Pt_gsf : 1.0);
2008 nhit_gsf = RefGSF->hitPattern().trackerLayersWithMeasurement();
2009 chi2_gsf = RefGSF->normalizedChi2();
2016 nhit_kf = RefKF->hitPattern().trackerLayersWithMeasurement();
2017 chi2_kf = RefKF->normalizedChi2();
2022 const double EcalETot =
2023 (FirstEcalGsfEnergy+OtherEcalGsfEnergy+EcalBremEnergy);
2027 (Ein_gsf - Eout_gsf) );
2033 HOverHE = Ene_hcalgsf/(Ene_hcalgsf + FirstEcalGsfEnergy);
2090 IsConversionTrack<reco::PFBlockElementTrack> isConvKf;
2098 auto notmatchedkf = std::partition(KFbegin,KFend,ECALToTracks);
2099 auto notconvkf = std::partition(KFbegin,notmatchedkf,isConvKf);
2101 for(
auto kf = notconvkf; kf != notmatchedkf; ++kf ) {
2124 std::vector<const reco::PFCluster*> bare_ptrs;
2126 double posX(0), posY(0), posZ(0),
2127 rawSCEnergy(0), corrSCEnergy(0), corrPSEnergy(0),
2128 PS1_clus_sum(0), PS2_clus_sum(0),
2129 ePS1(0), ePS2(0), ps1_energy(0.0), ps2_energy(0.0);
2135 edm::refToPtr<reco::PFClusterCollection>(clus.first->clusterRef());
2136 bare_ptrs.push_back(clusptr.
get());
2138 const double cluseraw = clusptr->energy();
2139 double cluscalibe = clusptr->correctedEnergy();
2141 posX += cluseraw * cluspos.X();
2142 posY += cluseraw * cluspos.Y();
2143 posZ += cluseraw * cluspos.Z();
2146 const auto& psclusters = RO.
ecal2ps.at(clus.first);
2147 PS1_clus_sum = std::accumulate(psclusters.begin(),psclusters.end(),
2149 PS2_clus_sum = std::accumulate(psclusters.begin(),psclusters.end(),
2153 PS1_clus_sum,PS2_clus_sum,
2158 rawSCEnergy += cluseraw;
2159 corrSCEnergy += cluscalibe;
2162 corrPSEnergy += ePS1 + ePS2;
2164 posX /= rawSCEnergy;
2165 posY /= rawSCEnergy;
2166 posZ /= rawSCEnergy;
2172 edm::refToPtr<reco::PFClusterCollection>(RO.
ecalclusters.front().
2173 first->clusterRef());
2181 edm::refToPtr<reco::PFClusterCollection>(clus.first->clusterRef());
2183 auto& hits_and_fractions = clusptr->hitsAndFractions();
2184 for(
auto& hit_and_fraction : hits_and_fractions ) {
2188 const auto& cluspsassociation = RO.
ecal2ps.at(clus.first);
2192 for(
const auto& pscluselem : cluspsassociation ) {
2194 edm::refToPtr<reco::PFClusterCollection>(pscluselem.first->
2205 throw cms::Exception(
"PFECALSuperClusterAlgo::buildSuperCluster")
2206 <<
"Found a PS cluster matched to more than one EE cluster!"
2207 << std::endl << std::hex << psclus.
get() <<
" == "
2208 << found_pscluster->get() << std::dec << std::endl;
2230 const double Pin_gsf = RO.
primaryGSFs.front().first->GsftrackRef()->pMode();
2231 const double gsfOuterEta =
2232 RO.
primaryGSFs.front().first->positionAtECALEntrance().Eta();
2233 double tot_ecal= 0.0;
2234 std::vector<double> min_brem_dists;
2235 std::vector<double> closest_brem_eta;
2238 tot_ecal +=
ecal.first->clusterRef()->correctedEnergy();
2241 double min_brem_dist = 5000.0;
2242 double eta = -999.0;
2243 for(
const auto& brem : RO.
brems ) {
2245 ecal.first->index(),
2248 if( dist < min_brem_dist && dist != -1.0
f ) {
2249 min_brem_dist = dist;
2250 eta = brem.first->positionAtECALEntrance().Eta();
2253 min_brem_dists.push_back(min_brem_dist);
2254 closest_brem_eta.push_back(eta);
2262 const float secpin = secd_kf->first->trackRef()->p();
2263 bool remove_this_kf =
false;
2267 const float minbremdist = min_brem_dists[bremidx];
2268 const double ecalenergy =
ecal->first->clusterRef()->correctedEnergy();
2269 const double Epin = ecalenergy/secpin;
2270 const double detaGsf =
2271 std::abs(gsfOuterEta -
ecal->first->clusterRef()->positionREP().Eta());
2272 const double detaBrem =
2273 std::abs(closest_brem_eta[bremidx] -
2274 ecal->first->clusterRef()->positionREP().Eta());
2281 const float tkdist =
_currentblock->dist(secd_kf->first->index(),
2282 ecal->first->index(),
2289 if( Epin > 3 && kf_matched != RO.
localMap.end() &&
2290 tkdist != -1.0f && tkdist < minbremdist &&
2291 detaGsf > 0.05 && detaBrem > 0.015) {
2292 double res_with =
std::abs((tot_ecal-Pin_gsf)/Pin_gsf);
2293 double res_without =
std::abs((tot_ecal-ecalenergy-Pin_gsf)/Pin_gsf);
2294 if(res_without < res_with) {
2296 <<
" REJECTED_RES totenergy " << tot_ecal
2297 <<
" Pin_gsf " << Pin_gsf
2298 <<
" cluster to secondary " << ecalenergy
2299 <<
" res_with " << res_with
2300 <<
" res_without " << res_without << std::endl;
2301 tot_ecal -= ecalenergy;
2302 remove_this_kf =
true;
2308 if( remove_this_kf ) {
2317 bool removeFreeECAL,
2318 bool removeSCEcal) {
2319 std::vector<bool> cluster_in_sc;
2326 bool remove_this_kf =
false;
2327 NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::HCAL>
2331 const float secpin = trkRef->p();
2333 for(
auto ecal = ecal_begin;
ecal != ecal_end; ++
ecal ) {
2334 const double ecalenergy =
ecal->first->clusterRef()->correctedEnergy();
2336 const size_t clus_idx = std::distance(ecal_begin,
ecal);
2337 if( cluster_in_sc.size() < clus_idx + 1) {
2341 ecal->first->index(),
2345 cluster_in_sc.push_back(dist != -1.0
f);
2356 if( kf_matched != RO.
localMap.end() ) {
2357 auto hcal_matched = std::partition(hcal_begin,hcal_end,tracksToHCALs);
2358 for(
auto hcalclus = hcal_begin;
2359 hcalclus != hcal_matched;
2363 const double hcalenergy = clusthcal->
clusterRef()->energy();
2364 const double hpluse = ecalenergy+hcalenergy;
2365 const bool isHoHE = ( (hcalenergy / hpluse ) > 0.1 && Algo < 3 );
2366 const bool isHoE = ( hcalenergy > ecalenergy );
2367 const bool isPoHE = ( secpin > hpluse );
2368 if( cluster_in_sc[clus_idx] ) {
2369 if(isHoE || isPoHE) {
2371 <<
"REJECTED TRACK FOR H/E or P/(H+E), CLUSTER IN SC"
2372 <<
" H/H+E " << (hcalenergy / hpluse)
2373 <<
" H/E " << (hcalenergy > ecalenergy)
2374 <<
" P/(H+E) " << (secpin/hpluse)
2375 <<
" HCAL ENE " << hcalenergy
2376 <<
" ECAL ENE " << ecalenergy
2377 <<
" secPIN " << secpin
2378 <<
" Algo Track " << Algo << std::endl;
2379 remove_this_kf =
true;
2384 <<
"REJECTED TRACK FOR H/H+E, CLUSTER NOT IN SC"
2385 <<
" H/H+E " << (hcalenergy / hpluse)
2386 <<
" H/E " << (hcalenergy > ecalenergy)
2387 <<
" P/(H+E) " << (secpin/hpluse)
2388 <<
" HCAL ENE " << hcalenergy
2389 <<
" ECAL ENE " << ecalenergy
2390 <<
" secPIN " << secpin
2391 <<
" Algo Track " << Algo << std::endl;
2392 remove_this_kf =
true;
2398 if( remove_this_kf ) {
2407 unsigned int Algo = 0;
2408 switch (trackRef->algo()) {
2409 case TrackBase::ctf:
2410 case TrackBase::iter0:
2411 case TrackBase::iter1:
2412 case TrackBase::iter2:
2415 case TrackBase::iter3:
2418 case TrackBase::iter4:
2421 case TrackBase::iter5:
2424 case TrackBase::iter6:
2435 bool isPrimary =
false;
2441 PFRecTrackRef kfPfRef_fromGsf = (*gsfPfRef).kfPFRecTrackRef();
2446 if(kfref == kfref_fromGsf)
float EtotBremPinPoutMode
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
bool EvaluateSingleLegMVA(const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
unsigned int whichTrackAlgo(const reco::TrackRef &trackRef)
virtual void setCharge(Charge q) GCC11_FINAL
set electric charge
void addSingleLegConvMva(const float &mvasingleleg)
add Single Leg Conversion mva
std::vector< PFClusterFlaggedElement > ecalclusters
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
void Dump(std::ostream &out=std::cout, const char *tab=" ") const
print the object inside the element
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)
reco::PFCandidateEGammaExtraCollection egExtra_
std::vector< std::pair< unsigned int, unsigned int > > fifthStepKfTrack_
reco::SuperClusterCollection refinedscs_
void addHitAndFraction(DetId id, float fraction)
void addSingleLegConvTrackRef(const reco::TrackRef &trackref)
add Single Leg Conversion TrackRef
void RunPFEG(const reco::PFBlockRef &blockRef, std::vector< bool > &active)
reco::PFBlockRef parentBlock
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
PFClusterRef clusterRef() const
void setPreshowerEnergyPlane2(double preshowerEnergy2)
std::pair< const PFClusterElement *, bool > PFClusterFlaggedElement
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
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)
void linkRefinableObjectPrimaryGSFTrackToECAL(ProtoEGObject &)
const edm::OwnVector< reco::PFBlockElement > & elements() const
double Phi_mpi_pi(double x)
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
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 set_mva_e_pi(float mva)
void linkRefinableObjectECALToSingleLegConv(ProtoEGObject &)
edm::Handle< reco::PFCluster::EEtoPSAssociation > eetops_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
bool isNonnull() const
Checks for non-null.
std::vector< PFKFFlaggedElement > secondaryKFs
void setEtaWidth(double ew)
void setSigmaEtaEta(float val)
set the sigmaetaeta
void dumpCurrentRefinableObjects() const
bool isNull() const
Checks for null.
void initializeProtoCands(std::list< ProtoEGObject > &)
T const * get() const
Returns C++ pointer to the item.
void linkRefinableObjectPrimaryKFsToSecondaryKFs(ProtoEGObject &)
const T & max(const T &a, const T &b)
bool unwrapSuperCluster(const reco::PFBlockElementSuperCluster *, std::vector< PFClusterFlaggedElement > &, ClusterMap &)
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
reco::PFCluster::EEtoPSAssociation EEtoPSAssociation
PFEGammaAlgo(const PFEGConfigInfo &)
reco::GsfTrackRef GsftrackRef() const
bool produceEGCandsWithNoSuperCluster
const PFSCElement * parentSC
std::vector< reco::PFCandidateEGammaExtra > PFCandidateEGammaExtraCollection
collection of PFCandidateEGammaExtras
std::vector< PFBremFlaggedElement > brems
void setEarlyBrem(float val)
set EarlyBrem
Abs< T >::type abs(const T &t)
double z() const
y coordinate
void setGsfTrackPout(const math::XYZTLorentzVector &pout)
set the pout (not trivial to get from the GSF track)
double energy() const
cluster energy
SuperClusterRef superClusterRef() const
std::list< ProtoEGObject > _refinableObjects
virtual bool trackType(TrackType trType) const
Container::value_type value_type
reco::PFCandidateEGammaExtraCollection outcandsextra_
void linkKFTrackToECAL(const PFKFFlaggedElement &, ProtoEGObject &)
void buildAndRefineEGObjects(const reco::PFBlockRef &block)
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
reco::PFBlock::LinkData _currentlinks
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
double x() const
x coordinate
virtual bool trackType(TrackType trType) const
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
void fill_extra_info(const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
reco::PFCandidateCollection egCandidate_
bool applyCrackCorrections
bool isAMuon(const reco::PFBlockElement &)
void setDeltaEta(float val)
set the delta eta
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
reco::ElectronSeedRef electronSeed
float calculate_ele_mva(const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
PFRecTrackRef trackRefPF() const
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
std::string mvaWeightFileEleID
XYZPointD XYZPoint
point in space with cartesian internal representation
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
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
TMVA::Reader * tmvaReaderEle_
reco::TrackRef trackRef() const
std::vector< PFKFFlaggedElement > primaryKFs
std::unordered_map< const PFClusterElement *, std::vector< PFClusterFlaggedElement > > ClusterMap
void addCluster(const CaloClusterPtr &r)
add reference to constituent BasicCluster
void Dump(std::ostream &out=std::cout, const char *tab=" ") const
print the object inside the element
ElementMap _recoveredlinks
void removeOrLinkECALClustersToKFTracks()
Particle reconstructed by the particle flow algorithm.
void Dump(std::ostream &out=std::cout, const char *tab=" ") const
print the object inside the element
reco::SuperCluster buildRefinedSuperCluster(const ProtoEGObject &)
void unlinkRefinableObjectKFandECALMatchedToHCAL(ProtoEGObject &, bool removeFreeECAL=false, bool removeSCECAL=false)
virtual void setP4(const LorentzVector &p4) GCC11_FINAL
set 4-momentum
std::pair< const PFKFElement *, bool > PFKFFlaggedElement
void mergeROsByAnyLink(std::list< ProtoEGObject > &)
GsfPFRecTrackRef GsftrackRefPF() const
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)
std::string mvaweightfile
volatile std::atomic< bool > shutdown_flag false
TMVA::Reader * tmvaReader_
void linkRefinableObjectSecondaryKFsToECAL(ProtoEGObject &)
void setLateBrem(float val)
set LateBrem
trackRef_iterator tracks_begin() const
first iterator over tracks
reco::PFCandidateCollection _finalCandidates
void linkRefinableObjectConvSecondaryKFsToSecondaryKFs(ProtoEGObject &)
verbosityLevel verbosityLevel_
T const * get() const
Returns C++ pointer to the item.
void setTrackRef(const reco::TrackRef &ref)
set track reference
virtual void setPdgId(int pdgId) GCC11_FINAL
reco::PFCandidateCollection outcands_
ConversionRef convRef() const
void fillPFCandidates(const std::list< ProtoEGObject > &, reco::PFCandidateCollection &, reco::PFCandidateEGammaExtraCollection &)
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
void setPreshowerEnergyPlane1(double preshowerEnergy1)
std::vector< PFGSFFlaggedElement > primaryGSFs
tuple size
Write out results.
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)
void linkRefinableObjectPrimaryGSFTrackToHCAL(ProtoEGObject &)