CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
PFEGammaAlgo Class Reference

#include <PFEGammaAlgo.h>

Public Member Functions

const std::vector
< reco::PFCandidate > & 
getCandidates ()
 
const std::vector
< reco::PFCandidateEGammaExtra > & 
getEGExtra ()
 
bool isEGValidCandidate (const reco::PFBlockRef &blockRef, std::vector< bool > &active)
 
 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)
 
void setGBRForest (const GBRForest *LCorrForest, const GBRForest *GCorrForest, const GBRForest *ResForest)
 
void setGBRForest (const GBRForest *LCorrForestEB, const GBRForest *LCorrForestEE, const GBRForest *GCorrForestBarrel, const GBRForest *GCorrForestEndcapHr9, const GBRForest *GCorrForestEndcapLr9, const GBRForest *PFEcalResolution)
 
void setnPU (int nVtx)
 
void setPhotonPrimaryVtx (const reco::Vertex &primary)
 
 ~PFEGammaAlgo ()
 

Private Types

typedef std::map< unsigned int,
std::vector< unsigned int > > 
AssMap
 
enum  verbosityLevel { Silent, Summary, Chatty }
 

Private Member Functions

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)
 
void AddElectronElements (unsigned int gsf_index, std::vector< unsigned int > &elemsToLock, const reco::PFBlockRef &blockRef, AssMap &associatedToGsf_, AssMap &associatedToBrems_, AssMap &associatedToEcal_)
 
double ClustersPhiRMS (std::vector< reco::CaloCluster >PFClusters, float PFPhoPhi)
 
void EarlyConversion (std::vector< reco::PFCandidate > &tempElectronCandidates, const reco::PFBlockElementSuperCluster *sc)
 
float EvaluateGCorrMVA (reco::PFCandidate, std::vector< reco::CaloCluster >PFClusters)
 
float EvaluateLCorrMVA (reco::PFClusterRef clusterRef)
 
float EvaluateResMVA (reco::PFCandidate, std::vector< reco::CaloCluster >PFClusters)
 
bool EvaluateSingleLegMVA (const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
 
std::vector< int > getPFMustacheClus (int nClust, std::vector< float > &ClustEt, std::vector< float > &ClustEta, std::vector< float > &ClustPhi)
 
bool isPrimaryTrack (const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
 
void RunPFEG (const reco::PFBlockRef &blockRef, std::vector< bool > &active)
 
bool SetLinks (const reco::PFBlockRef &blockRef, AssMap &associatedToGsf_, AssMap &associatedToBrems_, AssMap &associatedToEcal_, std::vector< bool > &active, const reco::Vertex &primaryVertex)
 
unsigned int whichTrackAlgo (const reco::TrackRef &trackRef)
 

Private Attributes

std::vector< unsigned int > AddFromElectron_
 
bool applyCrackCorrections_
 
float chi2
 
float chi2_gsf
 
float chi2_kf
 
float Clus5x5ratio_
 
float ClusEta_
 
float ClusPhi_
 
float ClusR9_
 
double coneEcalIsoForEgammaSC_
 
double coneTrackIsoForEgammaSC_
 
std::vector< std::pair
< unsigned int, unsigned int > > 
convGsfTrack_
 
float CrysEta_
 
int CrysIEta_
 
int CrysIPhi_
 
float CrysPhi_
 
float CrysX_
 
float CrysY_
 
float del_phi
 
float dEta_
 
float DEtaGsfEcalClust
 
float dPhi_
 
float dPtOverPt_gsf
 
float DPtOverPt_gsf
 
float DPtOverPt_kf
 
float e1x3_
 
float e1x5_
 
float e2x5Bottom_
 
float e2x5Left_
 
float e2x5Max_
 
float e2x5Right_
 
float e2x5Top_
 
float e3x1_
 
float e3x3_
 
float E3x3_
 
float e5x5Map [5][5]
 
float earlyBrem
 
float EB
 
float ebottom_
 
std::vector< reco::PFCandidateegCandidate_
 
std::vector
< reco::PFCandidateEGammaExtra
egExtra_
 
float EGsfPoutMode
 
float eleft_
 
float EoverPt
 
float eright_
 
float eSeed_
 
float Eta_gsf
 
float etop_
 
float EtotBremPinPoutMode
 
float EtotPinMode
 
float excluded_
 
std::vector< std::pair
< unsigned int, unsigned int > > 
fifthStepKfTrack_
 
float firstBrem
 
std::vector< bool > GsfTrackSingleEcal_
 
float HOverHE
 
float HOverPin
 
float HoverPt
 
bool isvalid_
 
float lateBrem
 
float lnPt_gsf
 
std::vector< bool > lockExtraKf_
 
float logPFClusE_
 
float LowClusE_
 
std::vector< int > match_ind
 
float Mustache_Et_out_
 
float Mustache_EtRatio_
 
float MustE_
 
double MVACUT
 
double mvaEleCut_
 
double mvaValue
 
const char * mvaWeightFile_
 
float nhit_gsf
 
float nhit_kf
 
float nlayers
 
float nlost
 
float nPFClus_
 
unsigned int nTrackIsoForEgammaSC_
 
float nVtx_
 
std::vector< reco::PFCandidatepermElectronCandidates_
 
float PFCrysEtaCrack_
 
float PFPhoE_
 
float PFPhoECorr_
 
float PFPhoEt_
 
float PFPhoEta_
 
float PFPhoEtCorr_
 
float PFPhoPhi_
 
float PFPhoR9_
 
float PFPhoR9Corr_
 
const reco::VertexprimaryVertex_
 
float RConv_
 
const GBRForestReaderGC_
 
const GBRForestReaderGCEB_
 
const GBRForestReaderGCEEhR9_
 
const GBRForestReaderGCEElR9_
 
const GBRForestReaderLC_
 
const GBRForestReaderLCEB_
 
const GBRForestReaderLCEE_
 
const GBRForestReaderRes_
 
float RMSAll_
 
float RMSMust_
 
float SCEtaWidth_
 
float SCPhiWidth_
 
float SigmaEtaEta
 
float STIP
 
double sumEtEcalIsoForEgammaSC_barrel_
 
double sumEtEcalIsoForEgammaSC_endcap_
 
double sumPtTrackIsoForEgammaSC_barrel_
 
double sumPtTrackIsoForEgammaSC_endcap_
 
double sumPtTrackIsoForPhoton_
 
double sumPtTrackIsoSlopeForPhoton_
 
boost::shared_ptr
< PFEnergyCalibration
thePFEnergyCalibration_
 
boost::shared_ptr
< PFSCEnergyCalibration
thePFSCEnergyCalibration_
 
TMVA::Reader * tmvaReader_
 
TMVA::Reader * tmvaReaderEle_
 
float TotPS1_
 
float TotPS2_
 
float track_pt
 
bool useEGammaSupercluster_
 
bool useEGElectrons_
 
bool usePFSCEleCalib_
 
bool useReg_
 
verbosityLevel verbosityLevel_
 
float VtxZ_
 
TH2D * X0_inner
 
TH2D * X0_middle
 
TH2D * X0_outer
 
TH2D * X0_sum
 
float x0inner_
 
float x0middle_
 
float x0outer_
 

Detailed Description

Definition at line 38 of file PFEGammaAlgo.h.

Member Typedef Documentation

typedef std::map< unsigned int, std::vector<unsigned int> > PFEGammaAlgo::AssMap
private

Definition at line 114 of file PFEGammaAlgo.h.

Member Enumeration Documentation

Enumerator
Silent 
Summary 
Chatty 

Definition at line 122 of file PFEGammaAlgo.h.

Constructor & Destructor Documentation

PFEGammaAlgo::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 
)

Definition at line 39 of file PFEGammaAlgo.cc.

References chi2, chi2_gsf, chi2_kf, del_phi, DEtaGsfEcalClust, DPtOverPt_gsf, dPtOverPt_gsf, EGsfPoutMode, EoverPt, Eta_gsf, EtotBremPinPoutMode, EtotPinMode, firstBrem, HOverHE, HoverPt, lateBrem, lnPt_gsf, nhit_kf, nlayers, nlost, SigmaEtaEta, STIP, tmvaReader_, tmvaReaderEle_, track_pt, X0_inner, X0_middle, X0_outer, and X0_sum.

61  :
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),
76  isvalid_(false),
78  MVACUT(mvaConvCut),
79  useReg_(useReg),
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),
84  mvaValue(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),
89  EB(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),
92  e2x5Max_(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),
97  nVtx_(0.0),
98  x0inner_(0.0), x0middle_(0.0), x0outer_(0.0),
100 {
101 
102 
103  // Set the tmva reader for electrons
104  tmvaReaderEle_ = new TMVA::Reader("!Color:Silent");
105  tmvaReaderEle_->AddVariable("lnPt_gsf",&lnPt_gsf);
106  tmvaReaderEle_->AddVariable("Eta_gsf",&Eta_gsf);
107  tmvaReaderEle_->AddVariable("dPtOverPt_gsf",&dPtOverPt_gsf);
108  tmvaReaderEle_->AddVariable("DPtOverPt_gsf",&DPtOverPt_gsf);
109  //tmvaReaderEle_->AddVariable("nhit_gsf",&nhit_gsf);
110  tmvaReaderEle_->AddVariable("chi2_gsf",&chi2_gsf);
111  //tmvaReaderEle_->AddVariable("DPtOverPt_kf",&DPtOverPt_kf);
112  tmvaReaderEle_->AddVariable("nhit_kf",&nhit_kf);
113  tmvaReaderEle_->AddVariable("chi2_kf",&chi2_kf);
114  tmvaReaderEle_->AddVariable("EtotPinMode",&EtotPinMode);
115  tmvaReaderEle_->AddVariable("EGsfPoutMode",&EGsfPoutMode);
116  tmvaReaderEle_->AddVariable("EtotBremPinPoutMode",&EtotBremPinPoutMode);
117  tmvaReaderEle_->AddVariable("DEtaGsfEcalClust",&DEtaGsfEcalClust);
118  tmvaReaderEle_->AddVariable("SigmaEtaEta",&SigmaEtaEta);
119  tmvaReaderEle_->AddVariable("HOverHE",&HOverHE);
120 // tmvaReaderEle_->AddVariable("HOverPin",&HOverPin);
121  tmvaReaderEle_->AddVariable("lateBrem",&lateBrem);
122  tmvaReaderEle_->AddVariable("firstBrem",&firstBrem);
123  tmvaReaderEle_->BookMVA("BDT",mvaWeightFileEleID.c_str());
124 
125 
126  //Book MVA
127  tmvaReader_ = new TMVA::Reader("!Color:Silent");
128  tmvaReader_->AddVariable("del_phi",&del_phi);
129  tmvaReader_->AddVariable("nlayers", &nlayers);
130  tmvaReader_->AddVariable("chi2",&chi2);
131  tmvaReader_->AddVariable("EoverPt",&EoverPt);
132  tmvaReader_->AddVariable("HoverPt",&HoverPt);
133  tmvaReader_->AddVariable("track_pt", &track_pt);
134  tmvaReader_->AddVariable("STIP",&STIP);
135  tmvaReader_->AddVariable("nlost", &nlost);
136  tmvaReader_->BookMVA("BDT",mvaweightfile.c_str());
137 
138  //Material Map
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");
144 
145 }
float SCEtaWidth_
Definition: PFEGammaAlgo.h:257
float EtotBremPinPoutMode
Definition: PFEGammaAlgo.h:199
double mvaValue
Definition: PFEGammaAlgo.h:242
bool usePFSCEleCalib_
Definition: PFEGammaAlgo.h:175
boost::shared_ptr< PFSCEnergyCalibration > thePFSCEnergyCalibration_
Definition: PFEGammaAlgo.h:172
bool useEGammaSupercluster_
Definition: PFEGammaAlgo.h:177
double sumPtTrackIsoSlopeForPhoton_
Definition: PFEGammaAlgo.h:235
bool applyCrackCorrections_
Definition: PFEGammaAlgo.h:174
float e2x5Bottom_
Definition: PFEGammaAlgo.h:253
float EGsfPoutMode
Definition: PFEGammaAlgo.h:199
float Mustache_Et_out_
Definition: PFEGammaAlgo.h:268
float DEtaGsfEcalClust
Definition: PFEGammaAlgo.h:200
TH2D * X0_outer
Definition: PFEGammaAlgo.h:265
float Clus5x5ratio_
Definition: PFEGammaAlgo.h:247
float PFPhoEtCorr_
Definition: PFEGammaAlgo.h:257
float e2x5Right_
Definition: PFEGammaAlgo.h:253
boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_
Definition: PFEGammaAlgo.h:173
float DPtOverPt_gsf
Definition: PFEGammaAlgo.h:193
double mvaEleCut_
Definition: PFEGammaAlgo.h:171
float SCPhiWidth_
Definition: PFEGammaAlgo.h:257
double coneTrackIsoForEgammaSC_
Definition: PFEGammaAlgo.h:184
float Mustache_EtRatio_
Definition: PFEGammaAlgo.h:268
double sumPtTrackIsoForEgammaSC_endcap_
Definition: PFEGammaAlgo.h:182
float dPtOverPt_gsf
Definition: PFEGammaAlgo.h:193
float logPFClusE_
Definition: PFEGammaAlgo.h:247
unsigned int nTrackIsoForEgammaSC_
Definition: PFEGammaAlgo.h:183
double sumPtTrackIsoForEgammaSC_barrel_
Definition: PFEGammaAlgo.h:181
bool useEGElectrons_
Definition: PFEGammaAlgo.h:176
float PFPhoECorr_
Definition: PFEGammaAlgo.h:257
double coneEcalIsoForEgammaSC_
Definition: PFEGammaAlgo.h:180
float SigmaEtaEta
Definition: PFEGammaAlgo.h:201
TMVA::Reader * tmvaReaderEle_
Definition: PFEGammaAlgo.h:170
float EtotPinMode
Definition: PFEGammaAlgo.h:199
double sumEtEcalIsoForEgammaSC_endcap_
Definition: PFEGammaAlgo.h:179
TH2D * X0_inner
Definition: PFEGammaAlgo.h:263
double sumEtEcalIsoForEgammaSC_barrel_
Definition: PFEGammaAlgo.h:178
float PFPhoR9Corr_
Definition: PFEGammaAlgo.h:257
TMVA::Reader * tmvaReader_
Definition: PFEGammaAlgo.h:222
TH2D * X0_middle
Definition: PFEGammaAlgo.h:264
double sumPtTrackIsoForPhoton_
Definition: PFEGammaAlgo.h:234
verbosityLevel verbosityLevel_
Definition: PFEGammaAlgo.h:213
float PFCrysEtaCrack_
Definition: PFEGammaAlgo.h:247
PFEGammaAlgo::~PFEGammaAlgo ( )
inline

Definition at line 67 of file PFEGammaAlgo.h.

References tmvaReader_, and tmvaReaderEle_.

67 {delete tmvaReaderEle_; delete tmvaReader_; };
TMVA::Reader * tmvaReaderEle_
Definition: PFEGammaAlgo.h:170
TMVA::Reader * tmvaReader_
Definition: PFEGammaAlgo.h:222

Member Function Documentation

bool PFEGammaAlgo::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 
)
private

Definition at line 2946 of file PFEGammaAlgo.cc.

References reco::PFCandidate::addElementInBlock(), applyCrackCorrections_, reco::PFBlock::associatedElements(), Association::block, reco::PFBlockElement::BREM, DeDxDiscriminatorTools::charge(), reco::PFBlockElementCluster::clusterRef(), gather_cfg::cout, reco::PFCandidate::e, reco::PFBlockElement::ECAL, egCandidate_, egExtra_, reco::PFBlock::elements(), asciidump::elements, reco::PFCandidate::gamma, edm::Ref< C, T, F >::get(), PFEnergyResolution::getEnergyResolutionEm(), reco::PFBlockElementGsfTrack::GsftrackRef(), reco::PFBlockElement::HCAL, patCandidatesForDimuonsSequences_cff::hcal, edm::Ref< C, T, F >::isNonnull(), isPrimaryTrack(), reco::PFBlock::linkData(), reco::PFBlock::LINKTEST_ALL, M_PI, nhit_gsf, nhit_kf, PFClusterWidthAlgo::pflowEtaWidth(), PFClusterWidthAlgo::pflowPhiWidth(), reco::PFBlockElementBrem::positionAtECALEntrance(), reco::PFBlockElementGsfTrack::positionAtECALEntrance(), reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, pileupReCalc_HLTpaths::scale, reco::PFCandidateEGammaExtra::setClusterEnergies(), reco::PFCandidate::setEcalEnergy(), reco::PFCandidate::setGsfTrackRef(), reco::PFCandidate::setHcalEnergy(), reco::PFCandidate::setPositionAtECALEntrance(), reco::PFCandidate::setPs1Energy(), reco::PFCandidate::setPs2Energy(), reco::PFCandidateEGammaExtra::setStatus(), reco::PFCandidateEGammaExtra::setSuperClusterBoxRef(), reco::PFCandidate::setSuperClusterRef(), reco::PFCandidate::setTrackRef(), reco::PFCandidate::setVertexSource(), funct::sin(), mathSSE::sqrt(), thePFEnergyCalibration_, thePFSCEnergyCalibration_, reco::PFBlockElement::TRACK, reco::PFBlockElementTrack::trackRef(), and usePFSCEleCalib_.

Referenced by RunPFEG().

