282 if (
iEvent.isRealData()) {
293 edm::LogWarning(
"DataSource") <<
"WARNING! No Tau collection found. This missing input will not block the job. " 294 "Instead, an empty tau collection is being be produced.";
295 auto patTaus = std::make_unique<std::vector<Tau>>();
311 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
316 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>> genMatches(
genMatchTokens_.size());
328 std::vector<edm::ValueMap<TauJetCorrFactors>> tauJetCorrs;
333 tauJetCorrs.push_back(*tauJetCorr);
337 auto patTaus = std::make_unique<std::vector<Tau>>();
346 aTau.embedLeadTrack();
348 aTau.embedSignalTracks();
350 aTau.embedIsolationTracks();
353 aTau.embedLeadPFCand();
355 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 356 "from a reco::PFTau is impossible.\n";
360 aTau.embedLeadPFChargedHadrCand();
362 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 363 "from a reco::PFTau is impossible.\n";
367 aTau.embedLeadPFNeutralCand();
369 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 370 "from a reco::PFTau is impossible.\n";
374 aTau.embedSignalPFCands();
376 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 377 "from a reco::PFTau is impossible.\n";
381 aTau.embedSignalPFChargedHadrCands();
383 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 384 "from a reco::PFTau is impossible.\n";
388 aTau.embedSignalPFNeutralHadrCands();
390 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 391 "from a reco::PFTau is impossible.\n";
395 aTau.embedSignalPFGammaCands();
397 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 398 "from a reco::PFTau is impossible.\n";
402 aTau.embedIsolationPFCands();
404 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 405 "from a reco::PFTau is impossible.\n";
409 aTau.embedIsolationPFChargedHadrCands();
411 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 412 "from a reco::PFTau is impossible.\n";
416 aTau.embedIsolationPFNeutralHadrCands();
418 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 419 "from a reco::PFTau is impossible.\n";
423 aTau.embedIsolationPFGammaCands();
425 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made " 426 "from a reco::PFTau is impossible.\n";
431 for (
unsigned int i = 0;
i < tauJetCorrs.size(); ++
i) {
435 aTau.addJECFactors(tauJetCorr);
437 std::vector<std::string>
levels = tauJetCorrs[0][tausRef].correctionLabels();
439 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
441 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
443 aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
446 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n" 447 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain" 456 for (
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
458 aTau.addGenParticleRef(genTau);
461 aTau.embedGenParticle();
468 aTau.setGenJet(genJetTau);
475 size_t numberTauIds = numberPlainTauIds;
477 numberTauIds += it.size();
481 if (numberPlainTauIds != numberTauIds &&
phID_ !=
iEvent.processHistoryID()) {
485 if (!pfTauIdDiscr.isValid())
489 std::string prov_cfg_label = idcfg.second.first.first;
490 std::string prov_ID_label = idcfg.second.first.second;
492 if (prov_cfg_label ==
"rawValues" || prov_cfg_label ==
"workingPoints") {
493 const std::vector<std::string> psetsFromProvenance =
495 .getParameter<std::vector<std::string>>(prov_cfg_label);
496 for (
size_t i = 0;
i < psetsFromProvenance.size(); ++
i) {
497 if (psetsFromProvenance[
i] == prov_ID_label) {
499 if (prov_cfg_label ==
"rawValues")
500 idcfg.second.second = -1 -
i;
502 idcfg.second.second =
i;
506 }
else if (prov_cfg_label ==
"IDdefinitions" || prov_cfg_label ==
"IDWPdefinitions") {
507 const std::vector<edm::ParameterSet> psetsFromProvenance =
509 .getParameter<std::vector<edm::ParameterSet>>(prov_cfg_label);
510 for (
size_t i = 0;
i < psetsFromProvenance.size(); ++
i) {
511 if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") == prov_ID_label) {
513 if (prov_cfg_label ==
"IDdefinitions")
514 idcfg.second.second = -1 -
i;
516 idcfg.second.second =
i;
523 int i = std::stoi(prov_ID_label);
524 if (prov_cfg_label ==
"direct_rawValues")
525 idcfg.second.second = -1 -
i;
527 idcfg.second.second =
i;
529 }
catch (std::invalid_argument
const&
e) {
530 throw cms::Exception(
"Configuration") <<
"PATTauProducer: Direct access to ID container requested, so " 531 "argument of 'idLabel' must be convertable to int!\n";
535 throw cms::Exception(
"Configuration") <<
"PATTauProducer: Requested working point '" << prov_ID_label
536 <<
"' for ID '" << idcfg.first <<
"' not found!\n";
542 std::vector<pat::Tau::IdPair> ids(numberTauIds);
543 auto const& tausDeref = *tausRef;
547 for (
size_t i = 0;
i < numberPlainTauIds; ++
i) {
553 if (!missingDiscriminators.empty()) {
554 missingDiscriminators +=
", ";
566 if (!missingDiscriminators.empty()) {
567 missingDiscriminators +=
", ";
569 missingDiscriminators += it.first;
582 <<
"PATTauProducer: unsupported datatype '" <<
typeid(tausDeref).
name() <<
"' for tauSource\n";
585 edm::LogWarning(
"DataSource") <<
"The following tau discriminators have not been found in the event:\n" 586 << missingDiscriminators <<
"\n" 587 <<
"They will not be embedded into the pat::Tau object.\n" 588 <<
"Note: this message will be printed only at first occurence.";
596 if (aTau.isPFTau()) {
601 aTau.setDecayMode(pfTauRef->decayMode());
605 if (!aTau.pfEssential_.empty()) {
610 float ecalEnergy = 0;
611 float hcalEnergy = 0;
612 float sumPhiTimesEnergy = 0.;
613 float sumEtaTimesEnergy = 0.;
614 float sumEnergy = 0.;
615 float leadChargedCandPt = -99;
616 float leadChargedCandEtaAtEcalEntrance = -99;
617 const std::vector<reco::CandidatePtr>& signalCands = pfTauRef->signalCands();
618 for (
const auto& it : signalCands) {
620 if (ipfcand !=
nullptr) {
625 sumEnergy += ipfcand->
energy();
638 if (
track->pt() > leadChargedCandPt) {
640 leadChargedCandPt =
track->pt();
647 if (ipatcand !=
nullptr) {
650 double posAtECal_phi = ipatcand->
phi();
651 double posAtECal_eta = ipatcand->
eta();
655 posAtECal_phi = posAtECalEntrance.phi();
656 posAtECal_eta = posAtECalEntrance.eta();
658 sumPhiTimesEnergy += posAtECal_phi * ipatcand->
energy();
659 sumEtaTimesEnergy += posAtECal_eta * ipatcand->
energy();
660 sumEnergy += ipatcand->
energy();
662 if (
track !=
nullptr) {
663 if (
track->pt() > leadChargedCandPt) {
664 leadChargedCandEtaAtEcalEntrance = posAtECal_eta;
665 leadChargedCandPt =
track->pt();
675 if (sumEnergy != 0.) {
682 float leadingTrackNormChi2 = 0;
683 float ecalEnergyLeadChargedHadrCand = -99.;
684 float hcalEnergyLeadChargedHadrCand = -99.;
685 float emFraction = -1.;
686 float myHCALenergy = 0.;
687 float myECALenergy = 0.;
691 if (pfCandPtr !=
nullptr) {
692 ecalEnergyLeadChargedHadrCand = pfCandPtr->
ecalEnergy();
693 hcalEnergyLeadChargedHadrCand = pfCandPtr->
hcalEnergy();
696 leadingTrackNormChi2 = trackRef->normalizedChi2();
697 for (
const auto& isoPFCand : pfTauRef->isolationPFCands()) {
698 myHCALenergy += isoPFCand->hcalEnergy();
699 myECALenergy += isoPFCand->ecalEnergy();
701 for (
const auto& signalPFCand : pfTauRef->signalPFCands()) {
702 myHCALenergy += signalPFCand->hcalEnergy();
703 myECALenergy += signalPFCand->ecalEnergy();
705 if (myHCALenergy + myECALenergy != 0.) {
706 emFraction = myECALenergy / (myHCALenergy + myECALenergy);
711 if (packedCandPtr !=
nullptr) {
714 ecalEnergyLeadChargedHadrCand =
716 hcalEnergyLeadChargedHadrCand =
719 if (
track !=
nullptr) {
720 leadingTrackNormChi2 =
track->normalizedChi2();
721 for (
const auto& isoCand : pfTauRef->isolationCands()) {
729 for (
const auto& signalCand : pfTauRef->signalCands()) {
737 if (myHCALenergy + myECALenergy != 0.) {
738 emFraction = myECALenergy / (myHCALenergy + myECALenergy);
756 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
761 aTauPFEssential.
ip3d_ = tauLifetimeInfo.
ip3d();
775 aTau.setIsolation(it->first, it->second);
779 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