CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFPhotonAlgo.h
Go to the documentation of this file.
1 #ifndef PFProducer_PFPhotonAlgo_H
2 #define PFProducer_PFPhotonAlgo_H
3 
19 
21 #include "TMVA/Reader.h"
22 #include <iostream>
23 #include <TH2D.h>
24 
26 
27 namespace reco {
28  class PFCandidate;
29  class PFCandidateCollectioon;
30 }
31 
32 class PFPhotonAlgo {
33  public:
34 
35  //constructor
36  PFPhotonAlgo(std::string mvaweightfile,
37  double mvaConvCut,
38  bool useReg,
39  std::string X0_Map,
40  const reco::Vertex& primary,
41  const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
42  double sumPtTrackIsoForPhoton,
43  double sumPtTrackIsoSlopeForPhoton
44 );
45 
46  //destructor
48 
49  void setGBRForest(const GBRForest *LCorrForest,
50  const GBRForest *GCorrForest,
51  const GBRForest *ResForest
52  )
53  {
54  ReaderLC_=LCorrForest;
55  ReaderGC_=GCorrForest;
56  ReaderRes_=ResForest;
57  }
58 
60  const GBRForest *LCorrForestEB,
61  const GBRForest *LCorrForestEE,
62  const GBRForest *GCorrForestBarrel,
63  const GBRForest *GCorrForestEndcapHr9,
64  const GBRForest *GCorrForestEndcapLr9,
65  const GBRForest *PFEcalResolution
66  )
67  {
68  ReaderLCEB_=LCorrForestEB;
69  ReaderLCEE_=LCorrForestEE;
70  ReaderGCEB_=GCorrForestBarrel;
71  ReaderGCEEhR9_=GCorrForestEndcapHr9;
72  ReaderGCEElR9_=GCorrForestEndcapLr9;
73  ReaderRes_=PFEcalResolution;
74  }
75  void setnPU(int nVtx){
76  nVtx_=nVtx;
77  }
78  void setPhotonPrimaryVtx(const reco::Vertex& primary){
79  primaryVertex_ = & primary;
80  }
81  //check candidate validity
83  std::vector< bool >& active,
84  std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates,
85  std::vector<reco::PFCandidatePhotonExtra>& pfPhotonExtraCandidates,
86  std::vector<reco::PFCandidate>&
87  tempElectronCandidates
88  // std::auto_ptr< reco::PFCandidateCollection > &pfElectronCandidates_
89  ){
90  isvalid_=false;
91  // RunPFPhoton has to set isvalid_ to TRUE in case it finds a valid candidate
92  // ... TODO: maybe can be replaced by checking for the size of the CandCollection.....
94  match_ind.clear();
95  RunPFPhoton(blockRef,
96  active,
97  pfPhotonCandidates,
98  pfPhotonExtraCandidates,
99  tempElectronCandidates
100  );
101  int ind=0;
102  int matches=match_ind.size();
103 
104  for ( std::vector<reco::PFCandidate>::const_iterator ec=tempElectronCandidates.begin(); ec != tempElectronCandidates.end(); ++ec){
105  bool matched=false;
106  for(int i=0; i<matches; i++)
107  {
108  if(ind==match_ind[i])
109  {
110  matched=true;
111  //std::cout<<"This is matched in .h "<<*ec<<std::endl;
112  break;
113  }
114  }
115  ++ind;
116  if(matched)continue;
117  permElectronCandidates_.push_back(*ec);
118  //std::cout<<"This is NOT matched in .h "<<*ec<<std::endl;
119  }
120 
121  match_ind.clear();
122 
123  tempElectronCandidates.clear();
124  for ( std::vector<reco::PFCandidate>::const_iterator ec=permElectronCandidates_.begin(); ec != permElectronCandidates_.end(); ++ec)tempElectronCandidates.push_back(*ec);
125  permElectronCandidates_.clear();
126 
127  return isvalid_;
128  };
129 
130 private:
131 
136  };
137 
138 
139  bool isvalid_; // is set to TRUE when a valid PhotonCandidate is found in a PFBlock
140  verbosityLevel verbosityLevel_; /* Verbosity Level:
141  ............... 0: Say nothing at all
142  ............... 1: Print summary about found PhotonCadidates only
143  ............... 2: Chatty mode
144  */
145  //FOR SINGLE LEG MVA:
146  double MVACUT;
147  bool useReg_;
149  TMVA::Reader *tmvaReader_;
153 
159 
160  boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_;
163  std::vector<int>match_ind;
164  //std::auto_ptr< reco::PFCandidateCollection > permElectronCandidates_;
165 
166  std::vector< reco::PFCandidate >permElectronCandidates_;
167  float nlost, nlayers;
169  double mvaValue;
170  //for Cluster Shape Calculations:
171  float e5x5Map[5][5];
172 
173  //For Local Containment Corrections:
177  float CrysX_, CrysY_;
178  float EB;
179  //Cluster Shapes:
182  float e2x5Max_;
183  //For Global Corrections:
186  float TotPS1_, TotPS2_;
187  float nVtx_;
188  //for Material Map
189  TH2D* X0_sum;
190  TH2D* X0_inner;
191  TH2D* X0_middle;
192  TH2D* X0_outer;
194  //for PileUP
196 
197  std::vector<unsigned int> AddFromElectron_;
198  void RunPFPhoton(const reco::PFBlockRef& blockRef,
199  std::vector< bool >& active,
200 
201  std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates,
202  std::vector<reco::PFCandidatePhotonExtra>&
203  pfPhotonExtraCandidates,
204  // std::auto_ptr< reco::PFCandidateCollection >
205  //&pfElectronCandidates_
206  std::vector<reco::PFCandidate>&
207  tempElectronCandidates
208  );
209 
210  bool EvaluateSingleLegMVA(const reco::PFBlockRef& blockref,
211  const reco::Vertex& primaryvtx,
212  unsigned int track_index);
213 
214  double ClustersPhiRMS(const std::vector<reco::CaloCluster>&PFClusters, float PFPhoPhi);
215  float EvaluateLCorrMVA(reco::PFClusterRef clusterRef );
216  float EvaluateGCorrMVA(const reco::PFCandidate&, const std::vector<reco::CaloCluster>& PFClusters);
217  float EvaluateResMVA(const reco::PFCandidate&,const std::vector<reco::CaloCluster>& PFClusters );
218  std::vector<int> getPFMustacheClus(int nClust, std::vector<float>& ClustEt, std::vector<float>& ClustEta, std::vector<float>& ClustPhi);
219  void EarlyConversion(
220  //std::auto_ptr< reco::PFCandidateCollection >
221  //&pfElectronCandidates_,
222  std::vector<reco::PFCandidate>&
223  tempElectronCandidates,
225  );
226 };
227 
228 #endif
float Clus5x5ratio_
Definition: PFPhotonAlgo.h:174
int i
Definition: DBlmapReader.cc:9
std::vector< int > getPFMustacheClus(int nClust, std::vector< float > &ClustEt, std::vector< float > &ClustEta, std::vector< float > &ClustPhi)
const GBRForest * ReaderLCEE_
Definition: PFPhotonAlgo.h:155
float SCEtaWidth_
Definition: PFPhotonAlgo.h:184
float logPFClusE_
Definition: PFPhotonAlgo.h:174
void setnPU(int nVtx)
Definition: PFPhotonAlgo.h:75
const GBRForest * ReaderGC_
Definition: PFPhotonAlgo.h:151
float Mustache_Et_out_
Definition: PFPhotonAlgo.h:195
float e5x5Map[5][5]
Definition: PFPhotonAlgo.h:171
verbosityLevel verbosityLevel_
Definition: PFPhotonAlgo.h:140
const GBRForest * ReaderRes_
Definition: PFPhotonAlgo.h:152
std::vector< unsigned int > AddFromElectron_
Definition: PFPhotonAlgo.h:197
const GBRForest * ReaderGCEEhR9_
Definition: PFPhotonAlgo.h:157
std::vector< reco::PFCandidate > permElectronCandidates_
Definition: PFPhotonAlgo.h:166
float e2x5Right_
Definition: PFPhotonAlgo.h:180
double ClustersPhiRMS(const std::vector< reco::CaloCluster > &PFClusters, float PFPhoPhi)
void RunPFPhoton(const reco::PFBlockRef &blockRef, std::vector< bool > &active, std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates, std::vector< reco::PFCandidatePhotonExtra > &pfPhotonExtraCandidates, std::vector< reco::PFCandidate > &tempElectronCandidates)
Definition: PFPhotonAlgo.cc:87
double mvaValue
Definition: PFPhotonAlgo.h:169
TMVA::Reader * tmvaReader_
Definition: PFPhotonAlgo.h:149
float EvaluateResMVA(const reco::PFCandidate &, const std::vector< reco::CaloCluster > &PFClusters)
TH2D * X0_outer
Definition: PFPhotonAlgo.h:192
float EvaluateGCorrMVA(const reco::PFCandidate &, const std::vector< reco::CaloCluster > &PFClusters)
float EvaluateLCorrMVA(reco::PFClusterRef clusterRef)
const GBRForest * ReaderLC_
Definition: PFPhotonAlgo.h:150
const GBRForest * ReaderLCEB_
Definition: PFPhotonAlgo.h:154
TH2D * X0_inner
Definition: PFPhotonAlgo.h:190
float PFPhoECorr_
Definition: PFPhotonAlgo.h:184
TH2D * X0_middle
Definition: PFPhotonAlgo.h:191
const reco::Vertex * primaryVertex_
Definition: PFPhotonAlgo.h:148
float e2x5Bottom_
Definition: PFPhotonAlgo.h:180
double sumPtTrackIsoSlopeForPhoton_
Definition: PFPhotonAlgo.h:162
PFPhotonAlgo(std::string mvaweightfile, double mvaConvCut, bool useReg, std::string X0_Map, const reco::Vertex &primary, const boost::shared_ptr< PFEnergyCalibration > &thePFEnergyCalibration, double sumPtTrackIsoForPhoton, double sumPtTrackIsoSlopeForPhoton)
Definition: PFPhotonAlgo.cc:30
float SCPhiWidth_
Definition: PFPhotonAlgo.h:184
boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_
Definition: PFPhotonAlgo.h:160
const GBRForest * ReaderGCEB_
Definition: PFPhotonAlgo.h:156
void setGBRForest(const GBRForest *LCorrForestEB, const GBRForest *LCorrForestEE, const GBRForest *GCorrForestBarrel, const GBRForest *GCorrForestEndcapHr9, const GBRForest *GCorrForestEndcapLr9, const GBRForest *PFEcalResolution)
Definition: PFPhotonAlgo.h:59
void EarlyConversion(std::vector< reco::PFCandidate > &tempElectronCandidates, const reco::PFBlockElementSuperCluster *sc)
float PFCrysEtaCrack_
Definition: PFPhotonAlgo.h:174
void setGBRForest(const GBRForest *LCorrForest, const GBRForest *GCorrForest, const GBRForest *ResForest)
Definition: PFPhotonAlgo.h:49
bool EvaluateSingleLegMVA(const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:38
float Mustache_EtRatio_
Definition: PFPhotonAlgo.h:195
const GBRForest * ReaderGCEElR9_
Definition: PFPhotonAlgo.h:158
double sumPtTrackIsoForPhoton_
Definition: PFPhotonAlgo.h:161
void setPhotonPrimaryVtx(const reco::Vertex &primary)
Definition: PFPhotonAlgo.h:78
float PFPhoEtCorr_
Definition: PFPhotonAlgo.h:184
std::vector< int > match_ind
Definition: PFPhotonAlgo.h:163
bool isPhotonValidCandidate(const reco::PFBlockRef &blockRef, std::vector< bool > &active, std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates, std::vector< reco::PFCandidatePhotonExtra > &pfPhotonExtraCandidates, std::vector< reco::PFCandidate > &tempElectronCandidates)
Definition: PFPhotonAlgo.h:82
float PFPhoR9Corr_
Definition: PFPhotonAlgo.h:184