CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/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   bool checkStatusFlag_;
00102 
00103   // The following vectors correspond to a GSF track, but the order is not 
00104   // the order of the tracks in the GSF track collection
00105   std::vector<reco::GsfTrackRef> GsfTrackRef_;  
00106   // the list of candidatePtr
00107   std::vector<reco::CandidatePtr> CandidatePtr_;
00108   //the list of KfTrackRef
00109   std::vector<reco::TrackRef> kfTrackRef_;
00110   // the list of ambiguous tracks
00111   std::vector<std::vector<reco::GsfTrackRef> > ambiguousGsfTracks_;
00112   // the collection of basic clusters associated to a GSF track
00113   std::vector<reco::BasicClusterCollection> basicClusters_;
00114   // the correcsponding PFCluster ref
00115   std::vector<std::vector<const reco::PFCluster *> > pfClusters_;
00116   // the collection of preshower clusters associated to a GSF track
00117   std::vector<reco::PreshowerClusterCollection> preshowerClusters_;
00118   // the super cluster collection (actually only one) associated to a GSF track
00119   std::vector<reco::SuperClusterCollection> superClusters_;
00120   // the references to the basic clusters associated to a GSF track
00121   std::vector<reco::CaloClusterPtrVector> basicClusterPtr_;
00122   // the references to the basic clusters associated to a GSF track
00123   std::vector<reco::CaloClusterPtrVector> preshowerClusterPtr_;
00124   // the references to the GsfElectonCore associated to a GSF track
00125   std::vector<reco::GsfElectronCoreRef> gsfElectronCoreRefs_;
00126   // keep track of the index of the PF Candidate
00127   std::vector<int> gsfPFCandidateIndex_;
00128   // maps to ease the creation of the Value Maps 
00129   std::map<reco::GsfTrackRef,reco::SuperClusterRef> scMap_;
00130   std::map<reco::GsfTrackRef,float> gsfMvaMap_;
00131 
00132   bool emptyIsOk_;
00133 
00134 };
00135 #endif