2953  {
2954 
2955  const reco::PFBlock& block = *blockRef;
2956  PFBlock::LinkData linkData = block.linkData();
2958  PFEnergyResolution pfresol_;
2959  //PFEnergyCalibration pfcalib_;
2960 
2961  bool DebugIDCandidates = false;
2962 // vector<reco::PFCluster> pfClust_vec(0);
2963 // pfClust_vec.clear();
2964 
2965 
2966  // They should be reset for each gsf track
2967  int eecal=0;
2968  int hcal=0;
2969  int charge =0;
2970  // bool goodphi=true;
2971  math::XYZTLorentzVector momentum_kf,momentum_gsf,momentum,momentum_mean;
2972  float dpt=0; float dpt_gsf=0;
2973  float Eene=0; float dene=0; float Hene=0.;
2974  float RawEene = 0.;
2975  double posX=0.;
2976  double posY=0.;
2977  double posZ=0.;
2978  std::vector<float> bremEnergyVec;
2979 
2980  std::vector<const PFCluster*> pfSC_Clust_vec;
2981 
2982  float de_gs = 0., de_me = 0., de_kf = 0.;
2983  float m_el=0.00051;
2984  int nhit_kf=0; int nhit_gsf=0;
2985  bool has_gsf=false;
2986  bool has_kf=false;
2987  math::XYZTLorentzVector newmomentum;
2988  float ps1TotEne = 0;
2989  float ps2TotEne = 0;
2990  vector<unsigned int> elementsToAdd(0);
2991  reco::TrackRef RefKF;
2992 
2993 
2994 
2995  elementsToAdd.push_back(gsf_index);
2996  const reco::PFBlockElementGsfTrack * GsfEl =
2997  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[gsf_index]));
2998  const math::XYZPointF& posGsfEcalEntrance = GsfEl->positionAtECALEntrance();
2999  reco::GsfTrackRef RefGSF = GsfEl->GsftrackRef();
3000  if (RefGSF.isNonnull()) {
3001 
3002  has_gsf=true;
3003 
3004  charge= RefGSF->chargeMode();
3005  nhit_gsf= RefGSF->hitPattern().trackerLayersWithMeasurement();
3006 
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);
3012 
3013  if( DebugIDCandidates )
3014  cout << "SetCandidates:: GsfTrackRef: Ene " << ENE
3015  << " charge " << charge << " nhits " << nhit_gsf <<endl;
3016 
3017  momentum_gsf.SetE(ENE);
3018  dpt_gsf=RefGSF->ptModeError()*
3019  (RefGSF->pMode()/RefGSF->ptMode());
3020 
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);
3027  // dpt_mean=RefGSF->ptError()*
3028  // (RefGSF->p()/RefGSF->pt());
3029  }
3030  else {
3031  if( DebugIDCandidates )
3032  cout << "SetCandidates:: !!!! NULL GSF Track Ref " << endl;
3033  }
3034 
3035  // vector<unsigned int> assogsf_index = associatedToGsf_[igsf].second;
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++) {
3040  PFBlockElement::Type assoele_type = elements[(assogsf_index[ielegsf])].type();
3041  if (assoele_type == reco::PFBlockElement::TRACK) {
3042  elementsToAdd.push_back((assogsf_index[ielegsf])); // Daniele
3043  const reco::PFBlockElementTrack * KfTk =
3044  dynamic_cast<const reco::PFBlockElementTrack*>((&elements[(assogsf_index[ielegsf])]));
3045  // 19 Mar 2010 do not consider here track from gamam conv
3046  bool isPrim = isPrimaryTrack(*KfTk,*GsfEl);
3047  if(!isPrim) continue;
3048 
3049  RefKF = KfTk->trackRef();
3050  if (RefKF.isNonnull()) {
3051  has_kf = true;
3052  // dpt_kf=(RefKF->ptError()*RefKF->ptError());
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;
3060 
3061  momentum_kf.SetE(ENE);
3062  }
3063  else {
3064  if( DebugIDCandidates )
3065  cout << "SetCandidates:: !!!! NULL KF Track Ref " << endl;
3066  }
3067  }
3068 
3069  if (assoele_type == reco::PFBlockElement::ECAL) {
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);
3074  // Important is the PS clusters are not saved before the ecal one, these
3075  // energy are not correctly assigned
3076  // For the moment I get only the closest PS clusters: this has to be changed
3077  for(unsigned int ips =0; ips<assoecalgsf_index.size();ips++) {
3078  PFBlockElement::Type typeassoecal = elements[(assoecalgsf_index[ips])].type();
3079  if (typeassoecal == reco::PFBlockElement::PS1) {
3080  PFClusterRef psref = elements[(assoecalgsf_index[ips])].clusterRef();
3081  ps1Ene.push_back(psref->energy());
3082  elementsToAdd.push_back((assoecalgsf_index[ips]));
3083  }
3084  if (typeassoecal == reco::PFBlockElement::PS2) {
3085  PFClusterRef psref = elements[(assoecalgsf_index[ips])].clusterRef();
3086  ps2Ene.push_back(psref->energy());
3087  elementsToAdd.push_back((assoecalgsf_index[ips]));
3088  }
3089  if (typeassoecal == reco::PFBlockElement::HCAL) {
3090  const reco::PFBlockElementCluster * clust =
3091  dynamic_cast<const reco::PFBlockElementCluster*>((&elements[(assoecalgsf_index[ips])]));
3092  elementsToAdd.push_back((assoecalgsf_index[ips]));
3093  Hene+=clust->clusterRef()->energy();
3094  hcal++;
3095  }
3096  }
3097  elementsToAdd.push_back((assogsf_index[ielegsf]));
3098 
3099 
3100  const reco::PFBlockElementCluster * clust =
3101  dynamic_cast<const reco::PFBlockElementCluster*>((&elements[(assogsf_index[ielegsf])]));
3102 
3103  eecal++;
3104 
3105  const reco::PFCluster& cl(*clust->clusterRef());
3106  //pfClust_vec.push_back((*clust->clusterRef()));
3107 
3108  // The electron RAW energy is the energy of the corrected GSF cluster
3109  double ps1,ps2;
3110  ps1=ps2=0.;
3111  // float EE=pfcalib_.energyEm(cl,ps1Ene,ps2Ene);
3112  float EE = thePFEnergyCalibration_->energyEm(cl,ps1Ene,ps2Ene,ps1,ps2,applyCrackCorrections_);
3113  // float RawEE = cl.energy();
3114 
3115  float ceta=cl.position().eta();
3116  float cphi=cl.position().phi();
3117 
3118  /*
3119  float mphi=-2.97025;
3120  if (ceta<0) mphi+=0.00638;
3121 
3122  for (int ip=1; ip<19; ip++){
3123  float df= cphi - (mphi+(ip*6.283185/18));
3124  if (fabs(df)<0.01) goodphi=false;
3125  }
3126  */
3127 
3128  float dE=pfresol_.getEnergyResolutionEm(EE,cl.position().eta());
3129  if( DebugIDCandidates )
3130  cout << "SetCandidates:: EcalCluster: EneNoCalib " << clust->clusterRef()->energy()
3131  << " eta,phi " << ceta << "," << cphi << " Calib " << EE << " dE " << dE <<endl;
3132 
3133  bool elecCluster=false;
3134  if (FirstEcalGsf) {
3135  FirstEcalGsf = false;
3136  elecCluster=true;
3137  ecalGsf_index = assogsf_index[ielegsf];
3138  // std::cout << " PFElectronAlgo / Seed " << EE << std::endl;
3139  RawEene += EE;
3140  }
3141 
3142  // create a photon/electron candidate
3143  math::XYZTLorentzVector clusterMomentum;
3144  math::XYZPoint direction=cl.position()/cl.position().R();
3145  clusterMomentum.SetPxPyPzE(EE*direction.x(),
3146  EE*direction.y(),
3147  EE*direction.z(),
3148  EE);
3149  reco::PFCandidate cluster_Candidate((elecCluster)?charge:0,
3150  clusterMomentum,
3152 
3153  cluster_Candidate.setPs1Energy(ps1);
3154  cluster_Candidate.setPs2Energy(ps2);
3155  // The Raw Ecal energy will be the energy of the basic cluster.
3156  // It will be the corrected energy without the preshower
3157  cluster_Candidate.setEcalEnergy(EE-ps1-ps2,EE);
3158  // std::cout << " PFElectronAlgo, adding Brem (1) " << EE << std::endl;
3159  cluster_Candidate.setPositionAtECALEntrance(math::XYZPointF(cl.position()));
3160  cluster_Candidate.addElementInBlock(blockRef,assogsf_index[ielegsf]);
3161  // store the photon candidate
3162 // std::map<unsigned int,std::vector<reco::PFCandidate> >::iterator itcheck=
3163 // electronConstituents_.find(cgsf);
3164 // if(itcheck==electronConstituents_.end())
3165 // {
3166 // // beurk
3167 // std::vector<reco::PFCandidate> tmpVec;
3168 // tmpVec.push_back(cluster_Candidate);
3169 // electronConstituents_.insert(std::pair<unsigned int, std::vector<reco::PFCandidate> >
3170 // (cgsf,tmpVec));
3171 // }
3172 // else
3173 // {
3174 // itcheck->second.push_back(cluster_Candidate);
3175 // }
3176 
3177  Eene+=EE;
3178  posX += EE * cl.position().X();
3179  posY += EE * cl.position().Y();
3180  posZ += EE * cl.position().Z();
3181  ps1TotEne+=ps1;
3182  ps2TotEne+=ps2;
3183  dene+=dE*dE;
3184 
3185  //MM Add cluster to the vector pfSC_Clust_vec needed for brem corrections
3186  pfSC_Clust_vec.push_back( &cl );
3187 
3188  }
3189 
3190 
3191 
3192  // Important: Add energy from the brems
3193  if (assoele_type == reco::PFBlockElement::BREM) {
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++){
3198  if (elements[(assobrem_index[ibrem])].type() == reco::PFBlockElement::ECAL) {
3199  // brem emission is from the considered gsf track
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++) {
3206  if (elements[(assoelebrem_index[ielebrem])].type() == reco::PFBlockElement::PS1) {
3207  PFClusterRef psref = elements[(assoelebrem_index[ielebrem])].clusterRef();
3208  ps1EneFromBrem.push_back(psref->energy());
3209  elementsToAdd.push_back(assoelebrem_index[ielebrem]);
3210  }
3211  if (elements[(assoelebrem_index[ielebrem])].type() == reco::PFBlockElement::PS2) {
3212  PFClusterRef psref = elements[(assoelebrem_index[ielebrem])].clusterRef();
3213  ps2EneFromBrem.push_back(psref->energy());
3214  elementsToAdd.push_back(assoelebrem_index[ielebrem]);
3215  }
3216  }
3217  elementsToAdd.push_back(assobrem_index[ibrem]);
3218  reco::PFClusterRef clusterRef = elements[(assobrem_index[ibrem])].clusterRef();
3219  //pfClust_vec.push_back(*clusterRef);
3220  // to get a calibrated PS energy
3221  double ps1=0;
3222  double ps2=0;
3223  float EE = thePFEnergyCalibration_->energyEm(*clusterRef,ps1EneFromBrem,ps2EneFromBrem,ps1,ps2,applyCrackCorrections_);
3224  bremEnergyVec.push_back(EE);
3225  // float RawEE = clusterRef->energy();
3226  float ceta = clusterRef->position().eta();
3227  // float cphi = clusterRef->position().phi();
3228  float dE=pfresol_.getEnergyResolutionEm(EE,ceta);
3229  if( DebugIDCandidates )
3230  cout << "SetCandidates:: BremCluster: Ene " << EE << " dE " << dE <<endl;
3231 
3232  Eene+=EE;
3233  posX += EE * clusterRef->position().X();
3234  posY += EE * clusterRef->position().Y();
3235  posZ += EE * clusterRef->position().Z();
3236  ps1TotEne+=ps1;
3237  ps2TotEne+=ps2;
3238  // Removed 4 March 2009. Florian. The Raw energy is the (corrected) one of the GSF cluster only
3239  // RawEene += RawEE;
3240  dene+=dE*dE;
3241 
3242  //MM Add cluster to the vector pfSC_Clust_vec needed for brem corrections
3243  pfSC_Clust_vec.push_back( clusterRef.get() );
3244 
3245  // create a PFCandidate out of it. Watch out, it is for the e/gamma and tau only
3246  // not to be used by the PFAlgo
3247  math::XYZTLorentzVector photonMomentum;
3248  math::XYZPoint direction=clusterRef->position()/clusterRef->position().R();
3249 
3250  photonMomentum.SetPxPyPzE(EE*direction.x(),
3251  EE*direction.y(),
3252  EE*direction.z(),
3253  EE);
3254  reco::PFCandidate photon_Candidate(0,photonMomentum, reco::PFCandidate::gamma);
3255 
3256  photon_Candidate.setPs1Energy(ps1);
3257  photon_Candidate.setPs2Energy(ps2);
3258  // yes, EE, we want the raw ecal energy of the daugther to have the same definition
3259  // as the GSF cluster
3260  photon_Candidate.setEcalEnergy(EE-ps1-ps2,EE);
3261  // std::cout << " PFElectronAlgo, adding Brem " << EE << std::endl;
3262  photon_Candidate.setPositionAtECALEntrance(math::XYZPointF(clusterRef->position()));
3263  photon_Candidate.addElementInBlock(blockRef,assobrem_index[ibrem]);
3264 
3265  // store the photon candidate
3266  //FIXME: constituents needed?
3267 // std::map<unsigned int,std::vector<reco::PFCandidate> >::iterator itcheck=
3268 // electronConstituents_.find(cgsf);
3269 // if(itcheck==electronConstituents_.end())
3270 // {
3271 // // beurk
3272 // std::vector<reco::PFCandidate> tmpVec;
3273 // tmpVec.push_back(photon_Candidate);
3274 // electronConstituents_.insert(std::pair<unsigned int, std::vector<reco::PFCandidate> >
3275 // (cgsf,tmpVec));
3276 // }
3277 // else
3278 // {
3279 // itcheck->second.push_back(photon_Candidate);
3280 // }
3281  }
3282  }
3283  }
3284  }
3285  } // End Loop On element associated to the GSF tracks
3286  if (has_gsf) {
3287 
3288  // SuperCluster energy corrections
3289  double unCorrEene = Eene;
3290  double absEta = fabs(momentum_gsf.Eta());
3291  double emTheta = momentum_gsf.Theta();
3292  PFClusterWidthAlgo pfSCwidth(pfSC_Clust_vec);
3293  double brLinear = pfSCwidth.pflowPhiWidth()/pfSCwidth.pflowEtaWidth();
3294  pfSC_Clust_vec.clear();
3295 
3296  if( DebugIDCandidates )
3297  cout << "PFEelectronAlgo:: absEta " << absEta << " theta " << emTheta
3298  << " EneRaw " << Eene << " Err " << dene;
3299 
3300  // The calibrations are provided till ET = 200 GeV //No longer a such cut MM
3301  // Protection on at least 1 GeV energy...avoid possible divergencies at very low energy.
3302  if(usePFSCEleCalib_ && unCorrEene > 0.) {
3303  if( absEta < 1.5) {
3304  double Etene = Eene*sin(emTheta);
3305  double emBR_e = thePFSCEnergyCalibration_->SCCorrFBremBarrel(Eene, Etene, brLinear);
3306  double emBR_et = emBR_e*sin(emTheta);
3307  double emCorrFull_et = thePFSCEnergyCalibration_->SCCorrEtEtaBarrel(emBR_et, absEta);
3308  Eene = emCorrFull_et/sin(emTheta);
3309  }
3310  else {
3311  // double Etene = Eene*sin(emTheta); //not needed anymore for endcaps MM
3312  double emBR_e = thePFSCEnergyCalibration_->SCCorrFBremEndcap(Eene, absEta, brLinear);
3313  double emBR_et = emBR_e*sin(emTheta);
3314  double emCorrFull_et = thePFSCEnergyCalibration_->SCCorrEtEtaEndcap(emBR_et, absEta);
3315  Eene = emCorrFull_et/sin(emTheta);
3316  }
3317  dene = sqrt(dene)*(Eene/unCorrEene);
3318  dene = dene*dene;
3319  }
3320 
3321  if( DebugIDCandidates )
3322  cout << " EneCorrected " << Eene << " Err " << dene << endl;
3323 
3324  // charge determination with the majority method
3325  // if the kf track exists: 2 among 3 of supercluster barycenter position
3326  // gsf track and kf track
3327  if(has_kf && unCorrEene > 0.) {
3328  posX /=unCorrEene;
3329  posY /=unCorrEene;
3330  posZ /=unCorrEene;
3331  math::XYZPoint sc_pflow(posX,posY,posZ);
3332 
3333  std::multimap<double, unsigned int> bremElems;
3334  block.associatedElements( gsf_index,linkData,
3335  bremElems,
3338 
3339  double phiTrack = RefGSF->phiMode();
3340  if(bremElems.size()>0) {
3341  unsigned int brem_index = bremElems.begin()->second;
3342  const reco::PFBlockElementBrem * BremEl =
3343  dynamic_cast<const reco::PFBlockElementBrem*>((&elements[brem_index]));
3344  phiTrack = BremEl->positionAtECALEntrance().phi();
3345  }
3346 
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;
3352 
3353  int chargeGsf = RefGSF->chargeMode();
3354  int chargeKf = RefKF->charge();
3355 
3356  int chargeSC = 0;
3357  if(dphi_normalsc < 0.)
3358  chargeSC = 1;
3359  else
3360  chargeSC = -1;
3361 
3362  if(chargeKf == chargeGsf)
3363  charge = chargeGsf;
3364  else if(chargeGsf == chargeSC)
3365  charge = chargeGsf;
3366  else
3367  charge = chargeKf;
3368 
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;
3375 
3376  }
3377 
3378  // Think about this...
3379  if ((nhit_gsf<8) && (has_kf)){
3380 
3381  // Use Hene if some condition....
3382 
3383  momentum=momentum_kf;
3384  float Fe=Eene;
3385  float scale= Fe/momentum.E();
3386 
3387  // Daniele Changed
3388  if (Eene < 0.0001) {
3389  Fe = momentum.E();
3390  scale = 1.;
3391  }
3392 
3393 
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;
3399 
3400 
3401  }
3402  if ((nhit_gsf>7) || (has_kf==false)){
3403  if(Eene > 0.0001) {
3404  de_gs=1-momentum_gsf.E()/Eene;
3405  de_me=1-momentum_mean.E()/Eene;
3406  de_kf=1-momentum_kf.E()/Eene;
3407  }
3408 
3409  momentum=momentum_gsf;
3410  dpt=1/(dpt_gsf*dpt_gsf);
3411 
3412  if(dene > 0.)
3413  dene= 1./dene;
3414 
3415  float Fe = 0.;
3416  if(Eene > 0.0001) {
3417  Fe =((dene*Eene) +(dpt*momentum.E()))/(dene+dpt);
3418  }
3419  else {
3420  Fe=momentum.E();
3421  }
3422 
3423  if ((de_gs>0.05)&&(de_kf>0.05)){
3424  Fe=Eene;
3425  }
3426  if ((de_gs<-0.1)&&(de_me<-0.1) &&(de_kf<0.) &&
3427  (momentum.E()/dpt_gsf) > 5. && momentum_gsf.pt() < 30.){
3428  Fe=momentum.E();
3429  }
3430  float scale= Fe/momentum.E();
3431 
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;
3437 
3438 
3439  }
3440  if (newmomentum.pt()>0.5){
3441 
3442  // the pf candidate are created: we need to set something more?
3443  // IMPORTANT -> We need the gsftrackRef, not only the TrackRef??
3444 
3445  if( DebugIDCandidates )
3446  cout << "SetCandidates:: I am before doing candidate " <<endl;
3447 
3448  //vector with the cluster energies (for the extra)
3449  std::vector<float> clusterEnergyVec;
3450  clusterEnergyVec.push_back(RawEene);
3451  clusterEnergyVec.insert(clusterEnergyVec.end(),bremEnergyVec.begin(),bremEnergyVec.end());
3452 
3453  // add the information in the extra
3454  //std::vector<reco::PFCandidateElectronExtra>::iterator itextra;
3455  //PFElectronExtraEqual myExtraEqual(RefGSF);
3456  PFCandidateEGammaExtra myExtraEqual(RefGSF);
3457  //myExtraEqual.setSuperClusterRef(scref);
3458  myExtraEqual.setSuperClusterBoxRef(scref);
3459  myExtraEqual.setClusterEnergies(clusterEnergyVec);
3460  //itextra=find_if(electronExtra_.begin(),electronExtra_.end(),myExtraEqual);
3461  //if(itextra!=electronExtra_.end()) {
3462  //itextra->setClusterEnergies(clusterEnergyVec);
3463 // else {
3464 // if(RawEene>0.)
3465 // std::cout << " There is a big problem with the electron extra, PFElectronAlgo should crash soon " << RawEene << std::endl;
3466 // }
3467 
3468  reco::PFCandidate::ParticleType particleType
3470  //reco::PFCandidate temp_Candidate;
3471  reco::PFCandidate temp_Candidate(charge,newmomentum,particleType);
3472  //FIXME: need bdt output
3473  //temp_Candidate.set_mva_e_pi(BDToutput_[cgsf]);
3474  temp_Candidate.setEcalEnergy(RawEene,Eene);
3475  // Note the Hcal energy is set but the element is never locked
3476  temp_Candidate.setHcalEnergy(Hene,Hene);
3477  temp_Candidate.setPs1Energy(ps1TotEne);
3478  temp_Candidate.setPs2Energy(ps2TotEne);
3479  temp_Candidate.setTrackRef(RefKF);
3480  // This reference could be NULL it is needed a protection?
3481  temp_Candidate.setGsfTrackRef(RefGSF);
3482  temp_Candidate.setPositionAtECALEntrance(posGsfEcalEntrance);
3483  // Add Vertex
3484  temp_Candidate.setVertexSource(PFCandidate::kGSFVertex);
3485 
3486  //supercluster ref is always available now and points to ecal-drive box/mustache supercluster
3487  temp_Candidate.setSuperClusterRef(scref);
3488 
3489  // save the superclusterRef when available
3490  //FIXME: Point back to ecal-driven supercluster ref, which is now always available
3491 // if(RefGSF->extra().isAvailable() && RefGSF->extra()->seedRef().isAvailable()) {
3492 // reco::ElectronSeedRef seedRef= RefGSF->extra()->seedRef().castTo<reco::ElectronSeedRef>();
3493 // if(seedRef.isAvailable() && seedRef->isEcalDriven()) {
3494 // reco::SuperClusterRef scRef = seedRef->caloCluster().castTo<reco::SuperClusterRef>();
3495 // if(scRef.isNonnull())
3496 // temp_Candidate.setSuperClusterRef(scRef);
3497 // }
3498 // }
3499 
3500  if( DebugIDCandidates )
3501  cout << "SetCandidates:: I am after doing candidate " <<endl;
3502 
3503 // for (unsigned int elad=0; elad<elementsToAdd.size();elad++){
3504 // temp_Candidate.addElementInBlock(blockRef,elementsToAdd[elad]);
3505 // }
3506 //
3507 // // now add the photons to this candidate
3508 // std::map<unsigned int, std::vector<reco::PFCandidate> >::const_iterator itcluster=
3509 // electronConstituents_.find(cgsf);
3510 // if(itcluster!=electronConstituents_.end())
3511 // {
3512 // const std::vector<reco::PFCandidate> & theClusters=itcluster->second;
3513 // unsigned nclus=theClusters.size();
3514 // // std::cout << " PFElectronAlgo " << nclus << " daugthers to add" << std::endl;
3515 // for(unsigned iclus=0;iclus<nclus;++iclus)
3516 // {
3517 // temp_Candidate.addDaughter(theClusters[iclus]);
3518 // }
3519 // }
3520 
3521  // By-pass the mva is the electron has been pre-selected
3522 // bool bypassmva=false;
3523 // if(useEGElectrons_) {
3524 // GsfElectronEqual myEqual(RefGSF);
3525 // std::vector<reco::GsfElectron>::const_iterator itcheck=find_if(theGsfElectrons_->begin(),theGsfElectrons_->end(),myEqual);
3526 // if(itcheck!=theGsfElectrons_->end()) {
3527 // if(BDToutput_[cgsf] >= -1.) {
3528 // // bypass the mva only if the reconstruction went fine
3529 // bypassmva=true;
3530 //
3531 // if( DebugIDCandidates ) {
3532 // if(BDToutput_[cgsf] < -0.1) {
3533 // float esceg = itcheck->caloEnergy();
3534 // cout << " Attention By pass the mva " << BDToutput_[cgsf]
3535 // << " SuperClusterEnergy " << esceg
3536 // << " PF Energy " << Eene << endl;
3537 //
3538 // cout << " hoe " << itcheck->hcalOverEcal()
3539 // << " tkiso04 " << itcheck->dr04TkSumPt()
3540 // << " ecaliso04 " << itcheck->dr04EcalRecHitSumEt()
3541 // << " hcaliso04 " << itcheck->dr04HcalTowerSumEt()
3542 // << " tkiso03 " << itcheck->dr03TkSumPt()
3543 // << " ecaliso03 " << itcheck->dr03EcalRecHitSumEt()
3544 // << " hcaliso03 " << itcheck->dr03HcalTowerSumEt() << endl;
3545 // }
3546 // } // end DebugIDCandidates
3547 // }
3548 // }
3549 // }
3550 
3551  myExtraEqual.setStatus(PFCandidateEGammaExtra::Selected,true);
3552 
3553  // ... and lock all elemts used
3554  for(std::vector<unsigned int>::const_iterator it = elemsToLock.begin();
3555  it != elemsToLock.end(); ++it)
3556  {
3557  if(active[*it])
3558  {
3559  temp_Candidate.addElementInBlock(blockRef,*it);
3560  }
3561  active[*it] = false;
3562  }
3563 
3564  egCandidate_.push_back(temp_Candidate);
3565  egExtra_.push_back(myExtraEqual);
3566 
3567  return true;
3568 
3569 // bool mvaSelected = (BDToutput_[cgsf] >= mvaEleCut_);
3570 // if( mvaSelected || bypassmva ) {
3571 // elCandidate_.push_back(temp_Candidate);
3572 // if(itextra!=electronExtra_.end())
3573 // itextra->setStatus(PFCandidateElectronExtra::Selected,true);
3574 // }
3575 // else {
3576 // if(itextra!=electronExtra_.end())
3577 // itextra->setStatus(PFCandidateElectronExtra::Rejected,true);
3578 // }
3579 // allElCandidate_.push_back(temp_Candidate);
3580 //
3581 // // save the status information
3582 // if(itextra!=electronExtra_.end()) {
3583 // itextra->setStatus(PFCandidateElectronExtra::ECALDrivenPreselected,bypassmva);
3584 // itextra->setStatus(PFCandidateElectronExtra::MVASelected,mvaSelected);
3585 // }
3586 
3587 
3588  }
3589  else {
3590  //BDToutput_[cgsf] = -1.; // if the momentum is < 0.5 ID = false, but not sure
3591  // it could be misleading.
3592  if( DebugIDCandidates )
3593  cout << "SetCandidates:: No Candidate Produced because of Pt cut: 0.5 " <<endl;
3594  return false;
3595  }
3596  }
3597  else {
3598  //BDToutput_[cgsf] = -1.; // if gsf ref does not exist
3599  if( DebugIDCandidates )
3600  cout << "SetCandidates:: No Candidate Produced because of No GSF Track Ref " <<endl;
3601  return false;
3602  }
3603  return false;
3604 }
std::vector< reco::PFCandidateEGammaExtra > egExtra_
Definition: PFEGammaAlgo.h:276
type
Definition: HCALResponse.h:21
const math::XYZPointF & positionAtECALEntrance() const
bool usePFSCEleCalib_
Definition: PFEGammaAlgo.h:175
boost::shared_ptr< PFSCEnergyCalibration > thePFSCEnergyCalibration_
Definition: PFEGammaAlgo.h:172
ParticleType
particle types
Definition: PFCandidate.h:40
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
bool applyCrackCorrections_
Definition: PFEGammaAlgo.h:174
PFClusterRef clusterRef() const
const math::XYZPointF & positionAtECALEntrance() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< unsigned int, Link > LinkData
Definition: PFBlock.h:46
bool isPrimaryTrack(const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
list elements
Definition: asciidump.py:414
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
const LinkData & linkData() const
Definition: PFBlock.h:112
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:11
double charge(const std::vector< uint8_t > &Ampls)
boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_
Definition: PFEGammaAlgo.h:173
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
double getEnergyResolutionEm(double CorrectedEnergy, double eta) const
T sqrt(T t)
Definition: SSEVec.h:48
reco::GsfTrackRef GsftrackRef() const
block
Formating index page&#39;s pieces.
Definition: Association.py:232
#define M_PI
Definition: BFit3D.cc:3
void associatedElements(unsigned i, const LinkData &linkData, std::multimap< double, unsigned > &sortedAssociates, reco::PFBlockElement::Type type=PFBlockElement::NONE, LinkTest test=LINKTEST_RECHIT) const
Definition: PFBlock.cc:75
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
reco::TrackRef trackRef() const
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:35
tuple cout
Definition: gather_cfg.py:121
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
std::vector< reco::PFCandidate > egCandidate_
Definition: PFEGammaAlgo.h:272
Block of elements.
Definition: PFBlock.h:30
void PFEGammaAlgo::AddElectronElements ( unsigned int  gsf_index,
std::vector< unsigned int > &  elemsToLock,
const reco::PFBlockRef blockRef,
AssMap associatedToGsf_,
AssMap associatedToBrems_,
AssMap associatedToEcal_ 
)
private

Definition at line 2827 of file PFEGammaAlgo.cc.

References reco::PFBlock::associatedElements(), Association::block, reco::PFBlockElement::BREM, convGsfTrack_, reco::PFBlockElement::ECAL, reco::PFBlock::elements(), asciidump::elements, fifthStepKfTrack_, first, reco::PFBlockElementGsfTrack::GsftrackRef(), reco::PFBlock::linkData(), reco::PFBlock::LINKTEST_ALL, reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, edm::second(), and reco::PFBlockElement::TRACK.

Referenced by RunPFEG().

2832  {
2833  const reco::PFBlock& block = *blockRef;
2834  PFBlock::LinkData linkData = block.linkData();
2835 
2837 
2838  const reco::PFBlockElementGsfTrack * GsfEl =
2839  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[gsf_index]));
2840  reco::GsfTrackRef RefGSF = GsfEl->GsftrackRef();
2841 
2842  // lock only the elements that pass the BDT cut
2843 // bool bypassmva=false;
2844 // if(useEGElectrons_) {
2845 // GsfElectronEqual myEqual(RefGSF);
2846 // std::vector<reco::GsfElectron>::const_iterator itcheck=find_if(theGsfElectrons_->begin(),theGsfElectrons_->end(),myEqual);
2847 // if(itcheck!=theGsfElectrons_->end()) {
2848 // if(BDToutput_[cgsf] >= -1.)
2849 // bypassmva=true;
2850 // }
2851 // }
2852 
2853  //if(BDToutput_[cgsf] < mvaEleCut_ && bypassmva == false) continue;
2854 
2855 
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++) {
2859  PFBlockElement::Type assoele_type = elements[(assogsf_index[ielegsf])].type();
2860  // lock the elements associated to the gsf: ECAL, Brems
2861  elemsToLock.push_back((assogsf_index[ielegsf]));
2862  if (assoele_type == reco::PFBlockElement::ECAL) {
2863  unsigned int keyecalgsf = assogsf_index[ielegsf];
2864 
2865  // added protection against fifth step
2866  if(fifthStepKfTrack_.size() > 0) {
2867  for(unsigned int itr = 0; itr < fifthStepKfTrack_.size(); itr++) {
2868  if(fifthStepKfTrack_[itr].first == keyecalgsf) {
2869  elemsToLock.push_back((fifthStepKfTrack_[itr].second));
2870  }
2871  }
2872  }
2873 
2874  // added locking for conv gsf tracks and kf tracks
2875  if(convGsfTrack_.size() > 0) {
2876  for(unsigned int iconv = 0; iconv < convGsfTrack_.size(); iconv++) {
2877  if(convGsfTrack_[iconv].first == keyecalgsf) {
2878  // lock the GSF track
2879  elemsToLock.push_back(convGsfTrack_[iconv].second);
2880  // lock also the KF track associated
2881  std::multimap<double, unsigned> convKf;
2882  block.associatedElements( convGsfTrack_[iconv].second,
2883  linkData,
2884  convKf,
2887  if(convKf.size() > 0) {
2888  elemsToLock.push_back(convKf.begin()->second);
2889  }
2890  }
2891  }
2892  }
2893 
2894 
2895  vector<unsigned int> assoecalgsf_index = associatedToEcal_.find(keyecalgsf)->second;
2896  for(unsigned int ips =0; ips<assoecalgsf_index.size();ips++) {
2897  // lock the elements associated to ECAL: PS1,PS2, for the moment not HCAL
2898  if (elements[(assoecalgsf_index[ips])].type() == reco::PFBlockElement::PS1)
2899  elemsToLock.push_back((assoecalgsf_index[ips]));
2900  if (elements[(assoecalgsf_index[ips])].type() == reco::PFBlockElement::PS2)
2901  elemsToLock.push_back(assoecalgsf_index[ips]);
2902  if (elements[(assoecalgsf_index[ips])].type() == reco::PFBlockElement::TRACK) {
2903  //FIXME: some extra input needed here which is not available yet
2904 // if(lockExtraKf_[cgsf] == true) {
2905 // elemsToLock.push_back(assoecalgsf_index[ips])
2906 // }
2907  }
2908  }
2909  } // End if ECAL
2910  if (assoele_type == reco::PFBlockElement::BREM) {
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++){
2914  if (elements[(assobrem_index[ibrem])].type() == reco::PFBlockElement::ECAL) {
2915  unsigned int keyecalbrem = assobrem_index[ibrem];
2916  // lock the ecal cluster associated to the brem
2917  elemsToLock.push_back(assobrem_index[ibrem]);
2918 
2919  // add protection against fifth step
2920  if(fifthStepKfTrack_.size() > 0) {
2921  for(unsigned int itr = 0; itr < fifthStepKfTrack_.size(); itr++) {
2922  if(fifthStepKfTrack_[itr].first == keyecalbrem) {
2923  elemsToLock.push_back(fifthStepKfTrack_[itr].second);
2924  }
2925  }
2926  }
2927 
2928  vector<unsigned int> assoelebrem_index = associatedToEcal_.find(keyecalbrem)->second;
2929  // lock the elements associated to ECAL: PS1,PS2, for the moment not HCAL
2930  for (unsigned int ielebrem=0; ielebrem<assoelebrem_index.size();ielebrem++) {
2931  if (elements[(assoelebrem_index[ielebrem])].type() == reco::PFBlockElement::PS1)
2932  elemsToLock.push_back(assoelebrem_index[ielebrem]);
2933  if (elements[(assoelebrem_index[ielebrem])].type() == reco::PFBlockElement::PS2)
2934  elemsToLock.push_back(assoelebrem_index[ielebrem]);
2935  }
2936  }
2937  }
2938  } // End if BREM
2939  } // End loop on elements from gsf track
2940  return;
2941 }
type
Definition: HCALResponse.h:21
std::vector< std::pair< unsigned int, unsigned int > > fifthStepKfTrack_
Definition: PFEGammaAlgo.h:166
std::map< unsigned int, Link > LinkData
Definition: PFBlock.h:46
list elements
Definition: asciidump.py:414
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
const LinkData & linkData() const
Definition: PFBlock.h:112
U second(std::pair< T, U > const &p)
reco::GsfTrackRef GsftrackRef() const
bool first
Definition: L1TdeRCT.cc:94
block
Formating index page&#39;s pieces.
Definition: Association.py:232
void associatedElements(unsigned i, const LinkData &linkData, std::multimap< double, unsigned > &sortedAssociates, reco::PFBlockElement::Type type=PFBlockElement::NONE, LinkTest test=LINKTEST_RECHIT) const
Definition: PFBlock.cc:75
std::vector< std::pair< unsigned int, unsigned int > > convGsfTrack_
Definition: PFEGammaAlgo.h:167
Block of elements.
Definition: PFBlock.h:30
double PFEGammaAlgo::ClustersPhiRMS ( std::vector< reco::CaloCluster PFClusters,
float  PFPhoPhi 
)
private

