17 bool copyGammasFromPiZeros,
30 tau_ = std::make_unique<PFTau>();
55 LogDebug(
"TauConstructorAddPFCand") <<
" region = " <<
region <<
", type = " <<
type <<
": Pt = " << ptr->pt()
56 <<
", eta = " << ptr->eta() <<
", phi = " << ptr->phi();
61 LogDebug(
"TauConstructorAddPFCand") <<
"--> adding PFCand to tauP4.";
80 tau_->signalTauChargedHadronCandidatesRestricted().reserve(size);
81 tau_->selectedSignalChargedHadrCands_.reserve(size);
83 tau_->isolationTauChargedHadronCandidatesRestricted().reserve(size);
84 tau_->selectedIsolationChargedHadrCands_.reserve(size);
90 LogDebug(
"TauConstructorCheckOverlap") <<
" pfGammas: #entries = " <<
pfGammas.size();
93 if ((*pfGamma).refCore() == neutral.
refCore() && (*pfGamma).key() == neutral.
key())
99 LogDebug(
"TauConstructorCheckOverlap") <<
" piZeros: #entries = " << piZeros.size();
100 for (std::vector<reco::RecoTauPiZero>::const_iterator piZero = piZeros.begin(); piZero != piZeros.end();
102 size_t numPFGammas = piZero->numberOfDaughters();
103 for (
size_t iPFGamma = 0; iPFGamma < numPFGammas; ++iPFGamma) {
106 if (
pfGamma.id() == neutral.id() &&
pfGamma.key() == neutral.key())
117 const std::vector<CandidatePtr>& neutrals =
chargedHadron.getNeutralPFCandidates();
118 std::vector<CandidatePtr> neutrals_cleaned;
119 for (std::vector<CandidatePtr>::const_iterator neutral = neutrals.begin(); neutral != neutrals.end(); ++neutral) {
120 LogDebug(
"TauConstructorAddChH") <<
"neutral = " << neutral->id() <<
":" << neutral->key();
121 bool isUnique =
true;
130 checkOverlap(*neutral,
tau_->isolationPiZeroCandidatesRestricted(), isUnique);
132 LogDebug(
"TauConstructorAddChH") <<
"--> isUnique = " << isUnique;
134 neutrals_cleaned.push_back(*neutral);
137 if (neutrals_cleaned.size() != neutrals.size()) {
142 tau_->signalTauChargedHadronCandidatesRestricted().push_back(chargedHadron_cleaned);
143 p4_ += chargedHadron_cleaned.
p4();
148 for (std::vector<CandidatePtr>::const_iterator neutral = neutrals.begin(); neutral != neutrals.end(); ++neutral) {
149 if (
std::abs((*neutral)->pdgId()) == 22)
151 else if (
std::abs((*neutral)->pdgId()) == 130)
155 tau_->isolationTauChargedHadronCandidatesRestricted().push_back(chargedHadron_cleaned);
163 for (std::vector<CandidatePtr>::const_iterator neutral = neutrals.begin(); neutral != neutrals.end(); ++neutral) {
164 if (
std::abs((*neutral)->pdgId()) == 22)
166 else if (
std::abs((*neutral)->pdgId()) == 130)
174 tau_->signalPiZeroCandidatesRestricted().reserve(size);
180 tau_->isolationPiZeroCandidatesRestricted().reserve(size);
187 LogDebug(
"TauConstructorAddPi0") <<
" region = " <<
region <<
": Pt = " << piZero.
pt() <<
", eta = " << piZero.
eta()
188 <<
", phi = " << piZero.
phi();
190 tau_->signalPiZeroCandidatesRestricted().push_back(piZero);
199 tau_->isolationPiZeroCandidatesRestricted().push_back(piZero);
219 template <
typename T1,
typename T2>
220 void checkMatchedProductIds(
const T1&
t1,
const T2&
t2) {
221 if (
t1.id() !=
t2.id()) {
223 <<
"Error: the input tag" 224 <<
" for the PF candidate collection provided to the RecoTauBuilder " 225 <<
" does not match the one that was used to build the source jets." 226 <<
" Please update the pfCandSrc paramters for the PFTau builders.";
234 checkMatchedProductIds(candPtr,
pfCands_);
241 template <
typename T>
242 bool ptDescending(
const T&
a,
const T&
b) {
243 return a.pt() >
b.pt();
245 template <
typename T>
246 bool ptDescendingPtr(
const T&
a,
const T&
b) {
247 return a->pt() >
b->pt();
253 std::sort(
tau_->signalTauChargedHadronCandidatesRestricted().begin(),
254 tau_->signalTauChargedHadronCandidatesRestricted().end(),
255 ptDescending<PFRecoTauChargedHadron>);
256 std::sort(
tau_->isolationTauChargedHadronCandidatesRestricted().begin(),
257 tau_->isolationTauChargedHadronCandidatesRestricted().end(),
258 ptDescending<PFRecoTauChargedHadron>);
260 tau_->signalPiZeroCandidatesRestricted().end(),
261 ptDescending<RecoTauPiZero>);
262 std::sort(
tau_->isolationPiZeroCandidatesRestricted().begin(),
263 tau_->isolationPiZeroCandidatesRestricted().end(),
264 ptDescending<RecoTauPiZero>);
270 std::sort(sortedCollection->begin(), sortedCollection->end(), ptDescendingPtr<CandidatePtr>);
272 for (std::vector<CandidatePtr>::const_iterator particle = sortedCollection->begin();
273 particle != sortedCollection->end();
275 colkey.second->push_back(*particle);
287 unsigned int nCharged =
tau.signalTauChargedHadronCandidates().size();
293 const std::vector<RecoTauPiZero>& piZeros =
tau.signalPiZeroCandidates();
294 for (std::vector<RecoTauPiZero>::const_iterator piZero = piZeros.begin(); piZero != piZeros.end(); ++piZero) {
295 double photonSumPt_insideSignalCone = 0.;
296 double photonSumPt_outsideSignalCone = 0.;
297 int numPhotons = piZero->numberOfDaughters();
298 for (
int idxPhoton = 0; idxPhoton < numPhotons; ++idxPhoton) {
301 if (
dR < dRsignalCone) {
302 photonSumPt_insideSignalCone +=
photon->pt();
304 photonSumPt_outsideSignalCone +=
photon->pt();
331 LogDebug(
"TauConstructorGet") <<
"Start getting";
346 double leadChargedHadronPt = 0.;
347 int leadChargedHadronCharge = 0;
348 for (std::vector<PFRecoTauChargedHadron>::const_iterator
chargedHadron =
349 tau_->signalTauChargedHadronCandidatesRestricted().begin();
365 tau_->setCharge(leadChargedHadronCharge);
368 tau_->setPdgId(
tau_->charge() < 0 ? 15 : -15);
375 tau_->setSignalConeSize(dRsignalCone);
384 LogDebug(
"TauConstructorGet") <<
"Pt = " <<
tau_->pt() <<
", eta = " <<
tau_->eta() <<
", phi = " <<
tau_->phi()
385 <<
", mass = " <<
tau_->mass() <<
", dm = " <<
tau_->decayMode();
392 tau_->setisolationPFGammaCandsEtSum(
399 if (setupLeadingObjects) {
400 typedef std::vector<CandidatePtr>::const_iterator Iter;
405 tau_->setleadCand(*leadingCand);
408 Iter leadingChargedCand =
412 tau_->setleadChargedHadrCand(*leadingChargedCand);
418 tau_->setleadNeutralCand(*leadingGammaCand);
void addPFCand(Region region, ParticleType type, const CandidatePtr &ptr, bool skipAddToP4=false)
Append a PFCandidateRef/Ptr to a given collection.
void addTauChargedHadron(Region region, const PFRecoTauChargedHadron &chargedHadron)
Add a ChargedHadron to the given collection.
double minRelPhotonSumPt_outsideSignalCone_
reco::Candidate::LorentzVector p4_
CollectionMap collections_
void reserve(Region region, ParticleType type, size_t size)
Reserve a set amount of space for a given RefVector.
double pt() const final
transverse momentum
double sumPFCandPt(InputIterator begin, InputIterator end)
Sum the pT of a collection of PFCandidates.
minAbsPhotonSumPt_outsideSignalCone
minAbsPhotonSumPt_insideSignalCone
std::vector< CandidatePtr > * getCollection(Region region, ParticleType type)
std::unique_ptr< reco::PFTau > tau_
virtual const daughters & daughterPtrVector() const
references to daughtes
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float charge(ConstView const &tracks, int32_t i)
std::unique_ptr< reco::PFTau > get(bool setupLeadingCandidates=true)
InputIterator leadCand(InputIterator begin, InputIterator end)
const LorentzVector & p4() const final
four-momentum Lorentz vector
const edm::Handle< edm::View< reco::Candidate > > & pfCands_
SortedCollectionMap sortedCollections_
minRelPhotonSumPt_outsideSignalCone
SortedListPtr getSortedCollection(Region region, ParticleType type)
bool isNonnull() const
Checks for non-null.
Abs< T >::type abs(const T &t)
std::vector< CandidatePtr > neutralPFCandidates_
const CandidatePtr & getChargedPFCandidate() const
reference to "charged" PFCandidate (either charged PFCandidate or PFNeutralHadron) ...
void addPFCands(Region region, ParticleType type, const InputIterator &begin, const InputIterator &end)
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double minAbsPhotonSumPt_outsideSignalCone_
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
RecoTauConstructor(const JetBaseRef &jetRef, const edm::Handle< edm::View< reco::Candidate > > &pfCands, bool copyGammasFromPiZeros=false, const StringObjectFunction< reco::PFTau > *signalConeSize=nullptr, double minAbsPhotonSumPt_insideSignalCone=2.5, double minRelPhotonSumPt_insideSignalCone=0., double minAbsPhotonSumPt_outsideSignalCone=1.e+9, double minRelPhotonSumPt_outsideSignalCone=1.e+9)
Constructor with PFCandidate Handle.
void reserveTauChargedHadron(Region region, size_t size)
Reserve a set amount of space for the ChargedHadrons.
void reservePiZero(Region region, size_t size)
Reserve a set amount of space for the PiZeros.
double minRelPhotonSumPt_insideSignalCone_
std::shared_ptr< std::vector< CandidatePtr > > SortedListPtr
def checkOverlap(process)
RefCore const & refCore() const
CandidatePtr convertToPtr(const PFCandidatePtr &pfPtr) const
const std::vector< CandidatePtr > & getNeutralPFCandidates() const
references to additional neutral PFCandidates
void sortAndCopyIntoTau()
void addPiZero(Region region, const RecoTauPiZero &piZero)
Add a PiZero to the given collection.
const StringObjectFunction< reco::PFTau > * signalConeSize_
double minAbsPhotonSumPt_insideSignalCone_
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
double phi() const final
momentum azimuthal angle
edm::Ptr< PFCandidate > PFCandidatePtr
persistent Ptr to a PFCandidate
minRelPhotonSumPt_insideSignalCone
std::vector< CandidatePtr > pfGammas(const Jet &jet, bool sort=true)
Extract all pfGammas from a PFJet.
double eta() const final
momentum pseudorapidity