CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoEgamma/EgammaElectronProducers/plugins/GsfElectronProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EgammaElectronProducers
00004 // Class:      GsfElectronProducer
00005 //
00014 #include "GsfElectronProducer.h"
00015 
00016 #include "FWCore/Framework/interface/Frameworkfwd.h"
00017 #include "FWCore/Framework/interface/MakerMacros.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00020 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00022 #include "FWCore/ParameterSet/interface/Registry.h"
00023 #include "CommonTools/Utils/interface/StringToEnumValue.h"
00024 
00025 #include "DataFormats/EcalRecHit/interface/EcalSeverityLevel.h"
00026 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00027 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00028 #include "DataFormats/EgammaReco/interface/ElectronSeed.h"
00029 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00030 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
00031 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
00032 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00033 
00034 
00035 #include <iostream>
00036 
00037 using namespace reco;
00038 
00039 /* void GsfElectronProducer::fillDescriptions( edm::ConfigurationDescriptions & descriptions )
00040  {
00041   edm::ParameterSetDescription desc ;
00042   GsfElectronBaseProducer::fillDescription(desc) ;
00043 
00044   // input collections
00045   desc.add<edm::InputTag>("gsfElectronCoresTag",edm::InputTag("gsfElectronCores")) ;
00046   desc.add<edm::InputTag>("ecalDrivenGsfElectronsTag",edm::InputTag("ecalDrivenGsfElectrons")) ;
00047   desc.add<edm::InputTag>("pfMvaTag",edm::InputTag("pfElectronTranslator:pf")) ;
00048 
00049   // steering
00050   desc.add<bool>("addPflowElectrons",true) ;
00051 
00052   // preselection parameters (tracker driven only electrons)
00053   desc.add<double>("minSCEtBarrelPflow",0.0) ;
00054   desc.add<double>("minSCEtEndcapsPflow",0.0) ;
00055   desc.add<double>("minEOverPBarrelPflow",0.0) ;
00056   desc.add<double>("maxEOverPBarrelPflow",999999999.) ;
00057   desc.add<double>("minEOverPEndcapsPflow",0.0) ;
00058   desc.add<double>("maxEOverPEndcapsPflow",999999999.) ;
00059   desc.add<double>("maxDeltaEtaBarrelPflow",999999999.) ;
00060   desc.add<double>("maxDeltaEtaEndcapsPflow",999999999.) ;
00061   desc.add<double>("maxDeltaPhiBarrelPflow",999999999.) ;
00062   desc.add<double>("maxDeltaPhiEndcapsPflow",999999999.) ;
00063   desc.add<double>("hOverEConeSizePflow",0.15) ;
00064   desc.add<double>("hOverEPtMinPflow",0.) ;
00065   desc.add<double>("maxHOverEBarrelPflow",999999999.) ;
00066   desc.add<double>("maxHOverEEndcapsPflow",999999999.) ;
00067   desc.add<double>("maxHBarrelPflow",0.0) ;
00068   desc.add<double>("maxHEndcapsPflow",0.0) ;
00069   desc.add<double>("maxSigmaIetaIetaBarrelPflow",999999999.) ;
00070   desc.add<double>("maxSigmaIetaIetaEndcapsPflow",999999999.) ;
00071   desc.add<double>("maxFbremBarrelPflow",999999999.) ;
00072   desc.add<double>("maxFbremEndcapsPflow",999999999.) ;
00073   desc.add<bool>("isBarrelPflow",false) ;
00074   desc.add<bool>("isEndcapsPflow",false) ;
00075   desc.add<bool>("isFiducialPflow",false) ;
00076   desc.add<double>("maxTIPPflow",999999999.) ;
00077   desc.add<double>("minMVAPflow",-0.4) ;
00078 
00079   descriptions.add("produceGsfElectrons",desc) ;
00080  }
00081  */
00082 GsfElectronProducer::GsfElectronProducer( const edm::ParameterSet & cfg )
00083  : GsfElectronBaseProducer(cfg), pfTranslatorParametersChecked_(false)
00084  {}
00085 
00086 GsfElectronProducer::~GsfElectronProducer()
00087  {}
00088 
00089 void GsfElectronProducer::produce( edm::Event & event, const edm::EventSetup & setup )
00090  {
00091   beginEvent(event,setup) ;
00092   algo_->clonePreviousElectrons() ;
00093   // don't add pflow only electrons if one so wish
00094   if (strategyCfg_.addPflowElectrons)
00095    { algo_->completeElectrons() ; }
00096   algo_->addPflowInfo() ;
00097   fillEvent(event) ;
00098   endEvent() ;
00099  }
00100 
00101 void GsfElectronProducer::beginEvent( edm::Event & event, const edm::EventSetup & setup )
00102  {
00103   // extra configuration checks
00104   if (!pfTranslatorParametersChecked_)
00105    {
00106     pfTranslatorParametersChecked_ = true ;
00107     edm::Handle<edm::ValueMap<float> > pfMva ;
00108     event.getByLabel(inputCfg_.pfMVA,pfMva) ;
00109     checkPfTranslatorParameters(pfMva.provenance()->psetID()) ;
00110    }
00111 
00112   // call to base class
00113   GsfElectronBaseProducer::beginEvent(event,setup) ;
00114  }
00115 
00116 void GsfElectronProducer::checkPfTranslatorParameters( edm::ParameterSetID const & psetid )
00117  {
00118   edm::ParameterSet pset ;
00119   edm::pset::Registry::instance()->getMapped(psetid,pset) ;
00120   edm::ParameterSet mvaBlock = pset.getParameter<edm::ParameterSet>("MVACutBlock") ;
00121   double pfTranslatorMinMva = mvaBlock.getParameter<double>("MVACut") ;
00122   double pfTranslatorUndefined = -99. ;
00123   if (strategyCfg_.applyPreselection&&(cutsCfgPflow_.minMVA<pfTranslatorMinMva))
00124    {
00125     // For pure tracker seeded electrons, if MVA is under translatorMinMva, there is no supercluster
00126     // of any kind available, so GsfElectronCoreProducer has already discarded the electron.
00127     edm::LogWarning("GsfElectronAlgo|MvaCutTooLow")
00128       <<"Parameter minMVAPflow ("<<cutsCfgPflow_.minMVA<<") will have no effect on purely tracker seeded electrons."
00129       <<" It is inferior to the cut already applied by PFlow translator ("<<pfTranslatorMinMva<<")." ;
00130    }
00131   if (strategyCfg_.applyPreselection&&(cutsCfg_.minMVA<pfTranslatorMinMva))
00132    {
00133     // For ecal seeded electrons, there is a cluster and GsfElectronCoreProducer has kept all electrons,
00134     // but when MVA is under translatorMinMva, the translator has not stored the supercluster and
00135     // forced the MVA value to translatorUndefined
00136     if (cutsCfg_.minMVA>pfTranslatorUndefined)
00137      {
00138       edm::LogWarning("GsfElectronAlgo|IncompletePflowInformation")
00139         <<"Parameter minMVA  ("<<cutsCfg_.minMVA<<")is inferior to the cut applied by PFlow translator ("<<pfTranslatorMinMva<<")."
00140         <<" Some ecal (and eventually tracker) seeded electrons may lack their MVA value and PFlow supercluster." ;
00141      }
00142     else
00143      {
00144       // the MVA value has been forced to translatorUndefined, inferior minMVAPflow
00145       // so the cut actually applied is the PFlow one
00146       throw cms::Exception("GsfElectronAlgo|BadMvaCut")
00147         <<"Parameter minMVA is inferior to the lowest possible value."
00148         <<" Every electron will be blessed whatever other criteria." ;
00149      }
00150    }
00151  }
00152 
00153