21 namespace reco {
namespace tau {
36 const std::vector<reco::PFRecoTauChargedHadron>&,
37 const std::vector<RecoTauPiZero>&,
38 const std::vector<PFCandidatePtr>&)
const override;
73 typedef std::vector<edm::ParameterSet>
VPSet;
75 for ( VPSet::const_iterator
decayMode = decayModes.begin();
101 if ( mode_ == kRemoveChargedDaughterOverlaps ) {
103 }
else if ( mode_ == kRemoveChargedAndNeutralDaughterOverlaps ) {
105 for ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
106 daughter != daughters.end(); ++daughter ) {
127 for ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
128 daughter != daughters.end(); ++daughter ) {
141 for ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
142 daughter != daughters.end(); ++daughter ) {
153 class SortPi0sDescendingPt
158 return a.
pt() > b.
pt();
171 const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons,
172 const std::vector<RecoTauPiZero>& piZeros,
173 const std::vector<PFCandidatePtr>& regionalExtras)
const 176 std::cout <<
"<RecoTauBuilderCombinatoricPlugin::operator()>:" << std::endl;
177 std::cout <<
" processing jet: Pt = " << jet->pt() <<
", eta = " << jet->eta() <<
", phi = " << jet->eta() <<
"," 178 <<
" mass = " << jet->mass() <<
", area = " << jet->jetArea() << std::endl;
188 typedef std::vector<PFCandidatePtr>
PFCandPtrs;
191 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
193 for ( ChargedHadronList::const_iterator
chargedHadron = chargedHadrons.begin();
195 std::cout <<
"chargedHadron #" << idx <<
":" << std::endl;
199 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
201 for ( PiZeroList::const_iterator piZero = piZeros.begin();
202 piZero != piZeros.end(); ++piZero ) {
203 std::cout <<
"piZero #" << idx <<
":" << std::endl;
221 size_t piZerosToBuild =
decayMode->nPiZeros_;
223 size_t tracksToBuild =
decayMode->nCharged_;
225 std::cout <<
"piZerosToBuild = " << piZerosToBuild << std::endl;
226 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
227 std::cout <<
"tracksToBuild = " << tracksToBuild << std::endl;
228 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
232 if ( chargedHadrons.size() < tracksToBuild )
continue;
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 PFCandPtrs::iterator pfch_end = pfchs.end();
251 trackCombo != trackCombos.
end(); ++trackCombo ) {
253 trackCombo->combo_begin(), trackCombo->combo_end(),
256 PiZeroList cleanSignalPiZeros = signalPiZeroXCleaner(piZeros);
259 std::sort(cleanSignalPiZeros.begin(), cleanSignalPiZeros.end(), SortPi0sDescendingPt());
263 if ( cleanSignalPiZeros.size() < piZerosToBuild )
continue;
266 PiZeroList::iterator signalPiZero_begin = cleanSignalPiZeros.begin();
267 PiZeroList::iterator signalPiZero_end = cleanSignalPiZeros.end();
271 PiZeroCombo piZeroCombos(signalPiZero_begin, signalPiZero_end, piZerosToBuild);
274 piZeroCombo != piZeroCombos.
end(); ++piZeroCombo ) {
290 trackCombo->combo_begin(), trackCombo->combo_end(),
293 PiZeroList precleanedIsolationPiZeros = isolationPiZeroXCleaner(piZeros);
294 std::set<reco::CandidatePtr> toRemove;
296 signalPiZero != piZeroCombo->combo_end(); ++signalPiZero ) {
297 toRemove.insert(signalPiZero->daughterPtrVector().begin(), signalPiZero->daughterPtrVector().end());
299 PiZeroList cleanIsolationPiZeros;
300 BOOST_FOREACH(
const RecoTauPiZero& precleanedPiZero, precleanedIsolationPiZeros ) {
302 std::vector<reco::CandidatePtr> cleanDaughters;
303 std::set_difference(toCheck.begin(), toCheck.end(), toRemove.begin(), toRemove.end(), std::back_inserter(cleanDaughters));
306 cleanIsolationPiZeros.push_back(precleanedPiZero);
310 std::cout <<
"#cleanIsolationPiZeros = " << cleanIsolationPiZeros.size() << std::endl;
312 for ( PiZeroList::const_iterator piZero = cleanIsolationPiZeros.begin();
313 piZero != cleanIsolationPiZeros.end(); ++piZero ) {
314 std::cout <<
"piZero #" << idx <<
":" << std::endl;
328 (piZeros.size() - piZerosToBuild)*2);
331 (piZeros.size() - piZerosToBuild));
337 piZeroCombo->combo_begin(), piZeroCombo->combo_end());
347 trackCombo->combo_begin(), trackCombo->combo_end());
358 pfChargedHadronXCleanerType pfChargedHadronXCleaner_comboChargedHadrons(trackCombo->combo_begin(), trackCombo->combo_end());
365 pfCandXCleanerType pfCandXCleaner_allChargedHadrons(pfChargedHadronXCleaner_allChargedHadrons, piZeroXCleaner);
377 xclean::FilterPFCandByParticleId
379 xclean::FilterPFCandByParticleId
381 xclean::FilterPFCandByParticleId
384 RegionalJunkConeAndIdFilter pfChargedJunk(
386 isolationConeFilter);
388 RegionalJunkConeAndIdFilter pfGammaJunk(
390 isolationConeFilter);
392 RegionalJunkConeAndIdFilter pfNeutralJunk(
394 isolationConeFilter);
398 boost::make_filter_iterator(
399 isolationConeFilterPiZero,
400 cleanIsolationPiZeros.begin(), cleanIsolationPiZeros.end()),
401 boost::make_filter_iterator(
402 isolationConeFilterPiZero,
403 cleanIsolationPiZeros.end(), cleanIsolationPiZeros.end()));
411 std::cout <<
"adding isolation PFChargedHadrons from trackCombo:" << std::endl;
415 boost::make_filter_iterator(
416 isolationConeFilterChargedHadron,
417 trackCombo->remainder_begin(), trackCombo->remainder_end()),
418 boost::make_filter_iterator(
419 isolationConeFilterChargedHadron,
420 trackCombo->remainder_end(), trackCombo->remainder_end()));
425 std::cout <<
"adding isolation PFChargedHadrons not considered in trackCombo:" << std::endl;
429 boost::make_filter_iterator(
430 pfCandFilter_comboChargedHadrons,
431 pfch_end, pfchs.end()),
432 boost::make_filter_iterator(
433 pfCandFilter_comboChargedHadrons,
434 pfchs.end(), pfchs.end()));
438 std::cout <<
"adding isolation PFChargedHadrons from 'regional junk':" << std::endl;
442 boost::make_filter_iterator(
443 pfChargedJunk, regionalJunk.begin(), regionalJunk.end()),
444 boost::make_filter_iterator(
445 pfChargedJunk, regionalJunk.end(), regionalJunk.end()));
449 std::cout <<
"adding isolation PFGammas not considered in PiZeros:" << std::endl;
453 boost::make_filter_iterator(
454 pfCandFilter_allChargedHadrons,
455 pfgammas.begin(), pfgammas.end()),
456 boost::make_filter_iterator(
457 pfCandFilter_allChargedHadrons,
458 pfgammas.end(), pfgammas.end()));
463 boost::make_filter_iterator(
464 pfGammaJunk, regionalJunk.begin(), regionalJunk.end()),
465 boost::make_filter_iterator(
466 pfGammaJunk, regionalJunk.end(), regionalJunk.end()));
471 boost::make_filter_iterator(
472 pfCandFilter_allChargedHadrons,
473 pfnhs.begin(), pfnhs.end()),
474 boost::make_filter_iterator(
475 pfCandFilter_allChargedHadrons,
476 pfnhs.end(), pfnhs.end()));
481 boost::make_filter_iterator(
482 pfNeutralJunk, regionalJunk.begin(), regionalJunk.end()),
483 boost::make_filter_iterator(
484 pfNeutralJunk, regionalJunk.end(), regionalJunk.end()));
486 std::auto_ptr<reco::PFTau> tauPtr = tau.
get(
true);
491 tauPtr->setVertex(primaryVertexRef->position());
494 double tauEn = tauPtr->energy();
495 double tauPz = tauPtr->pz();
496 const double chargedPionMass = 0.13957;
497 double tauMass =
std::max(tauPtr->mass(), chargedPionMass);
498 double bendCorrMass2 = 0.;
499 const std::vector<RecoTauPiZero>& piZeros = tauPtr->signalPiZeroCandidates();
500 for (
auto const& piZero : piZeros ) {
501 double piZeroEn = piZero.energy();
502 double piZeroPx = piZero.px();
503 double piZeroPy = piZero.py();
504 double piZeroPz = piZero.pz();
505 double tau_wo_piZeroPx = tauPtr->px() - piZeroPx;
506 double tau_wo_piZeroPy = tauPtr->py() - piZeroPy;
509 bendCorrMass2 +=
square(((piZeroPz*tauEn - piZeroEn*tauPz)/tauMass)*piZero.bendCorrEta());
510 bendCorrMass2 +=
square(((piZeroPy*tau_wo_piZeroPx - piZeroPx*tau_wo_piZeroPy)/tauMass)*piZero.bendCorrPhi());
513 tauPtr->setBendCorrMass(
sqrt(bendCorrMass2));
515 output.push_back(tauPtr);
520 return output.release();
528 "RecoTauBuilderCombinatoricPlugin");
T getParameter(std::string const &) const
static AlgebraicMatrix initialize()
const edm::Handle< PFCandidateCollection > & getPFCands() const
Hack to be able to convert Ptrs to Refs.
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 PFCandidates.
std::vector< reco::PFRecoTauChargedHadron > ChargedHadronList
ParameterSet const & getParameterSet(ParameterSetID const &id)
std::vector< reco::PFCandidatePtr > PFCandPtrs
double minRelPhotonSumPt_outsideSignalCone_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
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)
double minAbsPhotonSumPt_outsideSignalCone_
tau::CombinatoricGenerator< PiZeroList > PiZeroCombo
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
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_
reco::VertexRef primaryVertex(const reco::PFJetRef &jet) const
Get primary vertex associated to this jet.
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< PFCandidatePtr > 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< 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)
return_type operator()(const reco::PFJetRef &, const std::vector< reco::PFRecoTauChargedHadron > &, const std::vector< RecoTauPiZero > &, const std::vector< PFCandidatePtr > &) const override
std::vector< PFCandidatePtr > pfChargedCands(const PFJet &jet, bool sort=true)
Extract all non-neutral candidates from a PFJet.
~RecoTauBuilderCombinatoricPlugin() override
double minRelPhotonSumPt_insideSignalCone_
const daughters & daughterPtrVector() const
references to daughtes
#define DEFINE_EDM_PLUGIN(factory, type, name)
double isolationConeSize_
std::vector< RecoTauPiZero > PiZeroList
iterator::value_type::ValueIter combo_iterator
Transform a pizero to remove given candidates.
CombinatoricIterator< T > begin()