16 bool copyGammasFromPiZeros,
54 LogDebug(
"TauConstructorAddPFCand") <<
" region = " <<
region <<
", type = " <<
type <<
": Pt = " << ptr->pt()
55 <<
", eta = " << ptr->eta() <<
", phi = " << ptr->phi();
60 LogDebug(
"TauConstructorAddPFCand") <<
"--> adding PFCand to tauP4.";
79 tau_->signalTauChargedHadronCandidatesRestricted().reserve(
size);
80 tau_->selectedSignalChargedHadrCands_.reserve(
size);
82 tau_->isolationTauChargedHadronCandidatesRestricted().reserve(
size);
83 tau_->selectedIsolationChargedHadrCands_.reserve(
size);
89 LogDebug(
"TauConstructorCheckOverlap") <<
" pfGammas: #entries = " <<
pfGammas.size();
92 if ((*pfGamma).refCore() == neutral.
refCore() && (*pfGamma).key() == neutral.
key())
98 LogDebug(
"TauConstructorCheckOverlap") <<
" piZeros: #entries = " << piZeros.size();
99 for (std::vector<reco::RecoTauPiZero>::const_iterator piZero = piZeros.begin(); piZero != piZeros.end();
101 size_t numPFGammas = piZero->numberOfDaughters();
102 for (
size_t iPFGamma = 0; iPFGamma < numPFGammas; ++iPFGamma) {
105 if (
pfGamma.id() == neutral.id() &&
pfGamma.key() == neutral.key())
116 const std::vector<CandidatePtr>& neutrals =
chargedHadron.getNeutralPFCandidates();
117 std::vector<CandidatePtr> neutrals_cleaned;
118 for (std::vector<CandidatePtr>::const_iterator neutral = neutrals.begin(); neutral != neutrals.end(); ++neutral) {
119 LogDebug(
"TauConstructorAddChH") <<
"neutral = " << neutral->id() <<
":" << neutral->key();
120 bool isUnique =
true;
129 checkOverlap(*neutral,
tau_->isolationPiZeroCandidatesRestricted(), isUnique);
131 LogDebug(
"TauConstructorAddChH") <<
"--> isUnique = " << isUnique;
133 neutrals_cleaned.push_back(*neutral);
136 if (neutrals_cleaned.size() != neutrals.size()) {
141 tau_->signalTauChargedHadronCandidatesRestricted().push_back(chargedHadron_cleaned);
142 p4_ += chargedHadron_cleaned.
p4();
147 for (std::vector<CandidatePtr>::const_iterator neutral = neutrals.begin(); neutral != neutrals.end(); ++neutral) {
148 if (
std::abs((*neutral)->pdgId()) == 22)
150 else if (
std::abs((*neutral)->pdgId()) == 130)
154 tau_->isolationTauChargedHadronCandidatesRestricted().push_back(chargedHadron_cleaned);
162 for (std::vector<CandidatePtr>::const_iterator neutral = neutrals.begin(); neutral != neutrals.end(); ++neutral) {
163 if (
std::abs((*neutral)->pdgId()) == 22)
165 else if (
std::abs((*neutral)->pdgId()) == 130)
173 tau_->signalPiZeroCandidatesRestricted().reserve(
size);
179 tau_->isolationPiZeroCandidatesRestricted().reserve(
size);
186 LogDebug(
"TauConstructorAddPi0") <<
" region = " <<
region <<
": Pt = " << piZero.
pt() <<
", eta = " << piZero.
eta()
187 <<
", phi = " << piZero.
phi();
189 tau_->signalPiZeroCandidatesRestricted().push_back(piZero);
198 tau_->isolationPiZeroCandidatesRestricted().push_back(piZero);
218 template <
typename T1,
typename T2>
219 void checkMatchedProductIds(
const T1&
t1,
const T2&
t2) {
220 if (
t1.id() !=
t2.id()) {
222 <<
"Error: the input tag"
223 <<
" for the PF candidate collection provided to the RecoTauBuilder "
224 <<
" does not match the one that was used to build the source jets."
225 <<
" Please update the pfCandSrc paramters for the PFTau builders.";
233 checkMatchedProductIds(candPtr,
pfCands_);
240 template <
typename T>
241 bool ptDescending(
const T&
a,
const T&
b) {
242 return a.pt() >
b.pt();
244 template <
typename T>
245 bool ptDescendingPtr(
const T&
a,
const T&
b) {
246 return a->pt() >
b->pt();
252 std::sort(
tau_->signalTauChargedHadronCandidatesRestricted().begin(),
253 tau_->signalTauChargedHadronCandidatesRestricted().end(),
254 ptDescending<PFRecoTauChargedHadron>);
255 std::sort(
tau_->isolationTauChargedHadronCandidatesRestricted().begin(),
256 tau_->isolationTauChargedHadronCandidatesRestricted().end(),
257 ptDescending<PFRecoTauChargedHadron>);
258 std::sort(
tau_->signalPiZeroCandidatesRestricted().begin(),
259 tau_->signalPiZeroCandidatesRestricted().end(),
260 ptDescending<RecoTauPiZero>);
261 std::sort(
tau_->isolationPiZeroCandidatesRestricted().begin(),
262 tau_->isolationPiZeroCandidatesRestricted().end(),
263 ptDescending<RecoTauPiZero>);
269 std::sort(sortedCollection->begin(), sortedCollection->end(), ptDescendingPtr<CandidatePtr>);
271 for (std::vector<CandidatePtr>::const_iterator particle = sortedCollection->begin();
272 particle != sortedCollection->end();
274 colkey.second->push_back(*particle);
286 unsigned int nCharged =
tau.signalTauChargedHadronCandidates().size();
292 const std::vector<RecoTauPiZero>& piZeros =
tau.signalPiZeroCandidates();
293 for (std::vector<RecoTauPiZero>::const_iterator piZero = piZeros.begin(); piZero != piZeros.end(); ++piZero) {
294 double photonSumPt_insideSignalCone = 0.;
295 double photonSumPt_outsideSignalCone = 0.;
296 int numPhotons = piZero->numberOfDaughters();
297 for (
int idxPhoton = 0; idxPhoton < numPhotons; ++idxPhoton) {
300 if (
dR < dRsignalCone) {
301 photonSumPt_insideSignalCone +=
photon->pt();
303 photonSumPt_outsideSignalCone +=
photon->pt();
325 return static_cast<PFTau::hadronicDecayMode>(trackIndex +
nPiZeros);
330 LogDebug(
"TauConstructorGet") <<
"Start getting";
345 double leadChargedHadronPt = 0.;
346 int leadChargedHadronCharge = 0;
347 for (std::vector<PFRecoTauChargedHadron>::const_iterator
chargedHadron =
348 tau_->signalTauChargedHadronCandidatesRestricted().begin();
364 tau_->setCharge(leadChargedHadronCharge);
367 tau_->setPdgId(
tau_->charge() < 0 ? 15 : -15);
374 tau_->setSignalConeSize(dRsignalCone);
383 LogDebug(
"TauConstructorGet") <<
"Pt = " <<
tau_->pt() <<
", eta = " <<
tau_->eta() <<
", phi = " <<
tau_->phi()
384 <<
", mass = " <<
tau_->mass() <<
", dm = " <<
tau_->decayMode();
391 tau_->setisolationPFGammaCandsEtSum(
398 if (setupLeadingObjects) {
399 typedef std::vector<CandidatePtr>::const_iterator Iter;
404 tau_->setleadCand(*leadingCand);
407 Iter leadingChargedCand =
411 tau_->setleadChargedHadrCand(*leadingChargedCand);
417 tau_->setleadNeutralCand(*leadingGammaCand);