41 const boost::shared_ptr<PFSCEnergyCalibration>& thePFSCEnergyCalibration,
42 const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
43 bool applyCrackCorrections,
46 bool useEGammaSupercluster,
47 double sumEtEcalIsoForEgammaSC_barrel,
48 double sumEtEcalIsoForEgammaSC_endcap,
49 double coneEcalIsoForEgammaSC,
50 double sumPtTrackIsoForEgammaSC_barrel,
51 double sumPtTrackIsoForEgammaSC_endcap,
52 unsigned int nTrackIsoForEgammaSC,
53 double coneTrackIsoForEgammaSC,
59 double sumPtTrackIsoForPhoton,
60 double sumPtTrackIsoSlopeForPhoton
62 mvaEleCut_(mvaEleCut),
63 thePFSCEnergyCalibration_(thePFSCEnergyCalibration),
64 thePFEnergyCalibration_(thePFEnergyCalibration),
65 applyCrackCorrections_(applyCrackCorrections),
66 usePFSCEleCalib_(usePFSCEleCalib),
67 useEGElectrons_(useEGElectrons),
68 useEGammaSupercluster_(useEGammaSupercluster),
69 sumEtEcalIsoForEgammaSC_barrel_(sumEtEcalIsoForEgammaSC_barrel),
70 sumEtEcalIsoForEgammaSC_endcap_(sumEtEcalIsoForEgammaSC_endcap),
71 coneEcalIsoForEgammaSC_(coneEcalIsoForEgammaSC),
72 sumPtTrackIsoForEgammaSC_barrel_(sumPtTrackIsoForEgammaSC_barrel),
73 sumPtTrackIsoForEgammaSC_endcap_(sumPtTrackIsoForEgammaSC_endcap),
74 nTrackIsoForEgammaSC_(nTrackIsoForEgammaSC),
75 coneTrackIsoForEgammaSC_(coneTrackIsoForEgammaSC),
80 sumPtTrackIsoForPhoton_(sumPtTrackIsoForPhoton),
81 sumPtTrackIsoSlopeForPhoton_(sumPtTrackIsoSlopeForPhoton),
82 nlost(0.0), nlayers(0.0),
83 chi2(0.0), STIP(0.0), del_phi(0.0),HoverPt(0.0), EoverPt(0.0), track_pt(0.0),
85 CrysPhi_(0.0), CrysEta_(0.0), VtxZ_(0.0), ClusPhi_(0.0), ClusEta_(0.0),
86 ClusR9_(0.0), Clus5x5ratio_(0.0), PFCrysEtaCrack_(0.0), logPFClusE_(0.0), e3x3_(0.0),
87 CrysIPhi_(0), CrysIEta_(0),
88 CrysX_(0.0), CrysY_(0.0),
90 eSeed_(0.0), e1x3_(0.0),e3x1_(0.0), e1x5_(0.0), e2x5Top_(0.0), e2x5Bottom_(0.0), e2x5Left_(0.0), e2x5Right_(0.0),
91 etop_(0.0), ebottom_(0.0), eleft_(0.0), eright_(0.0),
93 PFPhoEta_(0.0), PFPhoPhi_(0.0), PFPhoR9_(0.0), PFPhoR9Corr_(0.0), SCPhiWidth_(0.0), SCEtaWidth_(0.0),
94 PFPhoEt_(0.0), RConv_(0.0), PFPhoEtCorr_(0.0), PFPhoE_(0.0), PFPhoECorr_(0.0), MustE_(0.0), E3x3_(0.0),
95 dEta_(0.0), dPhi_(0.0), LowClusE_(0.0), RMSAll_(0.0), RMSMust_(0.0), nPFClus_(0.0),
96 TotPS1_(0.0), TotPS2_(0.0),
98 x0inner_(0.0), x0middle_(0.0), x0outer_(0.0),
99 excluded_(0.0), Mustache_EtRatio_(0.0), Mustache_Et_out_(0.0)
139 TFile *XO_File =
new TFile(X0_Map.c_str(),
"READ");
140 X0_sum=(TH2D*)XO_File->Get(
"TrackerSum");
141 X0_inner = (TH2D*)XO_File->Get(
"Inner");
142 X0_middle = (TH2D*)XO_File->Get(
"Middle");
143 X0_outer = (TH2D*)XO_File->Get(
"Outer");
148 std::vector<bool>& active
178 std::vector<bool>::const_iterator actIter = active.begin();
180 bool isActive =
true;
183 if(elements.
size() != active.size()) {
198 associatedToBrems,associatedToEcal,
206 std::vector<unsigned int> elemsToLock;
207 elemsToLock.resize(0);
209 for( ; ele != elements.
end(); ++ele, ++actIter ) {
217 float photonEnergy_ = 0.;
221 float RawEcalEne = 0.;
224 float ps1TotEne = 0.;
225 float ps2TotEne = 0.;
227 bool hasConvTrack=
false;
228 bool hasSingleleg=
false;
229 std::vector<unsigned int> AddClusters(0);
231 std::multimap<unsigned int, unsigned int>ClusterAddPS1;
232 std::multimap<unsigned int, unsigned int>ClusterAddPS2;
233 std::vector<reco::TrackRef>singleLegRef;
234 std::vector<float>MVA_values(0);
235 std::vector<float>MVALCorr;
236 std::vector<CaloCluster>PFClusters;
238 isActive = *(actIter);
251 elemsToLock.push_back(ele-elements.
begin());
253 std::multimap<double, unsigned int> ecalAssoPFClusters;
254 blockRef->associatedElements( ele-elements.
begin(),
264 if( ! ecalAssoPFClusters.size() ) {
273 std::vector<unsigned int> matchedGsf;
274 for (
map<
unsigned int,vector<unsigned int> >::iterator igsf = associatedToGsf.begin();
275 igsf != associatedToGsf.end(); igsf++) {
277 bool matched =
false;
278 if( !( active[igsf->first] ) )
continue;
280 vector<unsigned int> assogsf_index = igsf->second;
281 for (
unsigned int ielegsf=0;ielegsf<assogsf_index.size();ielegsf++) {
282 unsigned int associdx = assogsf_index[ielegsf];
284 if( !( active[associdx] ) )
continue;
288 if(assoele_type == reco::PFBlockElement::ECAL) {
289 for(std::multimap<double, unsigned int>::iterator itecal = ecalAssoPFClusters.begin();
290 itecal != ecalAssoPFClusters.end(); ++itecal) {
292 if (itecal->second==associdx) {
310 for(std::multimap<double, unsigned int>::iterator itecal = ecalAssoPFClusters.begin();
311 itecal != ecalAssoPFClusters.end(); ++itecal) {
350 vector<double> ps1Ene(0);
351 vector<double> ps2Ene(0);
366 if( !( active[itecal->second] ) ) {
378 bool isClosest=
false;
379 std::multimap<double, unsigned int> Trackscheck;
380 blockRef->associatedElements( itecal->second,
385 for(std::multimap<double, unsigned int>::iterator track = Trackscheck.begin();
386 track != Trackscheck.end(); ++track) {
389 if( ! (active[track->second]) )
continue;
392 std::multimap<double, unsigned int> closecheck;
393 blockRef->associatedElements(track->second,
396 reco::PFBlockElement::ECAL,
398 if(closecheck.begin()->second ==itecal->second)isClosest=
true;
399 if(!hasSingleleg)mva_reject++;
402 if(mva_reject>0 && isClosest)useIt=
false;
404 if( !useIt )
continue;
409 elemsToLock.push_back(itecal->second);
412 std::multimap<double, unsigned int> PS1Elems;
413 std::multimap<double, unsigned int> PS2Elems;
415 blockRef->associatedElements( itecal->second,
421 blockRef->associatedElements( itecal->second,
428 for(std::multimap<double, unsigned int>::iterator iteps = PS1Elems.begin();
429 iteps != PS1Elems.end(); ++iteps) {
432 if( !(active[iteps->second]) )
continue;
435 std::multimap<double, unsigned int> ECALPS1check;
436 blockRef->associatedElements( iteps->second,
439 reco::PFBlockElement::ECAL,
441 if(itecal->second==ECALPS1check.begin()->second)
444 ps1Ene.
push_back( ps1ClusterRef->energy() );
445 ps1=ps1+ps1ClusterRef->energy();
447 elemsToLock.push_back(iteps->second);
450 for(std::multimap<double, unsigned int>::iterator iteps = PS2Elems.begin();
451 iteps != PS2Elems.end(); ++iteps) {
454 if( !(active[iteps->second]) )
continue;
457 std::multimap<double, unsigned int> ECALPS2check;
458 blockRef->associatedElements( iteps->second,
461 reco::PFBlockElement::ECAL,
463 if(itecal->second==ECALPS2check.begin()->second)
466 ps2Ene.
push_back( ps2ClusterRef->energy() );
467 ps2=ps2ClusterRef->energy()+ps2;
469 elemsToLock.push_back(iteps->second);
474 std::multimap<double, unsigned int> hcalElems;
475 blockRef->associatedElements( itecal->second,linkData,
480 for(std::multimap<double, unsigned int>::iterator ithcal = hcalElems.begin();
481 ithcal != hcalElems.end(); ++ithcal) {
483 if ( ! (active[ithcal->second] ) )
continue;
489 bool useHcal =
false;
490 if ( !useHcal )
continue;
498 std::multimap<double, unsigned int>
convTracks;
499 blockRef->associatedElements( itecal->second,
504 for(std::multimap<double, unsigned int>::iterator track = convTracks.begin();
505 track != convTracks.end(); ++track) {
508 if( ! (active[track->second]) )
continue;
527 for(
unsigned int i=0;
i<IsoTracks.size();
i++)
528 {
if(IsoTracks[
i]==track->second)included=
true;}
529 if(!included)IsoTracks.push_back(track->second);
534 elemsToLock.push_back(track->second);
538 for(
unsigned int ic=0; ic<singleLegRef.size(); ic++)
539 if(singleLegRef[ic]==t_ref)matched=
true;
546 std::multimap<double, unsigned int> moreClusters;
547 blockRef->associatedElements( track->second,
550 reco::PFBlockElement::ECAL,
553 float p_in=
sqrt(elements[track->second].trackRef()->innerMomentum().x() * elements[track->second].trackRef()->innerMomentum().x() +
554 elements[track->second].trackRef()->innerMomentum().y()*elements[track->second].trackRef()->innerMomentum().y()+
555 elements[track->second].trackRef()->innerMomentum().z()*elements[track->second].trackRef()->innerMomentum().z());
557 for(std::multimap<double, unsigned int>::iterator clust = moreClusters.begin();
558 clust != moreClusters.end(); ++clust)
560 if(!active[clust->second])
continue;
562 linked_E=linked_E+elements[clust->second].clusterRef()->energy();
564 if(linked_E/p_in>1.5)
break;
567 for(std::multimap<double, unsigned int>::iterator cluscheck = ecalAssoPFClusters.begin();
568 cluscheck != ecalAssoPFClusters.end(); ++cluscheck)
570 if(cluscheck->second==clust->second)included=
true;
572 if(!included)AddClusters.
push_back(clust->second);
580 elemsToLock.push_back(track->second);
586 std::multimap<double, unsigned int> moreClusters;
587 blockRef->associatedElements( track->second,
590 reco::PFBlockElement::ECAL,
593 float p_in=
sqrt(elements[track->second].trackRef()->innerMomentum().x() * elements[track->second].trackRef()->innerMomentum().x() +
594 elements[track->second].trackRef()->innerMomentum().y()*elements[track->second].trackRef()->innerMomentum().y()+
595 elements[track->second].trackRef()->innerMomentum().z()*elements[track->second].trackRef()->innerMomentum().z());
597 for(std::multimap<double, unsigned int>::iterator clust = moreClusters.begin();
598 clust != moreClusters.end(); ++clust)
600 if(!active[clust->second])
continue;
601 linked_E=linked_E+elements[clust->second].clusterRef()->energy();
602 if(linked_E/p_in>1.5)
break;
604 for(std::multimap<double, unsigned int>::iterator cluscheck = ecalAssoPFClusters.begin();
605 cluscheck != ecalAssoPFClusters.end(); ++cluscheck)
607 if(cluscheck->second==clust->second)included=
true;
609 if(!included)AddClusters.
push_back(clust->second);
615 std::multimap<double, unsigned int> moreTracks;
616 blockRef->associatedElements( track->second,
622 for(std::multimap<double, unsigned int>::iterator track2 = moreTracks.begin();
623 track2 != moreTracks.end(); ++track2) {
626 if( ! (active[track2->second]) )
continue;
628 if(track->second==track2->second)
continue;
632 elemsToLock.push_back(track2->second);
635 std::multimap<double, unsigned int> convEcalAll;
636 blockRef->associatedElements( track2->second,
639 reco::PFBlockElement::ECAL,
645 std::multimap<double, unsigned int> convEcal;
646 for(std::multimap<double, unsigned int>::iterator itecal = convEcalAll.begin();
647 itecal != convEcalAll.end(); ++itecal) {
652 if (clusterRef->hitsAndFractions().at(0).first.subdetId()==sc->
superClusterRef()->seed()->hitsAndFractions().at(0).first.subdetId()) {
653 convEcal.insert(*itecal);
657 float p_in=
sqrt(elements[track->second].trackRef()->innerMomentum().x()*elements[track->second].trackRef()->innerMomentum().x()+
658 elements[track->second].trackRef()->innerMomentum().y()*elements[track->second].trackRef()->innerMomentum().y()+
659 elements[track->second].trackRef()->innerMomentum().z()*elements[track->second].trackRef()->innerMomentum().z());
663 for(std::multimap<double, unsigned int>::iterator itConvEcal = convEcal.begin();
664 itConvEcal != convEcal.end(); ++itConvEcal) {
666 if( ! (active[itConvEcal->second]) )
continue;
668 for(std::multimap<double, unsigned int>::iterator cluscheck = ecalAssoPFClusters.begin();
669 cluscheck != ecalAssoPFClusters.end(); ++cluscheck)
671 if(cluscheck->second==itConvEcal->second)included=
true;
673 linked_E=linked_E+elements[itConvEcal->second].clusterRef()->energy();
674 if(linked_E/p_in>1.5)
break;
675 if(!included){AddClusters.
push_back(itConvEcal->second);
682 std::multimap<double, unsigned int> hcalElems_conv;
683 blockRef->associatedElements( itecal->second,linkData,
688 for(std::multimap<double, unsigned int>::iterator ithcal2 = hcalElems_conv.begin();
689 ithcal2 != hcalElems_conv.end(); ++ithcal2) {
691 if ( ! (active[ithcal2->second] ) )
continue;
698 if ( !useHcal )
continue;
714 float addedCalibEne=0;
716 std::vector<double>AddedPS1(0);
717 std::vector<double>AddedPS2(0);
720 for(
unsigned int i=0;
i<AddClusters.size();
i++)
722 std::multimap<double, unsigned int> PS1Elems_conv;
723 std::multimap<double, unsigned int> PS2Elems_conv;
724 blockRef->associatedElements(AddClusters[
i],
729 blockRef->associatedElements( AddClusters[i],
735 for(std::multimap<double, unsigned int>::iterator iteps = PS1Elems_conv.begin();
736 iteps != PS1Elems_conv.end(); ++iteps)
738 if(!active[iteps->second])
continue;
739 std::multimap<double, unsigned int> PS1Elems_check;
740 blockRef->associatedElements(iteps->second,
743 reco::PFBlockElement::ECAL,
745 if(PS1Elems_check.begin()->second==AddClusters[
i])
749 AddedPS1.
push_back(ps1ClusterRef->energy());
750 addedps1=addedps1+ps1ClusterRef->energy();
751 elemsToLock.push_back(iteps->second);
755 for(std::multimap<double, unsigned int>::iterator iteps = PS2Elems_conv.begin();
756 iteps != PS2Elems_conv.end(); ++iteps) {
757 if(!active[iteps->second])
continue;
758 std::multimap<double, unsigned int> PS2Elems_check;
759 blockRef->associatedElements(iteps->second,
762 reco::PFBlockElement::ECAL,
765 if(PS2Elems_check.begin()->second==AddClusters[
i])
768 AddedPS2.
push_back(ps2ClusterRef->energy());
769 addedps2=addedps2+ps2ClusterRef->energy();
770 elemsToLock.push_back(iteps->second);
774 addedRawEne = AddclusterRef->energy()+addedRawEne;
778 elemsToLock.push_back(AddClusters[i]);
782 PFClusters.push_back(*clusterRef);
785 EE=LocCorr*clusterRef->energy()+addedCalibEne;
789 MVALCorr.push_back(LocCorr*clusterRef->energy());
795 RawEcalEne += clusterRef->energy()+addedRawEne;
796 photonX_ += EE * clusterRef->position().X();
797 photonY_ += EE * clusterRef->position().Y();
798 photonZ_ += EE * clusterRef->position().Z();
799 ps1TotEne += ps1+addedps1;
800 ps2TotEne += ps2+addedps2;
805 bool goodelectron =
false;
806 if (matchedGsf.size()>0) {
808 int eleidx = matchedGsf.front();
809 AddElectronElements(eleidx, elemsToLock, blockRef, associatedToGsf, associatedToBrems, associatedToEcal);
814 if (goodelectron)
continue;
819 if( ! (photonEnergy_ > 0.) )
continue;
820 float sum_track_pt=0;
822 for(
unsigned int i=0;
i<IsoTracks.size();
i++)sum_track_pt=sum_track_pt+elements[IsoTracks[
i]].trackRef()->pt();
837 photonEnergy_* photonDirection.Y(),
838 photonEnergy_* photonDirection.Z(),
862 photonCand.setPs1Energy(ps1TotEne);
863 photonCand.setPs2Energy(ps2TotEne);
864 photonCand.setEcalEnergy(RawEcalEne,photonEnergy_);
865 photonCand.setHcalEnergy(0.,0.);
866 photonCand.set_mva_nothing_gamma(1.);
869 photonCand.setVertex(
v );
884 for(std::vector<unsigned int>::const_iterator it =
886 it !=
AddFromElectron_.end(); ++it)photonCand.addElementInBlock(blockRef,*it);
889 for(std::vector<unsigned int>::const_iterator it = elemsToLock.begin();
890 it != elemsToLock.end(); ++it)
894 photonCand.addElementInBlock(blockRef,*it);
897 if(elements[*it].convRef().isNonnull())
901 for(
unsigned int ic = 0; ic < ConversionsRef_.
size(); ic++)
903 if(ConversionsRef_[ic]==elements[*it].convRef())matched=
true;
905 if(!matched)ConversionsRef_.
push_back(elements[*it].convRef());
919 for(
unsigned int l=0;
l<MVALCorr.size(); ++
l)
932 GCorr * photonEnergy_ );
933 photonCand.setP4(photonCorrMomentum);
936 std::multimap<float, unsigned int>OrderedClust;
937 for(
unsigned int i=0;
i<PFClusters.size(); ++
i){
939 OrderedClust.insert(make_pair(et,
i));
941 std::multimap<float, unsigned int>::reverse_iterator rit;
942 rit=OrderedClust.rbegin();
943 unsigned int highEindex=(*rit).second;
964 for(
unsigned int ic = 0; ic < MVA_values.size(); ic++)
970 for(
unsigned int ic = 0; ic < ConversionsRef_.
size(); ic++)
978 elemsToLock.resize(0);
1000 std::vector<unsigned int>insideMust;
1001 std::vector<unsigned int>outsideMust;
1002 std::multimap<float, unsigned int>OrderedClust;
1008 for(
unsigned int i=0;
i<insideMust.size(); ++
i){
1010 OrderedClust.insert(make_pair(PFClusters[index].
energy(),index));
1012 std::multimap<float, unsigned int>::iterator it;
1013 it=OrderedClust.begin();
1014 unsigned int lowEindex=(*it).second;
1015 std::multimap<float, unsigned int>::reverse_iterator rit;
1016 rit=OrderedClust.rbegin();
1017 unsigned int highEindex=(*rit).second;
1018 if(insideMust.size()>1){
1019 dEta_=fabs(PFClusters[highEindex].
eta()-PFClusters[lowEindex].
eta());
1020 dPhi_=asin(PFClusters[highEindex].
phi()-PFClusters[lowEindex].
phi());
1029 std::vector<reco::CaloCluster>PFMustClusters;
1030 if(insideMust.size()>2){
1031 for(
unsigned int i=0;
i<insideMust.size(); ++
i){
1032 unsigned int index=insideMust[
i];
1033 if(index==lowEindex)
continue;
1034 PFMustClusters.push_back(PFClusters[index]);
1038 for(
unsigned int i=0;
i<insideMust.size(); ++
i){
1039 unsigned int index=insideMust[
i];
1040 PFMustClusters.push_back(PFClusters[index]);
1047 for(
unsigned i=0;
i<eleInBlocks.size();
i++)
1050 unsigned indexInBlock = eleInBlocks[
i].second;
1104 std::vector<unsigned int>insideMust;
1105 std::vector<unsigned int>outsideMust;
1106 std::multimap<float, unsigned int>OrderedClust;
1112 for(
unsigned int i=0;
i<insideMust.size(); ++
i){
1114 OrderedClust.insert(make_pair(PFClusters[index].
energy(),index));
1116 std::multimap<float, unsigned int>::iterator it;
1117 it=OrderedClust.begin();
1118 unsigned int lowEindex=(*it).second;
1119 std::multimap<float, unsigned int>::reverse_iterator rit;
1120 rit=OrderedClust.rbegin();
1121 unsigned int highEindex=(*rit).second;
1122 if(insideMust.size()>1){
1123 dEta_=fabs(PFClusters[highEindex].
eta()-PFClusters[lowEindex].
eta());
1124 dPhi_=asin(PFClusters[highEindex].
phi()-PFClusters[lowEindex].
phi());
1133 std::vector<reco::CaloCluster>PFMustClusters;
1134 if(insideMust.size()>2){
1135 for(
unsigned int i=0;
i<insideMust.size(); ++
i){
1136 unsigned int index=insideMust[
i];
1137 if(index==lowEindex)
continue;
1138 PFMustClusters.push_back(PFClusters[index]);
1142 for(
unsigned int i=0;
i<insideMust.size(); ++
i){
1143 unsigned int index=insideMust[
i];
1144 PFMustClusters.push_back(PFClusters[index]);
1151 for(
unsigned i=0;
i<eleInBlocks.size();
i++)
1154 unsigned indexInBlock = eleInBlocks[
i].second;
1239 double PFClustPhiRMS=0;
1243 for(
unsigned int c=0;
c<PFClusters.size(); ++
c){
1244 delPhi2=(acos(
cos(PFPhoPhi-PFClusters[
c].
phi()))* acos(
cos(PFPhoPhi-PFClusters[
c].
phi())) )+delPhi2;
1245 delPhiSum=delPhiSum+ acos(
cos(PFPhoPhi-PFClusters[
c].
phi()))*PFClusters[
c].energy();
1246 ClusSum=ClusSum+PFClusters[
c].energy();
1248 double meandPhi=delPhiSum/ClusSum;
1249 PFClustPhiRMS=
sqrt(fabs(delPhi2/ClusSum - (meandPhi*meandPhi)));
1251 return PFClustPhiRMS;
1257 std::pair<double, double>ClusCoor=ClusterVar.
GetCrysCoor();
1258 std::pair<int, int>ClusIndex=ClusterVar.
GetCrysIndex();
1306 if(rightstrip>leftstrip)
e2x5Max_=rightstrip+centerstrip;
1307 else e2x5Max_=leftstrip+centerstrip;
1312 ClusPhi_=clusterRef->position().phi();
1313 ClusEta_=fabs(clusterRef->position().eta());
1314 EB=fabs(clusterRef->position().eta())/clusterRef->position().eta();
1344 LC_Var[22]=CrysIphiMod2;
1345 LC_Var[23]=CrysIetaMod5;
1346 LC_Var[24]=CrysIphiMod20;
1385 bool convtkfound=
false;
1391 chi2=elements[track_index].trackRef()->chi2()/elements[track_index].trackRef()->ndof();
1392 nlost=elements[track_index].trackRef()->trackerExpectedHitsInner().numberOfLostHits();
1393 nlayers=elements[track_index].trackRef()->hitPattern().trackerLayersWithMeasurement();
1394 track_pt=elements[track_index].trackRef()->pt();
1395 STIP=elements[track_index].trackRefPF()->STIP();
1399 std::multimap<double, unsigned int> ecalAssoTrack;
1404 std::multimap<double, unsigned int> hcalAssoTrack;
1409 if(ecalAssoTrack.size() > 0) {
1410 for(std::multimap<double, unsigned int>::iterator itecal = ecalAssoTrack.begin();
1411 itecal != ecalAssoTrack.end(); ++itecal) {
1412 linked_e=linked_e+elements[itecal->second].clusterRef()->energy();
1415 if(hcalAssoTrack.size() > 0) {
1416 for(std::multimap<double, unsigned int>::iterator ithcal = hcalAssoTrack.begin();
1417 ithcal != hcalAssoTrack.end(); ++ithcal) {
1418 linked_h=linked_h+elements[ithcal->second].clusterRef()->energy();
1421 EoverPt=linked_e/elements[track_index].trackRef()->pt();
1422 HoverPt=linked_h/elements[track_index].trackRef()->pt();
1423 GlobalVector rvtx(elements[track_index].trackRef()->innerPosition().
X()-primaryvtx.
x(),
1424 elements[track_index].trackRef()->innerPosition().Y()-primaryvtx.
y(),
1425 elements[track_index].trackRef()->innerPosition().Z()-primaryvtx.
z());
1426 double vtx_phi=rvtx.
phi();
1428 del_phi=fabs(
deltaPhi(vtx_phi, elements[track_index].trackRef()->innerMomentum().
Phi()));
1438 std::vector<reco::PFCandidate>&
1439 tempElectronCandidates,
1445 for ( std::vector<reco::PFCandidate>::const_iterator ec=tempElectronCandidates.begin(); ec != tempElectronCandidates.end(); ++ec )
1448 int mh=ec->gsfTrackRef()->trackerExpectedHitsInner().numberOfLostHits();
1457 if(seedRef.
isAvailable() && seedRef->isEcalDriven())
1464 if(PhotscRef==ElecscRef)
1471 for(
unsigned i=0;
i<eleInBlocks.size();
i++)
1474 unsigned indexInBlock = eleInBlocks[
i].second;
1489 AssMap& associatedToGsf_,
1490 AssMap& associatedToBrems_,
1491 AssMap& associatedToEcal_,
1492 std::vector<bool>& active,
1494 unsigned int CutIndex = 100000;
1495 double CutGSFECAL = 10000. ;
1498 bool DebugSetLinksSummary =
false;
1499 bool DebugSetLinksDetailed =
false;
1505 bool IsThereAGSFTrack =
false;
1506 bool IsThereAGoodGSFTrack =
false;
1508 vector<unsigned int> trackIs(0);
1509 vector<unsigned int> gsfIs(0);
1510 vector<unsigned int> ecalIs(0);
1512 std::vector<bool> localactive(elements.
size(),
true);
1516 std::multimap<double, unsigned int> kfElems;
1517 for(
unsigned int iEle=0; iEle<elements.
size(); iEle++) {
1518 localactive[iEle] = active[iEle];
1519 bool thisIsAMuon =
false;
1522 case PFBlockElement::TRACK:
1526 if ( !thisIsAMuon && active[iEle] ) {
1527 trackIs.push_back( iEle );
1528 if (DebugSetLinksDetailed)
1529 cout<<
"TRACK, stored index, continue "<< iEle << endl;
1532 case PFBlockElement::GSF:
1538 thisIsAMuon = kfElems.size() ?
1541 if ( !thisIsAMuon && active[iEle] ) {
1542 IsThereAGSFTrack =
true;
1543 gsfIs.push_back( iEle );
1544 if (DebugSetLinksDetailed)
1545 cout<<
"GSF, stored index, continue "<< iEle << endl;
1549 if ( active[iEle] ) {
1550 ecalIs.push_back( iEle );
1551 if (DebugSetLinksDetailed)
1552 cout<<
"ECAL, stored index, continue "<< iEle << endl;
1561 if(IsThereAGSFTrack) {
1572 if (DebugSetLinksDetailed) {
1573 cout<<
"#########################################################"<<endl;
1574 cout<<
"##### Process Block: #####"<<endl;
1575 cout<<
"#########################################################"<<endl;
1580 for(
unsigned int iEle=0; iEle<trackIs.size(); iEle++) {
1581 std::multimap<double, unsigned int> gsfElems;
1586 if(gsfElems.size() == 0){
1589 std::multimap<double, unsigned int> ecalKfElems;
1594 if(ecalKfElems.size() > 0) {
1595 unsigned int ecalKf_index = ecalKfElems.begin()->second;
1596 if(localactive[ecalKf_index]==
true) {
1600 bool isGsfLinked =
false;
1601 for(
unsigned int iGsf=0; iGsf<gsfIs.size(); iGsf++) {
1609 std::multimap<double, unsigned int> ecalGsfElems;
1614 if(ecalGsfElems.size() > 0) {
1615 if (ecalGsfElems.begin()->second == ecalKf_index) {
1620 if(isGsfLinked ==
false) {
1627 int nexhits = refKf->trackerExpectedHitsInner().numberOfLostHits();
1629 unsigned int Algo = 0;
1631 Algo = refKf->algo();
1633 bool trackIsFromPrimaryVertex =
false;
1635 if ( (*trackIt).castTo<
TrackRef>() == refKf ) {
1636 trackIsFromPrimaryVertex =
true;
1641 if(Algo < 9 && nexhits == 0 && trackIsFromPrimaryVertex) {
1642 localactive[ecalKf_index] =
false;
1654 for(
unsigned int iEle=0; iEle<gsfIs.size(); iEle++) {
1656 if (!localactive[(gsfIs[iEle])])
continue;
1658 localactive[gsfIs[iEle]] =
false;
1659 bool ClosestEcalWithKf =
false;
1661 if (DebugSetLinksDetailed)
cout <<
" Gsf Index " << gsfIs[iEle] << endl;
1668 IsThereAGoodGSFTrack =
true;
1670 float etaOut_gsf = GsfEl->
Pout().eta();
1671 float diffOutEcalEta = fabs(eta_gsf-etaOut_gsf);
1673 float Pin_gsf = 0.01;
1675 Pin_gsf = RefGSF->pMode();
1679 unsigned int KfGsf_index = CutIndex;
1680 unsigned int KfGsf_secondIndex = CutIndex;
1681 std::multimap<double, unsigned int> kfElems;
1686 std::multimap<double, unsigned int> ecalKfElems;
1687 if (kfElems.size() > 0) {
1691 for(std::multimap<double, unsigned int>::iterator itkf = kfElems.begin();
1692 itkf != kfElems.end(); ++itkf) {
1700 if(localactive[itkf->second] ==
true) {
1702 KfGsf_index = itkf->second;
1703 localactive[KfGsf_index] =
false;
1711 KfGsf_secondIndex = itkf->second;
1717 std::multimap<double, unsigned int> ecalGsfElems;
1722 double ecalGsf_dist = CutGSFECAL;
1723 unsigned int ClosestEcalGsf_index = CutIndex;
1724 if (ecalGsfElems.size() > 0) {
1725 if(localactive[(ecalGsfElems.begin()->second)] ==
true) {
1727 bool compatibleEPout =
true;
1728 if(diffOutEcalEta > 0.3) {
1729 reco::PFClusterRef clusterRef = elements[(ecalGsfElems.begin()->second)].clusterRef();
1730 float EoPout = (clusterRef->energy())/(GsfEl->
Pout().t());
1732 compatibleEPout =
false;
1734 if(compatibleEPout) {
1735 ClosestEcalGsf_index = ecalGsfElems.begin()->second;
1736 ecalGsf_dist = block.
dist(gsfIs[iEle],ClosestEcalGsf_index,
1741 std::multimap<double, unsigned int> ecalOtherGsfElems;
1747 if(ecalOtherGsfElems.size()>0) {
1752 if(ecalOtherGsfElems.begin()->second != gsfIs[iEle]&&
1754 ecalGsf_dist = CutGSFECAL;
1755 ClosestEcalGsf_index = CutIndex;
1763 else if(ecalKfElems.size() > 0) {
1764 if(localactive[(ecalKfElems.begin()->second)] ==
true) {
1765 ClosestEcalGsf_index = ecalKfElems.begin()->second;
1766 ecalGsf_dist = block.
dist(gsfIs[iEle],ClosestEcalGsf_index,
1768 ClosestEcalWithKf =
true;
1771 std::multimap<double, unsigned int> ecalOtherGsfElems;
1776 if(ecalOtherGsfElems.size() > 0) {
1780 if(ecalOtherGsfElems.begin()->second != gsfIs[iEle] &&
1782 ecalGsf_dist = CutGSFECAL;
1783 ClosestEcalGsf_index = CutIndex;
1784 ClosestEcalWithKf =
false;
1790 if (DebugSetLinksDetailed)
1791 cout <<
" Closest Ecal to the Gsf/Kf: index " << ClosestEcalGsf_index
1792 <<
" dist " << ecalGsf_dist << endl;
1797 std::multimap<double, unsigned int> bremElems;
1804 multimap<unsigned int,unsigned int> cleanedEcalBremElems;
1805 vector<unsigned int> keyBremIndex(0);
1806 unsigned int latestBrem_trajP = 0;
1807 unsigned int latestBrem_index = CutIndex;
1808 for(std::multimap<double, unsigned int>::iterator ieb = bremElems.begin();
1809 ieb != bremElems.end(); ++ieb ) {
1810 unsigned int brem_index = ieb->second;
1811 if(localactive[brem_index] ==
false)
continue;
1815 std::multimap<double, unsigned int> ecalBremsElems;
1822 for (std::multimap<double, unsigned int>::iterator ie = ecalBremsElems.begin();
1823 ie != ecalBremsElems.end();ie++) {
1824 unsigned int ecalBrem_index = ie->second;
1825 if(localactive[ecalBrem_index] ==
false)
continue;
1828 float ecalBrem_dist = block.
dist(brem_index,ecalBrem_index,
1832 if (ecalBrem_index == ClosestEcalGsf_index && (ecalBrem_dist + 0.0012) > ecalGsf_dist)
continue;
1835 std::multimap<double, unsigned int> sortedBremElems;
1841 bool isGoodBrem =
false;
1842 unsigned int sortedBrem_index = CutIndex;
1843 for (std::multimap<double, unsigned int>::iterator ibs = sortedBremElems.begin();
1844 ibs != sortedBremElems.end();ibs++) {
1845 unsigned int temp_sortedBrem_index = ibs->second;
1846 std::multimap<double, unsigned int> sortedGsfElems;
1851 bool enteredInPrimaryGsf =
false;
1852 for (std::multimap<double, unsigned int>::iterator igs = sortedGsfElems.begin();
1853 igs != sortedGsfElems.end();igs++) {
1858 if(igs->second == gsfIs[iEle]) {
1860 sortedBrem_index = temp_sortedBrem_index;
1862 enteredInPrimaryGsf =
true;
1866 if(enteredInPrimaryGsf)
1874 std::multimap<double, unsigned int> ecalOtherGsfElems;
1879 if (ecalOtherGsfElems.size() > 0) {
1882 if(ecalOtherGsfElems.begin()->second != gsfIs[iEle] &&
1892 elements[ecalBrem_index].clusterRef();
1898 if(sortedBremEcal_deta < 0.015) {
1900 cleanedEcalBremElems.insert(pair<unsigned int,unsigned int>(sortedBrem_index,ecalBrem_index));
1903 if (BremTrajP > latestBrem_trajP) {
1904 latestBrem_trajP = BremTrajP;
1905 latestBrem_index = sortedBrem_index;
1907 if (DebugSetLinksDetailed)
1908 cout <<
" brem Index " << sortedBrem_index
1909 <<
" associated cluster " << ecalBrem_index <<
" BremTrajP " << BremTrajP <<endl;
1914 localactive[ecalBrem_index] =
false;
1915 bool alreadyfound =
false;
1916 for(
unsigned int ii=0;
ii<keyBremIndex.size();
ii++) {
1917 if (sortedBrem_index == keyBremIndex[
ii]) alreadyfound =
true;
1919 if (alreadyfound ==
false) {
1920 keyBremIndex.push_back(sortedBrem_index);
1921 localactive[sortedBrem_index] =
false;
1930 vector<unsigned int> GsfElemIndex(0);
1931 vector<unsigned int> EcalIndex(0);
1934 if (ClosestEcalGsf_index < CutIndex) {
1935 GsfElemIndex.push_back(ClosestEcalGsf_index);
1936 localactive[ClosestEcalGsf_index] =
false;
1937 for (std::multimap<double, unsigned int>::iterator
ii = ecalGsfElems.begin();
1938 ii != ecalGsfElems.end();
ii++) {
1939 if(localactive[
ii->second]) {
1941 std::multimap<double, unsigned int> ecalOtherGsfElems;
1946 if(ecalOtherGsfElems.size()) {
1947 if(ecalOtherGsfElems.begin()->second != gsfIs[iEle])
continue;
1952 float etacl = clusterRef->eta();
1953 if( fabs(eta_gsf-etacl) < 0.05) {
1954 GsfElemIndex.push_back(
ii->second);
1955 localactive[
ii->second] =
false;
1956 if (DebugSetLinksDetailed)
1957 cout <<
" ExtraCluster From Gsf " <<
ii->second << endl;
1994 if(GsfElemIndex.size() == 0){
1995 if(latestBrem_index < CutIndex) {
1996 unsigned int ckey = cleanedEcalBremElems.count(latestBrem_index);
1998 unsigned int temp_cal =
1999 cleanedEcalBremElems.find(latestBrem_index)->second;
2000 GsfElemIndex.push_back(temp_cal);
2001 if (DebugSetLinksDetailed)
2002 cout <<
"******************** Gsf Cluster From Brem " << temp_cal
2003 <<
" Latest Brem index " << latestBrem_index
2004 <<
" ************************* " << endl;
2007 pair<multimap<unsigned int,unsigned int>::iterator,multimap<unsigned int,unsigned int>::iterator>
ret;
2008 ret = cleanedEcalBremElems.equal_range(latestBrem_index);
2009 multimap<unsigned int,unsigned int>::iterator it;
2010 for(it=ret.first; it!=ret.second; ++it) {
2011 GsfElemIndex.push_back((*it).second);
2012 if (DebugSetLinksDetailed)
2013 cout <<
"******************** Gsf Cluster From Brem " << (*it).second
2014 <<
" Latest Brem index " << latestBrem_index
2015 <<
" ************************* " << endl;
2019 unsigned int elToErase = 0;
2020 for(
unsigned int i = 0;
i<keyBremIndex.size();
i++) {
2021 if(latestBrem_index == keyBremIndex[
i]) {
2025 keyBremIndex.erase(keyBremIndex.begin()+elToErase);
2033 for(
unsigned int iConv=0; iConv<gsfIs.size(); iConv++) {
2041 if (DebugSetLinksDetailed)
2042 cout <<
" PFElectronAlgo:: I'm running on convGsfBrem " << endl;
2044 float conv_dist = block.
dist(gsfIs[iConv],gsfIs[iEle],
2046 if(conv_dist > 0.) {
2049 std::multimap<double, unsigned int> ecalConvElems;
2054 if(ecalConvElems.size() > 0) {
2056 if(localactive[(ecalConvElems.begin()->second)] ==
true) {
2057 if (DebugSetLinksDetailed)
2058 cout <<
" PFElectronAlgo:: convGsfBrem has a ECAL cluster linked and free" << endl;
2060 std::multimap<double, unsigned int> ecalOtherGsfPrimElems;
2062 ecalOtherGsfPrimElems,
2065 if(ecalOtherGsfPrimElems.size()>0) {
2066 unsigned int gsfprimcheck_index = ecalOtherGsfPrimElems.begin()->second;
2071 reco::PFClusterRef clusterRef = elements[ecalConvElems.begin()->second].clusterRef();
2072 if (DebugSetLinksDetailed)
2073 cout <<
" PFElectronAlgo: !!!!!!! convGsfBrem ECAL cluster has been stored !!!!!!! "
2074 <<
" Energy " << clusterRef->energy() <<
" eta,phi " << clusterRef->position().eta()
2075 <<
", " << clusterRef->position().phi() << endl;
2077 GsfElemIndex.push_back(ecalConvElems.begin()->second);
2078 convGsfTrack_.push_back(make_pair(ecalConvElems.begin()->second,gsfIs[iConv]));
2079 localactive[ecalConvElems.begin()->second] =
false;
2091 EcalIndex.insert(EcalIndex.end(),GsfElemIndex.begin(),GsfElemIndex.end());
2096 for(
unsigned int i =0;
i<keyBremIndex.size();
i++) {
2097 unsigned int ikey = keyBremIndex[
i];
2098 unsigned int ckey = cleanedEcalBremElems.count(ikey);
2099 vector<unsigned int> BremElemIndex(0);
2101 unsigned int temp_cal =
2102 cleanedEcalBremElems.find(ikey)->second;
2103 BremElemIndex.push_back(temp_cal);
2106 pair<multimap<unsigned int,unsigned int>::iterator,multimap<unsigned int,unsigned int>::iterator>
ret;
2107 ret = cleanedEcalBremElems.equal_range(ikey);
2108 multimap<unsigned int,unsigned int>::iterator it;
2109 for(it=ret.first; it!=ret.second; ++it) {
2110 BremElemIndex.push_back((*it).second);
2113 EcalIndex.insert(EcalIndex.end(),BremElemIndex.begin(),BremElemIndex.end());
2114 associatedToBrems_.insert(pair<
unsigned int,vector<unsigned int> >(ikey,BremElemIndex));
2119 vector<unsigned int> convBremKFTrack;
2120 convBremKFTrack.clear();
2121 if (kfElems.size() > 0) {
2122 for(std::multimap<double, unsigned int>::iterator itkf = kfElems.begin();
2123 itkf != kfElems.end(); ++itkf) {
2131 std::multimap<double, unsigned int> ecalConvElems;
2136 if(ecalConvElems.size() > 0) {
2142 float secpin = trkRef->p();
2146 float eneclust =clust->
clusterRef()->energy();
2152 std::multimap<double, unsigned int> hcalConvElems;
2158 bool isHoHE =
false;
2160 bool isPoHE =
false;
2162 float enehcalclust = -1;
2163 if(hcalConvElems.size() > 0) {
2166 enehcalclust =clusthcal->
clusterRef()->energy();
2168 if( (enehcalclust / (enehcalclust+eneclust) ) > 0.1 && Algo < 3) {
2170 if(enehcalclust > eneclust)
2172 if(secpin > (enehcalclust+eneclust) )
2178 if(localactive[(ecalConvElems.begin()->second)] ==
false) {
2180 if(isHoE || isPoHE) {
2181 if (DebugSetLinksDetailed)
2182 cout <<
"PFElectronAlgo:: LOCKED ECAL REJECTED TRACK FOR H/E or P/(H+E) "
2183 <<
" H/H+E " << enehcalclust/(enehcalclust+eneclust)
2184 <<
" H/E " << enehcalclust/eneclust
2185 <<
" P/(H+E) " << secpin/(enehcalclust+eneclust)
2186 <<
" HCAL ENE " << enehcalclust
2187 <<
" ECAL ENE " << eneclust
2188 <<
" secPIN " << secpin
2189 <<
" Algo Track " << Algo << endl;
2194 for(
unsigned int iecal =0; iecal < EcalIndex.size(); iecal++) {
2197 if(EcalIndex[iecal] == ecalConvElems.begin()->second) {
2198 if (DebugSetLinksDetailed)
2199 cout <<
" PFElectronAlgo:: Conv Brem Recovery locked cluster and I will lock also the KF track " << endl;
2200 convBremKFTrack.push_back(itkf->second);
2209 if (DebugSetLinksDetailed)
2210 cout <<
"PFElectronAlgo:: FREE ECAL REJECTED TRACK FOR H/H+E "
2211 <<
" H/H+E " << (enehcalclust / (enehcalclust+eneclust) )
2212 <<
" H/E " << enehcalclust/eneclust
2213 <<
" P/(H+E) " << secpin/(enehcalclust+eneclust)
2214 <<
" HCAL ENE " << enehcalclust
2215 <<
" ECAL ENE " << eneclust
2216 <<
" secPIN " << secpin
2217 <<
" Algo Track " << Algo << endl;
2222 std::multimap<double, unsigned int> ecalOtherKFPrimElems;
2224 ecalOtherKFPrimElems,
2227 if(ecalOtherKFPrimElems.size() > 0) {
2231 bool isFromGSF =
false;
2232 for(std::multimap<double, unsigned int>::iterator itclos = kfElems.begin();
2233 itclos != kfElems.end(); ++itclos) {
2234 if(ecalOtherKFPrimElems.begin()->second == itclos->second) {
2244 float Epin = eneclust/secpin;
2247 float totenergy = 0.;
2248 for(
unsigned int ikeyecal = 0;
2249 ikeyecal<EcalIndex.size(); ikeyecal++){
2251 bool foundcluster =
false;
2253 for(
unsigned int i2 = 0; i2<ikeyecal-1; i2++) {
2254 if(EcalIndex[ikeyecal] == EcalIndex[i2])
2255 foundcluster =
true;
2258 if(foundcluster)
continue;
2261 totenergy += clusasso->
clusterRef()->energy();
2266 if(totenergy == 0.) {
2267 if (DebugSetLinksDetailed)
2268 cout <<
"PFElectronAlgo:: REJECTED_NULLTOT totenergy " << totenergy << endl;
2274 double res_before = fabs((totenergy-Pin_gsf)/Pin_gsf);
2275 double res_after = fabs(((totenergy+eneclust)-Pin_gsf)/Pin_gsf);
2277 if(res_before < res_after) {
2278 if (DebugSetLinksDetailed)
2279 cout <<
"PFElectronAlgo::REJECTED_RES totenergy " << totenergy <<
" Pin_gsf " << Pin_gsf <<
" cluster to secondary " << eneclust
2280 <<
" Res before " << res_before <<
" res_after " << res_after << endl;
2285 if (DebugSetLinksDetailed)
2286 cout <<
"PFElectronAlgo:: conv brem found asso to ECAL linked to a secondary KF " << endl;
2287 convBremKFTrack.push_back(itkf->second);
2288 GsfElemIndex.push_back(ecalConvElems.begin()->second);
2289 EcalIndex.push_back(ecalConvElems.begin()->second);
2290 localactive[(ecalConvElems.begin()->second)] =
false;
2291 localactive[(itkf->second)] =
false;
2302 double sumEtEcalInTheCone = 0.;
2307 double PhiFC = clust->
clusterRef()->position().Phi();
2308 double EtaFC = clust->
clusterRef()->position().Eta();
2311 for(
unsigned int iEcal=0; iEcal<ecalIs.size(); iEcal++) {
2312 bool foundcluster =
false;
2313 for(
unsigned int ikeyecal = 0;
2314 ikeyecal<EcalIndex.size(); ikeyecal++){
2315 if(ecalIs[iEcal] == EcalIndex[ikeyecal])
2316 foundcluster =
true;
2320 if(foundcluster ==
false) {
2323 double eta_clust = clustExt->
clusterRef()->position().Eta();
2324 double phi_clust = clustExt->
clusterRef()->position().Phi();
2325 double theta_clust = clustExt->
clusterRef()->position().Theta();
2326 double deta_clust = eta_clust - EtaFC;
2327 double dphi_clust = phi_clust - PhiFC;
2328 if ( dphi_clust < -
M_PI )
2329 dphi_clust = dphi_clust + 2.*
M_PI;
2330 else if ( dphi_clust >
M_PI )
2331 dphi_clust = dphi_clust - 2.*
M_PI;
2332 double DR =
sqrt(deta_clust*deta_clust+
2333 dphi_clust*dphi_clust);
2337 vector<double> ps1Ene(0);
2338 vector<double> ps2Ene(0);
2342 double ET_calib = EE_calib*
sin(theta_clust);
2343 sumEtEcalInTheCone += ET_calib;
2349 unsigned int sumNTracksInTheCone = 0;
2350 double sumPtTracksInTheCone = 0.;
2351 for(
unsigned int iTrack=0; iTrack<trackIs.size(); iTrack++) {
2353 if(localactive[(trackIs[iTrack])]==
true) {
2358 double deta_trk = trkref->eta() - RefGSF->etaMode();
2359 double dphi_trk = trkref->phi() - RefGSF->phiMode();
2360 if ( dphi_trk < -
M_PI )
2361 dphi_trk = dphi_trk + 2.*
M_PI;
2362 else if ( dphi_trk >
M_PI )
2363 dphi_trk = dphi_trk - 2.*
M_PI;
2364 double DR =
sqrt(deta_trk*deta_trk+
2370 if(DR < coneTrackIsoForEgammaSC_ && NValPixelHit >=3) {
2371 sumNTracksInTheCone++;
2372 sumPtTracksInTheCone+=trkref->pt();
2379 bool isBarrelIsolated =
false;
2380 if( fabs(EtaFC < 1.478) &&
2383 isBarrelIsolated =
true;
2386 bool isEndcapIsolated =
false;
2387 if( fabs(EtaFC >= 1.478) &&
2390 isEndcapIsolated =
true;
2394 if(DebugSetLinksDetailed) {
2395 if(fabs(EtaFC < 1.478) && isBarrelIsolated ==
false) {
2396 cout <<
"**** PFElectronAlgo:: SUPERCLUSTER FOUND BUT FAILS ISOLATION:BARREL *** "
2397 <<
" sumEtEcalInTheCone " <<sumEtEcalInTheCone
2398 <<
" sumNTracksInTheCone " << sumNTracksInTheCone
2399 <<
" sumPtTracksInTheCone " << sumPtTracksInTheCone << endl;
2401 if(fabs(EtaFC >= 1.478) && isEndcapIsolated ==
false) {
2402 cout <<
"**** PFElectronAlgo:: SUPERCLUSTER FOUND BUT FAILS ISOLATION:ENDCAP *** "
2403 <<
" sumEtEcalInTheCone " <<sumEtEcalInTheCone
2404 <<
" sumNTracksInTheCone " << sumNTracksInTheCone
2405 <<
" sumPtTracksInTheCone " << sumPtTracksInTheCone << endl;
2412 if(isBarrelIsolated || isEndcapIsolated ) {
2416 double totenergy = 0.;
2417 for(
unsigned int ikeyecal = 0;
2418 ikeyecal<EcalIndex.size(); ikeyecal++){
2420 bool foundcluster =
false;
2422 for(
unsigned int i2 = 0; i2<ikeyecal-1; i2++) {
2423 if(EcalIndex[ikeyecal] == EcalIndex[i2])
2424 foundcluster =
true;;
2427 if(foundcluster)
continue;
2430 totenergy += clusasso->
clusterRef()->energy();
2436 for(
unsigned int ikeyecal = 0;
2437 ikeyecal<EcalIndex.size(); ikeyecal++){
2439 bool foundcluster =
false;
2441 for(
unsigned int i2 = 0; i2<ikeyecal-1; i2++) {
2442 if(EcalIndex[ikeyecal] == EcalIndex[i2])
2443 foundcluster =
true;
2446 if(foundcluster)
continue;
2449 std::multimap<double, unsigned int> ecalFromSuperClusterElems;
2451 ecalFromSuperClusterElems,
2454 if(ecalFromSuperClusterElems.size() > 0) {
2455 for(std::multimap<double, unsigned int>::iterator itsc = ecalFromSuperClusterElems.begin();
2456 itsc != ecalFromSuperClusterElems.end(); ++itsc) {
2457 if(localactive[itsc->second] ==
false) {
2461 std::multimap<double, unsigned int> ecalOtherKFPrimElems;
2463 ecalOtherKFPrimElems,
2466 if(ecalOtherKFPrimElems.size() > 0) {
2467 if(localactive[ecalOtherKFPrimElems.begin()->second] ==
true) {
2468 if (DebugSetLinksDetailed)
2469 cout <<
"**** PFElectronAlgo:: SUPERCLUSTER FOUND BUT FAILS KF VETO *** " << endl;
2473 bool isInTheEtaRange =
false;
2476 double deta_clustToAdd = clustToAdd->
clusterRef()->position().Eta() - EtaFC;
2477 double ene_clustToAdd = clustToAdd->
clusterRef()->energy();
2479 if(fabs(deta_clustToAdd) < 0.05)
2480 isInTheEtaRange =
true;
2483 bool isBetterEpin =
false;
2484 if(isInTheEtaRange ==
false ) {
2485 if (DebugSetLinksDetailed)
2486 cout <<
"**** PFElectronAlgo:: SUPERCLUSTER FOUND BUT FAILS GAMMA DETA RANGE *** "
2487 << fabs(deta_clustToAdd) << endl;
2489 if(KfGsf_index < CutIndex) {
2491 double res_before_gsf = fabs((totenergy-Pin_gsf)/Pin_gsf);
2492 double res_after_gsf = fabs(((totenergy+ene_clustToAdd)-Pin_gsf)/Pin_gsf);
2497 double Pin_kf = trackEl->
trackRef()->p();
2498 double res_before_kf = fabs((totenergy-Pin_kf)/Pin_kf);
2499 double res_after_kf = fabs(((totenergy+ene_clustToAdd)-Pin_kf)/Pin_kf);
2502 if(res_after_gsf < res_before_gsf && res_after_kf < res_before_kf ) {
2503 isBetterEpin =
true;
2506 if (DebugSetLinksDetailed)
2507 cout <<
"**** PFElectronAlgo:: SUPERCLUSTER FOUND AND FAILS ALSO RES_EPIN"
2508 <<
" tot energy " << totenergy
2509 <<
" Pin_gsf " << Pin_gsf
2510 <<
" Pin_kf " << Pin_kf
2511 <<
" cluster from SC to ADD " << ene_clustToAdd
2512 <<
" Res before GSF " << res_before_gsf <<
" res_after_gsf " << res_after_gsf
2513 <<
" Res before KF " << res_before_kf <<
" res_after_kf " << res_after_kf << endl;
2518 if(isInTheEtaRange || isBetterEpin) {
2519 if (DebugSetLinksDetailed)
2520 cout <<
"!!!! PFElectronAlgo:: ECAL from SUPERCLUSTER FOUND !!!!! " << endl;
2521 GsfElemIndex.push_back(itsc->second);
2522 EcalIndex.push_back(itsc->second);
2523 localactive[(itsc->second)] =
false;
2532 if(KfGsf_index < CutIndex)
2533 GsfElemIndex.push_back(KfGsf_index);
2534 else if(KfGsf_secondIndex < CutIndex)
2535 GsfElemIndex.push_back(KfGsf_secondIndex);
2538 GsfElemIndex.insert(GsfElemIndex.end(),convBremKFTrack.begin(),convBremKFTrack.end());
2539 GsfElemIndex.insert(GsfElemIndex.end(),keyBremIndex.begin(),keyBremIndex.end());
2540 associatedToGsf_.insert(pair<
unsigned int, vector<unsigned int> >(gsfIs[iEle],GsfElemIndex));
2543 for(
unsigned int ikeyecal = 0;
2544 ikeyecal<EcalIndex.size(); ikeyecal++){
2547 vector<unsigned int> EcalElemsIndex(0);
2549 std::multimap<double, unsigned int> PS1Elems;
2554 for( std::multimap<double, unsigned int>::iterator it = PS1Elems.begin();
2555 it != PS1Elems.end();it++) {
2556 unsigned int index = it->second;
2557 if(localactive[index] ==
true) {
2560 std::multimap<double, unsigned> sortedECAL;
2565 unsigned jEcal = sortedECAL.begin()->second;
2566 if ( jEcal != EcalIndex[ikeyecal])
continue;
2569 EcalElemsIndex.push_back(index);
2570 localactive[
index] =
false;
2574 std::multimap<double, unsigned int> PS2Elems;
2579 for( std::multimap<double, unsigned int>::iterator it = PS2Elems.begin();
2580 it != PS2Elems.end();it++) {
2581 unsigned int index = it->second;
2582 if(localactive[index] ==
true) {
2584 std::multimap<double, unsigned> sortedECAL;
2589 unsigned jEcal = sortedECAL.begin()->second;
2590 if ( jEcal != EcalIndex[ikeyecal])
continue;
2592 EcalElemsIndex.push_back(index);
2593 localactive[
index] =
false;
2600 std::multimap<double, unsigned int> hcalGsfElems;
2605 for( std::multimap<double, unsigned int>::iterator it = hcalGsfElems.begin();
2606 it != hcalGsfElems.end();it++) {
2607 unsigned int index = it->second;
2620 EcalElemsIndex.push_back(index);
2621 localactive[
index] =
false;
2626 if(hcalGsfElems.size() == 0 && ClosestEcalWithKf ==
true) {
2627 std::multimap<double, unsigned int> hcalKfElems;
2632 for( std::multimap<double, unsigned int>::iterator it = hcalKfElems.begin();
2633 it != hcalKfElems.end();it++) {
2634 unsigned int index = it->second;
2635 if(localactive[index] ==
true) {
2638 std::multimap<double, unsigned> sortedKf;
2643 unsigned jKf = sortedKf.begin()->second;
2644 if ( jKf != KfGsf_index)
continue;
2645 EcalElemsIndex.push_back(index);
2646 localactive[
index] =
false;
2651 std::multimap<double, unsigned int> kfEtraElems;
2656 if(kfEtraElems.size() > 0) {
2657 for( std::multimap<double, unsigned int>::iterator it = kfEtraElems.begin();
2658 it != kfEtraElems.end();it++) {
2659 unsigned int index = it->second;
2667 bool thisIsAMuon =
false;
2669 if (DebugSetLinksDetailed && thisIsAMuon)
2670 cout <<
" This is a Muon: index " << index << endl;
2671 if(localactive[index] ==
true && !thisIsAMuon) {
2672 if(index != KfGsf_index) {
2675 std::multimap<double, unsigned> sortedECAL;
2680 unsigned jEcal = sortedECAL.begin()->second;
2681 if ( jEcal != EcalIndex[ikeyecal])
continue;
2682 EcalElemsIndex.push_back(index);
2683 localactive[
index] =
false;
2690 associatedToEcal_.insert(pair<
unsigned int,vector<unsigned int> >(EcalIndex[ikeyecal],EcalElemsIndex));
2699 if (DebugSetLinksSummary) {
2700 if(IsThereAGoodGSFTrack) {
2701 if (DebugSetLinksSummary)
cout <<
" -- The Link Summary --" << endl;
2702 for(
map<
unsigned int,vector<unsigned int> >::iterator it = associatedToGsf_.begin();
2703 it != associatedToGsf_.end(); it++) {
2705 if (DebugSetLinksSummary)
cout <<
" AssoGsf " << it->first << endl;
2706 vector<unsigned int> eleasso = it->second;
2707 for(
unsigned int i=0;
i<eleasso.size();
i++) {
2710 if (DebugSetLinksSummary)
2711 cout <<
" AssoGsfElements BREM " << eleasso[
i] << endl;
2714 if (DebugSetLinksSummary)
2715 cout <<
" AssoGsfElements ECAL " << eleasso[
i] << endl;
2718 if (DebugSetLinksSummary)
2719 cout <<
" AssoGsfElements KF " << eleasso[
i] << endl;
2722 if (DebugSetLinksSummary)
2723 cout <<
" AssoGsfElements ????? " << eleasso[
i] << endl;
2728 for(
map<
unsigned int,vector<unsigned int> >::iterator it = associatedToBrems_.begin();
2729 it != associatedToBrems_.end(); it++) {
2730 if (DebugSetLinksSummary)
cout <<
" AssoBrem " << it->first << endl;
2731 vector<unsigned int> eleasso = it->second;
2732 for(
unsigned int i=0;
i<eleasso.size();
i++) {
2735 if (DebugSetLinksSummary)
2736 cout <<
" AssoBremElements ECAL " << eleasso[
i] << endl;
2739 if (DebugSetLinksSummary)
2740 cout <<
" AssoBremElements ????? " << eleasso[
i] << endl;
2745 for(
map<
unsigned int,vector<unsigned int> >::iterator it = associatedToEcal_.begin();
2746 it != associatedToEcal_.end(); it++) {
2747 if (DebugSetLinksSummary)
cout <<
" AssoECAL " << it->first << endl;
2748 vector<unsigned int> eleasso = it->second;
2749 for(
unsigned int i=0;
i<eleasso.size();
i++) {
2752 if (DebugSetLinksSummary)
2753 cout <<
" AssoECALElements PS1 " << eleasso[
i] << endl;
2756 if (DebugSetLinksSummary)
2757 cout <<
" AssoECALElements PS2 " << eleasso[
i] << endl;
2760 if (DebugSetLinksSummary)
2761 cout <<
" AssoECALElements HCAL " << eleasso[
i] << endl;
2764 if (DebugSetLinksSummary)
2765 cout <<
" AssoHCALElements ????? " << eleasso[
i] << endl;
2769 if (DebugSetLinksSummary)
2770 cout <<
"-- End Summary --" << endl;
2775 return IsThereAGoodGSFTrack;
2779 unsigned int Algo = 0;
2780 switch (trackRef->algo()) {
2781 case TrackBase::ctf:
2782 case TrackBase::iter0:
2783 case TrackBase::iter1:
2784 case TrackBase::iter2:
2787 case TrackBase::iter3:
2790 case TrackBase::iter4:
2793 case TrackBase::iter5:
2796 case TrackBase::iter6:
2807 bool isPrimary =
false;
2813 PFRecTrackRef kfPfRef_fromGsf = (*gsfPfRef).kfPFRecTrackRef();
2818 if(kfref == kfref_fromGsf)
2828 std::vector<unsigned int> &elemsToLock,
2830 AssMap& associatedToGsf_,
2831 AssMap& associatedToBrems_,
2832 AssMap& associatedToEcal_){
2856 elemsToLock.push_back(gsf_index);
2857 vector<unsigned int> &assogsf_index = associatedToGsf_[gsf_index];
2858 for (
unsigned int ielegsf=0;ielegsf<assogsf_index.size();ielegsf++) {
2861 elemsToLock.push_back((assogsf_index[ielegsf]));
2863 unsigned int keyecalgsf = assogsf_index[ielegsf];
2876 for(
unsigned int iconv = 0; iconv <
convGsfTrack_.size(); iconv++) {
2881 std::multimap<double, unsigned> convKf;
2887 if(convKf.size() > 0) {
2888 elemsToLock.push_back(convKf.begin()->second);
2895 vector<unsigned int> assoecalgsf_index = associatedToEcal_.find(keyecalgsf)->second;
2896 for(
unsigned int ips =0; ips<assoecalgsf_index.size();ips++) {
2899 elemsToLock.push_back((assoecalgsf_index[ips]));
2901 elemsToLock.push_back(assoecalgsf_index[ips]);
2911 unsigned int brem_index = assogsf_index[ielegsf];
2912 vector<unsigned int> assobrem_index = associatedToBrems_.find(brem_index)->second;
2913 for (
unsigned int ibrem = 0; ibrem < assobrem_index.size(); ibrem++){
2915 unsigned int keyecalbrem = assobrem_index[ibrem];
2917 elemsToLock.push_back(assobrem_index[ibrem]);
2928 vector<unsigned int> assoelebrem_index = associatedToEcal_.find(keyecalbrem)->second;
2930 for (
unsigned int ielebrem=0; ielebrem<assoelebrem_index.size();ielebrem++) {
2932 elemsToLock.push_back(assoelebrem_index[ielebrem]);
2934 elemsToLock.push_back(assoelebrem_index[ielebrem]);
2948 std::vector<unsigned int> &elemsToLock,
2950 AssMap& associatedToGsf_,
2951 AssMap& associatedToBrems_,
2952 AssMap& associatedToEcal_,
2953 std::vector<bool>& active) {
2961 bool DebugIDCandidates =
false;
2972 float dpt=0;
float dpt_gsf=0;
2973 float Eene=0;
float dene=0;
float Hene=0.;
2978 std::vector<float> bremEnergyVec;
2980 std::vector<const PFCluster*> pfSC_Clust_vec;
2982 float de_gs = 0., de_me = 0., de_kf = 0.;
2988 float ps1TotEne = 0;
2989 float ps2TotEne = 0;
2990 vector<unsigned int> elementsToAdd(0);
2995 elementsToAdd.push_back(gsf_index);
3004 charge= RefGSF->chargeMode();
3005 nhit_gsf= RefGSF->hitPattern().trackerLayersWithMeasurement();
3007 momentum_gsf.SetPx(RefGSF->pxMode());
3008 momentum_gsf.SetPy(RefGSF->pyMode());
3009 momentum_gsf.SetPz(RefGSF->pzMode());
3010 float ENE=
sqrt(RefGSF->pMode()*
3011 RefGSF->pMode()+m_el*m_el);
3013 if( DebugIDCandidates )
3014 cout <<
"SetCandidates:: GsfTrackRef: Ene " << ENE
3015 <<
" charge " << charge <<
" nhits " << nhit_gsf <<endl;
3017 momentum_gsf.SetE(ENE);
3018 dpt_gsf=RefGSF->ptModeError()*
3019 (RefGSF->pMode()/RefGSF->ptMode());
3021 momentum_mean.SetPx(RefGSF->px());
3022 momentum_mean.SetPy(RefGSF->py());
3023 momentum_mean.SetPz(RefGSF->pz());
3024 float ENEm=
sqrt(RefGSF->p()*
3025 RefGSF->p()+m_el*m_el);
3026 momentum_mean.SetE(ENEm);
3031 if( DebugIDCandidates )
3032 cout <<
"SetCandidates:: !!!! NULL GSF Track Ref " << endl;
3036 vector<unsigned int> &assogsf_index = associatedToGsf_[gsf_index];
3037 unsigned int ecalGsf_index = 100000;
3038 bool FirstEcalGsf =
true;
3039 for (
unsigned int ielegsf=0;ielegsf<assogsf_index.size();ielegsf++) {
3042 elementsToAdd.push_back((assogsf_index[ielegsf]));
3047 if(!isPrim)
continue;
3053 nhit_kf=RefKF->hitPattern().trackerLayersWithMeasurement();
3054 momentum_kf.SetPx(RefKF->px());
3055 momentum_kf.SetPy(RefKF->py());
3056 momentum_kf.SetPz(RefKF->pz());
3057 float ENE=
sqrt(RefKF->p()*RefKF->p()+m_el*m_el);
3058 if( DebugIDCandidates )
3059 cout <<
"SetCandidates:: KFTrackRef: Ene " << ENE <<
" nhits " << nhit_kf << endl;
3061 momentum_kf.SetE(ENE);
3064 if( DebugIDCandidates )
3065 cout <<
"SetCandidates:: !!!! NULL KF Track Ref " << endl;
3070 unsigned int keyecalgsf = assogsf_index[ielegsf];
3071 vector<unsigned int> assoecalgsf_index = associatedToEcal_.find(keyecalgsf)->second;
3072 vector<double> ps1Ene(0);
3073 vector<double> ps2Ene(0);
3077 for(
unsigned int ips =0; ips<assoecalgsf_index.size();ips++) {
3080 PFClusterRef psref = elements[(assoecalgsf_index[ips])].clusterRef();
3081 ps1Ene.push_back(psref->energy());
3082 elementsToAdd.push_back((assoecalgsf_index[ips]));
3085 PFClusterRef psref = elements[(assoecalgsf_index[ips])].clusterRef();
3086 ps2Ene.push_back(psref->energy());
3087 elementsToAdd.push_back((assoecalgsf_index[ips]));
3092 elementsToAdd.push_back((assoecalgsf_index[ips]));
3097 elementsToAdd.push_back((assogsf_index[ielegsf]));
3115 float ceta=cl.position().eta();
3116 float cphi=cl.position().phi();
3129 if( DebugIDCandidates )
3130 cout <<
"SetCandidates:: EcalCluster: EneNoCalib " << clust->
clusterRef()->energy()
3131 <<
" eta,phi " << ceta <<
"," << cphi <<
" Calib " << EE <<
" dE " << dE <<endl;
3133 bool elecCluster=
false;
3135 FirstEcalGsf =
false;
3137 ecalGsf_index = assogsf_index[ielegsf];
3145 clusterMomentum.SetPxPyPzE(EE*direction.x(),
3178 posX += EE * cl.position().X();
3179 posY += EE * cl.position().Y();
3180 posZ += EE * cl.position().Z();
3186 pfSC_Clust_vec.push_back( &cl );
3194 unsigned int brem_index = assogsf_index[ielegsf];
3195 vector<unsigned int> assobrem_index = associatedToBrems_.find(brem_index)->second;
3196 elementsToAdd.push_back(brem_index);
3197 for (
unsigned int ibrem = 0; ibrem < assobrem_index.size(); ibrem++){
3200 if( assobrem_index[ibrem] != ecalGsf_index) {
3201 unsigned int keyecalbrem = assobrem_index[ibrem];
3202 const vector<unsigned int>& assoelebrem_index = associatedToEcal_.find(keyecalbrem)->second;
3203 vector<double> ps1EneFromBrem(0);
3204 vector<double> ps2EneFromBrem(0);
3205 for (
unsigned int ielebrem=0; ielebrem<assoelebrem_index.size();ielebrem++) {
3207 PFClusterRef psref = elements[(assoelebrem_index[ielebrem])].clusterRef();
3208 ps1EneFromBrem.push_back(psref->energy());
3209 elementsToAdd.push_back(assoelebrem_index[ielebrem]);
3212 PFClusterRef psref = elements[(assoelebrem_index[ielebrem])].clusterRef();
3213 ps2EneFromBrem.push_back(psref->energy());
3214 elementsToAdd.push_back(assoelebrem_index[ielebrem]);
3217 elementsToAdd.push_back(assobrem_index[ibrem]);
3224 bremEnergyVec.push_back(EE);
3226 float ceta = clusterRef->position().eta();
3229 if( DebugIDCandidates )
3230 cout <<
"SetCandidates:: BremCluster: Ene " << EE <<
" dE " << dE <<endl;
3233 posX += EE * clusterRef->position().X();
3234 posY += EE * clusterRef->position().Y();
3235 posZ += EE * clusterRef->position().Z();
3243 pfSC_Clust_vec.push_back( clusterRef.
get() );
3248 math::XYZPoint direction=clusterRef->position()/clusterRef->position().R();
3250 photonMomentum.SetPxPyPzE(EE*direction.x(),
3289 double unCorrEene = Eene;
3290 double absEta = fabs(momentum_gsf.Eta());
3291 double emTheta = momentum_gsf.Theta();
3294 pfSC_Clust_vec.clear();
3296 if( DebugIDCandidates )
3297 cout <<
"PFEelectronAlgo:: absEta " << absEta <<
" theta " << emTheta
3298 <<
" EneRaw " << Eene <<
" Err " << dene;
3304 double Etene = Eene*
sin(emTheta);
3306 double emBR_et = emBR_e*
sin(emTheta);
3308 Eene = emCorrFull_et/
sin(emTheta);
3313 double emBR_et = emBR_e*
sin(emTheta);
3315 Eene = emCorrFull_et/
sin(emTheta);
3317 dene =
sqrt(dene)*(Eene/unCorrEene);
3321 if( DebugIDCandidates )
3322 cout <<
" EneCorrected " << Eene <<
" Err " << dene << endl;
3327 if(has_kf && unCorrEene > 0.) {
3333 std::multimap<double, unsigned int> bremElems;
3339 double phiTrack = RefGSF->phiMode();
3340 if(bremElems.size()>0) {
3341 unsigned int brem_index = bremElems.begin()->second;
3347 double dphi_normalsc = sc_pflow.Phi() - phiTrack;
3348 if ( dphi_normalsc < -
M_PI )
3349 dphi_normalsc = dphi_normalsc + 2.*
M_PI;
3350 else if ( dphi_normalsc >
M_PI )
3351 dphi_normalsc = dphi_normalsc - 2.*
M_PI;
3353 int chargeGsf = RefGSF->chargeMode();
3354 int chargeKf = RefKF->charge();
3357 if(dphi_normalsc < 0.)
3362 if(chargeKf == chargeGsf)
3364 else if(chargeGsf == chargeSC)
3369 if( DebugIDCandidates )
3370 cout <<
"PFElectronAlgo:: charge determination "
3371 <<
" charge GSF " << chargeGsf
3372 <<
" charge KF " << chargeKf
3373 <<
" charge SC " << chargeSC
3374 <<
" Final Charge " << charge << endl;
3379 if ((nhit_gsf<8) && (has_kf)){
3383 momentum=momentum_kf;
3385 float scale= Fe/momentum.E();
3388 if (Eene < 0.0001) {
3394 newmomentum.SetPxPyPzE(scale*momentum.Px(),
3395 scale*momentum.Py(),
3396 scale*momentum.Pz(),Fe);
3397 if( DebugIDCandidates )
3398 cout <<
"SetCandidates:: (nhit_gsf<8) && (has_kf):: pt " << newmomentum.pt() <<
" Ene " << Fe <<endl;
3402 if ((nhit_gsf>7) || (has_kf==
false)){
3404 de_gs=1-momentum_gsf.E()/Eene;
3405 de_me=1-momentum_mean.E()/Eene;
3406 de_kf=1-momentum_kf.E()/Eene;
3409 momentum=momentum_gsf;
3410 dpt=1/(dpt_gsf*dpt_gsf);
3417 Fe =((dene*Eene) +(dpt*momentum.E()))/(dene+dpt);
3423 if ((de_gs>0.05)&&(de_kf>0.05)){
3426 if ((de_gs<-0.1)&&(de_me<-0.1) &&(de_kf<0.) &&
3427 (momentum.E()/dpt_gsf) > 5. && momentum_gsf.pt() < 30.){
3430 float scale= Fe/momentum.E();
3432 newmomentum.SetPxPyPzE(scale*momentum.Px(),
3433 scale*momentum.Py(),
3434 scale*momentum.Pz(),Fe);
3435 if( DebugIDCandidates )
3436 cout <<
"SetCandidates::(nhit_gsf>7) || (has_kf==false) " << newmomentum.pt() <<
" Ene " << Fe <<endl;
3440 if (newmomentum.pt()>0.5){
3445 if( DebugIDCandidates )
3446 cout <<
"SetCandidates:: I am before doing candidate " <<endl;
3449 std::vector<float> clusterEnergyVec;
3450 clusterEnergyVec.push_back(RawEene);
3451 clusterEnergyVec.insert(clusterEnergyVec.end(),bremEnergyVec.begin(),bremEnergyVec.end());
3500 if( DebugIDCandidates )
3501 cout <<
"SetCandidates:: I am after doing candidate " <<endl;
3551 myExtraEqual.
setStatus(PFCandidateEGammaExtra::Selected,
true);
3554 for(std::vector<unsigned int>::const_iterator it = elemsToLock.begin();
3555 it != elemsToLock.end(); ++it)
3561 active[*it] =
false;
3592 if( DebugIDCandidates )
3593 cout <<
"SetCandidates:: No Candidate Produced because of Pt cut: 0.5 " <<endl;
3599 if( DebugIDCandidates )
3600 cout <<
"SetCandidates:: No Candidate Produced because of No GSF Track Ref " <<endl;
std::vector< reco::PFCandidateEGammaExtra > egExtra_
float EtotBremPinPoutMode
std::vector< int > match_ind
double GetResponse(const float *vector) const
const math::XYZTLorentzVector & Pout() const
virtual double energy() const GCC11_FINAL
energy
void setPs2Energy(float e2)
set corrected PS2 energy
Abstract base class for a PFBlock element (track, cluster...)
const math::XYZPointF & positionAtECALEntrance() const
bool EvaluateSingleLegMVA(const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
unsigned int whichTrackAlgo(const reco::TrackRef &trackRef)
void setPs1Energy(float e1)
set corrected PS1 energy
boost::shared_ptr< PFSCEnergyCalibration > thePFSCEnergyCalibration_
void MustacheClust(const std::vector< CaloCluster > &clusters, std::vector< unsigned int > &insideMust, std::vector< unsigned int > &outsideMust)
ParticleType
particle types
bool useEGammaSupercluster_
std::vector< std::pair< unsigned int, unsigned int > > fifthStepKfTrack_
void addSingleLegConvTrackRef(const reco::TrackRef &trackref)
add Single Leg Conversion TrackRef
void RunPFEG(const reco::PFBlockRef &blockRef, std::vector< bool > &active)
void setStatus(StatusFlag type, bool status=true)
set status
std::vector< unsigned int > AddFromElectron_
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
trackRef_iterator tracks_end() const
last iterator over tracks
bool SetLinks(const reco::PFBlockRef &blockRef, AssMap &associatedToGsf_, AssMap &associatedToBrems_, AssMap &associatedToEcal_, std::vector< bool > &active, const reco::Vertex &primaryVertex)
static bool isMuon(const reco::PFBlockElement &elt)
void setPositionAtECALEntrance(const math::XYZPointF &pos)
set position at ECAL entrance
bool applyCrackCorrections_
PFClusterRef clusterRef() const
const reco::Vertex * primaryVertex_
double y() const
y coordinate
const math::XYZPointF & positionAtECALEntrance() const
Sin< T >::type sin(const T &t)
std::map< unsigned int, Link > LinkData
Geom::Phi< T > phi() const
double pflowPhiWidth() const
Geom::Theta< T > theta() const
bool isPrimaryTrack(const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
const edm::OwnVector< reco::PFBlockElement > & elements() const
const GBRForest * ReaderGCEElR9_
void EarlyConversion(std::vector< reco::PFCandidate > &tempElectronCandidates, const reco::PFBlockElementSuperCluster *sc)
const GBRForest * ReaderGCEB_
const LinkData & linkData() const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
unsigned int indTrajPoint() const
double E5x5Element(int i, int j)
std::pair< double, double > GetCrysCoor()
double pflowEtaWidth() const
std::vector< ElementInBlock > ElementsInBlocks
static int position[TOTALCHAMBERS][3]
boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_
float EvaluateGCorrMVA(reco::PFCandidate, std::vector< reco::CaloCluster >PFClusters)
const ElementsInBlocks & elementsInBlocks() const
void AddElectronElements(unsigned int gsf_index, std::vector< unsigned int > &elemsToLock, const reco::PFBlockRef &blockRef, AssMap &associatedToGsf_, AssMap &associatedToBrems_, AssMap &associatedToEcal_)
const GBRForest * ReaderGCEEhR9_
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
bool isNonnull() const
Checks for non-null.
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
double ClustersPhiRMS(std::vector< reco::CaloCluster >PFClusters, float PFPhoPhi)
float EvaluateLCorrMVA(reco::PFClusterRef clusterRef)
void setVertexSource(PFVertexType vt)
double getEnergyResolutionEm(double CorrectedEnergy, double eta) const
std::pair< double, double > GetCrysIndex()
void addElementInBlock(const reco::PFBlockRef &blockref, unsigned elementIndex)
add an element to the current PFCandidate
double sumPtTrackIsoForEgammaSC_endcap_
virtual reco::TrackRef trackRef() const
reco::GsfTrackRef GsftrackRef() const
Cos< T >::type cos(const T &t)
const GBRForest * ReaderLCEB_
bool AddElectronCandidate(unsigned int gsf_index, reco::SuperClusterRef scref, std::vector< unsigned int > &elemsToLock, const reco::PFBlockRef &blockRef, AssMap &associatedToGsf_, AssMap &associatedToBrems_, AssMap &associatedToEcal_, std::vector< bool > &active)
double z() const
y coordinate
SuperClusterRef superClusterRef() const
unsigned int nTrackIsoForEgammaSC_
void setSuperClusterBoxRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
virtual bool trackType(TrackType trType) const
block
Formating index page's pieces.
double sumPtTrackIsoForEgammaSC_barrel_
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
void setClusterEnergies(const std::vector< float > &energies)
set the cluster energies. the Pout should be saved first
double x() const
x coordinate
virtual bool trackType(TrackType trType) const
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
void addSingleLegConvMva(float &mvasingleleg)
add Single Leg Conversion mva
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
XYZPointD XYZPoint
point in space with cartesian internal representation
float EvaluateResMVA(reco::PFCandidate, std::vector< reco::CaloCluster >PFClusters)
double coneEcalIsoForEgammaSC_
std::vector< std::pair< unsigned int, unsigned int > > convGsfTrack_
void addConversionRef(const reco::ConversionRef &convref)
add Conversions from PF
TMVA::Reader * tmvaReaderEle_
reco::TrackRef trackRef() const
const GBRForest * ReaderLCEE_
std::map< unsigned int, std::vector< unsigned int > > AssMap
Particle reconstructed by the particle flow algorithm.
double sumEtEcalIsoForEgammaSC_endcap_
double sumEtEcalIsoForEgammaSC_barrel_
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
const GBRForest * ReaderRes_
int numberOfValidPixelHits() const
GsfPFRecTrackRef GsftrackRefPF() const
size_type size() const
Size of the RefVector.
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
double dist(unsigned ie1, unsigned ie2, const LinkData &linkData, LinkTest test) const
void FillMustacheVar(const std::vector< CaloCluster > &clusters)
TMVA::Reader * tmvaReader_
trackRef_iterator tracks_begin() const
first iterator over tracks
verbosityLevel verbosityLevel_
T const * get() const
Returns C++ pointer to the item.
void setTrackRef(const reco::TrackRef &ref)
set track reference
PFEGammaAlgo(const double mvaEleCut, std::string mvaWeightFileEleID, const boost::shared_ptr< PFSCEnergyCalibration > &thePFSCEnergyCalibration, const boost::shared_ptr< PFEnergyCalibration > &thePFEnergyCalibration, bool applyCrackCorrections, bool usePFSCEleCalib, bool useEGElectrons, bool useEGammaSupercluster, double sumEtEcalIsoForEgammaSC_barrel, double sumEtEcalIsoForEgammaSC_endcap, double coneEcalIsoForEgammaSC, double sumPtTrackIsoForEgammaSC_barrel, double sumPtTrackIsoForEgammaSC_endcap, unsigned int nTrackIsoForEgammaSC, double coneTrackIsoForEgammaSC, std::string mvaweightfile, double mvaConvCut, bool useReg, std::string X0_Map, const reco::Vertex &primary, double sumPtTrackIsoForPhoton, double sumPtTrackIsoSlopeForPhoton)
std::vector< reco::PFCandidate > egCandidate_
void setHcalEnergy(float ehRaw, float ehCorr)
set corrected Hcal energy
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any