37 el.setMvaOutput(mvaOutput);
44 auto matchWithPFCandidates(std::vector<reco::PFCandidate>
const&
pfCandidates) {
45 std::map<reco::GsfTrackRef, reco::GsfElectron::MvaInput> gsfMVAInputs{};
51 if (pfCand.gsfTrackRef().isNonnull()) {
56 input.sigmaEtaEta = pfCand.egammaExtraRef()->sigmaEtaEta();
57 input.hadEnergy = pfCand.egammaExtraRef()->hadEnergy();
58 gsfMVAInputs[pfCand.gsfTrackRef()] =
input;
65 LogTrace(
"GsfElectronAlgo") <<
"========== " <<
title <<
" ==========";
66 LogTrace(
"GsfElectronAlgo") <<
"Event: " <<
event.id();
69 LogTrace(
"GsfElectronAlgo") <<
"Electron with charge, pt, eta, phi: " << ele.charge() <<
" , " << ele.pt()
70 <<
" , " << ele.eta() <<
" , " << ele.phi();
72 LogTrace(
"GsfElectronAlgo") <<
"=================================================";
84 return std::make_unique<GsfElectronAlgo::HeavyObjectCache>(conf);
93 std::unique_ptr<GsfElectronAlgo>
algo_;
127 desc.add<
edm::InputTag>(
"barrelRecHitCollectionTag", {
"ecalRecHit",
"EcalRecHitsEB"});
128 desc.add<
edm::InputTag>(
"endcapRecHitCollectionTag", {
"ecalRecHit",
"EcalRecHitsEE"});
132 desc.add<
bool>(
"checkHcalStatus",
true);
135 desc.add<
bool>(
"useDefaultEnergyCorrection",
true);
136 desc.add<
bool>(
"useCombinationRegression",
false);
137 desc.add<
bool>(
"ecalDrivenEcalEnergyFromClassBasedParameterization",
true);
138 desc.add<
bool>(
"ecalDrivenEcalErrorFromClassBasedParameterization",
true);
139 desc.add<
bool>(
"applyPreselection",
false);
140 desc.add<
bool>(
"useEcalRegression",
false);
141 desc.add<
bool>(
"applyAmbResolution",
false);
142 desc.add<
bool>(
"ignoreNotPreselected",
true);
143 desc.add<
bool>(
"useGsfPfRecTracks",
true);
144 desc.add<
bool>(
"pureTrackerDrivenEcalErrorFromSimpleParameterization",
true);
145 desc.add<
unsigned int>(
"ambSortingStrategy", 1);
146 desc.add<
unsigned int>(
"ambClustersOverlapStrategy", 1);
147 desc.add<
bool>(
"fillConvVtxFitProb",
true);
148 desc.add<
bool>(
"resetMvaValuesUsingPFCandidates",
false);
151 desc.add<std::vector<std::string>>(
"recHitFlagsToBeExcludedBarrel");
152 desc.add<std::vector<std::string>>(
"recHitFlagsToBeExcludedEndcaps");
153 desc.add<std::vector<std::string>>(
"recHitSeverityToBeExcludedBarrel");
154 desc.add<std::vector<std::string>>(
"recHitSeverityToBeExcludedEndcaps");
161 desc.add<
bool>(
"useNumCrystals",
true);
162 desc.add<
double>(
"etMinBarrel", 0.0);
163 desc.add<
double>(
"etMinEndcaps", 0.11);
164 desc.add<
double>(
"etMinHcal", 0.0);
165 desc.add<
double>(
"eMinBarrel", 0.095);
166 desc.add<
double>(
"eMinEndcaps", 0.0);
167 desc.add<
double>(
"intRadiusEcalBarrel", 3.0);
168 desc.add<
double>(
"intRadiusEcalEndcaps", 3.0);
169 desc.add<
double>(
"intRadiusHcal", 0.15);
170 desc.add<
double>(
"jurassicWidth", 1.5);
171 desc.add<
bool>(
"vetoClustered",
false);
174 desc.add<
bool>(
"ctfTracksCheck",
true);
177 desc.add<
double>(
"MaxElePtForOnlyMVA", 50.0);
178 desc.add<
double>(
"PreSelectMVA", -0.1);
182 psd0.
add<
double>(
"minSCEtBarrel", 4.0);
183 psd0.
add<
double>(
"minSCEtEndcaps", 4.0);
184 psd0.
add<
double>(
"minEOverPBarrel", 0.0);
185 psd0.
add<
double>(
"minEOverPEndcaps", 0.0);
186 psd0.
add<
double>(
"maxEOverPBarrel", 999999999.0);
187 psd0.
add<
double>(
"maxEOverPEndcaps", 999999999.0);
188 psd0.
add<
double>(
"maxDeltaEtaBarrel", 0.02);
189 psd0.
add<
double>(
"maxDeltaEtaEndcaps", 0.02);
190 psd0.
add<
double>(
"maxDeltaPhiBarrel", 0.15);
191 psd0.
add<
double>(
"maxDeltaPhiEndcaps", 0.15);
192 psd0.
add<
double>(
"hOverEConeSize", 0.15);
193 psd0.
add<
double>(
"hOverEPtMin", 0.0);
194 psd0.
add<
double>(
"maxHOverEBarrelCone", 0.15);
195 psd0.
add<
double>(
"maxHOverEEndcapsCone", 0.15);
196 psd0.
add<
double>(
"maxHBarrelCone", 0.0);
197 psd0.
add<
double>(
"maxHEndcapsCone", 0.0);
198 psd0.
add<
double>(
"maxHOverEBarrelTower", 0.15);
199 psd0.
add<
double>(
"maxHOverEEndcapsTower", 0.15);
200 psd0.
add<
double>(
"maxHBarrelTower", 0.0);
201 psd0.
add<
double>(
"maxHEndcapsTower", 0.0);
202 psd0.
add<
double>(
"maxSigmaIetaIetaBarrel", 999999999.0);
203 psd0.
add<
double>(
"maxSigmaIetaIetaEndcaps", 999999999.0);
204 psd0.
add<
double>(
"maxFbremBarrel", 999999999.0);
205 psd0.
add<
double>(
"maxFbremEndcaps", 999999999.0);
206 psd0.
add<
bool>(
"isBarrel",
false);
207 psd0.
add<
bool>(
"isEndcaps",
false);
208 psd0.
add<
bool>(
"isFiducial",
false);
209 psd0.
add<
bool>(
"seedFromTEC",
true);
210 psd0.
add<
double>(
"maxTIP", 999999999.0);
218 desc.add<
std::string>(
"crackCorrectionFunction",
"EcalClusterCrackCorrection");
220 desc.add<
bool>(
"ecalWeightsFromDB",
true);
221 desc.add<std::vector<std::string>>(
"ecalRefinedRegressionWeightFiles", {})
222 ->setComment(
"if not from DB. Otherwise, keep empty");
223 desc.add<
bool>(
"combinationWeightsFromDB",
true);
224 desc.add<std::vector<std::string>>(
"combinationRegressionWeightFile", {})
225 ->setComment(
"if not from DB. Otherwise, keep empty");
228 desc.add<std::vector<std::string>>(
"ecalRefinedRegressionWeightLabels", {});
229 desc.add<std::vector<std::string>>(
"combinationRegressionWeightLabels", {});
231 desc.add<std::vector<std::string>>(
232 "ElecMVAFilesString",
234 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_10_17Feb2011.weights.xml",
235 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_12_17Feb2011.weights.xml",
236 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_20_17Feb2011.weights.xml",
237 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_22_17Feb2011.weights.xml",
239 desc.add<std::vector<std::string>>(
240 "SoftElecMVAFilesString",
242 "RecoEgamma/ElectronIdentification/data/TMVA_BDTSoftElectrons_7Feb2014.weights.xml",
245 descriptions.
add(
"gsfElectronProducer",
desc);
253 .maxEOverPBarrel =
pset.getParameter<
double>(
"maxEOverPBarrel"),
255 .minEOverPBarrel =
pset.getParameter<
double>(
"minEOverPBarrel"),
256 .minEOverPEndcaps =
pset.getParameter<
double>(
"minEOverPEndcaps"),
257 .maxHOverEBarrelCone =
pset.getParameter<
double>(
"maxHOverEBarrelCone"),
259 .maxHBarrelCone =
pset.getParameter<
double>(
"maxHBarrelCone"),
260 .maxHEndcapsCone =
pset.getParameter<
double>(
"maxHEndcapsCone"),
261 .maxHOverEBarrelTower =
pset.getParameter<
double>(
"maxHOverEBarrelTower"),
263 .maxHBarrelTower =
pset.getParameter<
double>(
"maxHBarrelTower"),
264 .maxHEndcapsTower =
pset.getParameter<
double>(
"maxHEndcapsTower"),
265 .maxDeltaEtaBarrel =
pset.getParameter<
double>(
"maxDeltaEtaBarrel"),
266 .maxDeltaEtaEndcaps =
pset.getParameter<
double>(
"maxDeltaEtaEndcaps"),
267 .maxDeltaPhiBarrel =
pset.getParameter<
double>(
"maxDeltaPhiBarrel"),
268 .maxDeltaPhiEndcaps =
pset.getParameter<
double>(
"maxDeltaPhiEndcaps"),
269 .maxSigmaIetaIetaBarrel =
pset.getParameter<
double>(
"maxSigmaIetaIetaBarrel"),
270 .maxSigmaIetaIetaEndcaps =
pset.getParameter<
double>(
"maxSigmaIetaIetaEndcaps"),
271 .maxFbremBarrel =
pset.getParameter<
double>(
"maxFbremBarrel"),
272 .maxFbremEndcaps =
pset.getParameter<
double>(
"maxFbremEndcaps"),
273 .isBarrel =
pset.getParameter<
bool>(
"isBarrel"),
274 .isEndcaps =
pset.getParameter<
bool>(
"isEndcaps"),
275 .isFiducial =
pset.getParameter<
bool>(
"isFiducial"),
276 .maxTIP =
pset.getParameter<
double>(
"maxTIP"),
277 .seedFromTEC =
pset.getParameter<
bool>(
"seedFromTEC"),
279 .multThresEE =
pset.getParameter<
double>(
"multThresEE"),
286 ecalSeedingParametersChecked_(
false),
287 electronPutToken_(produces<GsfElectronCollection>()),
288 gsfPfRecTracksTag_(consumes(
cfg.getParameter<
edm::InputTag>(
"gsfPfRecTracksTag"))),
289 useGsfPfRecTracks_(
cfg.getParameter<
bool>(
"useGsfPfRecTracks")),
290 resetMvaValuesUsingPFCandidates_(
cfg.getParameter<
bool>(
"resetMvaValuesUsingPFCandidates")) {
291 if (resetMvaValuesUsingPFCandidates_) {
292 egmPFCandidateCollection_ = consumes(
cfg.getParameter<
edm::InputTag>(
"egmPFCandidatesTag"));
295 inputCfg_.gsfElectronCores = consumes(
cfg.getParameter<
edm::InputTag>(
"gsfElectronCoresTag"));
296 inputCfg_.hcalTowersTag = consumes(
cfg.getParameter<
edm::InputTag>(
"hcalTowers"));
297 inputCfg_.barrelRecHitCollection = consumes(
cfg.getParameter<
edm::InputTag>(
"barrelRecHitCollectionTag"));
298 inputCfg_.endcapRecHitCollection = consumes(
cfg.getParameter<
edm::InputTag>(
"endcapRecHitCollectionTag"));
299 inputCfg_.ctfTracks = consumes(
cfg.getParameter<
edm::InputTag>(
"ctfTracksTag"));
302 inputCfg_.beamSpotTag = consumes(
cfg.getParameter<
edm::InputTag>(
"beamSpotTag"));
303 inputCfg_.vtxCollectionTag = consumes(
cfg.getParameter<
edm::InputTag>(
"vtxTag"));
304 if (
cfg.getParameter<
bool>(
"fillConvVtxFitProb"))
305 inputCfg_.conversions = consumes(
cfg.getParameter<
edm::InputTag>(
"conversionsTag"));
307 strategyCfg_.useDefaultEnergyCorrection =
cfg.getParameter<
bool>(
"useDefaultEnergyCorrection");
309 strategyCfg_.applyPreselection =
cfg.getParameter<
bool>(
"applyPreselection");
310 strategyCfg_.ecalDrivenEcalEnergyFromClassBasedParameterization =
311 cfg.getParameter<
bool>(
"ecalDrivenEcalEnergyFromClassBasedParameterization");
312 strategyCfg_.ecalDrivenEcalErrorFromClassBasedParameterization =
313 cfg.getParameter<
bool>(
"ecalDrivenEcalErrorFromClassBasedParameterization");
314 strategyCfg_.pureTrackerDrivenEcalErrorFromSimpleParameterization =
315 cfg.getParameter<
bool>(
"pureTrackerDrivenEcalErrorFromSimpleParameterization");
316 strategyCfg_.applyAmbResolution =
cfg.getParameter<
bool>(
"applyAmbResolution");
317 strategyCfg_.ignoreNotPreselected =
cfg.getParameter<
bool>(
"ignoreNotPreselected");
318 strategyCfg_.ambSortingStrategy =
cfg.getParameter<
unsigned>(
"ambSortingStrategy");
319 strategyCfg_.ambClustersOverlapStrategy =
cfg.getParameter<
unsigned>(
"ambClustersOverlapStrategy");
320 strategyCfg_.ctfTracksCheck =
cfg.getParameter<
bool>(
"ctfTracksCheck");
321 strategyCfg_.PreSelectMVA =
cfg.getParameter<
double>(
"PreSelectMVA");
322 strategyCfg_.MaxElePtForOnlyMVA =
cfg.getParameter<
double>(
"MaxElePtForOnlyMVA");
323 strategyCfg_.useEcalRegression =
cfg.getParameter<
bool>(
"useEcalRegression");
324 strategyCfg_.useCombinationRegression =
cfg.getParameter<
bool>(
"useCombinationRegression");
325 strategyCfg_.fillConvVtxFitProb =
cfg.getParameter<
bool>(
"fillConvVtxFitProb");
329 hcalCfg_.hOverEConeSize = psetPreselection.
getParameter<
double>(
"hOverEConeSize");
330 if (hcalCfg_.hOverEConeSize > 0) {
331 hcalCfg_.useTowers =
true;
332 hcalCfg_.checkHcalStatus =
cfg.getParameter<
bool>(
"checkHcalStatus");
333 hcalCfg_.hcalTowers = consumes(
cfg.getParameter<
edm::InputTag>(
"hcalTowers"));
334 hcalCfg_.hOverEPtMin = psetPreselection.getParameter<
double>(
"hOverEPtMin");
339 auto const& flagnamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedBarrel");
341 auto const& flagnamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedEndcaps");
343 auto const& severitynamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedBarrel");
345 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesbarrel);
346 auto const& severitynamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedEndcaps");
348 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesendcaps);
353 .etMinHcal =
cfg.getParameter<
double>(
"etMinHcal"),
354 .intRadiusEcalBarrel =
cfg.getParameter<
double>(
"intRadiusEcalBarrel"),
355 .intRadiusEcalEndcaps =
cfg.getParameter<
double>(
"intRadiusEcalEndcaps"),
356 .jurassicWidth =
cfg.getParameter<
double>(
"jurassicWidth"),
358 .eMinBarrel =
cfg.getParameter<
double>(
"eMinBarrel"),
359 .etMinEndcaps =
cfg.getParameter<
double>(
"etMinEndcaps"),
360 .eMinEndcaps =
cfg.getParameter<
double>(
"eMinEndcaps"),
362 .useNumCrystals =
cfg.getParameter<
bool>(
"useNumCrystals")};
366 .ecalWeightsFromDB =
cfg.getParameter<
bool>(
"ecalWeightsFromDB"),
367 .ecalRegressionWeightFiles =
cfg.getParameter<std::vector<std::string>>(
"ecalRefinedRegressionWeightFiles"),
369 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightLabels"),
370 .combinationWeightsFromDB =
cfg.getParameter<
bool>(
"combinationWeightsFromDB"),
371 .combinationRegressionWeightFiles =
372 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightFile")};
375 algo_ = std::make_unique<GsfElectronAlgo>(
388 consumesCollector());
392 if (!
pset.exists(
"SeedConfiguration")) {
397 if (seedConfiguration.
getParameter<
bool>(
"applyHOverECut")) {
402 << seedConfiguration.
getParameter<
double>(
"hOverEConeSize") <<
").";
406 <<
"The max barrel cone H/E is lower than during ecal seeding.";
410 <<
"The max endcaps cone H/E is lower than during ecal seeding.";
416 <<
"The minimum super-cluster Et in barrel is lower than during ecal seeding.";
420 <<
"The minimum super-cluster Et in endcaps is lower than during ecal seeding.";
443 throw cms::Exception(
"GsfElectronAlgo|UnknownAmbiguitySortingStrategy")
458 if (gsfPfRecTrack.gsfTrackRef() ==
e1.gsfTrack()) {
460 edm::LogWarning(
"GsfElectronAlgo") <<
"associated gsfPfRecTrack already found";
463 for (
auto const& duplicate : gsfPfRecTrack.convBremGsfPFRecTrackRef()) {
464 e1.addAmbiguousGsfTrack(duplicate->gsfTrackRef());
481 LogDebug(
"GsfElectronAlgo") <<
"Blessing electron with E/P " <<
e1->eSuperClusterOverP() <<
", cluster "
482 << scRef1.
get() <<
" & track " <<
e1->gsfTrack().get();
484 for (
auto e2 =
e1 + 1; e2 !=
electrons.end(); ++e2) {
494 bool sameCluster =
false;
496 sameCluster = (scRef1 == scRef2);
506 throw cms::Exception(
"GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")
512 LogDebug(
"GsfElectronAlgo") <<
"Discarding electron with E/P " << e2->eSuperClusterOverP() <<
", cluster "
513 << scRef2.
get() <<
" and track " << e2->gsfTrack().get();
514 e1->addAmbiguousGsfTrack(e2->gsfTrack());
515 e2->setAmbiguous(
true);
516 }
else if (
e1->gsfTrack() == e2->gsfTrack()) {
517 edm::LogWarning(
"GsfElectronAlgo") <<
"Forgetting electron with E/P " << e2->eSuperClusterOverP()
518 <<
", cluster " << scRef2.
get() <<
" and track " << e2->gsfTrack().get();
519 e2->setAmbiguous(
true);
534 return passmva && passCutBased;
538 return passCutBased || passPF || passmva;
548 if (!
seeds.isValid()) {
550 <<
"Cannot check consistency of parameters with ecal seeding ones,"
551 <<
" because the original collection of seeds is not any more available.";
562 el.setMvaInput(gsfMVAInputMap.find(el.gsfTrack())->
second);
566 logElectrons(
electrons,
event,
"GsfElectronAlgo Info (before preselection)");
572 logElectrons(
electrons,
event,
"GsfElectronAlgo Info (after preselection)");
579 logElectrons(
electrons,
event,
"GsfElectronAlgo Info (after amb. solving)");