17 namespace reco {
namespace tau {
32 const std::vector<reco::PFRecoTauChargedHadron>&,
33 const std::vector<RecoTauPiZero>&,
34 const std::vector<PFCandidatePtr>&)
const override;
56 isolationConeSize_(pset.getParameter<double>(
"isolationConeSize"))
58 typedef std::vector<edm::ParameterSet> VPSet;
59 const VPSet& decayModes = pset.
getParameter<VPSet>(
"decayModes");
60 for ( VPSet::const_iterator decayMode = decayModes.begin();
61 decayMode != decayModes.end(); ++decayMode ) {
63 info.
nCharged_ = decayMode->getParameter<uint32_t>(
"nCharged");
64 info.
nPiZeros_ = decayMode->getParameter<uint32_t>(
"nPiZeros");
65 info.
maxPFCHs_ = decayMode->getParameter<uint32_t>(
"maxTracks");
66 info.
maxPiZeros_ = decayMode->getParameter<uint32_t>(
"maxPiZeros");
86 if ( mode_ == kRemoveChargedDaughterOverlaps ) {
87 if ( chargedHadron->getChargedPFCandidate().isNonnull() ) toRemove_.insert(
reco::CandidatePtr(chargedHadron->getChargedPFCandidate()));
88 }
else if ( mode_ == kRemoveChargedAndNeutralDaughterOverlaps ) {
90 for ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
91 daughter != daughters.end(); ++daughter ) {
112 for ( ChargedHadronList::const_iterator chargedHadron = chargedHadronsBegin; chargedHadron != chargedHadronsEnd; ++chargedHadron ) {
114 for ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
115 daughter != daughters.end(); ++daughter ) {
126 class SortPi0sDescendingPt
131 return a.
pt() > b.
pt();
152 const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons,
153 const std::vector<RecoTauPiZero>& piZeros,
154 const std::vector<PFCandidatePtr>& regionalExtras)
const
157 std::cout <<
"<RecoTauBuilderCombinatoricPlugin::operator()>:" << std::endl;
158 std::cout <<
" processing jet: Pt = " << jet->pt() <<
", eta = " << jet->eta() <<
", phi = " << jet->eta() <<
","
159 <<
" mass = " << jet->mass() <<
", area = " << jet->jetArea() << std::endl;
171 typedef std::vector<PFCandidatePtr>
PFCandPtrs;
174 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
176 for ( ChargedHadronList::const_iterator chargedHadron = chargedHadrons.begin();
177 chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
178 std::cout <<
"chargedHadron #" << idx <<
":" << std::endl;
182 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
184 for ( PiZeroList::const_iterator piZero = piZeros.begin();
185 piZero != piZeros.end(); ++piZero ) {
186 std::cout <<
"piZero #" << idx <<
": Pt = " << piZero->pt() <<
", eta = " << piZero->eta() <<
", phi = " << piZero->phi() << std::endl;
187 size_t numDaughters = piZero->numberOfDaughters();
188 for (
size_t iDaughter = 0; iDaughter < numDaughters; ++iDaughter ) {
190 std::cout <<
" daughter #" << iDaughter <<
" (" << getPFCandidateType(daughter->
particleId()) <<
"):"
191 <<
" Pt = " << daughter->
pt() <<
", eta = " << daughter->
eta() <<
", phi = " << daughter->
phi() << std::endl;
205 for ( std::vector<decayModeInfo>::const_iterator decayMode =
decayModesToBuild_.begin();
208 size_t piZerosToBuild = decayMode->nPiZeros_;
210 size_t tracksToBuild = decayMode->nCharged_;
212 std::cout <<
"piZerosToBuild = " << piZerosToBuild << std::endl;
213 std::cout <<
"tracksToBuild = " << tracksToBuild << std::endl;
217 if ( chargedHadrons.size() < tracksToBuild )
continue;
220 ChargedHadronList::const_iterator chargedHadron_begin = chargedHadrons.begin();
221 ChargedHadronList::const_iterator chargedHadron_end = chargedHadrons.end();
222 chargedHadron_end =
takeNElements(chargedHadron_begin, chargedHadron_end, decayMode->maxPFCHs_);
225 ChargedHadronCombo trackCombos(chargedHadron_begin, chargedHadron_end, tracksToBuild);
227 PFCandPtrs::iterator pfch_end = pfchs.end();
228 pfch_end =
takeNElements(pfchs.begin(), pfch_end, decayMode->maxPFCHs_);
236 trackCombo != trackCombos.
end(); ++trackCombo ) {
238 trackCombo->combo_begin(), trackCombo->combo_end(),
241 PiZeroList cleanSignalPiZeros = signalPiZeroXCleaner(piZeros);
244 std::sort(cleanSignalPiZeros.begin(), cleanSignalPiZeros.end(), SortPi0sDescendingPt());
248 if ( cleanSignalPiZeros.size() < piZerosToBuild )
continue;
251 PiZeroList::iterator signalPiZero_begin = cleanSignalPiZeros.begin();
252 PiZeroList::iterator signalPiZero_end = cleanSignalPiZeros.end();
253 signalPiZero_end =
takeNElements(signalPiZero_begin, signalPiZero_end, decayMode->maxPiZeros_);
256 PiZeroCombo piZeroCombos(signalPiZero_begin, signalPiZero_end, piZerosToBuild);
259 piZeroCombo != piZeroCombos.
end(); ++piZeroCombo ) {
272 trackCombo->combo_begin(), trackCombo->combo_end(),
275 PiZeroList precleanedIsolationPiZeros = isolationPiZeroXCleaner(piZeros);
276 std::set<reco::CandidatePtr> toRemove;
278 signalPiZero != piZeroCombo->combo_end(); ++signalPiZero ) {
279 toRemove.insert(signalPiZero->daughterPtrVector().begin(), signalPiZero->daughterPtrVector().end());
282 BOOST_FOREACH(
const RecoTauPiZero& precleanedPiZero, precleanedIsolationPiZeros ) {
284 std::vector<reco::CandidatePtr> cleanDaughters;
285 std::set_difference(toCheck.begin(), toCheck.end(), toRemove.begin(), toRemove.end(), std::back_inserter(cleanDaughters));
288 cleanIsolationPiZeros.push_back(precleanedPiZero);
300 (piZeros.size() - piZerosToBuild)*2);
303 (piZeros.size() - piZerosToBuild));
309 piZeroCombo->combo_begin(), piZeroCombo->combo_end());
319 trackCombo->combo_begin(), trackCombo->combo_end());
323 using namespace reco::tau::cone;
334 pfCandXCleanerType pfCandXCleaner(pfCandXCleaner_chargedHadrons, pfCandXCleaner_pizeros);
353 RegionalJunkConeAndIdFilter pfChargedJunk(
355 isolationConeFilter);
357 RegionalJunkConeAndIdFilter pfGammaJunk(
359 isolationConeFilter);
361 RegionalJunkConeAndIdFilter pfNeutralJunk(
363 isolationConeFilter);
367 boost::make_filter_iterator(
368 isolationConeFilterPiZero,
369 cleanIsolationPiZeros.begin(), cleanIsolationPiZeros.end()),
370 boost::make_filter_iterator(
371 isolationConeFilterPiZero,
372 cleanIsolationPiZeros.end(), cleanIsolationPiZeros.end()));
381 boost::make_filter_iterator(
382 isolationConeFilterChargedHadron,
383 trackCombo->remainder_begin(), trackCombo->remainder_end()),
384 boost::make_filter_iterator(
385 isolationConeFilterChargedHadron,
386 trackCombo->remainder_end(), trackCombo->remainder_end()));
392 boost::make_filter_iterator(
394 pfch_end, pfchs.end()),
395 boost::make_filter_iterator(
397 pfchs.end(), pfchs.end()));
402 boost::make_filter_iterator(
403 pfChargedJunk, regionalJunk.begin(), regionalJunk.end()),
404 boost::make_filter_iterator(
405 pfChargedJunk, regionalJunk.end(), regionalJunk.end()));
411 boost::make_filter_iterator(
412 pfGammaJunk, regionalJunk.begin(), regionalJunk.end()),
413 boost::make_filter_iterator(
414 pfGammaJunk, regionalJunk.end(), regionalJunk.end()));
419 boost::make_filter_iterator(
421 pfnhs.begin(), pfnhs.end()),
422 boost::make_filter_iterator(
424 pfnhs.end(), pfnhs.end()));
429 boost::make_filter_iterator(
430 pfNeutralJunk, regionalJunk.begin(), regionalJunk.end()),
431 boost::make_filter_iterator(
432 pfNeutralJunk, regionalJunk.end(), regionalJunk.end()));
434 std::auto_ptr<reco::PFTau> tauPtr = tau.
get(
true);
436 if ( primaryVertexRef.
isNonnull() ) tauPtr->setVertex(primaryVertexRef->position());
438 output.push_back(tauPtr);
443 return output.release();
451 "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)
ParticleType
particle types
std::auto_ptr< reco::PFTau > get(bool setupLeadingCandidates=true)
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
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()
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.
bool isNonnull() const
Checks for non-null.
std::vector< decayModeInfo > decayModesToBuild_
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
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.
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
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
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.
Particle reconstructed by the particle flow algorithm.
std::vector< PFCandidatePtr > pfChargedCands(const PFJet &jet, bool sort=true)
Extract all non-neutral candidates from a PFJet.
const daughters & daughterPtrVector() const
references to daughtes
#define DEFINE_EDM_PLUGIN(factory, type, name)
double isolationConeSize_
virtual ParticleType particleId() const
virtual float pt() const GCC11_FINAL
transverse momentum
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()