86 return std::make_unique<PATMuonHeavyObjectCache>(
iConfig);
99 typedef std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>>
GenAssociations;
114 template <
typename T>
116 const char* psetName,
134 bool primaryVertexIsValid,
136 bool beamspotIsValid);
140 const DetId& chamberId);
142 edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
146 edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
148 const std::vector<std::string>& collection_names);
195 std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection>>>
genMatchTokens_;
274 template <
typename T>
276 const char* psetName,
281 if (iConfig.
exists(psetName)) {
284 if (depconf.
exists(
"tracker"))
286 if (depconf.
exists(
"ecal"))
288 if (depconf.
exists(
"hcal"))
290 if (depconf.
exists(
"pfAllParticles")) {
293 if (depconf.
exists(
"pfChargedHadrons")) {
296 if (depconf.
exists(
"pfChargedAll")) {
299 if (depconf.
exists(
"pfPUChargedHadrons")) {
302 if (depconf.
exists(
"pfNeutralHadrons")) {
305 if (depconf.
exists(
"pfPhotons")) {
308 if (depconf.
exists(
"user")) {
309 std::vector<edm::InputTag> userdeps = depconf.
getParameter<std::vector<edm::InputTag>>(
"user");
310 std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
312 for (; it != ed; ++it, ++
key) {
316 labels, [
this](
IsolationLabel const&
label) {
return consumes<edm::ValueMap<T>>(label.second); });
320 return consumes<edm::ValueMap<T>>(label.second);
331 float mvaDrMax = iConfig.
getParameter<
double>(
"mvaDrMax");
332 muonMvaEstimator_ = std::make_unique<MuonMvaEstimator>(mvaTrainingFile, mvaDrMax);
333 muonLowPtMvaEstimator_ = std::make_unique<MuonMvaEstimator>(mvaLowPtTrainingFile, mvaDrMax);
338 muonMvaIDEstimator_ = std::make_unique<MuonMvaIDEstimator>(mvaIDTrainingFile);
343 softMuonMvaEstimator_ = std::make_unique<SoftMuonMvaEstimator>(softMvaTrainingFile);
348 : relMiniIsoPUCorrected_(0),
349 useUserData_(iConfig.exists(
"userData")),
350 computeMuonMVA_(
false),
351 computeMuonIDMVA_(
false),
352 computeSoftMuonMVA_(
false),
353 recomputeBasicSelectors_(
false),
355 isolator_(iConfig.exists(
"userIsolation") ? iConfig.getParameter<edm::
ParameterSet>(
"userIsolation")
361 patMuonPutToken_{produces<std::vector<Muon>>()} {
363 muonToken_ = consumes<edm::View<reco::Muon>>(
iConfig.getParameter<
edm::InputTag>(
"muonSource"));
365 embedBestTrack_ =
iConfig.getParameter<
bool>(
"embedMuonBestTrack");
366 embedTunePBestTrack_ =
iConfig.getParameter<
bool>(
"embedTunePMuonBestTrack");
367 forceEmbedBestTrack_ =
iConfig.getParameter<
bool>(
"forceBestTrackEmbedding");
368 embedTrack_ =
iConfig.getParameter<
bool>(
"embedTrack");
369 embedCombinedMuon_ =
iConfig.getParameter<
bool>(
"embedCombinedMuon");
370 embedStandAloneMuon_ =
iConfig.getParameter<
bool>(
"embedStandAloneMuon");
372 embedCaloMETMuonCorrs_ =
iConfig.getParameter<
bool>(
"embedCaloMETMuonCorrs");
373 embedTcMETMuonCorrs_ =
iConfig.getParameter<
bool>(
"embedTcMETMuonCorrs");
374 caloMETMuonCorrsToken_ =
375 mayConsume<edm::ValueMap<reco::MuonMETCorrectionData>>(
iConfig.getParameter<
edm::InputTag>(
"caloMETMuonCorrs"));
376 tcMETMuonCorrsToken_ =
377 mayConsume<edm::ValueMap<reco::MuonMETCorrectionData>>(
iConfig.getParameter<
edm::InputTag>(
"tcMETMuonCorrs"));
379 useParticleFlow_ =
iConfig.getParameter<
bool>(
"useParticleFlow");
380 embedPFCandidate_ =
iConfig.getParameter<
bool>(
"embedPFCandidate");
381 pfMuonToken_ = mayConsume<reco::PFCandidateCollection>(
iConfig.getParameter<
edm::InputTag>(
"pfMuonSource"));
382 embedPfEcalEnergy_ =
iConfig.getParameter<
bool>(
"embedPfEcalEnergy");
384 embedPickyMuon_ =
iConfig.getParameter<
bool>(
"embedPickyMuon");
385 embedTpfmsMuon_ =
iConfig.getParameter<
bool>(
"embedTpfmsMuon");
386 embedDytMuon_ =
iConfig.getParameter<
bool>(
"embedDytMuon");
388 addInverseBeta_ =
iConfig.getParameter<
bool>(
"addInverseBeta");
389 if (addInverseBeta_) {
390 muonTimeExtraToken_ =
391 consumes<edm::ValueMap<reco::MuonTimeExtra>>(
iConfig.getParameter<
edm::InputTag>(
"sourceMuonTimeExtra"));
394 addGenMatch_ =
iConfig.getParameter<
bool>(
"addGenMatch");
396 embedGenMatch_ =
iConfig.getParameter<
bool>(
"embedGenMatch");
402 iConfig.getParameter<std::vector<edm::InputTag>>(
"genParticleMatch"),
407 addEfficiencies_ =
iConfig.getParameter<
bool>(
"addEfficiencies");
408 if (addEfficiencies_) {
413 addResolutions_ =
iConfig.getParameter<
bool>(
"addResolutions");
414 if (addResolutions_) {
419 addPuppiIsolation_ =
iConfig.getParameter<
bool>(
"addPuppiIsolation");
420 if (addPuppiIsolation_) {
421 PUPPIIsolation_charged_hadrons_ =
422 consumes<edm::ValueMap<float>>(
iConfig.getParameter<
edm::InputTag>(
"puppiIsolationChargedHadrons"));
423 PUPPIIsolation_neutral_hadrons_ =
424 consumes<edm::ValueMap<float>>(
iConfig.getParameter<
edm::InputTag>(
"puppiIsolationNeutralHadrons"));
425 PUPPIIsolation_photons_ =
428 PUPPINoLeptonsIsolation_charged_hadrons_ =
429 consumes<edm::ValueMap<float>>(
iConfig.getParameter<
edm::InputTag>(
"puppiNoLeptonsIsolationChargedHadrons"));
430 PUPPINoLeptonsIsolation_neutral_hadrons_ =
431 consumes<edm::ValueMap<float>>(
iConfig.getParameter<
edm::InputTag>(
"puppiNoLeptonsIsolationNeutralHadrons"));
432 PUPPINoLeptonsIsolation_photons_ =
433 consumes<edm::ValueMap<float>>(
iConfig.getParameter<
edm::InputTag>(
"puppiNoLeptonsIsolationPhotons"));
436 readIsolationLabels(
iConfig,
"isoDeposits", isoDepositLabels_, isoDepositTokens_);
438 readIsolationLabels(
iConfig,
"isolationValues", isolationValueLabels_, isolationValueTokens_);
444 embedHighLevelSelection_ =
iConfig.getParameter<
bool>(
"embedHighLevelSelection");
445 if (embedHighLevelSelection_) {
451 computeMiniIso_ =
iConfig.getParameter<
bool>(
"computeMiniIso");
453 computePuppiCombinedIso_ =
iConfig.getParameter<
bool>(
"computePuppiCombinedIso");
455 effectiveAreaVec_ =
iConfig.getParameter<std::vector<double>>(
"effectiveAreaVec");
457 miniIsoParams_ =
iConfig.getParameter<std::vector<double>>(
"miniIsoParams");
458 if (computeMiniIso_ && miniIsoParams_.size() != 9) {
459 throw cms::Exception(
"ParameterError") <<
"miniIsoParams must have exactly 9 elements.\n";
461 if (computeMiniIso_ || computePuppiCombinedIso_)
462 pcToken_ = consumes<pat::PackedCandidateCollection>(
iConfig.getParameter<
edm::InputTag>(
"pfCandsForMiniIso"));
465 recomputeBasicSelectors_ =
iConfig.getParameter<
bool>(
"recomputeBasicSelectors");
466 computeMuonMVA_ =
iConfig.getParameter<
bool>(
"computeMuonMVA");
467 computeMuonIDMVA_ =
iConfig.getParameter<
bool>(
"computeMuonIDMVA");
468 if (computeMuonMVA_ and not computeMiniIso_)
469 throw cms::Exception(
"ConfigurationError") <<
"MiniIso is needed for Muon MVA calculation.\n";
471 if (computeMuonMVA_) {
473 mvaBTagCollectionTag_ = consumes<reco::JetTagCollection>(
iConfig.getParameter<
edm::InputTag>(
"mvaJetTag"));
474 mvaL1Corrector_ = consumes<reco::JetCorrector>(
iConfig.getParameter<
edm::InputTag>(
"mvaL1Corrector"));
475 mvaL1L2L3ResCorrector_ = consumes<reco::JetCorrector>(
iConfig.getParameter<
edm::InputTag>(
"mvaL1L2L3ResCorrector"));
477 mvaUseJec_ =
iConfig.getParameter<
bool>(
"mvaUseJec");
480 computeSoftMuonMVA_ =
iConfig.getParameter<
bool>(
"computeSoftMuonMVA");
483 simInfo_ = consumes<edm::ValueMap<reco::MuonSimInfo>>(
iConfig.getParameter<
edm::InputTag>(
"muonSimInfo"));
485 addTriggerMatching_ =
iConfig.getParameter<
bool>(
"addTriggerMatching");
486 if (addTriggerMatching_) {
488 consumes<std::vector<pat::TriggerObjectStandAlone>>(
iConfig.getParameter<
edm::InputTag>(
"triggerObjects"));
489 triggerResults_ = consumes<edm::TriggerResults>(
iConfig.getParameter<
edm::InputTag>(
"triggerResults"));
491 hltCollectionFilters_ =
iConfig.getParameter<std::vector<std::string>>(
"hltCollectionFilters");
498 const DetId& chamberId) {
499 const GeomDet* chamberGeometry = geometry->idToDet(chamberId);
500 if (chamberGeometry) {
501 LocalPoint localPosition(chamberMatch.
x, chamberMatch.
y, 0);
502 return std::optional<GlobalPoint>(std::in_place, chamberGeometry->
toGlobal(localPosition));
504 return std::optional<GlobalPoint>();
508 edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
516 std::optional<GlobalPoint> muonPosition;
521 for (
const auto& chamberMatch : aMuon.
matches()) {
524 if (
abs(detId.station()) > 3)
527 if (
abs(detId.station()) == 2)
531 CSCDetId detId(chamberMatch.id.rawId());
532 if (
abs(detId.station()) > 3)
535 if (
abs(detId.station()) == 2)
539 if (not muonPosition)
541 for (
const auto& triggerObject : *triggerObjects) {
543 if (
std::abs(triggerObject.eta()) < 0.001) {
545 if (
deltaPhi(triggerObject.phi(), muonPosition->phi()) > 0.1)
549 if (
deltaR(triggerObject.p4(), *muonPosition) > 0.15)
560 edm::Handle<std::vector<pat::TriggerObjectStandAlone>>& triggerObjects,
562 const std::vector<std::string>& collection_filter_names) {
565 for (
const auto& triggerObject : *triggerObjects) {
568 for (
const auto&
name : collection_filter_names) {
569 if (triggerObject.hasCollection(
name)) {
589 throw cms::Exception(
"FatalError") <<
"Unable to find GlobalTrackingGeometryRecord in event!\n";
666 bool beamSpotIsValid =
false;
667 bool primaryVertexIsValid =
false;
677 if (beamSpotHandle.
isValid()) {
678 beamSpot = *beamSpotHandle;
679 beamSpotIsValid =
true;
681 edm::LogError(
"DataNotAvailable") <<
"No beam spot available from EventSetup, not adding high level selection \n";
683 if (pvHandle.
isValid() && !pvHandle->empty()) {
684 primaryVertex = pvHandle->at(0);
685 primaryVertexIsValid =
true;
688 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
714 Muon aMuon(muonBaseRef);
729 chosenTrack = bestTrack;
732 unsigned int nhits = chosenTrack->numberOfValidHits();
736 embedHighLevel(aMuon, chosenTrack, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
740 double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
751 fillMuon(aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues);
758 (*PUPPIIsolation_neutral_hadrons)[muonBaseRef],
759 (*PUPPIIsolation_photons)[muonBaseRef]);
762 (*PUPPINoLeptonsIsolation_neutral_hadrons)[muonBaseRef],
763 (*PUPPINoLeptonsIsolation_photons)[muonBaseRef]);
773 patMuons.push_back(aMuon);
806 unsigned int idx = itMuon - muons->begin();
811 fillMuon(aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
816 (*PUPPIIsolation_neutral_hadrons)[muonRef],
817 (*PUPPIIsolation_photons)[muonRef]);
819 (*PUPPINoLeptonsIsolation_neutral_hadrons)[muonRef],
820 (*PUPPINoLeptonsIsolation_photons)[muonRef]);
860 chosenTrack = bestTrack;
862 unsigned int nhits = chosenTrack->numberOfValidHits();
866 embedHighLevel(aMuon, chosenTrack, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
870 double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
886 if (pfmu.muonRef().isNonnull()) {
887 if (pfmu.muonRef().id() != muonRef.id())
889 <<
"Muon reference within PF candidates does not point to the muon collection." << std::endl;
890 if (pfmu.muonRef().key() == muonRef.key()) {
909 if (simInfoIsAvailalbe) {
910 const auto& msi = (*simInfo)[muonBaseRef];
926 patMuons.push_back(aMuon);
931 std::sort(patMuons.begin(), patMuons.end(), [](
auto const& t1,
auto const& t2) {
return t1.pt() > t2.pt(); });
941 if (primaryVertexIsValid)
946 bool triggerObjectsAvailable =
false;
947 bool triggerResultsAvailable =
false;
953 for (
auto&
muon : patMuons) {
962 muon.setSelectors(0);
963 bool isRun2016BCDEF = (272728 <= iEvent.
run() && iEvent.
run() <= 278808);
966 float miniIsoValue = -1;
978 double puppiCombinedIsolationPAT = -1;
986 float jetPtRatio = 0.0;
987 float jetPtRel = 0.0;
989 float mva_lowpt = 0.0;
992 mva = globalCache()->muonMvaEstimator().computeMva(
muon,
994 *(mvaBTagCollectionTag.
product()),
999 mvaL1L2L3ResCorrector.
product());
1000 mva_lowpt = globalCache()->muonLowPtMvaEstimator().computeMva(
muon,
1002 *(mvaBTagCollectionTag.
product()),
1007 mvaL1L2L3ResCorrector.
product());
1010 mva = globalCache()->muonMvaEstimator().computeMva(
1011 muon, primaryVertex, *mvaBTagCollectionTag, jetPtRatio, jetPtRel, miniIsoValue);
1012 mva_lowpt = globalCache()->muonLowPtMvaEstimator().computeMva(
1013 muon, primaryVertex, *mvaBTagCollectionTag, jetPtRatio, jetPtRel, miniIsoValue);
1016 muon.setMvaValue(mva);
1017 muon.setLowPtMvaValue(mva_lowpt);
1018 muon.setJetPtRatio(jetPtRatio);
1019 muon.setJetPtRel(jetPtRel);
1024 miniIsoValue < 0.11 && (
muon.jetPtRatio() > 0.74 ||
muon.jetPtRel() > 6.8));
1032 const double sip3D = edB3D > 0 ? dB3D / edB3D : 0.0;
1037 dB2D < 0.05 and dz < 0.1) {
1044 if (
muon.pt() > 5 and
muon.isLooseMuon() and sip3D < 4 and dB2D < 0.5 and dz < 1) {
1052 constexpr
int MVAsentinelValue = -99;
1053 constexpr
float mvaIDmediumCut = 0.08;
1054 constexpr
float mvaIDtightCut = 0.49;
1056 if (
muon.isLooseMuon()) {
1057 mvaID = globalCache()->muonMvaIDEstimator().computeMVAID(
muon)[1];
1059 mvaID = MVAsentinelValue;
1061 muon.setMvaIDValue(mvaID);
1068 float mva = globalCache()->softMuonMvaEstimator().computeMva(
muon);
1069 muon.setSoftMvaValue(mva);
1120 for (
auto const& genMatch : genMatches) {
1131 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
1146 for (
size_t j = 0;
j < isolationValues.size(); ++
j) {
1150 }
else if (isolationValues[
j]->
contains(muonRef.
id())) {
1190 constexpr
double dR_threshold = 0.4;
1191 constexpr
double dR2_threshold = dR_threshold * dR_threshold;
1192 constexpr
double mix_fraction = 0.5;
1194 double val_PuppiWithLep = 0.0;
1195 double val_PuppiWithoutLep = 0.0;
1197 for (
const auto& cand : *pc) {
1203 if (pType ==
OTHER) {
1204 if (cand.pdgId() != 1 && cand.pdgId() != 2 &&
abs(cand.pdgId()) != 11 &&
abs(cand.pdgId()) != 13) {
1205 LogTrace(
"PATMuonProducer") <<
"candidate with PDGID = " << cand.pdgId()
1206 <<
" is not CH/NH/PH/e/mu or 1/2 (and this is removed from isolation calculation)"
1212 if (d_eta > dR_threshold)
1216 if (d_phi > dR_threshold)
1220 if (dR2 > dR2_threshold)
1222 if (pType == CH && dR2 < 0.0001 * 0.0001)
1224 if (pType ==
NH && dR2 < 0.01 * 0.01)
1226 if (pType == PH && dR2 < 0.01 * 0.01)
1228 val_PuppiWithLep += cand.pt() * cand.puppiWeight();
1229 val_PuppiWithoutLep += cand.pt() * cand.puppiWeightNoLep();
1233 double reliso_Puppi_withLep = val_PuppiWithLep / muon.
pt();
1234 double reliso_Puppi_withoutlep = val_PuppiWithoutLep / muon.
pt();
1235 double reliso_Puppi_combined = mix_fraction * reliso_Puppi_withLep + (1.0 - mix_fraction) * reliso_Puppi_withoutlep;
1236 return reliso_Puppi_combined;
1248 iDesc.
setComment(
"PAT muon producer module");
1254 iDesc.
add<
bool>(
"embedMuonBestTrack",
true)->setComment(
"embed muon best track (global pflow)");
1255 iDesc.
add<
bool>(
"embedTunePMuonBestTrack",
true)->setComment(
"embed muon best track (muon only)");
1256 iDesc.
add<
bool>(
"forceBestTrackEmbedding",
true)
1258 "force embedding separately the best tracks even if they're already embedded e.g. as tracker or global "
1260 iDesc.
add<
bool>(
"embedTrack",
true)->setComment(
"embed external track");
1261 iDesc.
add<
bool>(
"embedStandAloneMuon",
true)->setComment(
"embed external stand-alone muon");
1262 iDesc.
add<
bool>(
"embedCombinedMuon",
false)->setComment(
"embed external combined muon");
1263 iDesc.
add<
bool>(
"embedPickyMuon",
false)->setComment(
"embed external picky track");
1264 iDesc.
add<
bool>(
"embedTpfmsMuon",
false)->setComment(
"embed external tpfms track");
1265 iDesc.
add<
bool>(
"embedDytMuon",
false)->setComment(
"embed external dyt track ");
1268 iDesc.
add<
bool>(
"embedCaloMETMuonCorrs",
true)->setComment(
"whether to add MET muon correction for caloMET or not");
1270 ->setComment(
"source of MET muon corrections for caloMET");
1271 iDesc.
add<
bool>(
"embedTcMETMuonCorrs",
true)->setComment(
"whether to add MET muon correction for tcMET or not");
1273 ->setComment(
"source of MET muon corrections for tcMET");
1277 iDesc.
add<
bool>(
"useParticleFlow",
false)->setComment(
"whether to use particle flow or not");
1278 iDesc.
add<
bool>(
"embedPFCandidate",
false)->setComment(
"embed external particle flow object");
1279 iDesc.
add<
bool>(
"embedPfEcalEnergy",
true)->setComment(
"add ecal energy as reconstructed by PF");
1282 iDesc.
add<
bool>(
"addInverseBeta",
true)->setComment(
"add combined inverse beta");
1284 ->setComment(
"source of inverse beta values");
1287 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
1288 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
1289 std::vector<edm::InputTag> emptySourceVector;
1293 ->
setComment(
"input with MC match information");
1296 iDesc.
add<
bool>(
"computeMiniIso",
false)->setComment(
"whether or not to compute and store electron mini-isolation");
1297 iDesc.
add<
bool>(
"computePuppiCombinedIso",
false)
1298 ->setComment(
"whether or not to compute and store puppi combined isolation");
1301 ->setComment(
"collection to use to compute mini-iso");
1302 iDesc.
add<std::vector<double>>(
"miniIsoParams", std::vector<double>())
1303 ->
setComment(
"mini-iso parameters to use for muons");
1305 iDesc.
add<
bool>(
"addTriggerMatching",
false)->setComment(
"add L1 and HLT matching to offline muon");
1320 isoDepositsPSet.
addOptional<std::vector<edm::InputTag>>(
"user");
1321 iDesc.
addOptional(
"isoDeposits", isoDepositsPSet);
1334 iDesc.
addOptional(
"isolationValues", isolationValuesPSet);
1338 "puppiIsolationChargedHadrons",
1339 edm::InputTag(
"muonPUPPIIsolation",
"h+-DR030-ThresholdVeto000-ConeVeto000"),
1342 "puppiIsolationNeutralHadrons",
1343 edm::InputTag(
"muonPUPPIIsolation",
"h0-DR030-ThresholdVeto000-ConeVeto001"),
1346 "puppiIsolationPhotons",
1347 edm::InputTag(
"muonPUPPIIsolation",
"gamma-DR030-ThresholdVeto000-ConeVeto001"),
1350 "puppiNoLeptonsIsolationChargedHadrons",
1351 edm::InputTag(
"muonPUPPINoLeptonsIsolation",
"h+-DR030-ThresholdVeto000-ConeVeto000"),
1354 "puppiNoLeptonsIsolationNeutralHadrons",
1355 edm::InputTag(
"muonPUPPINoLeptonsIsolation",
"h0-DR030-ThresholdVeto000-ConeVeto001"),
1358 "puppiNoLeptonsIsolationPhotons",
1359 edm::InputTag(
"muonPUPPINoLeptonsIsolation",
"gamma-DR030-ThresholdVeto000-ConeVeto001"),
1366 iDesc.
add(
"efficiencies", efficienciesPSet);
1367 iDesc.
add<
bool>(
"addEfficiencies",
false);
1376 iDesc.
add(
"userIsolation", isolationPSet);
1378 iDesc.
add<
bool>(
"embedHighLevelSelection",
true)->setComment(
"embed high level selection");
1382 ->
setComment(
"input with high level selection");
1384 ->
setComment(
"input with high level selection");
1395 bool primaryVertexIsValid,
1397 bool beamspotIsValid) {
1406 std::pair<bool, Measurement1D>
result =
1408 double d0_corr = result.second.value();
1409 double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1422 d0_corr = result.second.value();
1423 d0_err = beamspotIsValid ? result.second.error() : -1.0;
bool embedTpfmsMuon_
embed track from tpfms muon fit into the muon
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
bool enabled() const
'true' if this there is at least one efficiency configured
bool useUserData_
add user data to the muon (this will be data members of th muon even w/o embedding) ...
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T >>> &tokens)
constexpr double deltaPhi(double phi1, double phi2)
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_photons_
double ecalEnergy() const
return corrected Ecal energy
void setComment(std::string const &value)
Assists in assimilating all pat::UserData into pat objects.
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
bool addPuppiIsolation_
add puppi isolation
void embedDytMuon()
embed reference to the above dyt Track
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool isNonnull() const
Checks for non-null.
void embedTpfmsMuon()
embed reference to the above tpfms Track
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > tcMETMuonCorrsToken_
source of tcMET muon corrections
void setIsolation(IsolationKeys key, float value)
bool embedTcMETMuonCorrs_
embed muon MET correction info for tcMET into the muon
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData &t)
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
input source of the primary vertex
bool contains(EventRange const &lh, EventID const &rh)
double pt() const final
transverse momentum
edm::EDGetTokenT< edm::ValueMap< reco::MuonTimeExtra > > muonTimeExtraToken_
input tag for reading inverse beta
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
void embedCombinedMuon()
set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon...
edm::EDGetTokenT< double > rho_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
input source
void embedTunePMuonBestTrack(bool force=false)
bool addEfficiencies_
add efficiencies to the muon (this will be data members of th muon even w/o embedding) ...
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > caloMETMuonCorrsToken_
source of caloMET muon corrections
bool getByToken(EDGetToken token, Handle< PROD > &result) const
enum start value shifted to 81 so as to avoid clashes with PDG codes
void setAllowAnything()
allow any parameter label/value pairs
double zError() const
error on z
void setSimFlavour(int f)
#define DEFINE_FWK_MODULE(type)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
bool embedCaloMETMuonCorrs_
embed muon MET correction info for caloMET into the muon
bool isChargedHadron(long pdgid)
~PATMuonProducer() override
default destructur
edm::EDGetTokenT< edm::ValueMap< reco::MuonSimInfo > > simInfo_
MC info.
void embedMuonBestTrack(bool force=false)
std::vector< pat::PackedCandidate > PackedCandidateCollection
void setIsolationPUPPINoLeptons(float chargedhadrons, float neutralhadrons, float photons)
sets PUPPINoLeptons isolations
void setMuonMiniIso(pat::Muon &aMuon, const pat::PackedCandidateCollection *pc)
reco::TransientTrack build(const reco::Track *p) const
PATMuonProducer(const edm::ParameterSet &iConfig, PATMuonHeavyObjectCache const *)
default constructir
bool exists(std::string const ¶meterName) const
checks if a parameter exists
bool addTriggerMatching_
Trigger.
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
bool embedBestTrack_
embed the track from best muon measurement (global pflow)
edm::EDGetTokenT< reco::JetCorrector > mvaL1Corrector_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackBuilderToken_
bool addResolutions_
add resolutions to the muon (this will be data members of th muon even w/o embedding) ...
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
IsolationKeys
Enum defining isolation keys.
void unpackPathNames(const edm::TriggerNames &names)
unpack trigger names into indices
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_charged_hadrons_
std::vector< double > miniIsoParams_
void setSimPhi(float phi)
Log< level::Error, false > LogError
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
bool computePuppiCombinedIso_
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
void setSimProdRho(float rho)
void setSimHeaviestMotherFlavour(int id)
reco::Muon::Selector makeSelectorBitset(reco::Muon const &muon, reco::Vertex const *vertex=nullptr, bool run2016_hip_mitigation=false)
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
const Point & position() const
position
void embedHighLevel(pat::Muon &aMuon, reco::TrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
std::vector< double > effectiveAreaVec_
const std::string names[nVars_]
pat::MuonMvaIDEstimator const & muonMvaIDEstimator() const
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_neutral_hadrons_
void setSimType(reco::MuonSimType type)
void embedStandAloneMuon()
set reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
double relMiniIsoPUCorrected_
edm::EDGetTokenT< reco::JetTagCollection > mvaBTagCollectionTag_
pat::MuonMvaEstimator const & muonMvaEstimator() const
edm::EDGetTokenT< reco::PFCandidateCollection > pfMuonToken_
input source pfCandidates that will be to be transformed into pat::Muons, when using PF2PAT ...
void setIsolationPUPPI(float chargedhadrons, float neutralhadrons, float photons)
sets PUPPI isolations
pat::helper::MultiIsolator isolator_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
bool enabled() const
'true' if this there is at least one efficiency configured
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
static void fillDescription(edm::ParameterSetDescription &iDesc)
const PFIsolation & miniPFIsolation() const
std::vector< IsolationLabel > IsolationLabels
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
input source of the primary vertex/beamspot
std::unique_ptr< const pat::MuonMvaEstimator > muonLowPtMvaEstimator_
bool getData(T &iHolder) const
bool addInverseBeta_
add combined inverse beta measurement into the muon
bool useParticleFlow_
switch to use particle flow (PF2PAT) or not
pat::PATUserDataHelper< pat::Muon > userDataHelper_
helper class to add userData to the muon
bool enabled() const
True if it has a non null configuration.
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
bool embedStandAloneMuon_
embed track from muon system into the muon
void setComment(std::string const &value)
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
pat::SoftMuonMvaEstimator const & softMuonMvaEstimator() const
bool embedTrack_
embed the track from inner tracker into the muon
void setDB(double dB, double edB, IPTYPE type=PV2D)
bool addGenMatch_
add generator match information
PATMuonHeavyObjectCache(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
description of config file parameters
void fillL1TriggerInfo(pat::Muon &muon, edm::Handle< std::vector< pat::TriggerObjectStandAlone >> &triggerObjects, const edm::TriggerNames &names, const edm::ESHandle< GlobalTrackingGeometry > &geometry)
double muonRelMiniIsoPUCorrected(const PFIsolation &iso, const reco::Candidate::PolarLorentzVector &p4, double dr, double rho, const std::vector< double > &area)
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
bool embedPfEcalEnergy_
add ecal PF energy
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
everything that needs to be done during the event loop
std::unique_ptr< const pat::MuonMvaEstimator > muonMvaEstimator_
reco::PFCandidateRef pfCandidateRef() const
tuple key
prepare the HTCondor submission files and eventually submit them
Abs< T >::type abs(const T &t)
double relMiniIsoPUCorrected(const pat::Muon &aMuon, double rho)
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
static void globalEndJob(PATMuonHeavyObjectCache *)
static std::string const triggerResults
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double puppiCombinedIsolation(const pat::Muon &muon, const pat::PackedCandidateCollection *pc)
void readTimeExtra(const reco::MuonTimeExtra &t)
std::vector< std::string > hltCollectionFilters_
float miniIsoDr(const reco::Candidate::PolarLorentzVector &p4, float mindr, float maxdr, float kt_scale)
reco::MuonRef muonRef() const
void fillHltTriggerInfo(pat::Muon &muon, edm::Handle< std::vector< pat::TriggerObjectStandAlone >> &triggerObjects, const edm::TriggerNames &names, const std::vector< std::string > &collection_names)
static std::unique_ptr< PATMuonHeavyObjectCache > initializeGlobalCache(const edm::ParameterSet &iConfig)
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
bool isAValidMuonTrack(const MuonTrackType &type) const
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void addGenParticleRef(const reco::GenParticleRef &ref)
void setPfEcalEnergy(float pfEcalEnergy)
bool embedTunePBestTrack_
embed the track from best muon measurement (muon only)
T const * product() const
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
double getRelMiniIsoPUCorrected(const pat::Muon &muon, double rho, const std::vector< double > &area)
void setSimMotherPdgId(int id)
T getParameter(std::string const &) const
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
void addTriggerObjectMatch(const TriggerObjectStandAlone &trigObj)
add a trigger match
void setExtSimType(reco::ExtendedMuonSimType type)
std::vector< MuonChamberMatch > & matches()
get muon matching information
std::unique_ptr< const pat::MuonMvaIDEstimator > muonMvaIDEstimator_
void setMiniPFIsolation(PFIsolation const &iso)
std::unique_ptr< const pat::SoftMuonMvaEstimator > softMuonMvaEstimator_
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
edm::EDGetTokenT< reco::JetCorrector > mvaL1L2L3ResCorrector_
void fillMuon(Muon &aMuon, const MuonBaseRef &muonRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
common muon filling, for both the standard and PF2PAT case
void setSimProdZ(float z)
Particle reconstructed by the particle flow algorithm.
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
pat::helper::EfficiencyLoader efficiencyLoader_
helper class to add efficiencies to the muon
bool embedPickyMuon_
embed track from picky muon fit into the muon
void setNormChi2(double normChi2)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
bool embedDytMuon_
embed track from DYT muon fit into the muon
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
const edm::EDPutTokenT< std::vector< Muon > > patMuonPutToken_
Calculates a lepton's calorimetric isolation energy.
bool isPhoton(long pdgid)
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
isolation value pair for temporary storage before being folded into the muon
edm::EDGetTokenT< std::vector< pat::TriggerObjectStandAlone > > triggerObjects_
bool embedGenMatch_
embed the gen match information into the muon
const Point & position() const
position
IsolationLabels isoDepositLabels_
input source for isoDeposits
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
input tags for generator match information
PFIsolation getMiniPFIsolation(const pat::PackedCandidateCollection *pfcands, const reco::Candidate::PolarLorentzVector &p4, float mindr=0.05, float maxdr=0.2, float kt_scale=10.0, float ptthresh=0.5, float deadcone_ch=0.0001, float deadcone_pu=0.01, float deadcone_ph=0.01, float deadcone_nh=0.01, float dZ_cut=0.0)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Covariance3DMatrix rotatedCovariance3D() const
IsolationLabels isolationValueLabels_
input source isolation value maps
bool recomputeBasicSelectors_
void embedPickyMuon()
embed reference to the above picky Track
double phi() const final
momentum azimuthal angle
bool forceEmbedBestTrack_
force separate embed of the best track even if already embedded
edm::RefToBase< reco::Muon > MuonBaseRef
typedefs for convenience
bool embedPFCandidate_
embed pfCandidates into the muon
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
void setNumberOfValidHits(unsigned int numberOfValidHits)
bool computeMuonMVA_
standard muon selectors
void setSimEta(float eta)
bool embedCombinedMuon_
embed track of the combined fit into the muon
pat::MuonMvaEstimator const & muonLowPtMvaEstimator() const
Analysis-level muon class.
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
static std::string const source
bool isGlobalMuon() const override
void setP4(const LorentzVector &p4) final
set 4-momentum
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
std::optional< GlobalPoint > getMuonDirection(const reco::MuonChamberMatch &chamberMatch, const edm::ESHandle< GlobalTrackingGeometry > &geometry, const DetId &chamberId)
bool isNeutralHadron(long pdgid)
Global3DVector GlobalVector
Calculates a lepton's tracker isolation pt.
Analysis-level trigger object class (stand-alone)
void setSimMatchQuality(float quality)
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
void setSimTpEvent(int tpEvent)
bool embedHighLevelSelection_
embed high level selection variables
double eta() const final
momentum pseudorapidity