Definition at line 174 of file PATTauProducer.cc.
176 if (
iEvent.isRealData()) {
187 edm::LogWarning(
"DataSource") <<
"WARNING! No Tau collection found. This missing input will not block the job. "
188 "Instead, an empty tau collection is being be produced.";
189 auto patTaus = std::make_unique<std::vector<Tau>>();
203 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
208 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>> genMatches(
genMatchTokens_.size());
220 std::vector<edm::ValueMap<TauJetCorrFactors>> tauJetCorrs;
225 tauJetCorrs.push_back(*tauJetCorr);
229 auto patTaus = std::make_unique<std::vector<Tau>>();
238 aTau.embedLeadTrack();
240 aTau.embedSignalTracks();
242 aTau.embedIsolationTracks();
245 aTau.embedLeadPFCand();
247 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
248 "from a reco::PFTau is impossible.\n";
252 aTau.embedLeadPFChargedHadrCand();
254 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
255 "from a reco::PFTau is impossible.\n";
259 aTau.embedLeadPFNeutralCand();
261 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
262 "from a reco::PFTau is impossible.\n";
266 aTau.embedSignalPFCands();
268 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
269 "from a reco::PFTau is impossible.\n";
273 aTau.embedSignalPFChargedHadrCands();
275 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
276 "from a reco::PFTau is impossible.\n";
280 aTau.embedSignalPFNeutralHadrCands();
282 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
283 "from a reco::PFTau is impossible.\n";
287 aTau.embedSignalPFGammaCands();
289 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
290 "from a reco::PFTau is impossible.\n";
294 aTau.embedIsolationPFCands();
296 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
297 "from a reco::PFTau is impossible.\n";
301 aTau.embedIsolationPFChargedHadrCands();
303 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
304 "from a reco::PFTau is impossible.\n";
308 aTau.embedIsolationPFNeutralHadrCands();
310 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
311 "from a reco::PFTau is impossible.\n";
315 aTau.embedIsolationPFGammaCands();
317 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
318 "from a reco::PFTau is impossible.\n";
323 for (
unsigned int i = 0;
i < tauJetCorrs.size(); ++
i) {
327 aTau.addJECFactors(tauJetCorr);
329 std::vector<std::string>
levels = tauJetCorrs[0][tausRef].correctionLabels();
331 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
333 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
335 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
338 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
339 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain"
348 for (
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
350 aTau.addGenParticleRef(genTau);
353 aTau.embedGenParticle();
360 aTau.setGenJet(genJetTau);
367 size_t numberTauIds = numberPlainTauIds;
369 numberTauIds += it.size();
373 if (numberPlainTauIds != numberTauIds &&
phID_ !=
iEvent.processHistoryID()) {
377 if (!pfTauIdDiscr.isValid())
381 std::string prov_cfg_label = idcfg.second.first.first;
382 std::string prov_ID_label = idcfg.second.first.second;
384 if (prov_cfg_label ==
"rawValues" || prov_cfg_label ==
"workingPoints") {
385 const std::vector<std::string> psetsFromProvenance =
387 .getParameter<std::vector<std::string>>(prov_cfg_label);
388 for (
size_t i = 0;
i < psetsFromProvenance.size(); ++
i) {
389 if (psetsFromProvenance[
i] == prov_ID_label) {
391 if (prov_cfg_label ==
"rawValues")
392 idcfg.second.second = -1 -
i;
394 idcfg.second.second =
i;
398 }
else if (prov_cfg_label ==
"IDdefinitions" || prov_cfg_label ==
"IDWPdefinitions") {
399 const std::vector<edm::ParameterSet> psetsFromProvenance =
401 .getParameter<std::vector<edm::ParameterSet>>(prov_cfg_label);
402 for (
size_t i = 0;
i < psetsFromProvenance.size(); ++
i) {
403 if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") == prov_ID_label) {
405 if (prov_cfg_label ==
"IDdefinitions")
406 idcfg.second.second = -1 -
i;
408 idcfg.second.second =
i;
415 int i = std::stoi(prov_ID_label);
416 if (prov_cfg_label ==
"direct_rawValues")
417 idcfg.second.second = -
i;
419 idcfg.second.second =
i;
420 }
catch (std::invalid_argument
const&
e) {
421 throw cms::Exception(
"Configuration") <<
"PATTauProducer: Direct access to ID container requested, so "
422 "argument of 'idLabel' must be convertable to int!\n";
426 throw cms::Exception(
"Configuration") <<
"PATTauProducer: Requested working point '" << prov_ID_label
427 <<
"' for ID '" << idcfg.first <<
"' not found!\n";
433 std::vector<pat::Tau::IdPair> ids(numberTauIds);
434 auto const& tausDeref = *tausRef;
438 for (
size_t i = 0;
i < numberPlainTauIds; ++
i) {
444 if (!missingDiscriminators.empty()) {
445 missingDiscriminators +=
", ";
457 if (!missingDiscriminators.empty()) {
458 missingDiscriminators +=
", ";
460 missingDiscriminators += it.first;
473 <<
"PATTauProducer: unsupported datatype '" <<
typeid(tausDeref).
name() <<
"' for tauSource\n";
476 edm::LogWarning(
"DataSource") <<
"The following tau discriminators have not been found in the event:\n"
477 << missingDiscriminators <<
"\n"
478 <<
"They will not be embedded into the pat::Tau object.\n"
479 <<
"Note: this message will be printed only at first occurence.";
487 if (aTau.isPFTau()) {
492 aTau.setDecayMode(pfTauRef->decayMode());
496 if (!aTau.pfEssential_.empty()) {
501 float ecalEnergy = 0;
502 float hcalEnergy = 0;
503 float sumPhiTimesEnergy = 0.;
504 float sumEtaTimesEnergy = 0.;
505 float sumEnergy = 0.;
506 float leadChargedCandPt = -99;
507 float leadChargedCandEtaAtEcalEntrance = -99;
508 const std::vector<reco::CandidatePtr>& signalCands = pfTauRef->signalCands();
509 for (
const auto& it : signalCands) {
510 const reco::PFCandidate* icand = dynamic_cast<const reco::PFCandidate*>(it.get());
511 if (icand !=
nullptr) {
516 sumEnergy += icand->
energy();
529 if (
track->pt() > leadChargedCandPt) {
531 leadChargedCandPt =
track->pt();
538 sumEnergy += it->energy();
540 if (
track !=
nullptr) {
541 if (
track->pt() > leadChargedCandPt) {
542 leadChargedCandPt =
track->pt();
551 if (sumEnergy != 0.) {
558 float leadingTrackNormChi2 = 0;
559 float ecalEnergyLeadChargedHadrCand = -99.;
560 float hcalEnergyLeadChargedHadrCand = -99.;
561 float emFraction = -1.;
562 float myHCALenergy = 0.;
563 float myECALenergy = 0.;
566 const reco::PFCandidate* pfCandPtr = dynamic_cast<const reco::PFCandidate*>(leadingPFCharged.
get());
567 if (pfCandPtr !=
nullptr) {
568 ecalEnergyLeadChargedHadrCand = pfCandPtr->
ecalEnergy();
569 hcalEnergyLeadChargedHadrCand = pfCandPtr->
hcalEnergy();
572 leadingTrackNormChi2 = trackRef->normalizedChi2();
573 for (
const auto& isoPFCand : pfTauRef->isolationPFCands()) {
574 myHCALenergy += isoPFCand->hcalEnergy();
575 myECALenergy += isoPFCand->ecalEnergy();
577 for (
const auto& signalPFCand : pfTauRef->signalPFCands()) {
578 myHCALenergy += signalPFCand->hcalEnergy();
579 myECALenergy += signalPFCand->ecalEnergy();
581 if (myHCALenergy + myECALenergy != 0.) {
582 emFraction = myECALenergy / (myHCALenergy + myECALenergy);
587 if (packedCandPtr !=
nullptr) {
590 if (
track !=
nullptr) {
591 leadingTrackNormChi2 =
track->normalizedChi2();
608 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
613 aTauPFEssential.
ip3d_ = tauLifetimeInfo.
ip3d();
627 aTau.setIsolation(it->first, it->second);
631 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
References pat::PATUserDataHelper< ObjectType >::add(), addGenJetMatch_, addGenMatch_, pat::PATObject< ObjectType >::addGenParticleRef(), pat::Tau::addJECFactors(), addTauID_, addTauJetCorrFactors_, baseTauToken_, pat::helper::MultiIsolator::beginEvent(), CandIsolatorFromDeposits_cfi::deposits, reco::PFTauTransverseImpactParameter::dxy(), pat::tau::TauPFEssential::dxy_, reco::PFTauTransverseImpactParameter::dxy_error(), pat::tau::TauPFEssential::dxy_error_, reco::PFTauTransverseImpactParameter::dxy_PCA(), pat::tau::TauPFEssential::dxy_PCA_, MillePedeFileConverter_cfg::e, reco::PFCandidate::ecalEnergy(), pat::tau::TauPFEssential::ecalEnergy_, pat::tau::TauPFEssential::ecalEnergyLeadChargedHadrCand_, efficiencyLoader_, embedGenMatch_, pat::PATObject< ObjectType >::embedGenParticle(), pat::Tau::embedIsolationPFCands(), embedIsolationPFCands_, pat::Tau::embedIsolationPFChargedHadrCands(), embedIsolationPFChargedHadrCands_, pat::Tau::embedIsolationPFGammaCands(), embedIsolationPFGammaCands_, pat::Tau::embedIsolationPFNeutralHadrCands(), embedIsolationPFNeutralHadrCands_, pat::Tau::embedIsolationTracks(), embedIsolationTracks_, pat::Tau::embedLeadPFCand(), embedLeadPFCand_, pat::Tau::embedLeadPFChargedHadrCand(), embedLeadPFChargedHadrCand_, pat::Tau::embedLeadPFNeutralCand(), embedLeadPFNeutralCand_, pat::Tau::embedLeadTrack(), embedLeadTrack_, pat::Tau::embedSignalPFCands(), embedSignalPFCands_, pat::Tau::embedSignalPFChargedHadrCands(), embedSignalPFChargedHadrCands_, pat::Tau::embedSignalPFGammaCands(), embedSignalPFGammaCands_, pat::Tau::embedSignalPFNeutralHadrCands(), embedSignalPFNeutralHadrCands_, pat::Tau::embedSignalTracks(), embedSignalTracks_, pat::tau::TauPFEssential::emFraction_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), pat::helper::MultiIsolator::enabled(), pat::helper::MultiIsolator::endEvent(), reco::LeafCandidate::energy(), pat::tau::TauPFEssential::etaAtEcalEntrance_, pat::tau::TauPFEssential::etaAtEcalEntranceLeadChargedCand_, Exception, pat::helper::MultiIsolator::fill(), spr::find(), dqmdumpme::first, firstOccurence_, reco::PFTauTransverseImpactParameter::flightLength(), pat::tau::TauPFEssential::flightLength_, reco::PFTauTransverseImpactParameter::flightLengthSig(), pat::tau::TauPFEssential::flightLengthSig_, newFWLiteAna::found, jetProducer_cfi::genJetMatch, genJetMatchToken_, genMatchTokens_, edm::Ptr< T >::get(), edm::Ref< C, T, F >::get(), getTauIdDiscriminator(), getTauIdDiscriminatorFromContainer(), reco::PFCandidate::gsfTrackRef(), reco::PFTauTransverseImpactParameter::hasSecondaryVertex(), pat::tau::TauPFEssential::hasSV_, pat::PackedCandidate::hasTrackDetails(), reco::PFCandidate::hcalEnergy(), pat::tau::TauPFEssential::hcalEnergy_, pat::tau::TauPFEssential::hcalEnergyLeadChargedHadrCand_, mps_fire::i, training_settings::idx, iEvent, pat::Tau::initializeJEC(), reco::PFTauTransverseImpactParameter::ip3d(), pat::tau::TauPFEssential::ip3d_, reco::PFTauTransverseImpactParameter::ip3d_error(), pat::tau::TauPFEssential::ip3d_error_, edm::Ref< C, T, F >::isAvailable(), edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), isoDepositLabels_, isoDepositTokens_, isolator_, isolatorTmpStorage_, pat::Tau::isPFTau(), dqmiolumiharvest::j, edm::InputTag::label(), pat::tau::TauPFEssential::leadingTrackNormChi2_, jets_cff::levels, eostools::move(), reco::PFCandidate::muonRef(), dqmiodumpmetadata::n, Skims_PA_cff::name, pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), TauSpinnerFilter_cfi::ntaus, edm::parameterSet(), hemisphereProducer_cfi::patTaus, pat::Tau::pfEssential_, pfTauIDContainerTokens_, pfTauIDTokens_, pfTauToken_, pat::tau::TauPFEssential::phiAtEcalEntrance_, phID_, reco::PFCandidate::positionAtECALEntrance(), pat::PackedCandidate::pseudoTrack(), pat::tau::TauPFEssential::ptLeadChargedCand_, pTTauComparator_, resolutionLoader_, edm::second(), pat::Tau::setDecayMode(), pat::helper::EfficiencyLoader::setEfficiencies(), pat::Tau::setGenJet(), pat::Lepton< LeptonType >::setIsoDeposit(), pat::Lepton< LeptonType >::setIsolation(), pat::helper::KinResolutionsLoader::setResolutions(), pat::Tau::setTauIDs(), skipMissingTauID_, AlCaHLTBitMon_QueryRunRegistry::string, tauIDSrcContainers_, tauIDSrcs_, tauJetCorrFactorsTokens_, tauTransverseImpactParameterSrc_, tauTransverseImpactParameterToken_, HLT_2018_cff::track, reco::PFCandidate::trackRef(), userDataHelper_, and useUserData_.