Definition at line 1238 of file PFEGammaAlgo.cc.

References trackerHits::c, funct::cos(), phi, and mathSSE::sqrt().

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

1238  {
1239  double PFClustPhiRMS=0;
1240  double delPhi2=0;
1241  double delPhiSum=0;
1242  double ClusSum=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();
1247  }
1248  double meandPhi=delPhiSum/ClusSum;
1249  PFClustPhiRMS=sqrt(fabs(delPhi2/ClusSum - (meandPhi*meandPhi)));
1250 
1251  return PFClustPhiRMS;
1252 }
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Definition: DDAxes.h:10
void PFEGammaAlgo::EarlyConversion ( std::vector< reco::PFCandidate > &  tempElectronCandidates,
const reco::PFBlockElementSuperCluster sc 
)
private

Definition at line 1435 of file PFEGammaAlgo.cc.

References AddFromElectron_, prof2calltree::count, i, edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), match_ind, and reco::PFBlockElementSuperCluster::superClusterRef().

1441  {
1442  //step 1 check temp electrons for clusters that match Photon Supercluster:
1443  // permElectronCandidates->clear();
1444  int count=0;
1445  for ( std::vector<reco::PFCandidate>::const_iterator ec=tempElectronCandidates.begin(); ec != tempElectronCandidates.end(); ++ec )
1446  {
1447  // bool matched=false;
1448  int mh=ec->gsfTrackRef()->trackerExpectedHitsInner().numberOfLostHits();
1449  //if(mh==0)continue;//Case where missing hits greater than zero
1450 
1451  reco::GsfTrackRef gsf=ec->gsfTrackRef();
1452  //some hoopla to get Electron SC ref
1453 
1454  if(gsf->extra().isAvailable() && gsf->extra()->seedRef().isAvailable() && mh>0)
1455  {
1456  reco::ElectronSeedRef seedRef= gsf->extra()->seedRef().castTo<reco::ElectronSeedRef>();
1457  if(seedRef.isAvailable() && seedRef->isEcalDriven())
1458  {
1459  reco::SuperClusterRef ElecscRef = seedRef->caloCluster().castTo<reco::SuperClusterRef>();
1460 
1461  if(ElecscRef.isNonnull()){
1462  //finally see if it matches:
1463  reco::SuperClusterRef PhotscRef=sc->superClusterRef();
1464  if(PhotscRef==ElecscRef)
1465  {
1466  match_ind.push_back(count);
1467  // matched=true;
1468  //cout<<"Matched Electron with Index "<<count<<" This is the electron "<<*ec<<endl;
1469  //find that they have the same SC footprint start to collect Clusters and tracks and these will be passed to PFPhoton
1470  reco::PFCandidate::ElementsInBlocks eleInBlocks = ec->elementsInBlocks();
1471  for(unsigned i=0; i<eleInBlocks.size(); i++)
1472  {
1473  reco::PFBlockRef blockRef = eleInBlocks[i].first;
1474  unsigned indexInBlock = eleInBlocks[i].second;
1475  //const edm::OwnVector< reco::PFBlockElement >& elements=eleInBlocks[i].first->elements();
1476  //const reco::PFBlockElement& element = elements[indexInBlock];
1477 
1478  AddFromElectron_.push_back(indexInBlock);
1479  }
1480  }
1481  }
1482  }
1483  }
1484  count++;
1485  }
1486 }
std::vector< int > match_ind
Definition: PFEGammaAlgo.h:236
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > AddFromElectron_
Definition: PFEGammaAlgo.h:270
bool isAvailable() const
Definition: Ref.h:276
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:360
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
float PFEGammaAlgo::EvaluateGCorrMVA ( reco::PFCandidate  photon,
std::vector< reco::CaloCluster PFClusters 
)
private

Definition at line 1090 of file PFEGammaAlgo.cc.

References ClustersPhiRMS(), dEta_, dPhi_, E3x3_, asciidump::elements, reco::PFCandidate::elementsInBlocks(), relval_parameters_module::energy, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), eta(), reco::Mustache::FillMustacheVar(), GBRForest::GetResponse(), i, getHLTprescales::index, LowClusE_, reco::Mustache::LowestMustClust(), reco::Mustache::MustacheClust(), reco::Mustache::MustacheE(), MustE_, nVtx_, PFPhoE_, PFPhoECorr_, PFPhoEta_, PFPhoPhi_, PFPhoR9_, PFPhoR9Corr_, phi, reco::LeafCandidate::phi(), dttmaxenums::R, RConv_, ReaderGCEB_, ReaderGCEEhR9_, ReaderGCEElR9_, RMSAll_, RMSMust_, SCEtaWidth_, SCPhiWidth_, mathSSE::sqrt(), reco::PFCandidate::superClusterRef(), TotPS1_, TotPS2_, reco::PFBlockElement::TRACK, reco::PFBlockElement::trackRef(), reco::PFBlockElement::type(), X0_inner, X0_middle, X0_outer, X0_sum, x0inner_, x0middle_, and x0outer_.

Referenced by RunPFEG().

1090  {
1091  float BDTG=1;
1092  PFPhoEta_=photon.eta();
1093  PFPhoPhi_=photon.phi();
1094  PFPhoE_=photon.energy();
1095  //fill Material Map:
1096  int ix = X0_sum->GetXaxis()->FindBin(PFPhoEta_);
1097  int iy = X0_sum->GetYaxis()->FindBin(PFPhoPhi_);
1098  x0inner_= X0_inner->GetBinContent(ix,iy);
1099  x0middle_=X0_middle->GetBinContent(ix,iy);
1100  x0outer_=X0_outer->GetBinContent(ix,iy);
1101  SCPhiWidth_=photon.superClusterRef()->phiWidth();
1102  SCEtaWidth_=photon.superClusterRef()->etaWidth();
1103  Mustache Must;
1104  std::vector<unsigned int>insideMust;
1105  std::vector<unsigned int>outsideMust;
1106  std::multimap<float, unsigned int>OrderedClust;
1107  Must.FillMustacheVar(PFClusters);
1108  MustE_=Must.MustacheE();
1109  LowClusE_=Must.LowestMustClust();
1111  Must.MustacheClust(PFClusters,insideMust, outsideMust );
1112  for(unsigned int i=0; i<insideMust.size(); ++i){
1113  int index=insideMust[i];
1114  OrderedClust.insert(make_pair(PFClusters[index].energy(),index));
1115  }
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());
1125  }
1126  else{
1127  dEta_=0;
1128  dPhi_=0;
1129  LowClusE_=0;
1130  }
1131  //calculate RMS for All clusters and up until the Next to Lowest inside the Mustache
1132  RMSAll_=ClustersPhiRMS(PFClusters, PFPhoPhi_);
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]);
1139  }
1140  }
1141  else{
1142  for(unsigned int i=0; i<insideMust.size(); ++i){
1143  unsigned int index=insideMust[i];
1144  PFMustClusters.push_back(PFClusters[index]);
1145  }
1146  }
1147  RMSMust_=ClustersPhiRMS(PFMustClusters, PFPhoPhi_);
1148  //then use cluster Width for just one PFCluster
1149  RConv_=310;
1150  PFCandidate::ElementsInBlocks eleInBlocks = photon.elementsInBlocks();
1151  for(unsigned i=0; i<eleInBlocks.size(); i++)
1152  {
1153  PFBlockRef blockRef = eleInBlocks[i].first;
1154  unsigned indexInBlock = eleInBlocks[i].second;
1155  const edm::OwnVector< reco::PFBlockElement >& elements=eleInBlocks[i].first->elements();
1156  const reco::PFBlockElement& element = elements[indexInBlock];
1157  if(element.type()==reco::PFBlockElement::TRACK){
1158  float R=sqrt(element.trackRef()->innerPosition().X()*element.trackRef()->innerPosition().X()+element.trackRef()->innerPosition().Y()*element.trackRef()->innerPosition().Y());
1159  if(RConv_>R)RConv_=R;
1160  }
1161  else continue;
1162  }
1163  //cout<<"Nvtx "<<nVtx_<<endl;
1164  if(fabs(PFPhoEta_)<1.4446){
1165  float GC_Var[17];
1166  GC_Var[0]=PFPhoEta_;
1167  GC_Var[1]=PFPhoECorr_;
1168  GC_Var[2]=PFPhoR9Corr_;
1169  GC_Var[3]=SCEtaWidth_;
1170  GC_Var[4]=SCPhiWidth_;
1171  GC_Var[5]=PFPhoPhi_;
1172  GC_Var[6]=x0inner_;
1173  GC_Var[7]=x0middle_;
1174  GC_Var[8]=x0outer_;
1175  GC_Var[9]=RConv_;
1176  GC_Var[10]=LowClusE_;
1177  GC_Var[11]=RMSMust_;
1178  GC_Var[12]=RMSAll_;
1179  GC_Var[13]=dEta_;
1180  GC_Var[14]=dPhi_;
1181  GC_Var[15]=nVtx_;
1182  GC_Var[16]=MustE_;
1183  BDTG=ReaderGCEB_->GetResponse(GC_Var);
1184  }
1185  else if(PFPhoR9_>0.94){
1186  float GC_Var[19];
1187  GC_Var[0]=PFPhoEta_;
1188  GC_Var[1]=PFPhoECorr_;
1189  GC_Var[2]=PFPhoR9Corr_;
1190  GC_Var[3]=SCEtaWidth_;
1191  GC_Var[4]=SCPhiWidth_;
1192  GC_Var[5]=PFPhoPhi_;
1193  GC_Var[6]=x0inner_;
1194  GC_Var[7]=x0middle_;
1195  GC_Var[8]=x0outer_;
1196  GC_Var[9]=RConv_;
1197  GC_Var[10]=LowClusE_;
1198  GC_Var[11]=RMSMust_;
1199  GC_Var[12]=RMSAll_;
1200  GC_Var[13]=dEta_;
1201  GC_Var[14]=dPhi_;
1202  GC_Var[15]=nVtx_;
1203  GC_Var[16]=TotPS1_;
1204  GC_Var[17]=TotPS2_;
1205  GC_Var[18]=MustE_;
1206  BDTG=ReaderGCEEhR9_->GetResponse(GC_Var);
1207  }
1208 
1209  else{
1210  float GC_Var[19];
1211  GC_Var[0]=PFPhoEta_;
1212  GC_Var[1]=PFPhoE_;
1213  GC_Var[2]=PFPhoR9Corr_;
1214  GC_Var[3]=SCEtaWidth_;
1215  GC_Var[4]=SCPhiWidth_;
1216  GC_Var[5]=PFPhoPhi_;
1217  GC_Var[6]=x0inner_;
1218  GC_Var[7]=x0middle_;
1219  GC_Var[8]=x0outer_;
1220  GC_Var[9]=RConv_;
1221  GC_Var[10]=LowClusE_;
1222  GC_Var[11]=RMSMust_;
1223  GC_Var[12]=RMSAll_;
1224  GC_Var[13]=dEta_;
1225  GC_Var[14]=dPhi_;
1226  GC_Var[15]=nVtx_;
1227  GC_Var[16]=TotPS1_;
1228  GC_Var[17]=TotPS2_;
1229  GC_Var[18]=MustE_;
1230  BDTG=ReaderGCEElR9_->GetResponse(GC_Var);
1231  }
1232  //cout<<"GC "<<BDTG<<endl;
1233 
1234  return BDTG;
1235 
1236 }
float SCEtaWidth_
Definition: PFEGammaAlgo.h:257
double GetResponse(const float *vector) const
Definition: GBRForest.h:51
virtual double energy() const GCC11_FINAL
energy
Abstract base class for a PFBlock element (track, cluster...)
int i
Definition: DBlmapReader.cc:9
void MustacheClust(const std::vector< CaloCluster > &clusters, std::vector< unsigned int > &insideMust, std::vector< unsigned int > &outsideMust)
Definition: Mustache.cc:168
Type type() const
list elements
Definition: asciidump.py:414
const GBRForest * ReaderGCEElR9_
Definition: PFEGammaAlgo.h:231
const GBRForest * ReaderGCEB_
Definition: PFEGammaAlgo.h:229
TH2D * X0_outer
Definition: PFEGammaAlgo.h:265
T eta() const
float LowestMustClust()
Definition: Mustache.h:44
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:360
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.h:365
const GBRForest * ReaderGCEEhR9_
Definition: PFEGammaAlgo.h:230
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
double ClustersPhiRMS(std::vector< reco::CaloCluster >PFClusters, float PFPhoPhi)
float SCPhiWidth_
Definition: PFEGammaAlgo.h:257
T sqrt(T t)
Definition: SSEVec.h:48
virtual reco::TrackRef trackRef() const
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
float PFPhoECorr_
Definition: PFEGammaAlgo.h:257
TH2D * X0_inner
Definition: PFEGammaAlgo.h:263
float PFPhoR9Corr_
Definition: PFEGammaAlgo.h:257
void FillMustacheVar(const std::vector< CaloCluster > &clusters)
Definition: Mustache.cc:206
TH2D * X0_middle
Definition: PFEGammaAlgo.h:264
float MustacheE()
Definition: Mustache.h:41
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:516
Definition: DDAxes.h:10
float PFEGammaAlgo::EvaluateLCorrMVA ( reco::PFClusterRef  clusterRef)
private

Definition at line 1254 of file PFEGammaAlgo.cc.

References Clus5x5ratio_, ClusEta_, ClusPhi_, ClusR9_, CrysEta_, CrysIEta_, CrysIPhi_, CrysPhi_, CrysX_, CrysY_, e1x3_, e1x5_, e2x5Bottom_, e2x5Left_, e2x5Max_, e2x5Right_, e2x5Top_, e3x1_, PFPhotonClusters::E5x5Element(), EB, ebottom_, PFLayer::ECAL_BARREL, eleft_, eright_, eSeed_, PFPhotonClusters::EtaCrack(), etop_, PFPhotonClusters::GetCrysCoor(), PFPhotonClusters::GetCrysIndex(), GBRForest::GetResponse(), create_public_lumi_plots::log, logPFClusE_, PFCrysEtaCrack_, primaryVertex_, ReaderLCEB_, ReaderLCEE_, VtxZ_, and reco::Vertex::z().

Referenced by RunPFEG().

