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