CMS 3D CMS Logo

GsfElectronBaseProducer.cc
Go to the documentation of this file.
2 
5 
14 
15 
23 
27 
28 
29 namespace {
30 
31  void logElectrons(reco::GsfElectronCollection const& electrons, edm::Event const& event, const std::string& title)
32  {
33  LogTrace("GsfElectronAlgo") << "========== " << title << " ==========";
34  LogTrace("GsfElectronAlgo") << "Event: " << event.id();
35  LogTrace("GsfElectronAlgo") << "Number of electrons: " << electrons.size();
36  for (auto const& ele : electrons) {
37  LogTrace("GsfElectronAlgo") << "Electron with charge, pt, eta, phi: " << ele.charge() << " , " << ele.pt()
38  << " , " << ele.eta() << " , " << ele.phi();
39  }
40  LogTrace("GsfElectronAlgo") << "=================================================";
41  }
42 
43 } // namespace
44 
45 
46 using namespace reco;
47 
49 {
51  // input collections
52  desc.add<edm::InputTag>("gsfElectronCoresTag", edm::InputTag("gedGsfElectronCores"));
53  desc.add<edm::InputTag>("pflowGsfElectronsTag", edm::InputTag(""));
54  desc.add<edm::InputTag>("pfMvaTag", edm::InputTag(""));
55  desc.add<edm::InputTag>("previousGsfElectronsTag", edm::InputTag(""));
56  desc.add<edm::InputTag>("hcalTowers", edm::InputTag("towerMaker"));
57  desc.add<edm::InputTag>("vtxTag", edm::InputTag("offlinePrimaryVertices"));
58  desc.add<edm::InputTag>("conversionsTag", edm::InputTag("allConversions"));
59  desc.add<edm::InputTag>("gsfPfRecTracksTag", edm::InputTag("pfTrackElec"));
60  desc.add<edm::InputTag>("barrelRecHitCollectionTag", edm::InputTag("ecalRecHit","EcalRecHitsEB"));
61  desc.add<edm::InputTag>("endcapRecHitCollectionTag", edm::InputTag("ecalRecHit","EcalRecHitsEE"));
62  desc.add<edm::InputTag>("seedsTag", edm::InputTag("ecalDrivenElectronSeeds"));
63  desc.add<edm::InputTag>("beamSpotTag", edm::InputTag("offlineBeamSpot"));
64  desc.add<edm::InputTag>("egmPFCandidatesTag", edm::InputTag("particleFlowEGamma"));
65  desc.add<bool>("checkHcalStatus", true);
66 
67  // steering
68  desc.add<bool>("gedElectronMode", true);
69  desc.add<bool>("useCombinationRegression", true);
70  desc.add<bool>("ecalDrivenEcalEnergyFromClassBasedParameterization", false);
71  desc.add<bool>("ecalDrivenEcalErrorFromClassBasedParameterization", false);
72  desc.add<bool>("applyPreselection", true);
73  desc.add<bool>("useEcalRegression", true);
74  desc.add<bool>("applyAmbResolution", false);
75  desc.add<bool>("useGsfPfRecTracks", true);
76  desc.add<bool>("pureTrackerDrivenEcalErrorFromSimpleParameterization", true);
77  desc.add<unsigned int>("ambSortingStrategy", 1);
78  desc.add<unsigned int>("ambClustersOverlapStrategy", 1);
79  desc.add<bool>("addPflowElectrons", true); // this one should be transfered to the "core" level
80  desc.add<bool>("fillConvVtxFitProb", true);
81 
82  // Ecal rec hits configuration
83  desc.add<std::vector<std::string>>("recHitFlagsToBeExcludedBarrel");
84  desc.add<std::vector<std::string>>("recHitFlagsToBeExcludedEndcaps");
85  desc.add<std::vector<std::string>>("recHitSeverityToBeExcludedBarrel");
86  desc.add<std::vector<std::string>>("recHitSeverityToBeExcludedEndcaps");
87 
88  // Isolation algos configuration
89  desc.add("trkIsol03Cfg",EleTkIsolFromCands::pSetDescript());
90  desc.add("trkIsol04Cfg",EleTkIsolFromCands::pSetDescript());
91  desc.add("trkIsolHEEP03Cfg",EleTkIsolFromCands::pSetDescript());
92  desc.add("trkIsolHEEP04Cfg",EleTkIsolFromCands::pSetDescript());
93  desc.add<bool>("useNumCrystals", true);
94  desc.add<double>("etMinBarrel", 0.0);
95  desc.add<double>("etMinEndcaps", 0.11);
96  desc.add<double>("etMinHcal", 0.0);
97  desc.add<double>("eMinBarrel", 0.095);
98  desc.add<double>("eMinEndcaps", 0.0);
99  desc.add<double>("intRadiusEcalBarrel", 3.0);
100  desc.add<double>("intRadiusEcalEndcaps", 3.0);
101  desc.add<double>("intRadiusHcal", 0.15);
102  desc.add<double>("jurassicWidth", 1.5);
103  desc.add<bool>("vetoClustered", false);
104  {
106  psd0.add<std::string>("propagatorAlongTISE", "PropagatorWithMaterial");
107  psd0.add<std::string>("propagatorOppositeTISE", "PropagatorWithMaterialOpposite");
108  desc.add<edm::ParameterSetDescription>("TransientInitialStateEstimatorParameters", psd0);
109  }
110 
111  // backward compatibility mechanism for ctf tracks
112  desc.add<bool>("ctfTracksCheck", true);
113  desc.add<edm::InputTag>("ctfTracksTag", edm::InputTag("generalTracks"));
114 
115  desc.add<double>("MaxElePtForOnlyMVA",50.0);
116  desc.add<double>("PreSelectMVA", -0.1);
117 
118  {
120  psd0.add<double>("minSCEtBarrel", 0.0);
121  psd0.add<double>("minSCEtEndcaps", 0.0);
122  psd0.add<double>("minEOverPBarrel", 0.0);
123  psd0.add<double>("minEOverPEndcaps", 0.0);
124  psd0.add<double>("maxEOverPBarrel", 999999999.0);
125  psd0.add<double>("maxEOverPEndcaps", 999999999.0);
126  psd0.add<double>("maxDeltaEtaBarrel", 999999999.0);
127  psd0.add<double>("maxDeltaEtaEndcaps", 999999999.0);
128  psd0.add<double>("maxDeltaPhiBarrel", 999999999.0);
129  psd0.add<double>("maxDeltaPhiEndcaps", 999999999.0);
130  psd0.add<double>("hOverEConeSize", 0.15);
131  psd0.add<double>("hOverEPtMin", 0.0);
132  psd0.add<double>("maxHOverEBarrelCone", 999999999.0);
133  psd0.add<double>("maxHOverEEndcapsCone", 999999999.0);
134  psd0.add<double>("maxHBarrelCone", 0.0);
135  psd0.add<double>("maxHEndcapsCone", 0.0);
136  psd0.add<double>("maxHOverEBarrelTower", 999999999.0);
137  psd0.add<double>("maxHOverEEndcapsTower", 999999999.0);
138  psd0.add<double>("maxHBarrelTower", 0.0);
139  psd0.add<double>("maxHEndcapsTower", 0.0);
140  psd0.add<double>("maxSigmaIetaIetaBarrel", 999999999.0);
141  psd0.add<double>("maxSigmaIetaIetaEndcaps", 999999999.0);
142  psd0.add<double>("maxFbremBarrel", 999999999.0);
143  psd0.add<double>("maxFbremEndcaps", 999999999.0);
144  psd0.add<bool>("isBarrel", false);
145  psd0.add<bool>("isEndcaps", false);
146  psd0.add<bool>("isFiducial", false);
147  psd0.add<bool>("seedFromTEC", true);
148  psd0.add<double>("maxTIP", 999999999.0);
149  psd0.add<double>("minMVA", -0.4);
150  psd0.add<double>("minMvaByPassForIsolated", -0.4);
151  // preselection parameters (ecal driven electrons)
152  desc.add<edm::ParameterSetDescription>("preselection", psd0);
153  // preselection parameters (tracker driven only electrons)
154  desc.add<edm::ParameterSetDescription>("preselectionPflow", psd0);
155  }
156 
157  // Corrections
158  desc.add<std::string>("superClusterErrorFunction", "EcalClusterEnergyUncertaintyObjectSpecific");
159  desc.add<std::string>("crackCorrectionFunction", "EcalClusterCrackCorrection");
160 
161  desc.add<bool>("ecalWeightsFromDB", true);
162  desc.add<std::vector<std::string>>("ecalRefinedRegressionWeightFiles", {})->setComment(
163  "if not from DB. Otherwise, keep empty");
164  desc.add<bool>("combinationWeightsFromDB", true);
165  desc.add<std::vector<std::string>>("combinationRegressionWeightFile", {})->setComment(
166  "if not from DB. Otherwise, keep empty");
167 
168  // regression. The labels are needed in all cases.
169  desc.add<std::vector<std::string>>("ecalRefinedRegressionWeightLabels", {});
170  desc.add<std::vector<std::string>>("combinationRegressionWeightLabels", {});
171 
172  // Iso values
173  desc.add<bool>("useIsolationValues", false);
174 
175  {
177  psd0.add<edm::InputTag>("edSumPhotonEt", edm::InputTag("elEDIsoValueGamma04"));
178  psd0.add<edm::InputTag>("edSumNeutralHadronEt", edm::InputTag("elEDIsoValueNeutral04"));
179  psd0.add<edm::InputTag>("edSumChargedHadronPt", edm::InputTag("elEDIsoValueCharged04"));
180  desc.add<edm::ParameterSetDescription>("edIsolationValues", psd0);
181  }
182  {
184  psd0.add<edm::InputTag>("pfSumNeutralHadronEt", edm::InputTag("elPFIsoValueNeutral04"));
185  psd0.add<edm::InputTag>("pfSumChargedHadronPt", edm::InputTag("elPFIsoValueCharged04"));
186  psd0.add<edm::InputTag>("pfSumPhotonEt", edm::InputTag("elPFIsoValueGamma04"));
187  desc.add<edm::ParameterSetDescription>("pfIsolationValues", psd0);
188  }
189 
190  desc.add<std::vector<std::string>>("ElecMVAFilesString", {
191  "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_10_17Feb2011.weights.xml",
192  "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_12_17Feb2011.weights.xml",
193  "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_20_17Feb2011.weights.xml",
194  "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_22_17Feb2011.weights.xml",
195  });
196  desc.add<std::vector<std::string>>("SoftElecMVAFilesString", {
197  "RecoEgamma/ElectronIdentification/data/TMVA_BDTSoftElectrons_7Feb2014.weights.xml",
198  });
199 
200  descriptions.addDefault(desc);
201 }
202 
203 namespace {
204  GsfElectronAlgo::CutsConfiguration makeCutsConfiguration(edm::ParameterSet const& pset)
205  {
207  .minSCEtBarrel = pset.getParameter<double>("minSCEtBarrel"),
208  .minSCEtEndcaps = pset.getParameter<double>("minSCEtEndcaps"),
209  .maxEOverPBarrel = pset.getParameter<double>("maxEOverPBarrel"),
210  .maxEOverPEndcaps = pset.getParameter<double>("maxEOverPEndcaps"),
211  .minEOverPBarrel = pset.getParameter<double>("minEOverPBarrel"),
212  .minEOverPEndcaps = pset.getParameter<double>("minEOverPEndcaps"),
213  .maxHOverEBarrelCone = pset.getParameter<double>("maxHOverEBarrelCone"),
214  .maxHOverEEndcapsCone = pset.getParameter<double>("maxHOverEEndcapsCone"),
215  .maxHBarrelCone = pset.getParameter<double>("maxHBarrelCone"),
216  .maxHEndcapsCone = pset.getParameter<double>("maxHEndcapsCone"),
217  .maxHOverEBarrelTower = pset.getParameter<double>("maxHOverEBarrelTower"),
218  .maxHOverEEndcapsTower = pset.getParameter<double>("maxHOverEEndcapsTower"),
219  .maxHBarrelTower = pset.getParameter<double>("maxHBarrelTower"),
220  .maxHEndcapsTower = pset.getParameter<double>("maxHEndcapsTower"),
221  .maxDeltaEtaBarrel = pset.getParameter<double>("maxDeltaEtaBarrel"),
222  .maxDeltaEtaEndcaps = pset.getParameter<double>("maxDeltaEtaEndcaps"),
223  .maxDeltaPhiBarrel = pset.getParameter<double>("maxDeltaPhiBarrel"),
224  .maxDeltaPhiEndcaps = pset.getParameter<double>("maxDeltaPhiEndcaps"),
225  .maxSigmaIetaIetaBarrel = pset.getParameter<double>("maxSigmaIetaIetaBarrel"),
226  .maxSigmaIetaIetaEndcaps = pset.getParameter<double>("maxSigmaIetaIetaEndcaps"),
227  .maxFbremBarrel = pset.getParameter<double>("maxFbremBarrel"),
228  .maxFbremEndcaps = pset.getParameter<double>("maxFbremEndcaps"),
229  .isBarrel = pset.getParameter<bool>("isBarrel"),
230  .isEndcaps = pset.getParameter<bool>("isEndcaps"),
231  .isFiducial = pset.getParameter<bool>("isFiducial"),
232  .minMVA = pset.getParameter<double>("minMVA"),
233  .minMvaByPassForIsolated = pset.getParameter<double>("minMvaByPassForIsolated"),
234  .maxTIP = pset.getParameter<double>("maxTIP"),
235  .seedFromTEC = pset.getParameter<bool>("seedFromTEC"),
236  };
237  }
238 };
239 
241  : cutsCfg_(makeCutsConfiguration(cfg.getParameter<edm::ParameterSet>("preselection")))
242  , cutsCfgPflow_(makeCutsConfiguration(cfg.getParameter<edm::ParameterSet>("preselectionPflow")))
243  , ecalSeedingParametersChecked_(false)
244  , electronPutToken_(produces<GsfElectronCollection>())
245 {
246  inputCfg_.previousGsfElectrons = consumes<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("previousGsfElectronsTag"));
247  inputCfg_.pflowGsfElectronsTag = consumes<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("pflowGsfElectronsTag"));
248  inputCfg_.gsfElectronCores = consumes<reco::GsfElectronCoreCollection>(cfg.getParameter<edm::InputTag>("gsfElectronCoresTag"));
249  inputCfg_.hcalTowersTag = consumes<CaloTowerCollection>(cfg.getParameter<edm::InputTag>("hcalTowers"));
250  inputCfg_.barrelRecHitCollection = consumes<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("barrelRecHitCollectionTag"));
251  inputCfg_.endcapRecHitCollection = consumes<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("endcapRecHitCollectionTag"));
252  pfMVA_ = consumes<edm::ValueMap<float> >(cfg.getParameter<edm::InputTag>("pfMvaTag"));
253  inputCfg_.ctfTracks = consumes<reco::TrackCollection>(cfg.getParameter<edm::InputTag>("ctfTracksTag"));
254  inputCfg_.seedsTag = consumes<reco::ElectronSeedCollection>(cfg.getParameter<edm::InputTag>("seedsTag")); // used to check config consistency with seeding
255  inputCfg_.beamSpotTag = consumes<reco::BeamSpot>(cfg.getParameter<edm::InputTag>("beamSpotTag"));
256  inputCfg_.gsfPfRecTracksTag = consumes<reco::GsfPFRecTrackCollection>(cfg.getParameter<edm::InputTag>("gsfPfRecTracksTag"));
257  inputCfg_.vtxCollectionTag = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vtxTag"));
258  if(cfg.getParameter<bool>("fillConvVtxFitProb") ) inputCfg_.conversions = consumes<reco::ConversionCollection>(cfg.getParameter<edm::InputTag>("conversionsTag"));
259 
260  if ( cfg.getParameter<bool>("useIsolationValues") ) {
261  inputCfg_.pfIsoVals = cfg.getParameter<edm::ParameterSet> ("pfIsolationValues");
264  mayConsume<edm::ValueMap<double> >(tag);
265  }
266 
267  inputCfg_.edIsoVals = cfg.getParameter<edm::ParameterSet> ("edIsolationValues");
270  mayConsume<edm::ValueMap<double> >(tag);
271  }
272  }
273 
274  strategyCfg_.useGsfPfRecTracks = cfg.getParameter<bool>("useGsfPfRecTracks") ;
275  strategyCfg_.applyPreselection = cfg.getParameter<bool>("applyPreselection") ;
276  strategyCfg_.ecalDrivenEcalEnergyFromClassBasedParameterization = cfg.getParameter<bool>("ecalDrivenEcalEnergyFromClassBasedParameterization") ;
277  strategyCfg_.ecalDrivenEcalErrorFromClassBasedParameterization = cfg.getParameter<bool>("ecalDrivenEcalErrorFromClassBasedParameterization") ;
278  strategyCfg_.pureTrackerDrivenEcalErrorFromSimpleParameterization = cfg.getParameter<bool>("pureTrackerDrivenEcalErrorFromSimpleParameterization") ;
279  strategyCfg_.applyAmbResolution = cfg.getParameter<bool>("applyAmbResolution") ;
280  strategyCfg_.ambSortingStrategy = cfg.getParameter<unsigned>("ambSortingStrategy") ;
281  strategyCfg_.ambClustersOverlapStrategy = cfg.getParameter<unsigned>("ambClustersOverlapStrategy") ;
282  strategyCfg_.addPflowElectrons = cfg.getParameter<bool>("addPflowElectrons") ;
283  strategyCfg_.ctfTracksCheck = cfg.getParameter<bool>("ctfTracksCheck");
284  strategyCfg_.gedElectronMode = cfg.getParameter<bool>("gedElectronMode");
285  strategyCfg_.PreSelectMVA = cfg.getParameter<double>("PreSelectMVA");
286  strategyCfg_.MaxElePtForOnlyMVA = cfg.getParameter<double>("MaxElePtForOnlyMVA");
287  strategyCfg_.useEcalRegression = cfg.getParameter<bool>("useEcalRegression");
288  strategyCfg_.useCombinationRegression = cfg.getParameter<bool>("useCombinationRegression");
289  strategyCfg_.fillConvVtxFitProb = cfg.getParameter<bool>("fillConvVtxFitProb");
290 
291  // hcal helpers
292  auto const& psetPreselection = cfg.getParameter<edm::ParameterSet>("preselection");
293  hcalCfg_.hOverEConeSize = psetPreselection.getParameter<double>("hOverEConeSize") ;
294  if (hcalCfg_.hOverEConeSize>0)
295  {
297  hcalCfg_.checkHcalStatus = cfg.getParameter<bool>("checkHcalStatus") ;
298  hcalCfg_.hcalTowers = consumes<CaloTowerCollection>(cfg.getParameter<edm::InputTag>("hcalTowers")) ;
299  hcalCfg_.hOverEPtMin = psetPreselection.getParameter<double>("hOverEPtMin") ;
300  }
301  auto const& psetPreselectionPflow = cfg.getParameter<edm::ParameterSet>("preselectionPflow");
302  hcalCfgPflow_.hOverEConeSize = psetPreselectionPflow.getParameter<double>("hOverEConeSize") ;
304  {
306  hcalCfgPflow_.checkHcalStatus = cfg.getParameter<bool>("checkHcalStatus") ;
307  hcalCfgPflow_.hcalTowers = consumes<CaloTowerCollection>(cfg.getParameter<edm::InputTag>("hcalTowers")) ;
308  hcalCfgPflow_.hOverEPtMin = psetPreselectionPflow.getParameter<double>("hOverEPtMin") ;
309  }
310 
311  // Ecal rec hits configuration
313  const std::vector<std::string> flagnamesbarrel = cfg.getParameter<std::vector<std::string> >("recHitFlagsToBeExcludedBarrel");
314  recHitsCfg.recHitFlagsToBeExcludedBarrel = StringToEnumValue<EcalRecHit::Flags>(flagnamesbarrel);
315  const std::vector<std::string> flagnamesendcaps = cfg.getParameter<std::vector<std::string> >("recHitFlagsToBeExcludedEndcaps");
316  recHitsCfg.recHitFlagsToBeExcludedEndcaps = StringToEnumValue<EcalRecHit::Flags>(flagnamesendcaps);
317  const std::vector<std::string> severitynamesbarrel = cfg.getParameter<std::vector<std::string> >("recHitSeverityToBeExcludedBarrel");
318  recHitsCfg.recHitSeverityToBeExcludedBarrel = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesbarrel);
319  const std::vector<std::string> severitynamesendcaps = cfg.getParameter<std::vector<std::string> >("recHitSeverityToBeExcludedEndcaps");
320  recHitsCfg.recHitSeverityToBeExcludedEndcaps = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesendcaps);
321  //recHitsCfg.severityLevelCut = cfg.getParameter<int>("severityLevelCut") ;
322 
323  // isolation
325  .intRadiusHcal = cfg.getParameter<double>("intRadiusHcal"),
326  .etMinHcal = cfg.getParameter<double>("etMinHcal"),
327  .intRadiusEcalBarrel = cfg.getParameter<double>("intRadiusEcalBarrel"),
328  .intRadiusEcalEndcaps = cfg.getParameter<double>("intRadiusEcalEndcaps"),
329  .jurassicWidth = cfg.getParameter<double>("jurassicWidth"),
330  .etMinBarrel = cfg.getParameter<double>("etMinBarrel"),
331  .eMinBarrel = cfg.getParameter<double>("eMinBarrel"),
332  .etMinEndcaps = cfg.getParameter<double>("etMinEndcaps"),
333  .eMinEndcaps = cfg.getParameter<double>("eMinEndcaps"),
334  .vetoClustered = cfg.getParameter<bool>("vetoClustered"),
335  .useNumCrystals = cfg.getParameter<bool>("useNumCrystals")
336  };
337 
338  const RegressionHelper::Configuration regressionCfg{
339  .ecalRegressionWeightLabels = cfg.getParameter<std::vector<std::string> >("ecalRefinedRegressionWeightLabels"),
340  .ecalWeightsFromDB = cfg.getParameter<bool>("ecalWeightsFromDB"),
341  .ecalRegressionWeightFiles = cfg.getParameter<std::vector<std::string> >("ecalRefinedRegressionWeightFiles"),
342  .combinationRegressionWeightLabels = cfg.getParameter<std::vector<std::string> >("combinationRegressionWeightLabels"),
343  .combinationWeightsFromDB = cfg.getParameter<bool>("combinationWeightsFromDB"),
344  .combinationRegressionWeightFiles = cfg.getParameter<std::vector<std::string> >("combinationRegressionWeightFile")
345  };
346 
347  // functions for corrector
348  EcalClusterFunctionBaseClass * const superClusterErrorFunction =
349  EcalClusterFunctionFactory::get()->create(cfg.getParameter<std::string>("superClusterErrorFunction"),cfg);
350  EcalClusterFunctionBaseClass * const crackCorrectionFunction =
351  EcalClusterFunctionFactory::get()->create(cfg.getParameter<std::string>("crackCorrectionFunction"),cfg) ;
352 
353  // create algo
354  algo_ = new GsfElectronAlgo
358  isoCfg,recHitsCfg,
359  superClusterErrorFunction,
360  crackCorrectionFunction,
361  regressionCfg,
362  cfg.getParameter<edm::ParameterSet>("trkIsol03Cfg"),
363  cfg.getParameter<edm::ParameterSet>("trkIsol04Cfg"),
364  cfg.getParameter<edm::ParameterSet>("trkIsolHEEP03Cfg"),
365  cfg.getParameter<edm::ParameterSet>("trkIsolHEEP04Cfg")
366  ) ;
367  }
368 
370 
372  {
373  // check configuration
375  {
378  event.getByToken(inputCfg_.seedsTag,seeds) ;
379  if (!seeds.isValid())
380  {
381  edm::LogWarning("GsfElectronAlgo|UnreachableSeedsProvenance")
382  <<"Cannot check consistency of parameters with ecal seeding ones,"
383  <<" because the original collection of seeds is not any more available." ;
384  }
385  else
386  {
388  }
389  }
390  }
391 
393  {
394  // all electrons
395  logElectrons(electrons, event, "GsfElectronAlgo Info (before preselection)") ;
396  // preselection
398  {
399  electrons.erase( std::remove_if(electrons.begin(), electrons.end(),
400  [this](auto const& ele){ return !isPreselected(ele); }), electrons.end() );
401  logElectrons(electrons, event, "GsfElectronAlgo Info (after preselection)") ;
402  }
403  // ambiguity
404  setAmbiguityData(electrons,event) ;
406  {
407  electrons.erase( std::remove_if(electrons.begin(), electrons.end(),
408  std::mem_fn(&reco::GsfElectron::ambiguous)), electrons.end() );
409  logElectrons(electrons, event, "GsfElectronAlgo Info (after amb. solving)") ;
410  }
411  // final filling
412  orphanHandle_ = event.emplace(electronPutToken_, std::move(electrons));
413 }
414 
415 
417  {
418  if ( !pset.exists("SeedConfiguration") ) { return; }
419  edm::ParameterSet seedConfiguration = pset.getParameter<edm::ParameterSet>("SeedConfiguration") ;
420 
421  if (seedConfiguration.getParameter<bool>("applyHOverECut"))
422  {
423  if ((hcalCfg_.hOverEConeSize!=0)&&(hcalCfg_.hOverEConeSize!=seedConfiguration.getParameter<double>("hOverEConeSize")))
424  { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The H/E cone size ("<<hcalCfg_.hOverEConeSize<<") is different from ecal seeding ("<<seedConfiguration.getParameter<double>("hOverEConeSize")<<")." ; }
425  if (cutsCfg_.maxHOverEBarrelCone<seedConfiguration.getParameter<double>("maxHOverEBarrel"))
426  { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The max barrel cone H/E is lower than during ecal seeding." ; }
427  if (cutsCfg_.maxHOverEEndcapsCone<seedConfiguration.getParameter<double>("maxHOverEEndcaps"))
428  { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The max endcaps cone H/E is lower than during ecal seeding." ; }
429  }
430 
431  if (cutsCfg_.minSCEtBarrel<seedConfiguration.getParameter<double>("SCEtCut"))
432  { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The minimum super-cluster Et in barrel is lower than during ecal seeding." ; }
433  if (cutsCfg_.minSCEtEndcaps<seedConfiguration.getParameter<double>("SCEtCut"))
434  { edm::LogWarning("GsfElectronAlgo|InconsistentParameters") <<"The minimum super-cluster Et in endcaps is lower than during ecal seeding." ; }
435  }
436 
437 //=======================================================================================
438 // Ambiguity solving
439 //=======================================================================================
440 
442  edm::Event const& event,
443  bool ignoreNotPreselected) const
444 {
445  // Getting required event data
446  auto const& beamspot = event.get(inputCfg_.beamSpotTag);
449  auto const& barrelRecHits = event.get(inputCfg_.barrelRecHitCollection);
450  auto const& endcapRecHits = event.get(inputCfg_.endcapRecHitCollection);
451 
452  if (strategyCfg_.ambSortingStrategy == 0) {
453  std::sort(electrons.begin(), electrons.end(), EgAmbiguityTools::isBetter);
454  } else if (strategyCfg_.ambSortingStrategy == 1) {
455  std::sort(electrons.begin(), electrons.end(), EgAmbiguityTools::isInnerMost);
456  } else {
457  throw cms::Exception("GsfElectronAlgo|UnknownAmbiguitySortingStrategy")
458  << "value of strategyCfg_.ambSortingStrategy is : " << strategyCfg_.ambSortingStrategy;
459  }
460 
461  // init
462  for (auto e1 = electrons.begin(); e1 != electrons.end(); ++e1) {
463  e1->clearAmbiguousGsfTracks();
464  e1->setAmbiguous(false);
465  }
466 
467  // get ambiguous from GsfPfRecTracks
469  for (auto& e1 : electrons) {
470  bool found = false;
471  for (auto const& gsfPfRecTrack : *gsfPfRecTracks.product()) {
472  if (gsfPfRecTrack.gsfTrackRef() == e1.gsfTrack()) {
473  if (found) {
474  edm::LogWarning("GsfElectronAlgo") << "associated gsfPfRecTrack already found";
475  } else {
476  found = true;
477  for (auto const& duplicate : gsfPfRecTrack.convBremGsfPFRecTrackRef()) {
478  e1.addAmbiguousGsfTrack(duplicate->gsfTrackRef());
479  }
480  }
481  }
482  }
483  }
484  }
485  // or search overlapping clusters
486  else {
487  for (auto e1 = electrons.begin(); e1 != electrons.end(); ++e1) {
488  if (e1->ambiguous())
489  continue;
490  if (ignoreNotPreselected && !isPreselected(*e1))
491  continue;
492 
493  SuperClusterRef scRef1 = e1->superCluster();
494  CaloClusterPtr eleClu1 = e1->electronCluster();
495  LogDebug("GsfElectronAlgo") << "Blessing electron with E/P " << e1->eSuperClusterOverP() << ", cluster "
496  << scRef1.get() << " & track " << e1->gsfTrack().get();
497 
498  for (auto e2 = e1 + 1; e2 != electrons.end(); ++e2) {
499  if (e2->ambiguous())
500  continue;
501  if (ignoreNotPreselected && !isPreselected(*e2))
502  continue;
503 
504  SuperClusterRef scRef2 = e2->superCluster();
505  CaloClusterPtr eleClu2 = e2->electronCluster();
506 
507  // search if same cluster
508  bool sameCluster = false;
510  sameCluster = (scRef1 == scRef2);
511  } else if (strategyCfg_.ambClustersOverlapStrategy == 1) {
512  float eMin = 1.;
513  float threshold = eMin * cosh(EleRelPoint(scRef1->position(), beamspot.position()).eta());
514  sameCluster =
516  (EgAmbiguityTools::sharedEnergy(*scRef1->seed(), *eleClu2, barrelRecHits, endcapRecHits) >= threshold) ||
517  (EgAmbiguityTools::sharedEnergy(*eleClu1, *scRef2->seed(), barrelRecHits, endcapRecHits) >= threshold) ||
518  (EgAmbiguityTools::sharedEnergy(*scRef1->seed(), *scRef2->seed(), barrelRecHits, endcapRecHits) >=
519  threshold));
520  } else {
521  throw cms::Exception("GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")
522  << "value of strategyCfg_.ambClustersOverlapStrategy is : " << strategyCfg_.ambClustersOverlapStrategy;
523  }
524 
525  // main instructions
526  if (sameCluster) {
527  LogDebug("GsfElectronAlgo") << "Discarding electron with E/P " << e2->eSuperClusterOverP() << ", cluster "
528  << scRef2.get() << " and track " << e2->gsfTrack().get();
529  e1->addAmbiguousGsfTrack(e2->gsfTrack());
530  e2->setAmbiguous(true);
531  } else if (e1->gsfTrack() == e2->gsfTrack()) {
532  edm::LogWarning("GsfElectronAlgo") << "Forgetting electron with E/P " << e2->eSuperClusterOverP()
533  << ", cluster " << scRef2.get() << " and track " << e2->gsfTrack().get();
534  e2->setAmbiguous(true);
535  }
536  }
537  }
538  }
539 }
540 
541 
543 {
544  bool passCutBased = ele.passingCutBasedPreselection();
545  bool passPF = ele.passingPflowPreselection();
546  // it is worth nothing for gedGsfElectrons, this does nothing as its not set
547  // till GedGsfElectron finaliser, this is always false
549  bool passmva = ele.passingMvaPreselection();
550  if (!ele.ecalDrivenSeed()) {
551  if (ele.pt() > strategyCfg_.MaxElePtForOnlyMVA)
552  return passmva && passCutBased;
553  else
554  return passmva;
555  } else
556  return (passCutBased || passPF || passmva);
557  } else {
558  return passCutBased || passPF;
559  }
560 
561  return true;
562 }
#define LogDebug(id)
T getParameter(std::string const &) const
void setAmbiguityData(reco::GsfElectronCollection &electrons, edm::Event const &event, bool ignoreNotPreselected=true) const
edm::EDGetTokenT< reco::GsfElectronCoreCollection > gsfElectronCores
std::vector< std::string > ecalRegressionWeightLabels
void checkEcalSeedingParameters(edm::ParameterSet const &)
edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons
edm::EDGetTokenT< reco::VertexCollection > vtxCollectionTag
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool isBetter(reco::GsfElectron const &, reco::GsfElectron const &)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
double pt() const final
transverse momentum
bool passingCutBasedPreselection() const
Definition: GsfElectron.h:719
bool passingMvaPreselection() const
Definition: GsfElectron.h:735
edm::EDGetTokenT< EcalRecHitCollection > endcapRecHitCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
edm::EDGetTokenT< reco::GsfElectronCollection > pflowGsfElectronsTag
bool ambiguous() const
Definition: GsfElectron.h:721
static void fillDescriptions(edm::ConfigurationDescriptions &)
edm::EDGetTokenT< EcalRecHitCollection > barrelRecHitCollection
edm::EDGetTokenT< reco::GsfPFRecTrackCollection > gsfPfRecTracksTag
void fillEvent(reco::GsfElectronCollection &electrons, edm::Event &event)
float sharedEnergy(reco::CaloCluster const &clu1, reco::CaloCluster const &clu2, EcalRecHitCollection const &barrelRecHits, EcalRecHitCollection const &endcapRecHits)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:169
edm::EDGetTokenT< reco::ConversionCollection > conversions
GsfElectronAlgo::InputTagsConfiguration inputCfg_
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag
void addDefault(ParameterSetDescription const &psetDescription)
static edm::ParameterSetDescription pSetDescript()
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
edm::EDGetTokenT< reco::ElectronSeedCollection > seedsTag
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
ElectronHcalHelper::Configuration hcalCfg_
#define LogTrace(id)
edm::EDGetTokenT< CaloTowerCollection > hcalTowersTag
ElectronHcalHelper::Configuration hcalCfgPflow_
edm::EDGetTokenT< reco::TrackCollection > ctfTracks
GsfElectronAlgo::StrategyConfiguration strategyCfg_
void beginEvent(edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< edm::ValueMap< float > > pfMVA_
fixed size matrix
HLT enums.
const edm::EDPutTokenT< reco::GsfElectronCollection > electronPutToken_
bool isInnerMost(reco::GsfElectron const &, reco::GsfElectron const &)
GsfElectronBaseProducer(const edm::ParameterSet &, const gsfAlgoHelpers::HeavyObjectCache *)
bool isPreselected(reco::GsfElectron const &ele) const
edm::EDGetTokenT< CaloTowerCollection > hcalTowers
const GsfElectronAlgo::CutsConfiguration cutsCfgPflow_
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
edm::OrphanHandle< reco::GsfElectronCollection > orphanHandle_
Definition: event.py:1
Provenance const * provenance() const
Definition: HandleBase.h:83
const GsfElectronAlgo::CutsConfiguration cutsCfg_
bool ecalDrivenSeed() const
Definition: GsfElectron.h:188
bool passingPflowPreselection() const
Definition: GsfElectron.h:720