14 #include <boost/ptr_container/ptr_vector.hpp>
15 #include <boost/ptr_container/ptr_list.hpp>
16 #include <boost/foreach.hpp>
48 void print(
const std::vector<reco::RecoTauPiZero>& piZeros,
66 std::auto_ptr<StringCutObjectSelector<reco::RecoTauPiZero> >
79 typedef std::vector<edm::ParameterSet>
VPSet;
86 for (VPSet::const_iterator builderPSet = builders.begin();
87 builderPSet != builders.end(); ++builderPSet) {
97 const VPSet& rankers = pset.
getParameter<VPSet>(
"ranking");
98 for (VPSet::const_iterator rankerPSet = rankers.begin();
99 rankerPSet != rankers.end(); ++rankerPSet) {
103 pluginType, *rankerPSet));
110 if (pset.
exists(
"outputSelection")) {
112 if (selection !=
"") {
121 produces<reco::JetPiZeroAssociation>();
132 builder.
setup(evt, es);
137 reco::tau::castView<reco::PFJetRefVector>(jetView);
139 std::unique_ptr<reco::JetPiZeroAssociation> association;
141 if (jetRefs.
size()) {
143 evt.
get(jetRefs.
id(), pfJetCollectionHandle);
144 association = std::make_unique<reco::JetPiZeroAssociation>(
reco::PFJetRefProd(pfJetCollectionHandle));
146 association = std::make_unique<reco::JetPiZeroAssociation>();
158 dirtyPiZeros.transfer(dirtyPiZeros.end(),
result);
161 <<
"Exception caught in builder plugin " << builder.
name()
162 <<
", rethrowing" << std::endl;
170 std::vector<reco::RecoTauPiZero> cleanPiZeros;
171 std::set<reco::CandidatePtr> photonsInCleanCollection;
172 while (dirtyPiZeros.size()) {
174 std::auto_ptr<reco::RecoTauPiZero>
toAdd(
175 dirtyPiZeros.pop_front().release());
181 std::vector<reco::CandidatePtr> uniqueGammas;
182 std::set_difference(
toAdd->daughterPtrVector().begin(),
183 toAdd->daughterPtrVector().end(),
184 photonsInCleanCollection.begin(),
185 photonsInCleanCollection.end(),
186 std::back_inserter(uniqueGammas));
189 if (!uniqueGammas.size()) {
191 }
else if (uniqueGammas.size() ==
toAdd->daughterPtrVector().size()) {
194 photonsInCleanCollection.insert(
toAdd->daughterPtrVector().begin(),
195 toAdd->daughterPtrVector().end());
196 cleanPiZeros.push_back(*
toAdd);
200 toAdd->clearDaughters();
203 toAdd->addDaughter(gamma);
209 PiZeroList::iterator insertionPoint = std::lower_bound(
211 dirtyPiZeros.insert(insertionPoint,
toAdd);
217 cleanPiZeros.begin(), cleanPiZeros.end(),
225 association->setValue(jet.
key(), cleanPiZeros);
232 const std::vector<reco::RecoTauPiZero>& piZeros, std::ostream&
out) {
233 const unsigned int width = 25;
236 out <<
"* Rankers:" << std::endl;
237 for (rankerList::const_iterator ranker =
rankers_.begin();
238 ranker !=
rankers_.end(); ++ranker) {
239 out <<
"* " << std::setiosflags(std::ios::left)
240 << std::setw(width) << ranker->name()
241 <<
" " << std::resetiosflags(std::ios::left)
242 << std::setprecision(3) << (*ranker)(piZero);
T getParameter(std::string const &) const
void produce(edm::Event &evt, const edm::EventSetup &es) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< reco::CandidateView > cand_token
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
reco::tau::RecoTauPiZeroQualityPlugin Ranker
bool exists(std::string const ¶meterName) const
checks if a parameter exists
RecoTauPiZeroProducer(const edm::ParameterSet &pset)
reco::tau::RecoTauLexicographicalRanking< rankerList, reco::RecoTauPiZero > PiZeroPredicate
key_type key() const
Accessor for product key.
void print(const std::vector< reco::RecoTauPiZero > &piZeros, std::ostream &out)
void setup(edm::Event &, const edm::EventSetup &)
reco::tau::RecoTauPiZeroBuilderPlugin Builder
ProductID id() const
Accessor for product ID.
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
bool get(ProductID const &oid, Handle< PROD > &result) const
edm::RefProd< PFJetCollection > PFJetRefProd
boost::ptr_vector< reco::RecoTauPiZero > PiZeroVector
boost::ptr_vector< Builder > builderList
boost::ptr_list< reco::RecoTauPiZero > PiZeroList
size_type size() const
Size of the RefVector.
virtual void setMass(double m) final
set particle mass
boost::ptr_vector< Ranker > rankerList
void set(reco::Candidate &c) const
set up a candidate
std::auto_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
const std::string & name() const
T get(const Candidate &c)
std::auto_ptr< PiZeroPredicate > predicate_