CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/RecoParticleFlow/PFProducer/interface/PFElectronAlgo.h

Go to the documentation of this file.
00001 #ifndef PFProducer_PFElectronAlgo_H
00002 #define PFProducer_PFElectronAlgo_H
00003 
00004 #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
00005 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
00006 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00007 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateElectronExtra.h"
00008 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00009 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00010 #include "DataFormats/Common/interface/Handle.h"
00011 #include "DataFormats/Common/interface/OrphanHandle.h"
00012 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementGsfTrack.h"
00013 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
00014 #include "TMVA/Reader.h"
00015 #include <iostream>
00016 
00017 
00018 class PFSCEnergyCalibration;
00019 class PFEnergyCalibration;
00020 
00021 namespace reco { 
00022 class PFCandidate;
00023 }
00024 
00025 class PFElectronAlgo {
00026  public:
00027   
00028   //constructor
00029   PFElectronAlgo(const double mvaEleCut,
00030                  std::string  mvaWeightFileEleID,
00031                  const boost::shared_ptr<PFSCEnergyCalibration>& thePFSCEnergyCalibration,
00032                  const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
00033                  bool applyCrackCorrections,
00034                  bool usePFSCEleCalib,
00035                  bool useEGElectrons,
00036                  bool useEGammaSupercluster,
00037                  double sumEtEcalIsoForEgammaSC_barrel,
00038                  double sumEtEcalIsoForEgammaSC_endcap,
00039                  double coneEcalIsoForEgammaSC,
00040                  double sumPtTrackIsoForEgammaSC_barrel,
00041                  double sumPtTrackIsoForEgammaSC_endcap,
00042                  unsigned int nTrackIsoForEgammaSC,
00043                  double coneTrackIsoForEgammaSC);
00044 
00045   //destructor
00046   ~PFElectronAlgo(){delete tmvaReader_;};
00047   
00048   //check candidate validity
00049   bool isElectronValidCandidate(const reco::PFBlockRef&  blockRef,
00050                                 std::vector<bool>&  active)
00051   {
00052     isvalid_=false;
00053     RunPFElectron(blockRef,active);
00054     return isvalid_;};
00055   
00056   //get electron PFCandidate
00057   const std::vector<reco::PFCandidate>& getElectronCandidates() {return elCandidate_;};
00058 
00059   //get all electron PFCandidate
00060   const std::vector<reco::PFCandidate>& getAllElectronCandidates() {return allElCandidate_;};
00061 
00062   //get the electron PFCandidateExtra (for all candidates)
00063   const std::vector< reco::PFCandidateElectronExtra>& getElectronExtra() {return electronExtra_;};
00064 
00065   // retrieve the list of pre-defined e/g electrons
00066   void setEGElectronCollection(const reco::GsfElectronCollection & egelectrons);
00067 
00068  private: 
00069   typedef  std::map< unsigned int, std::vector<unsigned int> >  AssMap;
00070 
00071   void RunPFElectron(const reco::PFBlockRef&  blockRef,
00072                      std::vector<bool>& active);
00073 
00074   unsigned int FindClosestElement(const unsigned int iele,
00075                           std::multimap<double, unsigned int>& Elems, 
00076                           float& chi2cut,
00077                           std::vector<bool>& active,
00078                           const reco::PFBlockRef&  blockRef);
00079   
00080   bool SetLinks(const reco::PFBlockRef&  blockRef,
00081                 AssMap& associatedToGsf_,
00082                 AssMap& associatedToBrems_,
00083                 AssMap& associatedToEcal_,
00084                 std::vector<bool>& active);
00085   
00086   void SetIDOutputs(const reco::PFBlockRef&  blockRef,
00087                     AssMap& associatedToGsf_,
00088                     AssMap& associatedToBrems_,
00089                     AssMap& associatedToEcal_);
00090   
00091   void SetCandidates(const reco::PFBlockRef&  blockRef,
00092                      AssMap& associatedToGsf_,
00093                      AssMap& associatedToBrems_,
00094                      AssMap& associatedToEcal_);
00095   
00096   void SetActive(const reco::PFBlockRef&  blockRef, 
00097                  AssMap& associatedToGsf_, 
00098                  AssMap& associatedToBrems_, 
00099                  AssMap& associatedToEcal_,
00100                  std::vector<bool>& active);
00101   
00102   unsigned int whichTrackAlgo(const reco::TrackRef& trackRef);
00103 
00104   bool isPrimaryTrack(const reco::PFBlockElementTrack& KfEl,
00105                       const reco::PFBlockElementGsfTrack& GsfEl);
00106 
00107   std::vector<reco::PFCandidate> elCandidate_;
00108   std::vector<reco::PFCandidate> allElCandidate_;
00109   std::map<unsigned int,std::vector<reco::PFCandidate> > electronConstituents_;
00110   std::vector<double> BDToutput_;
00111   std::vector<reco::PFCandidateElectronExtra > electronExtra_;
00112   std::vector<bool> lockExtraKf_;
00113   std::vector<bool> GsfTrackSingleEcal_;
00114   std::vector< std::pair <unsigned int, unsigned int> > fifthStepKfTrack_;
00115   std::vector< std::pair <unsigned int, unsigned int> > convGsfTrack_;
00116 
00117   
00118   TMVA::Reader    *tmvaReader_;
00119   double mvaEleCut_;
00120   boost::shared_ptr<PFSCEnergyCalibration> thePFSCEnergyCalibration_; 
00121   boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_; 
00122   bool applyCrackCorrections_;
00123   bool usePFSCEleCalib_;
00124   bool useEGElectrons_;
00125   bool useEGammaSupercluster_;
00126   double sumEtEcalIsoForEgammaSC_barrel_;
00127   double sumEtEcalIsoForEgammaSC_endcap_;
00128   double coneEcalIsoForEgammaSC_;
00129   double sumPtTrackIsoForEgammaSC_barrel_;
00130   double sumPtTrackIsoForEgammaSC_endcap_;
00131   unsigned int nTrackIsoForEgammaSC_;
00132   double coneTrackIsoForEgammaSC_;
00133 
00134   const char  *mvaWeightFile_;
00135 
00136   // New BDT observables
00137   // Normalization 
00138   float lnPt_gsf,Eta_gsf;
00139   
00140   // Pure Tracking observ.
00141   float dPtOverPt_gsf,chi2_gsf,DPtOverPt_gsf,
00142     chi2_kf,DPtOverPt_kf;
00143   //  int nhit_gsf,nhit_kf;
00144   float nhit_gsf,nhit_kf;
00145   
00146   // Tracker-Ecal observ. 
00147   float EtotPinMode,EGsfPoutMode,EtotBremPinPoutMode;
00148   float DEtaGsfEcalClust;
00149   float SigmaEtaEta; 
00150   //int lateBrem,firstBrem,earlyBrem;
00151   float lateBrem,firstBrem,earlyBrem;
00152   float HOverHE,HOverPin;
00153 
00154   bool isvalid_;
00155 
00156   const std::vector<reco::GsfElectron> * theGsfElectrons_;
00157 };
00158 
00159 
00160 #endif