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/CaloRecHit/interface/CaloCluster.h"
00012 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
00013 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementGsfTrack.h"
00014 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00015 #include "DataFormats/GsfTrackReco/interface/GsfTrackExtra.h"
00016 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
00017 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementSuperCluster.h"
00018 #include "DataFormats/VertexReco/interface/Vertex.h"
00019
00020 #include "CondFormats/EgammaObjects/interface/GBRForest.h"
00021 #include "TMVA/Reader.h"
00022 #include <iostream>
00023 #include <TH2D.h>
00024
00025 class PFEnergyCalibration;
00026
00027 namespace reco {
00028 class PFCandidate;
00029 class PFCandidateCollectioon;
00030 }
00031
00032 class PFPhotonAlgo {
00033 public:
00034
00035
00036 PFPhotonAlgo(std::string mvaweightfile,
00037 double mvaConvCut,
00038 bool useReg,
00039 std::string X0_Map,
00040 const reco::Vertex& primary,
00041 const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
00042 double sumPtTrackIsoForPhoton,
00043 double sumPtTrackIsoSlopeForPhoton
00044 );
00045
00046
00047 ~PFPhotonAlgo(){delete tmvaReader_; };
00048
00049 void setGBRForest(const GBRForest *LCorrForest,
00050 const GBRForest *GCorrForest,
00051 const GBRForest *ResForest
00052 )
00053 {
00054 ReaderLC_=LCorrForest;
00055 ReaderGC_=GCorrForest;
00056 ReaderRes_=ResForest;
00057 }
00058
00059 void setGBRForest(
00060 const GBRForest *LCorrForestEB,
00061 const GBRForest *LCorrForestEE,
00062 const GBRForest *GCorrForestBarrel,
00063 const GBRForest *GCorrForestEndcapHr9,
00064 const GBRForest *GCorrForestEndcapLr9,
00065 const GBRForest *PFEcalResolution
00066 )
00067 {
00068 ReaderLCEB_=LCorrForestEB;
00069 ReaderLCEE_=LCorrForestEE;
00070 ReaderGCEB_=GCorrForestBarrel;
00071 ReaderGCEEhR9_=GCorrForestEndcapHr9;
00072 ReaderGCEElR9_=GCorrForestEndcapLr9;
00073 ReaderRes_=PFEcalResolution;
00074 }
00075 void setnPU(int nVtx){
00076 nVtx_=nVtx;
00077 }
00078
00079 bool isPhotonValidCandidate(const reco::PFBlockRef& blockRef,
00080 std::vector< bool >& active,
00081 std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates,
00082 std::vector<reco::PFCandidatePhotonExtra>& pfPhotonExtraCandidates,
00083 std::vector<reco::PFCandidate>&
00084 tempElectronCandidates
00085
00086 ){
00087 isvalid_=false;
00088
00089
00090 permElectronCandidates_.clear();
00091 match_ind.clear();
00092 RunPFPhoton(blockRef,
00093 active,
00094 pfPhotonCandidates,
00095 pfPhotonExtraCandidates,
00096 tempElectronCandidates
00097 );
00098 int ind=0;
00099 int matches=match_ind.size();
00100
00101 for ( std::vector<reco::PFCandidate>::const_iterator ec=tempElectronCandidates.begin(); ec != tempElectronCandidates.end(); ++ec){
00102 bool matched=false;
00103 for(int i=0; i<matches; i++)
00104 {
00105 if(ind==match_ind[i])
00106 {
00107 matched=true;
00108
00109 break;
00110 }
00111 }
00112 ++ind;
00113 if(matched)continue;
00114 permElectronCandidates_.push_back(*ec);
00115
00116 }
00117
00118 match_ind.clear();
00119
00120 tempElectronCandidates.clear();
00121 for ( std::vector<reco::PFCandidate>::const_iterator ec=permElectronCandidates_.begin(); ec != permElectronCandidates_.end(); ++ec)tempElectronCandidates.push_back(*ec);
00122 permElectronCandidates_.clear();
00123
00124 return isvalid_;
00125 };
00126
00127 private:
00128
00129 enum verbosityLevel {
00130 Silent,
00131 Summary,
00132 Chatty
00133 };
00134
00135
00136 bool isvalid_;
00137 verbosityLevel verbosityLevel_;
00138
00139
00140
00141
00142
00143 double MVACUT;
00144 bool useReg_;
00145 reco::Vertex primaryVertex_;
00146 TMVA::Reader *tmvaReader_;
00147 const GBRForest *ReaderLC_;
00148 const GBRForest *ReaderGC_;
00149 const GBRForest *ReaderRes_;
00150
00151 const GBRForest *ReaderLCEB_;
00152 const GBRForest *ReaderLCEE_;
00153 const GBRForest *ReaderGCEB_;
00154 const GBRForest *ReaderGCEEhR9_;
00155 const GBRForest *ReaderGCEElR9_;
00156
00157 boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_;
00158 double sumPtTrackIsoForPhoton_;
00159 double sumPtTrackIsoSlopeForPhoton_;
00160 std::vector<int>match_ind;
00161
00162
00163 std::vector< reco::PFCandidate >permElectronCandidates_;
00164 float nlost, nlayers;
00165 float chi2, STIP, del_phi,HoverPt, EoverPt, track_pt;
00166 double mvaValue;
00167
00168 float e5x5Map[5][5];
00169
00170
00171 float CrysPhi_, CrysEta_, VtxZ_, ClusPhi_, ClusEta_,
00172 ClusR9_, Clus5x5ratio_, PFCrysEtaCrack_, logPFClusE_, e3x3_;
00173 int CrysIPhi_, CrysIEta_;
00174 float CrysX_, CrysY_;
00175 float EB;
00176
00177 float eSeed_, e1x3_,e3x1_, e1x5_, e2x5Top_, e2x5Bottom_, e2x5Left_, e2x5Right_ ;
00178 float etop_, ebottom_, eleft_, eright_;
00179 float e2x5Max_;
00180
00181 float PFPhoEta_, PFPhoPhi_, PFPhoR9_, PFPhoR9Corr_, SCPhiWidth_, SCEtaWidth_, PFPhoEt_, RConv_, PFPhoEtCorr_, PFPhoE_, PFPhoECorr_, MustE_, E3x3_;
00182 float dEta_, dPhi_, LowClusE_, RMSAll_, RMSMust_, nPFClus_;
00183 float TotPS1_, TotPS2_;
00184 float nVtx_;
00185
00186 TH2D* X0_sum;
00187 TH2D* X0_inner;
00188 TH2D* X0_middle;
00189 TH2D* X0_outer;
00190 float x0inner_, x0middle_, x0outer_;
00191
00192 float excluded_, Mustache_EtRatio_, Mustache_Et_out_;
00193
00194 std::vector<unsigned int> AddFromElectron_;
00195 void RunPFPhoton(const reco::PFBlockRef& blockRef,
00196 std::vector< bool >& active,
00197
00198 std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates,
00199 std::vector<reco::PFCandidatePhotonExtra>&
00200 pfPhotonExtraCandidates,
00201
00202
00203 std::vector<reco::PFCandidate>&
00204 tempElectronCandidates
00205 );
00206
00207 bool EvaluateSingleLegMVA(const reco::PFBlockRef& blockref,
00208 const reco::Vertex& primaryvtx,
00209 unsigned int track_index);
00210
00211 double ClustersPhiRMS(std::vector<reco::CaloCluster>PFClusters, float PFPhoPhi);
00212 float EvaluateLCorrMVA(reco::PFClusterRef clusterRef );
00213 float EvaluateGCorrMVA(reco::PFCandidate, std::vector<reco::CaloCluster>PFClusters);
00214 float EvaluateResMVA(reco::PFCandidate,std::vector<reco::CaloCluster>PFClusters );
00215 std::vector<int> getPFMustacheClus(int nClust, std::vector<float>& ClustEt, std::vector<float>& ClustEta, std::vector<float>& ClustPhi);
00216 void EarlyConversion(
00217
00218
00219 std::vector<reco::PFCandidate>&
00220 tempElectronCandidates,
00221 const reco::PFBlockElementSuperCluster* sc
00222 );
00223 };
00224
00225 #endif