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_;
128 desc.add<
edm::InputTag>(
"barrelRecHitCollectionTag", {
"ecalRecHit",
"EcalRecHitsEB"});
129 desc.add<
edm::InputTag>(
"endcapRecHitCollectionTag", {
"ecalRecHit",
"EcalRecHitsEE"});
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");
157 desc.add<
bool>(
"checkHcalStatus",
true);
159 desc.add<std::vector<double>>(
"recHitEThresholdHB", {0., 0., 0., 0.});
160 desc.add<std::vector<double>>(
"recHitEThresholdHE", {0., 0., 0., 0., 0., 0., 0.});
161 desc.add<
int>(
"maxHcalRecHitSeverity", 999999);
162 desc.add<
bool>(
"hcalRun2EffDepth",
false);
169 desc.add<
bool>(
"useNumCrystals",
true);
170 desc.add<
double>(
"etMinBarrel", 0.0);
171 desc.add<
double>(
"etMinEndcaps", 0.11);
172 desc.add<
double>(
"etMinHcal", 0.0);
173 desc.add<
double>(
"eMinBarrel", 0.095);
174 desc.add<
double>(
"eMinEndcaps", 0.0);
175 desc.add<
double>(
"intRadiusEcalBarrel", 3.0);
176 desc.add<
double>(
"intRadiusEcalEndcaps", 3.0);
177 desc.add<
double>(
"intRadiusHcal", 0.15);
178 desc.add<
double>(
"jurassicWidth", 1.5);
179 desc.add<
bool>(
"vetoClustered",
false);
182 desc.add<
bool>(
"ctfTracksCheck",
true);
185 desc.add<
double>(
"MaxElePtForOnlyMVA", 50.0);
186 desc.add<
double>(
"PreSelectMVA", -0.1);
190 psd0.
add<
double>(
"minSCEtBarrel", 4.0);
191 psd0.
add<
double>(
"minSCEtEndcaps", 4.0);
192 psd0.
add<
double>(
"minEOverPBarrel", 0.0);
193 psd0.
add<
double>(
"minEOverPEndcaps", 0.0);
194 psd0.
add<
double>(
"maxEOverPBarrel", 999999999.0);
195 psd0.
add<
double>(
"maxEOverPEndcaps", 999999999.0);
196 psd0.
add<
double>(
"maxDeltaEtaBarrel", 0.02);
197 psd0.
add<
double>(
"maxDeltaEtaEndcaps", 0.02);
198 psd0.
add<
double>(
"maxDeltaPhiBarrel", 0.15);
199 psd0.
add<
double>(
"maxDeltaPhiEndcaps", 0.15);
200 psd0.
add<
double>(
"hOverEConeSize", 0.15);
201 psd0.
add<
double>(
"maxHOverEBarrelCone", 0.15);
202 psd0.
add<
double>(
"maxHOverEEndcapsCone", 0.15);
203 psd0.
add<
double>(
"maxHBarrelCone", 0.0);
204 psd0.
add<
double>(
"maxHEndcapsCone", 0.0);
205 psd0.
add<
double>(
"maxHOverEBarrelBc", 0.15);
206 psd0.
add<
double>(
"maxHOverEEndcapsBc", 0.15);
207 psd0.
add<
double>(
"maxHBarrelBc", 0.0);
208 psd0.
add<
double>(
"maxHEndcapsBc", 0.0);
209 psd0.
add<
double>(
"maxSigmaIetaIetaBarrel", 999999999.0);
210 psd0.
add<
double>(
"maxSigmaIetaIetaEndcaps", 999999999.0);
211 psd0.
add<
double>(
"maxFbremBarrel", 999999999.0);
212 psd0.
add<
double>(
"maxFbremEndcaps", 999999999.0);
213 psd0.
add<
bool>(
"isBarrel",
false);
214 psd0.
add<
bool>(
"isEndcaps",
false);
215 psd0.
add<
bool>(
"isFiducial",
false);
216 psd0.
add<
bool>(
"seedFromTEC",
true);
217 psd0.
add<
double>(
"maxTIP", 999999999.0);
225 desc.add<
std::string>(
"crackCorrectionFunction",
"EcalClusterCrackCorrection");
227 desc.add<
bool>(
"ecalWeightsFromDB",
true);
228 desc.add<std::vector<std::string>>(
"ecalRefinedRegressionWeightFiles", {})
229 ->setComment(
"if not from DB. Otherwise, keep empty");
230 desc.add<
bool>(
"combinationWeightsFromDB",
true);
231 desc.add<std::vector<std::string>>(
"combinationRegressionWeightFile", {})
232 ->setComment(
"if not from DB. Otherwise, keep empty");
235 desc.add<std::vector<std::string>>(
"ecalRefinedRegressionWeightLabels", {});
236 desc.add<std::vector<std::string>>(
"combinationRegressionWeightLabels", {});
238 desc.add<std::vector<std::string>>(
239 "ElecMVAFilesString",
241 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_10_17Feb2011.weights.xml",
242 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_12_17Feb2011.weights.xml",
243 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_20_17Feb2011.weights.xml",
244 "RecoEgamma/ElectronIdentification/data/TMVA_Category_BDTSimpleCat_22_17Feb2011.weights.xml",
246 desc.add<std::vector<std::string>>(
247 "SoftElecMVAFilesString",
249 "RecoEgamma/ElectronIdentification/data/TMVA_BDTSoftElectrons_7Feb2014.weights.xml",
252 descriptions.
add(
"gsfElectronProducerDefault",
desc);
260 .maxEOverPBarrel =
pset.getParameter<
double>(
"maxEOverPBarrel"),
262 .minEOverPBarrel =
pset.getParameter<
double>(
"minEOverPBarrel"),
263 .minEOverPEndcaps =
pset.getParameter<
double>(
"minEOverPEndcaps"),
264 .maxHOverEBarrelCone =
pset.getParameter<
double>(
"maxHOverEBarrelCone"),
266 .maxHBarrelCone =
pset.getParameter<
double>(
"maxHBarrelCone"),
267 .maxHEndcapsCone =
pset.getParameter<
double>(
"maxHEndcapsCone"),
268 .maxHOverEBarrelBc =
pset.getParameter<
double>(
"maxHOverEBarrelBc"),
270 .maxHBarrelBc =
pset.getParameter<
double>(
"maxHBarrelBc"),
271 .maxHEndcapsBc =
pset.getParameter<
double>(
"maxHEndcapsBc"),
272 .maxDeltaEtaBarrel =
pset.getParameter<
double>(
"maxDeltaEtaBarrel"),
273 .maxDeltaEtaEndcaps =
pset.getParameter<
double>(
"maxDeltaEtaEndcaps"),
274 .maxDeltaPhiBarrel =
pset.getParameter<
double>(
"maxDeltaPhiBarrel"),
275 .maxDeltaPhiEndcaps =
pset.getParameter<
double>(
"maxDeltaPhiEndcaps"),
276 .maxSigmaIetaIetaBarrel =
pset.getParameter<
double>(
"maxSigmaIetaIetaBarrel"),
277 .maxSigmaIetaIetaEndcaps =
pset.getParameter<
double>(
"maxSigmaIetaIetaEndcaps"),
278 .maxFbremBarrel =
pset.getParameter<
double>(
"maxFbremBarrel"),
279 .maxFbremEndcaps =
pset.getParameter<
double>(
"maxFbremEndcaps"),
280 .isBarrel =
pset.getParameter<
bool>(
"isBarrel"),
281 .isEndcaps =
pset.getParameter<
bool>(
"isEndcaps"),
282 .isFiducial =
pset.getParameter<
bool>(
"isFiducial"),
283 .maxTIP =
pset.getParameter<
double>(
"maxTIP"),
284 .seedFromTEC =
pset.getParameter<
bool>(
"seedFromTEC"),
286 .multThresEE =
pset.getParameter<
double>(
"multThresEE"),
293 ecalSeedingParametersChecked_(
false),
294 electronPutToken_(produces<GsfElectronCollection>()),
295 gsfPfRecTracksTag_(consumes(
cfg.getParameter<
edm::InputTag>(
"gsfPfRecTracksTag"))),
296 useGsfPfRecTracks_(
cfg.getParameter<
bool>(
"useGsfPfRecTracks")),
297 resetMvaValuesUsingPFCandidates_(
cfg.getParameter<
bool>(
"resetMvaValuesUsingPFCandidates")) {
298 if (resetMvaValuesUsingPFCandidates_) {
299 egmPFCandidateCollection_ = consumes(
cfg.getParameter<
edm::InputTag>(
"egmPFCandidatesTag"));
302 inputCfg_.gsfElectronCores = consumes(
cfg.getParameter<
edm::InputTag>(
"gsfElectronCoresTag"));
303 inputCfg_.hbheRecHitsTag = consumes(
cfg.getParameter<
edm::InputTag>(
"hbheRecHits"));
304 inputCfg_.barrelRecHitCollection = consumes(
cfg.getParameter<
edm::InputTag>(
"barrelRecHitCollectionTag"));
305 inputCfg_.endcapRecHitCollection = consumes(
cfg.getParameter<
edm::InputTag>(
"endcapRecHitCollectionTag"));
306 inputCfg_.ctfTracks = consumes(
cfg.getParameter<
edm::InputTag>(
"ctfTracksTag"));
309 inputCfg_.beamSpotTag = consumes(
cfg.getParameter<
edm::InputTag>(
"beamSpotTag"));
310 inputCfg_.vtxCollectionTag = consumes(
cfg.getParameter<
edm::InputTag>(
"vtxTag"));
311 if (
cfg.getParameter<
bool>(
"fillConvVtxFitProb"))
312 inputCfg_.conversions = consumes(
cfg.getParameter<
edm::InputTag>(
"conversionsTag"));
314 strategyCfg_.useDefaultEnergyCorrection =
cfg.getParameter<
bool>(
"useDefaultEnergyCorrection");
316 strategyCfg_.applyPreselection =
cfg.getParameter<
bool>(
"applyPreselection");
317 strategyCfg_.ecalDrivenEcalEnergyFromClassBasedParameterization =
318 cfg.getParameter<
bool>(
"ecalDrivenEcalEnergyFromClassBasedParameterization");
319 strategyCfg_.ecalDrivenEcalErrorFromClassBasedParameterization =
320 cfg.getParameter<
bool>(
"ecalDrivenEcalErrorFromClassBasedParameterization");
321 strategyCfg_.pureTrackerDrivenEcalErrorFromSimpleParameterization =
322 cfg.getParameter<
bool>(
"pureTrackerDrivenEcalErrorFromSimpleParameterization");
323 strategyCfg_.applyAmbResolution =
cfg.getParameter<
bool>(
"applyAmbResolution");
324 strategyCfg_.ignoreNotPreselected =
cfg.getParameter<
bool>(
"ignoreNotPreselected");
325 strategyCfg_.ambSortingStrategy =
cfg.getParameter<
unsigned>(
"ambSortingStrategy");
326 strategyCfg_.ambClustersOverlapStrategy =
cfg.getParameter<
unsigned>(
"ambClustersOverlapStrategy");
327 strategyCfg_.ctfTracksCheck =
cfg.getParameter<
bool>(
"ctfTracksCheck");
328 strategyCfg_.PreSelectMVA =
cfg.getParameter<
double>(
"PreSelectMVA");
329 strategyCfg_.MaxElePtForOnlyMVA =
cfg.getParameter<
double>(
"MaxElePtForOnlyMVA");
330 strategyCfg_.useEcalRegression =
cfg.getParameter<
bool>(
"useEcalRegression");
331 strategyCfg_.useCombinationRegression =
cfg.getParameter<
bool>(
"useCombinationRegression");
332 strategyCfg_.fillConvVtxFitProb =
cfg.getParameter<
bool>(
"fillConvVtxFitProb");
336 hcalCfg_.hOverEConeSize = psetPreselection.
getParameter<
double>(
"hOverEConeSize");
337 if (hcalCfg_.hOverEConeSize > 0) {
338 hcalCfg_.onlyBehindCluster =
false;
339 hcalCfg_.checkHcalStatus =
cfg.getParameter<
bool>(
"checkHcalStatus");
342 hcalCfg_.hbheRecHits = consumes<HBHERecHitCollection>(
cfg.getParameter<
edm::InputTag>(
"hbheRecHits"));
345 hcalCfg_.maxSeverityHB =
cfg.getParameter<
int>(
"maxHcalRecHitSeverity");
347 hcalCfg_.maxSeverityHE = hcalCfg_.maxSeverityHB;
350 hcalCfgBc_.hOverEConeSize = 0.;
351 hcalCfgBc_.onlyBehindCluster =
true;
352 hcalCfgBc_.checkHcalStatus =
cfg.getParameter<
bool>(
"checkHcalStatus");
355 hcalCfgBc_.hbheRecHits = consumes<HBHERecHitCollection>(
cfg.getParameter<
edm::InputTag>(
"hbheRecHits"));
358 hcalCfgBc_.maxSeverityHB =
cfg.getParameter<
int>(
"maxHcalRecHitSeverity");
360 hcalCfgBc_.maxSeverityHE = hcalCfgBc_.maxSeverityHB;
362 hcalRun2EffDepth_ =
cfg.getParameter<
bool>(
"hcalRun2EffDepth");
366 auto const& flagnamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedBarrel");
367 recHitsCfg.recHitFlagsToBeExcludedBarrel = StringToEnumValue<EcalRecHit::Flags>(flagnamesbarrel);
368 auto const& flagnamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitFlagsToBeExcludedEndcaps");
369 recHitsCfg.recHitFlagsToBeExcludedEndcaps = StringToEnumValue<EcalRecHit::Flags>(flagnamesendcaps);
370 auto const& severitynamesbarrel =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedBarrel");
371 recHitsCfg.recHitSeverityToBeExcludedBarrel =
372 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesbarrel);
373 auto const& severitynamesendcaps =
cfg.getParameter<std::vector<std::string>>(
"recHitSeverityToBeExcludedEndcaps");
374 recHitsCfg.recHitSeverityToBeExcludedEndcaps =
375 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesendcaps);
380 .etMinHcal =
cfg.getParameter<
double>(
"etMinHcal"),
381 .intRadiusEcalBarrel =
cfg.getParameter<
double>(
"intRadiusEcalBarrel"),
382 .intRadiusEcalEndcaps =
cfg.getParameter<
double>(
"intRadiusEcalEndcaps"),
383 .jurassicWidth =
cfg.getParameter<
double>(
"jurassicWidth"),
385 .eMinBarrel =
cfg.getParameter<
double>(
"eMinBarrel"),
386 .etMinEndcaps =
cfg.getParameter<
double>(
"etMinEndcaps"),
387 .eMinEndcaps =
cfg.getParameter<
double>(
"eMinEndcaps"),
389 .useNumCrystals =
cfg.getParameter<
bool>(
"useNumCrystals")};
393 .ecalWeightsFromDB =
cfg.getParameter<
bool>(
"ecalWeightsFromDB"),
394 .ecalRegressionWeightFiles =
cfg.getParameter<std::vector<std::string>>(
"ecalRefinedRegressionWeightFiles"),
396 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightLabels"),
397 .combinationWeightsFromDB =
cfg.getParameter<
bool>(
"combinationWeightsFromDB"),
398 .combinationRegressionWeightFiles =
399 cfg.getParameter<std::vector<std::string>>(
"combinationRegressionWeightFile")};
402 algo_ = std::make_unique<GsfElectronAlgo>(
416 consumesCollector());
420 if (!
pset.exists(
"SeedConfiguration")) {
425 if (seedConfiguration.
getParameter<
bool>(
"applyHOverECut")) {
430 << seedConfiguration.
getParameter<
double>(
"hOverEConeSize") <<
").";
434 <<
"The max barrel cone H/E is lower than during ecal seeding.";
438 <<
"The max endcaps cone H/E is lower than during ecal seeding.";
444 <<
"The minimum super-cluster Et in barrel is lower than during ecal seeding.";
448 <<
"The minimum super-cluster Et in endcaps is lower than during ecal seeding.";
471 throw cms::Exception(
"GsfElectronAlgo|UnknownAmbiguitySortingStrategy")
486 if (gsfPfRecTrack.gsfTrackRef() ==
e1.gsfTrack()) {
488 edm::LogWarning(
"GsfElectronAlgo") <<
"associated gsfPfRecTrack already found";
491 for (
auto const& duplicate : gsfPfRecTrack.convBremGsfPFRecTrackRef()) {
492 e1.addAmbiguousGsfTrack(duplicate->gsfTrackRef());
509 LogDebug(
"GsfElectronAlgo") <<
"Blessing electron with E/P " <<
e1->eSuperClusterOverP() <<
", cluster "
510 << scRef1.
get() <<
" & track " <<
e1->gsfTrack().get();
512 for (
auto e2 =
e1 + 1; e2 !=
electrons.end(); ++e2) {
522 bool sameCluster =
false;
524 sameCluster = (scRef1 == scRef2);
534 throw cms::Exception(
"GsfElectronAlgo|UnknownAmbiguityClustersOverlapStrategy")
540 LogDebug(
"GsfElectronAlgo") <<
"Discarding electron with E/P " << e2->eSuperClusterOverP() <<
", cluster "
541 << scRef2.
get() <<
" and track " << e2->gsfTrack().get();
542 e1->addAmbiguousGsfTrack(e2->gsfTrack());
543 e2->setAmbiguous(
true);
544 }
else if (
e1->gsfTrack() == e2->gsfTrack()) {
545 edm::LogWarning(
"GsfElectronAlgo") <<
"Forgetting electron with E/P " << e2->eSuperClusterOverP()
546 <<
", cluster " << scRef2.
get() <<
" and track " << e2->gsfTrack().get();
547 e2->setAmbiguous(
true);
562 return passmva && passCutBased;
566 return passCutBased || passPF || passmva;
576 if (!
seeds.isValid()) {
578 <<
"Cannot check consistency of parameters with ecal seeding ones,"
579 <<
" because the original collection of seeds is not any more available.";
590 el.setMvaInput(gsfMVAInputMap.find(el.gsfTrack())->
second);
594 logElectrons(
electrons,
event,
"GsfElectronAlgo Info (before preselection)");
600 logElectrons(
electrons,
event,
"GsfElectronAlgo Info (after preselection)");
607 logElectrons(
electrons,
event,
"GsfElectronAlgo Info (after amb. solving)");
612 ele.hcalToRun2EffDepth();