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  //check candidate validity
80  std::vector< bool >& active,
81  std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates,
82  std::vector<reco::PFCandidatePhotonExtra>& pfPhotonExtraCandidates,
83  std::vector<reco::PFCandidate>&
84  tempElectronCandidates
85  // std::auto_ptr< reco::PFCandidateCollection > &pfElectronCandidates_
86  ){
87  isvalid_=false;
88  // RunPFPhoton has to set isvalid_ to TRUE in case it finds a valid candidate
89  // ... TODO: maybe can be replaced by checking for the size of the CandCollection.....
91  match_ind.clear();
92  RunPFPhoton(blockRef,
93  active,
94  pfPhotonCandidates,
95  pfPhotonExtraCandidates,
96  tempElectronCandidates
97  );
98  int ind=0;
99  int matches=match_ind.size();
100 
101  for ( std::vector<reco::PFCandidate>::const_iterator ec=tempElectronCandidates.begin(); ec != tempElectronCandidates.end(); ++ec){
102  bool matched=false;
103  for(int i=0; i<matches; i++)
104  {
105  if(ind==match_ind[i])
106  {
107  matched=true;
108  //std::cout<<"This is matched in .h "<<*ec<<std::endl;
109  break;
110  }
111  }
112  ++ind;
113  if(matched)continue;
114  permElectronCandidates_.push_back(*ec);
115  //std::cout<<"This is NOT matched in .h "<<*ec<<std::endl;
116  }
117 
118  match_ind.clear();
119 
120  tempElectronCandidates.clear();
121  for ( std::vector<reco::PFCandidate>::const_iterator ec=permElectronCandidates_.begin(); ec != permElectronCandidates_.end(); ++ec)tempElectronCandidates.push_back(*ec);
122  permElectronCandidates_.clear();
123 
124  return isvalid_;
125  };
126 
127 private:
128 
133  };
134 
135 
136  bool isvalid_; // is set to TRUE when a valid PhotonCandidate is found in a PFBlock
137  verbosityLevel verbosityLevel_; /* Verbosity Level:
138  ............... 0: Say nothing at all
139  ............... 1: Print summary about found PhotonCadidates only
140  ............... 2: Chatty mode
141  */
142  //FOR SINGLE LEG MVA:
143  double MVACUT;
144  bool useReg_;
146  TMVA::Reader *tmvaReader_;
150 
156 
157  boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_;
160  std::vector<int>match_ind;
161  //std::auto_ptr< reco::PFCandidateCollection > permElectronCandidates_;
162 
163  std::vector< reco::PFCandidate >permElectronCandidates_;
164  float nlost, nlayers;
166  double mvaValue;
167  //for Cluster Shape Calculations:
168  float e5x5Map[5][5];
169 
170  //For Local Containment Corrections:
174  float CrysX_, CrysY_;
175  float EB;
176  //Cluster Shapes:
179  float e2x5Max_;
180  //For Global Corrections:
183  float TotPS1_, TotPS2_;
184  float nVtx_;
185  //for Material Map
186  TH2D* X0_sum;
187  TH2D* X0_inner;
188  TH2D* X0_middle;
189  TH2D* X0_outer;
191  //for PileUP
193 
194  std::vector<unsigned int> AddFromElectron_;
195  void RunPFPhoton(const reco::PFBlockRef& blockRef,
196  std::vector< bool >& active,
197 
198  std::auto_ptr< reco::PFCandidateCollection > &pfPhotonCandidates,
199  std::vector<reco::PFCandidatePhotonExtra>&
200  pfPhotonExtraCandidates,
201  // std::auto_ptr< reco::PFCandidateCollection >
202  //&pfElectronCandidates_
203  std::vector<reco::PFCandidate>&
204  tempElectronCandidates
205  );
206 
207  bool EvaluateSingleLegMVA(const reco::PFBlockRef& blockref,
208  const reco::Vertex& primaryvtx,
209  unsigned int track_index);
210 
211  double ClustersPhiRMS(std::vector<reco::CaloCluster>PFClusters, float PFPhoPhi);
212  float EvaluateLCorrMVA(reco::PFClusterRef clusterRef );
213  float EvaluateGCorrMVA(reco::PFCandidate, std::vector<reco::CaloCluster>PFClusters);
214  float EvaluateResMVA(reco::PFCandidate,std::vector<reco::CaloCluster>PFClusters );
215  std::vector<int> getPFMustacheClus(int nClust, std::vector<float>& ClustEt, std::vector<float>& ClustEta, std::vector<float>& ClustPhi);
216  void EarlyConversion(
217  //std::auto_ptr< reco::PFCandidateCollection >
218  //&pfElectronCandidates_,
219  std::vector<reco::PFCandidate>&
220  tempElectronCandidates,
222  );
223 };
224 
225 #endif
float Clus5x5ratio_
Definition: PFPhotonAlgo.h:171
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:152
float SCEtaWidth_
Definition: PFPhotonAlgo.h:181
float logPFClusE_
Definition: PFPhotonAlgo.h:171
void setnPU(int nVtx)
Definition: PFPhotonAlgo.h:75
const GBRForest * ReaderGC_
Definition: PFPhotonAlgo.h:148
float Mustache_Et_out_
Definition: PFPhotonAlgo.h:192
float e5x5Map[5][5]
Definition: PFPhotonAlgo.h:168
verbosityLevel verbosityLevel_
Definition: PFPhotonAlgo.h:137
const GBRForest * ReaderRes_
Definition: PFPhotonAlgo.h:149
std::vector< unsigned int > AddFromElectron_
Definition: PFPhotonAlgo.h:194
const GBRForest * ReaderGCEEhR9_
Definition: PFPhotonAlgo.h:154
std::vector< reco::PFCandidate > permElectronCandidates_
Definition: PFPhotonAlgo.h:163
float EvaluateGCorrMVA(reco::PFCandidate, std::vector< reco::CaloCluster >PFClusters)
float e2x5Right_
Definition: PFPhotonAlgo.h:177
reco::Vertex primaryVertex_
Definition: PFPhotonAlgo.h:145
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:166
TMVA::Reader * tmvaReader_
Definition: PFPhotonAlgo.h:146
TH2D * X0_outer
Definition: PFPhotonAlgo.h:189
float EvaluateLCorrMVA(reco::PFClusterRef clusterRef)
const GBRForest * ReaderLC_
Definition: PFPhotonAlgo.h:147
const GBRForest * ReaderLCEB_
Definition: PFPhotonAlgo.h:151
TH2D * X0_inner
Definition: PFPhotonAlgo.h:187
float PFPhoECorr_
Definition: PFPhotonAlgo.h:181
TH2D * X0_middle
Definition: PFPhotonAlgo.h:188
float e2x5Bottom_
Definition: PFPhotonAlgo.h:177
double sumPtTrackIsoSlopeForPhoton_
Definition: PFPhotonAlgo.h:159
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:181
double ClustersPhiRMS(std::vector< reco::CaloCluster >PFClusters, float PFPhoPhi)
boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_
Definition: PFPhotonAlgo.h:157
const GBRForest * ReaderGCEB_
Definition: PFPhotonAlgo.h:153
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:171
void setGBRForest(const GBRForest *LCorrForest, const GBRForest *GCorrForest, const GBRForest *ResForest)
Definition: PFPhotonAlgo.h:49
float EvaluateResMVA(reco::PFCandidate, std::vector< reco::CaloCluster >PFClusters)
bool EvaluateSingleLegMVA(const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
float Mustache_EtRatio_
Definition: PFPhotonAlgo.h:192
const GBRForest * ReaderGCEElR9_
Definition: PFPhotonAlgo.h:155
double sumPtTrackIsoForPhoton_
Definition: PFPhotonAlgo.h:158
float PFPhoEtCorr_
Definition: PFPhotonAlgo.h:181
std::vector< int > match_ind
Definition: PFPhotonAlgo.h:160
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:79
float PFPhoR9Corr_
Definition: PFPhotonAlgo.h:181