38 const std::vector<tensorflow::Session*>& tfSessions) {
39 std::vector<GsfElectron::MvaOutput> mva_outputs(electrons.size());
41 for (
auto& el : electrons) {
46 mva_outputs[iele] = mvaOutput;
48 el.setMvaOutput(mvaOutput);
54 LogDebug(
"GsfElectronProducer") <<
"Getting DNN PFId for ele";
57 for (
auto& el : electrons) {
58 const auto&
values = dnn_ele_pfid[jele];
60 auto& mvaOutput = mva_outputs[jele];
66 el.setMvaOutput(mvaOutput);
75 auto matchWithPFCandidates(std::vector<reco::PFCandidate>
const&
pfCandidates) {
76 std::map<reco::GsfTrackRef, reco::GsfElectron::MvaInput> gsfMVAInputs{};
79 for (
auto const& pfCand : pfCandidates) {
82 if (pfCand.gsfTrackRef().isNonnull()) {
87 input.
sigmaEtaEta = pfCand.egammaExtraRef()->sigmaEtaEta();
88 input.
hadEnergy = pfCand.egammaExtraRef()->hadEnergy();
89 gsfMVAInputs[pfCand.gsfTrackRef()] =
input;
96 LogTrace(
"GsfElectronAlgo") <<
"========== " << title <<
" ==========";
97 LogTrace(
"GsfElectronAlgo") <<
"Event: " <<
event.id();
98 LogTrace(
"GsfElectronAlgo") <<
"Number of electrons: " << electrons.size();
99 for (
auto const& ele : electrons) {
100 LogTrace(
"GsfElectronAlgo") <<
"Electron with charge, pt, eta, phi: " << ele.charge() <<
" , " << ele.pt()
101 <<
" , " << ele.eta() <<
" , " << ele.phi();
103 LogTrace(
"GsfElectronAlgo") <<
"=================================================";
115 return std::make_unique<GsfElectronAlgo::HeavyObjectCache>(conf);
118 void endStream()
override;
126 std::unique_ptr<GsfElectronAlgo>
algo_;
139 bool ignoreNotPreselected =
true)
const;
161 desc.
add<
edm::InputTag>(
"gsfElectronCoresTag", {
"ecalDrivenGsfElectronCores"});
165 desc.
add<
edm::InputTag>(
"barrelRecHitCollectionTag", {
"ecalRecHit",
"EcalRecHitsEB"});
166 desc.
add<
edm::InputTag>(
"endcapRecHitCollectionTag", {
"ecalRecHit",
"EcalRecHitsEE"});
172 desc.
add<
bool>(
"useDefaultEnergyCorrection",
true);
173 desc.
add<
bool>(
"useCombinationRegression",
false);
174 desc.
add<
bool>(
"ecalDrivenEcalEnergyFromClassBasedParameterization",
true);
175 desc.
add<
bool>(
"ecalDrivenEcalErrorFromClassBasedParameterization",
true);
176 desc.
add<
bool>(
"applyPreselection",
false);
177 desc.
add<
bool>(
"useEcalRegression",
false);
178 desc.
add<
bool>(
"applyAmbResolution",
false);
179 desc.
add<
bool>(
"ignoreNotPreselected",
true);
180 desc.
add<
bool>(
"useGsfPfRecTracks",
true);
181 desc.
add<
bool>(
"pureTrackerDrivenEcalErrorFromSimpleParameterization",
true);
182 desc.
add<
unsigned int>(
"ambSortingStrategy", 1);
183 desc.
add<
unsigned int>(
"ambClustersOverlapStrategy", 1);
184 desc.
add<
bool>(
"fillConvVtxFitProb",
true);
185 desc.
add<
bool>(
"resetMvaValuesUsingPFCandidates",
false);
188 desc.
add<std::vector<std::string>>(
"recHitFlagsToBeExcludedBarrel");
189 desc.
add<std::vector<std::string>>(
"recHitFlagsToBeExcludedEndcaps");
190 desc.
add<std::vector<std::string>>(
"recHitSeverityToBeExcludedBarrel");
191 desc.
add<std::vector<std::string>>(
"recHitSeverityToBeExcludedEndcaps");
194 desc.
add<
bool>(
"checkHcalStatus",
true);
196 desc.
add<std::vector<double>>(
"recHitEThresholdHB", {0., 0., 0., 0.});
197 desc.
add<std::vector<double>>(
"recHitEThresholdHE", {0., 0., 0., 0., 0., 0., 0.});
198 desc.
add<
int>(
"maxHcalRecHitSeverity", 999999);
199 desc.
add<
bool>(
"hcalRun2EffDepth",
false);
206 desc.
add<
bool>(
"useNumCrystals",
true);
207 desc.
add<
double>(
"etMinBarrel", 0.0);
208 desc.
add<
double>(
"etMinEndcaps", 0.11);
209 desc.
add<
double>(
"etMinHcal", 0.0);
210 desc.
add<
double>(
"eMinBarrel", 0.095);
211 desc.
add<
double>(
"eMinEndcaps", 0.0);
212 desc.
add<
double>(
"intRadiusEcalBarrel", 3.0);
213 desc.
add<
double>(
"intRadiusEcalEndcaps", 3.0);
214 desc.
add<
double>(
"intRadiusHcal", 0.15);
215 desc.
add<
double>(
"jurassicWidth", 1.5);
216 desc.
add<
bool>(
"vetoClustered",
false);
219 desc.
add<
bool>(
"ctfTracksCheck",
true);
222 desc.
add<
double>(
"MaxElePtForOnlyMVA", 50.0);
223 desc.
add<
double>(
"PreSelectMVA", -0.1);
227 psd0.
add<
double>(
"minSCEtBarrel", 4.0);
228 psd0.
add<
double>(
"minSCEtEndcaps", 4.0);
229 psd0.
add<
double>(
"minEOverPBarrel", 0.0);
230 psd0.
add<
double>(
"minEOverPEndcaps", 0.0);
231 psd0.
add<
double>(
"maxEOverPBarrel", 999999999.0);
232 psd0.
add<
double>(
"maxEOverPEndcaps", 999999999.0);
233 psd0.
add<
double>(
"maxDeltaEtaBarrel", 0.02);
234 psd0.
add<
double>(
"maxDeltaEtaEndcaps", 0.02);
235 psd0.
add<
double>(
"maxDeltaPhiBarrel", 0.15);
236 psd0.
add<
double>(
"maxDeltaPhiEndcaps", 0.15);
237 psd0.
add<
double>(
"hOverEConeSize", 0.15);
238 psd0.
add<
double>(
"maxHOverEBarrelCone", 0.15);
239 psd0.
add<
double>(
"maxHOverEEndcapsCone", 0.15);
240 psd0.
add<
double>(
"maxHBarrelCone", 0.0);
241 psd0.
add<
double>(
"maxHEndcapsCone", 0.0);
242 psd0.
add<
double>(
"maxHOverEBarrelBc", 0.15);
243 psd0.
add<
double>(
"maxHOverEEndcapsBc", 0.15);
244 psd0.
add<
double>(
"maxHBarrelBc", 0.0);
245 psd0.
add<
double>(
"maxHEndcapsBc", 0.0);
246 psd0.
add<
double>(
"maxSigmaIetaIetaBarrel", 999999999.0);
247 psd0.
add<
double>(
"maxSigmaIetaIetaEndcaps", 999999999.0);
248 psd0.
add<
double>(
"maxFbremBarrel", 999999999.0);
249 psd0.
add<
double>(
"maxFbremEndcaps", 999999999.0);
250 psd0.
add<
bool>(
"isBarrel",
false);
251 psd0.
add<
bool>(
"isEndcaps",
false);
252 psd0.
add<
bool>(
"isFiducial",
false);
253 psd0.
add<
bool>(
"seedFromTEC",
true);
254 psd0.
add<
double>(
"maxTIP", 999999999.0);
262 desc.
add<
std::string>(
"crackCorrectionFunction",
"EcalClusterCrackCorrection");
264 desc.
add<
bool>(
"ecalWeightsFromDB",
true);
265 desc.
add<std::vector<std::string>>(
"ecalRefinedRegressionWeightFiles", {})
266 ->setComment(
"if not from DB. Otherwise, keep empty");
267 desc.
add<
bool>(
"combinationWeightsFromDB",
true);
268 desc.
add<std::vector<std::string>>(
"combinationRegressionWeightFile", {})
269 ->setComment(
"if not from DB. Otherwise, keep empty");
272 desc.
add<std::vector<std::string>>(
"ecalRefinedRegressionWeightLabels", {});
273 desc.
add<std::vector<std::string>>(
"combinationRegressionWeightLabels", {});
275 desc.
add<std::vector<std::string>>(
276 "ElecMVAFilesString",
278 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_10_17Feb2011.weights.xml",
279 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_12_17Feb2011.weights.xml",
280 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_20_17Feb2011.weights.xml",
281 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_22_17Feb2011.weights.xml",
283 desc.
add<std::vector<std::string>>(
284 "SoftElecMVAFilesString",
286 "RecoEgamma/ElectronIdentification/data/TMVA_BDTSoftElectrons_7Feb2014.weights.xml",
291 psd1.
add<
bool>(
"enabled",
false);
293 psd1.
add<
std::string>(
"outputTensorName",
"sequential/FinalLayer/Softmax");
294 psd1.
add<
uint>(
"outputDim", 5);
295 psd1.
add<std::vector<std::string>>(
297 {
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/lowpT/lowpT_modelDNN.pb",
298 "RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/highpTEB/highpTEB_modelDNN.pb",
299 "RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/highpTEE/highpTEE_modelDNN.pb"});
300 psd1.
add<std::vector<std::string>>(
302 {
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/lowpT/lowpT_scaler.txt",
303 "RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/highpTEB/highpTEB_scaler.txt",
304 "RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/highpTEE/highpTEE_scaler.txt"});
305 psd1.
add<
bool>(
"useEBModelInGap",
true);
315 psd0.
add<
double>(
"drMax", 0.3);
316 psd0.
add<
double>(
"drVetoBarrel", 0.0);
317 psd0.
add<
double>(
"drVetoEndcap", 0.0);
318 psd0.
add<
double>(
"etaStripBarrel", 0.0);
319 psd0.
add<
double>(
"etaStripEndcap", 0.0);
320 psd0.
add<
double>(
"energyBarrel", 0.0);
321 psd0.
add<
double>(
"energyEndcap", 0.0);
331 psd0.
add<
bool>(
"useHF",
false);
332 psd0.
add<
double>(
"drMax", 0.3);
333 psd0.
add<
double>(
"drVetoBarrel", 0.0);
334 psd0.
add<
double>(
"drVetoEndcap", 0.0);
335 psd0.
add<
double>(
"etaStripBarrel", 0.0);
336 psd0.
add<
double>(
"etaStripEndcap", 0.0);
337 psd0.
add<
double>(
"energyBarrel", 0.0);
338 psd0.
add<
double>(
"energyEndcap", 0.0);
339 psd0.
add<
bool>(
"useEt",
true);
343 descriptions.
add(
"gsfElectronProducerDefault", desc);
351 .maxEOverPBarrel = pset.
getParameter<
double>(
"maxEOverPBarrel"),
352 .maxEOverPEndcaps = pset.
getParameter<
double>(
"maxEOverPEndcaps"),
353 .minEOverPBarrel = pset.
getParameter<
double>(
"minEOverPBarrel"),
354 .minEOverPEndcaps = pset.
getParameter<
double>(
"minEOverPEndcaps"),
355 .maxHOverEBarrelCone = pset.
getParameter<
double>(
"maxHOverEBarrelCone"),
356 .maxHOverEEndcapsCone = pset.
getParameter<
double>(
"maxHOverEEndcapsCone"),
357 .maxHBarrelCone = pset.
getParameter<
double>(
"maxHBarrelCone"),
358 .maxHEndcapsCone = pset.
getParameter<
double>(
"maxHEndcapsCone"),
359 .maxHOverEBarrelBc = pset.
getParameter<
double>(
"maxHOverEBarrelBc"),
360 .maxHOverEEndcapsBc = pset.
getParameter<
double>(
"maxHOverEEndcapsBc"),
361 .maxHBarrelBc = pset.
getParameter<
double>(
"maxHBarrelBc"),
362 .maxHEndcapsBc = pset.
getParameter<
double>(
"maxHEndcapsBc"),
363 .maxDeltaEtaBarrel = pset.
getParameter<
double>(
"maxDeltaEtaBarrel"),
364 .maxDeltaEtaEndcaps = pset.
getParameter<
double>(
"maxDeltaEtaEndcaps"),
365 .maxDeltaPhiBarrel = pset.
getParameter<
double>(
"maxDeltaPhiBarrel"),
366 .maxDeltaPhiEndcaps = pset.
getParameter<
double>(
"maxDeltaPhiEndcaps"),
367 .maxSigmaIetaIetaBarrel = pset.
getParameter<
double>(
"maxSigmaIetaIetaBarrel"),
368 .maxSigmaIetaIetaEndcaps = pset.
getParameter<
double>(
"maxSigmaIetaIetaEndcaps"),
369 .maxFbremBarrel = pset.
getParameter<
double>(
"maxFbremBarrel"),
370 .maxFbremEndcaps = pset.
getParameter<
double>(
"maxFbremEndcaps"),
377 .multThresEE = pset.
getParameter<
double>(
"multThresEE"),
384 ecalSeedingParametersChecked_(
false),
385 electronPutToken_(produces<GsfElectronCollection>()),
386 gsfPfRecTracksTag_(consumes(
cfg.getParameter<
edm::InputTag>(
"gsfPfRecTracksTag"))),
387 useGsfPfRecTracks_(
cfg.getParameter<
bool>(
"useGsfPfRecTracks")),
388 resetMvaValuesUsingPFCandidates_(
cfg.getParameter<
bool>(
"resetMvaValuesUsingPFCandidates")) {
389 if (resetMvaValuesUsingPFCandidates_) {
390 egmPFCandidateCollection_ = consumes(
cfg.getParameter<
edm::InputTag>(
"egmPFCandidatesTag"));
393 inputCfg_.gsfElectronCores = consumes(
cfg.getParameter<
edm::InputTag>(
"gsfElectronCoresTag"));
394 inputCfg_.hbheRecHitsTag = consumes(
cfg.getParameter<
edm::InputTag>(
"hbheRecHits"));
395 inputCfg_.barrelRecHitCollection = consumes(
cfg.getParameter<
edm::InputTag>(
"barrelRecHitCollectionTag"));
396 inputCfg_.endcapRecHitCollection = consumes(
cfg.getParameter<
edm::InputTag>(
"endcapRecHitCollectionTag"));
397 inputCfg_.ctfTracks = consumes(
cfg.getParameter<
edm::InputTag>(
"ctfTracksTag"));
400 inputCfg_.beamSpotTag = consumes(
cfg.getParameter<
edm::InputTag>(
"beamSpotTag"));
401 inputCfg_.vtxCollectionTag = consumes(
cfg.getParameter<
edm::InputTag>(
"vtxTag"));
402 if (
cfg.getParameter<
bool>(
"fillConvVtxFitProb"))
403 inputCfg_.conversions = consumes(
cfg.getParameter<
edm::InputTag>(
"conversionsTag"));
408 inputCfg_.pfClusterProducer =
410 inputCfg_.pfClusterProducerHCAL = consumes(pfHCALClusIsolCfg.getParameter<
edm::InputTag>(
"pfClusterProducerHCAL"));
411 inputCfg_.pfClusterProducerHFEM = consumes(pfHCALClusIsolCfg.getParameter<
edm::InputTag>(
"pfClusterProducerHFEM"));
412 inputCfg_.pfClusterProducerHFHAD = consumes(pfHCALClusIsolCfg.getParameter<
edm::InputTag>(
"pfClusterProducerHFHAD"));
416 dnnPFidEnabled_ = pset_dnn.
getParameter<
bool>(
"enabled");
418 strategyCfg_.useDefaultEnergyCorrection =
cfg.getParameter<
bool>(
"useDefaultEnergyCorrection");
420 strategyCfg_.applyPreselection =
cfg.getParameter<
bool>(
"applyPreselection");
421 strategyCfg_.ecalDrivenEcalEnergyFromClassBasedParameterization =
422 cfg.getParameter<
bool>(
"ecalDrivenEcalEnergyFromClassBasedParameterization");
423 strategyCfg_.ecalDrivenEcalErrorFromClassBasedParameterization =
424 cfg.getParameter<
bool>(
"ecalDrivenEcalErrorFromClassBasedParameterization");
425 strategyCfg_.pureTrackerDrivenEcalErrorFromSimpleParameterization =
426 cfg.getParameter<
bool>(
"pureTrackerDrivenEcalErrorFromSimpleParameterization");
427 strategyCfg_.applyAmbResolution =
cfg.getParameter<
bool>(
"applyAmbResolution");
428 strategyCfg_.ignoreNotPreselected =
cfg.getParameter<
bool>(
"ignoreNotPreselected");
429 strategyCfg_.ambSortingStrategy =
cfg.getParameter<
unsigned>(
"ambSortingStrategy");
430 strategyCfg_.ambClustersOverlapStrategy =
cfg.getParameter<
unsigned>(
"ambClustersOverlapStrategy");
431 strategyCfg_.ctfTracksCheck =
cfg.getParameter<
bool>(
"ctfTracksCheck");
432 strategyCfg_.PreSelectMVA =
cfg.getParameter<
double>(
"PreSelectMVA");
433 strategyCfg_.MaxElePtForOnlyMVA =
cfg.getParameter<
double>(
"MaxElePtForOnlyMVA");
434 strategyCfg_.useEcalRegression =
cfg.getParameter<
bool>(
"useEcalRegression");
435 strategyCfg_.useCombinationRegression =
cfg.getParameter<
bool>(
"useCombinationRegression");
436 strategyCfg_.fillConvVtxFitProb =
cfg.getParameter<
bool>(
"fillConvVtxFitProb");
437 strategyCfg_.computePfClusterIso = dnnPFidEnabled_;
441 hcalCfg_.hOverEConeSize = psetPreselection.
getParameter<
double>(
"hOverEConeSize");
442 if (hcalCfg_.hOverEConeSize > 0) {
443 hcalCfg_.onlyBehindCluster =
false;
444 hcalCfg_.checkHcalStatus =
cfg.getParameter<
bool>(
"checkHcalStatus");
447 hcalCfg_.hbheRecHits = consumes<HBHERecHitCollection>(
cfg.getParameter<
edm::InputTag>(
"hbheRecHits"));
450 hcalCfg_.maxSeverityHB =
cfg.getParameter<
int>(
"maxHcalRecHitSeverity");
452 hcalCfg_.maxSeverityHE = hcalCfg_.maxSeverityHB;
455 hcalCfgBc_.hOverEConeSize = 0.;
456 hcalCfgBc_.onlyBehindCluster =
true;
457 hcalCfgBc_.checkHcalStatus =
cfg.getParameter<
bool>(
"checkHcalStatus");
460 hcalCfgBc_.hbheRecHits = consumes<HBHERecHitCollection>(
cfg.getParameter<
edm::InputTag>(
"hbheRecHits"));
463 hcalCfgBc_.maxSeverityHB =
cfg.getParameter<
int>(
"maxHcalRecHitSeverity");
465 hcalCfgBc_.maxSeverityHE = hcalCfgBc_.maxSeverityHB;
467 hcalRun2EffDepth_ =
cfg.getParameter<
bool>(
"hcalRun2EffDepth");
471 auto const& flagnamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedBarrel");
472 recHitsCfg.recHitFlagsToBeExcludedBarrel = StringToEnumValue<EcalRecHit::Flags>(flagnamesbarrel);
473 auto const& flagnamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedEndcaps");
474 recHitsCfg.recHitFlagsToBeExcludedEndcaps = StringToEnumValue<EcalRecHit::Flags>(flagnamesendcaps);
475 auto const& severitynamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedBarrel");
476 recHitsCfg.recHitSeverityToBeExcludedBarrel =
477 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesbarrel);
478 auto const& severitynamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedEndcaps");
479 recHitsCfg.recHitSeverityToBeExcludedEndcaps =
480 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesendcaps);
485 .etMinHcal =
cfg.getParameter<
double>(
"etMinHcal"),
486 .intRadiusEcalBarrel =
cfg.getParameter<
double>(
"intRadiusEcalBarrel"),
487 .intRadiusEcalEndcaps =
cfg.getParameter<
double>(
"intRadiusEcalEndcaps"),
488 .jurassicWidth =
cfg.getParameter<
double>(
"jurassicWidth"),
489 .etMinBarrel =
cfg.getParameter<
double>(
"etMinBarrel"),
490 .eMinBarrel =
cfg.getParameter<
double>(
"eMinBarrel"),
491 .etMinEndcaps =
cfg.getParameter<
double>(
"etMinEndcaps"),
492 .eMinEndcaps =
cfg.getParameter<
double>(
"eMinEndcaps"),
493 .vetoClustered =
cfg.getParameter<
bool>(
"vetoClustered"),
494 .useNumCrystals =
cfg.getParameter<
bool>(
"useNumCrystals")};
498 .
ecaldrMax = pfECALClusIsolCfg.getParameter<
double>(
"drMax"),
499 .ecaldrVetoBarrel = pfECALClusIsolCfg.getParameter<
double>(
"drVetoBarrel"),
500 .ecaldrVetoEndcap = pfECALClusIsolCfg.getParameter<
double>(
"drVetoEndcap"),
501 .ecaletaStripBarrel = pfECALClusIsolCfg.getParameter<
double>(
"etaStripBarrel"),
502 .ecaletaStripEndcap = pfECALClusIsolCfg.getParameter<
double>(
"etaStripEndcap"),
503 .ecalenergyBarrel = pfECALClusIsolCfg.getParameter<
double>(
"energyBarrel"),
504 .ecalenergyEndcap = pfECALClusIsolCfg.getParameter<
double>(
"energyEndcap"),
505 .
useHF = pfHCALClusIsolCfg.getParameter<
bool>(
"useHF"),
506 .hcaldrMax = pfHCALClusIsolCfg.getParameter<
double>(
"drMax"),
507 .hcaldrVetoBarrel = pfHCALClusIsolCfg.getParameter<
double>(
"drVetoBarrel"),
508 .hcaldrVetoEndcap = pfHCALClusIsolCfg.getParameter<
double>(
"drVetoEndcap"),
509 .hcaletaStripBarrel = pfHCALClusIsolCfg.getParameter<
double>(
"etaStripBarrel"),
510 .hcaletaStripEndcap = pfHCALClusIsolCfg.getParameter<
double>(
"etaStripEndcap"),
511 .hcalenergyBarrel = pfHCALClusIsolCfg.getParameter<
double>(
"energyBarrel"),
512 .hcalenergyEndcap = pfHCALClusIsolCfg.getParameter<
double>(
"energyEndcap"),
513 .hcaluseEt = pfHCALClusIsolCfg.getParameter<
bool>(
"useEt")};
517 .ecalWeightsFromDB =
cfg.getParameter<
bool>(
"ecalWeightsFromDB"),
518 .ecalRegressionWeightFiles =
cfg.getParameter<std::vector<std::string>>(
"ecalRefinedRegressionWeightFiles"),
519 .combinationRegressionWeightLabels =
520 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightLabels"),
521 .combinationWeightsFromDB =
cfg.getParameter<
bool>(
"combinationWeightsFromDB"),
522 .combinationRegressionWeightFiles =
523 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightFile")};
526 algo_ = std::make_unique<GsfElectronAlgo>(
536 cfg.getParameter<
std::string>(
"crackCorrectionFunction"),
cfg, consumesCollector()),
542 consumesCollector());
544 if (dnnPFidEnabled_) {
545 tfSessions_ = gcache->iElectronDNNEstimator->getSessions();
556 if (!pset.
exists(
"SeedConfiguration")) {
561 if (seedConfiguration.
getParameter<
bool>(
"applyHOverECut")) {
562 if ((hcalCfg_.hOverEConeSize != 0) &&
563 (hcalCfg_.hOverEConeSize != seedConfiguration.
getParameter<
double>(
"hOverEConeSize"))) {
565 <<
"The H/E cone size (" << hcalCfg_.hOverEConeSize <<
") is different from ecal seeding ("
566 << seedConfiguration.
getParameter<
double>(
"hOverEConeSize") <<
").";
568 if (cutsCfg_.maxHOverEBarrelCone < seedConfiguration.
getParameter<
double>(
"maxHOverEBarrel")) {
570 <<
"The max barrel cone H/E is lower than during ecal seeding.";
572 if (cutsCfg_.maxHOverEEndcapsCone < seedConfiguration.
getParameter<
double>(
"maxHOverEEndcaps")) {
574 <<
"The max endcaps cone H/E is lower than during ecal seeding.";
578 if (cutsCfg_.minSCEtBarrel < seedConfiguration.
getParameter<
double>(
"SCEtCut")) {
580 <<
"The minimum super-cluster Et in barrel is lower than during ecal seeding.";
582 if (cutsCfg_.minSCEtEndcaps < seedConfiguration.
getParameter<
double>(
"SCEtCut")) {
584 <<
"The minimum super-cluster Et in endcaps is lower than during ecal seeding.";
594 bool ignoreNotPreselected)
const {
596 auto const&
beamspot =
event.get(inputCfg_.beamSpotTag);
597 auto gsfPfRecTracks =
599 auto const&
barrelRecHits =
event.get(inputCfg_.barrelRecHitCollection);
600 auto const&
endcapRecHits =
event.get(inputCfg_.endcapRecHitCollection);
602 if (strategyCfg_.ambSortingStrategy == 0) {
604 }
else if (strategyCfg_.ambSortingStrategy == 1) {
607 throw cms::Exception(
"GsfElectronAlgo|UnknownAmbiguitySortingStrategy")
608 <<
"value of strategyCfg_.ambSortingStrategy is : " << strategyCfg_.ambSortingStrategy;
619 for (
auto& e1 : electrons) {
621 for (
auto const& gsfPfRecTrack : *gsfPfRecTracks) {
622 if (gsfPfRecTrack.gsfTrackRef() == e1.gsfTrack()) {
624 edm::LogWarning(
"GsfElectronAlgo") <<
"associated gsfPfRecTrack already found";
627 for (
auto const& duplicate : gsfPfRecTrack.convBremGsfPFRecTrackRef()) {
628 e1.addAmbiguousGsfTrack(duplicate->gsfTrackRef());
637 for (
auto e1 = electrons.begin(); e1 != electrons.end(); ++e1) {
645 LogDebug(
"GsfElectronAlgo") <<
"Blessing electron with E/P " << e1->eSuperClusterOverP() <<
", cluster "
646 << scRef1.
get() <<
" & track " << e1->gsfTrack().get();
648 for (
auto e2 = e1 + 1; e2 != electrons.end(); ++e2) {
658 bool sameCluster =
false;
659 if (strategyCfg_.ambClustersOverlapStrategy == 0) {
660 sameCluster = (scRef1 == scRef2);
661 }
else if (strategyCfg_.ambClustersOverlapStrategy == 1) {
670 throw cms::Exception(
"GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")
671 <<
"value of strategyCfg_.ambClustersOverlapStrategy is : " << strategyCfg_.ambClustersOverlapStrategy;
676 LogDebug(
"GsfElectronAlgo") <<
"Discarding electron with E/P " << e2->eSuperClusterOverP() <<
", cluster "
677 << scRef2.
get() <<
" and track " << e2->gsfTrack().get();
678 e1->addAmbiguousGsfTrack(e2->gsfTrack());
679 e2->setAmbiguous(
true);
680 }
else if (e1->gsfTrack() == e2->gsfTrack()) {
681 edm::LogWarning(
"GsfElectronAlgo") <<
"Forgetting electron with E/P " << e2->eSuperClusterOverP()
682 <<
", cluster " << scRef2.
get() <<
" and track " << e2->gsfTrack().get();
683 e2->setAmbiguous(
true);
697 if (ele.
pt() > strategyCfg_.MaxElePtForOnlyMVA)
698 return passmva && passCutBased;
702 return passCutBased || passPF || passmva;
711 auto seeds =
event.getHandle(inputCfg_.seedsTag);
712 if (!
seeds.isValid()) {
714 <<
"Cannot check consistency of parameters with ecal seeding ones,"
715 <<
" because the original collection of seeds is not any more available.";
721 auto electrons =
algo_->completeElectrons(event, setup, globalCache());
724 for (
auto& el : electrons) {
725 el.setMvaInput(gsfMVAInputMap.find(el.gsfTrack())->
second);
731 logElectrons(electrons, event,
"GsfElectronAlgo Info (before preselection)");
733 if (strategyCfg_.applyPreselection) {
735 std::remove_if(electrons.begin(), electrons.end(), [
this](
auto const& ele) {
return !
isPreselected(ele); }),
737 logElectrons(electrons, event,
"GsfElectronAlgo Info (after preselection)");
741 if (strategyCfg_.applyAmbResolution) {
744 logElectrons(electrons, event,
"GsfElectronAlgo Info (after amb. solving)");
748 for (
auto& ele : electrons)
749 ele.hcalToRun2EffDepth();
void checkEcalSeedingParameters(edm::ParameterSet const &)
static constexpr float kMultThresEE
const edm::EDGetTokenT< reco::GsfPFRecTrackCollection > gsfPfRecTracksTag_
GsfElectronAlgo::Tokens inputCfg_
double pt() const final
transverse momentum
edm::EDGetTokenT< reco::PFCandidateCollection > egmPFCandidateCollection_
std::vector< std::string > ecalRegressionWeightLabels
void setAmbiguityData(reco::GsfElectronCollection &electrons, edm::Event const &event, bool ignoreNotPreselected=true) const
#define DEFINE_FWK_MODULE(type)
static void fillDescriptions(edm::ConfigurationDescriptions &)
const bool resetMvaValuesUsingPFCandidates_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< Vertex > VertexCollection
collection of Vertex objects
bool passingCutBasedPreselection() const
bool passingMvaPreselection() const
const bool useGsfPfRecTracks_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
bool ecalSeedingParametersChecked_
static std::string const input
std::unique_ptr< const ElectronMVAEstimator > iElectronMVAEstimator
U second(std::pair< T, U > const &p)
bool isBetterElectron(reco::GsfElectron const &, reco::GsfElectron const &)
bool isInnermostElectron(reco::GsfElectron const &, reco::GsfElectron const &)
void endStream() override
GsfElectronProducer(const edm::ParameterSet &, const GsfElectronAlgo::HeavyObjectCache *)
static std::unique_ptr< GsfElectronAlgo::HeavyObjectCache > initializeGlobalCache(const edm::ParameterSet &conf)
float dnn_e_sigNonIsolated
const edm::EDPutTokenT< reco::GsfElectronCollection > electronPutToken_
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
bool closeSession(Session *&session)
bool get(ProductID const &oid, Handle< PROD > &result) const
std::vector< tensorflow::Session * > tfSessions_
static edm::ParameterSetDescription pSetDescript()
T const * get() const
Returns C++ pointer to the item.
std::unique_ptr< const ElectronDNNEstimator > iElectronDNNEstimator
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static constexpr float kMultThresEB
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
const GsfElectronAlgo::CutsConfiguration cutsCfg_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
float sharedEnergy(reco::CaloCluster const &clu1, reco::CaloCluster const &clu2, EcalRecHitCollection const &barrelRecHits, EcalRecHitCollection const &endcapRecHits)
bool isPreselected(reco::GsfElectron const &ele) const
float dnn_e_bkgNonIsolated
std::unique_ptr< GsfElectronAlgo > algo_
ElectronHcalHelper::Configuration hcalCfgBc_
std::unique_ptr< const SoftElectronMVAEstimator > sElectronMVAEstimator
Log< level::Warning, false > LogWarning
std::array< double, 4 > arrayHB
static void globalEndJob(GsfElectronAlgo::HeavyObjectCache const *)
void produce(edm::Event &event, const edm::EventSetup &setup) override
GsfElectronAlgo::StrategyConfiguration strategyCfg_
bool ecalDrivenSeed() const
bool passingPflowPreselection() const
std::array< double, 7 > arrayHE