CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoEgamma/EgammaElectronProducers/plugins/GsfElectronBaseProducer.cc

Go to the documentation of this file.
00001 
00002 #include "GsfElectronBaseProducer.h"
00003 
00004 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionFactory.h"
00005 
00006 #include "FWCore/Framework/interface/Frameworkfwd.h"
00007 #include "FWCore/Framework/interface/MakerMacros.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 #include "FWCore/ParameterSet/interface/Registry.h"
00013 #include "CommonTools/Utils/interface/StringToEnumValue.h"
00014 
00015 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00016 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00017 #include "DataFormats/EgammaReco/interface/ElectronSeed.h"
00018 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00019 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
00020 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
00021 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00022 #include "DataFormats/EcalRecHit/interface/EcalSeverityLevel.h"
00023 
00024 
00025 #include <iostream>
00026 
00027 using namespace reco;
00028 
00029 void GsfElectronBaseProducer::fillDescription( edm::ParameterSetDescription & desc )
00030  {
00031   // input collections
00032   desc.add<edm::InputTag>("previousGsfElectronsTag",edm::InputTag("ecalDrivenGsfElectrons")) ;
00033   desc.add<edm::InputTag>("pflowGsfElectronsTag",edm::InputTag("pflowGsfElectrons")) ;
00034   desc.add<edm::InputTag>("gsfElectronCoresTag",edm::InputTag("gsfElectronCores")) ;
00035   desc.add<edm::InputTag>("hcalTowers",edm::InputTag("towerMaker")) ;
00036   desc.add<edm::InputTag>("barrelRecHitCollectionTag",edm::InputTag("ecalRecHit","EcalRecHitsEB")) ;
00037   desc.add<edm::InputTag>("endcapRecHitCollectionTag",edm::InputTag("ecalRecHit","EcalRecHitsEE")) ;
00038   //desc.add<edm::InputTag>("pfMvaTag",edm::InputTag("pfElectronTranslator:pf")) ;
00039   desc.add<edm::InputTag>("seedsTag",edm::InputTag("ecalDrivenElectronSeeds")) ;
00040   desc.add<edm::InputTag>("beamSpotTag",edm::InputTag("offlineBeamSpot")) ;
00041   desc.add<edm::InputTag>("gsfPfRecTracksTag",edm::InputTag("pfTrackElec")) ;
00042 
00043   // backward compatibility mechanism for ctf tracks
00044   desc.add<bool>("ctfTracksCheck",true) ;
00045   desc.add<edm::InputTag>("ctfTracksTag",edm::InputTag("generalTracks")) ;
00046 
00047   // steering
00048   desc.add<bool>("useGsfPfRecTracks",true) ;
00049   desc.add<bool>("applyPreselection",false) ;
00050   desc.add<bool>("ecalDrivenEcalEnergyFromClassBasedParameterization",false) ;
00051   desc.add<bool>("ecalDrivenEcalErrorFromClassBasedParameterization",false) ;
00052   desc.add<bool>("pureTrackerDrivenEcalErrorFromSimpleParameterization",false) ;
00053   desc.add<bool>("applyAmbResolution",false) ;
00054   desc.add<unsigned>("ambSortingStrategy",1) ;
00055   desc.add<unsigned>("ambClustersOverlapStrategy",1) ;
00056   //desc.add<bool>("addPflowElectrons",true) ;
00057 
00058 //  // preselection parameters (ecal driven electrons)
00059 //  desc.add<bool>("seedFromTEC",true) ;
00060 //  desc.add<double>("minSCEtBarrel",4.0) ;
00061 //  desc.add<double>("minSCEtEndcaps",4.0) ;
00062 //  desc.add<double>("minEOverPBarrel",0.0) ;
00063 //  desc.add<double>("maxEOverPBarrel",999999999.) ;
00064 //  desc.add<double>("minEOverPEndcaps",0.0) ;
00065 //  desc.add<double>("maxEOverPEndcaps",999999999.) ;
00066 //  desc.add<double>("maxDeltaEtaBarrel",0.02) ;
00067 //  desc.add<double>("maxDeltaEtaEndcaps",0.02) ;
00068 //  desc.add<double>("maxDeltaPhiBarrel",0.15) ;
00069 //  desc.add<double>("maxDeltaPhiEndcaps",0.15) ;
00070 //  desc.add<double>("hOverEConeSize",0.15) ;
00071 //  desc.add<double>("hOverEPtMin",0.) ;
00072 //  desc.add<double>("maxHOverEBarrel",0.15) ;
00073 //  desc.add<double>("maxHOverEEndcaps",0.15) ;
00074 //  desc.add<double>("maxHBarrel",0.0) ;
00075 //  desc.add<double>("maxHEndcaps",0.0) ;
00076 //  desc.add<double>("maxSigmaIetaIetaBarrel",999999999.) ;
00077 //  desc.add<double>("maxSigmaIetaIetaEndcaps",999999999.) ;
00078 //  desc.add<double>("maxFbremBarrel",999999999.) ;
00079 //  desc.add<double>("maxFbremEndcaps",999999999.) ;
00080 //  desc.add<bool>("isBarrel",false) ;
00081 //  desc.add<bool>("isEndcaps",false) ;
00082 //  desc.add<bool>("isFiducial",false) ;
00083 //  desc.add<double>("maxTIP",999999999.) ;
00084 //  desc.add<double>("minMVA",-0.4) ;
00085 //
00086 //  // preselection parameters (tracker driven only electrons)
00087 //  desc.add<double>("minSCEtBarrelPflow",0.0) ;
00088 //  desc.add<double>("minSCEtEndcapsPflow",0.0) ;
00089 //  desc.add<double>("minEOverPBarrelPflow",0.0) ;
00090 //  desc.add<double>("maxEOverPBarrelPflow",999999999.) ;
00091 //  desc.add<double>("minEOverPEndcapsPflow",0.0) ;
00092 //  desc.add<double>("maxEOverPEndcapsPflow",999999999.) ;
00093 //  desc.add<double>("maxDeltaEtaBarrelPflow",999999999.) ;
00094 //  desc.add<double>("maxDeltaEtaEndcapsPflow",999999999.) ;
00095 //  desc.add<double>("maxDeltaPhiBarrelPflow",999999999.) ;
00096 //  desc.add<double>("maxDeltaPhiEndcapsPflow",999999999.) ;
00097 //  desc.add<double>("hOverEConeSizePflow",0.15) ;
00098 //  desc.add<double>("hOverEPtMinPflow",0.) ;
00099 //  desc.add<double>("maxHOverEBarrelPflow",999999999.) ;
00100 //  desc.add<double>("maxHOverEEndcapsPflow",999999999.) ;
00101 //  desc.add<double>("maxHBarrelPflow",0.0) ;
00102 //  desc.add<double>("maxHEndcapsPflow",0.0) ;
00103 //  desc.add<double>("maxSigmaIetaIetaBarrelPflow",999999999.) ;
00104 //  desc.add<double>("maxSigmaIetaIetaEndcapsPflow",999999999.) ;
00105 //  desc.add<double>("maxFbremBarrelPflow",999999999.) ;
00106 //  desc.add<double>("maxFbremEndcapsPflow",999999999.) ;
00107 //  desc.add<bool>("isBarrelPflow",false) ;
00108 //  desc.add<bool>("isEndcapsPflow",false) ;
00109 //  desc.add<bool>("isFiducialPflow",false) ;
00110 //  desc.add<double>("maxTIPPflow",999999999.) ;
00111 //  desc.add<double>("minMVAPflow",-0.4) ;
00112 
00113   // Ecal rec hits configuration
00114   desc.add<std::vector<int> >("recHitFlagsToBeExcludedBarrel") ;
00115   desc.add<std::vector<int> >("recHitFlagsToBeExcludedEndcaps") ;
00116   desc.add<std::vector<int> >("recHitSeverityToBeExcludedBarrel") ;
00117   desc.add<std::vector<int> >("recHitSeverityToBeExcludedEndcaps") ;
00118   //desc.add<int>("severityLevelCut",4) ;
00119 
00120   // Isolation algos configuration
00121   desc.add<double>("intRadiusBarrelTk",0.015) ;
00122   desc.add<double>("intRadiusEndcapTk",0.015) ;
00123   desc.add<double>("stripBarrelTk",0.015) ;
00124   desc.add<double>("stripEndcapTk",0.015) ;
00125   desc.add<double>("ptMinTk",0.7) ;
00126   desc.add<double>("maxVtxDistTk",0.2) ;
00127   desc.add<double>("maxDrbTk",999999999.) ;
00128   desc.add<double>("intRadiusHcal",0.15) ;
00129   desc.add<double>("etMinHcal",0.0) ;
00130   desc.add<double>("intRadiusEcalBarrel",3.0) ;
00131   desc.add<double>("intRadiusEcalEndcaps",3.0) ;
00132   desc.add<double>("jurassicWidth",1.5) ;
00133   desc.add<double>("etMinBarrel",0.0) ;
00134   desc.add<double>("eMinBarrel",0.08) ;
00135   desc.add<double>("etMinEndcaps",0.1) ;
00136   desc.add<double>("eMinEndcaps",0.0) ;
00137   desc.add<bool>("vetoClustered",false) ;
00138   desc.add<bool>("useNumCrystals",true) ;
00139 
00140   edm::ParameterSetDescription descNested ;
00141   descNested.add<std::string>("propagatorAlongTISE","PropagatorWithMaterial") ;
00142   descNested.add<std::string>("propagatorOppositeTISE","PropagatorWithMaterialOpposite") ;
00143   desc.add<edm::ParameterSetDescription>("TransientInitialStateEstimatorParameters",descNested) ;
00144 
00145   // Corrections
00146   desc.add<std::string>("superClusterErrorFunction","EcalClusterEnergyUncertaintyObjectSpecific") ;
00147   desc.add<std::string>("crackCorrectionFunction","EcalClusterCrackCorrection") ;
00148  }
00149 
00150 GsfElectronBaseProducer::GsfElectronBaseProducer( const edm::ParameterSet& cfg )
00151  : ecalSeedingParametersChecked_(false)
00152  {
00153   produces<GsfElectronCollection>();
00154 
00155   inputCfg_.previousGsfElectrons = cfg.getParameter<edm::InputTag>("previousGsfElectronsTag");
00156   inputCfg_.pflowGsfElectronsTag = cfg.getParameter<edm::InputTag>("pflowGsfElectronsTag");
00157   inputCfg_.gsfElectronCores = cfg.getParameter<edm::InputTag>("gsfElectronCoresTag");
00158   inputCfg_.hcalTowersTag = cfg.getParameter<edm::InputTag>("hcalTowers") ;
00159   //inputCfg_.tracks_ = cfg.getParameter<edm::InputTag>("tracks");
00160   inputCfg_.barrelRecHitCollection = cfg.getParameter<edm::InputTag>("barrelRecHitCollectionTag") ;
00161   inputCfg_.endcapRecHitCollection = cfg.getParameter<edm::InputTag>("endcapRecHitCollectionTag") ;
00162   inputCfg_.pfMVA = cfg.getParameter<edm::InputTag>("pfMvaTag") ;
00163   inputCfg_.ctfTracks = cfg.getParameter<edm::InputTag>("ctfTracksTag");
00164   inputCfg_.seedsTag = cfg.getParameter<edm::InputTag>("seedsTag"); // used to check config consistency with seeding
00165   inputCfg_.beamSpotTag = cfg.getParameter<edm::InputTag>("beamSpotTag") ;
00166   inputCfg_.gsfPfRecTracksTag = cfg.getParameter<edm::InputTag>("gsfPfRecTracksTag") ;
00167 
00168   bool useIsolationValues = cfg.getParameter<bool>("useIsolationValues") ;
00169   if ( useIsolationValues ) {
00170         if( ! cfg.exists("pfIsolationValues") )
00171                 throw cms::Exception("GsfElectronBaseProducer|InternalError")
00172                         <<"Missing ParameterSet pfIsolationValues" ;
00173         else
00174                 inputCfg_.pfIsoVals = 
00175                         cfg.getParameter<edm::ParameterSet> ("pfIsolationValues");
00176 
00177         if ( ! cfg.exists("edIsolationValues") )
00178                 throw cms::Exception("GsfElectronBaseProducer|InternalError")
00179                         <<"Missing ParameterSet edIsolationValues" ;
00180         else
00181                 inputCfg_.edIsoVals = 
00182                         cfg.getParameter<edm::ParameterSet> ("edIsolationValues");
00183   }
00184 
00185   strategyCfg_.useGsfPfRecTracks = cfg.getParameter<bool>("useGsfPfRecTracks") ;
00186   strategyCfg_.applyPreselection = cfg.getParameter<bool>("applyPreselection") ;
00187   strategyCfg_.ecalDrivenEcalEnergyFromClassBasedParameterization = cfg.getParameter<bool>("ecalDrivenEcalEnergyFromClassBasedParameterization") ;
00188   strategyCfg_.ecalDrivenEcalErrorFromClassBasedParameterization = cfg.getParameter<bool>("ecalDrivenEcalErrorFromClassBasedParameterization") ;
00189   strategyCfg_.pureTrackerDrivenEcalErrorFromSimpleParameterization = cfg.getParameter<bool>("pureTrackerDrivenEcalErrorFromSimpleParameterization") ;
00190   strategyCfg_.applyAmbResolution = cfg.getParameter<bool>("applyAmbResolution") ;
00191   strategyCfg_.ambSortingStrategy = cfg.getParameter<unsigned>("ambSortingStrategy") ;
00192   strategyCfg_.ambClustersOverlapStrategy = cfg.getParameter<unsigned>("ambClustersOverlapStrategy") ;
00193   strategyCfg_.addPflowElectrons = cfg.getParameter<bool>("addPflowElectrons") ;
00194   strategyCfg_.ctfTracksCheck = cfg.getParameter<bool>("ctfTracksCheck");
00195 
00196   cutsCfg_.minSCEtBarrel = cfg.getParameter<double>("minSCEtBarrel") ;
00197   cutsCfg_.minSCEtEndcaps = cfg.getParameter<double>("minSCEtEndcaps") ;
00198   cutsCfg_.maxEOverPBarrel = cfg.getParameter<double>("maxEOverPBarrel") ;
00199   cutsCfg_.maxEOverPEndcaps = cfg.getParameter<double>("maxEOverPEndcaps") ;
00200   cutsCfg_.minEOverPBarrel = cfg.getParameter<double>("minEOverPBarrel") ;
00201   cutsCfg_.minEOverPEndcaps = cfg.getParameter<double>("minEOverPEndcaps") ;
00202 
00203   // H/E
00204   cutsCfg_.maxHOverEBarrel = cfg.getParameter<double>("maxHOverEBarrel") ;
00205   cutsCfg_.maxHOverEEndcaps = cfg.getParameter<double>("maxHOverEEndcaps") ;
00206   cutsCfg_.maxHBarrel = cfg.getParameter<double>("maxHBarrel") ;
00207   cutsCfg_.maxHEndcaps = cfg.getParameter<double>("maxHEndcaps") ;
00208 
00209   cutsCfg_.maxDeltaEtaBarrel = cfg.getParameter<double>("maxDeltaEtaBarrel") ;
00210   cutsCfg_.maxDeltaEtaEndcaps = cfg.getParameter<double>("maxDeltaEtaEndcaps") ;
00211   cutsCfg_.maxDeltaPhiBarrel = cfg.getParameter<double>("maxDeltaPhiBarrel") ;
00212   cutsCfg_.maxDeltaPhiEndcaps = cfg.getParameter<double>("maxDeltaPhiEndcaps") ;
00213   cutsCfg_.maxSigmaIetaIetaBarrel = cfg.getParameter<double>("maxSigmaIetaIetaBarrel") ;
00214   cutsCfg_.maxSigmaIetaIetaEndcaps = cfg.getParameter<double>("maxSigmaIetaIetaEndcaps") ;
00215   cutsCfg_.maxFbremBarrel = cfg.getParameter<double>("maxFbremBarrel") ;
00216   cutsCfg_.maxFbremEndcaps = cfg.getParameter<double>("maxFbremEndcaps") ;
00217   cutsCfg_.isBarrel = cfg.getParameter<bool>("isBarrel") ;
00218   cutsCfg_.isEndcaps = cfg.getParameter<bool>("isEndcaps") ;
00219   cutsCfg_.isFiducial = cfg.getParameter<bool>("isFiducial") ;
00220   cutsCfg_.minMVA = cfg.getParameter<double>("minMVA") ;
00221   cutsCfg_.minMvaByPassForIsolated = cfg.getParameter<double>("minMvaByPassForIsolated") ;
00222   cutsCfg_.maxTIP = cfg.getParameter<double>("maxTIP") ;
00223   cutsCfg_.seedFromTEC = cfg.getParameter<bool>("seedFromTEC") ;
00224 
00225   cutsCfgPflow_.minSCEtBarrel = cfg.getParameter<double>("minSCEtBarrelPflow") ;
00226   cutsCfgPflow_.minSCEtEndcaps = cfg.getParameter<double>("minSCEtEndcapsPflow") ;
00227   cutsCfgPflow_.maxEOverPBarrel = cfg.getParameter<double>("maxEOverPBarrelPflow") ;
00228   cutsCfgPflow_.maxEOverPEndcaps = cfg.getParameter<double>("maxEOverPEndcapsPflow") ;
00229   cutsCfgPflow_.minEOverPBarrel = cfg.getParameter<double>("minEOverPBarrelPflow") ;
00230   cutsCfgPflow_.minEOverPEndcaps = cfg.getParameter<double>("minEOverPEndcapsPflow") ;
00231 
00232   // H/E
00233   cutsCfgPflow_.maxHOverEBarrel = cfg.getParameter<double>("maxHOverEBarrelPflow") ;
00234   cutsCfgPflow_.maxHOverEEndcaps = cfg.getParameter<double>("maxHOverEEndcapsPflow") ;
00235   cutsCfgPflow_.maxHBarrel = cfg.getParameter<double>("maxHBarrelPflow") ;
00236   cutsCfgPflow_.maxHEndcaps = cfg.getParameter<double>("maxHEndcapsPflow") ;
00237 
00238   cutsCfgPflow_.maxDeltaEtaBarrel = cfg.getParameter<double>("maxDeltaEtaBarrelPflow") ;
00239   cutsCfgPflow_.maxDeltaEtaEndcaps = cfg.getParameter<double>("maxDeltaEtaEndcapsPflow") ;
00240   cutsCfgPflow_.maxDeltaPhiBarrel = cfg.getParameter<double>("maxDeltaPhiBarrelPflow") ;
00241   cutsCfgPflow_.maxDeltaPhiEndcaps = cfg.getParameter<double>("maxDeltaPhiEndcapsPflow") ;
00242   cutsCfgPflow_.maxDeltaPhiBarrel = cfg.getParameter<double>("maxDeltaPhiBarrelPflow") ;
00243   cutsCfgPflow_.maxDeltaPhiEndcaps = cfg.getParameter<double>("maxDeltaPhiEndcapsPflow") ;
00244   cutsCfgPflow_.maxDeltaPhiBarrel = cfg.getParameter<double>("maxDeltaPhiBarrelPflow") ;
00245   cutsCfgPflow_.maxDeltaPhiEndcaps = cfg.getParameter<double>("maxDeltaPhiEndcapsPflow") ;
00246   cutsCfgPflow_.maxSigmaIetaIetaBarrel = cfg.getParameter<double>("maxSigmaIetaIetaBarrelPflow") ;
00247   cutsCfgPflow_.maxSigmaIetaIetaEndcaps = cfg.getParameter<double>("maxSigmaIetaIetaEndcapsPflow") ;
00248   cutsCfgPflow_.maxFbremBarrel = cfg.getParameter<double>("maxFbremBarrelPflow") ;
00249   cutsCfgPflow_.maxFbremEndcaps = cfg.getParameter<double>("maxFbremEndcapsPflow") ;
00250   cutsCfgPflow_.isBarrel = cfg.getParameter<bool>("isBarrelPflow") ;
00251   cutsCfgPflow_.isEndcaps = cfg.getParameter<bool>("isEndcapsPflow") ;
00252   cutsCfgPflow_.isFiducial = cfg.getParameter<bool>("isFiducialPflow") ;
00253   cutsCfgPflow_.minMVA = cfg.getParameter<double>("minMVAPflow") ;
00254   cutsCfgPflow_.minMvaByPassForIsolated = cfg.getParameter<double>("minMvaByPassForIsolatedPflow") ;
00255   cutsCfgPflow_.maxTIP = cfg.getParameter<double>("maxTIPPflow") ;
00256   cutsCfgPflow_.seedFromTEC = true ; // not applied for pflow
00257 
00258   // hcal helpers
00259   hcalCfg_.hOverEConeSize = cfg.getParameter<double>("hOverEConeSize") ;
00260   if (hcalCfg_.hOverEConeSize>0)
00261    {
00262     hcalCfg_.useTowers = true ;
00263     hcalCfg_.hcalTowers = cfg.getParameter<edm::InputTag>("hcalTowers") ;
00264     hcalCfg_.hOverEPtMin = cfg.getParameter<double>("hOverEPtMin") ;
00265    }
00266   hcalCfgPflow_.hOverEConeSize = cfg.getParameter<double>("hOverEConeSizePflow") ;
00267   if (hcalCfgPflow_.hOverEConeSize>0)
00268    {
00269     hcalCfgPflow_.useTowers = true ;
00270     hcalCfgPflow_.hcalTowers = cfg.getParameter<edm::InputTag>("hcalTowers") ;
00271     hcalCfgPflow_.hOverEPtMin = cfg.getParameter<double>("hOverEPtMinPflow") ;
00272    }
00273 
00274   // Ecal rec hits configuration
00275   GsfElectronAlgo::EcalRecHitsConfiguration recHitsCfg ;
00276   const std::vector<std::string> flagnamesbarrel = cfg.getParameter<std::vector<std::string> >("recHitFlagsToBeExcludedBarrel");
00277   recHitsCfg.recHitFlagsToBeExcludedBarrel = StringToEnumValue<EcalRecHit::Flags>(flagnamesbarrel);
00278   const std::vector<std::string> flagnamesendcaps = cfg.getParameter<std::vector<std::string> >("recHitFlagsToBeExcludedEndcaps");
00279   recHitsCfg.recHitFlagsToBeExcludedEndcaps = StringToEnumValue<EcalRecHit::Flags>(flagnamesendcaps);
00280   const std::vector<std::string> severitynamesbarrel = cfg.getParameter<std::vector<std::string> >("recHitSeverityToBeExcludedBarrel");
00281   recHitsCfg.recHitSeverityToBeExcludedBarrel = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesbarrel);
00282   const std::vector<std::string> severitynamesendcaps = cfg.getParameter<std::vector<std::string> >("recHitSeverityToBeExcludedEndcaps");
00283   recHitsCfg.recHitSeverityToBeExcludedEndcaps = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesendcaps);
00284   //recHitsCfg.severityLevelCut = cfg.getParameter<int>("severityLevelCut") ;
00285 
00286   // isolation
00287   GsfElectronAlgo::IsolationConfiguration isoCfg ;
00288   isoCfg.intRadiusBarrelTk = cfg.getParameter<double>("intRadiusBarrelTk") ;
00289   isoCfg.intRadiusEndcapTk = cfg.getParameter<double>("intRadiusEndcapTk") ;
00290   isoCfg.stripBarrelTk = cfg.getParameter<double>("stripBarrelTk") ;
00291   isoCfg.stripEndcapTk = cfg.getParameter<double>("stripEndcapTk") ;
00292   isoCfg.ptMinTk = cfg.getParameter<double>("ptMinTk") ;
00293   isoCfg.maxVtxDistTk = cfg.getParameter<double>("maxVtxDistTk") ;
00294   isoCfg.maxDrbTk = cfg.getParameter<double>("maxDrbTk") ;
00295   isoCfg.intRadiusHcal = cfg.getParameter<double>("intRadiusHcal") ;
00296   isoCfg.etMinHcal = cfg.getParameter<double>("etMinHcal") ;
00297   isoCfg.intRadiusEcalBarrel = cfg.getParameter<double>("intRadiusEcalBarrel") ;
00298   isoCfg.intRadiusEcalEndcaps = cfg.getParameter<double>("intRadiusEcalEndcaps") ;
00299   isoCfg.jurassicWidth = cfg.getParameter<double>("jurassicWidth") ;
00300   isoCfg.etMinBarrel = cfg.getParameter<double>("etMinBarrel") ;
00301   isoCfg.eMinBarrel = cfg.getParameter<double>("eMinBarrel") ;
00302   isoCfg.etMinEndcaps = cfg.getParameter<double>("etMinEndcaps") ;
00303   isoCfg.eMinEndcaps = cfg.getParameter<double>("eMinEndcaps") ;
00304   isoCfg.vetoClustered = cfg.getParameter<bool>("vetoClustered") ;
00305   isoCfg.useNumCrystals = cfg.getParameter<bool>("useNumCrystals") ;
00306 
00307   // functions for corrector
00308   EcalClusterFunctionBaseClass * superClusterErrorFunction = 0 ;
00309   std::string superClusterErrorFunctionName
00310    = cfg.getParameter<std::string>("superClusterErrorFunction") ;
00311   if (superClusterErrorFunctionName!="")
00312    {
00313     superClusterErrorFunction
00314      = EcalClusterFunctionFactory::get()->create(superClusterErrorFunctionName,cfg) ;
00315    }
00316   else
00317   {
00318    superClusterErrorFunction
00319     = EcalClusterFunctionFactory::get()->create("EcalClusterEnergyUncertaintyObjectSpecific",cfg) ;
00320   }
00321   EcalClusterFunctionBaseClass * crackCorrectionFunction = 0 ;
00322   std::string crackCorrectionFunctionName
00323    = cfg.getParameter<std::string>("crackCorrectionFunction") ;
00324   if (crackCorrectionFunctionName!="")
00325    {
00326     crackCorrectionFunction
00327      = EcalClusterFunctionFactory::get()->create(crackCorrectionFunctionName,cfg) ;
00328    }
00329 
00330   // create algo
00331   algo_ = new GsfElectronAlgo
00332    ( inputCfg_, strategyCfg_,
00333      cutsCfg_,cutsCfgPflow_,
00334      hcalCfg_,hcalCfgPflow_,
00335      isoCfg,recHitsCfg,
00336      superClusterErrorFunction,
00337      crackCorrectionFunction ) ;
00338  }
00339 
00340 GsfElectronBaseProducer::~GsfElectronBaseProducer()
00341  { delete algo_ ; }
00342 
00343 void GsfElectronBaseProducer::beginEvent( edm::Event & event, const edm::EventSetup & setup )
00344  {
00345   // check configuration
00346   if (!ecalSeedingParametersChecked_)
00347    {
00348     ecalSeedingParametersChecked_ = true ;
00349     edm::Handle<reco::ElectronSeedCollection> seeds ;
00350     event.getByLabel(inputCfg_.seedsTag,seeds) ;
00351     if (!seeds.isValid())
00352      {
00353       edm::LogWarning("GsfElectronAlgo|UnreachableSeedsProvenance")
00354         <<"Cannot check consistency of parameters with ecal seeding ones,"
00355         <<" because the original collection of seeds is not any more available." ;
00356      }
00357     else
00358      {
00359       checkEcalSeedingParameters(seeds.provenance()->psetID()) ;
00360      }
00361    }
00362 
00363   // init the algo
00364   algo_->checkSetup(setup) ;
00365   algo_->beginEvent(event) ;
00366  }
00367 
00368 void GsfElectronBaseProducer::fillEvent( edm::Event & event )
00369  {
00370   // all electrons
00371   algo_->displayInternalElectrons("GsfElectronAlgo Info (before preselection)") ;
00372 
00373   // preselection
00374   if (strategyCfg_.applyPreselection)
00375    {
00376     algo_->removeNotPreselectedElectrons() ;
00377     algo_->displayInternalElectrons("GsfElectronAlgo Info (after preselection)") ;
00378    }
00379 
00380   // ambiguity
00381   algo_->setAmbiguityData() ;
00382   if (strategyCfg_.applyAmbResolution)
00383    {
00384     algo_->removeAmbiguousElectrons() ;
00385     algo_->displayInternalElectrons("GsfElectronAlgo Info (after amb. solving)") ;
00386    }
00387 
00388   // final filling
00389   std::auto_ptr<GsfElectronCollection> finalCollection( new GsfElectronCollection ) ;
00390   algo_->copyElectrons(*finalCollection) ;
00391   event.put(finalCollection) ;
00392  }
00393 
00394 void GsfElectronBaseProducer::endEvent()
00395  {
00396   algo_->endEvent() ;
00397  }
00398 
00399 void GsfElectronBaseProducer::checkEcalSeedingParameters( edm::ParameterSetID const & psetid )
00400  {
00401   edm::ParameterSet pset ;
00402   edm::pset::Registry::instance()->getMapped(psetid,pset) ;
00403   edm::ParameterSet seedConfiguration = pset.getParameter<edm::ParameterSet>("SeedConfiguration") ;
00404   //edm::ParameterSet orderedHitsFactoryPSet = seedConfiguration.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet") ;
00405   //edm::ParameterSet seedParameters = seedConfiguration.getParameter<edm::ParameterSet>("ecalDrivenElectronSeedsParameters") ;
00406 
00407   if (seedConfiguration.getParameter<bool>("applyHOverECut"))
00408    {
00409     if ((hcalCfg_.hOverEConeSize!=0)&&(hcalCfg_.hOverEConeSize!=seedConfiguration.getParameter<double>("hOverEConeSize")))
00410      { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The H/E cone size ("<<hcalCfg_.hOverEConeSize<<") is different from ecal seeding ("<<seedConfiguration.getParameter<double>("hOverEConeSize")<<")." ; }
00411     if (cutsCfg_.maxHOverEBarrel<seedConfiguration.getParameter<double>("maxHOverEBarrel"))
00412      { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The max barrel H/E is lower than during ecal seeding." ; }
00413     if (cutsCfg_.maxHOverEEndcaps<seedConfiguration.getParameter<double>("maxHOverEEndcaps"))
00414      { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The max endcaps H/E is lower than during ecal seeding." ; }
00415    }
00416 
00417   if (cutsCfg_.minSCEtBarrel<seedConfiguration.getParameter<double>("SCEtCut"))
00418    { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The minimum super-cluster Et in barrel is lower than during ecal seeding." ; }
00419   if (cutsCfg_.minSCEtEndcaps<seedConfiguration.getParameter<double>("SCEtCut"))
00420    { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The minimum super-cluster Et in endcaps is lower than during ecal seeding." ; }
00421  }
00422 
00423