35 const std::vector<reco::PFRecoTauChargedHadron>&,
36 const std::vector<RecoTauPiZero>&,
37 const std::vector<CandidatePtr>&)
const override;
40 std::unique_ptr<RecoTauQualityCuts>
qcuts_;
66 isolationConeSize_(
pset.getParameter<double>(
"isolationConeSize")),
67 signalConeSize_(
pset.getParameter<
std::
string>(
"signalConeSize")),
68 minAbsPhotonSumPt_insideSignalCone_(
pset.getParameter<double>(
"minAbsPhotonSumPt_insideSignalCone")),
69 minRelPhotonSumPt_insideSignalCone_(
pset.getParameter<double>(
"minRelPhotonSumPt_insideSignalCone")),
70 minAbsPhotonSumPt_outsideSignalCone_(
pset.getParameter<double>(
"minAbsPhotonSumPt_outsideSignalCone")),
71 minRelPhotonSumPt_outsideSignalCone_(
pset.getParameter<double>(
"minRelPhotonSumPt_outsideSignalCone")) {
72 typedef std::vector<edm::ParameterSet>
VPSet;
76 info.nCharged_ =
decayMode->getParameter<uint32_t>(
"nCharged");
77 info.nPiZeros_ =
decayMode->getParameter<uint32_t>(
"nPiZeros");
78 info.maxPFCHs_ =
decayMode->getParameter<uint32_t>(
"maxTracks");
79 info.maxPiZeros_ =
decayMode->getParameter<uint32_t>(
"maxPiZeros");
99 if (mode_ == kRemoveChargedDaughterOverlaps) {
102 }
else if (mode_ == kRemoveChargedAndNeutralDaughterOverlaps) {
104 for (reco::CompositePtrCandidate::daughters::const_iterator daughter =
daughters.begin();
116 const PiZeroList::const_iterator& piZerosEnd) {
117 for (
auto const& ptr :
flattenPiZeros(piZerosBegin, piZerosEnd)) {
130 for (reco::CompositePtrCandidate::daughters::const_iterator daughter =
daughters.begin();
141 const ChargedHadronList::const_iterator& chargedHadronsBegin,
142 const ChargedHadronList::const_iterator& chargedHadronsEnd) {
147 for (reco::CompositePtrCandidate::daughters::const_iterator daughter =
daughters.begin();
159 class SortPi0sDescendingPt {
164 double square(
double x) {
return x *
x; }
169 const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons,
170 const std::vector<RecoTauPiZero>& piZeros,
171 const std::vector<CandidatePtr>& regionalExtras)
const {
173 std::cout <<
"<RecoTauBuilderCombinatoricPlugin::operator()>:" << std::endl;
174 std::cout <<
" processing jet: Pt = " <<
jet->pt() <<
", eta = " <<
jet->eta() <<
", phi = " <<
jet->eta()
176 <<
" mass = " <<
jet->mass() <<
", area = " <<
jet->jetArea() << std::endl;
186 typedef std::vector<CandidatePtr>
CandPtrs;
189 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
191 for (ChargedHadronList::const_iterator
chargedHadron = chargedHadrons.begin();
194 std::cout <<
"chargedHadron #" <<
idx <<
":" << std::endl;
198 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
200 for (PiZeroList::const_iterator piZero = piZeros.begin(); piZero != piZeros.end(); ++piZero) {
220 size_t piZerosToBuild =
decayMode->nPiZeros_;
222 size_t tracksToBuild =
decayMode->nCharged_;
224 std::cout <<
"piZerosToBuild = " << piZerosToBuild << std::endl;
225 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
226 std::cout <<
"tracksToBuild = " << tracksToBuild << std::endl;
227 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
231 if (chargedHadrons.size() < tracksToBuild)
235 ChargedHadronList::const_iterator chargedHadron_begin = chargedHadrons.begin();
236 ChargedHadronList::const_iterator chargedHadron_end = chargedHadrons.end();
240 ChargedHadronCombo trackCombos(chargedHadron_begin, chargedHadron_end, tracksToBuild);
242 CandPtrs::iterator pfch_end = pfchs.end();
253 trackCombo->combo_begin(),
254 trackCombo->combo_end(),
257 PiZeroList cleanSignalPiZeros = signalPiZeroXCleaner(piZeros);
260 std::sort(cleanSignalPiZeros.begin(), cleanSignalPiZeros.end(), SortPi0sDescendingPt());
264 if (cleanSignalPiZeros.size() < piZerosToBuild)
268 PiZeroList::iterator signalPiZero_begin = cleanSignalPiZeros.begin();
269 PiZeroList::iterator signalPiZero_end = cleanSignalPiZeros.end();
273 PiZeroCombo piZeroCombos(signalPiZero_begin, signalPiZero_end, piZerosToBuild);
292 trackCombo->combo_begin(),
293 trackCombo->combo_end(),
296 PiZeroList precleanedIsolationPiZeros = isolationPiZeroXCleaner(piZeros);
297 std::set<reco::CandidatePtr> toRemove;
299 signalPiZero != piZeroCombo->combo_end();
301 toRemove.insert(signalPiZero->daughterPtrVector().begin(), signalPiZero->daughterPtrVector().end());
304 for (
auto const& precleanedPiZero : precleanedIsolationPiZeros) {
305 std::set<reco::CandidatePtr> toCheck(precleanedPiZero.daughterPtrVector().begin(),
306 precleanedPiZero.daughterPtrVector().end());
307 std::vector<reco::CandidatePtr> cleanDaughters;
309 toCheck.begin(), toCheck.end(), toRemove.begin(), toRemove.end(), std::back_inserter(cleanDaughters));
311 if (cleanDaughters.size() == precleanedPiZero.daughterPtrVector().size()) {
312 cleanIsolationPiZeros.push_back(precleanedPiZero);
316 std::cout <<
"#cleanIsolationPiZeros = " << cleanIsolationPiZeros.size() << std::endl;
318 for (PiZeroList::const_iterator piZero = cleanIsolationPiZeros.begin();
319 piZero != cleanIsolationPiZeros.end();
331 chargedHadrons.size() - tracksToBuild);
357 pfChargedHadronXCleanerType pfChargedHadronXCleaner_comboChargedHadrons(trackCombo->combo_begin(),
358 trackCombo->combo_end());
361 isolationConeFilter, pfChargedHadronXCleaner_comboChargedHadrons);
364 chargedHadrons.begin(), chargedHadrons.end());
369 pfCandXCleanerType pfCandXCleaner_allChargedHadrons(pfChargedHadronXCleaner_allChargedHadrons,
373 isolationConeFilter, pfCandXCleaner_allChargedHadrons);
386 RegionalJunkConeAndIdFilter pfChargedJunk(pfchCandSelector,
387 isolationConeFilter);
389 RegionalJunkConeAndIdFilter pfGammaJunk(pfgammaCandSelector,
390 isolationConeFilter);
392 RegionalJunkConeAndIdFilter pfNeutralJunk(pfnhCandSelector,
393 isolationConeFilter);
396 boost::make_filter_iterator(
397 isolationConeFilterPiZero, cleanIsolationPiZeros.begin(), cleanIsolationPiZeros.end()),
398 boost::make_filter_iterator(
399 isolationConeFilterPiZero, cleanIsolationPiZeros.end(), cleanIsolationPiZeros.end()));
407 std::cout <<
"adding isolation PFChargedHadrons from trackCombo:" << std::endl;
409 tau.addTauChargedHadrons(
411 boost::make_filter_iterator(
412 isolationConeFilterChargedHadron, trackCombo->remainder_begin(), trackCombo->remainder_end()),
413 boost::make_filter_iterator(
414 isolationConeFilterChargedHadron, trackCombo->remainder_end(), trackCombo->remainder_end()));
419 std::cout <<
"adding isolation PFChargedHadrons not considered in trackCombo:" << std::endl;
423 boost::make_filter_iterator(pfCandFilter_comboChargedHadrons, pfch_end, pfchs.end()),
424 boost::make_filter_iterator(pfCandFilter_comboChargedHadrons, pfchs.end(), pfchs.end()));
428 std::cout <<
"adding isolation PFChargedHadrons from 'regional junk':" << std::endl;
432 boost::make_filter_iterator(pfChargedJunk, regionalJunk.begin(), regionalJunk.end()),
433 boost::make_filter_iterator(pfChargedJunk, regionalJunk.end(), regionalJunk.end()));
437 std::cout <<
"adding isolation PFGammas not considered in PiZeros:" << std::endl;
442 boost::make_filter_iterator(pfCandFilter_allChargedHadrons, pfgammas.begin(), pfgammas.end()),
443 boost::make_filter_iterator(pfCandFilter_allChargedHadrons, pfgammas.end(), pfgammas.end()));
448 boost::make_filter_iterator(pfGammaJunk, regionalJunk.begin(), regionalJunk.end()),
449 boost::make_filter_iterator(pfGammaJunk, regionalJunk.end(), regionalJunk.end()));
454 boost::make_filter_iterator(pfCandFilter_allChargedHadrons, pfnhs.begin(), pfnhs.end()),
455 boost::make_filter_iterator(pfCandFilter_allChargedHadrons, pfnhs.end(), pfnhs.end()));
460 boost::make_filter_iterator(pfNeutralJunk, regionalJunk.begin(), regionalJunk.end()),
461 boost::make_filter_iterator(pfNeutralJunk, regionalJunk.end(), regionalJunk.end()));
463 std::unique_ptr<reco::PFTau> tauPtr =
tau.get(
true);
468 tauPtr->setVertex(primaryVertexRef->position());
471 double tauEn = tauPtr->energy();
472 double tauPz = tauPtr->pz();
473 const double chargedPionMass = 0.13957;
474 double tauMass =
std::max(tauPtr->mass(), chargedPionMass);
475 double bendCorrMass2 = 0.;
476 const std::vector<RecoTauPiZero>& piZeros = tauPtr->signalPiZeroCandidates();
477 for (
auto const& piZero : piZeros) {
478 double piZeroEn = piZero.energy();
479 double piZeroPx = piZero.px();
480 double piZeroPy = piZero.py();
481 double piZeroPz = piZero.pz();
482 double tau_wo_piZeroPx = tauPtr->px() - piZeroPx;
483 double tau_wo_piZeroPy = tauPtr->py() - piZeroPy;
486 bendCorrMass2 +=
square(((piZeroPz * tauEn - piZeroEn * tauPz) / tauMass) * piZero.bendCorrEta());
488 square(((piZeroPy * tau_wo_piZeroPx - piZeroPx * tau_wo_piZeroPy) / tauMass) * piZero.bendCorrPhi());
491 tauPtr->setBendCorrMass(
sqrt(bendCorrMass2));
507 "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()