1254  {
1255  float BDTG=1;
1256  PFPhotonClusters ClusterVar(clusterRef);
1257  std::pair<double, double>ClusCoor=ClusterVar.GetCrysCoor();
1258  std::pair<int, int>ClusIndex=ClusterVar.GetCrysIndex();
1259  //Local Coordinates:
1260  if(clusterRef->layer()==PFLayer:: ECAL_BARREL ){//is Barrel
1261  PFCrysEtaCrack_=ClusterVar.EtaCrack();
1262  CrysEta_=ClusCoor.first;
1263  CrysPhi_=ClusCoor.second;
1264  CrysIEta_=ClusIndex.first;
1265  CrysIPhi_=ClusIndex.second;
1266  }
1267  else{
1268  CrysX_=ClusCoor.first;
1269  CrysY_=ClusCoor.second;
1270  }
1271  //Shower Shape Variables:
1272  eSeed_= ClusterVar.E5x5Element(0, 0)/clusterRef->energy();
1273  etop_=ClusterVar.E5x5Element(0,1)/clusterRef->energy();
1274  ebottom_=ClusterVar.E5x5Element(0,-1)/clusterRef->energy();
1275  eleft_=ClusterVar.E5x5Element(-1,0)/clusterRef->energy();
1276  eright_=ClusterVar.E5x5Element(1,0)/clusterRef->energy();
1277  e1x3_=(ClusterVar.E5x5Element(0,0)+ClusterVar.E5x5Element(0,1)+ClusterVar.E5x5Element(0,-1))/clusterRef->energy();
1278  e3x1_=(ClusterVar.E5x5Element(0,0)+ClusterVar.E5x5Element(-1,0)+ClusterVar.E5x5Element(1,0))/clusterRef->energy();
1279  e1x5_=ClusterVar.E5x5Element(0,0)+ClusterVar.E5x5Element(0,-2)+ClusterVar.E5x5Element(0,-1)+ClusterVar.E5x5Element(0,1)+ClusterVar.E5x5Element(0,2);
1280 
1281  e2x5Top_=(ClusterVar.E5x5Element(-2,2)+ClusterVar.E5x5Element(-1, 2)+ClusterVar.E5x5Element(0, 2)
1282  +ClusterVar.E5x5Element(1, 2)+ClusterVar.E5x5Element(2, 2)
1283  +ClusterVar.E5x5Element(-2,1)+ClusterVar.E5x5Element(-1,1)+ClusterVar.E5x5Element(0,1)
1284  +ClusterVar.E5x5Element(1,1)+ClusterVar.E5x5Element(2,1))/clusterRef->energy();
1285  e2x5Bottom_=(ClusterVar.E5x5Element(-2,-2)+ClusterVar.E5x5Element(-1,-2)+ClusterVar.E5x5Element(0,-2)
1286  +ClusterVar.E5x5Element(1,-2)+ClusterVar.E5x5Element(2,-2)
1287  +ClusterVar.E5x5Element(-2,1)+ClusterVar.E5x5Element(-1,1)
1288  +ClusterVar.E5x5Element(0,1)+ClusterVar.E5x5Element(1,1)+ClusterVar.E5x5Element(2,1))/clusterRef->energy();
1289  e2x5Left_= (ClusterVar.E5x5Element(-2,-2)+ClusterVar.E5x5Element(-2,-1)
1290  +ClusterVar.E5x5Element(-2,0)
1291  +ClusterVar.E5x5Element(-2,1)+ClusterVar.E5x5Element(-2,2)
1292  +ClusterVar.E5x5Element(-1,-2)+ClusterVar.E5x5Element(-1,-1)+ClusterVar.E5x5Element(-1,0)
1293  +ClusterVar.E5x5Element(-1,1)+ClusterVar.E5x5Element(-1,2))/clusterRef->energy();
1294 
1295  e2x5Right_ =(ClusterVar.E5x5Element(2,-2)+ClusterVar.E5x5Element(2,-1)
1296  +ClusterVar.E5x5Element(2,0)+ClusterVar.E5x5Element(2,1)+ClusterVar.E5x5Element(2,2)
1297  +ClusterVar.E5x5Element(1,-2)+ClusterVar.E5x5Element(1,-1)+ClusterVar.E5x5Element(1,0)
1298  +ClusterVar.E5x5Element(1,1)+ClusterVar.E5x5Element(1,2))/clusterRef->energy();
1299  float centerstrip=ClusterVar.E5x5Element(0,0)+ClusterVar.E5x5Element(0, -2)
1300  +ClusterVar.E5x5Element(0,-1)+ClusterVar.E5x5Element(0,1)+ClusterVar.E5x5Element(0,2);
1301  float rightstrip=ClusterVar.E5x5Element(1, 0)+ClusterVar.E5x5Element(1,1)
1302  +ClusterVar.E5x5Element(1,2)+ClusterVar.E5x5Element(1,-1)+ClusterVar.E5x5Element(1,-2);
1303  float leftstrip=ClusterVar.E5x5Element(-1,0)+ClusterVar.E5x5Element(-1,-1)+ClusterVar.E5x5Element(-1,2)
1304  +ClusterVar.E5x5Element(-1,1)+ClusterVar.E5x5Element(-1,2);
1305 
1306  if(rightstrip>leftstrip)e2x5Max_=rightstrip+centerstrip;
1307  else e2x5Max_=leftstrip+centerstrip;
1308  e2x5Max_=e2x5Max_/clusterRef->energy();
1309  //GetCrysCoordinates(clusterRef);
1310  //fill5x5Map(clusterRef);
1311  VtxZ_=primaryVertex_->z();
1312  ClusPhi_=clusterRef->position().phi();
1313  ClusEta_=fabs(clusterRef->position().eta());
1314  EB=fabs(clusterRef->position().eta())/clusterRef->position().eta();
1315  logPFClusE_=log(clusterRef->energy());
1316  if(ClusEta_<1.4446){
1317  float LC_Var[26];
1318  LC_Var[0]=VtxZ_;
1319  LC_Var[1]=EB;
1320  LC_Var[2]=ClusEta_;
1321  LC_Var[3]=ClusPhi_;
1322  LC_Var[4]=logPFClusE_;
1323  LC_Var[5]=eSeed_;
1324  //top bottom left right
1325  LC_Var[6]=etop_;
1326  LC_Var[7]=ebottom_;
1327  LC_Var[8]=eleft_;
1328  LC_Var[9]=eright_;
1329  LC_Var[10]=ClusR9_;
1330  LC_Var[11]=e1x3_;
1331  LC_Var[12]=e3x1_;
1332  LC_Var[13]=Clus5x5ratio_;
1333  LC_Var[14]=e1x5_;
1334  LC_Var[15]=e2x5Max_;
1335  LC_Var[16]=e2x5Top_;
1336  LC_Var[17]=e2x5Bottom_;
1337  LC_Var[18]=e2x5Left_;
1338  LC_Var[19]=e2x5Right_;
1339  LC_Var[20]=CrysEta_;
1340  LC_Var[21]=CrysPhi_;
1341  float CrysIphiMod2=CrysIPhi_%2;
1342  float CrysIetaMod5=CrysIEta_%5;
1343  float CrysIphiMod20=CrysIPhi_%20;
1344  LC_Var[22]=CrysIphiMod2;
1345  LC_Var[23]=CrysIetaMod5;
1346  LC_Var[24]=CrysIphiMod20;
1347  LC_Var[25]=PFCrysEtaCrack_;
1348  BDTG=ReaderLCEB_->GetResponse(LC_Var);
1349  //cout<<"LC "<<BDTG<<endl;
1350  }
1351  else{
1352  float LC_Var[22];
1353  LC_Var[0]=VtxZ_;
1354  LC_Var[1]=EB;
1355  LC_Var[2]=ClusEta_;
1356  LC_Var[3]=ClusPhi_;
1357  LC_Var[4]=logPFClusE_;
1358  LC_Var[5]=eSeed_;
1359  //top bottom left right
1360  LC_Var[6]=etop_;
1361  LC_Var[7]=ebottom_;
1362  LC_Var[8]=eleft_;
1363  LC_Var[9]=eright_;
1364  LC_Var[10]=ClusR9_;
1365  LC_Var[11]=e1x3_;
1366  LC_Var[12]=e3x1_;
1367  LC_Var[13]=Clus5x5ratio_;
1368  LC_Var[14]=e1x5_;
1369  LC_Var[15]=e2x5Max_;
1370  LC_Var[16]=e2x5Top_;
1371  LC_Var[17]=e2x5Bottom_;
1372  LC_Var[18]=e2x5Left_;
1373  LC_Var[19]=e2x5Right_;
1374  LC_Var[20]=CrysX_;
1375  LC_Var[21]=CrysY_;
1376  BDTG=ReaderLCEE_->GetResponse(LC_Var);
1377  //cout<<"LC "<<BDTG<<endl;
1378  }
1379  return BDTG;
1380 
1381 }
double GetResponse(const float *vector) const
Definition: GBRForest.h:51
float e2x5Bottom_
Definition: PFEGammaAlgo.h:253
const reco::Vertex * primaryVertex_
Definition: PFEGammaAlgo.h:221
float Clus5x5ratio_
Definition: PFEGammaAlgo.h:247
float e2x5Right_
Definition: PFEGammaAlgo.h:253
const GBRForest * ReaderLCEB_
Definition: PFEGammaAlgo.h:227
double z() const
y coordinate
Definition: Vertex.h:99
float logPFClusE_
Definition: PFEGammaAlgo.h:247
const GBRForest * ReaderLCEE_
Definition: PFEGammaAlgo.h:228
float PFCrysEtaCrack_
Definition: PFEGammaAlgo.h:247
float PFEGammaAlgo::EvaluateResMVA ( reco::PFCandidate  photon,
std::vector< reco::CaloCluster PFClusters 
)
private

Definition at line 986 of file PFEGammaAlgo.cc.

References ClustersPhiRMS(), dEta_, dPhi_, E3x3_, asciidump::elements, reco::PFCandidate::elementsInBlocks(), relval_parameters_module::energy, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), eta(), reco::Mustache::FillMustacheVar(), GBRForest::GetResponse(), i, getHLTprescales::index, LowClusE_, reco::Mustache::LowestMustClust(), reco::Mustache::MustacheClust(), reco::Mustache::MustacheE(), MustE_, nVtx_, PFPhoE_, PFPhoEt_, PFPhoEta_, PFPhoPhi_, PFPhoR9Corr_, phi, reco::LeafCandidate::phi(), dttmaxenums::R, RConv_, ReaderRes_, RMSAll_, RMSMust_, SCEtaWidth_, SCPhiWidth_, mathSSE::sqrt(), reco::PFCandidate::superClusterRef(), reco::PFBlockElement::TRACK, reco::PFBlockElement::trackRef(), reco::PFBlockElement::type(), X0_inner, X0_middle, X0_outer, X0_sum, x0inner_, x0middle_, and x0outer_.

986  {
987  float BDTG=1;
988  PFPhoEta_=photon.eta();
989  PFPhoPhi_=photon.phi();
990  PFPhoE_=photon.energy();
991  //fill Material Map:
992  int ix = X0_sum->GetXaxis()->FindBin(PFPhoEta_);
993  int iy = X0_sum->GetYaxis()->FindBin(PFPhoPhi_);
994  x0inner_= X0_inner->GetBinContent(ix,iy);
995  x0middle_=X0_middle->GetBinContent(ix,iy);
996  x0outer_=X0_outer->GetBinContent(ix,iy);
997  SCPhiWidth_=photon.superClusterRef()->phiWidth();
998  SCEtaWidth_=photon.superClusterRef()->etaWidth();
999  Mustache Must;
1000  std::vector<unsigned int>insideMust;
1001  std::vector<unsigned int>outsideMust;
1002  std::multimap<float, unsigned int>OrderedClust;
1003  Must.FillMustacheVar(PFClusters);
1004  MustE_=Must.MustacheE();
1005  LowClusE_=Must.LowestMustClust();
1007  Must.MustacheClust(PFClusters,insideMust, outsideMust );
1008  for(unsigned int i=0; i<insideMust.size(); ++i){
1009  int index=insideMust[i];
1010  OrderedClust.insert(make_pair(PFClusters[index].energy(),index));
1011  }
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());
1021  }
1022  else{
1023  dEta_=0;
1024  dPhi_=0;
1025  LowClusE_=0;
1026  }
1027  //calculate RMS for All clusters and up until the Next to Lowest inside the Mustache
1028  RMSAll_=ClustersPhiRMS(PFClusters, PFPhoPhi_);
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]);
1035  }
1036  }
1037  else{
1038  for(unsigned int i=0; i<insideMust.size(); ++i){
1039  unsigned int index=insideMust[i];
1040  PFMustClusters.push_back(PFClusters[index]);
1041  }
1042  }
1043  RMSMust_=ClustersPhiRMS(PFMustClusters, PFPhoPhi_);
1044  //then use cluster Width for just one PFCluster
1045  RConv_=310;
1046  PFCandidate::ElementsInBlocks eleInBlocks = photon.elementsInBlocks();
1047  for(unsigned i=0; i<eleInBlocks.size(); i++)
1048  {
1049  PFBlockRef blockRef = eleInBlocks[i].first;
1050  unsigned indexInBlock = eleInBlocks[i].second;
1051  const edm::OwnVector< reco::PFBlockElement >& elements=eleInBlocks[i].first->elements();
1052  const reco::PFBlockElement& element = elements[indexInBlock];
1053  if(element.type()==reco::PFBlockElement::TRACK){
1054  float R=sqrt(element.trackRef()->innerPosition().X()*element.trackRef()->innerPosition().X()+element.trackRef()->innerPosition().Y()*element.trackRef()->innerPosition().Y());
1055  if(RConv_>R)RConv_=R;
1056  }
1057  else continue;
1058  }
1059  float GC_Var[17];
1060  GC_Var[0]=PFPhoEta_;
1061  GC_Var[1]=PFPhoEt_;
1062  GC_Var[2]=PFPhoR9Corr_;
1063  GC_Var[3]=PFPhoPhi_;
1064  GC_Var[4]=SCEtaWidth_;
1065  GC_Var[5]=SCPhiWidth_;
1066  GC_Var[6]=x0inner_;
1067  GC_Var[7]=x0middle_;
1068  GC_Var[8]=x0outer_;
1069  GC_Var[9]=RConv_;
1070  GC_Var[10]=LowClusE_;
1071  GC_Var[11]=RMSMust_;
1072  GC_Var[12]=RMSAll_;
1073  GC_Var[13]=dEta_;
1074  GC_Var[14]=dPhi_;
1075  GC_Var[15]=nVtx_;
1076  GC_Var[16]=MustE_;
1077 
1078  BDTG=ReaderRes_->GetResponse(GC_Var);
1079  // cout<<"Res "<<BDTG<<endl;
1080 
1081  // cout<<"BDTG Parameters X0"<<x0inner_<<", "<<x0middle_<<", "<<x0outer_<<endl;
1082  // cout<<"Et, Eta, Phi "<<PFPhoEt_<<", "<<PFPhoEta_<<", "<<PFPhoPhi_<<endl;
1083  // cout<<"PFPhoR9 "<<PFPhoR9_<<endl;
1084  // cout<<"R "<<RConv_<<endl;
1085 
1086  return BDTG;
1087 
1088 }
float SCEtaWidth_
Definition: PFEGammaAlgo.h:257
double GetResponse(const float *vector) const
Definition: GBRForest.h:51
virtual double energy() const GCC11_FINAL
energy
Abstract base class for a PFBlock element (track, cluster...)
int i
Definition: DBlmapReader.cc:9
void MustacheClust(const std::vector< CaloCluster > &clusters, std::vector< unsigned int > &insideMust, std::vector< unsigned int > &outsideMust)
Definition: Mustache.cc:168
Type type() const
list elements
Definition: asciidump.py:414
TH2D * X0_outer
Definition: PFEGammaAlgo.h:265
T eta() const
float LowestMustClust()
Definition: Mustache.h:44
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:360
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.h:365
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
double ClustersPhiRMS(std::vector< reco::CaloCluster >PFClusters, float PFPhoPhi)
float SCPhiWidth_
Definition: PFEGammaAlgo.h:257
T sqrt(T t)
Definition: SSEVec.h:48
virtual reco::TrackRef trackRef() const
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
TH2D * X0_inner
Definition: PFEGammaAlgo.h:263
const GBRForest * ReaderRes_
Definition: PFEGammaAlgo.h:225
float PFPhoR9Corr_
Definition: PFEGammaAlgo.h:257
void FillMustacheVar(const std::vector< CaloCluster > &clusters)
Definition: Mustache.cc:206
TH2D * X0_middle
Definition: PFEGammaAlgo.h:264
float MustacheE()
Definition: Mustache.h:41
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:516
Definition: DDAxes.h:10
bool PFEGammaAlgo::EvaluateSingleLegMVA ( const reco::PFBlockRef blockref,
const reco::Vertex primaryvtx,
unsigned int  track_index 
)
private

Definition at line 1383 of file PFEGammaAlgo.cc.

References reco::PFBlock::associatedElements(), Association::block, chi2, del_phi, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::PFBlockElement::ECAL, reco::PFBlock::elements(), asciidump::elements, EoverPt, reco::PFBlockElement::HCAL, HoverPt, reco::PFBlock::linkData(), reco::PFBlock::LINKTEST_ALL, MVACUT, mvaValue, nlayers, nlost, colinearityKinematic::Phi, PV3DBase< T, PVType, FrameType >::phi(), STIP, tmvaReader_, track_pt, X, reco::Vertex::x(), reco::Vertex::y(), and reco::Vertex::z().

Referenced by RunPFEG().

1384 {
1385  bool convtkfound=false;
1386  const reco::PFBlock& block = *blockref;
1388  //use this to store linkdata in the associatedElements function below
1389  PFBlock::LinkData linkData = block.linkData();
1390  //calculate MVA Variables
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();
1396 
1397  float linked_e=0;
1398  float linked_h=0;
1399  std::multimap<double, unsigned int> ecalAssoTrack;
1400  block.associatedElements( track_index,linkData,
1401  ecalAssoTrack,
1404  std::multimap<double, unsigned int> hcalAssoTrack;
1405  block.associatedElements( track_index,linkData,
1406  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();
1413  }
1414  }
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();
1419  }
1420  }
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();
1427  //delta Phi between conversion vertex and track
1428  del_phi=fabs(deltaPhi(vtx_phi, elements[track_index].trackRef()->innerMomentum().Phi()));
1429  mvaValue = tmvaReader_->EvaluateMVA("BDT");
1430  if(mvaValue > MVACUT)convtkfound=true;
1431  return convtkfound;
1432 }
double mvaValue
Definition: PFEGammaAlgo.h:242
double y() const
y coordinate
Definition: Vertex.h:97
std::map< unsigned int, Link > LinkData
Definition: PFBlock.h:46
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
#define X(str)
Definition: MuonsGrabber.cc:49
list elements
Definition: asciidump.py:414
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
const LinkData & linkData() const
Definition: PFBlock.h:112
double z() const
y coordinate
Definition: Vertex.h:99
block
Formating index page&#39;s pieces.
Definition: Association.py:232
double x() const
x coordinate
Definition: Vertex.h:95
void associatedElements(unsigned i, const LinkData &linkData, std::multimap< double, unsigned > &sortedAssociates, reco::PFBlockElement::Type type=PFBlockElement::NONE, LinkTest test=LINKTEST_RECHIT) const
Definition: PFBlock.cc:75
TMVA::Reader * tmvaReader_
Definition: PFEGammaAlgo.h:222
Block of elements.
Definition: PFBlock.h:30
const std::vector<reco::PFCandidate>& PFEGammaAlgo::getCandidates ( )
inline

Definition at line 111 of file PFEGammaAlgo.h.

References egCandidate_.

111 {return egCandidate_;};
std::vector< reco::PFCandidate > egCandidate_
Definition: PFEGammaAlgo.h:272
const std::vector< reco::PFCandidateEGammaExtra>& PFEGammaAlgo::getEGExtra ( )
inline

Definition at line 114 of file PFEGammaAlgo.h.

References egExtra_.

114 {return egExtra_;};
std::vector< reco::PFCandidateEGammaExtra > egExtra_
Definition: PFEGammaAlgo.h:276
std::vector<int> PFEGammaAlgo::getPFMustacheClus ( int  nClust,
std::vector< float > &  ClustEt,
std::vector< float > &  ClustEta,
std::vector< float > &  ClustPhi 
)
private
bool PFEGammaAlgo::isEGValidCandidate ( const reco::PFBlockRef blockRef,
std::vector< bool > &  active 
)
inline

Definition at line 102 of file PFEGammaAlgo.h.

References egCandidate_, and RunPFEG().

105  {
106  RunPFEG(blockRef,active);
107  return (egCandidate_.size()>0);
108  };
void RunPFEG(const reco::PFBlockRef &blockRef, std::vector< bool > &active)
std::vector< reco::PFCandidate > egCandidate_
Definition: PFEGammaAlgo.h:272
bool PFEGammaAlgo::isPrimaryTrack ( const reco::PFBlockElementTrack KfEl,
const reco::PFBlockElementGsfTrack GsfEl 
)
private

Definition at line 2805 of file PFEGammaAlgo.cc.

References reco::PFBlockElementGsfTrack::GsftrackRefPF(), edm::Ref< C, T, F >::isNonnull(), and reco::PFBlockElementTrack::trackRefPF().

Referenced by AddElectronCandidate(), and SetLinks().

