CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFEGammaAlgo.h
Go to the documentation of this file.
1 #ifndef PFProducer_PFEGammaAlgo_H
2 #define PFProducer_PFEGammaAlgo_H
3 
19 
24 
26 #include "TMVA/Reader.h"
27 #include <iostream>
28 #include <TH2D.h>
29 
32 
33 namespace reco {
34  class PFCandidate;
35  class PFCandidateCollectioon;
36 }
37 
38 class PFEGammaAlgo {
39  public:
40 
41  //constructor
42  PFEGammaAlgo(const double mvaEleCut,
43  std::string mvaWeightFileEleID,
44  const boost::shared_ptr<PFSCEnergyCalibration>& thePFSCEnergyCalibration,
45  const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
46  bool applyCrackCorrections,
47  bool usePFSCEleCalib,
48  bool useEGElectrons,
49  bool useEGammaSupercluster,
50  double sumEtEcalIsoForEgammaSC_barrel,
51  double sumEtEcalIsoForEgammaSC_endcap,
52  double coneEcalIsoForEgammaSC,
53  double sumPtTrackIsoForEgammaSC_barrel,
54  double sumPtTrackIsoForEgammaSC_endcap,
55  unsigned int nTrackIsoForEgammaSC,
56  double coneTrackIsoForEgammaSC,
57  std::string mvaweightfile,
58  double mvaConvCut,
59  bool useReg,
60  std::string X0_Map,
61  const reco::Vertex& primary,
62  double sumPtTrackIsoForPhoton,
63  double sumPtTrackIsoSlopeForPhoton
64 );
65 
66  //destructor
68 
69  void setGBRForest(const GBRForest *LCorrForest,
70  const GBRForest *GCorrForest,
71  const GBRForest *ResForest
72  )
73  {
74  ReaderLC_=LCorrForest;
75  ReaderGC_=GCorrForest;
76  ReaderRes_=ResForest;
77  }
78 
80  const GBRForest *LCorrForestEB,
81  const GBRForest *LCorrForestEE,
82  const GBRForest *GCorrForestBarrel,
83  const GBRForest *GCorrForestEndcapHr9,
84  const GBRForest *GCorrForestEndcapLr9,
85  const GBRForest *PFEcalResolution
86  )
87  {
88  ReaderLCEB_=LCorrForestEB;
89  ReaderLCEE_=LCorrForestEE;
90  ReaderGCEB_=GCorrForestBarrel;
91  ReaderGCEEhR9_=GCorrForestEndcapHr9;
92  ReaderGCEElR9_=GCorrForestEndcapLr9;
93  ReaderRes_=PFEcalResolution;
94  }
95  void setnPU(int nVtx){
96  nVtx_=nVtx;
97  }
98  void setPhotonPrimaryVtx(const reco::Vertex& primary){
99  primaryVertex_ = & primary;
100  }
101  //check candidate validity
102  bool isEGValidCandidate(const reco::PFBlockRef& blockRef,
103  std::vector< bool >& active
104  // std::auto_ptr< reco::PFCandidateCollection > &pfElectronCandidates_
105  ){
106  RunPFEG(blockRef,active);
107  return (egCandidate_.size()>0);
108  };
109 
110  //get PFCandidate collection
111  const std::vector<reco::PFCandidate>& getCandidates() {return egCandidate_;};
112 
113  //get the PFCandidateExtra (for all candidates)
114  const std::vector< reco::PFCandidateEGammaExtra>& getEGExtra() {return egExtra_;};
115 
116  //get electron PFCandidate
117 
118 
119 private:
120  typedef std::map< unsigned int, std::vector<unsigned int> > AssMap;
121 
126  };
127 
128 
129  bool SetLinks(const reco::PFBlockRef& blockRef,
130  AssMap& associatedToGsf_,
131  AssMap& associatedToBrems_,
132  AssMap& associatedToEcal_,
133  std::vector<bool>& active,
134  const reco::Vertex & primaryVertex);
135 
136  unsigned int whichTrackAlgo(const reco::TrackRef& trackRef);
137 
138  bool isPrimaryTrack(const reco::PFBlockElementTrack& KfEl,
139  const reco::PFBlockElementGsfTrack& GsfEl);
140 
141  void AddElectronElements(unsigned int gsf_index,
142  std::vector<unsigned int> &elemsToLock,
143  const reco::PFBlockRef& blockRef,
144  AssMap& associatedToGsf_,
145  AssMap& associatedToBrems_,
146  AssMap& associatedToEcal_);
147 
148 
149  bool AddElectronCandidate(unsigned int gsf_index,
150  reco::SuperClusterRef scref,
151  std::vector<unsigned int> &elemsToLock,
152  const reco::PFBlockRef& blockRef,
153  AssMap& associatedToGsf_,
154  AssMap& associatedToBrems_,
155  AssMap& associatedToEcal_,
156  std::vector<bool>& active);
157 
158  //Data members from PFElectronAlgo
159 // std::vector<reco::PFCandidate> elCandidate_;
160 // std::vector<reco::PFCandidate> allElCandidate_;
161  //std::map<unsigned int,std::vector<reco::PFCandidate> > electronConstituents_;
162  //std::vector<double> BDToutput_;
163  //std::vector<reco::PFCandidateElectronExtra > electronExtra_;
164  std::vector<bool> lockExtraKf_;
165  std::vector<bool> GsfTrackSingleEcal_;
166  std::vector< std::pair <unsigned int, unsigned int> > fifthStepKfTrack_;
167  std::vector< std::pair <unsigned int, unsigned int> > convGsfTrack_;
168 
169 
170  TMVA::Reader *tmvaReaderEle_;
171  double mvaEleCut_;
172  boost::shared_ptr<PFSCEnergyCalibration> thePFSCEnergyCalibration_;
173  boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_;
183  unsigned int nTrackIsoForEgammaSC_;
185 
186  const char *mvaWeightFile_;
187 
188  // New BDT observables
189  // Normalization
191 
192  // Pure Tracking observ.
195  // int nhit_gsf,nhit_kf;
197 
198  // Tracker-Ecal observ.
201  float SigmaEtaEta;
202  //int lateBrem,firstBrem,earlyBrem;
205 
206  bool isvalid_;
207 
208  //const std::vector<reco::GsfElectron> * theGsfElectrons_;
209  //end of data members from PFElectronAlgo
210 
211 
212  //bool isvalid_; // is set to TRUE when a valid PhotonCandidate is found in a PFBlock
213  verbosityLevel verbosityLevel_; /* Verbosity Level:
214  ............... 0: Say nothing at all
215  ............... 1: Print summary about found PhotonCadidates only
216  ............... 2: Chatty mode
217  */
218  //FOR SINGLE LEG MVA:
219  double MVACUT;
220  bool useReg_;
222  TMVA::Reader *tmvaReader_;
226 
232 
233 // boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_;
236  std::vector<int>match_ind;
237  //std::auto_ptr< reco::PFCandidateCollection > permElectronCandidates_;
238 
239  std::vector< reco::PFCandidate >permElectronCandidates_;
240  float nlost, nlayers;
242  double mvaValue;
243  //for Cluster Shape Calculations:
244  float e5x5Map[5][5];
245 
246  //For Local Containment Corrections:
250  float CrysX_, CrysY_;
251  float EB;
252  //Cluster Shapes:
255  float e2x5Max_;
256  //For Global Corrections:
259  float TotPS1_, TotPS2_;
260  float nVtx_;
261  //for Material Map
262  TH2D* X0_sum;
263  TH2D* X0_inner;
264  TH2D* X0_middle;
265  TH2D* X0_outer;
267  //for PileUP
269 
270  std::vector<unsigned int> AddFromElectron_;
271 
272  std::vector<reco::PFCandidate> egCandidate_;
273 // std::vector<reco::CaloCluser> ebeeCluster_;
274 // std::vector<reco::PreshowerCluser> esCluster_;
275 // std::vector<reco::SuperCluser> sCluster_;
276  std::vector<reco::PFCandidateEGammaExtra> egExtra_;
277 
278 
279 
280 
281 
282  void RunPFEG(const reco::PFBlockRef& blockRef,
283  std::vector< bool >& active
284  );
285 
286  bool EvaluateSingleLegMVA(const reco::PFBlockRef& blockref,
287  const reco::Vertex& primaryvtx,
288  unsigned int track_index);
289 
290  double ClustersPhiRMS(std::vector<reco::CaloCluster>PFClusters, float PFPhoPhi);
291  float EvaluateLCorrMVA(reco::PFClusterRef clusterRef );
292  float EvaluateGCorrMVA(reco::PFCandidate, std::vector<reco::CaloCluster>PFClusters);
293  float EvaluateResMVA(reco::PFCandidate,std::vector<reco::CaloCluster>PFClusters );
294  std::vector<int> getPFMustacheClus(int nClust, std::vector<float>& ClustEt, std::vector<float>& ClustEta, std::vector<float>& ClustPhi);
295  void EarlyConversion(
296  //std::auto_ptr< reco::PFCandidateCollection >
297  //&pfElectronCandidates_,
298  std::vector<reco::PFCandidate>&
299  tempElectronCandidates,
301  );
302 };
303 
304 #endif
std::vector< reco::PFCandidateEGammaExtra > egExtra_
Definition: PFEGammaAlgo.h:276
float SCEtaWidth_
Definition: PFEGammaAlgo.h:257
float e5x5Map[5][5]
Definition: PFEGammaAlgo.h:244
float EtotBremPinPoutMode
Definition: PFEGammaAlgo.h:199
std::vector< int > match_ind
Definition: PFEGammaAlgo.h:236
double mvaValue
Definition: PFEGammaAlgo.h:242
bool EvaluateSingleLegMVA(const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
bool usePFSCEleCalib_
Definition: PFEGammaAlgo.h:175
unsigned int whichTrackAlgo(const reco::TrackRef &trackRef)
boost::shared_ptr< PFSCEnergyCalibration > thePFSCEnergyCalibration_
Definition: PFEGammaAlgo.h:172
const char * mvaWeightFile_
Definition: PFEGammaAlgo.h:186
bool useEGammaSupercluster_
Definition: PFEGammaAlgo.h:177
std::vector< std::pair< unsigned int, unsigned int > > fifthStepKfTrack_
Definition: PFEGammaAlgo.h:166
const std::vector< reco::PFCandidate > & getCandidates()
Definition: PFEGammaAlgo.h:111
void RunPFEG(const reco::PFBlockRef &blockRef, std::vector< bool > &active)
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)
double sumPtTrackIsoSlopeForPhoton_
Definition: PFEGammaAlgo.h:235
bool applyCrackCorrections_
Definition: PFEGammaAlgo.h:174
float e2x5Bottom_
Definition: PFEGammaAlgo.h:253
float EGsfPoutMode
Definition: PFEGammaAlgo.h:199
std::vector< bool > lockExtraKf_
Definition: PFEGammaAlgo.h:164
const reco::Vertex * primaryVertex_
Definition: PFEGammaAlgo.h:221
const GBRForest * ReaderGC_
Definition: PFEGammaAlgo.h:224
float Mustache_Et_out_
Definition: PFEGammaAlgo.h:268
bool isPrimaryTrack(const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
float DEtaGsfEcalClust
Definition: PFEGammaAlgo.h:200
void setPhotonPrimaryVtx(const reco::Vertex &primary)
Definition: PFEGammaAlgo.h:98
const GBRForest * ReaderGCEElR9_
Definition: PFEGammaAlgo.h:231
void EarlyConversion(std::vector< reco::PFCandidate > &tempElectronCandidates, const reco::PFBlockElementSuperCluster *sc)
const GBRForest * ReaderGCEB_
Definition: PFEGammaAlgo.h:229
TH2D * X0_outer
Definition: PFEGammaAlgo.h:265
float Clus5x5ratio_
Definition: PFEGammaAlgo.h:247
float PFPhoEtCorr_
Definition: PFEGammaAlgo.h:257
void setGBRForest(const GBRForest *LCorrForest, const GBRForest *GCorrForest, const GBRForest *ResForest)
Definition: PFEGammaAlgo.h:69
float e2x5Right_
Definition: PFEGammaAlgo.h:253
boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_
Definition: PFEGammaAlgo.h:173
std::vector< bool > GsfTrackSingleEcal_
Definition: PFEGammaAlgo.h:165
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_)
float DPtOverPt_gsf
Definition: PFEGammaAlgo.h:193
const GBRForest * ReaderGCEEhR9_
Definition: PFEGammaAlgo.h:230
std::vector< reco::PFCandidate > permElectronCandidates_
Definition: PFEGammaAlgo.h:239
float EvaluateLCorrMVA(reco::PFClusterRef clusterRef)
double ClustersPhiRMS(std::vector< reco::CaloCluster >PFClusters, float PFPhoPhi)
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
void setnPU(int nVtx)
Definition: PFEGammaAlgo.h:95
double sumPtTrackIsoForEgammaSC_endcap_
Definition: PFEGammaAlgo.h:182
const GBRForest * ReaderLCEB_
Definition: PFEGammaAlgo.h:227
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)
float DPtOverPt_kf
Definition: PFEGammaAlgo.h:193
float dPtOverPt_gsf
Definition: PFEGammaAlgo.h:193
const std::vector< reco::PFCandidateEGammaExtra > & getEGExtra()
Definition: PFEGammaAlgo.h:114
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
float EvaluateResMVA(reco::PFCandidate, std::vector< reco::CaloCluster >PFClusters)
double coneEcalIsoForEgammaSC_
Definition: PFEGammaAlgo.h:180
bool isEGValidCandidate(const reco::PFBlockRef &blockRef, std::vector< bool > &active)
Definition: PFEGammaAlgo.h:102
float SigmaEtaEta
Definition: PFEGammaAlgo.h:201
std::vector< std::pair< unsigned int, unsigned int > > convGsfTrack_
Definition: PFEGammaAlgo.h:167
TMVA::Reader * tmvaReaderEle_
Definition: PFEGammaAlgo.h:170
float EtotPinMode
Definition: PFEGammaAlgo.h:199
const GBRForest * ReaderLCEE_
Definition: PFEGammaAlgo.h:228
std::map< unsigned int, std::vector< unsigned int > > AssMap
Definition: PFEGammaAlgo.h:114
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:35
std::vector< int > getPFMustacheClus(int nClust, std::vector< float > &ClustEt, std::vector< float > &ClustEta, std::vector< float > &ClustPhi)
double sumEtEcalIsoForEgammaSC_endcap_
Definition: PFEGammaAlgo.h:179
TH2D * X0_inner
Definition: PFEGammaAlgo.h:263
double sumEtEcalIsoForEgammaSC_barrel_
Definition: PFEGammaAlgo.h:178
const GBRForest * ReaderRes_
Definition: PFEGammaAlgo.h:225
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
const GBRForest * ReaderLC_
Definition: PFEGammaAlgo.h:223
void setGBRForest(const GBRForest *LCorrForestEB, const GBRForest *LCorrForestEE, const GBRForest *GCorrForestBarrel, const GBRForest *GCorrForestEndcapHr9, const GBRForest *GCorrForestEndcapLr9, const GBRForest *PFEcalResolution)
Definition: PFEGammaAlgo.h:79
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: PFEGammaAlgo.cc:39
std::vector< reco::PFCandidate > egCandidate_
Definition: PFEGammaAlgo.h:272
float PFCrysEtaCrack_
Definition: PFEGammaAlgo.h:247