diff --git a/DataFormats/JetReco/src/classes_def_3.xml b/DataFormats/JetReco/src/classes_def_3.xml
index 0d2f651598d82..3984dba45a20c 100644
--- a/DataFormats/JetReco/src/classes_def_3.xml
+++ b/DataFormats/JetReco/src/classes_def_3.xml
@@ -124,4 +124,10 @@
+
+
+
+
+
+
diff --git a/DataFormats/PatCandidates/interface/Tau.h b/DataFormats/PatCandidates/interface/Tau.h
index f473cce07430c..4bf85d03ebde2 100644
--- a/DataFormats/PatCandidates/interface/Tau.h
+++ b/DataFormats/PatCandidates/interface/Tau.h
@@ -23,6 +23,7 @@
#include "DataFormats/PatCandidates/interface/Lepton.h"
#include "DataFormats/JetReco/interface/GenJetCollection.h"
#include "DataFormats/Candidate/interface/Candidate.h"
+#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/PatCandidates/interface/TauPFSpecific.h"
#include "DataFormats/PatCandidates/interface/TauCaloSpecific.h"
@@ -160,7 +161,7 @@ namespace pat {
const pat::tau::TauPFEssential & pfEssential() const;
/// Method copied from reco::PFTau.
/// Throws an exception if this pat::Tau was not made from a reco::PFTau
- const reco::PFJetRef & pfJetRef() const { return pfSpecific().pfJetRef_; }
+ const reco::JetBaseRef & pfJetRef() const { return pfSpecific().pfJetRef_; }
/// Method copied from reco::PFTau.
/// Throws an exception if this pat::Tau was not made from a reco::PFTau
reco::PFRecoTauChargedHadronRef leadTauChargedHadronCandidate() const;
@@ -452,6 +453,8 @@ namespace pat {
private:
+ /// helper to avoid code duplication in constructors
+ void initFromBaseTau(const reco::BaseTau& aTau);
// ---- for content embedding ----
bool embeddedIsolationTracks_;
std::vector isolationTracks_;
diff --git a/DataFormats/PatCandidates/interface/TauPFSpecific.h b/DataFormats/PatCandidates/interface/TauPFSpecific.h
index 87bf760d8082b..6da4fe67653ba 100644
--- a/DataFormats/PatCandidates/interface/TauPFSpecific.h
+++ b/DataFormats/PatCandidates/interface/TauPFSpecific.h
@@ -6,7 +6,7 @@
/**
\class pat::tau::PFSpecific TauPFSpecific.h "DataFormats/PatCandidates/interface/TauPFSpecific.h"
- \brief Structure to hold information specific to a PFTau inside a pat::Tau
+ \brief Structure to hold information specific to a PFTau made from PFCandidates inside a pat::Tau
\author Giovanni Petrucciani
*/
@@ -24,8 +24,8 @@ struct TauPFSpecific {
// constructor from PFTau
TauPFSpecific(const reco::PFTau& tau);
// datamembers
- reco::PFJetRef pfJetRef_;
- reco::PFCandidatePtr leadPFChargedHadrCand_;
+ reco::JetBaseRef pfJetRef_;
+ reco::CandidatePtr leadPFChargedHadrCand_;
float leadPFChargedHadrCandsignedSipt_;
reco::PFCandidatePtr leadPFNeutralCand_;
reco::PFCandidatePtr leadPFCand_;
diff --git a/DataFormats/PatCandidates/src/Tau.cc b/DataFormats/PatCandidates/src/Tau.cc
index 012e6d30c2c95..f0fc3896bfa4b 100644
--- a/DataFormats/PatCandidates/src/Tau.cc
+++ b/DataFormats/PatCandidates/src/Tau.cc
@@ -3,6 +3,7 @@
#include "DataFormats/PatCandidates/interface/Tau.h"
#include "DataFormats/JetReco/interface/GenJet.h"
+#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
#include
#include
@@ -47,13 +48,7 @@ Tau::Tau(const reco::BaseTau & aTau) :
,embeddedIsolationPFNeutralHadrCands_(false)
,embeddedIsolationPFGammaCands_(false)
{
- const reco::PFTau * pfTau = dynamic_cast(&aTau);
- if (pfTau != nullptr){
- pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau));
- pfEssential_.push_back(pat::tau::TauPFEssential(*pfTau));
- }
- const reco::CaloTau * caloTau = dynamic_cast(&aTau);
- if (caloTau != nullptr) caloSpecific_.push_back(pat::tau::TauCaloSpecific(*caloTau));
+ initFromBaseTau(aTau);
}
/// constructor from ref to reco::BaseTau
@@ -74,13 +69,7 @@ Tau::Tau(const edm::RefToBase & aTauRef) :
,embeddedIsolationPFNeutralHadrCands_(false)
,embeddedIsolationPFGammaCands_(false)
{
- const reco::PFTau * pfTau = dynamic_cast(aTauRef.get());
- if (pfTau != nullptr){
- pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau));
- pfEssential_.push_back(pat::tau::TauPFEssential(*pfTau));
- }
- const reco::CaloTau * caloTau = dynamic_cast(aTauRef.get());
- if (caloTau != nullptr) caloSpecific_.push_back(pat::tau::TauCaloSpecific(*caloTau));
+ initFromBaseTau(*aTauRef);
}
/// constructor from ref to reco::BaseTau
@@ -101,12 +90,40 @@ Tau::Tau(const edm::Ptr & aTauRef) :
,embeddedIsolationPFNeutralHadrCands_(false)
,embeddedIsolationPFGammaCands_(false)
{
- const reco::PFTau * pfTau = dynamic_cast(aTauRef.get());
+ initFromBaseTau(*aTauRef);
+}
+
+void Tau::initFromBaseTau(const reco::BaseTau& aTau) {
+ const reco::PFTau * pfTau = dynamic_cast(&aTau);
if (pfTau != nullptr){
- pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau));
+ // If PFTau is made from PackedCandidates, directly fill slimmed version
+ // without PFSpecific
+ const pat::PackedCandidate* pc = dynamic_cast(pfTau->leadChargedHadrCand().get());
+ if (pc != nullptr) {
+ for (const auto& ptr : pfTau->signalChargedHadrCands())
+ signalChargedHadrCandPtrs_.push_back(ptr);
+
+ for (const auto& ptr : pfTau->signalNeutrHadrCands())
+ signalNeutralHadrCandPtrs_.push_back(ptr);
+
+ for (const auto& ptr : pfTau->signalGammaCands())
+ signalGammaCandPtrs_.push_back(ptr);
+
+ for (const auto& ptr : pfTau->isolationChargedHadrCands())
+ isolationChargedHadrCandPtrs_.push_back(ptr);
+
+ for (const auto& ptr : pfTau->isolationNeutrHadrCands())
+ isolationNeutralHadrCandPtrs_.push_back(ptr);
+
+ for (const auto& ptr : pfTau->isolationGammaCands())
+ isolationGammaCandPtrs_.push_back(ptr);
+ }
+ else {
+ pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau));
+ }
pfEssential_.push_back(pat::tau::TauPFEssential(*pfTau));
}
- const reco::CaloTau * caloTau = dynamic_cast(aTauRef.get());
+ const reco::CaloTau * caloTau = dynamic_cast(&aTau);
if (caloTau != nullptr) caloSpecific_.push_back(pat::tau::TauCaloSpecific(*caloTau));
}
@@ -326,7 +343,7 @@ void Tau::embedLeadPFCand() {
}
leadPFCand_.clear();
if (pfSpecific_[0].leadPFCand_.isNonnull() ) {
- leadPFCand_.push_back(*pfSpecific_[0].leadPFCand_); //already set in C-tor
+ leadPFCand_.push_back(*static_cast(&*pfSpecific_[0].leadPFCand_)); //already set in C-tor
embeddedLeadPFCand_ = true;
}
}
@@ -337,7 +354,7 @@ void Tau::embedLeadPFChargedHadrCand() {
}
leadPFChargedHadrCand_.clear();
if (pfSpecific_[0].leadPFChargedHadrCand_.isNonnull() ) {
- leadPFChargedHadrCand_.push_back(*pfSpecific_[0].leadPFChargedHadrCand_); //already set in C-tor
+ leadPFChargedHadrCand_.push_back(*static_cast(&*pfSpecific_[0].leadPFChargedHadrCand_)); //already set in C-tor
embeddedLeadPFChargedHadrCand_ = true;
}
}
@@ -348,7 +365,7 @@ void Tau::embedLeadPFNeutralCand() {
}
leadPFNeutralCand_.clear();
if (pfSpecific_[0].leadPFNeutralCand_.isNonnull() ) {
- leadPFNeutralCand_.push_back(*pfSpecific_[0].leadPFNeutralCand_); //already set in C-tor
+ leadPFNeutralCand_.push_back(*static_cast(&*pfSpecific_[0].leadPFNeutralCand_)); //already set in C-tor
embeddedLeadPFNeutralCand_ = true;
}
}
@@ -359,7 +376,7 @@ void Tau::embedSignalPFCands() {
}
std::vector candPtrs = pfSpecific_[0].selectedSignalPFCands_;
for (unsigned int i = 0; i < candPtrs.size(); i++) {
- signalPFCands_.push_back(*candPtrs.at(i));
+ signalPFCands_.push_back(candPtrs.at(i));
}
embeddedSignalPFCands_ = true;
}
@@ -369,7 +386,7 @@ void Tau::embedSignalPFChargedHadrCands() {
}
std::vector candPtrs = pfSpecific_[0].selectedSignalPFChargedHadrCands_;
for (unsigned int i = 0; i < candPtrs.size(); i++) {
- signalPFChargedHadrCands_.push_back(*candPtrs.at(i));
+ signalPFChargedHadrCands_.push_back(candPtrs.at(i));
}
embeddedSignalPFChargedHadrCands_ = true;
}
@@ -379,7 +396,7 @@ void Tau::embedSignalPFNeutralHadrCands() {
}
std::vector candPtrs = pfSpecific_[0].selectedSignalPFNeutrHadrCands_;
for (unsigned int i = 0; i < candPtrs.size(); i++) {
- signalPFNeutralHadrCands_.push_back(*candPtrs.at(i));
+ signalPFNeutralHadrCands_.push_back(candPtrs.at(i));
}
embeddedSignalPFNeutralHadrCands_ = true;
}
@@ -389,7 +406,7 @@ void Tau::embedSignalPFGammaCands() {
}
std::vector candPtrs = pfSpecific_[0].selectedSignalPFGammaCands_;
for (unsigned int i = 0; i < candPtrs.size(); i++) {
- signalPFGammaCands_.push_back(*candPtrs.at(i));
+ signalPFGammaCands_.push_back(candPtrs.at(i));
}
embeddedSignalPFGammaCands_ = true;
}
@@ -400,7 +417,7 @@ void Tau::embedIsolationPFCands() {
}
std::vector candPtrs = pfSpecific_[0].selectedIsolationPFCands_;
for (unsigned int i = 0; i < candPtrs.size(); i++) {
- isolationPFCands_.push_back(*candPtrs.at(i));
+ isolationPFCands_.push_back(candPtrs.at(i));
}
embeddedIsolationPFCands_ = true;
}
@@ -411,7 +428,7 @@ void Tau::embedIsolationPFChargedHadrCands() {
}
std::vector candPtrs = pfSpecific_[0].selectedIsolationPFChargedHadrCands_;
for (unsigned int i = 0; i < candPtrs.size(); i++) {
- isolationPFChargedHadrCands_.push_back(*candPtrs.at(i));
+ isolationPFChargedHadrCands_.push_back(candPtrs.at(i));
}
embeddedIsolationPFChargedHadrCands_ = true;
}
@@ -421,7 +438,7 @@ void Tau::embedIsolationPFNeutralHadrCands() {
}
std::vector candPtrs = pfSpecific_[0].selectedIsolationPFNeutrHadrCands_;
for (unsigned int i = 0; i < candPtrs.size(); i++) {
- isolationPFNeutralHadrCands_.push_back(*candPtrs.at(i));
+ isolationPFNeutralHadrCands_.push_back(candPtrs.at(i));
}
embeddedIsolationPFNeutralHadrCands_ = true;
}
@@ -431,7 +448,7 @@ void Tau::embedIsolationPFGammaCands() {
}
std::vector candPtrs = pfSpecific_[0].selectedIsolationPFGammaCands_;
for (unsigned int i = 0; i < candPtrs.size(); i++) {
- isolationPFGammaCands_.push_back(*candPtrs.at(i));
+ isolationPFGammaCands_.push_back(candPtrs.at(i));
}
embeddedIsolationPFGammaCands_ = true;
}
@@ -445,10 +462,17 @@ reco::PFRecoTauChargedHadronRef Tau::leadTauChargedHadronCandidate() const {
}
}
+const reco::PFCandidatePtr convertToPFCandidatePtr(const reco::CandidatePtr& ptr) {
+ const reco::PFCandidate* pf_cand = dynamic_cast(&*ptr);
+ if (pf_cand)
+ return edm::Ptr(ptr);
+ return reco::PFCandidatePtr();
+}
+
const reco::PFCandidatePtr Tau::leadPFChargedHadrCand() const {
if(!embeddedLeadPFChargedHadrCand_){
if(pfSpecific_.empty()) return reco::PFCandidatePtr();
- else return pfSpecific().leadPFChargedHadrCand_;
+ else return convertToPFCandidatePtr(pfSpecific().leadPFChargedHadrCand_);
}else
return reco::PFCandidatePtr(&leadPFChargedHadrCand_,0);
}
@@ -456,7 +480,7 @@ const reco::PFCandidatePtr Tau::leadPFChargedHadrCand() const {
const reco::PFCandidatePtr Tau::leadPFNeutralCand() const {
if(!embeddedLeadPFNeutralCand_){
if(pfSpecific_.empty()) return reco::PFCandidatePtr();
- else return pfSpecific().leadPFNeutralCand_;
+ else return convertToPFCandidatePtr(pfSpecific().leadPFNeutralCand_);
}else
return reco::PFCandidatePtr(&leadPFNeutralCand_,0);
}
@@ -464,7 +488,7 @@ const reco::PFCandidatePtr Tau::leadPFNeutralCand() const {
const reco::PFCandidatePtr Tau::leadPFCand() const {
if(!embeddedLeadPFCand_){
if(pfSpecific_.empty()) return reco::PFCandidatePtr();
- return pfSpecific().leadPFCand_;
+ return convertToPFCandidatePtr(pfSpecific().leadPFCand_);
}else
return reco::PFCandidatePtr(&leadPFCand_,0);
}
@@ -484,8 +508,10 @@ const std::vector& Tau::signalPFCands() const {
if(pfSpecific_.empty() || pfSpecific().selectedSignalPFCands_.empty() || !pfSpecific().selectedSignalPFCands_.front().isAvailable()){
// this part of code is called when reading from patTuple or miniAOD
// it returns empty collection in correct format so it can be substituted by reco::Candidates if available
- std::unique_ptr > aPtrs{new std::vector{}};
- signalPFCandsTransientPtrs_.set(std::move(aPtrs));
+ if (!signalPFCandsTransientPtrs_.isSet()) {
+ std::unique_ptr > aPtrs{new std::vector{}};
+ signalPFCandsTransientPtrs_.set(std::move(aPtrs));
+ }
return *signalPFCandsTransientPtrs_;
} else return pfSpecific().selectedSignalPFCands_;
}
@@ -506,8 +532,10 @@ const std::vector& Tau::signalPFChargedHadrCands() const {
if(pfSpecific_.empty() || pfSpecific().selectedSignalPFChargedHadrCands_.empty() || !pfSpecific().selectedSignalPFChargedHadrCands_.front().isAvailable()){
// this part of code is called when reading from patTuple or miniAOD
// it returns empty collection in correct format so it can be substituted by reco::Candidates if available
- std::unique_ptr > aPtrs{new std::vector{}};
- signalPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs));
+ if (!signalPFChargedHadrCandsTransientPtrs_.isSet()) {
+ std::unique_ptr > aPtrs{new std::vector{}};
+ signalPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs));
+ }
return *signalPFChargedHadrCandsTransientPtrs_;
} else return pfSpecific().selectedSignalPFChargedHadrCands_;
}
@@ -528,8 +556,10 @@ const std::vector& Tau::signalPFNeutrHadrCands() const {
if(pfSpecific_.empty() || pfSpecific().selectedSignalPFNeutrHadrCands_.empty() || !pfSpecific().selectedSignalPFNeutrHadrCands_.front().isAvailable()){
// this part of code is called when reading from patTuple or miniAOD
// it returns empty collection in correct format so it can be substituted by reco::Candidates if available
- std::unique_ptr > aPtrs{new std::vector{}};
- signalPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs));
+ if (!signalPFNeutralHadrCandsTransientPtrs_.isSet()) {
+ std::unique_ptr > aPtrs{new std::vector{}};
+ signalPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs));
+ }
return *signalPFNeutralHadrCandsTransientPtrs_;
} else return pfSpecific().selectedSignalPFNeutrHadrCands_;
}
@@ -550,8 +580,10 @@ const std::vector& Tau::signalPFGammaCands() const {
if(pfSpecific_.empty() || pfSpecific().selectedSignalPFGammaCands_.empty() || !pfSpecific().selectedSignalPFGammaCands_.front().isAvailable()){
// this part of code is called when reading from patTuple or miniAOD
// it returns empty collection in correct format so it can be substituted by reco::Candidates if available
- std::unique_ptr > aPtrs{new std::vector{}};
- signalPFGammaCandsTransientPtrs_.set(std::move(aPtrs));
+ if (!signalPFGammaCandsTransientPtrs_.isSet()) {
+ std::unique_ptr > aPtrs{new std::vector{}};
+ signalPFGammaCandsTransientPtrs_.set(std::move(aPtrs));
+ }
return *signalPFGammaCandsTransientPtrs_;
} else return pfSpecific().selectedSignalPFGammaCands_;
}
@@ -582,8 +614,10 @@ const std::vector& Tau::isolationPFCands() const {
if(pfSpecific_.empty() || pfSpecific().selectedIsolationPFCands_.empty() || !pfSpecific().selectedIsolationPFCands_.front().isAvailable()){
// this part of code is called when reading from patTuple or miniAOD
// it returns empty collection in correct format so it can be substituted by reco::Candidates if available
- std::unique_ptr > aPtrs{new std::vector{}};
- isolationPFCandsTransientPtrs_.set(std::move(aPtrs));
+ if (!isolationPFCandsTransientPtrs_.isSet()) {
+ std::unique_ptr > aPtrs{new std::vector{}};
+ isolationPFCandsTransientPtrs_.set(std::move(aPtrs));
+ }
return *isolationPFCandsTransientPtrs_;
} else return pfSpecific().selectedIsolationPFCands_;
}
@@ -604,8 +638,10 @@ const std::vector& Tau::isolationPFChargedHadrCands() cons
if(pfSpecific_.empty() || pfSpecific().selectedIsolationPFChargedHadrCands_.empty() || !pfSpecific().selectedIsolationPFChargedHadrCands_.front().isAvailable()){
// this part of code is called when reading from patTuple or miniAOD
// it returns empty collection in correct format so it can be substituted by reco::Candidates if available
- std::unique_ptr > aPtrs{new std::vector{}};
- isolationPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs));
+ if (!isolationPFChargedHadrCandsTransientPtrs_.isSet()) {
+ std::unique_ptr > aPtrs{new std::vector{}};
+ isolationPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs));
+ }
return *isolationPFChargedHadrCandsTransientPtrs_;
} else return pfSpecific().selectedIsolationPFChargedHadrCands_;
}
@@ -626,8 +662,10 @@ const std::vector& Tau::isolationPFNeutrHadrCands() const
if(pfSpecific_.empty() || pfSpecific().selectedIsolationPFNeutrHadrCands_.empty() || !pfSpecific().selectedIsolationPFNeutrHadrCands_.front().isAvailable()){
// this part of code is called when reading from patTuple or miniAOD
// it returns empty collection in correct format so it can be substituted by reco::Candidates if available
- std::unique_ptr > aPtrs{new std::vector{}};
- isolationPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs));
+ if (!isolationPFNeutralHadrCandsTransientPtrs_.isSet()) {
+ std::unique_ptr > aPtrs{new std::vector{}};
+ isolationPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs));
+ }
return *isolationPFNeutralHadrCandsTransientPtrs_;
} else return pfSpecific().selectedIsolationPFNeutrHadrCands_;
}
@@ -648,8 +686,10 @@ const std::vector& Tau::isolationPFGammaCands() const {
if(pfSpecific_.empty() || pfSpecific().selectedIsolationPFGammaCands_.empty() || !pfSpecific().selectedIsolationPFGammaCands_.front().isAvailable()){
// this part of code is called when reading from patTuple or miniAOD
// it returns empty collection in correct format so it can be substituted by reco::Candidates if available
- std::unique_ptr > aPtrs{new std::vector{}};
- isolationPFGammaCandsTransientPtrs_.set(std::move(aPtrs));
+ if (!isolationPFGammaCandsTransientPtrs_.isSet()) {
+ std::unique_ptr > aPtrs{new std::vector{}};
+ isolationPFGammaCandsTransientPtrs_.set(std::move(aPtrs));
+ }
return *isolationPFGammaCandsTransientPtrs_;
} else return pfSpecific().selectedIsolationPFGammaCands_;
}
diff --git a/DataFormats/PatCandidates/src/classes_def_objects.xml b/DataFormats/PatCandidates/src/classes_def_objects.xml
index 5392ee53572b2..528ecfb3191f4 100644
--- a/DataFormats/PatCandidates/src/classes_def_objects.xml
+++ b/DataFormats/PatCandidates/src/classes_def_objects.xml
@@ -164,7 +164,8 @@
-
+
+
@@ -173,6 +174,7 @@
+
@@ -617,6 +619,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/DataFormats/PatCandidates/src/classes_objects.h b/DataFormats/PatCandidates/src/classes_objects.h
index 10065b7cd826c..1d3384eae3a93 100644
--- a/DataFormats/PatCandidates/src/classes_objects.h
+++ b/DataFormats/PatCandidates/src/classes_objects.h
@@ -1,5 +1,6 @@
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/Common/interface/Association.h"
+#include "DataFormats/Common/interface/AssociationMap.h"
#include "DataFormats/Common/interface/Wrapper.h"
#include "DataFormats/Common/interface/PtrVector.h"
#include "DataFormats/Common/interface/FwdPtr.h"
diff --git a/DataFormats/TauReco/interface/JetPiZeroAssociation.h b/DataFormats/TauReco/interface/JetPiZeroAssociation.h
index bf351a682b42b..697cb283e2cf1 100644
--- a/DataFormats/TauReco/interface/JetPiZeroAssociation.h
+++ b/DataFormats/TauReco/interface/JetPiZeroAssociation.h
@@ -3,12 +3,12 @@
#include "DataFormats/Common/interface/AssociationVector.h"
#include "DataFormats/TauReco/interface/RecoTauPiZero.h"
-#include "DataFormats/JetReco/interface/PFJetCollection.h"
+#include "DataFormats/JetReco/interface/JetCollection.h"
namespace reco {
// This base class improves the readability of the ROOT class name by hiding
// the template crap
- typedef edm::AssociationVector > >
+ typedef edm::AssociationVector > >
JetPiZeroAssociationBase;
class JetPiZeroAssociation : public JetPiZeroAssociationBase {
@@ -17,7 +17,7 @@ namespace reco {
JetPiZeroAssociationBase()
{ }
- JetPiZeroAssociation(const reco::PFJetRefProd & ref) :
+ JetPiZeroAssociation(const JetRefBaseProd & ref) :
JetPiZeroAssociationBase(ref)
{ }
diff --git a/DataFormats/TauReco/interface/PFJetChargedHadronAssociation.h b/DataFormats/TauReco/interface/PFJetChargedHadronAssociation.h
index 28a13e4f67aed..4a5f2f6acba2e 100644
--- a/DataFormats/TauReco/interface/PFJetChargedHadronAssociation.h
+++ b/DataFormats/TauReco/interface/PFJetChargedHadronAssociation.h
@@ -3,13 +3,13 @@
#include "DataFormats/Common/interface/AssociationVector.h"
#include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h"
-#include "DataFormats/JetReco/interface/PFJetCollection.h"
+#include "DataFormats/JetReco/interface/JetCollection.h"
namespace reco
{
// This base class improves the readability of the ROOT class name by hiding
// the template crap
- typedef edm::AssociationVector > > PFJetChargedHadronAssociationBase;
+ typedef edm::AssociationVector > > PFJetChargedHadronAssociationBase;
class PFJetChargedHadronAssociation : public PFJetChargedHadronAssociationBase
{
@@ -18,7 +18,7 @@ namespace reco
: PFJetChargedHadronAssociationBase()
{}
- PFJetChargedHadronAssociation(const reco::PFJetRefProd& ref)
+ PFJetChargedHadronAssociation(const reco::JetRefBaseProd& ref)
: PFJetChargedHadronAssociationBase(ref)
{}
diff --git a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h
index 1b00b64f058e2..833bc806a280e 100644
--- a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h
+++ b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h
@@ -2,14 +2,15 @@
#define DataFormats_TauReco_PFRecoTauChargedHadron_h
#include "DataFormats/Candidate/interface/CompositePtrCandidate.h"
-#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
+#include "DataFormats/Candidate/interface/CandidateFwd.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/Common/interface/Ptr.h"
#include "DataFormats/Math/interface/Point3D.h"
namespace reco { namespace tau {
+ template
+ class PFRecoTauChargedHadronFromGenericTrackPlugin;
class PFRecoTauChargedHadronFromPFCandidatePlugin;
- class PFRecoTauChargedHadronFromTrackPlugin;
class RecoTauConstructor;
class PFRecoTauEnergyAlgorithmPlugin;
}}
@@ -47,13 +48,16 @@ class PFRecoTauChargedHadron : public CompositePtrCandidate
~PFRecoTauChargedHadron() override;
/// reference to "charged" PFCandidate (either charged PFCandidate or PFNeutralHadron)
- const PFCandidatePtr& getChargedPFCandidate() const;
+ const CandidatePtr& getChargedPFCandidate() const;
/// reference to reco::Track
const TrackPtr& getTrack() const;
+ /// reference to "lostTrack Candidate" when chadron built with tracks stored as pat::PackedCandidates
+ const CandidatePtr& getLostTrackCandidate() const;
+
/// references to additional neutral PFCandidates
- const std::vector& getNeutralPFCandidates() const;
+ const std::vector& getNeutralPFCandidates() const;
/// position at ECAL entrance
const math::XYZPointF& positionAtECALEntrance() const;
@@ -68,16 +72,18 @@ class PFRecoTauChargedHadron : public CompositePtrCandidate
private:
friend class tau::PFRecoTauChargedHadronFromPFCandidatePlugin;
- friend class tau::PFRecoTauChargedHadronFromTrackPlugin;
+ template
+ friend class tau::PFRecoTauChargedHadronFromGenericTrackPlugin;
friend class tau::RecoTauConstructor;
friend class tau::PFRecoTauEnergyAlgorithmPlugin;
friend class ::PFRecoTauChargedHadronProducer;
PFRecoTauChargedHadronAlgorithm algo_;
- PFCandidatePtr chargedPFCandidate_;
+ CandidatePtr chargedPFCandidate_;
+ CandidatePtr lostTrackCandidate_;
TrackPtr track_;
- std::vector neutralPFCandidates_;
+ std::vector neutralPFCandidates_;
math::XYZPointF positionAtECALEntrance_;
};
diff --git a/DataFormats/TauReco/interface/PFTau.h b/DataFormats/TauReco/interface/PFTau.h
index cd8c28fc87b53..65f0f8fb2f902 100644
--- a/DataFormats/TauReco/interface/PFTau.h
+++ b/DataFormats/TauReco/interface/PFTau.h
@@ -13,9 +13,9 @@
#include "DataFormats/TauReco/interface/BaseTau.h"
#include "DataFormats/TauReco/interface/PFTauFwd.h"
#include "DataFormats/TauReco/interface/PFTauTagInfo.h"
-#include "DataFormats/JetReco/interface/PFJetCollection.h"
-#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
-#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
+#include "DataFormats/JetReco/interface/JetCollection.h"
+#include "DataFormats/Candidate/interface/Candidate.h"
+#include "DataFormats/Candidate/interface/CandidateFwd.h"
#include "DataFormats/TauReco/interface/RecoTauPiZero.h"
#include "DataFormats/TauReco/interface/RecoTauPiZeroFwd.h"
#include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h"
@@ -58,59 +58,72 @@ class PFTau : public BaseTau {
~PFTau() override {};
PFTau* clone() const override;
- const PFJetRef& jetRef() const;
- void setjetRef(const PFJetRef&);
+ const JetBaseRef& jetRef() const;
+ void setjetRef(const JetBaseRef&);
// functions to access the PFTauTagInfoRef used by HLT
const PFTauTagInfoRef& pfTauTagInfoRef() const;
void setpfTauTagInfoRef(const PFTauTagInfoRef);
PFRecoTauChargedHadronRef leadTauChargedHadronCandidate() const;
- const PFCandidatePtr& leadPFChargedHadrCand() const;
- const PFCandidatePtr& leadPFNeutralCand() const;
+ const CandidatePtr& leadChargedHadrCand() const;
+ const CandidatePtr& leadNeutralCand() const;
//Can be either the charged or the neutral one
- const PFCandidatePtr& leadPFCand() const;
+ const CandidatePtr& leadCand() const;
- void setleadPFChargedHadrCand(const PFCandidatePtr&);
- void setleadPFNeutralCand(const PFCandidatePtr&);
- void setleadPFCand(const PFCandidatePtr&);
+ void setleadChargedHadrCand(const CandidatePtr&);
+ void setleadNeutralCand(const CandidatePtr&);
+ void setleadCand(const CandidatePtr&);
/// Signed transverse impact parameter significance of the Track
/// associated to the leading charged PFCandidate
float leadPFChargedHadrCandsignedSipt() const;
void setleadPFChargedHadrCandsignedSipt(const float&);
- /// PFCandidates in signal region
- const std::vector& signalPFCands() const;
- void setsignalPFCands(const std::vector&);
+ /// Candidates in signal region
+ const std::vector& signalCands() const;
+ void setsignalCands(const std::vector&);
/// Charged hadrons in signal region
- const std::vector& signalPFChargedHadrCands() const;
- void setsignalPFChargedHadrCands(const std::vector&);
+ const std::vector& signalChargedHadrCands() const;
+ void setsignalChargedHadrCands(const std::vector&);
/// Neutral hadrons in signal region
- const std::vector& signalPFNeutrHadrCands() const;
- void setsignalPFNeutrHadrCands(const std::vector&);
+ const std::vector& signalNeutrHadrCands() const;
+ void setsignalNeutrHadrCands(const std::vector&);
/// Gamma candidates in signal region
- const std::vector& signalPFGammaCands() const;
- void setsignalPFGammaCands(const std::vector&);
+ const std::vector& signalGammaCands() const;
+ void setsignalGammaCands(const std::vector&);
- /// PFCandidates in isolation region
- const std::vector& isolationPFCands() const;
- void setisolationPFCands(const std::vector&);
+ /// Candidates in isolation region
+ const std::vector& isolationCands() const;
+ void setisolationCands(const std::vector&);
/// Charged candidates in isolation region
- const std::vector& isolationPFChargedHadrCands() const;
- void setisolationPFChargedHadrCands(const std::vector&);
+ const std::vector& isolationChargedHadrCands() const;
+ void setisolationChargedHadrCands(const std::vector&);
//// Neutral hadrons in isolation region
- const std::vector& isolationPFNeutrHadrCands() const;
- void setisolationPFNeutrHadrCands(const std::vector&);
+ const std::vector& isolationNeutrHadrCands() const;
+ void setisolationNeutrHadrCands(const std::vector&);
/// Gamma candidates in isolation region
+ const std::vector& isolationGammaCands() const;
+ void setisolationGammaCands(const std::vector&);
+
+ /// Getters for different PFCandidates for PFTaus made from PFCandidates
+ const PFCandidatePtr leadPFChargedHadrCand() const;
+ const PFCandidatePtr leadPFNeutralCand() const;
+ const PFCandidatePtr leadPFCand() const;
+ const std::vector& signalPFCands() const;
+ const std::vector& signalPFChargedHadrCands() const;
+ const std::vector& signalPFNeutrHadrCands() const;
+ const std::vector& signalPFGammaCands() const;
+ const std::vector& isolationPFCands() const;
+ const std::vector& isolationPFChargedHadrCands() const;
+ const std::vector& isolationPFNeutrHadrCands() const;
const std::vector& isolationPFGammaCands() const;
- void setisolationPFGammaCands(const std::vector&);
/// Sum of charged hadron candidate PT in isolation cone; returns NaN
/// if isolation region is undefined.
@@ -244,24 +257,39 @@ class PFTau : public BaseTau {
float signalConeSize_;
- reco::PFJetRef jetRef_;
+ reco::JetBaseRef jetRef_;
PFTauTagInfoRef PFTauTagInfoRef_;
- reco::PFCandidatePtr leadPFChargedHadrCand_;
- reco::PFCandidatePtr leadPFNeutralCand_;
- reco::PFCandidatePtr leadPFCand_;
+ reco::CandidatePtr leadChargedHadrCand_;
+ reco::CandidatePtr leadNeutralCand_;
+ reco::CandidatePtr leadCand_;
reco::TrackRef electronPreIDTrack_;
// Signal candidates
- std::vector selectedSignalPFCands_;
- std::vector selectedSignalPFChargedHadrCands_;
- std::vector selectedSignalPFNeutrHadrCands_;
- std::vector selectedSignalPFGammaCands_;
+ std::vector selectedSignalCands_;
+ std::vector selectedSignalChargedHadrCands_;
+ std::vector selectedSignalNeutrHadrCands_;
+ std::vector selectedSignalGammaCands_;
// Isolation candidates
- std::vector selectedIsolationPFCands_;
- std::vector selectedIsolationPFChargedHadrCands_;
- std::vector selectedIsolationPFNeutrHadrCands_;
- std::vector selectedIsolationPFGammaCands_;
+ std::vector selectedIsolationCands_;
+ std::vector selectedIsolationChargedHadrCands_;
+ std::vector selectedIsolationNeutrHadrCands_;
+ std::vector selectedIsolationGammaCands_;
+
+ // Transient caches for PFCandidate-based accessors
+ edm::AtomicPtrCache leadPFChargedHadrCand_;
+ edm::AtomicPtrCache leadPFNeutralCand_;
+ edm::AtomicPtrCache leadPFCand_;
+
+ edm::AtomicPtrCache > selectedTransientSignalPFCands_;
+ edm::AtomicPtrCache > selectedTransientSignalPFChargedHadrCands_;
+ edm::AtomicPtrCache > selectedTransientSignalPFNeutrHadrCands_;
+ edm::AtomicPtrCache > selectedTransientSignalPFGammaCands_;
+
+ edm::AtomicPtrCache > selectedTransientIsolationPFCands_;
+ edm::AtomicPtrCache > selectedTransientIsolationPFChargedHadrCands_;
+ edm::AtomicPtrCache > selectedTransientIsolationPFNeutrHadrCands_;
+ edm::AtomicPtrCache > selectedTransientIsolationPFGammaCands_;
RecoTauPiZeroRefVector signalPiZeroCandidatesRefs_;
RecoTauPiZeroRefVector isolationPiZeroCandidatesRefs_;
diff --git a/DataFormats/TauReco/interface/PFTauTagInfo.h b/DataFormats/TauReco/interface/PFTauTagInfo.h
index 6b6df4c20603b..7f4e6f82b3912 100644
--- a/DataFormats/TauReco/interface/PFTauTagInfo.h
+++ b/DataFormats/TauReco/interface/PFTauTagInfo.h
@@ -11,7 +11,7 @@
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
-#include "DataFormats/JetReco/interface/PFJetCollection.h"
+#include "DataFormats/JetReco/interface/JetCollection.h"
#include "DataFormats/TauReco/interface/PFTauTagInfoFwd.h"
#include "DataFormats/TauReco/interface/BaseTauTagInfo.h"
@@ -24,22 +24,22 @@ namespace reco{
virtual PFTauTagInfo* clone()const;
//get the PFCandidates which compose the PF jet and were filtered by RecoTauTag/TauTagTools/ TauTagTools::filteredPFChargedHadrCands(.,...), filteredPFNeutrHadrCands(.), filteredPFGammaCands(.) functions through RecoTauTag/RecoTauTag/ PFRecoTauTagInfoProducer EDProducer
- std::vector PFCands()const;
- const std::vector& PFChargedHadrCands()const;
- void setPFChargedHadrCands(const std::vector&);
- const std::vector& PFNeutrHadrCands()const;
- void setPFNeutrHadrCands(const std::vector&);
- const std::vector& PFGammaCands()const;
- void setPFGammaCands(const std::vector&);
+ std::vector PFCands()const;
+ const std::vector& PFChargedHadrCands()const;
+ void setPFChargedHadrCands(const std::vector&);
+ const std::vector& PFNeutrHadrCands()const;
+ void setPFNeutrHadrCands(const std::vector&);
+ const std::vector& PFGammaCands()const;
+ void setPFGammaCands(const std::vector&);
//the reference to the PFJet
- const PFJetRef& pfjetRef()const;
- void setpfjetRef(const PFJetRef);
+ const JetBaseRef& pfjetRef()const;
+ void setpfjetRef(const JetBaseRef);
private:
- PFJetRef PFJetRef_;
- std::vector PFChargedHadrCands_;
- std::vector PFNeutrHadrCands_;
- std::vector PFGammaCands_;
+ JetBaseRef PFJetRef_;
+ std::vector PFChargedHadrCands_;
+ std::vector PFNeutrHadrCands_;
+ std::vector PFGammaCands_;
};
}
#endif
diff --git a/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc b/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc
index 898a4aa582b6e..be50d24d05472 100644
--- a/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc
+++ b/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc
@@ -39,7 +39,7 @@ PFRecoTauChargedHadron::PFRecoTauChargedHadron(const Candidate& c, PFRecoTauChar
PFRecoTauChargedHadron::~PFRecoTauChargedHadron()
{}
-const PFCandidatePtr& PFRecoTauChargedHadron::getChargedPFCandidate() const
+const CandidatePtr& PFRecoTauChargedHadron::getChargedPFCandidate() const
{
return chargedPFCandidate_;
}
@@ -49,7 +49,12 @@ const PFRecoTauChargedHadron::TrackPtr& PFRecoTauChargedHadron::getTrack() const
return track_;
}
-const std::vector& PFRecoTauChargedHadron::getNeutralPFCandidates() const
+const CandidatePtr& PFRecoTauChargedHadron::getLostTrackCandidate() const
+{
+ return lostTrackCandidate_;
+}
+
+const std::vector& PFRecoTauChargedHadron::getNeutralPFCandidates() const
{
return neutralPFCandidates_;
}
@@ -69,22 +74,6 @@ bool PFRecoTauChargedHadron::algoIs(PFRecoTauChargedHadron::PFRecoTauChargedHadr
return (algo_ == algo);
}
-namespace
-{
- std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType)
- {
- if ( pfCandidateType == reco::PFCandidate::X ) return "undefined";
- else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron";
- else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron";
- else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon";
- else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma";
- else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron";
- else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had";
- else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em";
- else assert(0);
- }
-}
-
void PFRecoTauChargedHadron::print(std::ostream& stream) const
{
stream << " Pt = " << this->pt() << ", eta = " << this->eta() << ", phi = " << this->phi() << " (mass = " << this->mass() << ")" << std::endl;
@@ -93,13 +82,16 @@ void PFRecoTauChargedHadron::print(std::ostream& stream) const
if ( chargedPFCandidate_.isNonnull() ) {
stream << " (" << chargedPFCandidate_.id() << ":" << chargedPFCandidate_.key() << "):"
<< " Pt = " << chargedPFCandidate_->pt() << ", eta = " << chargedPFCandidate_->eta() << ", phi = " << chargedPFCandidate_->phi()
- << " (type = " << getPFCandidateType(chargedPFCandidate_->particleId()) << ")" << std::endl;
+ << " (pdgId = " << chargedPFCandidate_->pdgId() << ")" << std::endl;
} else {
stream << ": N/A" << std::endl;
}
stream << "reco::Track: ";
if ( track_.isNonnull() ) {
stream << "Pt = " << track_->pt() << " +/- " << track_->ptError() << ", eta = " << track_->eta() << ", phi = " << track_->phi() << std::endl;
+ } else if ( lostTrackCandidate_.isNonnull() ) {
+ stream << "(lostTrackCandidate: " << lostTrackCandidate_.id() << ":" << lostTrackCandidate_.key() << "):"
+ << " Pt = " << lostTrackCandidate_->pt() << ", eta = " << lostTrackCandidate_->eta() << ", phi = " << lostTrackCandidate_->phi() << std::endl;
} else {
stream << "N/A" << std::endl;
}
@@ -107,11 +99,11 @@ void PFRecoTauChargedHadron::print(std::ostream& stream) const
if ( !neutralPFCandidates_.empty() ) {
stream << std::endl;
int idx = 0;
- for ( std::vector::const_iterator neutralPFCandidate = neutralPFCandidates_.begin();
+ for ( std::vector::const_iterator neutralPFCandidate = neutralPFCandidates_.begin();
neutralPFCandidate != neutralPFCandidates_.end(); ++neutralPFCandidate ) {
stream << " #" << idx << " (" << neutralPFCandidate->id() << ":" << neutralPFCandidate->key() << "):"
<< " Pt = " << (*neutralPFCandidate)->pt() << ", eta = " << (*neutralPFCandidate)->eta() << ", phi = " << (*neutralPFCandidate)->phi()
- << " (type = " << getPFCandidateType((*neutralPFCandidate)->particleId()) << ")" << std::endl;
+ << " (pdgId = " << (*neutralPFCandidate)->pdgId() << ")" << std::endl;
++idx;
}
} else {
diff --git a/DataFormats/TauReco/src/PFTau.cc b/DataFormats/TauReco/src/PFTau.cc
index 2beeec970273e..ddb1551d416c7 100644
--- a/DataFormats/TauReco/src/PFTau.cc
+++ b/DataFormats/TauReco/src/PFTau.cc
@@ -55,8 +55,8 @@ PFTau::PFTau(Charge q, const LorentzVector& p4, const Point& vtx)
PFTau* PFTau::clone() const { return new PFTau(*this); }
// Constituent getters and setters
-const PFJetRef& PFTau::jetRef() const { return jetRef_; }
-void PFTau::setjetRef(const PFJetRef& x) { jetRef_ = x; }
+const JetBaseRef& PFTau::jetRef() const { return jetRef_; }
+void PFTau::setjetRef(const JetBaseRef& x) { jetRef_ = x; }
const PFTauTagInfoRef& PFTau::pfTauTagInfoRef() const {
return PFTauTagInfoRef_;
@@ -64,34 +64,34 @@ const PFTauTagInfoRef& PFTau::pfTauTagInfoRef() const {
void PFTau::setpfTauTagInfoRef(const PFTauTagInfoRef x) { PFTauTagInfoRef_ = x; }
-const PFCandidatePtr& PFTau::leadPFChargedHadrCand() const { return leadPFChargedHadrCand_; }
-const PFCandidatePtr& PFTau::leadPFNeutralCand() const { return leadPFNeutralCand_; }
-const PFCandidatePtr& PFTau::leadPFCand() const { return leadPFCand_; }
+const CandidatePtr& PFTau::leadChargedHadrCand() const { return leadChargedHadrCand_; }
+const CandidatePtr& PFTau::leadNeutralCand() const { return leadNeutralCand_; }
+const CandidatePtr& PFTau::leadCand() const { return leadCand_; }
-void PFTau::setleadPFChargedHadrCand(const PFCandidatePtr& myLead) { leadPFChargedHadrCand_ = myLead;}
-void PFTau::setleadPFNeutralCand(const PFCandidatePtr& myLead) { leadPFNeutralCand_ = myLead;}
-void PFTau::setleadPFCand(const PFCandidatePtr& myLead) { leadPFCand_ = myLead;}
+void PFTau::setleadChargedHadrCand(const CandidatePtr& myLead) { leadChargedHadrCand_ = myLead;}
+void PFTau::setleadNeutralCand(const CandidatePtr& myLead) { leadNeutralCand_ = myLead;}
+void PFTau::setleadCand(const CandidatePtr& myLead) { leadCand_ = myLead;}
float PFTau::leadPFChargedHadrCandsignedSipt() const { return leadPFChargedHadrCandsignedSipt_; }
void PFTau::setleadPFChargedHadrCandsignedSipt(const float& x){ leadPFChargedHadrCandsignedSipt_ = x; }
-const std::vector& PFTau::signalPFCands() const { return selectedSignalPFCands_; }
-void PFTau::setsignalPFCands(const std::vector& myParts) { selectedSignalPFCands_ = myParts; }
-const std::vector& PFTau::signalPFChargedHadrCands() const { return selectedSignalPFChargedHadrCands_; }
-void PFTau::setsignalPFChargedHadrCands(const std::vector& myParts) { selectedSignalPFChargedHadrCands_ = myParts; }
-const std::vector& PFTau::signalPFNeutrHadrCands() const {return selectedSignalPFNeutrHadrCands_; }
-void PFTau::setsignalPFNeutrHadrCands(const std::vector& myParts) { selectedSignalPFNeutrHadrCands_ = myParts; }
-const std::vector& PFTau::signalPFGammaCands() const { return selectedSignalPFGammaCands_; }
-void PFTau::setsignalPFGammaCands(const std::vector& myParts) { selectedSignalPFGammaCands_ = myParts; }
-
-const std::vector& PFTau::isolationPFCands() const { return selectedIsolationPFCands_; }
-void PFTau::setisolationPFCands(const std::vector& myParts) { selectedIsolationPFCands_ = myParts;}
-const std::vector& PFTau::isolationPFChargedHadrCands() const { return selectedIsolationPFChargedHadrCands_; }
-void PFTau::setisolationPFChargedHadrCands(const std::vector& myParts) { selectedIsolationPFChargedHadrCands_ = myParts; }
-const std::vector& PFTau::isolationPFNeutrHadrCands() const { return selectedIsolationPFNeutrHadrCands_; }
-void PFTau::setisolationPFNeutrHadrCands(const std::vector& myParts) { selectedIsolationPFNeutrHadrCands_ = myParts; }
-const std::vector& PFTau::isolationPFGammaCands() const { return selectedIsolationPFGammaCands_; }
-void PFTau::setisolationPFGammaCands(const std::vector& myParts) { selectedIsolationPFGammaCands_ = myParts; }
+const std::vector& PFTau::signalCands() const { return selectedSignalCands_; }
+void PFTau::setsignalCands(const std::vector& myParts) { selectedSignalCands_ = myParts; }
+const std::vector& PFTau::signalChargedHadrCands() const { return selectedSignalChargedHadrCands_; }
+void PFTau::setsignalChargedHadrCands(const std::vector& myParts) { selectedSignalChargedHadrCands_ = myParts; }
+const std::vector& PFTau::signalNeutrHadrCands() const {return selectedSignalNeutrHadrCands_; }
+void PFTau::setsignalNeutrHadrCands(const std::vector& myParts) { selectedSignalNeutrHadrCands_ = myParts; }
+const std::vector& PFTau::signalGammaCands() const { return selectedSignalGammaCands_; }
+void PFTau::setsignalGammaCands(const std::vector& myParts) { selectedSignalGammaCands_ = myParts; }
+
+const std::vector& PFTau::isolationCands() const { return selectedIsolationCands_; }
+void PFTau::setisolationCands(const std::vector& myParts) { selectedIsolationCands_ = myParts;}
+const std::vector& PFTau::isolationChargedHadrCands() const { return selectedIsolationChargedHadrCands_; }
+void PFTau::setisolationChargedHadrCands(const std::vector& myParts) { selectedIsolationChargedHadrCands_ = myParts; }
+const std::vector& PFTau::isolationNeutrHadrCands() const { return selectedIsolationNeutrHadrCands_; }
+void PFTau::setisolationNeutrHadrCands(const std::vector& myParts) { selectedIsolationNeutrHadrCands_ = myParts; }
+const std::vector& PFTau::isolationGammaCands() const { return selectedIsolationGammaCands_; }
+void PFTau::setisolationGammaCands(const std::vector& myParts) { selectedIsolationGammaCands_ = myParts; }
namespace {
@@ -121,8 +121,111 @@ namespace {
oCache.reset();
oCache.set( std::make_unique(std::move(iFrom)));
}
+
+ std::unique_ptr convertToPFPtr(const reco::CandidatePtr& ptr) {
+ if (ptr.isNonnull()) {
+ const reco::PFCandidate* pf_cand = dynamic_cast(&*ptr);
+ if (pf_cand != nullptr) {
+ return std::unique_ptr(new reco::PFCandidatePtr(ptr));
+ } else throw cms::Exception("Type Mismatch") << "This PFTau was not made from PFCandidates, but it is being tried to access a PFCandidate.\n";
+ }
+ return std::unique_ptr(new reco::PFCandidatePtr());
+ }
+
+ std::unique_ptr > convertToPFPtrs(const std::vector& cands) {
+ std::unique_ptr > newSignalPFCands{new std::vector{}};
+ bool isPF = false;
+ for (auto& cand : cands) {
+ // Check for first Candidate if it is a PFCandidate; if yes, skip for the rest
+ if (!isPF) {
+ const reco::PFCandidate* pf_cand = dynamic_cast(&*cand);
+ if (pf_cand != nullptr) {
+ isPF = true;
+ newSignalPFCands->reserve(cands.size());
+ } else throw cms::Exception("Type Mismatch") << "This PFTau was not made from PFCandidates, but it is being tried to access PFCandidates.\n";
+ }
+ const auto& newPtr = edm::Ptr(cand);
+ newSignalPFCands->push_back(newPtr);
+ }
+ return newSignalPFCands;
+ }
+}
+
+const PFCandidatePtr PFTau::leadPFChargedHadrCand() const {
+ if (!leadPFChargedHadrCand_.isSet())
+ leadPFChargedHadrCand_.set(convertToPFPtr(leadChargedHadrCand_));
+ return *leadPFChargedHadrCand_;
+}
+
+const PFCandidatePtr PFTau::leadPFNeutralCand() const {
+ if (!leadPFNeutralCand_.isSet())
+ leadPFNeutralCand_.set(convertToPFPtr(leadNeutralCand_));
+ return *leadPFNeutralCand_;
+}
+
+const PFCandidatePtr PFTau::leadPFCand() const {
+ if (!leadPFCand_.isSet())
+ leadPFCand_.set(convertToPFPtr(leadCand_));
+ return *leadPFCand_;
+}
+
+const std::vector& PFTau::signalPFCands() const {
+ if (!selectedTransientSignalPFCands_.isSet()) {
+ selectedTransientSignalPFCands_.set(convertToPFPtrs(selectedSignalCands_));
+ }
+ return *selectedTransientSignalPFCands_;
}
+const std::vector& PFTau::signalPFChargedHadrCands() const {
+ if (!selectedTransientSignalPFChargedHadrCands_.isSet()) {
+ selectedTransientSignalPFChargedHadrCands_.set(convertToPFPtrs(selectedSignalChargedHadrCands_));
+ }
+ return *selectedTransientSignalPFChargedHadrCands_;
+}
+
+const std::vector& PFTau::signalPFNeutrHadrCands() const {
+ if (!selectedTransientSignalPFNeutrHadrCands_.isSet()) {
+ selectedTransientSignalPFNeutrHadrCands_.set(convertToPFPtrs(selectedSignalNeutrHadrCands_));
+ }
+ return *selectedTransientSignalPFNeutrHadrCands_;
+}
+
+const std::vector& PFTau::signalPFGammaCands() const {
+ if (!selectedTransientSignalPFGammaCands_.isSet()) {
+ selectedTransientSignalPFGammaCands_.set(convertToPFPtrs(selectedSignalGammaCands_));
+ }
+ return *selectedTransientSignalPFGammaCands_;
+}
+
+const std::vector& PFTau::isolationPFCands() const {
+ if (!selectedTransientIsolationPFCands_.isSet()) {
+ selectedTransientIsolationPFCands_.set(convertToPFPtrs(selectedIsolationCands_));
+ }
+ return *selectedTransientIsolationPFCands_;
+}
+
+const std::vector& PFTau::isolationPFChargedHadrCands() const {
+ if (!selectedTransientIsolationPFChargedHadrCands_.isSet()) {
+ selectedTransientIsolationPFChargedHadrCands_.set(convertToPFPtrs(selectedIsolationChargedHadrCands_));
+ }
+ return *selectedTransientIsolationPFChargedHadrCands_;
+}
+
+const std::vector& PFTau::isolationPFNeutrHadrCands() const {
+ if (!selectedTransientIsolationPFNeutrHadrCands_.isSet()) {
+ selectedTransientIsolationPFNeutrHadrCands_.set(convertToPFPtrs(selectedIsolationNeutrHadrCands_));
+ }
+ return *selectedTransientIsolationPFNeutrHadrCands_;
+}
+
+const std::vector& PFTau::isolationPFGammaCands() const {
+ if (!selectedTransientIsolationPFGammaCands_.isSet()) {
+ selectedTransientIsolationPFGammaCands_.set(convertToPFPtrs(selectedIsolationGammaCands_));
+ }
+ return *selectedTransientIsolationPFGammaCands_;
+}
+
+
// PiZero and decay mode information
const std::vector& PFTau::signalPiZeroCandidates() const {
// Check if the signal pi zeros are already filled
@@ -246,11 +349,14 @@ void PFTau::setelectronPreIDDecision(const bool& x) {electronPreIDDecision_ = x;
// Muon variables
bool PFTau::hasMuonReference() const { // check if muon ref exists
- if( leadPFChargedHadrCand_.isNull() ) return false;
- else if( leadPFChargedHadrCand_.isNonnull() ){
- reco::MuonRef muonRef = leadPFChargedHadrCand_->muonRef();
- if( muonRef.isNull() ) return false;
- else if( muonRef.isNonnull() ) return true;
+ if( leadChargedHadrCand_.isNull() ) return false;
+ else if( leadChargedHadrCand_.isNonnull() ){
+ const reco::PFCandidate* pf_cand = dynamic_cast(&*leadChargedHadrCand_);
+ if (pf_cand) {
+ reco::MuonRef muonRef = pf_cand->muonRef();
+ if( muonRef.isNull() ) return false;
+ else if( muonRef.isNonnull() ) return true;
+ }
}
return false;
}
@@ -264,7 +370,7 @@ void PFTau::setMuonDecision(const bool& x) {muonDecision_ = x;}
CandidatePtr PFTau::sourceCandidatePtr( size_type i ) const {
if ( i!=0 ) return CandidatePtr();
- return refToPtr(jetRef());
+ return jetRef().castTo();
}
@@ -284,31 +390,23 @@ void PFTau::dump(std::ostream& out) const {
out<<"# PF neutral hadr. cand's "<PFNeutrHadrCands().size()<PFGammaCands().size()<chargedHadronMultiplicity()<neutralHadronMultiplicity()<photonMultiplicity()<electronMultiplicity()< PFTauTagInfo::PFCands()const{
- std::vector thePFCands;
- for (std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++) thePFCands.push_back(*iPFCand);
- for (std::vector::const_iterator iPFCand=PFNeutrHadrCands_.begin();iPFCand!=PFNeutrHadrCands_.end();iPFCand++) thePFCands.push_back(*iPFCand);
- for (std::vector::const_iterator iPFCand=PFGammaCands_.begin();iPFCand!=PFGammaCands_.end();iPFCand++) thePFCands.push_back(*iPFCand);
+std::vector PFTauTagInfo::PFCands()const{
+ std::vector thePFCands;
+ for (std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++) thePFCands.push_back(*iPFCand);
+ for (std::vector::const_iterator iPFCand=PFNeutrHadrCands_.begin();iPFCand!=PFNeutrHadrCands_.end();iPFCand++) thePFCands.push_back(*iPFCand);
+ for (std::vector::const_iterator iPFCand=PFGammaCands_.begin();iPFCand!=PFGammaCands_.end();iPFCand++) thePFCands.push_back(*iPFCand);
return thePFCands;
}
-const std::vector& PFTauTagInfo::PFChargedHadrCands() const {return PFChargedHadrCands_;}
-void PFTauTagInfo::setPFChargedHadrCands(const std::vector& x){PFChargedHadrCands_=x;}
-const std::vector& PFTauTagInfo::PFNeutrHadrCands() const {return PFNeutrHadrCands_;}
-void PFTauTagInfo::setPFNeutrHadrCands(const std::vector& x){PFNeutrHadrCands_=x;}
-const std::vector& PFTauTagInfo::PFGammaCands() const {return PFGammaCands_;}
-void PFTauTagInfo::setPFGammaCands(const std::vector& x){PFGammaCands_=x;}
+const std::vector& PFTauTagInfo::PFChargedHadrCands() const {return PFChargedHadrCands_;}
+void PFTauTagInfo::setPFChargedHadrCands(const std::vector& x){PFChargedHadrCands_=x;}
+const std::vector& PFTauTagInfo::PFNeutrHadrCands() const {return PFNeutrHadrCands_;}
+void PFTauTagInfo::setPFNeutrHadrCands(const std::vector& x){PFNeutrHadrCands_=x;}
+const std::vector& PFTauTagInfo::PFGammaCands() const {return PFGammaCands_;}
+void PFTauTagInfo::setPFGammaCands(const std::vector& x){PFGammaCands_=x;}
-const PFJetRef& PFTauTagInfo::pfjetRef()const{return PFJetRef_;}
-void PFTauTagInfo::setpfjetRef(const PFJetRef x){PFJetRef_=x;}
+const JetBaseRef& PFTauTagInfo::pfjetRef()const{return PFJetRef_;}
+void PFTauTagInfo::setpfjetRef(const JetBaseRef x){PFJetRef_=x;}
diff --git a/DataFormats/TauReco/src/classes_3.h b/DataFormats/TauReco/src/classes_3.h
index 3461669048c91..51e5510aa9839 100644
--- a/DataFormats/TauReco/src/classes_3.h
+++ b/DataFormats/TauReco/src/classes_3.h
@@ -31,8 +31,11 @@
#include "DataFormats/TauReco/interface/PFTau3ProngSummaryFwd.h"
#include "DataFormats/TauReco/interface/PFTau3ProngSummaryAssociation.h"
#include "DataFormats/JetReco/interface/PFJet.h"
+#include "DataFormats/JetReco/interface/Jet.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
+#include "DataFormats/PatCandidates/interface/Jet.h"
+#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
#include
#include