CMS 3D CMS Logo

PFElectronAlgo.h
Go to the documentation of this file.
1 #ifndef PFProducer_PFElectronAlgo_H
2 #define PFProducer_PFElectronAlgo_H
3 
14 #include "TMVA/Reader.h"
15 #include "boost/shared_ptr.hpp"
16 #include <iostream>
17 
18 
21 
22 namespace reco {
23 class PFCandidate;
24 }
25 
27  public:
28 
29  //constructor
30  PFElectronAlgo(const double mvaEleCut,
31  std::string mvaWeightFileEleID,
32  const boost::shared_ptr<PFSCEnergyCalibration>& thePFSCEnergyCalibration,
33  const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
35  bool usePFSCEleCalib,
36  bool useEGElectrons,
43  unsigned int nTrackIsoForEgammaSC,
45 
46  //destructor
47  ~PFElectronAlgo(){delete tmvaReader_;};
48 
49  //check candidate validity
51  std::vector<bool>& active,
53  {
54  isvalid_=false;
55  RunPFElectron(blockRef,active, primaryVertex);
56  return isvalid_;};
57 
58  //get electron PFCandidate
59  const std::vector<reco::PFCandidate>& getElectronCandidates() {return elCandidate_;};
60 
61  //get all electron PFCandidate
62  const std::vector<reco::PFCandidate>& getAllElectronCandidates() {return allElCandidate_;};
63 
64  //get the electron PFCandidateExtra (for all candidates)
65  const std::vector< reco::PFCandidateElectronExtra>& getElectronExtra() {return electronExtra_;};
66 
67  // retrieve the list of pre-defined e/g electrons
68  void setEGElectronCollection(const reco::GsfElectronCollection & egelectrons);
69 
70  private:
71  typedef std::map< unsigned int, std::vector<unsigned int> > AssMap;
72 
73  void RunPFElectron(const reco::PFBlockRef& blockRef,
74  std::vector<bool>& active,
75  const reco::Vertex & primaryVertex);
76 
77  unsigned int FindClosestElement(const unsigned int iele,
78  std::multimap<double, unsigned int>& Elems,
79  float& chi2cut,
80  std::vector<bool>& active,
81  const reco::PFBlockRef& blockRef);
82 
83  bool SetLinks(const reco::PFBlockRef& blockRef,
84  AssMap& associatedToGsf_,
85  AssMap& associatedToBrems_,
86  AssMap& associatedToEcal_,
87  std::vector<bool>& active,
88  const reco::Vertex & primaryVertex);
89 
90  void SetIDOutputs(const reco::PFBlockRef& blockRef,
91  AssMap& associatedToGsf_,
92  AssMap& associatedToBrems_,
93  AssMap& associatedToEcal_,
94  const reco::Vertex & primaryVertex);
95 
96  void SetCandidates(const reco::PFBlockRef& blockRef,
97  AssMap& associatedToGsf_,
98  AssMap& associatedToBrems_,
99  AssMap& associatedToEcal_);
100 
101  void SetActive(const reco::PFBlockRef& blockRef,
102  AssMap& associatedToGsf_,
103  AssMap& associatedToBrems_,
104  AssMap& associatedToEcal_,
105  std::vector<bool>& active);
106 
107 
108 
109  bool isPrimaryTrack(const reco::PFBlockElementTrack& KfEl,
110  const reco::PFBlockElementGsfTrack& GsfEl);
111 
112  std::vector<reco::PFCandidate> elCandidate_;
113  std::vector<reco::PFCandidate> allElCandidate_;
114  std::map<unsigned int,std::vector<reco::PFCandidate> > electronConstituents_;
115  std::vector<double> BDToutput_;
116  std::vector<reco::PFCandidateElectronExtra > electronExtra_;
117  std::vector<bool> lockExtraKf_;
118  std::vector<bool> GsfTrackSingleEcal_;
119  std::vector< std::pair <unsigned int, unsigned int> > fifthStepKfTrack_;
120  std::vector< std::pair <unsigned int, unsigned int> > convGsfTrack_;
121 
122 
123  TMVA::Reader *tmvaReader_;
124  double mvaEleCut_;
125  boost::shared_ptr<PFSCEnergyCalibration> thePFSCEnergyCalibration_;
126  boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_;
136  unsigned int nTrackIsoForEgammaSC_;
138 
139  const char *mvaWeightFile_;
140 
141  // New BDT observables
142  // Normalization
143  float lnPt_gsf,Eta_gsf;
144 
145  // Pure Tracking observ.
146  float dPtOverPt_gsf,chi2_gsf,DPtOverPt_gsf,
147  chi2_kf,DPtOverPt_kf;
148  // int nhit_gsf,nhit_kf;
149  float nhit_gsf,nhit_kf;
150 
151  // Tracker-Ecal observ.
152  float EtotPinMode,EGsfPoutMode,EtotBremPinPoutMode;
154  float SigmaEtaEta;
155  //int lateBrem,firstBrem,earlyBrem;
156  float lateBrem,firstBrem,earlyBrem;
157  float HOverHE,HOverPin;
158 
159  bool isvalid_;
160 
161  const std::vector<reco::GsfElectron> * theGsfElectrons_;
162 };
163 
164 
165 #endif
std::vector< std::pair< unsigned int, unsigned int > > fifthStepKfTrack_
std::map< unsigned int, std::vector< unsigned int > > AssMap
const std::vector< reco::PFCandidate > & getAllElectronCandidates()
std::vector< std::pair< unsigned int, unsigned int > > convGsfTrack_
const char * mvaWeightFile_
std::vector< reco::PFCandidateElectronExtra > electronExtra_
const std::vector< reco::GsfElectron > * theGsfElectrons_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
double coneEcalIsoForEgammaSC_
TMVA::Reader * tmvaReader_
const std::vector< reco::PFCandidateElectronExtra > & getElectronExtra()
double sumEtEcalIsoForEgammaSC_barrel_
std::vector< bool > lockExtraKf_
std::vector< double > BDToutput_
double sumEtEcalIsoForEgammaSC_endcap_
std::map< unsigned int, std::vector< reco::PFCandidate > > electronConstituents_
const std::vector< reco::PFCandidate > & getElectronCandidates()
double sumPtTrackIsoForEgammaSC_endcap_
boost::shared_ptr< PFSCEnergyCalibration > thePFSCEnergyCalibration_
double coneTrackIsoForEgammaSC_
std::vector< bool > GsfTrackSingleEcal_
bool isElectronValidCandidate(const reco::PFBlockRef &blockRef, std::vector< bool > &active, const reco::Vertex &primaryVertex)
fixed size matrix
double sumPtTrackIsoForEgammaSC_barrel_
unsigned int nTrackIsoForEgammaSC_
boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_
std::vector< reco::PFCandidate > elCandidate_
bool applyCrackCorrections_
bool useEGammaSupercluster_
std::vector< reco::PFCandidate > allElCandidate_