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