2806  {
2807  bool isPrimary = false;
2808 
2809  GsfPFRecTrackRef gsfPfRef = GsfEl.GsftrackRefPF();
2810 
2811  if(gsfPfRef.isNonnull()) {
2812  PFRecTrackRef kfPfRef = KfEl.trackRefPF();
2813  PFRecTrackRef kfPfRef_fromGsf = (*gsfPfRef).kfPFRecTrackRef();
2814  if(kfPfRef.isNonnull() && kfPfRef_fromGsf.isNonnull()) {
2815  reco::TrackRef kfref= (*kfPfRef).trackRef();
2816  reco::TrackRef kfref_fromGsf = (*kfPfRef_fromGsf).trackRef();
2817  if(kfref.isNonnull() && kfref_fromGsf.isNonnull()) {
2818  if(kfref == kfref_fromGsf)
2819  isPrimary = true;
2820  }
2821  }
2822  }
2823 
2824  return isPrimary;
2825 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
PFRecTrackRef trackRefPF() const
GsfPFRecTrackRef GsftrackRefPF() const
void PFEGammaAlgo::RunPFEG ( const reco::PFBlockRef blockRef,
std::vector< bool > &  active 
)
private

Definition at line 147 of file PFEGammaAlgo.cc.

References reco::PFCandidateEGammaExtra::addConversionRef(), AddElectronCandidate(), AddElectronElements(), AddFromElectron_, reco::PFCandidateEGammaExtra::addSingleLegConvMva(), reco::PFCandidateEGammaExtra::addSingleLegConvTrackRef(), edm::OwnVector< T, P >::begin(), Chatty, convGsfTrack_, convBrem_cff::convTracks, E3x3_, reco::PFBlockElement::ECAL, egCandidate_, egExtra_, asciidump::elements, edm::OwnVector< T, P >::end(), EvaluateGCorrMVA(), EvaluateLCorrMVA(), EvaluateSingleLegMVA(), fifthStepKfTrack_, reco::PFCandidate::gamma, reco::PFCandidate::GAMMA_TO_GAMMACONV, reco::PFBlockElement::HCAL, i, isvalid_, prof2calltree::l, reco::PFBlock::LINKTEST_ALL, Association::map, mvaValue, PFPhoECorr_, PFPhoR9_, position, primaryVertex_, reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, edm::RefVector< C, T, F >::push_back(), edm::OwnVector< T, P >::push_back(), reco::PFBlockElement::SC, SetLinks(), reco::PFCandidateEGammaExtra::setSuperClusterBoxRef(), funct::sin(), edm::RefVector< C, T, F >::size(), edm::OwnVector< T, P >::size(), mathSSE::sqrt(), reco::PFBlockElementSuperCluster::superClusterRef(), reco::PFBlockElement::T_FROM_GAMMACONV, thePFEnergyCalibration_, theta(), TotPS1_, TotPS2_, reco::PFBlockElement::TRACK, reco::PFBlockElementTrack::trackType(), useReg_, findQualityFiles::v, verbosityLevel_, reco::Vertex::x(), reco::Vertex::y(), and reco::Vertex::z().

Referenced by isEGValidCandidate().

149  {
150 
151  // should be cleaned as often as often as possible
152 // elCandidate_.clear();
153 // electronExtra_.clear();
154 // allElCandidate_.clear();
155  //electronConstituents_.clear();
156  fifthStepKfTrack_.clear();
157  convGsfTrack_.clear();
158 
159  egCandidate_.clear();
160  egExtra_.clear();
161 
162  //std::cout<<" calling RunPFPhoton "<<std::endl;
163 
164  /* For now we construct the PhotonCandidate simply from
165  a) adding the CORRECTED energies of each participating ECAL cluster
166  b) build the energy-weighted direction for the Photon
167  */
168 
169 
170  // define how much is printed out for debugging.
171  // ... will be setable via CFG file parameter
172  verbosityLevel_ = Chatty; // Chatty mode.
173 
174 
175  // loop over all elements in the Block
176  const edm::OwnVector< reco::PFBlockElement >& elements = blockRef->elements();
178  std::vector<bool>::const_iterator actIter = active.begin();
179  PFBlock::LinkData linkData = blockRef->linkData();
180  bool isActive = true;
181 
182 
183  if(elements.size() != active.size()) {
184  // throw excpetion...
185  //std::cout<<" WARNING: Size of collection and active-vectro don't agree!"<<std::endl;
186  return;
187  }
188 
189  //build large set of association maps between gsf/kf tracks, PFClusters and SuperClusters
190  //this function originally came from the PFElectronAlgo
191  // the maps are initialized
192  AssMap associatedToGsf;
193  AssMap associatedToBrems;
194  AssMap associatedToEcal;
195 
196  //bool blockHasGSF =
197  SetLinks(blockRef,associatedToGsf,
198  associatedToBrems,associatedToEcal,
199  active, *primaryVertex_);
200 
201  //printf("blockHasGsf = %i\n",int(blockHasGSF));
202 
203 
204  // local vecotr to keep track of the indices of the 'elements' for the Photon candidate
205  // once we decide to keep the candidate, the 'active' entriesd for them must be set to false
206  std::vector<unsigned int> elemsToLock;
207  elemsToLock.resize(0);
208 
209  for( ; ele != elements.end(); ++ele, ++actIter ) {
210 
211  // if it's not a SuperCluster, go to the next element
212  if( !( ele->type() == reco::PFBlockElement::SC ) ) continue;
213 
214  //printf("supercluster\n");
215 
216  // Photon kienmatics, will be updated for each identified participating element
217  float photonEnergy_ = 0.;
218  float photonX_ = 0.;
219  float photonY_ = 0.;
220  float photonZ_ = 0.;
221  float RawEcalEne = 0.;
222 
223  // Total pre-shower energy
224  float ps1TotEne = 0.;
225  float ps2TotEne = 0.;
226 
227  bool hasConvTrack=false;
228  bool hasSingleleg=false;
229  std::vector<unsigned int> AddClusters(0);
230  std::vector<unsigned int> IsoTracks(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;
237  reco::ConversionRefVector ConversionsRef_;
238  isActive = *(actIter);
239  //cout << " Found a SuperCluster. Energy " ;
240  const reco::PFBlockElementSuperCluster *sc = dynamic_cast<const reco::PFBlockElementSuperCluster*>(&(*ele));
241  //std::cout << sc->superClusterRef()->energy () << " Track/Ecal/Hcal Iso " << sc->trackIso()<< " " << sc->ecalIso() ;
242  //std::cout << " " << sc->hcalIso() <<std::endl;
243  //if (!(sc->fromPhoton()))continue;
244 
245  // check the status of the SC Element...
246  // ..... I understand it should *always* be active, since PFElectronAlgo does not touch this (yet?) RISHI: YES
247  if( !isActive ) {
248  //std::cout<<" SuperCluster is NOT active.... "<<std::endl;
249  continue;
250  }
251  elemsToLock.push_back(ele-elements.begin()); //add SC to elements to lock
252  // loop over its constituent ECAL cluster
253  std::multimap<double, unsigned int> ecalAssoPFClusters;
254  blockRef->associatedElements( ele-elements.begin(),
255  linkData,
256  ecalAssoPFClusters,
259  //R9 of SuperCluster and RawE
260  //PFPhoR9_=sc->photonRef()->r9();
261  PFPhoR9_=1.0;
262  E3x3_=PFPhoR9_*(sc->superClusterRef()->rawEnergy());
263  // loop over the ECAL clusters linked to the iEle
264  if( ! ecalAssoPFClusters.size() ) {
265  // This SC element has NO ECAL elements asigned... *SHOULD NOT HAPPEN*
266  //std::cout<<" Found SC element with no ECAL assigned "<<std::endl;
267  continue;
268  }
269 
270  //list of matched gsf tracks associated to this supercluster through
271  //a shared PFCluster
272  //std::set<unsigned int> matchedGsf;
273  std::vector<unsigned int> matchedGsf;
274  for (map<unsigned int,vector<unsigned int> >::iterator igsf = associatedToGsf.begin();
275  igsf != associatedToGsf.end(); igsf++) {
276 
277  bool matched = false;
278  if( !( active[igsf->first] ) ) continue;
279 
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];
283 
284  if( !( active[associdx] ) ) continue;
285 
286  PFBlockElement::Type assoele_type = elements[associdx].type();
287 
288  if(assoele_type == reco::PFBlockElement::ECAL) {
289  for(std::multimap<double, unsigned int>::iterator itecal = ecalAssoPFClusters.begin();
290  itecal != ecalAssoPFClusters.end(); ++itecal) {
291 
292  if (itecal->second==associdx) {
293  matchedGsf.push_back(igsf->first);
294  matched = true;
295  break;
296  }
297  }
298  }
299 
300  if (matched) break;
301  }
302 
303  }
304 
305  //printf("matchedGsf size = %i\n",int(matchedGsf.size()));
306 
307 
308  // This is basically CASE 2
309  // .... we loop over all ECAL cluster linked to each other by this SC
310  for(std::multimap<double, unsigned int>::iterator itecal = ecalAssoPFClusters.begin();
311  itecal != ecalAssoPFClusters.end(); ++itecal) {
312 
313  //printf("ecal cluster\n");
314 
315  //loop over associated elements to check for gsf
316 
317 // std::map<unsigned int, std::vector<unsigned int> >::const_iterator assoc_ecal_it = associatedToEcal.find(itecal->second);
318 // if (assoc_ecal_it!=associatedToEcal.end()) {
319 // const std::vector<unsigned int> &assoecal_index = assoc_ecal_it->second;
320 // for (unsigned int iecalassoc=0;iecalassoc<assoecal_index.size();iecalassoc++) {
321 // int associdx = assoecal_index[iecalassoc];
322 // PFBlockElement::Type assoele_type = elements[associdx].type();
323 // // lock the elements associated to the gsf: ECAL, Brems
324 // //active[(assogsf_index[ielegsf])] = false;
325 // printf("matched element to ecal cluster, type = %i\n",int(assoele_type));
326 //
327 // if (assoele_type == reco::PFBlockElement::GSF) {
328 // printf("matched gsf\n");
329 // if (!matchedGsf.count(associdx)) {
330 // matchedGsf.insert(associdx);
331 // }
332 // }
333 // }
334 // }
335 
336 
337 
338  // to get the reference to the PF clusters, this is needed.
339  reco::PFClusterRef clusterRef = elements[itecal->second].clusterRef();
340 
341 
342 
343 
344  // from the clusterRef get the energy, direction, etc
345  // float ClustRawEnergy = clusterRef->energy();
346  // float ClustEta = clusterRef->position().eta();
347  // float ClustPhi = clusterRef->position().phi();
348 
349  // initialize the vectors for the PS energies
350  vector<double> ps1Ene(0);
351  vector<double> ps2Ene(0);
352  double ps1=0;
353  double ps2=0;
354  hasSingleleg=false;
355  hasConvTrack=false;
356 
357  /*
358  cout << " My cluster index " << itecal->second
359  << " energy " << ClustRawEnergy
360  << " eta " << ClustEta
361  << " phi " << ClustPhi << endl;
362  */
363  // check if this ECAL element is still active (could have been eaten by PFElectronAlgo)
364  // ......for now we give the PFElectron Algo *ALWAYS* Shot-Gun on the ECAL elements to the PFElectronAlgo
365 
366  if( !( active[itecal->second] ) ) {
367  //std::cout<< " .... this ECAL element is NOT active anymore. Is skipped. "<<std::endl;
368  continue;
369  }
370 
371  // ------------------------------------------------------------------------------------------
372  // TODO: do some tests on the ECAL cluster itself, deciding to use it or not for the Photons
373  // ..... ??? Do we need this?
374  if ( false ) {
375  // Check if there are a large number tracks that do not pass pre-ID around this ECAL cluster
376  bool useIt = true;
377  int mva_reject=0;
378  bool isClosest=false;
379  std::multimap<double, unsigned int> Trackscheck;
380  blockRef->associatedElements( itecal->second,
381  linkData,
382  Trackscheck,
385  for(std::multimap<double, unsigned int>::iterator track = Trackscheck.begin();
386  track != Trackscheck.end(); ++track) {
387 
388  // first check if is it's still active
389  if( ! (active[track->second]) ) continue;
390  hasSingleleg=EvaluateSingleLegMVA(blockRef, *primaryVertex_, track->second);
391  //check if it is the closest linked track
392  std::multimap<double, unsigned int> closecheck;
393  blockRef->associatedElements(track->second,
394  linkData,
395  closecheck,
396  reco::PFBlockElement::ECAL,
398  if(closecheck.begin()->second ==itecal->second)isClosest=true;
399  if(!hasSingleleg)mva_reject++;
400  }
401 
402  if(mva_reject>0 && isClosest)useIt=false;
403  //if(mva_reject==1 && isClosest)useIt=false;
404  if( !useIt ) continue; // Go to next ECAL cluster within SC
405  }
406  // ------------------------------------------------------------------------------------------
407 
408  // We decided to keep the ECAL cluster for this Photon Candidate ...
409  elemsToLock.push_back(itecal->second);
410 
411  // look for PS in this Block linked to this ECAL cluster
412  std::multimap<double, unsigned int> PS1Elems;
413  std::multimap<double, unsigned int> PS2Elems;
414  //PS Layer 1 linked to ECAL cluster
415  blockRef->associatedElements( itecal->second,
416  linkData,
417  PS1Elems,
420  //PS Layer 2 linked to the ECAL cluster
421  blockRef->associatedElements( itecal->second,
422  linkData,
423  PS2Elems,
426 
427  // loop over all PS1 and compute energy
428  for(std::multimap<double, unsigned int>::iterator iteps = PS1Elems.begin();
429  iteps != PS1Elems.end(); ++iteps) {
430 
431  // first chekc if it's still active
432  if( !(active[iteps->second]) ) continue;
433 
434  //Check if this PS1 is not closer to another ECAL cluster in this Block
435  std::multimap<double, unsigned int> ECALPS1check;
436  blockRef->associatedElements( iteps->second,
437  linkData,
438  ECALPS1check,
439  reco::PFBlockElement::ECAL,
441  if(itecal->second==ECALPS1check.begin()->second)//then it is closest linked
442  {
443  reco::PFClusterRef ps1ClusterRef = elements[iteps->second].clusterRef();
444  ps1Ene.push_back( ps1ClusterRef->energy() );
445  ps1=ps1+ps1ClusterRef->energy(); //add to total PS1
446  // incativate this PS1 Element
447  elemsToLock.push_back(iteps->second);
448  }
449  }
450  for(std::multimap<double, unsigned int>::iterator iteps = PS2Elems.begin();
451  iteps != PS2Elems.end(); ++iteps) {
452 
453  // first chekc if it's still active
454  if( !(active[iteps->second]) ) continue;
455 
456  // Check if this PS2 is not closer to another ECAL cluster in this Block:
457  std::multimap<double, unsigned int> ECALPS2check;
458  blockRef->associatedElements( iteps->second,
459  linkData,
460  ECALPS2check,
461  reco::PFBlockElement::ECAL,
463  if(itecal->second==ECALPS2check.begin()->second)//is closest linked
464  {
465  reco::PFClusterRef ps2ClusterRef = elements[iteps->second].clusterRef();
466  ps2Ene.push_back( ps2ClusterRef->energy() );
467  ps2=ps2ClusterRef->energy()+ps2; //add to total PS2
468  // incativate this PS2 Element
469  elemsToLock.push_back(iteps->second);
470  }
471  }
472 
473  // loop over the HCAL Clusters linked to the ECAL cluster (CASE 6)
474  std::multimap<double, unsigned int> hcalElems;
475  blockRef->associatedElements( itecal->second,linkData,
476  hcalElems,
479 
480  for(std::multimap<double, unsigned int>::iterator ithcal = hcalElems.begin();
481  ithcal != hcalElems.end(); ++ithcal) {
482 
483  if ( ! (active[ithcal->second] ) ) continue; // HCAL Cluster already used....
484 
485  // TODO: Decide if this HCAL cluster is to be used
486  // .... based on some Physics
487  // .... To we need to check if it's closer to any other ECAL/TRACK?
488 
489  bool useHcal = false;
490  if ( !useHcal ) continue;
491  //not locked
492  //elemsToLock.push_back(ithcal->second);
493  }
494 
495  // This is entry point for CASE 3.
496  // .... we loop over all Tracks linked to this ECAL and check if it's labeled as conversion
497  // This is the part for looping over all 'Conversion' Tracks
498  std::multimap<double, unsigned int> convTracks;
499  blockRef->associatedElements( itecal->second,
500  linkData,
501  convTracks,
504  for(std::multimap<double, unsigned int>::iterator track = convTracks.begin();
505  track != convTracks.end(); ++track) {
506 
507  // first check if is it's still active
508  if( ! (active[track->second]) ) continue;
509 
510  // check if it's a CONV track
511  const reco::PFBlockElementTrack * trackRef = dynamic_cast<const reco::PFBlockElementTrack*>((&elements[track->second]));
512 
513  //Check if track is a Single leg from a Conversion
514  mvaValue=-999;
515  hasSingleleg=EvaluateSingleLegMVA(blockRef, *primaryVertex_, track->second);
516 
517  // Daniele; example for mvaValues, do the same for single leg trackRef and convRef
518  //
519  // if(hasSingleleg)
520  // mvaValues.push_back(mvaValue);
521 
522  //If it is not then it will be used to check Track Isolation at the end
523  if(!hasSingleleg)
524  {
525  bool included=false;
526  //check if this track is already included in the vector so it is linked to an ECAL cluster that is already examined
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);
530  }
531  //For now only Pre-ID tracks that are not already identified as Conversions
532  if(hasSingleleg &&!(trackRef->trackType(reco::PFBlockElement::T_FROM_GAMMACONV)))
533  {
534  elemsToLock.push_back(track->second);
535 
536  reco::TrackRef t_ref=elements[track->second].trackRef();
537  bool matched=false;
538  for(unsigned int ic=0; ic<singleLegRef.size(); ic++)
539  if(singleLegRef[ic]==t_ref)matched=true;
540 
541  if(!matched){
542  singleLegRef.push_back(t_ref);
543  MVA_values.push_back(mvaValue);
544  }
545  //find all the clusters linked to this track
546  std::multimap<double, unsigned int> moreClusters;
547  blockRef->associatedElements( track->second,
548  linkData,
549  moreClusters,
550  reco::PFBlockElement::ECAL,
552 
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());
556  float linked_E=0;
557  for(std::multimap<double, unsigned int>::iterator clust = moreClusters.begin();
558  clust != moreClusters.end(); ++clust)
559  {
560  if(!active[clust->second])continue;
561  //running sum of linked energy
562  linked_E=linked_E+elements[clust->second].clusterRef()->energy();
563  //prevent too much energy from being added
564  if(linked_E/p_in>1.5)break;
565  bool included=false;
566  //check if these ecal clusters are already included with the supercluster
567  for(std::multimap<double, unsigned int>::iterator cluscheck = ecalAssoPFClusters.begin();
568  cluscheck != ecalAssoPFClusters.end(); ++cluscheck)
569  {
570  if(cluscheck->second==clust->second)included=true;
571  }
572  if(!included)AddClusters.push_back(clust->second);//Add to a container of clusters to be Added to the Photon candidate
573  }
574  }
575 
576  // Possibly need to be more smart about them (CASE 5)
577  // .... for now we simply skip non id'ed tracks
578  if( ! (trackRef->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) ) ) continue;
579  hasConvTrack=true;
580  elemsToLock.push_back(track->second);
581  //again look at the clusters linked to this track
582  //if(elements[track->second].convRef().isNonnull())
583  //{
584  // ConversionsRef_.push_back(elements[track->second].convRef());
585  //}
586  std::multimap<double, unsigned int> moreClusters;
587  blockRef->associatedElements( track->second,
588  linkData,
589  moreClusters,
590  reco::PFBlockElement::ECAL,
592 
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());
596  float linked_E=0;
597  for(std::multimap<double, unsigned int>::iterator clust = moreClusters.begin();
598  clust != moreClusters.end(); ++clust)
599  {
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;
603  bool included=false;
604  for(std::multimap<double, unsigned int>::iterator cluscheck = ecalAssoPFClusters.begin();
605  cluscheck != ecalAssoPFClusters.end(); ++cluscheck)
606  {
607  if(cluscheck->second==clust->second)included=true;
608  }
609  if(!included)AddClusters.push_back(clust->second);//again only add if it is not already included with the supercluster
610  }
611 
612  // we need to check for other TRACKS linked to this conversion track, that point possibly no an ECAL cluster not included in the SC
613  // .... This is basically CASE 4.
614 
615  std::multimap<double, unsigned int> moreTracks;
616  blockRef->associatedElements( track->second,
617  linkData,
618  moreTracks,
621 
622  for(std::multimap<double, unsigned int>::iterator track2 = moreTracks.begin();
623  track2 != moreTracks.end(); ++track2) {
624 
625  // first check if is it's still active
626  if( ! (active[track2->second]) ) continue;
627  //skip over the 1st leg already found above
628  if(track->second==track2->second)continue;
629  // check if it's a CONV track
630  const reco::PFBlockElementTrack * track2Ref = dynamic_cast<const reco::PFBlockElementTrack*>((&elements[track2->second]));
631  if( ! (track2Ref->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) ) ) continue; // Possibly need to be more smart about them (CASE 5)
632  elemsToLock.push_back(track2->second);
633  // so it's another active conversion track, that is in the Block and linked to the conversion track we already found
634  // find the ECAL cluster linked to it...
635  std::multimap<double, unsigned int> convEcalAll;
636  blockRef->associatedElements( track2->second,
637  linkData,
638  convEcalAll,
639  reco::PFBlockElement::ECAL,
641 
642  //create cleaned collection of associated ecal clusters restricted to subdetector of the seeding supercluster
643  //This cleaning is needed since poorly reconstructed conversions can occasionally have the second track pointing
644  //to the wrong subdetector
645  std::multimap<double, unsigned int> convEcal;
646  for(std::multimap<double, unsigned int>::iterator itecal = convEcalAll.begin();
647  itecal != convEcalAll.end(); ++itecal) {
648 
649  // to get the reference to the PF clusters, this is needed.
650  reco::PFClusterRef clusterRef = elements[itecal->second].clusterRef();
651 
652  if (clusterRef->hitsAndFractions().at(0).first.subdetId()==sc->superClusterRef()->seed()->hitsAndFractions().at(0).first.subdetId()) {
653  convEcal.insert(*itecal);
654  }
655  }
656 
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());
660 
661 
662  float linked_E=0;
663  for(std::multimap<double, unsigned int>::iterator itConvEcal = convEcal.begin();
664  itConvEcal != convEcal.end(); ++itConvEcal) {
665 
666  if( ! (active[itConvEcal->second]) ) continue;
667  bool included=false;
668  for(std::multimap<double, unsigned int>::iterator cluscheck = ecalAssoPFClusters.begin();
669  cluscheck != ecalAssoPFClusters.end(); ++cluscheck)
670  {
671  if(cluscheck->second==itConvEcal->second)included=true;
672  }
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);
676  }
677 
678  // it's still active, so we have to add it.
679  // CAUTION: we don't care here if it's part of the SC or not, we include it anyways
680 
681  // loop over the HCAL Clusters linked to the ECAL cluster (CASE 6)
682  std::multimap<double, unsigned int> hcalElems_conv;
683  blockRef->associatedElements( itecal->second,linkData,
684  hcalElems_conv,
687 
688  for(std::multimap<double, unsigned int>::iterator ithcal2 = hcalElems_conv.begin();
689  ithcal2 != hcalElems_conv.end(); ++ithcal2) {
690 
691  if ( ! (active[ithcal2->second] ) ) continue; // HCAL Cluster already used....
692 
693  // TODO: Decide if this HCAL cluster is to be used
694  // .... based on some Physics
695  // .... To we need to check if it's closer to any other ECAL/TRACK?
696 
697  bool useHcal = true;
698  if ( !useHcal ) continue;
699 
700  //elemsToLock.push_back(ithcal2->second);
701 
702  } // end of loop over HCAL clusters linked to the ECAL cluster from second CONVERSION leg
703 
704  } // end of loop over ECALs linked to second T_FROM_GAMMACONV
705 
706  } // end of loop over SECOND conversion leg
707 
708  // TODO: Do we need to check separatly if there are HCAL cluster linked to the track?
709 
710  } // end of loop over tracks
711 
712 
713  // Calibrate the Added ECAL energy
714  float addedCalibEne=0;
715  float addedRawEne=0;
716  std::vector<double>AddedPS1(0);
717  std::vector<double>AddedPS2(0);
718  double addedps1=0;
719  double addedps2=0;
720  for(unsigned int i=0; i<AddClusters.size(); i++)
721  {
722  std::multimap<double, unsigned int> PS1Elems_conv;
723  std::multimap<double, unsigned int> PS2Elems_conv;
724  blockRef->associatedElements(AddClusters[i],
725  linkData,
726  PS1Elems_conv,
729  blockRef->associatedElements( AddClusters[i],
730  linkData,
731  PS2Elems_conv,
734 
735  for(std::multimap<double, unsigned int>::iterator iteps = PS1Elems_conv.begin();
736  iteps != PS1Elems_conv.end(); ++iteps)
737  {
738  if(!active[iteps->second])continue;
739  std::multimap<double, unsigned int> PS1Elems_check;
740  blockRef->associatedElements(iteps->second,
741  linkData,
742  PS1Elems_check,
743  reco::PFBlockElement::ECAL,
745  if(PS1Elems_check.begin()->second==AddClusters[i])
746  {
747 
748  reco::PFClusterRef ps1ClusterRef = elements[iteps->second].clusterRef();
749  AddedPS1.push_back(ps1ClusterRef->energy());
750  addedps1=addedps1+ps1ClusterRef->energy();
751  elemsToLock.push_back(iteps->second);
752  }
753  }
754 
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,
760  linkData,
761  PS2Elems_check,
762  reco::PFBlockElement::ECAL,
764 
765  if(PS2Elems_check.begin()->second==AddClusters[i])
766  {
767  reco::PFClusterRef ps2ClusterRef = elements[iteps->second].clusterRef();
768  AddedPS2.push_back(ps2ClusterRef->energy());
769  addedps2=addedps2+ps2ClusterRef->energy();
770  elemsToLock.push_back(iteps->second);
771  }
772  }
773  reco::PFClusterRef AddclusterRef = elements[AddClusters[i]].clusterRef();
774  addedRawEne = AddclusterRef->energy()+addedRawEne;
775  addedCalibEne = thePFEnergyCalibration_->energyEm(*AddclusterRef,AddedPS1,AddedPS2,false)+addedCalibEne;
776  AddedPS2.clear();
777  AddedPS1.clear();
778  elemsToLock.push_back(AddClusters[i]);
779  }
780  AddClusters.clear();
781  float EE=thePFEnergyCalibration_->energyEm(*clusterRef,ps1Ene,ps2Ene,false)+addedCalibEne;
782  PFClusters.push_back(*clusterRef);
783  if(useReg_){
784  float LocCorr=EvaluateLCorrMVA(clusterRef);
785  EE=LocCorr*clusterRef->energy()+addedCalibEne;
786  }
787  else{
788  float LocCorr=EvaluateLCorrMVA(clusterRef);
789  MVALCorr.push_back(LocCorr*clusterRef->energy());
790  }
791 
792  //cout<<"Original Energy "<<EE<<"Added Energy "<<addedCalibEne<<endl;
793 
794  photonEnergy_ += EE;
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;
801  } // end of loop over all ECAL cluster within this SC
802 
803 
804  //add elements from electron candidates
805  bool goodelectron = false;
806  if (matchedGsf.size()>0) {
807  //printf("making electron, candsize = %i\n",int(egCandidate_.size()));
808  int eleidx = matchedGsf.front();
809  AddElectronElements(eleidx, elemsToLock, blockRef, associatedToGsf, associatedToBrems, associatedToEcal);
810  goodelectron = AddElectronCandidate(eleidx, sc->superClusterRef(), elemsToLock, blockRef, associatedToGsf, associatedToBrems, associatedToEcal, active);
811  //printf("goodelectron = %i, candsize = %i\n",int(goodelectron),int(egCandidate_.size()));
812  }
813 
814  if (goodelectron) continue;
815 
816  //printf("making photon\n");
817 
818  // we've looped over all ECAL clusters, ready to generate PhotonCandidate
819  if( ! (photonEnergy_ > 0.) ) continue; // This SC is not a Photon Candidate
820  float sum_track_pt=0;
821  //Now check if there are tracks failing isolation outside of the Jurassic isolation region
822  for(unsigned int i=0; i<IsoTracks.size(); i++)sum_track_pt=sum_track_pt+elements[IsoTracks[i]].trackRef()->pt();
823 
824 
825 
826  math::XYZVector photonPosition(photonX_,
827  photonY_,
828  photonZ_);
829  math::XYZVector photonPositionwrtVtx(
830  photonX_- primaryVertex_->x(),
831  photonY_-primaryVertex_->y(),
832  photonZ_-primaryVertex_->z()
833  );
834  math::XYZVector photonDirection=photonPositionwrtVtx.Unit();
835 
836  math::XYZTLorentzVector photonMomentum(photonEnergy_* photonDirection.X(),
837  photonEnergy_* photonDirection.Y(),
838  photonEnergy_* photonDirection.Z(),
839  photonEnergy_ );
840 
841 // if(sum_track_pt>(sumPtTrackIsoForPhoton_ + sumPtTrackIsoSlopeForPhoton_ * photonMomentum.pt()) && AddFromElectron_.size()==0)
842 // {
843 // elemsToLock.resize(0);
844 // continue;
845 //
846 // }
847 
848  //THIS SC is not a Photon it fails track Isolation
849  //if(sum_track_pt>(2+ 0.001* photonMomentum.pt()))
850  //continue;//THIS SC is not a Photon it fails track Isolation
851 
852  /*
853  std::cout<<" Created Photon with energy = "<<photonEnergy_<<std::endl;
854  std::cout<<" pT = "<<photonMomentum.pt()<<std::endl;
855  std::cout<<" RawEne = "<<RawEcalEne<<std::endl;
856  std::cout<<" E = "<<photonMomentum.e()<<std::endl;
857  std::cout<<" eta = "<<photonMomentum.eta()<<std::endl;
858  std::cout<<" TrackIsolation = "<< sum_track_pt <<std::endl;
859  */
860 
861  reco::PFCandidate photonCand(0,photonMomentum, reco::PFCandidate::gamma);
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.);
867  photonCand.setSuperClusterRef(sc->superClusterRef());
869  photonCand.setVertex( v );
870  if(hasConvTrack || hasSingleleg)photonCand.setFlag( reco::PFCandidate::GAMMA_TO_GAMMACONV, true);
871 // int matches=match_ind.size();
872 // int count=0;
873 // for ( std::vector<reco::PFCandidate>::const_iterator ec=tempElectronCandidates.begin(); ec != tempElectronCandidates.end(); ++ec ){
874 // for(int i=0; i<matches; i++)
875 // {
876 // if(count==match_ind[i])photonCand.addDaughter(*ec);
877 // count++;
878 // }
879 // }
880  // set isvalid_ to TRUE since we've found at least one photon candidate
881  isvalid_ = true;
882  // push back the candidate into the collection ...
883  //Add Elements from Electron
884  for(std::vector<unsigned int>::const_iterator it =
885  AddFromElectron_.begin();
886  it != AddFromElectron_.end(); ++it)photonCand.addElementInBlock(blockRef,*it);
887 
888  // ... and lock all elemts used
889  for(std::vector<unsigned int>::const_iterator it = elemsToLock.begin();
890  it != elemsToLock.end(); ++it)
891  {
892  if(active[*it])
893  {
894  photonCand.addElementInBlock(blockRef,*it);
895  if( elements[*it].type() == reco::PFBlockElement::TRACK )
896  {
897  if(elements[*it].convRef().isNonnull())
898  {
899  //make sure it is not stored already as the partner track
900  bool matched=false;
901  for(unsigned int ic = 0; ic < ConversionsRef_.size(); ic++)
902  {
903  if(ConversionsRef_[ic]==elements[*it].convRef())matched=true;
904  }
905  if(!matched)ConversionsRef_.push_back(elements[*it].convRef());
906  }
907  }
908  }
909  active[*it] = false;
910  }
911  PFPhoECorr_=0;
912  // here add the extra information
913  //PFCandidateEGammaExtra myExtra(sc->superClusterRef());
914  PFCandidateEGammaExtra myExtra;
915  //myExtra.setSuperClusterRef(sc->superClusterRef());
916  myExtra.setSuperClusterBoxRef(sc->superClusterRef());
917  //myExtra.setClusterEnergies(MVALCorr);
918  //Store Locally Contained PF Cluster regressed energy
919  for(unsigned int l=0; l<MVALCorr.size(); ++l)
920  {
921  //myExtra.addLCorrClusEnergy(MVALCorr[l]);
922  PFPhoECorr_=PFPhoECorr_+MVALCorr[l];//total Locally corrected energy
923  }
924  TotPS1_=ps1TotEne;
925  TotPS2_=ps2TotEne;
926  //Do Global Corrections here:
927  float GCorr=EvaluateGCorrMVA(photonCand, PFClusters);
928  if(useReg_){
929  math::XYZTLorentzVector photonCorrMomentum(GCorr*PFPhoECorr_* photonDirection.X(),
930  GCorr*PFPhoECorr_* photonDirection.Y(),
931  GCorr*PFPhoECorr_* photonDirection.Z(),
932  GCorr * photonEnergy_ );
933  photonCand.setP4(photonCorrMomentum);
934  }
935 
936  std::multimap<float, unsigned int>OrderedClust;
937  for(unsigned int i=0; i<PFClusters.size(); ++i){
938  float et=PFClusters[i].energy()*sin(PFClusters[i].position().theta());
939  OrderedClust.insert(make_pair(et, i));
940  }
941  std::multimap<float, unsigned int>::reverse_iterator rit;
942  rit=OrderedClust.rbegin();
943  unsigned int highEindex=(*rit).second;
944  //store Position at ECAL Entrance as Position of Max Et PFCluster
945  photonCand.setPositionAtECALEntrance(math::XYZPointF(PFClusters[highEindex].position()));
946 
947  //Mustache ID variables
948 // Mustache Must;
949 // Must.FillMustacheVar(PFClusters);
950 // int excluded= Must.OutsideMust();
951 // float MustacheEt=Must.MustacheEtOut();
952  //myExtra.setMustache_Et(MustacheEt);
953  //myExtra.setExcludedClust(excluded);
954 // if(fabs(photonCand.eta()<1.4446))
955 // myExtra.setMVAGlobalCorrE(GCorr * PFPhoECorr_);
956 // else if(PFPhoR9_>0.94)
957 // myExtra.setMVAGlobalCorrE(GCorr * PFPhoECorr_);
958 // else myExtra.setMVAGlobalCorrE(GCorr * photonEnergy_);
959 // float Res=EvaluateResMVA(photonCand, PFClusters);
960 // myExtra.SetPFPhotonRes(Res);
961 
962  // Daniele example for mvaValues
963  // do the same for single leg trackRef and convRef
964  for(unsigned int ic = 0; ic < MVA_values.size(); ic++)
965  {
966  myExtra.addSingleLegConvMva(MVA_values[ic]);
967  myExtra.addSingleLegConvTrackRef(singleLegRef[ic]);
968  //cout<<"Single Leg Tracks "<<singleLegRef[ic]->pt()<<" MVA "<<MVA_values[ic]<<endl;
969  }
970  for(unsigned int ic = 0; ic < ConversionsRef_.size(); ic++)
971  {
972  myExtra.addConversionRef(ConversionsRef_[ic]);
973  //cout<<"Conversion Pairs "<<ConversionsRef_[ic]->pairMomentum()<<endl;
974  }
975  egExtra_.push_back(myExtra);
976  egCandidate_.push_back(photonCand);
977  // ... and reset the vector
978  elemsToLock.resize(0);
979  hasConvTrack=false;
980  hasSingleleg=false;
981  } // end of loops over all elements in block
982 
983  return;
984 }
std::vector< reco::PFCandidateEGammaExtra > egExtra_
Definition: PFEGammaAlgo.h:276
type
Definition: HCALResponse.h:21
double mvaValue
Definition: PFEGammaAlgo.h:242
tuple convTracks
Definition: convBrem_cff.py:35
bool EvaluateSingleLegMVA(const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< unsigned int, unsigned int > > fifthStepKfTrack_
Definition: PFEGammaAlgo.h:166
void addSingleLegConvTrackRef(const reco::TrackRef &trackref)
add Single Leg Conversion TrackRef
std::vector< unsigned int > AddFromElectron_
Definition: PFEGammaAlgo.h:270
bool SetLinks(const reco::PFBlockRef &blockRef, AssMap &associatedToGsf_, AssMap &associatedToBrems_, AssMap &associatedToEcal_, std::vector< bool > &active, const reco::Vertex &primaryVertex)
const reco::Vertex * primaryVertex_
Definition: PFEGammaAlgo.h:221
double y() const
y coordinate
Definition: Vertex.h:97
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< unsigned int, Link > LinkData
Definition: PFBlock.h:46
size_type size() const
Definition: OwnVector.h:247
Geom::Theta< T > theta() const
list elements
Definition: asciidump.py:414
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:11
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_
Definition: PFEGammaAlgo.h:173
dictionary map
Definition: Association.py:205
float EvaluateGCorrMVA(reco::PFCandidate, std::vector< reco::CaloCluster >PFClusters)
void AddElectronElements(unsigned int gsf_index, std::vector< unsigned int > &elemsToLock, const reco::PFBlockRef &blockRef, AssMap &associatedToGsf_, AssMap &associatedToBrems_, AssMap &associatedToEcal_)
iterator begin()
Definition: OwnVector.h:227
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
void push_back(D *&d)
Definition: OwnVector.h:273
float EvaluateLCorrMVA(reco::PFClusterRef clusterRef)
T sqrt(T t)
Definition: SSEVec.h:48
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
Definition: Vertex.h:99
void setSuperClusterBoxRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
double x() const
x coordinate
Definition: Vertex.h:95
iterator end()
Definition: OwnVector.h:232
virtual bool trackType(TrackType trType) const
void addSingleLegConvMva(float &mvasingleleg)
add Single Leg Conversion mva
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
float PFPhoECorr_
Definition: PFEGammaAlgo.h:257
std::vector< std::pair< unsigned int, unsigned int > > convGsfTrack_
Definition: PFEGammaAlgo.h:167
void addConversionRef(const reco::ConversionRef &convref)
add Conversions from PF
std::map< unsigned int, std::vector< unsigned int > > AssMap
Definition: PFEGammaAlgo.h:114
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:35
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
verbosityLevel verbosityLevel_
Definition: PFEGammaAlgo.h:213
std::vector< reco::PFCandidate > egCandidate_
Definition: PFEGammaAlgo.h:272
void PFEGammaAlgo::setGBRForest ( const GBRForest LCorrForest,
const GBRForest GCorrForest,
const GBRForest ResForest 
)
inline

Definition at line 69 of file PFEGammaAlgo.h.

References ReaderGC_, ReaderLC_, and ReaderRes_.

73  {
74  ReaderLC_=LCorrForest;
75  ReaderGC_=GCorrForest;
76  ReaderRes_=ResForest;
77  }
const GBRForest * ReaderGC_
Definition: PFEGammaAlgo.h:224
const GBRForest * ReaderRes_
Definition: PFEGammaAlgo.h:225
const GBRForest * ReaderLC_
Definition: PFEGammaAlgo.h:223
void PFEGammaAlgo::setGBRForest ( const GBRForest LCorrForestEB,
const GBRForest LCorrForestEE,
const GBRForest GCorrForestBarrel,
const GBRForest GCorrForestEndcapHr9,
const GBRForest GCorrForestEndcapLr9,
const GBRForest PFEcalResolution 
)
inline

Definition at line 79 of file PFEGammaAlgo.h.

References ReaderGCEB_, ReaderGCEEhR9_, ReaderGCEElR9_, ReaderLCEB_, ReaderLCEE_, and ReaderRes_.

87  {
88  ReaderLCEB_=LCorrForestEB;
89  ReaderLCEE_=LCorrForestEE;
90  ReaderGCEB_=GCorrForestBarrel;
91  ReaderGCEEhR9_=GCorrForestEndcapHr9;
92  ReaderGCEElR9_=GCorrForestEndcapLr9;
93  ReaderRes_=PFEcalResolution;
94  }
const GBRForest * ReaderGCEElR9_
Definition: PFEGammaAlgo.h:231
const GBRForest * ReaderGCEB_
Definition: PFEGammaAlgo.h:229
const GBRForest * ReaderGCEEhR9_
Definition: PFEGammaAlgo.h:230
const GBRForest * ReaderLCEB_
Definition: PFEGammaAlgo.h:227
const GBRForest * ReaderLCEE_
Definition: PFEGammaAlgo.h:228
const GBRForest * ReaderRes_
Definition: PFEGammaAlgo.h:225
bool PFEGammaAlgo::SetLinks ( const reco::PFBlockRef blockRef,
AssMap associatedToGsf_,
AssMap associatedToBrems_,
AssMap associatedToEcal_,
std::vector< bool > &  active,
const reco::Vertex primaryVertex 
)
private

Definition at line 1488 of file PFEGammaAlgo.cc.

References applyCrackCorrections_, reco::PFBlock::associatedElements(), Association::block, reco::PFBlockElement::BREM, reco::PFBlockElementCluster::clusterRef(), coneEcalIsoForEgammaSC_, convGsfTrack_, gather_cfg::cout, reco::PFBlock::dist(), ECAL, reco::PFBlockElement::ECAL, reco::PFBlock::elements(), asciidump::elements, fifthStepKfTrack_, reco::PFBlockElement::GSF, reco::PFBlockElementGsfTrack::GsftrackRef(), reco::PFBlockElement::HCAL, i, cuy::ii, getHLTprescales::index, reco::PFBlockElementBrem::indTrajPoint(), PFMuonAlgo::isMuon(), edm::Ref< C, T, F >::isNonnull(), isPrimaryTrack(), reco::PFBlock::linkData(), reco::PFBlock::LINKTEST_ALL, M_PI, Association::map, nTrackIsoForEgammaSC_, reco::HitPattern::numberOfValidPixelHits(), reco::PFBlockElementBrem::positionAtECALEntrance(), reco::PFBlockElementGsfTrack::positionAtECALEntrance(), reco::PFBlockElementGsfTrack::Pout(), reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, run_regression::ret, funct::sin(), edm::OwnVector< T, P >::size(), mathSSE::sqrt(), sumEtEcalIsoForEgammaSC_barrel_, sumEtEcalIsoForEgammaSC_endcap_, sumPtTrackIsoForEgammaSC_barrel_, sumPtTrackIsoForEgammaSC_endcap_, reco::PFBlockElement::T_FROM_GAMMACONV, thePFEnergyCalibration_, reco::PFBlockElement::TRACK, reco::PFBlockElementTrack::trackRef(), reco::Vertex::tracks_begin(), reco::Vertex::tracks_end(), reco::PFBlockElementGsfTrack::trackType(), useEGammaSupercluster_, and whichTrackAlgo().

Referenced by RunPFEG().

1493  {
1494  unsigned int CutIndex = 100000;
1495  double CutGSFECAL = 10000. ;
1496  // no other cut are not used anymore. We use the default of PFBlockAlgo
1497  //PFEnergyCalibration pfcalib_;
1498  bool DebugSetLinksSummary = false;
1499  bool DebugSetLinksDetailed = false;
1500 
1501  const reco::PFBlock& block = *blockRef;
1503  PFBlock::LinkData linkData = block.linkData();
1504 
1505  bool IsThereAGSFTrack = false;
1506  bool IsThereAGoodGSFTrack = false;
1507 
1508  vector<unsigned int> trackIs(0);
1509  vector<unsigned int> gsfIs(0);
1510  vector<unsigned int> ecalIs(0);
1511 
1512  std::vector<bool> localactive(elements.size(),true);
1513 
1514 
1515  // Save the elements in shorter vectors like in PFAlgo.
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;
1520  PFBlockElement::Type type = elements[iEle].type();
1521  switch( type ) {
1522  case PFBlockElement::TRACK:
1523  // Check if the track is already identified as a muon
1524  thisIsAMuon = PFMuonAlgo::isMuon(elements[iEle]);
1525  // Otherwise store index
1526  if ( !thisIsAMuon && active[iEle] ) {
1527  trackIs.push_back( iEle );
1528  if (DebugSetLinksDetailed)
1529  cout<<"TRACK, stored index, continue "<< iEle << endl;
1530  }
1531  continue;
1532  case PFBlockElement::GSF:
1533  // Check if the track has a KF partner identified as a muon
1534  block.associatedElements( iEle,linkData,
1535  kfElems,
1538  thisIsAMuon = kfElems.size() ?
1539  PFMuonAlgo::isMuon(elements[kfElems.begin()->second]) : false;
1540  // Otherwise store index
1541  if ( !thisIsAMuon && active[iEle] ) {
1542  IsThereAGSFTrack = true;
1543  gsfIs.push_back( iEle );
1544  if (DebugSetLinksDetailed)
1545  cout<<"GSF, stored index, continue "<< iEle << endl;
1546  }
1547  continue;
1548  case PFBlockElement::ECAL:
1549  if ( active[iEle] ) {
1550  ecalIs.push_back( iEle );
1551  if (DebugSetLinksDetailed)
1552  cout<<"ECAL, stored index, continue "<< iEle << endl;
1553  }
1554  continue;
1555  default:
1556  continue;
1557  }
1558  }
1559  // ******************* Start Link *****************************
1560  // Do something only if a gsf track is found in the block
1561  if(IsThereAGSFTrack) {
1562 
1563 
1564  // LocalLock the Elements associated to a Kf tracks and not to a Gsf
1565  // The clusters associated both to a kf track and to a brem tangend
1566  // are then assigned only to the kf track
1567  // Could be improved doing this after.
1568 
1569  // 19 Mar 2010 adding the KF track from Gamma Conv.
1570  // They are linked to the GSF tracks they are not considered
1571  // anymore in the following ecal cluster locking
1572  if (DebugSetLinksDetailed) {
1573  cout<<"#########################################################"<<endl;
1574  cout<<"##### Process Block: #####"<<endl;
1575  cout<<"#########################################################"<<endl;
1576  cout<<block<<endl;
1577  }
1578 
1579 
1580  for(unsigned int iEle=0; iEle<trackIs.size(); iEle++) {
1581  std::multimap<double, unsigned int> gsfElems;
1582  block.associatedElements( trackIs[iEle], linkData,
1583  gsfElems ,
1586  if(gsfElems.size() == 0){
1587  // This means that the considered kf is *not* associated
1588  // to any gsf track
1589  std::multimap<double, unsigned int> ecalKfElems;
1590  block.associatedElements( trackIs[iEle],linkData,
1591  ecalKfElems,
1594  if(ecalKfElems.size() > 0) {
1595  unsigned int ecalKf_index = ecalKfElems.begin()->second;
1596  if(localactive[ecalKf_index]==true) {
1597  // Check if this clusters is however well linked to a primary gsf track
1598  // if this the case the cluster is not locked.
1599 
1600  bool isGsfLinked = false;
1601  for(unsigned int iGsf=0; iGsf<gsfIs.size(); iGsf++) {
1602  // if the ecal cluster is associated contemporary to a KF track
1603  // and to a GSF track from conv, it is assigned to the KF track
1604  // In this way we can loose some cluster but it is safer for double counting.
1605  const reco::PFBlockElementGsfTrack * GsfEl =
1606  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[gsfIs[iGsf]]));
1608 
1609  std::multimap<double, unsigned int> ecalGsfElems;
1610  block.associatedElements( gsfIs[iGsf],linkData,
1611  ecalGsfElems,
1614  if(ecalGsfElems.size() > 0) {
1615  if (ecalGsfElems.begin()->second == ecalKf_index) {
1616  isGsfLinked = true;
1617  }
1618  }
1619  }
1620  if(isGsfLinked == false) {
1621  // add protection against energy loss because
1622  // of the tracking fifth step
1623  const reco::PFBlockElementTrack * kfEle =
1624  dynamic_cast<const reco::PFBlockElementTrack*>((&elements[(trackIs[iEle])]));
1625  reco::TrackRef refKf = kfEle->trackRef();
1626 
1627  int nexhits = refKf->trackerExpectedHitsInner().numberOfLostHits();
1628 
1629  unsigned int Algo = 0;
1630  if (refKf.isNonnull())
1631  Algo = refKf->algo();
1632 
1633  bool trackIsFromPrimaryVertex = false;
1634  for (Vertex::trackRef_iterator trackIt = primaryVertex.tracks_begin(); trackIt != primaryVertex.tracks_end(); ++trackIt) {
1635  if ( (*trackIt).castTo<TrackRef>() == refKf ) {
1636  trackIsFromPrimaryVertex = true;
1637  break;
1638  }
1639  }
1640 
1641  if(Algo < 9 && nexhits == 0 && trackIsFromPrimaryVertex) {
1642  localactive[ecalKf_index] = false;
1643  } else {
1644  fifthStepKfTrack_.push_back(make_pair(ecalKf_index,trackIs[iEle]));
1645  }
1646  }
1647  }
1648  }
1649  } // gsfElems.size()
1650  } // loop on kf tracks
1651 
1652 
1653  // start loop on gsf tracks
1654  for(unsigned int iEle=0; iEle<gsfIs.size(); iEle++) {
1655 
1656  if (!localactive[(gsfIs[iEle])]) continue;
1657 
1658  localactive[gsfIs[iEle]] = false;
1659  bool ClosestEcalWithKf = false;
1660 
1661  if (DebugSetLinksDetailed) cout << " Gsf Index " << gsfIs[iEle] << endl;
1662 
1663  const reco::PFBlockElementGsfTrack * GsfEl =
1664  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[(gsfIs[iEle])]));
1665 
1666  // if GsfTrack fron converted bremsstralung continue
1668  IsThereAGoodGSFTrack = true;
1669  float eta_gsf = GsfEl->positionAtECALEntrance().eta();
1670  float etaOut_gsf = GsfEl->Pout().eta();
1671  float diffOutEcalEta = fabs(eta_gsf-etaOut_gsf);
1672  reco::GsfTrackRef RefGSF = GsfEl->GsftrackRef();
1673  float Pin_gsf = 0.01;
1674  if (RefGSF.isNonnull() )
1675  Pin_gsf = RefGSF->pMode();
1676 
1677 
1678  // Find Associated Kf Track elements and Ecal to KF elements
1679  unsigned int KfGsf_index = CutIndex;
1680  unsigned int KfGsf_secondIndex = CutIndex;
1681  std::multimap<double, unsigned int> kfElems;
1682  block.associatedElements( gsfIs[iEle],linkData,
1683  kfElems,
1686  std::multimap<double, unsigned int> ecalKfElems;
1687  if (kfElems.size() > 0) {
1688  // 19 Mar 2010 now a loop is needed because > 1 KF track could
1689  // be associated to the same GSF track
1690 
1691  for(std::multimap<double, unsigned int>::iterator itkf = kfElems.begin();
1692  itkf != kfElems.end(); ++itkf) {
1693  const reco::PFBlockElementTrack * TrkEl =
1694  dynamic_cast<const reco::PFBlockElementTrack*>((&elements[itkf->second]));
1695 
1696  bool isPrim = isPrimaryTrack(*TrkEl,*GsfEl);
1697  if(!isPrim)
1698  continue;
1699 
1700  if(localactive[itkf->second] == true) {
1701 
1702  KfGsf_index = itkf->second;
1703  localactive[KfGsf_index] = false;
1704  // Find clusters associated to kftrack using linkbyrechit
1705  block.associatedElements( KfGsf_index, linkData,
1706  ecalKfElems ,
1709  }
1710  else {
1711  KfGsf_secondIndex = itkf->second;
1712  }
1713  }
1714  }
1715 
1716  // Find the closest Ecal clusters associated to this Gsf
1717  std::multimap<double, unsigned int> ecalGsfElems;
1718  block.associatedElements( gsfIs[iEle],linkData,
1719  ecalGsfElems,
1722  double ecalGsf_dist = CutGSFECAL;
1723  unsigned int ClosestEcalGsf_index = CutIndex;
1724  if (ecalGsfElems.size() > 0) {
1725  if(localactive[(ecalGsfElems.begin()->second)] == true) {
1726  // check energy compatibility for outer eta != ecal entrance, looping tracks
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());
1731  if(EoPout > 5)
1732  compatibleEPout = false;
1733  }
1734  if(compatibleEPout) {
1735  ClosestEcalGsf_index = ecalGsfElems.begin()->second;
1736  ecalGsf_dist = block.dist(gsfIs[iEle],ClosestEcalGsf_index,
1737  linkData,reco::PFBlock::LINKTEST_ALL);
1738 
1739  // Check that this cluster is not closer to another primary Gsf track
1740 
1741  std::multimap<double, unsigned int> ecalOtherGsfElems;
1742  block.associatedElements( ClosestEcalGsf_index,linkData,
1743  ecalOtherGsfElems,
1746 
1747  if(ecalOtherGsfElems.size()>0) {
1748  // get if it is closed to a conv brem gsf tracks
1749  const reco::PFBlockElementGsfTrack * gsfCheck =
1750  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[ecalOtherGsfElems.begin()->second]));
1751 
1752  if(ecalOtherGsfElems.begin()->second != gsfIs[iEle]&&
1753  gsfCheck->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) == false) {
1754  ecalGsf_dist = CutGSFECAL;
1755  ClosestEcalGsf_index = CutIndex;
1756  }
1757  }
1758  }
1759  // do not lock at the moment we need this for the late brem
1760  }
1761  }
1762  // if any cluster is found with the gsf-ecal link, try with kf-ecal
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,
1767  linkData,reco::PFBlock::LINKTEST_ALL);
1768  ClosestEcalWithKf = true;
1769 
1770  // Check if this cluster is not closer to another Gsf track
1771  std::multimap<double, unsigned int> ecalOtherGsfElems;
1772  block.associatedElements( ClosestEcalGsf_index,linkData,
1773  ecalOtherGsfElems,
1776  if(ecalOtherGsfElems.size() > 0) {
1777  const reco::PFBlockElementGsfTrack * gsfCheck =
1778  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[ecalOtherGsfElems.begin()->second]));
1779 
1780  if(ecalOtherGsfElems.begin()->second != gsfIs[iEle] &&
1781  gsfCheck->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) == false) {
1782  ecalGsf_dist = CutGSFECAL;
1783  ClosestEcalGsf_index = CutIndex;
1784  ClosestEcalWithKf = false;
1785  }
1786  }
1787  }
1788  }
1789 
1790  if (DebugSetLinksDetailed)
1791  cout << " Closest Ecal to the Gsf/Kf: index " << ClosestEcalGsf_index
1792  << " dist " << ecalGsf_dist << endl;
1793 
1794 
1795 
1796  // Find the brems associated to this Gsf
1797  std::multimap<double, unsigned int> bremElems;
1798  block.associatedElements( gsfIs[iEle],linkData,
1799  bremElems,
1802 
1803 
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;
1812 
1813 
1814  // Find the ecal clusters associated to the brems
1815  std::multimap<double, unsigned int> ecalBremsElems;
1816 
1817  block.associatedElements( brem_index, linkData,
1818  ecalBremsElems,
1821 
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;
1826 
1827  //to be changed, using the distance
1828  float ecalBrem_dist = block.dist(brem_index,ecalBrem_index,
1829  linkData,reco::PFBlock::LINKTEST_ALL);
1830 
1831 
1832  if (ecalBrem_index == ClosestEcalGsf_index && (ecalBrem_dist + 0.0012) > ecalGsf_dist) continue;
1833 
1834  // Find the closest brem
1835  std::multimap<double, unsigned int> sortedBremElems;
1836  block.associatedElements( ecalBrem_index,linkData,
1837  sortedBremElems,
1840  // check that this brem is that one coming from the same *primary* gsf
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;
1847  block.associatedElements( temp_sortedBrem_index,linkData,
1848  sortedGsfElems,
1851  bool enteredInPrimaryGsf = false;
1852  for (std::multimap<double, unsigned int>::iterator igs = sortedGsfElems.begin();
1853  igs != sortedGsfElems.end();igs++) {
1854  const reco::PFBlockElementGsfTrack * gsfCheck =
1855  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[igs->second]));
1856 
1857  if(gsfCheck->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) == false) {
1858  if(igs->second == gsfIs[iEle]) {
1859  isGoodBrem = true;
1860  sortedBrem_index = temp_sortedBrem_index;
1861  }
1862  enteredInPrimaryGsf = true;
1863  break;
1864  }
1865  }
1866  if(enteredInPrimaryGsf)
1867  break;
1868  }
1869 
1870  if(isGoodBrem) {
1871 
1872  // Check that this cluster is not closer to another Gsf Track
1873  // The check is not performed on KF track because the ecal clusters are aready locked.
1874  std::multimap<double, unsigned int> ecalOtherGsfElems;
1875  block.associatedElements( ecalBrem_index,linkData,
1876  ecalOtherGsfElems,
1879  if (ecalOtherGsfElems.size() > 0) {
1880  const reco::PFBlockElementGsfTrack * gsfCheck =
1881  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[ecalOtherGsfElems.begin()->second]));
1882  if(ecalOtherGsfElems.begin()->second != gsfIs[iEle] &&
1883  gsfCheck->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) == false) {
1884  continue;
1885  }
1886  }
1887 
1888  const reco::PFBlockElementBrem * BremEl =
1889  dynamic_cast<const reco::PFBlockElementBrem*>((&elements[sortedBrem_index]));
1890 
1891  reco::PFClusterRef clusterRef =
1892  elements[ecalBrem_index].clusterRef();
1893 
1894 
1895  float sortedBremEcal_deta = fabs(clusterRef->position().eta() - BremEl->positionAtECALEntrance().eta());
1896  // Triangular cut on plan chi2:deta -> OLD
1897  //if((0.0075*sortedBremEcal_chi2 + 100.*sortedBremEcal_deta -1.5) < 0.) {
1898  if(sortedBremEcal_deta < 0.015) {
1899 
1900  cleanedEcalBremElems.insert(pair<unsigned int,unsigned int>(sortedBrem_index,ecalBrem_index));
1901 
1902  unsigned int BremTrajP = BremEl->indTrajPoint();
1903  if (BremTrajP > latestBrem_trajP) {
1904  latestBrem_trajP = BremTrajP;
1905  latestBrem_index = sortedBrem_index;
1906  }
1907  if (DebugSetLinksDetailed)
1908  cout << " brem Index " << sortedBrem_index
1909  << " associated cluster " << ecalBrem_index << " BremTrajP " << BremTrajP <<endl;
1910 
1911  // > 1 ecal clusters could be associated to the same brem twice: allowed N-1 link.
1912  // But the brem need to be stored once.
1913  // locallock the brem and the ecal clusters
1914  localactive[ecalBrem_index] = false; // the cluster
1915  bool alreadyfound = false;
1916  for(unsigned int ii=0;ii<keyBremIndex.size();ii++) {
1917  if (sortedBrem_index == keyBremIndex[ii]) alreadyfound = true;
1918  }
1919  if (alreadyfound == false) {
1920  keyBremIndex.push_back(sortedBrem_index);
1921  localactive[sortedBrem_index] = false; // the brem
1922  }
1923  }
1924  }
1925  }
1926  }
1927 
1928 
1929  // Find Possible Extra Cluster associated to the gsf/kf
1930  vector<unsigned int> GsfElemIndex(0);
1931  vector<unsigned int> EcalIndex(0);
1932 
1933  // locallock the ecal cluster associated to the gsf
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]) {
1940  // Check that this cluster is not closer to another Gsf Track
1941  std::multimap<double, unsigned int> ecalOtherGsfElems;
1942  block.associatedElements( ii->second,linkData,
1943  ecalOtherGsfElems,
1946  if(ecalOtherGsfElems.size()) {
1947  if(ecalOtherGsfElems.begin()->second != gsfIs[iEle]) continue;
1948  }
1949 
1950  // get the cluster only if the deta (ecal-gsf) < 0.05
1951  reco::PFClusterRef clusterRef = elements[(ii->second)].clusterRef();
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;
1958  }
1959  }
1960  }
1961  }
1962 
1963  //Add the possibility to link other ecal clusters from kf.
1964 
1965 // for (std::multimap<double, unsigned int>::iterator ii = ecalKfElems.begin();
1966 // ii != ecalKfElems.end();ii++) {
1967 // if(localactive[ii->second]) {
1968 // // Check that this cluster is not closer to another Gsf Track
1969 // std::multimap<double, unsigned int> ecalOtherGsfElems;
1970 // block.associatedElements( ii->second,linkData,
1971 // ecalOtherGsfElems,
1972 // reco::PFBlockElement::GSF,
1973 // reco::PFBlock::LINKTEST_CHI2);
1974 // if(ecalOtherGsfElems.size()) {
1975 // if(ecalOtherGsfElems.begin()->second != gsfIs[iEle]) continue;
1976 // }
1977 // GsfElemIndex.push_back(ii->second);
1978 // reco::PFClusterRef clusterRef = elements[(ii->second)].clusterRef();
1979 // float etacl = clusterRef->eta();
1980 // if( fabs(eta_gsf-etacl) < 0.05) {
1981 // localactive[ii->second] = false;
1982 // if (DebugSetLinksDetailed)
1983 // cout << " ExtraCluster From KF " << ii->second << endl;
1984 // }
1985 // }
1986 // }
1987 
1988  //****************** Fill Maps *************************
1989 
1990  // The GsfMap
1991 
1992  // if any clusters have been associated to the gsf track
1993  // use the Ecal clusters associated to the latest brem and associate it to the gsf
1994  if(GsfElemIndex.size() == 0){
1995  if(latestBrem_index < CutIndex) {
1996  unsigned int ckey = cleanedEcalBremElems.count(latestBrem_index);
1997  if(ckey == 1) {
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;
2005  }
2006  else{
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;
2016  }
2017  }
2018  // erase the brem.
2019  unsigned int elToErase = 0;
2020  for(unsigned int i = 0; i<keyBremIndex.size();i++) {
2021  if(latestBrem_index == keyBremIndex[i]) {
2022  elToErase = i;
2023  }
2024  }
2025  keyBremIndex.erase(keyBremIndex.begin()+elToErase);
2026  }
2027  }
2028 
2029  // Get Extra Clusters from converted brem gsf tracks. The locallock method
2030  // tells me if the ecal cluster has been already assigned to the primary
2031  // gsf track or to a brem
2032 
2033  for(unsigned int iConv=0; iConv<gsfIs.size(); iConv++) {
2034  if(iConv != iEle) {
2035 
2036  const reco::PFBlockElementGsfTrack * gsfConv =
2037  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[(gsfIs[iConv])]));
2038 
2039  // look at only to secondary gsf tracks
2041  if (DebugSetLinksDetailed)
2042  cout << " PFElectronAlgo:: I'm running on convGsfBrem " << endl;
2043  // check if they are linked to the primary
2044  float conv_dist = block.dist(gsfIs[iConv],gsfIs[iEle],
2045  linkData,reco::PFBlock::LINKTEST_ALL);
2046  if(conv_dist > 0.) {
2047  // find the closest ecal cluster associated to conversions
2048 
2049  std::multimap<double, unsigned int> ecalConvElems;
2050  block.associatedElements( gsfIs[iConv],linkData,
2051  ecalConvElems,
2054  if(ecalConvElems.size() > 0) {
2055  // the ecal cluster is still active?
2056  if(localactive[(ecalConvElems.begin()->second)] == true) {
2057  if (DebugSetLinksDetailed)
2058  cout << " PFElectronAlgo:: convGsfBrem has a ECAL cluster linked and free" << endl;
2059  // Check that this cluster is not closer to another primary Gsf track
2060  std::multimap<double, unsigned int> ecalOtherGsfPrimElems;
2061  block.associatedElements( ecalConvElems.begin()->second,linkData,
2062  ecalOtherGsfPrimElems,
2065  if(ecalOtherGsfPrimElems.size()>0) {
2066  unsigned int gsfprimcheck_index = ecalOtherGsfPrimElems.begin()->second;
2067  const reco::PFBlockElementGsfTrack * gsfCheck =
2068  dynamic_cast<const reco::PFBlockElementGsfTrack*>((&elements[gsfprimcheck_index]));
2069  if(gsfCheck->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) == false) continue;
2070 
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;
2076 
2077  GsfElemIndex.push_back(ecalConvElems.begin()->second);
2078  convGsfTrack_.push_back(make_pair(ecalConvElems.begin()->second,gsfIs[iConv]));
2079  localactive[ecalConvElems.begin()->second] = false;
2080 
2081  }
2082  }
2083  }
2084  }
2085  }
2086  }
2087  }
2088 
2089 
2090 
2091  EcalIndex.insert(EcalIndex.end(),GsfElemIndex.begin(),GsfElemIndex.end());
2092 
2093 
2094 
2095  // The BremMap
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);
2100  if(ckey == 1) {
2101  unsigned int temp_cal =
2102  cleanedEcalBremElems.find(ikey)->second;
2103  BremElemIndex.push_back(temp_cal);
2104  }
2105  else{
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);
2111  }
2112  }
2113  EcalIndex.insert(EcalIndex.end(),BremElemIndex.begin(),BremElemIndex.end());
2114  associatedToBrems_.insert(pair<unsigned int,vector<unsigned int> >(ikey,BremElemIndex));
2115  }
2116 
2117 
2118  // 19 Mar 2010: add KF and ECAL elements from converted brem photons
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) {
2124  const reco::PFBlockElementTrack * TrkEl =
2125  dynamic_cast<const reco::PFBlockElementTrack*>((&elements[itkf->second]));
2126  bool isPrim = isPrimaryTrack(*TrkEl,*GsfEl);
2127 
2128  if(!isPrim) {
2129 
2130  // search for linked ECAL clusters
2131  std::multimap<double, unsigned int> ecalConvElems;
2132  block.associatedElements( itkf->second,linkData,
2133  ecalConvElems,
2136  if(ecalConvElems.size() > 0) {
2137  // Further Cleaning: DANIELE This could be improved!
2138  TrackRef trkRef = TrkEl->trackRef();
2139  // iter0, iter1, iter2, iter3 = Algo < 3
2140  unsigned int Algo = whichTrackAlgo(trkRef);
2141 
2142  float secpin = trkRef->p();
2143 
2144  const reco::PFBlockElementCluster * clust =
2145  dynamic_cast<const reco::PFBlockElementCluster*>((&elements[(ecalConvElems.begin()->second)]));
2146  float eneclust =clust->clusterRef()->energy();
2147 
2148  //1) ******* Reject secondary KF tracks linked to also an HCAL cluster with H/(E+H) > 0.1
2149  // This is applied also to KF linked to locked ECAL cluster
2150  // NOTE: trusting the H/(E+H) and not the conv brem selection increse the number
2151  // of charged hadrons around the electron. DANIELE? re-think about this.
2152  std::multimap<double, unsigned int> hcalConvElems;
2153  block.associatedElements( itkf->second,linkData,
2154  hcalConvElems,
2157 
2158  bool isHoHE = false;
2159  bool isHoE = false;
2160  bool isPoHE = false;
2161 
2162  float enehcalclust = -1;
2163  if(hcalConvElems.size() > 0) {
2164  const reco::PFBlockElementCluster * clusthcal =
2165  dynamic_cast<const reco::PFBlockElementCluster*>((&elements[(hcalConvElems.begin()->second)]));
2166  enehcalclust =clusthcal->clusterRef()->energy();
2167  // NOTE: DANIELE? Are you sure you want to use the Algo type here?
2168  if( (enehcalclust / (enehcalclust+eneclust) ) > 0.1 && Algo < 3) {
2169  isHoHE = true;
2170  if(enehcalclust > eneclust)
2171  isHoE = true;
2172  if(secpin > (enehcalclust+eneclust) )
2173  isPoHE = true;
2174  }
2175  }
2176 
2177 
2178  if(localactive[(ecalConvElems.begin()->second)] == false) {
2179 
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;
2190  continue;
2191  }
2192 
2193  // check if this track has been alread assigned to an ECAL cluster
2194  for(unsigned int iecal =0; iecal < EcalIndex.size(); iecal++) {
2195  // in case this track is already assigned to a locked ECAL cluster
2196  // the secondary kf track is also saved for further lock
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);
2201  }
2202  }
2203  }
2204  else{
2205  // ECAL cluster free
2206 
2207  //
2208  if(isHoHE){
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;
2218  continue;
2219  }
2220 
2221  // check that this cluster is not cluser to another KF track (primary)
2222  std::multimap<double, unsigned int> ecalOtherKFPrimElems;
2223  block.associatedElements( ecalConvElems.begin()->second,linkData,
2224  ecalOtherKFPrimElems,
2227  if(ecalOtherKFPrimElems.size() > 0) {
2228 
2229  // check that this ECAL clusters is the best associated to at least one of the KF tracks
2230  // linked to the considered GSF track
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) {
2235  isFromGSF = true;
2236  break;
2237  }
2238  }
2239  if(isFromGSF){
2240 
2241  // Further Cleaning: DANIELE This could be improved!
2242 
2243 
2244  float Epin = eneclust/secpin;
2245 
2246  // compute the pfsupercluster energy till now
2247  float totenergy = 0.;
2248  for(unsigned int ikeyecal = 0;
2249  ikeyecal<EcalIndex.size(); ikeyecal++){
2250  // EcalIndex can have the same cluster save twice (because of the late brem cluster).
2251  bool foundcluster = false;
2252  if(ikeyecal > 0) {
2253  for(unsigned int i2 = 0; i2<ikeyecal-1; i2++) {
2254  if(EcalIndex[ikeyecal] == EcalIndex[i2])
2255  foundcluster = true;
2256  }
2257  }
2258  if(foundcluster) continue;
2259  const reco::PFBlockElementCluster * clusasso =
2260  dynamic_cast<const reco::PFBlockElementCluster*>((&elements[(EcalIndex[ikeyecal])]));
2261  totenergy += clusasso->clusterRef()->energy();
2262  }
2263 
2264  // Further Cleaning: DANIELE This could be improved!
2265  //2) ***** Do not consider secondary tracks if the GSF and brems have failed in finding ECAL clusters
2266  if(totenergy == 0.) {
2267  if (DebugSetLinksDetailed)
2268  cout << "PFElectronAlgo:: REJECTED_NULLTOT totenergy " << totenergy << endl;
2269  continue;
2270  }
2271 
2272  //3) ****** Reject secondary KF tracks that have an high E/secPin and that make worse the Etot/pin
2273  if(Epin > 3) {
2274  double res_before = fabs((totenergy-Pin_gsf)/Pin_gsf);
2275  double res_after = fabs(((totenergy+eneclust)-Pin_gsf)/Pin_gsf);
2276 
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;
2281  continue;
2282  }
2283  }
2284 
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;
2292  }
2293  }
2294  }
2295  }
2296  }
2297  }
2298  }
2299 
2300  // 4May import EG supercluster
2301  if(EcalIndex.size() > 0 && useEGammaSupercluster_) {
2302  double sumEtEcalInTheCone = 0.;
2303 
2304  // Position of the first cluster
2305  const reco::PFBlockElementCluster * clust =
2306  dynamic_cast<const reco::PFBlockElementCluster*>((&elements[EcalIndex[0]]));
2307  double PhiFC = clust->clusterRef()->position().Phi();
2308  double EtaFC = clust->clusterRef()->position().Eta();
2309 
2310  // Compute ECAL isolation ->
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;
2317  }
2318 
2319  // -> only for clusters not already in the PFSCCluster
2320  if(foundcluster == false) {
2321  const reco::PFBlockElementCluster * clustExt =
2322  dynamic_cast<const reco::PFBlockElementCluster*>((&elements[ecalIs[iEcal]]));
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);
2334 
2335  //Jurassic veto in deta
2336  if(fabs(deta_clust) > 0.05 && DR < coneEcalIsoForEgammaSC_) {
2337  vector<double> ps1Ene(0);
2338  vector<double> ps2Ene(0);
2339  double ps1,ps2;
2340  ps1=ps2=0.;
2341  double EE_calib = thePFEnergyCalibration_->energyEm(*(clustExt->clusterRef()),ps1Ene,ps2Ene,ps1,ps2,applyCrackCorrections_);
2342  double ET_calib = EE_calib*sin(theta_clust);
2343  sumEtEcalInTheCone += ET_calib;
2344  }
2345  }
2346  } //EndLoop Additional ECAL clusters in the block
2347 
2348  // Compute track isolation: number of tracks && sumPt
2349  unsigned int sumNTracksInTheCone = 0;
2350  double sumPtTracksInTheCone = 0.;
2351  for(unsigned int iTrack=0; iTrack<trackIs.size(); iTrack++) {
2352  // the track from the electron are already locked at this stage
2353  if(localactive[(trackIs[iTrack])]==true) {
2354  const reco::PFBlockElementTrack * kfEle =
2355  dynamic_cast<const reco::PFBlockElementTrack*>((&elements[(trackIs[iTrack])]));
2356  reco::TrackRef trkref = kfEle->trackRef();
2357  if (trkref.isNonnull()) {
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+
2365  dphi_trk*dphi_trk);
2366 
2367  reco::HitPattern kfHitPattern = trkref->hitPattern();
2368  int NValPixelHit = kfHitPattern.numberOfValidPixelHits();
2369 
2370  if(DR < coneTrackIsoForEgammaSC_ && NValPixelHit >=3) {
2371  sumNTracksInTheCone++;
2372  sumPtTracksInTheCone+=trkref->pt();
2373  }
2374  }
2375  }
2376  }
2377 
2378 
2379  bool isBarrelIsolated = false;
2380  if( fabs(EtaFC < 1.478) &&
2381  (sumEtEcalInTheCone < sumEtEcalIsoForEgammaSC_barrel_ &&
2382  (sumNTracksInTheCone < nTrackIsoForEgammaSC_ || sumPtTracksInTheCone < sumPtTrackIsoForEgammaSC_barrel_)))
2383  isBarrelIsolated = true;
2384 
2385 
2386  bool isEndcapIsolated = false;
2387  if( fabs(EtaFC >= 1.478) &&
2388  (sumEtEcalInTheCone < sumEtEcalIsoForEgammaSC_endcap_ &&
2389  (sumNTracksInTheCone < nTrackIsoForEgammaSC_ || sumPtTracksInTheCone < sumPtTrackIsoForEgammaSC_endcap_)))
2390  isEndcapIsolated = true;
2391 
2392 
2393  // only print out
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;
2400  }
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;
2406  }
2407  }
2408 
2409 
2410 
2411 
2412  if(isBarrelIsolated || isEndcapIsolated ) {
2413 
2414 
2415  // Compute TotEnergy
2416  double totenergy = 0.;
2417  for(unsigned int ikeyecal = 0;
2418  ikeyecal<EcalIndex.size(); ikeyecal++){
2419  // EcalIndex can have the same cluster save twice (because of the late brem cluster).
2420  bool foundcluster = false;
2421  if(ikeyecal > 0) {
2422  for(unsigned int i2 = 0; i2<ikeyecal-1; i2++) {
2423  if(EcalIndex[ikeyecal] == EcalIndex[i2])
2424  foundcluster = true;;
2425  }
2426  }
2427  if(foundcluster) continue;
2428  const reco::PFBlockElementCluster * clusasso =
2429  dynamic_cast<const reco::PFBlockElementCluster*>((&elements[(EcalIndex[ikeyecal])]));
2430  totenergy += clusasso->clusterRef()->energy();
2431  }
2432  // End copute TotEnergy
2433 
2434 
2435  // Find extra cluster from e/g importing
2436  for(unsigned int ikeyecal = 0;
2437  ikeyecal<EcalIndex.size(); ikeyecal++){
2438  // EcalIndex can have the same cluster save twice (because of the late brem cluster).
2439  bool foundcluster = false;
2440  if(ikeyecal > 0) {
2441  for(unsigned int i2 = 0; i2<ikeyecal-1; i2++) {
2442  if(EcalIndex[ikeyecal] == EcalIndex[i2])
2443  foundcluster = true;
2444  }
2445  }
2446  if(foundcluster) continue;
2447 
2448 
2449  std::multimap<double, unsigned int> ecalFromSuperClusterElems;
2450  block.associatedElements( EcalIndex[ikeyecal],linkData,
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) {
2458  continue;
2459  }
2460 
2461  std::multimap<double, unsigned int> ecalOtherKFPrimElems;
2462  block.associatedElements( itsc->second,linkData,
2463  ecalOtherKFPrimElems,
2464  reco::PFBlockElement::TRACK,
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;
2470  continue;
2471  }
2472  }
2473  bool isInTheEtaRange = false;
2474  const reco::PFBlockElementCluster * clustToAdd =
2475  dynamic_cast<const reco::PFBlockElementCluster*>((&elements[itsc->second]));
2476  double deta_clustToAdd = clustToAdd->clusterRef()->position().Eta() - EtaFC;
2477  double ene_clustToAdd = clustToAdd->clusterRef()->energy();
2478 
2479  if(fabs(deta_clustToAdd) < 0.05)
2480  isInTheEtaRange = true;
2481 
2482  // check for both KF and GSF
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;
2488 
2489  if(KfGsf_index < CutIndex) {
2490  //GSF
2491  double res_before_gsf = fabs((totenergy-Pin_gsf)/Pin_gsf);
2492  double res_after_gsf = fabs(((totenergy+ene_clustToAdd)-Pin_gsf)/Pin_gsf);
2493 
2494  //KF
2495  const reco::PFBlockElementTrack * trackEl =
2496  dynamic_cast<const reco::PFBlockElementTrack*>((&elements[KfGsf_index]));
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);
2500 
2501  // The new cluster improve both the E/pin?
2502  if(res_after_gsf < res_before_gsf && res_after_kf < res_before_kf ) {
2503  isBetterEpin = true;
2504  }
2505  else {
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;
2514  }
2515  }
2516  }
2517 
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;
2524  }
2525  }
2526  }
2527  }
2528  } // END ISOLATION IF
2529  }
2530 
2531 
2532  if(KfGsf_index < CutIndex)
2533  GsfElemIndex.push_back(KfGsf_index);
2534  else if(KfGsf_secondIndex < CutIndex)
2535  GsfElemIndex.push_back(KfGsf_secondIndex);
2536 
2537  // insert the secondary KF tracks
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));
2541 
2542  // The EcalMap
2543  for(unsigned int ikeyecal = 0;
2544  ikeyecal<EcalIndex.size(); ikeyecal++){
2545 
2546 
2547  vector<unsigned int> EcalElemsIndex(0);
2548 
2549  std::multimap<double, unsigned int> PS1Elems;
2550  block.associatedElements( EcalIndex[ikeyecal],linkData,
2551  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) {
2558 
2559  // Check that this cluster is not closer to another ECAL cluster
2560  std::multimap<double, unsigned> sortedECAL;
2561  block.associatedElements( index, linkData,
2562  sortedECAL,
2565  unsigned jEcal = sortedECAL.begin()->second;
2566  if ( jEcal != EcalIndex[ikeyecal]) continue;
2567 
2568 
2569  EcalElemsIndex.push_back(index);
2570  localactive[index] = false;
2571  }
2572  }
2573 
2574  std::multimap<double, unsigned int> PS2Elems;
2575  block.associatedElements( EcalIndex[ikeyecal],linkData,
2576  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) {
2583  // Check that this cluster is not closer to another ECAL cluster
2584  std::multimap<double, unsigned> sortedECAL;
2585  block.associatedElements( index, linkData,
2586  sortedECAL,
2589  unsigned jEcal = sortedECAL.begin()->second;
2590  if ( jEcal != EcalIndex[ikeyecal]) continue;
2591 
2592  EcalElemsIndex.push_back(index);
2593  localactive[index] = false;
2594  }
2595  }
2596  if(ikeyecal == 0) {
2597  // The first cluster is that one coming from the Gsf.
2598  // Only for this one is found the HCAL cluster using the Track-HCAL link
2599  // and not the Ecal-Hcal not well tested yet.
2600  std::multimap<double, unsigned int> hcalGsfElems;
2601  block.associatedElements( gsfIs[iEle],linkData,
2602  hcalGsfElems,
2605  for( std::multimap<double, unsigned int>::iterator it = hcalGsfElems.begin();
2606  it != hcalGsfElems.end();it++) {
2607  unsigned int index = it->second;
2608  // if(localactive[index] == true) {
2609 
2610  // Check that this cluster is not closer to another GSF
2611  // remove in high energetic jets this is dangerous.
2612 // std::multimap<double, unsigned> sortedGsf;
2613 // block.associatedElements( index, linkData,
2614 // sortedGsf,
2615 // reco::PFBlockElement::GSF,
2616 // reco::PFBlock::LINKTEST_ALL );
2617 // unsigned jGsf = sortedGsf.begin()->second;
2618 // if ( jGsf != gsfIs[iEle]) continue;
2619 
2620  EcalElemsIndex.push_back(index);
2621  localactive[index] = false;
2622 
2623  // }
2624  }
2625  // if the closest ecal cluster has been link with the KF, check KF - HCAL link
2626  if(hcalGsfElems.size() == 0 && ClosestEcalWithKf == true) {
2627  std::multimap<double, unsigned int> hcalKfElems;
2628  block.associatedElements( KfGsf_index,linkData,
2629  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) {
2636 
2637  // Check that this cluster is not closer to another KF
2638  std::multimap<double, unsigned> sortedKf;
2639  block.associatedElements( index, linkData,
2640  sortedKf,
2641  reco::PFBlockElement::TRACK,
2643  unsigned jKf = sortedKf.begin()->second;
2644  if ( jKf != KfGsf_index) continue;
2645  EcalElemsIndex.push_back(index);
2646  localactive[index] = false;
2647  }
2648  }
2649  }
2650  // Find Other Primary Tracks Associated to the same Gsf Clusters
2651  std::multimap<double, unsigned int> kfEtraElems;
2652  block.associatedElements( EcalIndex[ikeyecal],linkData,
2653  kfEtraElems,
2654  reco::PFBlockElement::TRACK,
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;
2660 
2661  // 19 Mar 2010 do not consider here tracks from gamma conv
2662  // const reco::PFBlockElementTrack * kfTk =
2663  // dynamic_cast<const reco::PFBlockElementTrack*>((&elements[index]));
2664  // DANIELE ? It is not need because of the local locking
2665  // if(kfTk->isLinkedToDisplacedVertex()) continue;
2666 
2667  bool thisIsAMuon = false;
2668  thisIsAMuon = PFMuonAlgo::isMuon(elements[index]);
2669  if (DebugSetLinksDetailed && thisIsAMuon)
2670  cout << " This is a Muon: index " << index << endl;
2671  if(localactive[index] == true && !thisIsAMuon) {
2672  if(index != KfGsf_index) {
2673  // Check that this track is not closer to another ECAL cluster
2674  // Not Sure here I need this step
2675  std::multimap<double, unsigned> sortedECAL;
2676  block.associatedElements( index, linkData,
2677  sortedECAL,
2680  unsigned jEcal = sortedECAL.begin()->second;
2681  if ( jEcal != EcalIndex[ikeyecal]) continue;
2682  EcalElemsIndex.push_back(index);
2683  localactive[index] = false;
2684  }
2685  }
2686  }
2687  }
2688 
2689  }
2690  associatedToEcal_.insert(pair<unsigned int,vector<unsigned int> >(EcalIndex[ikeyecal],EcalElemsIndex));
2691  }
2692  }// end type GSF
2693  } // endis there a gsf track
2694 
2695  // ******************* End Link *****************************
2696 
2697  //
2698  // Below is only for debugging printout
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++) {
2704 
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++) {
2708  PFBlockElement::Type type = elements[eleasso[i]].type();
2709  if(type == reco::PFBlockElement::BREM) {
2710  if (DebugSetLinksSummary)
2711  cout << " AssoGsfElements BREM " << eleasso[i] << endl;
2712  }
2713  else if(type == reco::PFBlockElement::ECAL) {
2714  if (DebugSetLinksSummary)
2715  cout << " AssoGsfElements ECAL " << eleasso[i] << endl;
2716  }
2717  else if(type == reco::PFBlockElement::TRACK) {
2718  if (DebugSetLinksSummary)
2719  cout << " AssoGsfElements KF " << eleasso[i] << endl;
2720  }
2721  else {
2722  if (DebugSetLinksSummary)
2723  cout << " AssoGsfElements ????? " << eleasso[i] << endl;
2724  }
2725  }
2726  }
2727 
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++) {
2733  PFBlockElement::Type type = elements[eleasso[i]].type();
2734  if(type == reco::PFBlockElement::ECAL) {
2735  if (DebugSetLinksSummary)
2736  cout << " AssoBremElements ECAL " << eleasso[i] << endl;
2737  }
2738  else {
2739  if (DebugSetLinksSummary)
2740  cout << " AssoBremElements ????? " << eleasso[i] << endl;
2741  }
2742  }
2743  }
2744 
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++) {
2750  PFBlockElement::Type type = elements[eleasso[i]].type();
2751  if(type == reco::PFBlockElement::PS1) {
2752  if (DebugSetLinksSummary)
2753  cout << " AssoECALElements PS1 " << eleasso[i] << endl;
2754  }
2755  else if(type == reco::PFBlockElement::PS2) {
2756  if (DebugSetLinksSummary)
2757  cout << " AssoECALElements PS2 " << eleasso[i] << endl;
2758  }
2759  else if(type == reco::PFBlockElement::HCAL) {
2760  if (DebugSetLinksSummary)
2761  cout << " AssoECALElements HCAL " << eleasso[i] << endl;
2762  }
2763  else {
2764  if (DebugSetLinksSummary)
2765  cout << " AssoHCALElements ????? " << eleasso[i] << endl;
2766  }
2767  }
2768  }
2769  if (DebugSetLinksSummary)
2770  cout << "-- End Summary --" << endl;
2771  }
2772 
2773  }
2774  // EndPrintOut
2775  return IsThereAGoodGSFTrack;
2776 }
type
Definition: HCALResponse.h:21
const math::XYZTLorentzVector & Pout() const
const math::XYZPointF & positionAtECALEntrance() const
int i
Definition: DBlmapReader.cc:9
unsigned int whichTrackAlgo(const reco::TrackRef &trackRef)
bool useEGammaSupercluster_
Definition: PFEGammaAlgo.h:177
std::vector< std::pair< unsigned int, unsigned int > > fifthStepKfTrack_
Definition: PFEGammaAlgo.h:166
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:45
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:153
bool applyCrackCorrections_
Definition: PFEGammaAlgo.h:174
PFClusterRef clusterRef() const
const math::XYZPointF & positionAtECALEntrance() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< unsigned int, Link > LinkData
Definition: PFBlock.h:46
size_type size() const
Definition: OwnVector.h:247
bool isPrimaryTrack(const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
list elements
Definition: asciidump.py:414
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
const LinkData & linkData() const
Definition: PFBlock.h:112
unsigned int indTrajPoint() const
int ii
Definition: cuy.py:588
boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_
Definition: PFEGammaAlgo.h:173
dictionary map
Definition: Association.py:205
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
double sumPtTrackIsoForEgammaSC_endcap_
Definition: PFEGammaAlgo.h:182
T sqrt(T t)
Definition: SSEVec.h:48
reco::GsfTrackRef GsftrackRef() const
unsigned int nTrackIsoForEgammaSC_
Definition: PFEGammaAlgo.h:183
virtual bool trackType(TrackType trType) const
block
Formating index page&#39;s pieces.
Definition: Association.py:232
double sumPtTrackIsoForEgammaSC_barrel_
Definition: PFEGammaAlgo.h:181
#define M_PI
Definition: BFit3D.cc:3
void associatedElements(unsigned i, const LinkData &linkData, std::multimap< double, unsigned > &sortedAssociates, reco::PFBlockElement::Type type=PFBlockElement::NONE, LinkTest test=LINKTEST_RECHIT) const
Definition: PFBlock.cc:75
double coneEcalIsoForEgammaSC_
Definition: PFEGammaAlgo.h:180
std::vector< std::pair< unsigned int, unsigned int > > convGsfTrack_
Definition: PFEGammaAlgo.h:167
reco::TrackRef trackRef() const
double sumEtEcalIsoForEgammaSC_endcap_
Definition: PFEGammaAlgo.h:179
double sumEtEcalIsoForEgammaSC_barrel_
Definition: PFEGammaAlgo.h:178
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:38
int numberOfValidPixelHits() const
Definition: HitPattern.h:582
tuple cout
Definition: gather_cfg.py:121
double dist(unsigned ie1, unsigned ie2, const LinkData &linkData, LinkTest test) const
Definition: PFBlock.h:94
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:40
Definition: fakeMenu.h:4
Block of elements.
Definition: PFBlock.h:30
void PFEGammaAlgo::setnPU ( int  nVtx)
inline

Definition at line 95 of file PFEGammaAlgo.h.

References nVtx_.

95  {
96  nVtx_=nVtx;
97  }
void PFEGammaAlgo::setPhotonPrimaryVtx ( const reco::Vertex primary)
inline

Definition at line 98 of file PFEGammaAlgo.h.

References primaryVertex_.

98  {
99  primaryVertex_ = & primary;
100  }
const reco::Vertex * primaryVertex_
Definition: PFEGammaAlgo.h:221
unsigned int PFEGammaAlgo::whichTrackAlgo ( const reco::TrackRef trackRef)
private

Definition at line 2778 of file PFEGammaAlgo.cc.

Referenced by SetLinks().

2778  {
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:
2785  Algo = 0;
2786  break;
2787  case TrackBase::iter3:
2788  Algo = 1;
2789  break;
2790  case TrackBase::iter4:
2791  Algo = 2;
2792  break;
2793  case TrackBase::iter5:
2794  Algo = 3;
2795  break;
2796  case TrackBase::iter6:
2797  Algo = 4;
2798  break;
2799  default:
2800  Algo = 5;
2801  break;
2802  }
2803  return Algo;
2804 }
Definition: fakeMenu.h:4

