21 namespace reco {
namespace tau {
36 const std::vector<reco::PFRecoTauChargedHadron>&,
37 const std::vector<RecoTauPiZero>&,
38 const std::vector<PFCandidatePtr>&)
const override;
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"))
73 typedef std::vector<edm::ParameterSet> VPSet;
74 const VPSet& decayModes = pset.
getParameter<VPSet>(
"decayModes");
75 for ( VPSet::const_iterator decayMode = decayModes.begin();
76 decayMode != decayModes.end(); ++decayMode ) {
78 info.
nCharged_ = decayMode->getParameter<uint32_t>(
"nCharged");
79 info.
nPiZeros_ = decayMode->getParameter<uint32_t>(
"nPiZeros");
80 info.
maxPFCHs_ = decayMode->getParameter<uint32_t>(
"maxTracks");
81 info.
maxPiZeros_ = decayMode->getParameter<uint32_t>(
"maxPiZeros");
101 if ( mode_ == kRemoveChargedDaughterOverlaps ) {
102 if ( chargedHadron->getChargedPFCandidate().isNonnull() ) toRemove_.insert(
reco::CandidatePtr(chargedHadron->getChargedPFCandidate()));
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 ) {
139 for ( ChargedHadronList::const_iterator chargedHadron = chargedHadronsBegin; chargedHadron != chargedHadronsEnd; ++chargedHadron ) {
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;
190 typedef std::vector<PFCandidatePtr>
PFCandPtrs;
193 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
195 for ( ChargedHadronList::const_iterator chargedHadron = chargedHadrons.begin();
196 chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
197 std::cout <<
"chargedHadron #" << idx <<
":" << std::endl;
201 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
203 for ( PiZeroList::const_iterator piZero = piZeros.begin();
204 piZero != piZeros.end(); ++piZero ) {
205 std::cout <<
"piZero #" << idx <<
":" << std::endl;
220 for ( std::vector<decayModeInfo>::const_iterator decayMode =
decayModesToBuild_.begin();
223 size_t piZerosToBuild = decayMode->nPiZeros_;
225 size_t tracksToBuild = decayMode->nCharged_;
227 std::cout <<
"piZerosToBuild = " << piZerosToBuild << std::endl;
228 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
229 std::cout <<
"tracksToBuild = " << tracksToBuild << std::endl;
230 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
234 if ( chargedHadrons.size() < tracksToBuild )
continue;
237 ChargedHadronList::const_iterator chargedHadron_begin = chargedHadrons.begin();
238 ChargedHadronList::const_iterator chargedHadron_end = chargedHadrons.end();
239 chargedHadron_end =
takeNElements(chargedHadron_begin, chargedHadron_end, decayMode->maxPFCHs_);
242 ChargedHadronCombo trackCombos(chargedHadron_begin, chargedHadron_end, tracksToBuild);
244 PFCandPtrs::iterator pfch_end = pfchs.end();
245 pfch_end =
takeNElements(pfchs.begin(), pfch_end, decayMode->maxPFCHs_);
253 trackCombo != trackCombos.
end(); ++trackCombo ) {
255 trackCombo->combo_begin(), trackCombo->combo_end(),
258 PiZeroList cleanSignalPiZeros = signalPiZeroXCleaner(piZeros);
261 std::sort(cleanSignalPiZeros.begin(), cleanSignalPiZeros.end(), SortPi0sDescendingPt());
265 if ( cleanSignalPiZeros.size() < piZerosToBuild )
continue;
268 PiZeroList::iterator signalPiZero_begin = cleanSignalPiZeros.begin();
269 PiZeroList::iterator signalPiZero_end = cleanSignalPiZeros.end();
270 signalPiZero_end =
takeNElements(signalPiZero_begin, signalPiZero_end, decayMode->maxPiZeros_);
273 PiZeroCombo piZeroCombos(signalPiZero_begin, signalPiZero_end, piZerosToBuild);
276 piZeroCombo != piZeroCombos.
end(); ++piZeroCombo ) {
292 trackCombo->combo_begin(), trackCombo->combo_end(),
295 PiZeroList precleanedIsolationPiZeros = isolationPiZeroXCleaner(piZeros);
296 std::set<reco::CandidatePtr> toRemove;
298 signalPiZero != piZeroCombo->combo_end(); ++signalPiZero ) {
299 toRemove.insert(signalPiZero->daughterPtrVector().begin(), signalPiZero->daughterPtrVector().end());
302 BOOST_FOREACH(
const RecoTauPiZero& precleanedPiZero, precleanedIsolationPiZeros ) {
304 std::vector<reco::CandidatePtr> cleanDaughters;
305 std::set_difference(toCheck.begin(), toCheck.end(), toRemove.begin(), toRemove.end(), std::back_inserter(cleanDaughters));
308 cleanIsolationPiZeros.push_back(precleanedPiZero);
312 std::cout <<
"#cleanIsolationPiZeros = " << cleanIsolationPiZeros.size() << std::endl;
314 for ( PiZeroList::const_iterator piZero = cleanIsolationPiZeros.begin();
315 piZero != cleanIsolationPiZeros.end(); ++piZero ) {
316 std::cout <<
"piZero #" << idx <<
":" << std::endl;
330 (piZeros.size() - piZerosToBuild)*2);
333 (piZeros.size() - piZerosToBuild));
339 piZeroCombo->combo_begin(), piZeroCombo->combo_end());
349 trackCombo->combo_begin(), trackCombo->combo_end());
353 using namespace reco::tau::cone;
360 pfChargedHadronXCleanerType pfChargedHadronXCleaner_comboChargedHadrons(trackCombo->combo_begin(), trackCombo->combo_end());
367 pfCandXCleanerType pfCandXCleaner_allChargedHadrons(pfChargedHadronXCleaner_allChargedHadrons, piZeroXCleaner);
386 RegionalJunkConeAndIdFilter pfChargedJunk(
388 isolationConeFilter);
390 RegionalJunkConeAndIdFilter pfGammaJunk(
392 isolationConeFilter);
394 RegionalJunkConeAndIdFilter pfNeutralJunk(
396 isolationConeFilter);
400 boost::make_filter_iterator(
401 isolationConeFilterPiZero,
402 cleanIsolationPiZeros.begin(), cleanIsolationPiZeros.end()),
403 boost::make_filter_iterator(
404 isolationConeFilterPiZero,
405 cleanIsolationPiZeros.end(), cleanIsolationPiZeros.end()));
413 std::cout <<
"adding isolation PFChargedHadrons from trackCombo:" << std::endl;
417 boost::make_filter_iterator(
418 isolationConeFilterChargedHadron,
419 trackCombo->remainder_begin(), trackCombo->remainder_end()),
420 boost::make_filter_iterator(
421 isolationConeFilterChargedHadron,
422 trackCombo->remainder_end(), trackCombo->remainder_end()));
427 std::cout <<
"adding isolation PFChargedHadrons not considered in trackCombo:" << std::endl;
431 boost::make_filter_iterator(
432 pfCandFilter_comboChargedHadrons,
433 pfch_end, pfchs.end()),
434 boost::make_filter_iterator(
435 pfCandFilter_comboChargedHadrons,
436 pfchs.end(), pfchs.end()));
440 std::cout <<
"adding isolation PFChargedHadrons from 'regional junk':" << std::endl;
444 boost::make_filter_iterator(
445 pfChargedJunk, regionalJunk.begin(), regionalJunk.end()),
446 boost::make_filter_iterator(
447 pfChargedJunk, regionalJunk.end(), regionalJunk.end()));
451 std::cout <<
"adding isolation PFGammas not considered in PiZeros:" << std::endl;
455 boost::make_filter_iterator(
456 pfCandFilter_allChargedHadrons,
457 pfgammas.begin(), pfgammas.end()),
458 boost::make_filter_iterator(
459 pfCandFilter_allChargedHadrons,
460 pfgammas.end(), pfgammas.end()));
465 boost::make_filter_iterator(
466 pfGammaJunk, regionalJunk.begin(), regionalJunk.end()),
467 boost::make_filter_iterator(
468 pfGammaJunk, regionalJunk.end(), regionalJunk.end()));
473 boost::make_filter_iterator(
474 pfCandFilter_allChargedHadrons,
475 pfnhs.begin(), pfnhs.end()),
476 boost::make_filter_iterator(
477 pfCandFilter_allChargedHadrons,
478 pfnhs.end(), pfnhs.end()));
483 boost::make_filter_iterator(
484 pfNeutralJunk, regionalJunk.begin(), regionalJunk.end()),
485 boost::make_filter_iterator(
486 pfNeutralJunk, regionalJunk.end(), regionalJunk.end()));
488 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;
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
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
std::auto_ptr< output_type > return_type
return_type operator()(const reco::PFJetRef &, const std::vector< reco::PFRecoTauChargedHadron > &, const std::vector< RecoTauPiZero > &, const std::vector< PFCandidatePtr > &) const override
RecoTauBuilderCombinatoricPlugin(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
virtual ~RecoTauBuilderCombinatoricPlugin()
virtual double pt() const
transverse momentum
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)
void initialize(const PtrIter &chargedHadronsBegin, const PtrIter &chargedHadronsEnd)
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_
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
void reservePiZero(Region region, size_t size)
Reserve a set amount of space for the PiZeros.
std::vector< PFCandidatePtr > pfChargedCands(const PFJet &jet, bool sort=true)
Extract all non-neutral candidates from a PFJet.
double minRelPhotonSumPt_insideSignalCone_
const daughters & daughterPtrVector() const
references to daughtes
double square(const double a)
#define DEFINE_EDM_PLUGIN(factory, type, name)
double isolationConeSize_
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()