00001 #ifndef PFProducer_PFPhotonAlgo_H
00002 #define PFProducer_PFPhotonAlgo_H
00003
00004 #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
00005 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
00006 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00007 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtra.h"
00008 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtraFwd.h"
00009 #include "DataFormats/Common/interface/Handle.h"
00010 #include "DataFormats/Common/interface/OrphanHandle.h"
00011 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementGsfTrack.h"
00012 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00013 #include "DataFormats/GsfTrackReco/interface/GsfTrackExtra.h"
00014 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
00015 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementSuperCluster.h"
00016 #include "DataFormats/VertexReco/interface/Vertex.h"
00017 #include "CondFormats/EgammaObjects/interface/GBRForest.h"
00018 #include "TMVA/Reader.h"
00019 #include <iostream>
00020 #include <TH2D.h>
00021
00022 class PFEnergyCalibration;
00023
00024 namespace reco {
00025 class PFCandidate;
00026 class PFCandidateCollectioon;
00027 }
00028
00029 class PFPhotonAlgo {
00030 public:
00031
00032
00033 PFPhotonAlgo(std::string mvaweightfile,
00034 double mvaConvCut,
00035 bool useReg,
00036 std::string X0_Map,
00037 const reco::Vertex& primary,
00038 const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
00039 double sumPtTrackIsoForPhoton,
00040 double sumPtTrackIsoSlopeForPhoton
00041 );
00042
00043
00044 ~PFPhotonAlgo(){delete tmvaReader_; };
00045
00046 void setGBRForest(const GBRForest *LCorrForest,
00047 const GBRForest *GCorrForest,
00048 const GBRForest *ResForest
00049 )
00050 {
00051 ReaderLC_=LCorrForest;
00052 ReaderGC_=GCorrForest;
00053 ReaderRes_=ResForest;
00054 }
00055
00056 bool isPhotonValidCandidate(const reco::PFBlockRef& blockRef,
00057 std::vector< bool >& active,
00058 std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates,
00059 std::vector<reco::PFCandidatePhotonExtra>& pfPhotonExtraCandidates,
00060 std::vector<reco::PFCandidate>&
00061 tempElectronCandidates
00062
00063 ){
00064 isvalid_=false;
00065
00066
00067 permElectronCandidates_.clear();
00068 match_ind.clear();
00069 RunPFPhoton(blockRef,
00070 active,
00071 pfPhotonCandidates,
00072 pfPhotonExtraCandidates,
00073 tempElectronCandidates
00074 );
00075 int ind=0;
00076 bool matched=false;
00077 int matches=match_ind.size();
00078
00079 for ( std::vector<reco::PFCandidate>::const_iterator ec=tempElectronCandidates.begin(); ec != tempElectronCandidates.end(); ++ec){
00080 for(int i=0; i<matches; i++)
00081 {
00082 if(ind==match_ind[i])
00083 {
00084 matched=true;
00085
00086 break;
00087 }
00088 }
00089 ++ind;
00090 if(matched)continue;
00091 permElectronCandidates_.push_back(*ec);
00092
00093 }
00094
00095 match_ind.clear();
00096
00097 tempElectronCandidates.clear();
00098 for ( std::vector<reco::PFCandidate>::const_iterator ec=permElectronCandidates_.begin(); ec != permElectronCandidates_.end(); ++ec)tempElectronCandidates.push_back(*ec);
00099 permElectronCandidates_.clear();
00100
00101 return isvalid_;
00102 };
00103
00104 private:
00105
00106 enum verbosityLevel {
00107 Silent,
00108 Summary,
00109 Chatty
00110 };
00111
00112
00113 bool isvalid_;
00114 verbosityLevel verbosityLevel_;
00115
00116
00117
00118
00119
00120 double MVACUT;
00121 bool useReg_;
00122 reco::Vertex primaryVertex_;
00123 TMVA::Reader *tmvaReader_;
00124 const GBRForest *ReaderLC_;
00125 const GBRForest *ReaderGC_;
00126 const GBRForest *ReaderRes_;
00127 boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_;
00128 double sumPtTrackIsoForPhoton_;
00129 double sumPtTrackIsoSlopeForPhoton_;
00130 std::vector<int>match_ind;
00131
00132
00133 std::vector< reco::PFCandidate >permElectronCandidates_;
00134 float nlost, nlayers;
00135 float chi2, STIP, del_phi,HoverPt, EoverPt, track_pt;
00136 double mvaValue;
00137
00138 float e5x5Map[5][5];
00139
00140
00141 float CrysPhi_, CrysEta_, CrysIPhi_, CrysIEta_, VtxZ_, ClusPhi_, ClusEta_,
00142 ClusR9_, Clus5x5ratio_, PFCrysPhiCrack_, PFCrysEtaCrack_, logPFClusE_, e3x3_;
00143 float EB;
00144
00145 float eSeed_, e1x3_,e3x1_, e1x5_, e2x5Top_, e2x5Bottom_, e2x5Left_, e2x5Right_ ;
00146 float e2x5Max_;
00147
00148 float PFPhoEta_, PFPhoPhi_, PFPhoR9_, SCPhiWidth_, SCEtaWidth_, PFPhoEt_, RConv_;
00149 float dEta_, dPhi_, LowClusE_, nPFClus_;
00150
00151
00152 TH2D* X0_sum;
00153 TH2D* X0_inner;
00154 TH2D* X0_middle;
00155 TH2D* X0_outer;
00156 float x0inner_, x0middle_, x0outer_;
00157
00158 float excluded_, Mustache_EtRatio_, Mustache_Et_out_;
00159
00160 std::vector<unsigned int> AddFromElectron_;
00161 void RunPFPhoton(const reco::PFBlockRef& blockRef,
00162 std::vector< bool >& active,
00163
00164 std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates,
00165 std::vector<reco::PFCandidatePhotonExtra>&
00166 pfPhotonExtraCandidates,
00167
00168
00169 std::vector<reco::PFCandidate>&
00170 tempElectronCandidates
00171 );
00172
00173 bool EvaluateSingleLegMVA(const reco::PFBlockRef& blockref,
00174 const reco::Vertex& primaryvtx,
00175 unsigned int track_index);
00176
00177
00178 void GetCrysCoordinates(reco::PFClusterRef clusterRef);
00179 void fill5x5Map(reco::PFClusterRef clusterRef);
00180 float EvaluateLCorrMVA(reco::PFClusterRef clusterRef );
00181 float EvaluateGCorrMVA(reco::PFCandidate);
00182 float EvaluateResMVA(reco::PFCandidate);
00183 std::vector<int> getPFMustacheClus(int nClust, std::vector<float>& ClustEt, std::vector<float>& ClustEta, std::vector<float>& ClustPhi);
00184 void EarlyConversion(
00185
00186
00187 std::vector<reco::PFCandidate>&
00188 tempElectronCandidates,
00189 const reco::PFBlockElementSuperCluster* sc
00190 );
00191 };
00192
00193 #endif