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 ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
113 daughter != daughters.end(); ++daughter ) {
124 for ( ChargedHadronList::const_iterator chargedHadron = chargedHadronsBegin; chargedHadron != chargedHadronsEnd; ++chargedHadron ) {
126 for ( reco::CompositePtrCandidate::daughters::const_iterator daughter = daughters.begin();
127 daughter != daughters.end(); ++daughter ) {
138 class SortPi0sDescendingPt
143 return a.
pt() > b.
pt();
164 const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons,
165 const std::vector<RecoTauPiZero>& piZeros,
166 const std::vector<PFCandidatePtr>& regionalExtras)
const
169 std::cout <<
"<RecoTauBuilderCombinatoricPlugin::operator()>:" << std::endl;
170 std::cout <<
" processing jet: Pt = " << jet->pt() <<
", eta = " << jet->eta() <<
", phi = " << jet->eta() <<
","
171 <<
" mass = " << jet->mass() <<
", area = " << jet->jetArea() << std::endl;
183 typedef std::vector<PFCandidatePtr>
PFCandPtrs;
186 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
188 for ( ChargedHadronList::const_iterator chargedHadron = chargedHadrons.begin();
189 chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
190 std::cout <<
"chargedHadron #" << idx <<
":" << std::endl;
194 std::cout <<
"#piZeros = " << piZeros.size() << std::endl;
196 for ( PiZeroList::const_iterator piZero = piZeros.begin();
197 piZero != piZeros.end(); ++piZero ) {
198 std::cout <<
"piZero #" << idx <<
": Pt = " << piZero->pt() <<
", eta = " << piZero->eta() <<
", phi = " << piZero->phi() << std::endl;
199 size_t numDaughters = piZero->numberOfDaughters();
200 for (
size_t iDaughter = 0; iDaughter < numDaughters; ++iDaughter ) {
202 std::cout <<
" daughter #" << iDaughter <<
" (" << getPFCandidateType(daughter->
particleId()) <<
"):"
203 <<
" Pt = " << daughter->
pt() <<
", eta = " << daughter->
eta() <<
", phi = " << daughter->
phi() << std::endl;
217 for ( std::vector<decayModeInfo>::const_iterator decayMode =
decayModesToBuild_.begin();
220 size_t piZerosToBuild = decayMode->nPiZeros_;
222 size_t tracksToBuild = decayMode->nCharged_;
224 std::cout <<
"piZerosToBuild = " << piZerosToBuild << std::endl;
225 std::cout <<
"tracksToBuild = " << tracksToBuild << std::endl;
226 std::cout <<
"#chargedHadrons = " << chargedHadrons.size() << std::endl;
230 if ( chargedHadrons.size() < tracksToBuild )
continue;
233 ChargedHadronList::const_iterator chargedHadron_begin = chargedHadrons.begin();
234 ChargedHadronList::const_iterator chargedHadron_end = chargedHadrons.end();
235 chargedHadron_end =
takeNElements(chargedHadron_begin, chargedHadron_end, decayMode->maxPFCHs_);
238 ChargedHadronCombo trackCombos(chargedHadron_begin, chargedHadron_end, tracksToBuild);
240 PFCandPtrs::iterator pfch_end = pfchs.end();
241 pfch_end =
takeNElements(pfchs.begin(), pfch_end, decayMode->maxPFCHs_);
249 trackCombo != trackCombos.
end(); ++trackCombo ) {
251 trackCombo->combo_begin(), trackCombo->combo_end(),
254 PiZeroList cleanSignalPiZeros = signalPiZeroXCleaner(piZeros);
257 std::sort(cleanSignalPiZeros.begin(), cleanSignalPiZeros.end(), SortPi0sDescendingPt());
261 if ( cleanSignalPiZeros.size() < piZerosToBuild )
continue;
264 PiZeroList::iterator signalPiZero_begin = cleanSignalPiZeros.begin();
265 PiZeroList::iterator signalPiZero_end = cleanSignalPiZeros.end();
266 signalPiZero_end =
takeNElements(signalPiZero_begin, signalPiZero_end, decayMode->maxPiZeros_);
269 PiZeroCombo piZeroCombos(signalPiZero_begin, signalPiZero_end, piZerosToBuild);
272 piZeroCombo != piZeroCombos.
end(); ++piZeroCombo ) {
285 trackCombo->combo_begin(), trackCombo->combo_end(),
288 PiZeroList precleanedIsolationPiZeros = isolationPiZeroXCleaner(piZeros);
289 std::set<reco::CandidatePtr> toRemove;
291 signalPiZero != piZeroCombo->combo_end(); ++signalPiZero ) {
292 toRemove.insert(signalPiZero->daughterPtrVector().begin(), signalPiZero->daughterPtrVector().end());
295 BOOST_FOREACH(
const RecoTauPiZero& precleanedPiZero, precleanedIsolationPiZeros ) {
297 std::vector<reco::CandidatePtr> cleanDaughters;
298 std::set_difference(toCheck.begin(), toCheck.end(), toRemove.begin(), toRemove.end(), std::back_inserter(cleanDaughters));
301 cleanIsolationPiZeros.push_back(precleanedPiZero);
313 (piZeros.size() - piZerosToBuild)*2);
316 (piZeros.size() - piZerosToBuild));
322 piZeroCombo->combo_begin(), piZeroCombo->combo_end());
332 trackCombo->combo_begin(), trackCombo->combo_end());
336 using namespace reco::tau::cone;
343 pfChargedHadronXCleanerType pfChargedHadronXCleaner_comboChargedHadrons(trackCombo->combo_begin(), trackCombo->combo_end());
350 pfCandXCleanerType pfCandXCleaner_allChargedHadrons(pfChargedHadronXCleaner_allChargedHadrons, piZeroXCleaner);
369 RegionalJunkConeAndIdFilter pfChargedJunk(
371 isolationConeFilter);
373 RegionalJunkConeAndIdFilter pfGammaJunk(
375 isolationConeFilter);
377 RegionalJunkConeAndIdFilter pfNeutralJunk(
379 isolationConeFilter);
383 boost::make_filter_iterator(
384 isolationConeFilterPiZero,
385 cleanIsolationPiZeros.begin(), cleanIsolationPiZeros.end()),
386 boost::make_filter_iterator(
387 isolationConeFilterPiZero,
388 cleanIsolationPiZeros.end(), cleanIsolationPiZeros.end()));
396 std::cout <<
"adding isolation PFChargedHadrons from trackCombo:" << std::endl;
400 boost::make_filter_iterator(
401 isolationConeFilterChargedHadron,
402 trackCombo->remainder_begin(), trackCombo->remainder_end()),
403 boost::make_filter_iterator(
404 isolationConeFilterChargedHadron,
405 trackCombo->remainder_end(), trackCombo->remainder_end()));
410 std::cout <<
"adding isolation PFChargedHadrons not considered in trackCombo:" << std::endl;
414 boost::make_filter_iterator(
415 pfCandFilter_comboChargedHadrons,
416 pfch_end, pfchs.end()),
417 boost::make_filter_iterator(
418 pfCandFilter_comboChargedHadrons,
419 pfchs.end(), pfchs.end()));
423 std::cout <<
"adding isolation PFChargedHadrons from 'regional junk':" << std::endl;
427 boost::make_filter_iterator(
428 pfChargedJunk, regionalJunk.begin(), regionalJunk.end()),
429 boost::make_filter_iterator(
430 pfChargedJunk, regionalJunk.end(), regionalJunk.end()));
436 boost::make_filter_iterator(
437 pfGammaJunk, regionalJunk.begin(), regionalJunk.end()),
438 boost::make_filter_iterator(
439 pfGammaJunk, regionalJunk.end(), regionalJunk.end()));
444 boost::make_filter_iterator(
445 pfCandFilter_allChargedHadrons,
446 pfnhs.begin(), pfnhs.end()),
447 boost::make_filter_iterator(
448 pfCandFilter_allChargedHadrons,
449 pfnhs.end(), pfnhs.end()));
454 boost::make_filter_iterator(
455 pfNeutralJunk, regionalJunk.begin(), regionalJunk.end()),
456 boost::make_filter_iterator(
457 pfNeutralJunk, regionalJunk.end(), regionalJunk.end()));
459 std::auto_ptr<reco::PFTau> tauPtr = tau.
get(
true);
461 if ( primaryVertexRef.
isNonnull() ) tauPtr->setVertex(primaryVertexRef->position());
463 output.push_back(tauPtr);
468 return output.release();
476 "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()