16 namespace reco {
namespace tau {
23 const std::vector<RecoTauPiZero>& piZeros,
24 const std::vector<PFCandidatePtr>& regionalExtras)
const;
42 usePFLeptonsAsChargedHadrons_(pset.getParameter<bool>(
"usePFLeptons")),
43 isolationConeSize_(pset.getParameter<double>(
"isolationConeSize")) {
44 typedef std::vector<edm::ParameterSet> VPSet;
45 const VPSet& decayModes = pset.
getParameter<VPSet>(
"decayModes");
46 for (VPSet::const_iterator dm = decayModes.begin();
47 dm != decayModes.end(); ++dm) {
49 info.
nCharged_ = dm->getParameter<uint32_t>(
"nCharged");
50 info.
nPiZeros_ = dm->getParameter<uint32_t>(
"nPiZeros");
51 info.
maxPFCHs_ = dm->getParameter<uint32_t>(
"maxTracks");
52 info.
maxPiZeros_ = dm->getParameter<uint32_t>(
"maxPiZeros");
59 class SortPi0sDescendingPt {
62 return a.
pt() > b.
pt();
70 const std::vector<RecoTauPiZero>& piZeros,
71 const std::vector<PFCandidatePtr>& regionalExtras)
const
75 typedef std::vector<PFCandidatePtr>
PFCandPtrs;
76 typedef std::vector<RecoTauPiZero> PiZeroList;
118 for (std::vector<decayModeInfo>::const_iterator
122 size_t piZerosToBuild = decayMode->nPiZeros_;
125 size_t tracksToBuild = decayMode->nCharged_;
129 if (pfchs.size() < tracksToBuild)
133 PFCandPtrs::iterator pfch_begin = pfchs.begin();
134 PFCandPtrs::iterator pfch_end = pfchs.end();
135 pfch_end =
takeNElements(pfch_begin, pfch_end, decayMode->maxPFCHs_);
139 PFCombo trackCombos(pfch_begin, pfch_end, tracksToBuild);
145 for (PFCombo::iterator trackCombo = trackCombos.begin();
146 trackCombo != trackCombos.end(); ++trackCombo) {
148 xCleaner(trackCombo->combo_begin(), trackCombo->combo_end());
150 PiZeroList cleanPiZeros = xCleaner(piZeros);
153 std::sort(cleanPiZeros.begin(), cleanPiZeros.end(), SortPi0sDescendingPt());
157 if (cleanPiZeros.size() < piZerosToBuild)
161 PiZeroList::iterator piZero_begin = cleanPiZeros.begin();
162 PiZeroList::iterator piZero_end = cleanPiZeros.end();
165 decayMode->maxPiZeros_);
169 PiZeroCombo piZeroCombos(piZero_begin, piZero_end, piZerosToBuild);
171 for (PiZeroCombo::iterator piZeroCombo = piZeroCombos.begin();
172 piZeroCombo != piZeroCombos.end(); ++piZeroCombo) {
190 (cleanPiZeros.size() - piZerosToBuild)*2);
192 (cleanPiZeros.size() - piZerosToBuild));
198 trackCombo->combo_begin(), trackCombo->combo_end()
205 piZeroCombo->combo_begin(), piZeroCombo->combo_end()
210 using namespace reco::tau::cone;
219 pfCandFilter(isolationConeFilter, pfCandXCleaner);
236 RegionalJunkConeAndIdFilter pfChargedJunk(
241 RegionalJunkConeAndIdFilter pfGammaJunk(
246 RegionalJunkConeAndIdFilter pfNeutralJunk(
254 boost::make_filter_iterator(
256 trackCombo->remainder_begin(), trackCombo->remainder_end()),
257 boost::make_filter_iterator(
259 trackCombo->remainder_end(), trackCombo->remainder_end())
266 boost::make_filter_iterator(
268 pfch_end, pfchs.end()),
269 boost::make_filter_iterator(
271 pfchs.end(), pfchs.end())
277 boost::make_filter_iterator(
278 pfChargedJunk, regionalJunk.begin(), regionalJunk.end()),
279 boost::make_filter_iterator(
280 pfChargedJunk, regionalJunk.end(), regionalJunk.end())
287 boost::make_filter_iterator(
288 pfGammaJunk, regionalJunk.begin(), regionalJunk.end()),
289 boost::make_filter_iterator(
290 pfGammaJunk, regionalJunk.end(), regionalJunk.end())
296 boost::make_filter_iterator(
298 pfnhs.begin(), pfnhs.end()),
299 boost::make_filter_iterator(
301 pfnhs.end(), pfnhs.end())
307 boost::make_filter_iterator(
308 pfNeutralJunk, regionalJunk.begin(), regionalJunk.end()),
309 boost::make_filter_iterator(
310 pfNeutralJunk, regionalJunk.end(), regionalJunk.end())
315 boost::make_filter_iterator(
316 isolationConeFilterPiZero,
317 piZeroCombo->remainder_begin(), piZeroCombo->remainder_end()),
318 boost::make_filter_iterator(
319 isolationConeFilterPiZero,
320 piZeroCombo->remainder_end(), piZeroCombo->remainder_end())
325 boost::make_filter_iterator(
326 isolationConeFilterPiZero,
327 piZero_end, cleanPiZeros.end()),
328 boost::make_filter_iterator(
329 isolationConeFilterPiZero,
330 cleanPiZeros.end(), cleanPiZeros.end())
333 std::auto_ptr<reco::PFTau> tauPtr = tau.
get(
true);
336 tauPtr->setVertex(primaryVertexRef->position());
338 output.push_back(tauPtr);
342 return output.release();
349 "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)
void reserve(Region region, ParticleType type, size_t size)
Reserve a set amount of space for a given RefVector.
Coll filterRefs(const Coll &refcoll, bool invert=false) const
Filter a ref vector of PFCandidates.
ParameterSet const & getParameterSet(ParameterSetID const &id)
std::vector< reco::PFCandidatePtr > PFCandPtrs
boost::ptr_vector< reco::PFTau > output_type
std::auto_ptr< output_type > return_type
virtual ~RecoTauBuilderCombinatoricPlugin()
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 pi zeros to the input collection.
bool isNonnull() const
Checks for non-null.
std::vector< decayModeInfo > decayModesToBuild_
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.
bool usePFLeptonsAsChargedHadrons_
const reco::Candidate::LorentzVector & p4() const
virtual return_type operator()(const reco::PFJetRef &jet, const std::vector< RecoTauPiZero > &piZeros, const std::vector< PFCandidatePtr > ®ionalExtras) const
void addPFCands(Region region, ParticleType type, const InputIterator &begin, const InputIterator &end)
RecoTauQualityCuts qcuts_
virtual double pt() const
transverse momentum
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.
RecoTauBuilderCombinatoricPlugin(const edm::ParameterSet &pset)
#define DEFINE_EDM_PLUGIN(factory, type, name)
double isolationConeSize_
Transform a pizero to remove given candidates.