21 namespace reco {
namespace tau {
36 const std::vector<reco::PFRecoTauChargedHadron>&,
37 const std::vector<RecoTauPiZero>&,
38 const std::vector<CandidatePtr>&)
const override;
73 typedef std::vector<edm::ParameterSet>
VPSet;
75 for ( VPSet::const_iterator
decayMode = decayModes.begin();
100 if ( mode_ == kRemoveChargedDaughterOverlaps ) {
102 }
else if ( mode_ == kRemoveChargedAndNeutralDaughterOverlaps ) {
104 for ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
105 daughter != daughters.end(); ++daughter ) {
115 for(
auto const& ptr :
flattenPiZeros(piZerosBegin, piZerosEnd) ) {
126 for ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
127 daughter != daughters.end(); ++daughter ) {
140 for ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
141 daughter != daughters.end(); ++daughter ) {
152 class SortPi0sDescendingPt
157 return a.
pt() > b.
pt();
170 const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons,
171 const std::vector<RecoTauPiZero>& piZeros,
172 const std::vector<CandidatePtr>& regionalExtras)
const 175 std::cout <<
"<RecoTauBuilderCombinatoricPlugin::operator()>:" << std::endl;
176 std::cout <<
" processing jet: Pt = " << jet->pt() <<
", eta = " << jet->eta() <<
", phi = " << jet->eta() <<
"," 177 <<
" mass = " << jet->mass() <<
", area = " << jet->jetArea() << std::endl;
187 typedef std::vector<CandidatePtr>
CandPtrs;
190 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
192 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();
201 piZero != piZeros.end(); ++piZero ) {
202 std::cout <<
"piZero #" << idx <<
":" << std::endl;
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 )
continue;
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();
250 trackCombo != trackCombos.
end(); ++trackCombo ) {
252 trackCombo->combo_begin(), trackCombo->combo_end(),
255 PiZeroList cleanSignalPiZeros = signalPiZeroXCleaner(piZeros);
258 std::sort(cleanSignalPiZeros.begin(), cleanSignalPiZeros.end(), SortPi0sDescendingPt());
262 if ( cleanSignalPiZeros.size() < piZerosToBuild )
continue;
265 PiZeroList::iterator signalPiZero_begin = cleanSignalPiZeros.begin();
266 PiZeroList::iterator signalPiZero_end = cleanSignalPiZeros.end();
270 PiZeroCombo piZeroCombos(signalPiZero_begin, signalPiZero_end, piZerosToBuild);
273 piZeroCombo != piZeroCombos.
end(); ++piZeroCombo ) {
289 trackCombo->combo_begin(), trackCombo->combo_end(),
292 PiZeroList precleanedIsolationPiZeros = isolationPiZeroXCleaner(piZeros);
293 std::set<reco::CandidatePtr> toRemove;
295 signalPiZero != piZeroCombo->combo_end(); ++signalPiZero ) {
296 toRemove.insert(signalPiZero->daughterPtrVector().begin(), signalPiZero->daughterPtrVector().end());
298 PiZeroList cleanIsolationPiZeros;
299 for(
auto const& precleanedPiZero : precleanedIsolationPiZeros ) {
300 std::set<reco::CandidatePtr> toCheck(precleanedPiZero.daughterPtrVector().begin(), precleanedPiZero.daughterPtrVector().end());
301 std::vector<reco::CandidatePtr> cleanDaughters;
302 std::set_difference(toCheck.begin(), toCheck.end(), toRemove.begin(), toRemove.end(), std::back_inserter(cleanDaughters));
304 if ( cleanDaughters.size() == precleanedPiZero.daughterPtrVector().size() ) {
305 cleanIsolationPiZeros.push_back(precleanedPiZero);
309 std::cout <<
"#cleanIsolationPiZeros = " << cleanIsolationPiZeros.size() << std::endl;
311 for ( PiZeroList::const_iterator piZero = cleanIsolationPiZeros.begin();
312 piZero != cleanIsolationPiZeros.end(); ++piZero ) {
313 std::cout <<
"piZero #" << idx <<
":" << std::endl;
327 (piZeros.size() - piZerosToBuild)*2);
330 (piZeros.size() - piZerosToBuild));
336 piZeroCombo->combo_begin(), piZeroCombo->combo_end());
346 trackCombo->combo_begin(), trackCombo->combo_end());
357 pfChargedHadronXCleanerType pfChargedHadronXCleaner_comboChargedHadrons(trackCombo->combo_begin(), trackCombo->combo_end());
364 pfCandXCleanerType pfCandXCleaner_allChargedHadrons(pfChargedHadronXCleaner_allChargedHadrons, piZeroXCleaner);
376 xclean::FilterCandByAbsPdgId
377 pfchCandSelector(211);
378 xclean::FilterCandByAbsPdgId
379 pfgammaCandSelector(22);
380 xclean::FilterCandByAbsPdgId
381 pfnhCandSelector(130);
383 RegionalJunkConeAndIdFilter pfChargedJunk(
385 isolationConeFilter);
387 RegionalJunkConeAndIdFilter pfGammaJunk(
389 isolationConeFilter);
391 RegionalJunkConeAndIdFilter pfNeutralJunk(
393 isolationConeFilter);
397 boost::make_filter_iterator(
398 isolationConeFilterPiZero,
399 cleanIsolationPiZeros.begin(), cleanIsolationPiZeros.end()),
400 boost::make_filter_iterator(
401 isolationConeFilterPiZero,
402 cleanIsolationPiZeros.end(), cleanIsolationPiZeros.end()));
410 std::cout <<
"adding isolation PFChargedHadrons from trackCombo:" << std::endl;
414 boost::make_filter_iterator(
415 isolationConeFilterChargedHadron,
416 trackCombo->remainder_begin(), trackCombo->remainder_end()),
417 boost::make_filter_iterator(
418 isolationConeFilterChargedHadron,
419 trackCombo->remainder_end(), trackCombo->remainder_end()));
424 std::cout <<
"adding isolation PFChargedHadrons not considered in trackCombo:" << std::endl;
428 boost::make_filter_iterator(
429 pfCandFilter_comboChargedHadrons,
430 pfch_end, pfchs.end()),
431 boost::make_filter_iterator(
432 pfCandFilter_comboChargedHadrons,
433 pfchs.end(), pfchs.end()));
437 std::cout <<
"adding isolation PFChargedHadrons from 'regional junk':" << std::endl;
441 boost::make_filter_iterator(
442 pfChargedJunk, regionalJunk.begin(), regionalJunk.end()),
443 boost::make_filter_iterator(
444 pfChargedJunk, regionalJunk.end(), regionalJunk.end()));
448 std::cout <<
"adding isolation PFGammas not considered in PiZeros:" << std::endl;
452 boost::make_filter_iterator(
453 pfCandFilter_allChargedHadrons,
454 pfgammas.begin(), pfgammas.end()),
455 boost::make_filter_iterator(
456 pfCandFilter_allChargedHadrons,
457 pfgammas.end(), pfgammas.end()));
462 boost::make_filter_iterator(
463 pfGammaJunk, regionalJunk.begin(), regionalJunk.end()),
464 boost::make_filter_iterator(
465 pfGammaJunk, regionalJunk.end(), regionalJunk.end()));
470 boost::make_filter_iterator(
471 pfCandFilter_allChargedHadrons,
472 pfnhs.begin(), pfnhs.end()),
473 boost::make_filter_iterator(
474 pfCandFilter_allChargedHadrons,
475 pfnhs.end(), pfnhs.end()));
480 boost::make_filter_iterator(
481 pfNeutralJunk, regionalJunk.begin(), regionalJunk.end()),
482 boost::make_filter_iterator(
483 pfNeutralJunk, regionalJunk.end(), regionalJunk.end()));
485 std::auto_ptr<reco::PFTau> tauPtr = tau.
get(
true);
490 tauPtr->setVertex(primaryVertexRef->position());
493 double tauEn = tauPtr->energy();
494 double tauPz = tauPtr->pz();
495 const double chargedPionMass = 0.13957;
496 double tauMass =
std::max(tauPtr->mass(), chargedPionMass);
497 double bendCorrMass2 = 0.;
498 const std::vector<RecoTauPiZero>& piZeros = tauPtr->signalPiZeroCandidates();
499 for (
auto const& piZero : piZeros ) {
500 double piZeroEn = piZero.energy();
501 double piZeroPx = piZero.px();
502 double piZeroPy = piZero.py();
503 double piZeroPz = piZero.pz();
504 double tau_wo_piZeroPx = tauPtr->px() - piZeroPx;
505 double tau_wo_piZeroPy = tauPtr->py() - piZeroPy;
508 bendCorrMass2 +=
square(((piZeroPz*tauEn - piZeroEn*tauPz)/tauMass)*piZero.bendCorrEta());
509 bendCorrMass2 +=
square(((piZeroPy*tau_wo_piZeroPx - piZeroPx*tau_wo_piZeroPy)/tauMass)*piZero.bendCorrPhi());
512 tauPtr->setBendCorrMass(
sqrt(bendCorrMass2));
514 output.push_back(tauPtr);
519 return output.release();
527 "RecoTauBuilderCombinatoricPlugin");
reco::VertexRef primaryVertex(const reco::JetBaseRef &jet) const
Get primary vertex associated to this jet.
std::vector< CandidatePtr > pfCandidatesByPdgId(const Jet &jet, int pdgId, bool sort=true)
T getParameter(std::string const &) const
static AlgebraicMatrix initialize()
InputIterator takeNElements(const InputIterator &begin, const InputIterator &end, size_t N)
std::auto_ptr< reco::PFTau > get(bool setupLeadingCandidates=true)
bool isNonnull() const
Checks for non-null.
void reserve(Region region, ParticleType type, size_t size)
Reserve a set amount of space for a given RefVector.
void addTauChargedHadrons(Region region, const InputIterator &begin, const InputIterator &end)
Add a list of charged hadrons to the input collection.
CombinatoricIterator< T > end()
Coll filterCandRefs(const Coll &refcoll, bool invert=false) const
Filter a ref vector of Candidates.
std::vector< reco::PFRecoTauChargedHadron > ChargedHadronList
ParameterSet const & getParameterSet(ParameterSetID const &id)
double minRelPhotonSumPt_outsideSignalCone_
boost::ptr_vector< reco::PFTau > output_type
double pt() const final
transverse momentum
std::auto_ptr< output_type > return_type
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.
void addPiZeros(Region region, const InputIterator &begin, const InputIterator &end)
Add a list of pizeros to the input collection.
std::vector< decayModeInfo > decayModesToBuild_
double minAbsPhotonSumPt_insideSignalCone_
std::vector< reco::CandidatePtr > CandPtrs
void setPV(const reco::VertexRef &vtx) const
Update the primary vertex.
StringObjectFunction< reco::PFTau > signalConeSize_
const reco::Candidate::LorentzVector & p4() const
void addPFCands(Region region, ParticleType type, const InputIterator &begin, const InputIterator &end)
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
RecoTauQualityCuts qcuts_
void reservePiZero(Region region, size_t size)
Reserve a set amount of space for the PiZeros.
static double square(double x)
~RecoTauBuilderCombinatoricPlugin() override
double minRelPhotonSumPt_insideSignalCone_
return_type operator()(const reco::JetBaseRef &, const std::vector< reco::PFRecoTauChargedHadron > &, const std::vector< RecoTauPiZero > &, const std::vector< CandidatePtr > &) const override
#define DEFINE_EDM_PLUGIN(factory, type, name)
double isolationConeSize_
const edm::Handle< edm::View< reco::Candidate > > & getPFCands() const
Hack to be able to convert Ptrs to Refs.
std::vector< RecoTauPiZero > PiZeroList
iterator::value_type::ValueIter combo_iterator
Transform a pizero to remove given candidates.
CombinatoricIterator< T > begin()