CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/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                                 const reco::Vertex & primaryVertex)
00052   {
00053     isvalid_=false;
00054     RunPFElectron(blockRef,active, primaryVertex);
00055     return isvalid_;};
00056   
00057   //get electron PFCandidate
00058   const std::vector<reco::PFCandidate>& getElectronCandidates() {return elCandidate_;};
00059 
00060   //get all electron PFCandidate
00061   const std::vector<reco::PFCandidate>& getAllElectronCandidates() {return allElCandidate_;};
00062 
00063   //get the electron PFCandidateExtra (for all candidates)
00064   const std::vector< reco::PFCandidateElectronExtra>& getElectronExtra() {return electronExtra_;};
00065 
00066   // retrieve the list of pre-defined e/g electrons
00067   void setEGElectronCollection(const reco::GsfElectronCollection & egelectrons);
00068 
00069  private: 
00070   typedef  std::map< unsigned int, std::vector<unsigned int> >  AssMap;
00071 
00072   void RunPFElectron(const reco::PFBlockRef&  blockRef,
00073                      std::vector<bool>& active,
00074                          const reco::Vertex & primaryVertex);
00075 
00076   unsigned int FindClosestElement(const unsigned int iele,
00077                           std::multimap<double, unsigned int>& Elems, 
00078                           float& chi2cut,
00079                           std::vector<bool>& active,
00080                           const reco::PFBlockRef&  blockRef);
00081   
00082   bool SetLinks(const reco::PFBlockRef&  blockRef,
00083                 AssMap& associatedToGsf_,
00084                 AssMap& associatedToBrems_,
00085                 AssMap& associatedToEcal_,
00086                 std::vector<bool>& active,
00087                 const reco::Vertex & primaryVertex);
00088   
00089   void SetIDOutputs(const reco::PFBlockRef&  blockRef,
00090                     AssMap& associatedToGsf_,
00091                     AssMap& associatedToBrems_,
00092                     AssMap& associatedToEcal_,
00093                         const reco::Vertex & primaryVertex);
00094   
00095   void SetCandidates(const reco::PFBlockRef&  blockRef,
00096                      AssMap& associatedToGsf_,
00097                      AssMap& associatedToBrems_,
00098                      AssMap& associatedToEcal_);
00099   
00100   void SetActive(const reco::PFBlockRef&  blockRef, 
00101                  AssMap& associatedToGsf_, 
00102                  AssMap& associatedToBrems_, 
00103                  AssMap& associatedToEcal_,
00104                  std::vector<bool>& active);
00105   
00106   unsigned int whichTrackAlgo(const reco::TrackRef& trackRef);
00107 
00108   bool isPrimaryTrack(const reco::PFBlockElementTrack& KfEl,
00109                       const reco::PFBlockElementGsfTrack& GsfEl);
00110 
00111   std::vector<reco::PFCandidate> elCandidate_;
00112   std::vector<reco::PFCandidate> allElCandidate_;
00113   std::map<unsigned int,std::vector<reco::PFCandidate> > electronConstituents_;
00114   std::vector<double> BDToutput_;
00115   std::vector<reco::PFCandidateElectronExtra > electronExtra_;
00116   std::vector<bool> lockExtraKf_;
00117   std::vector<bool> GsfTrackSingleEcal_;
00118   std::vector< std::pair <unsigned int, unsigned int> > fifthStepKfTrack_;
00119   std::vector< std::pair <unsigned int, unsigned int> > convGsfTrack_;
00120 
00121   
00122   TMVA::Reader    *tmvaReader_;
00123   double mvaEleCut_;
00124   boost::shared_ptr<PFSCEnergyCalibration> thePFSCEnergyCalibration_; 
00125   boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_; 
00126   bool applyCrackCorrections_;
00127   bool usePFSCEleCalib_;
00128   bool useEGElectrons_;
00129   bool useEGammaSupercluster_;
00130   double sumEtEcalIsoForEgammaSC_barrel_;
00131   double sumEtEcalIsoForEgammaSC_endcap_;
00132   double coneEcalIsoForEgammaSC_;
00133   double sumPtTrackIsoForEgammaSC_barrel_;
00134   double sumPtTrackIsoForEgammaSC_endcap_;
00135   unsigned int nTrackIsoForEgammaSC_;
00136   double coneTrackIsoForEgammaSC_;
00137 
00138   const char  *mvaWeightFile_;
00139 
00140   // New BDT observables
00141   // Normalization 
00142   float lnPt_gsf,Eta_gsf;
00143   
00144   // Pure Tracking observ.
00145   float dPtOverPt_gsf,chi2_gsf,DPtOverPt_gsf,
00146     chi2_kf,DPtOverPt_kf;
00147   //  int nhit_gsf,nhit_kf;
00148   float nhit_gsf,nhit_kf;
00149   
00150   // Tracker-Ecal observ. 
00151   float EtotPinMode,EGsfPoutMode,EtotBremPinPoutMode;
00152   float DEtaGsfEcalClust;
00153   float SigmaEtaEta; 
00154   //int lateBrem,firstBrem,earlyBrem;
00155   float lateBrem,firstBrem,earlyBrem;
00156   float HOverHE,HOverPin;
00157 
00158   bool isvalid_;
00159 
00160   const std::vector<reco::GsfElectron> * theGsfElectrons_;
00161 };
00162 
00163 
00164 #endif