Member Data Documentation

std::vector<unsigned int> PFEGammaAlgo::AddFromElectron_
private

Definition at line 270 of file PFEGammaAlgo.h.

Referenced by EarlyConversion(), and RunPFEG().

bool PFEGammaAlgo::applyCrackCorrections_
private

Definition at line 174 of file PFEGammaAlgo.h.

Referenced by AddElectronCandidate(), and SetLinks().

float PFEGammaAlgo::chi2
private

Definition at line 241 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), and PFEGammaAlgo().

float PFEGammaAlgo::chi2_gsf
private

Definition at line 193 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::chi2_kf
private

Definition at line 193 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::Clus5x5ratio_
private

Definition at line 247 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::ClusEta_
private

Definition at line 247 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::ClusPhi_
private

Definition at line 247 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::ClusR9_
private

Definition at line 247 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

double PFEGammaAlgo::coneEcalIsoForEgammaSC_
private

Definition at line 180 of file PFEGammaAlgo.h.

Referenced by SetLinks().

double PFEGammaAlgo::coneTrackIsoForEgammaSC_
private

Definition at line 184 of file PFEGammaAlgo.h.

std::vector< std::pair <unsigned int, unsigned int> > PFEGammaAlgo::convGsfTrack_
private

Definition at line 167 of file PFEGammaAlgo.h.

