291 if (
iEvent.isRealData()) {
302 edm::LogWarning(
"DataSource") <<
"WARNING! No Tau collection found. This missing input will not block the job. " 303 "Instead, an empty tau collection is being be produced.";
304 auto patTaus = std::make_unique<std::vector<Tau>>();
320 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
325 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>> genMatches(
genMatchTokens_.size());
337 std::vector<edm::ValueMap<TauJetCorrFactors>> tauJetCorrs;
342 tauJetCorrs.push_back(*tauJetCorr);
346 auto patTaus = std::make_unique<std::vector<Tau>>();
355 aTau.embedLeadTrack();
357 aTau.embedSignalTracks();
359 aTau.embedIsolationTracks();
362 aTau.embedLeadPFCand();
364 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 365 "from a reco::PFTau is impossible.\n";
369 aTau.embedLeadPFChargedHadrCand();
371 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 372 "from a reco::PFTau is impossible.\n";
376 aTau.embedLeadPFNeutralCand();
378 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 379 "from a reco::PFTau is impossible.\n";
383 aTau.embedSignalPFCands();
385 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 386 "from a reco::PFTau is impossible.\n";
390 aTau.embedSignalPFChargedHadrCands();
392 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 393 "from a reco::PFTau is impossible.\n";
397 aTau.embedSignalPFNeutralHadrCands();
399 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 400 "from a reco::PFTau is impossible.\n";
404 aTau.embedSignalPFGammaCands();
406 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 407 "from a reco::PFTau is impossible.\n";
411 aTau.embedIsolationPFCands();
413 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 414 "from a reco::PFTau is impossible.\n";
418 aTau.embedIsolationPFChargedHadrCands();
420 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 421 "from a reco::PFTau is impossible.\n";
425 aTau.embedIsolationPFNeutralHadrCands();
427 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 428 "from a reco::PFTau is impossible.\n";
432 aTau.embedIsolationPFGammaCands();
434 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 435 "from a reco::PFTau is impossible.\n";
440 for (
unsigned int i = 0;
i < tauJetCorrs.size(); ++
i) {
444 aTau.addJECFactors(tauJetCorr);
446 std::vector<std::string>
levels = tauJetCorrs[0][tausRef].correctionLabels();
448 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
450 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
452 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
455 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n" 456 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain" 465 for (
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
467 aTau.addGenParticleRef(genTau);
470 aTau.embedGenParticle();
477 aTau.setGenJet(genJetTau);
484 size_t numberTauIds = numberPlainTauIds;
486 numberTauIds += it.size();
490 if (numberPlainTauIds != numberTauIds &&
phID_ !=
iEvent.processHistoryID()) {
494 if (!pfTauIdDiscr.isValid())
498 std::string prov_cfg_label = idcfg.second.first.first;
499 std::string prov_ID_label = idcfg.second.first.second;
501 if (prov_cfg_label ==
"rawValues" || prov_cfg_label ==
"workingPoints") {
502 const std::vector<std::string> psetsFromProvenance =
504 .getParameter<std::vector<std::string>>(prov_cfg_label);
505 for (
size_t i = 0;
i < psetsFromProvenance.size(); ++
i) {
506 if (psetsFromProvenance[
i] == prov_ID_label) {
508 if (prov_cfg_label ==
"rawValues")
509 idcfg.second.second = -1 -
i;
511 idcfg.second.second =
i;
515 }
else if (prov_cfg_label ==
"IDdefinitions" || prov_cfg_label ==
"IDWPdefinitions") {
516 const std::vector<edm::ParameterSet> psetsFromProvenance =
518 .getParameter<std::vector<edm::ParameterSet>>(prov_cfg_label);
519 for (
size_t i = 0;
i < psetsFromProvenance.size(); ++
i) {
520 if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") == prov_ID_label) {
522 if (prov_cfg_label ==
"IDdefinitions")
523 idcfg.second.second = -1 -
i;
525 idcfg.second.second =
i;
532 int i = std::stoi(prov_ID_label);
533 if (prov_cfg_label ==
"direct_rawValues")
534 idcfg.second.second = -1 -
i;
536 idcfg.second.second =
i;
538 }
catch (std::invalid_argument
const&
e) {
539 throw cms::Exception(
"Configuration") <<
"PATTauProducer: Direct access to ID container requested, so " 540 "argument of 'idLabel' must be convertable to int!\n";
544 throw cms::Exception(
"Configuration") <<
"PATTauProducer: Requested working point '" << prov_ID_label
545 <<
"' for ID '" << idcfg.first <<
"' not found!\n";
551 std::vector<pat::Tau::IdPair> ids(numberTauIds);
552 auto const& tausDeref = *tausRef;
556 for (
size_t i = 0;
i < numberPlainTauIds; ++
i) {
562 if (!missingDiscriminators.empty()) {
563 missingDiscriminators +=
", ";
575 if (!missingDiscriminators.empty()) {
576 missingDiscriminators +=
", ";
578 missingDiscriminators += it.first;
591 <<
"PATTauProducer: unsupported datatype '" <<
typeid(tausDeref).
name() <<
"' for tauSource\n";
594 edm::LogWarning(
"DataSource") <<
"The following tau discriminators have not been found in the event:\n" 595 << missingDiscriminators <<
"\n" 596 <<
"They will not be embedded into the pat::Tau object.\n" 597 <<
"Note: this message will be printed only at first occurence.";
605 if (aTau.isPFTau()) {
610 aTau.setDecayMode(pfTauRef->decayMode());
614 if (!aTau.pfEssential_.empty()) {
619 float ecalEnergy = 0;
620 float hcalEnergy = 0;
621 float sumPhiTimesEnergy = 0.;
622 float sumEtaTimesEnergy = 0.;
623 float sumEnergy = 0.;
624 float leadChargedCandPt = -99;
625 float leadChargedCandEtaAtEcalEntrance = -99;
626 const std::vector<reco::CandidatePtr>& signalCands = pfTauRef->signalCands();
627 for (
const auto& it : signalCands) {
629 if (ipfcand !=
nullptr) {
634 sumEnergy += ipfcand->
energy();
647 if (
track->pt() > leadChargedCandPt) {
649 leadChargedCandPt =
track->pt();
656 if (ipatcand !=
nullptr) {
659 double posAtECal_phi = ipatcand->
phi();
660 double posAtECal_eta = ipatcand->
eta();
664 posAtECal_phi = posAtECalEntrance.phi();
665 posAtECal_eta = posAtECalEntrance.eta();
667 sumPhiTimesEnergy += posAtECal_phi * ipatcand->
energy();
668 sumEtaTimesEnergy += posAtECal_eta * ipatcand->
energy();
669 sumEnergy += ipatcand->
energy();
671 if (
track !=
nullptr) {
672 if (
track->pt() > leadChargedCandPt) {
673 leadChargedCandEtaAtEcalEntrance = posAtECal_eta;
674 leadChargedCandPt =
track->pt();
684 if (sumEnergy != 0.) {
691 float leadingTrackNormChi2 = 0;
692 float ecalEnergyLeadChargedHadrCand = -99.;
693 float hcalEnergyLeadChargedHadrCand = -99.;
694 float emFraction = -1.;
695 float myHCALenergy = 0.;
696 float myECALenergy = 0.;
700 if (pfCandPtr !=
nullptr) {
701 ecalEnergyLeadChargedHadrCand = pfCandPtr->
ecalEnergy();
702 hcalEnergyLeadChargedHadrCand = pfCandPtr->
hcalEnergy();
705 leadingTrackNormChi2 = trackRef->normalizedChi2();
706 for (
const auto& isoPFCand : pfTauRef->isolationPFCands()) {
707 myHCALenergy += isoPFCand->hcalEnergy();
708 myECALenergy += isoPFCand->ecalEnergy();
710 for (
const auto& signalPFCand : pfTauRef->signalPFCands()) {
711 myHCALenergy += signalPFCand->hcalEnergy();
712 myECALenergy += signalPFCand->ecalEnergy();
714 if (myHCALenergy + myECALenergy != 0.) {
715 emFraction = myECALenergy / (myHCALenergy + myECALenergy);
720 if (packedCandPtr !=
nullptr) {
723 ecalEnergyLeadChargedHadrCand =
725 hcalEnergyLeadChargedHadrCand =
728 if (
track !=
nullptr) {
729 leadingTrackNormChi2 =
track->normalizedChi2();
730 for (
const auto& isoCand : pfTauRef->isolationCands()) {
738 for (
const auto& signalCand : pfTauRef->signalCands()) {
746 if (myHCALenergy + myECALenergy != 0.) {
747 emFraction = myECALenergy / (myHCALenergy + myECALenergy);
765 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
770 aTauPFEssential.
ip3d_ = tauLifetimeInfo.
ip3d();
784 aTau.setIsolation(it->first, it->second);
788 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
bool enabled() const
'true' if this there is at least one efficiency configured
reco::GsfTrackRef gsfTrackRef() const
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
float etaAtEcalEntranceLeadChargedCand_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
bool enabled() const
True if it has a non null configuration.
void beginEvent(const edm::EventSetup &)
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
const Vector & flightLength() const
bool addTauJetCorrFactors_
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
bool hasSecondaryVertex() const
pat::helper::EfficiencyLoader efficiencyLoader_
pat::helper::KinResolutionsLoader resolutionLoader_
bool isNonnull() const
Checks for non-null.
const math::XYZPointF & positionAtECALEntrance() const
float getTauIdDiscriminator(const edm::Handle< TauCollectionType > &, size_t, const edm::Handle< TauDiscrType > &)
double flightLengthSig() const
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
float caloFraction() const
Set the fraction of ECAL+HCAL energy over candidate energy.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
std::vector< edm::EDGetTokenT< reco::TauDiscriminatorContainer > > pfTauIDContainerTokens_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
bool embedIsolationPFChargedHadrCands_
U second(std::pair< T, U > const &p)
double ip3d_error() const
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
edm::EDGetTokenT< PFTauTIPAssociationByRef > tauTransverseImpactParameterToken_
double eta() const override
momentum pseudorapidity
pat::helper::MultiIsolator isolator_
double hcalEnergy() const
return corrected Hcal energy
edm::EDGetTokenT< edm::View< reco::BaseTau > > baseTauToken_
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
bool embedIsolationPFNeutralHadrCands_
bool isNonnull() const
Checks for non-null.
bool enabled() const
'true' if this there is at least one efficiency configured
float getTauIdDiscriminatorFromContainer(const edm::Handle< reco::PFTauCollection > &, size_t, const edm::Handle< reco::TauDiscriminatorContainer > &, int)
pat::PATUserDataHelper< pat::Tau > userDataHelper_
genJetMatch
switch on/off embedding of matched genJet's
bool embedSignalPFNeutralHadrCands_
bool embedIsolationPFCands_
double ecalEnergy() const
return corrected Ecal energy
reco::MuonRef muonRef() const
T const * get() const
Returns C++ pointer to the item.
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
const reco::Track * bestTrack() const override
return a pointer to the track if present. otherwise, return a null pointer
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
std::vector< edm::EDGetTokenT< edm::ValueMap< TauJetCorrFactors > > > tauJetCorrFactorsTokens_
edm::InputTag tauTransverseImpactParameterSrc_
bool embedIsolationTracks_
bool embedLeadPFChargedHadrCand_
const Point & dxy_PCA() const
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
std::pair< std::string, WPIdx > NameWPIdx
bool embedIsolationPFGammaCands_
std::vector< std::vector< NameWPIdx > > tauIDSrcContainers_
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetMatchToken_
bool embedSignalPFGammaCands_
std::vector< std::pair< pat::IsolationKeys, edm::InputTag > > isoDepositLabels_
float hcalFraction() const
Particle reconstructed by the particle flow algorithm.
bool embedLeadPFNeutralCand_
float leadingTrackNormChi2_
double energy() const override
energy
T const * get() const
Returns C++ pointer to the item.
reco::TrackRef trackRef() const
math::XYZPoint Point
point in the space
Log< level::Warning, false > LogWarning
edm::ProcessHistoryID phID_
float ecalEnergyLeadChargedHadrCand_
bool embedSignalPFChargedHadrCands_
std::vector< edm::EDGetTokenT< reco::PFTauDiscriminator > > pfTauIDTokens_
StableProvenance const & stable() const
std::vector< NameTag > tauIDSrcs_
edm::EDGetTokenT< reco::PFTauCollection > pfTauToken_
float hcalEnergyLeadChargedHadrCand_
double phi() const override
momentum azimuthal angle
GreaterByPt< Tau > pTTauComparator_
PositionAtECalEntranceComputer posAtECalEntranceComputer_
double energy() const final
energy