CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoParticleFlow/PFProducer/plugins/PFElectronTranslator.h

Go to the documentation of this file.
00001 #ifndef RecoParticleFlow_PFProducer_PFElectronTranslator_H
00002 #define RecoParticleFlow_PFProducer_PFElectronTranslator_H
00003 #include "FWCore/Framework/interface/EDProducer.h"
00004 #include "FWCore/Framework/interface/Frameworkfwd.h"
00005 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00006 #include "FWCore/Framework/interface/MakerMacros.h"
00007 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementFwd.h"
00008 #include "DataFormats/Common/interface/ValueMap.h"
00009 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00010 #include "DataFormats/EgammaReco/interface/PreshowerClusterFwd.h"
00011 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00012 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00013 #include "DataFormats/EgammaCandidates/interface/GsfElectronCoreFwd.h"
00014 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
00015 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
00016 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
00017 #include <iostream>
00018 #include <string>
00019 #include <map>
00020 
00021 
00022 
00023 class PFElectronTranslator : public edm::EDProducer
00024 {
00025  public:
00026   explicit PFElectronTranslator(const edm::ParameterSet&);
00027   ~PFElectronTranslator();
00028   
00029   virtual void produce(edm::Event &, const edm::EventSetup&);
00030   virtual void beginRun(edm::Run & run,const edm::EventSetup & c);
00031 
00032   typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
00033 
00034 
00035  private:
00036   // to retrieve the collection from the event
00037   bool fetchCandidateCollection(edm::Handle<reco::PFCandidateCollection>& c, 
00038                                 const edm::InputTag& tag, 
00039                                 const edm::Event& iEvent) const;
00040   // to retrieve the collection from the event
00041   void fetchGsfCollection(edm::Handle<reco::GsfTrackCollection>& c, 
00042                           const edm::InputTag& tag, 
00043                           const edm::Event& iEvent) const ;
00044 
00045   // makes a basic cluster from PFBlockElement and add it to the collection ; the corrected energy is taken
00046   // from the PFCandidate
00047   void createBasicCluster(const reco::PFBlockElement & ,  reco::BasicClusterCollection & basicClusters,
00048                           std::vector<const reco::PFCluster *> &,
00049                           const reco::PFCandidate & coCandidate) const;
00050   // makes a preshower cluster from of PFBlockElement and add it to the collection
00051   void createPreshowerCluster(const reco::PFBlockElement & PFBE, 
00052                               reco::PreshowerClusterCollection& preshowerClusters,
00053                               unsigned plane) const;
00054 
00055   // make a super cluster from its ingredients and add it to the collection
00056   void createSuperClusters(const reco::PFCandidateCollection &,
00057                           reco::SuperClusterCollection &superClusters) const;
00058 
00059   // make GsfElectronCores from ingredients
00060   void createGsfElectronCores(reco::GsfElectronCoreCollection &) const;
00061 
00062   // create the basic cluster Ptr
00063   void createBasicClusterPtrs(const edm::OrphanHandle<reco::BasicClusterCollection> & basicClustersHandle );
00064 
00065   // create the preshower cluster Refs
00066   void createPreshowerClusterPtrs(const edm::OrphanHandle<reco::PreshowerClusterCollection> & preshowerClustersHandle );
00067 
00068   // create the super cluster Refs
00069   void createSuperClusterGsfMapRefs(const edm::OrphanHandle<reco::SuperClusterCollection> & superClustersHandle );
00070 
00071   // create the GsfElectronCore Refs
00072   void createGsfElectronCoreRefs(const edm::OrphanHandle<reco::GsfElectronCoreCollection> & gsfElectronCoreHandle);
00073 
00074   // create the GsfElectrons
00075   void createGsfElectrons(const reco::PFCandidateCollection &,
00076                           const IsolationValueMaps& isolationValues,
00077                           reco::GsfElectronCollection &);
00078 
00079   // The following methods are used to fill the value maps
00080   void fillMVAValueMap(edm::Event& iEvent, edm::ValueMap<float>::Filler & filler) ;
00081   void fillValueMap(edm::Event& iEvent, edm::ValueMap<float>::Filler & filler) const;
00082   void fillSCRefValueMap(edm::Event& iEvent, 
00083                          edm::ValueMap<reco::SuperClusterRef>::Filler & filler) const;
00084   void getAmbiguousGsfTracks(const reco::PFBlockElement & PFBE, std::vector<reco::GsfTrackRef>& ) const ; 
00085 
00086 
00087   const reco::PFCandidate & correspondingDaughterCandidate(const reco::PFCandidate & cand, const reco::PFBlockElement & pfbe) const;
00088  private:
00089   edm::InputTag inputTagPFCandidates_;
00090   edm::InputTag inputTagPFCandidateElectrons_;
00091   edm::InputTag inputTagGSFTracks_;
00092   std::vector<edm::InputTag> inputTagIsoVals_;
00093   std::string PFBasicClusterCollection_;
00094   std::string PFPreshowerClusterCollection_;
00095   std::string PFSuperClusterCollection_;
00096   std::string PFMVAValueMap_;
00097   std::string PFSCValueMap_;
00098   std::string GsfElectronCoreCollection_;
00099   std::string GsfElectronCollection_;
00100   double MVACut_;
00101 
00102   // The following vectors correspond to a GSF track, but the order is not 
00103   // the order of the tracks in the GSF track collection
00104   std::vector<reco::GsfTrackRef> GsfTrackRef_;  
00105   // the list of candidatePtr
00106   std::vector<reco::CandidatePtr> CandidatePtr_;
00107   //the list of KfTrackRef
00108   std::vector<reco::TrackRef> kfTrackRef_;
00109   // the list of ambiguous tracks
00110   std::vector<std::vector<reco::GsfTrackRef> > ambiguousGsfTracks_;
00111   // the collection of basic clusters associated to a GSF track
00112   std::vector<reco::BasicClusterCollection> basicClusters_;
00113   // the correcsponding PFCluster ref
00114   std::vector<std::vector<const reco::PFCluster *> > pfClusters_;
00115   // the collection of preshower clusters associated to a GSF track
00116   std::vector<reco::PreshowerClusterCollection> preshowerClusters_;
00117   // the super cluster collection (actually only one) associated to a GSF trck
00118   std::vector<reco::SuperClusterCollection> superClusters_;
00119   // the references to the basic clusters associated to a GSF track
00120   std::vector<reco::CaloClusterPtrVector> basicClusterPtr_;
00121   // the references to the basic clusters associated to a GSF track
00122   std::vector<reco::CaloClusterPtrVector> preshowerClusterPtr_;
00123   // the references to the GsfElectonCore associated to a GSF track
00124   std::vector<reco::GsfElectronCoreRef> gsfElectronCoreRefs_;
00125   // keep track of the index of the PF Candidate
00126   std::vector<int> gsfPFCandidateIndex_;
00127   // maps to ease the creation of the Value Maps 
00128   std::map<reco::GsfTrackRef,reco::SuperClusterRef> scMap_;
00129   std::map<reco::GsfTrackRef,float> gsfMvaMap_;
00130 
00131   bool emptyIsOk_;
00132 
00133 };
00134 #endif