Referenced by AddElectronElements(), RunPFEG(), and SetLinks().

float PFEGammaAlgo::CrysEta_
private

Definition at line 247 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

int PFEGammaAlgo::CrysIEta_
private

Definition at line 249 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

int PFEGammaAlgo::CrysIPhi_
private

Definition at line 249 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::CrysPhi_
private

Definition at line 247 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::CrysX_
private

Definition at line 250 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::CrysY_
private

Definition at line 250 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::del_phi
private

Definition at line 241 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), and PFEGammaAlgo().

float PFEGammaAlgo::dEta_
private

Definition at line 258 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::DEtaGsfEcalClust
private

Definition at line 200 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::dPhi_
private

Definition at line 258 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::dPtOverPt_gsf
private

Definition at line 193 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::DPtOverPt_gsf
private

Definition at line 193 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::DPtOverPt_kf
private

Definition at line 193 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e1x3_
private

Definition at line 253 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::e1x5_
private

Definition at line 253 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::e2x5Bottom_
private

Definition at line 253 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::e2x5Left_
private

Definition at line 253 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::e2x5Max_
private

Definition at line 255 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::e2x5Right_
private

Definition at line 253 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::e2x5Top_
private

Definition at line 253 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::e3x1_
private

Definition at line 253 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::e3x3_
private

