35 const std::vector<reco::PFRecoTauChargedHadron>&,
36 const std::vector<RecoTauPiZero>&,
37 const std::vector<CandidatePtr>&)
const override;
40 std::unique_ptr<RecoTauQualityCuts>
qcuts_;
65 isolationConeSize_(
pset.getParameter<double>(
"isolationConeSize")),
66 signalConeSize_(
pset.getParameter<
std::
string>(
"signalConeSize")),
67 minAbsPhotonSumPt_insideSignalCone_(
pset.getParameter<double>(
"minAbsPhotonSumPt_insideSignalCone")),
68 minRelPhotonSumPt_insideSignalCone_(
pset.getParameter<double>(
"minRelPhotonSumPt_insideSignalCone")),
69 minAbsPhotonSumPt_outsideSignalCone_(
pset.getParameter<double>(
"minAbsPhotonSumPt_outsideSignalCone")),
70 minRelPhotonSumPt_outsideSignalCone_(
pset.getParameter<double>(
"minRelPhotonSumPt_outsideSignalCone")) {
71 typedef std::vector<edm::ParameterSet>
VPSet;
75 info.nCharged_ =
decayMode->getParameter<uint32_t>(
"nCharged");
76 info.nPiZeros_ =
decayMode->getParameter<uint32_t>(
"nPiZeros");
77 info.maxPFCHs_ =
decayMode->getParameter<uint32_t>(
"maxTracks");
78 info.maxPiZeros_ =
decayMode->getParameter<uint32_t>(
"maxPiZeros");
98 if (mode_ == kRemoveChargedDaughterOverlaps) {
101 }
else if (mode_ == kRemoveChargedAndNeutralDaughterOverlaps) {
103 for (reco::CompositePtrCandidate::daughters::const_iterator daughter =
daughters.begin();
115 const PiZeroList::const_iterator& piZerosEnd) {
116 for (
auto const& ptr :
flattenPiZeros(piZerosBegin, piZerosEnd)) {
129 for (reco::CompositePtrCandidate::daughters::const_iterator daughter =
daughters.begin();
140 const ChargedHadronList::const_iterator& chargedHadronsBegin,
141 const ChargedHadronList::const_iterator& chargedHadronsEnd) {
146 for (reco::CompositePtrCandidate::daughters::const_iterator daughter =
daughters.begin();
158 class SortPi0sDescendingPt {
163 double square(
double x) {
return x *
x; }
168 const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons,
169 const std::vector<RecoTauPiZero>& piZeros,
170 const std::vector<CandidatePtr>& regionalExtras)
const {
172 std::cout <<
"<RecoTauBuilderCombinatoricPlugin::operator()>:" << std::endl;
173 std::cout <<
" processing jet: Pt = " <<
jet->pt() <<
", eta = " <<
jet->eta() <<
", phi = " <<
jet->eta()
175 <<
" mass = " <<
jet->mass() <<
", area = " <<
jet->jetArea() << std::endl;
185 typedef std::vector<CandidatePtr>
CandPtrs;
188 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
190 for (ChargedHadronList::const_iterator
chargedHadron = chargedHadrons.begin();
193 std::cout <<
"chargedHadron #" <<
idx <<
":" << std::endl;
197 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
199 for (PiZeroList::const_iterator piZero = piZeros.begin(); piZero != piZeros.end(); ++piZero) {
219 size_t piZerosToBuild =
decayMode->nPiZeros_;
221 size_t tracksToBuild =
decayMode->nCharged_;
223 std::cout <<
"piZerosToBuild = " << piZerosToBuild << std::endl;
224 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
225 std::cout <<
"tracksToBuild = " << tracksToBuild << std::endl;
226 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
230 if (chargedHadrons.size() < tracksToBuild)
234 ChargedHadronList::const_iterator chargedHadron_begin = chargedHadrons.begin();
235 ChargedHadronList::const_iterator chargedHadron_end = chargedHadrons.end();
239 ChargedHadronCombo trackCombos(chargedHadron_begin, chargedHadron_end, tracksToBuild);
241 CandPtrs::iterator pfch_end = pfchs.end();
252 trackCombo->combo_begin(),
253 trackCombo->combo_end(),
256 PiZeroList cleanSignalPiZeros = signalPiZeroXCleaner(piZeros);
259 std::sort(cleanSignalPiZeros.begin(), cleanSignalPiZeros.end(), SortPi0sDescendingPt());
263 if (cleanSignalPiZeros.size() < piZerosToBuild)
267 PiZeroList::iterator signalPiZero_begin = cleanSignalPiZeros.begin();
268 PiZeroList::iterator signalPiZero_end = cleanSignalPiZeros.end();
272 PiZeroCombo piZeroCombos(signalPiZero_begin, signalPiZero_end, piZerosToBuild);
291 trackCombo->combo_begin(),
292 trackCombo->combo_end(),
295 PiZeroList precleanedIsolationPiZeros = isolationPiZeroXCleaner(piZeros);
296 std::set<reco::CandidatePtr> toRemove;
298 signalPiZero != piZeroCombo->combo_end();
300 toRemove.insert(signalPiZero->daughterPtrVector().begin(), signalPiZero->daughterPtrVector().end());
303 for (
auto const& precleanedPiZero : precleanedIsolationPiZeros) {
304 std::set<reco::CandidatePtr> toCheck(precleanedPiZero.daughterPtrVector().begin(),
305 precleanedPiZero.daughterPtrVector().end());
306 std::vector<reco::CandidatePtr> cleanDaughters;
308 toCheck.begin(), toCheck.end(), toRemove.begin(), toRemove.end(), std::back_inserter(cleanDaughters));
310 if (cleanDaughters.size() == precleanedPiZero.daughterPtrVector().size()) {
311 cleanIsolationPiZeros.push_back(precleanedPiZero);
315 std::cout <<
"#cleanIsolationPiZeros = " << cleanIsolationPiZeros.size() << std::endl;
317 for (PiZeroList::const_iterator piZero = cleanIsolationPiZeros.begin();
318 piZero != cleanIsolationPiZeros.end();
330 chargedHadrons.size() - tracksToBuild);
356 pfChargedHadronXCleanerType pfChargedHadronXCleaner_comboChargedHadrons(trackCombo->combo_begin(),
357 trackCombo->combo_end());
360 isolationConeFilter, pfChargedHadronXCleaner_comboChargedHadrons);
363 chargedHadrons.begin(), chargedHadrons.end());
368 pfCandXCleanerType pfCandXCleaner_allChargedHadrons(pfChargedHadronXCleaner_allChargedHadrons,
372 isolationConeFilter, pfCandXCleaner_allChargedHadrons);
385 RegionalJunkConeAndIdFilter pfChargedJunk(pfchCandSelector,
386 isolationConeFilter);
388 RegionalJunkConeAndIdFilter pfGammaJunk(pfgammaCandSelector,
389 isolationConeFilter);
391 RegionalJunkConeAndIdFilter pfNeutralJunk(pfnhCandSelector,
392 isolationConeFilter);
395 boost::make_filter_iterator(
396 isolationConeFilterPiZero, cleanIsolationPiZeros.begin(), cleanIsolationPiZeros.end()),
397 boost::make_filter_iterator(
398 isolationConeFilterPiZero, cleanIsolationPiZeros.end(), cleanIsolationPiZeros.end()));
406 std::cout <<
"adding isolation PFChargedHadrons from trackCombo:" << std::endl;
408 tau.addTauChargedHadrons(
410 boost::make_filter_iterator(
411 isolationConeFilterChargedHadron, trackCombo->remainder_begin(), trackCombo->remainder_end()),
412 boost::make_filter_iterator(
413 isolationConeFilterChargedHadron, trackCombo->remainder_end(), trackCombo->remainder_end()));
418 std::cout <<
"adding isolation PFChargedHadrons not considered in trackCombo:" << std::endl;
422 boost::make_filter_iterator(pfCandFilter_comboChargedHadrons, pfch_end, pfchs.end()),
423 boost::make_filter_iterator(pfCandFilter_comboChargedHadrons, pfchs.end(), pfchs.end()));
427 std::cout <<
"adding isolation PFChargedHadrons from 'regional junk':" << std::endl;
431 boost::make_filter_iterator(pfChargedJunk, regionalJunk.begin(), regionalJunk.end()),
432 boost::make_filter_iterator(pfChargedJunk, regionalJunk.end(), regionalJunk.end()));
436 std::cout <<
"adding isolation PFGammas not considered in PiZeros:" << std::endl;
441 boost::make_filter_iterator(pfCandFilter_allChargedHadrons, pfgammas.begin(), pfgammas.end()),
442 boost::make_filter_iterator(pfCandFilter_allChargedHadrons, pfgammas.end(), pfgammas.end()));
447 boost::make_filter_iterator(pfGammaJunk, regionalJunk.begin(), regionalJunk.end()),
448 boost::make_filter_iterator(pfGammaJunk, regionalJunk.end(), regionalJunk.end()));
453 boost::make_filter_iterator(pfCandFilter_allChargedHadrons, pfnhs.begin(), pfnhs.end()),
454 boost::make_filter_iterator(pfCandFilter_allChargedHadrons, pfnhs.end(), pfnhs.end()));
459 boost::make_filter_iterator(pfNeutralJunk, regionalJunk.begin(), regionalJunk.end()),
460 boost::make_filter_iterator(pfNeutralJunk, regionalJunk.end(), regionalJunk.end()));
462 std::unique_ptr<reco::PFTau> tauPtr =
tau.get(
true);
467 tauPtr->setVertex(primaryVertexRef->position());
470 double tauEn = tauPtr->energy();
471 double tauPz = tauPtr->pz();
472 const double chargedPionMass = 0.13957;
473 double tauMass =
std::max(tauPtr->mass(), chargedPionMass);
474 double bendCorrMass2 = 0.;
475 const std::vector<RecoTauPiZero>& piZeros = tauPtr->signalPiZeroCandidates();
476 for (
auto const& piZero : piZeros) {
477 double piZeroEn = piZero.energy();
478 double piZeroPx = piZero.px();
479 double piZeroPy = piZero.py();
480 double piZeroPz = piZero.pz();
481 double tau_wo_piZeroPx = tauPtr->px() - piZeroPx;
482 double tau_wo_piZeroPy = tauPtr->py() - piZeroPy;
485 bendCorrMass2 +=
square(((piZeroPz * tauEn - piZeroEn * tauPz) / tauMass) * piZero.bendCorrEta());
487 square(((piZeroPy * tau_wo_piZeroPx - piZeroPx * tau_wo_piZeroPy) / tauMass) * piZero.bendCorrPhi());
490 tauPtr->setBendCorrMass(
sqrt(bendCorrMass2));
506 "RecoTauBuilderCombinatoricPlugin");
std::vector< CandidatePtr > pfCandidatesByPdgId(const Jet &jet, int pdgId, bool sort=true)
InputIterator takeNElements(const InputIterator &begin, const InputIterator &end, size_t N)
std::vector< std::unique_ptr< reco::PFTau > > output_type
CombinatoricIterator< T > end()
std::vector< reco::PFRecoTauChargedHadron > ChargedHadronList
const edm::Handle< edm::View< reco::Candidate > > & getPFCands() const
Hack to be able to convert Ptrs to Refs.
double minRelPhotonSumPt_outsideSignalCone_
bool isNonnull() const
Checks for non-null.
RecoTauBuilderCombinatoricPlugin(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
std::vector< CandidatePtr > pfChargedCands(const Jet &jet, bool sort=true)
Extract all non-neutral candidates from a PFJet.
double minAbsPhotonSumPt_outsideSignalCone_
tau::CombinatoricGenerator< PiZeroList > PiZeroCombo
std::vector< CandidatePtr > flattenPiZeros(const std::vector< RecoTauPiZero >::const_iterator &, const std::vector< RecoTauPiZero >::const_iterator &)
Flatten a list of pi zeros into a list of there constituent PFCandidates.
std::vector< decayModeInfo > decayModesToBuild_
double minAbsPhotonSumPt_insideSignalCone_
reco::VertexRef primaryVertex(const reco::JetBaseRef &jet) const
Get primary vertex associated to this jet.
return_type operator()(const reco::JetBaseRef &, const std::vector< reco::PFRecoTauChargedHadron > &, const std::vector< RecoTauPiZero > &, const std::vector< CandidatePtr > &) const override
std::vector< reco::CandidatePtr > CandPtrs
StringObjectFunction< reco::PFTau > signalConeSize_
void initialize(const PtrIter &chargedHadronsBegin, const PtrIter &chargedHadronsEnd)
tau::CombinatoricGenerator< ChargedHadronList > ChargedHadronCombo
std::vector< CandidatePtr > daughters
collection of references to daughters
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
static double square(double x)
ParameterSet const & getParameterSet(ParameterSetID const &id)
~RecoTauBuilderCombinatoricPlugin() override
double minRelPhotonSumPt_insideSignalCone_
#define DEFINE_EDM_PLUGIN(factory, type, name)
double isolationConeSize_
std::unique_ptr< RecoTauQualityCuts > qcuts_
void initialize(const PtrIter &particlesBegin, const PtrIter &particlesEnd)
std::vector< RecoTauPiZero > PiZeroList
iterator::value_type::ValueIter combo_iterator
Transform a pizero to remove given candidates.
CombinatoricIterator< T > begin()