36 el.setMvaOutput(mvaOutput);
43 auto matchWithPFCandidates(std::vector<reco::PFCandidate>
const&
pfCandidates) {
44 std::map<reco::GsfTrackRef, reco::GsfElectron::MvaInput> gsfMVAInputs{};
50 if (pfCand.gsfTrackRef().isNonnull()) {
55 input.sigmaEtaEta = pfCand.egammaExtraRef()->sigmaEtaEta();
56 input.hadEnergy = pfCand.egammaExtraRef()->hadEnergy();
57 gsfMVAInputs[pfCand.gsfTrackRef()] =
input;
64 LogTrace(
"GsfElectronAlgo") <<
"========== " <<
title <<
" ==========";
65 LogTrace(
"GsfElectronAlgo") <<
"Event: " <<
event.id();
68 LogTrace(
"GsfElectronAlgo") <<
"Electron with charge, pt, eta, phi: " << ele.charge() <<
" , " << ele.pt()
69 <<
" , " << ele.eta() <<
" , " << ele.phi();
71 LogTrace(
"GsfElectronAlgo") <<
"=================================================";
83 return std::make_unique<GsfElectronAlgo::HeavyObjectCache>(conf);
92 std::unique_ptr<GsfElectronAlgo>
algo_;
103 bool ignoreNotPreselected =
true)
const;
121 desc.
add<
edm::InputTag>(
"gsfElectronCoresTag", {
"ecalDrivenGsfElectronCores"});
126 desc.
add<
edm::InputTag>(
"barrelRecHitCollectionTag", {
"ecalRecHit",
"EcalRecHitsEB"});
127 desc.
add<
edm::InputTag>(
"endcapRecHitCollectionTag", {
"ecalRecHit",
"EcalRecHitsEE"});
131 desc.
add<
bool>(
"checkHcalStatus",
true);
134 desc.
add<
bool>(
"useCombinationRegression",
false);
135 desc.
add<
bool>(
"ecalDrivenEcalEnergyFromClassBasedParameterization",
true);
136 desc.
add<
bool>(
"ecalDrivenEcalErrorFromClassBasedParameterization",
true);
137 desc.
add<
bool>(
"applyPreselection",
false);
138 desc.
add<
bool>(
"useEcalRegression",
false);
139 desc.
add<
bool>(
"applyAmbResolution",
false);
140 desc.
add<
bool>(
"useGsfPfRecTracks",
true);
141 desc.
add<
bool>(
"pureTrackerDrivenEcalErrorFromSimpleParameterization",
true);
142 desc.
add<
unsigned int>(
"ambSortingStrategy", 1);
143 desc.
add<
unsigned int>(
"ambClustersOverlapStrategy", 1);
144 desc.
add<
bool>(
"fillConvVtxFitProb",
true);
145 desc.
add<
bool>(
"resetMvaValuesUsingPFCandidates",
false);
148 desc.
add<std::vector<std::string>>(
"recHitFlagsToBeExcludedBarrel");
149 desc.
add<std::vector<std::string>>(
"recHitFlagsToBeExcludedEndcaps");
150 desc.
add<std::vector<std::string>>(
"recHitSeverityToBeExcludedBarrel");
151 desc.
add<std::vector<std::string>>(
"recHitSeverityToBeExcludedEndcaps");
158 desc.
add<
bool>(
"useNumCrystals",
true);
159 desc.
add<
double>(
"etMinBarrel", 0.0);
160 desc.
add<
double>(
"etMinEndcaps", 0.11);
161 desc.
add<
double>(
"etMinHcal", 0.0);
162 desc.
add<
double>(
"eMinBarrel", 0.095);
163 desc.
add<
double>(
"eMinEndcaps", 0.0);
164 desc.
add<
double>(
"intRadiusEcalBarrel", 3.0);
165 desc.
add<
double>(
"intRadiusEcalEndcaps", 3.0);
166 desc.
add<
double>(
"intRadiusHcal", 0.15);
167 desc.
add<
double>(
"jurassicWidth", 1.5);
168 desc.
add<
bool>(
"vetoClustered",
false);
171 desc.
add<
bool>(
"ctfTracksCheck",
true);
174 desc.
add<
double>(
"MaxElePtForOnlyMVA", 50.0);
175 desc.
add<
double>(
"PreSelectMVA", -0.1);
179 psd0.
add<
double>(
"minSCEtBarrel", 4.0);
180 psd0.
add<
double>(
"minSCEtEndcaps", 4.0);
181 psd0.
add<
double>(
"minEOverPBarrel", 0.0);
182 psd0.
add<
double>(
"minEOverPEndcaps", 0.0);
183 psd0.
add<
double>(
"maxEOverPBarrel", 999999999.0);
184 psd0.
add<
double>(
"maxEOverPEndcaps", 999999999.0);
185 psd0.
add<
double>(
"maxDeltaEtaBarrel", 0.02);
186 psd0.
add<
double>(
"maxDeltaEtaEndcaps", 0.02);
187 psd0.
add<
double>(
"maxDeltaPhiBarrel", 0.15);
188 psd0.
add<
double>(
"maxDeltaPhiEndcaps", 0.15);
189 psd0.
add<
double>(
"hOverEConeSize", 0.15);
190 psd0.
add<
double>(
"hOverEPtMin", 0.0);
191 psd0.
add<
double>(
"maxHOverEBarrelCone", 0.15);
192 psd0.
add<
double>(
"maxHOverEEndcapsCone", 0.15);
193 psd0.
add<
double>(
"maxHBarrelCone", 0.0);
194 psd0.
add<
double>(
"maxHEndcapsCone", 0.0);
195 psd0.
add<
double>(
"maxHOverEBarrelTower", 0.15);
196 psd0.
add<
double>(
"maxHOverEEndcapsTower", 0.15);
197 psd0.
add<
double>(
"maxHBarrelTower", 0.0);
198 psd0.
add<
double>(
"maxHEndcapsTower", 0.0);
199 psd0.
add<
double>(
"maxSigmaIetaIetaBarrel", 999999999.0);
200 psd0.
add<
double>(
"maxSigmaIetaIetaEndcaps", 999999999.0);
201 psd0.
add<
double>(
"maxFbremBarrel", 999999999.0);
202 psd0.
add<
double>(
"maxFbremEndcaps", 999999999.0);
203 psd0.
add<
bool>(
"isBarrel",
false);
204 psd0.
add<
bool>(
"isEndcaps",
false);
205 psd0.
add<
bool>(
"isFiducial",
false);
206 psd0.
add<
bool>(
"seedFromTEC",
true);
207 psd0.
add<
double>(
"maxTIP", 999999999.0);
208 psd0.
add<
double>(
"minMVA", -0.4);
209 psd0.
add<
double>(
"minMvaByPassForIsolated", -0.4);
215 desc.
add<
std::string>(
"superClusterErrorFunction",
"EcalClusterEnergyUncertaintyObjectSpecific");
216 desc.
add<
std::string>(
"crackCorrectionFunction",
"EcalClusterCrackCorrection");
218 desc.
add<
bool>(
"ecalWeightsFromDB",
true);
219 desc.
add<std::vector<std::string>>(
"ecalRefinedRegressionWeightFiles", {})
220 ->setComment(
"if not from DB. Otherwise, keep empty");
221 desc.
add<
bool>(
"combinationWeightsFromDB",
true);
222 desc.
add<std::vector<std::string>>(
"combinationRegressionWeightFile", {})
223 ->setComment(
"if not from DB. Otherwise, keep empty");
226 desc.
add<std::vector<std::string>>(
"ecalRefinedRegressionWeightLabels", {});
227 desc.
add<std::vector<std::string>>(
"combinationRegressionWeightLabels", {});
229 desc.
add<std::vector<std::string>>(
230 "ElecMVAFilesString",
232 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_10_17Feb2011.weights.xml",
233 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_12_17Feb2011.weights.xml",
234 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_20_17Feb2011.weights.xml",
235 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_22_17Feb2011.weights.xml",
237 desc.
add<std::vector<std::string>>(
238 "SoftElecMVAFilesString",
240 "RecoEgamma/ElectronIdentification/data/TMVA_BDTSoftElectrons_7Feb2014.weights.xml",
243 descriptions.
add(
"gsfElectronProducer", desc);
251 .maxEOverPBarrel =
pset.getParameter<
double>(
"maxEOverPBarrel"),
253 .minEOverPBarrel =
pset.getParameter<
double>(
"minEOverPBarrel"),
254 .minEOverPEndcaps =
pset.getParameter<
double>(
"minEOverPEndcaps"),
255 .maxHOverEBarrelCone =
pset.getParameter<
double>(
"maxHOverEBarrelCone"),
257 .maxHBarrelCone =
pset.getParameter<
double>(
"maxHBarrelCone"),
258 .maxHEndcapsCone =
pset.getParameter<
double>(
"maxHEndcapsCone"),
259 .maxHOverEBarrelTower =
pset.getParameter<
double>(
"maxHOverEBarrelTower"),
261 .maxHBarrelTower =
pset.getParameter<
double>(
"maxHBarrelTower"),
262 .maxHEndcapsTower =
pset.getParameter<
double>(
"maxHEndcapsTower"),
263 .maxDeltaEtaBarrel =
pset.getParameter<
double>(
"maxDeltaEtaBarrel"),
264 .maxDeltaEtaEndcaps =
pset.getParameter<
double>(
"maxDeltaEtaEndcaps"),
265 .maxDeltaPhiBarrel =
pset.getParameter<
double>(
"maxDeltaPhiBarrel"),
266 .maxDeltaPhiEndcaps =
pset.getParameter<
double>(
"maxDeltaPhiEndcaps"),
267 .maxSigmaIetaIetaBarrel =
pset.getParameter<
double>(
"maxSigmaIetaIetaBarrel"),
268 .maxSigmaIetaIetaEndcaps =
pset.getParameter<
double>(
"maxSigmaIetaIetaEndcaps"),
269 .maxFbremBarrel =
pset.getParameter<
double>(
"maxFbremBarrel"),
270 .maxFbremEndcaps =
pset.getParameter<
double>(
"maxFbremEndcaps"),
271 .isBarrel =
pset.getParameter<
bool>(
"isBarrel"),
272 .isEndcaps =
pset.getParameter<
bool>(
"isEndcaps"),
273 .isFiducial =
pset.getParameter<
bool>(
"isFiducial"),
274 .
minMVA =
pset.getParameter<
double>(
"minMVA"),
275 .minMvaByPassForIsolated =
pset.getParameter<
double>(
"minMvaByPassForIsolated"),
276 .maxTIP =
pset.getParameter<
double>(
"maxTIP"),
277 .seedFromTEC =
pset.getParameter<
bool>(
"seedFromTEC"),
284 ecalSeedingParametersChecked_(
false),
285 electronPutToken_(produces<GsfElectronCollection>()),
286 gsfPfRecTracksTag_(consumes<reco::GsfPFRecTrackCollection>(
cfg.getParameter<
edm::InputTag>(
"gsfPfRecTracksTag"))),
287 useGsfPfRecTracks_(
cfg.getParameter<
bool>(
"useGsfPfRecTracks")),
288 resetMvaValuesUsingPFCandidates_(
cfg.getParameter<
bool>(
"resetMvaValuesUsingPFCandidates")) {
289 if (resetMvaValuesUsingPFCandidates_) {
290 egmPFCandidateCollection_ =
291 consumes<reco::PFCandidateCollection>(
cfg.getParameter<
edm::InputTag>(
"egmPFCandidatesTag"));
294 inputCfg_.gsfElectronCores =
295 consumes<reco::GsfElectronCoreCollection>(
cfg.getParameter<
edm::InputTag>(
"gsfElectronCoresTag"));
296 inputCfg_.hcalTowersTag = consumes<CaloTowerCollection>(
cfg.getParameter<
edm::InputTag>(
"hcalTowers"));
297 inputCfg_.barrelRecHitCollection =
298 consumes<EcalRecHitCollection>(
cfg.getParameter<
edm::InputTag>(
"barrelRecHitCollectionTag"));
299 inputCfg_.endcapRecHitCollection =
300 consumes<EcalRecHitCollection>(
cfg.getParameter<
edm::InputTag>(
"endcapRecHitCollectionTag"));
301 inputCfg_.ctfTracks = consumes<reco::TrackCollection>(
cfg.getParameter<
edm::InputTag>(
"ctfTracksTag"));
303 inputCfg_.seedsTag = consumes<reco::ElectronSeedCollection>(
cfg.getParameter<
edm::InputTag>(
"seedsTag"));
304 inputCfg_.beamSpotTag = consumes<reco::BeamSpot>(
cfg.getParameter<
edm::InputTag>(
"beamSpotTag"));
305 inputCfg_.vtxCollectionTag = consumes<reco::VertexCollection>(
cfg.getParameter<
edm::InputTag>(
"vtxTag"));
306 if (
cfg.getParameter<
bool>(
"fillConvVtxFitProb"))
307 inputCfg_.conversions = consumes<reco::ConversionCollection>(
cfg.getParameter<
edm::InputTag>(
"conversionsTag"));
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_.ambSortingStrategy =
cfg.getParameter<
unsigned>(
"ambSortingStrategy");
318 strategyCfg_.ambClustersOverlapStrategy =
cfg.getParameter<
unsigned>(
"ambClustersOverlapStrategy");
319 strategyCfg_.ctfTracksCheck =
cfg.getParameter<
bool>(
"ctfTracksCheck");
320 strategyCfg_.PreSelectMVA =
cfg.getParameter<
double>(
"PreSelectMVA");
321 strategyCfg_.MaxElePtForOnlyMVA =
cfg.getParameter<
double>(
"MaxElePtForOnlyMVA");
322 strategyCfg_.useEcalRegression =
cfg.getParameter<
bool>(
"useEcalRegression");
323 strategyCfg_.useCombinationRegression =
cfg.getParameter<
bool>(
"useCombinationRegression");
324 strategyCfg_.fillConvVtxFitProb =
cfg.getParameter<
bool>(
"fillConvVtxFitProb");
328 hcalCfg_.hOverEConeSize = psetPreselection.
getParameter<
double>(
"hOverEConeSize");
329 if (hcalCfg_.hOverEConeSize > 0) {
330 hcalCfg_.useTowers =
true;
331 hcalCfg_.checkHcalStatus =
cfg.getParameter<
bool>(
"checkHcalStatus");
332 hcalCfg_.hcalTowers = consumes<CaloTowerCollection>(
cfg.getParameter<
edm::InputTag>(
"hcalTowers"));
333 hcalCfg_.hOverEPtMin = psetPreselection.getParameter<
double>(
"hOverEPtMin");
338 auto const& flagnamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedBarrel");
340 auto const& flagnamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedEndcaps");
342 auto const& severitynamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedBarrel");
344 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesbarrel);
345 auto const& severitynamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedEndcaps");
347 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesendcaps);
352 .etMinHcal =
cfg.getParameter<
double>(
"etMinHcal"),
353 .intRadiusEcalBarrel =
cfg.getParameter<
double>(
"intRadiusEcalBarrel"),
354 .intRadiusEcalEndcaps =
cfg.getParameter<
double>(
"intRadiusEcalEndcaps"),
355 .jurassicWidth =
cfg.getParameter<
double>(
"jurassicWidth"),
357 .eMinBarrel =
cfg.getParameter<
double>(
"eMinBarrel"),
358 .etMinEndcaps =
cfg.getParameter<
double>(
"etMinEndcaps"),
359 .eMinEndcaps =
cfg.getParameter<
double>(
"eMinEndcaps"),
361 .useNumCrystals =
cfg.getParameter<
bool>(
"useNumCrystals")};
365 .ecalWeightsFromDB =
cfg.getParameter<
bool>(
"ecalWeightsFromDB"),
366 .ecalRegressionWeightFiles =
cfg.getParameter<std::vector<std::string>>(
"ecalRefinedRegressionWeightFiles"),
368 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightLabels"),
369 .combinationWeightsFromDB =
cfg.getParameter<
bool>(
"combinationWeightsFromDB"),
370 .combinationRegressionWeightFiles =
371 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightFile")};
374 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.";
430 bool ignoreNotPreselected)
const {
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)");