Definition at line 247 of file PFEGammaAlgo.h.

float PFEGammaAlgo::E3x3_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), EvaluateResMVA(), and RunPFEG().

float PFEGammaAlgo::e5x5Map[5][5]
private

Definition at line 244 of file PFEGammaAlgo.h.

float PFEGammaAlgo::earlyBrem
private

Definition at line 203 of file PFEGammaAlgo.h.

float PFEGammaAlgo::EB
private

Definition at line 251 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::ebottom_
private

Definition at line 254 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

std::vector<reco::PFCandidate> PFEGammaAlgo::egCandidate_
private

Definition at line 272 of file PFEGammaAlgo.h.

Referenced by AddElectronCandidate(), getCandidates(), isEGValidCandidate(), and RunPFEG().

std::vector<reco::PFCandidateEGammaExtra> PFEGammaAlgo::egExtra_
private

Definition at line 276 of file PFEGammaAlgo.h.

Referenced by AddElectronCandidate(), getEGExtra(), and RunPFEG().

float PFEGammaAlgo::EGsfPoutMode
private

Definition at line 199 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::eleft_
private

Definition at line 254 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::EoverPt
private

Definition at line 241 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), and PFEGammaAlgo().

float PFEGammaAlgo::eright_
private

Definition at line 254 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::eSeed_
private

Definition at line 253 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::Eta_gsf
private

Definition at line 190 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::etop_
private

Definition at line 254 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::EtotBremPinPoutMode
private

Definition at line 199 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::EtotPinMode
private

Definition at line 199 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::excluded_
private

Definition at line 268 of file PFEGammaAlgo.h.

std::vector< std::pair <unsigned int, unsigned int> > PFEGammaAlgo::fifthStepKfTrack_
private

Definition at line 166 of file PFEGammaAlgo.h.

Referenced by AddElectronElements(), RunPFEG(), and SetLinks().

float PFEGammaAlgo::firstBrem
private

Definition at line 203 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

std::vector<bool> PFEGammaAlgo::GsfTrackSingleEcal_
private

Definition at line 165 of file PFEGammaAlgo.h.

float PFEGammaAlgo::HOverHE
private

Definition at line 204 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::HOverPin
private

Definition at line 204 of file PFEGammaAlgo.h.

float PFEGammaAlgo::HoverPt
private

Definition at line 241 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), and PFEGammaAlgo().

bool PFEGammaAlgo::isvalid_
private

Definition at line 206 of file PFEGammaAlgo.h.

Referenced by RunPFEG().

float PFEGammaAlgo::lateBrem
private

Definition at line 203 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::lnPt_gsf
private

Definition at line 190 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

std::vector<bool> PFEGammaAlgo::lockExtraKf_
private

Definition at line 164 of file PFEGammaAlgo.h.

float PFEGammaAlgo::logPFClusE_
private

Definition at line 247 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::LowClusE_
private

Definition at line 258 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

std::vector<int> PFEGammaAlgo::match_ind
private

Definition at line 236 of file PFEGammaAlgo.h.

Referenced by EarlyConversion().

float PFEGammaAlgo::Mustache_Et_out_
private

Definition at line 268 of file PFEGammaAlgo.h.

float PFEGammaAlgo::Mustache_EtRatio_
private

Definition at line 268 of file PFEGammaAlgo.h.

float PFEGammaAlgo::MustE_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

double PFEGammaAlgo::MVACUT
private

Definition at line 219 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

double PFEGammaAlgo::mvaEleCut_
private

Definition at line 171 of file PFEGammaAlgo.h.

double PFEGammaAlgo::mvaValue
private

Definition at line 242 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), and RunPFEG().

const char* PFEGammaAlgo::mvaWeightFile_
private

Definition at line 186 of file PFEGammaAlgo.h.

float PFEGammaAlgo::nhit_gsf
private

Definition at line 196 of file PFEGammaAlgo.h.

Referenced by AddElectronCandidate().

float PFEGammaAlgo::nhit_kf
private

Definition at line 196 of file PFEGammaAlgo.h.

Referenced by AddElectronCandidate(), and PFEGammaAlgo().

float PFEGammaAlgo::nlayers
private

Definition at line 240 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), and PFEGammaAlgo().

float PFEGammaAlgo::nlost
private

Definition at line 240 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), and PFEGammaAlgo().

float PFEGammaAlgo::nPFClus_
private

Definition at line 258 of file PFEGammaAlgo.h.

unsigned int PFEGammaAlgo::nTrackIsoForEgammaSC_
private

Definition at line 183 of file PFEGammaAlgo.h.

Referenced by SetLinks().

float PFEGammaAlgo::nVtx_
private

Definition at line 260 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), EvaluateResMVA(), and setnPU().

std::vector< reco::PFCandidate > PFEGammaAlgo::permElectronCandidates_
private

Definition at line 239 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFCrysEtaCrack_
private

Definition at line 247 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

float PFEGammaAlgo::PFPhoE_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::PFPhoECorr_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and RunPFEG().

float PFEGammaAlgo::PFPhoEt_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateResMVA().

float PFEGammaAlgo::PFPhoEta_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::PFPhoEtCorr_
private

Definition at line 257 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFPhoPhi_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::PFPhoR9_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and RunPFEG().

float PFEGammaAlgo::PFPhoR9Corr_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

const reco::Vertex* PFEGammaAlgo::primaryVertex_
private

Definition at line 221 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA(), RunPFEG(), and setPhotonPrimaryVtx().

float PFEGammaAlgo::RConv_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

const GBRForest* PFEGammaAlgo::ReaderGC_
private

Definition at line 224 of file PFEGammaAlgo.h.

Referenced by setGBRForest().

const GBRForest* PFEGammaAlgo::ReaderGCEB_
private

Definition at line 229 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and setGBRForest().

const GBRForest* PFEGammaAlgo::ReaderGCEEhR9_
private

Definition at line 230 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and setGBRForest().

const GBRForest* PFEGammaAlgo::ReaderGCEElR9_
private

Definition at line 231 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and setGBRForest().

const GBRForest* PFEGammaAlgo::ReaderLC_
private

Definition at line 223 of file PFEGammaAlgo.h.

Referenced by setGBRForest().

const GBRForest* PFEGammaAlgo::ReaderLCEB_
private

Definition at line 227 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA(), and setGBRForest().

const GBRForest* PFEGammaAlgo::ReaderLCEE_
private

Definition at line 228 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA(), and setGBRForest().

const GBRForest* PFEGammaAlgo::ReaderRes_
private

Definition at line 225 of file PFEGammaAlgo.h.

Referenced by EvaluateResMVA(), and setGBRForest().

float PFEGammaAlgo::RMSAll_
private

Definition at line 258 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::RMSMust_
private

Definition at line 258 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::SCEtaWidth_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::SCPhiWidth_
private

Definition at line 257 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::SigmaEtaEta
private

Definition at line 201 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::STIP
private

Definition at line 241 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), and PFEGammaAlgo().

double PFEGammaAlgo::sumEtEcalIsoForEgammaSC_barrel_
private

Definition at line 178 of file PFEGammaAlgo.h.

Referenced by SetLinks().

double PFEGammaAlgo::sumEtEcalIsoForEgammaSC_endcap_
private

Definition at line 179 of file PFEGammaAlgo.h.

Referenced by SetLinks().

double PFEGammaAlgo::sumPtTrackIsoForEgammaSC_barrel_
private

Definition at line 181 of file PFEGammaAlgo.h.

Referenced by SetLinks().

double PFEGammaAlgo::sumPtTrackIsoForEgammaSC_endcap_
private

Definition at line 182 of file PFEGammaAlgo.h.

Referenced by SetLinks().

double PFEGammaAlgo::sumPtTrackIsoForPhoton_
private

Definition at line 234 of file PFEGammaAlgo.h.

double PFEGammaAlgo::sumPtTrackIsoSlopeForPhoton_
private

Definition at line 235 of file PFEGammaAlgo.h.

boost::shared_ptr<PFEnergyCalibration> PFEGammaAlgo::thePFEnergyCalibration_
private

Definition at line 173 of file PFEGammaAlgo.h.

Referenced by AddElectronCandidate(), RunPFEG(), and SetLinks().

boost::shared_ptr<PFSCEnergyCalibration> PFEGammaAlgo::thePFSCEnergyCalibration_
private

Definition at line 172 of file PFEGammaAlgo.h.

Referenced by AddElectronCandidate().

TMVA::Reader* PFEGammaAlgo::tmvaReader_
private

Definition at line 222 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), PFEGammaAlgo(), and ~PFEGammaAlgo().

TMVA::Reader* PFEGammaAlgo::tmvaReaderEle_
private

Definition at line 170 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo(), and ~PFEGammaAlgo().

float PFEGammaAlgo::TotPS1_
private

Definition at line 259 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and RunPFEG().

float PFEGammaAlgo::TotPS2_
private

Definition at line 259 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and RunPFEG().

float PFEGammaAlgo::track_pt
private

Definition at line 241 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA(), and PFEGammaAlgo().

bool PFEGammaAlgo::useEGammaSupercluster_
private

Definition at line 177 of file PFEGammaAlgo.h.

Referenced by SetLinks().

bool PFEGammaAlgo::useEGElectrons_
private

Definition at line 176 of file PFEGammaAlgo.h.

bool PFEGammaAlgo::usePFSCEleCalib_
private

Definition at line 175 of file PFEGammaAlgo.h.

Referenced by AddElectronCandidate().

bool PFEGammaAlgo::useReg_
private

Definition at line 220 of file PFEGammaAlgo.h.

Referenced by RunPFEG().

verbosityLevel PFEGammaAlgo::verbosityLevel_
private

Definition at line 213 of file PFEGammaAlgo.h.

Referenced by RunPFEG().

float PFEGammaAlgo::VtxZ_
private

Definition at line 247 of file PFEGammaAlgo.h.

Referenced by EvaluateLCorrMVA().

TH2D* PFEGammaAlgo::X0_inner
private

Definition at line 263 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), EvaluateResMVA(), and PFEGammaAlgo().

TH2D* PFEGammaAlgo::X0_middle
private

Definition at line 264 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), EvaluateResMVA(), and PFEGammaAlgo().

TH2D* PFEGammaAlgo::X0_outer
private

Definition at line 265 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), EvaluateResMVA(), and PFEGammaAlgo().

TH2D* PFEGammaAlgo::X0_sum
private

Definition at line 262 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), EvaluateResMVA(), and PFEGammaAlgo().

float PFEGammaAlgo::x0inner_
private

Definition at line 266 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::x0middle_
private

Definition at line 266 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().

float PFEGammaAlgo::x0outer_
private

Definition at line 266 of file PFEGammaAlgo.h.

Referenced by EvaluateGCorrMVA(), and EvaluateResMVA().