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_;
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>(
"useDefaultEnergyCorrection",
true);
135 desc.
add<
bool>(
"useCombinationRegression",
false);
136 desc.
add<
bool>(
"ecalDrivenEcalEnergyFromClassBasedParameterization",
true);
137 desc.
add<
bool>(
"ecalDrivenEcalErrorFromClassBasedParameterization",
true);
138 desc.
add<
bool>(
"applyPreselection",
false);
139 desc.
add<
bool>(
"useEcalRegression",
false);
140 desc.
add<
bool>(
"applyAmbResolution",
false);
141 desc.
add<
bool>(
"ignoreNotPreselected",
true);
142 desc.
add<
bool>(
"useGsfPfRecTracks",
true);
143 desc.
add<
bool>(
"pureTrackerDrivenEcalErrorFromSimpleParameterization",
true);
144 desc.
add<
unsigned int>(
"ambSortingStrategy", 1);
145 desc.
add<
unsigned int>(
"ambClustersOverlapStrategy", 1);
146 desc.
add<
bool>(
"fillConvVtxFitProb",
true);
147 desc.
add<
bool>(
"resetMvaValuesUsingPFCandidates",
false);
150 desc.
add<std::vector<std::string>>(
"recHitFlagsToBeExcludedBarrel");
151 desc.
add<std::vector<std::string>>(
"recHitFlagsToBeExcludedEndcaps");
152 desc.
add<std::vector<std::string>>(
"recHitSeverityToBeExcludedBarrel");
153 desc.
add<std::vector<std::string>>(
"recHitSeverityToBeExcludedEndcaps");
160 desc.
add<
bool>(
"useNumCrystals",
true);
161 desc.
add<
double>(
"etMinBarrel", 0.0);
162 desc.
add<
double>(
"etMinEndcaps", 0.11);
163 desc.
add<
double>(
"etMinHcal", 0.0);
164 desc.
add<
double>(
"eMinBarrel", 0.095);
165 desc.
add<
double>(
"eMinEndcaps", 0.0);
166 desc.
add<
double>(
"intRadiusEcalBarrel", 3.0);
167 desc.
add<
double>(
"intRadiusEcalEndcaps", 3.0);
168 desc.
add<
double>(
"intRadiusHcal", 0.15);
169 desc.
add<
double>(
"jurassicWidth", 1.5);
170 desc.
add<
bool>(
"vetoClustered",
false);
173 desc.
add<
bool>(
"ctfTracksCheck",
true);
176 desc.
add<
double>(
"MaxElePtForOnlyMVA", 50.0);
177 desc.
add<
double>(
"PreSelectMVA", -0.1);
181 psd0.
add<
double>(
"minSCEtBarrel", 4.0);
182 psd0.
add<
double>(
"minSCEtEndcaps", 4.0);
183 psd0.
add<
double>(
"minEOverPBarrel", 0.0);
184 psd0.
add<
double>(
"minEOverPEndcaps", 0.0);
185 psd0.
add<
double>(
"maxEOverPBarrel", 999999999.0);
186 psd0.
add<
double>(
"maxEOverPEndcaps", 999999999.0);
187 psd0.
add<
double>(
"maxDeltaEtaBarrel", 0.02);
188 psd0.
add<
double>(
"maxDeltaEtaEndcaps", 0.02);
189 psd0.
add<
double>(
"maxDeltaPhiBarrel", 0.15);
190 psd0.
add<
double>(
"maxDeltaPhiEndcaps", 0.15);
191 psd0.
add<
double>(
"hOverEConeSize", 0.15);
192 psd0.
add<
double>(
"hOverEPtMin", 0.0);
193 psd0.
add<
double>(
"maxHOverEBarrelCone", 0.15);
194 psd0.
add<
double>(
"maxHOverEEndcapsCone", 0.15);
195 psd0.
add<
double>(
"maxHBarrelCone", 0.0);
196 psd0.
add<
double>(
"maxHEndcapsCone", 0.0);
197 psd0.
add<
double>(
"maxHOverEBarrelTower", 0.15);
198 psd0.
add<
double>(
"maxHOverEEndcapsTower", 0.15);
199 psd0.
add<
double>(
"maxHBarrelTower", 0.0);
200 psd0.
add<
double>(
"maxHEndcapsTower", 0.0);
201 psd0.
add<
double>(
"maxSigmaIetaIetaBarrel", 999999999.0);
202 psd0.
add<
double>(
"maxSigmaIetaIetaEndcaps", 999999999.0);
203 psd0.
add<
double>(
"maxFbremBarrel", 999999999.0);
204 psd0.
add<
double>(
"maxFbremEndcaps", 999999999.0);
205 psd0.
add<
bool>(
"isBarrel",
false);
206 psd0.
add<
bool>(
"isEndcaps",
false);
207 psd0.
add<
bool>(
"isFiducial",
false);
208 psd0.
add<
bool>(
"seedFromTEC",
true);
209 psd0.
add<
double>(
"maxTIP", 999999999.0);
210 psd0.
add<
double>(
"minMVA", -0.4);
211 psd0.
add<
double>(
"minMvaByPassForIsolated", -0.4);
217 desc.
add<
std::string>(
"superClusterErrorFunction",
"EcalClusterEnergyUncertaintyObjectSpecific");
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 .
minMVA =
pset.getParameter<
double>(
"minMVA"),
277 .minMvaByPassForIsolated =
pset.getParameter<
double>(
"minMvaByPassForIsolated"),
278 .maxTIP =
pset.getParameter<
double>(
"maxTIP"),
279 .seedFromTEC =
pset.getParameter<
bool>(
"seedFromTEC"),
286 ecalSeedingParametersChecked_(
false),
287 electronPutToken_(produces<GsfElectronCollection>()),
288 gsfPfRecTracksTag_(consumes<reco::GsfPFRecTrackCollection>(
cfg.getParameter<
edm::InputTag>(
"gsfPfRecTracksTag"))),
289 useGsfPfRecTracks_(
cfg.getParameter<
bool>(
"useGsfPfRecTracks")),
290 resetMvaValuesUsingPFCandidates_(
cfg.getParameter<
bool>(
"resetMvaValuesUsingPFCandidates")) {
291 if (resetMvaValuesUsingPFCandidates_) {
292 egmPFCandidateCollection_ =
293 consumes<reco::PFCandidateCollection>(
cfg.getParameter<
edm::InputTag>(
"egmPFCandidatesTag"));
296 inputCfg_.gsfElectronCores =
297 consumes<reco::GsfElectronCoreCollection>(
cfg.getParameter<
edm::InputTag>(
"gsfElectronCoresTag"));
298 inputCfg_.hcalTowersTag = consumes<CaloTowerCollection>(
cfg.getParameter<
edm::InputTag>(
"hcalTowers"));
299 inputCfg_.barrelRecHitCollection =
300 consumes<EcalRecHitCollection>(
cfg.getParameter<
edm::InputTag>(
"barrelRecHitCollectionTag"));
301 inputCfg_.endcapRecHitCollection =
302 consumes<EcalRecHitCollection>(
cfg.getParameter<
edm::InputTag>(
"endcapRecHitCollectionTag"));
303 inputCfg_.ctfTracks = consumes<reco::TrackCollection>(
cfg.getParameter<
edm::InputTag>(
"ctfTracksTag"));
305 inputCfg_.seedsTag = consumes<reco::ElectronSeedCollection>(
cfg.getParameter<
edm::InputTag>(
"seedsTag"));
306 inputCfg_.beamSpotTag = consumes<reco::BeamSpot>(
cfg.getParameter<
edm::InputTag>(
"beamSpotTag"));
307 inputCfg_.vtxCollectionTag = consumes<reco::VertexCollection>(
cfg.getParameter<
edm::InputTag>(
"vtxTag"));
308 if (
cfg.getParameter<
bool>(
"fillConvVtxFitProb"))
309 inputCfg_.conversions = consumes<reco::ConversionCollection>(
cfg.getParameter<
edm::InputTag>(
"conversionsTag"));
311 strategyCfg_.useDefaultEnergyCorrection =
cfg.getParameter<
bool>(
"useDefaultEnergyCorrection");
312 strategyCfg_.applyPreselection =
cfg.getParameter<
bool>(
"applyPreselection");
313 strategyCfg_.ecalDrivenEcalEnergyFromClassBasedParameterization =
314 cfg.getParameter<
bool>(
"ecalDrivenEcalEnergyFromClassBasedParameterization");
315 strategyCfg_.ecalDrivenEcalErrorFromClassBasedParameterization =
316 cfg.getParameter<
bool>(
"ecalDrivenEcalErrorFromClassBasedParameterization");
317 strategyCfg_.pureTrackerDrivenEcalErrorFromSimpleParameterization =
318 cfg.getParameter<
bool>(
"pureTrackerDrivenEcalErrorFromSimpleParameterization");
319 strategyCfg_.applyAmbResolution =
cfg.getParameter<
bool>(
"applyAmbResolution");
320 strategyCfg_.ignoreNotPreselected =
cfg.getParameter<
bool>(
"ignoreNotPreselected");
321 strategyCfg_.ambSortingStrategy =
cfg.getParameter<
unsigned>(
"ambSortingStrategy");
322 strategyCfg_.ambClustersOverlapStrategy =
cfg.getParameter<
unsigned>(
"ambClustersOverlapStrategy");
323 strategyCfg_.ctfTracksCheck =
cfg.getParameter<
bool>(
"ctfTracksCheck");
324 strategyCfg_.PreSelectMVA =
cfg.getParameter<
double>(
"PreSelectMVA");
325 strategyCfg_.MaxElePtForOnlyMVA =
cfg.getParameter<
double>(
"MaxElePtForOnlyMVA");
326 strategyCfg_.useEcalRegression =
cfg.getParameter<
bool>(
"useEcalRegression");
327 strategyCfg_.useCombinationRegression =
cfg.getParameter<
bool>(
"useCombinationRegression");
328 strategyCfg_.fillConvVtxFitProb =
cfg.getParameter<
bool>(
"fillConvVtxFitProb");
332 hcalCfg_.hOverEConeSize = psetPreselection.
getParameter<
double>(
"hOverEConeSize");
333 if (hcalCfg_.hOverEConeSize > 0) {
334 hcalCfg_.useTowers =
true;
335 hcalCfg_.checkHcalStatus =
cfg.getParameter<
bool>(
"checkHcalStatus");
336 hcalCfg_.hcalTowers = consumes<CaloTowerCollection>(
cfg.getParameter<
edm::InputTag>(
"hcalTowers"));
337 hcalCfg_.hOverEPtMin = psetPreselection.getParameter<
double>(
"hOverEPtMin");
342 auto const& flagnamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedBarrel");
344 auto const& flagnamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedEndcaps");
346 auto const& severitynamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedBarrel");
348 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesbarrel);
349 auto const& severitynamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedEndcaps");
351 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesendcaps);
356 .etMinHcal =
cfg.getParameter<
double>(
"etMinHcal"),
357 .intRadiusEcalBarrel =
cfg.getParameter<
double>(
"intRadiusEcalBarrel"),
358 .intRadiusEcalEndcaps =
cfg.getParameter<
double>(
"intRadiusEcalEndcaps"),
359 .jurassicWidth =
cfg.getParameter<
double>(
"jurassicWidth"),
361 .eMinBarrel =
cfg.getParameter<
double>(
"eMinBarrel"),
362 .etMinEndcaps =
cfg.getParameter<
double>(
"etMinEndcaps"),
363 .eMinEndcaps =
cfg.getParameter<
double>(
"eMinEndcaps"),
365 .useNumCrystals =
cfg.getParameter<
bool>(
"useNumCrystals")};
369 .ecalWeightsFromDB =
cfg.getParameter<
bool>(
"ecalWeightsFromDB"),
370 .ecalRegressionWeightFiles =
cfg.getParameter<std::vector<std::string>>(
"ecalRefinedRegressionWeightFiles"),
372 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightLabels"),
373 .combinationWeightsFromDB =
cfg.getParameter<
bool>(
"combinationWeightsFromDB"),
374 .combinationRegressionWeightFiles =
375 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightFile")};
378 algo_ = std::make_unique<GsfElectronAlgo>(
392 consumesCollector());
396 if (!
pset.exists(
"SeedConfiguration")) {
401 if (seedConfiguration.
getParameter<
bool>(
"applyHOverECut")) {
406 << seedConfiguration.
getParameter<
double>(
"hOverEConeSize") <<
").";
410 <<
"The max barrel cone H/E is lower than during ecal seeding.";
414 <<
"The max endcaps cone H/E is lower than during ecal seeding.";
420 <<
"The minimum super-cluster Et in barrel is lower than during ecal seeding.";
424 <<
"The minimum super-cluster Et in endcaps is lower than during ecal seeding.";
447 throw cms::Exception(
"GsfElectronAlgo|UnknownAmbiguitySortingStrategy")
462 if (gsfPfRecTrack.gsfTrackRef() ==
e1.gsfTrack()) {
464 edm::LogWarning(
"GsfElectronAlgo") <<
"associated gsfPfRecTrack already found";
467 for (
auto const& duplicate : gsfPfRecTrack.convBremGsfPFRecTrackRef()) {
468 e1.addAmbiguousGsfTrack(duplicate->gsfTrackRef());
485 LogDebug(
"GsfElectronAlgo") <<
"Blessing electron with E/P " <<
e1->eSuperClusterOverP() <<
", cluster "
486 << scRef1.
get() <<
" & track " <<
e1->gsfTrack().get();
488 for (
auto e2 =
e1 + 1; e2 !=
electrons.end(); ++e2) {
498 bool sameCluster =
false;
500 sameCluster = (scRef1 == scRef2);
510 throw cms::Exception(
"GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")
516 LogDebug(
"GsfElectronAlgo") <<
"Discarding electron with E/P " << e2->eSuperClusterOverP() <<
", cluster "
517 << scRef2.
get() <<
" and track " << e2->gsfTrack().get();
518 e1->addAmbiguousGsfTrack(e2->gsfTrack());
519 e2->setAmbiguous(
true);
520 }
else if (
e1->gsfTrack() == e2->gsfTrack()) {
521 edm::LogWarning(
"GsfElectronAlgo") <<
"Forgetting electron with E/P " << e2->eSuperClusterOverP()
522 <<
", cluster " << scRef2.
get() <<
" and track " << e2->gsfTrack().get();
523 e2->setAmbiguous(
true);
538 return passmva && passCutBased;
542 return passCutBased || passPF || passmva;
552 if (!
seeds.isValid()) {
554 <<
"Cannot check consistency of parameters with ecal seeding ones,"
555 <<
" because the original collection of seeds is not any more available.";
566 el.setMvaInput(gsfMVAInputMap.find(el.gsfTrack())->
second);
570 logElectrons(
electrons,
event,
"GsfElectronAlgo Info (before preselection)");
576 logElectrons(
electrons,
event,
"GsfElectronAlgo Info (after preselection)");
583 logElectrons(
electrons,
event,
"GsfElectronAlgo Info (after amb. solving)");