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