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> >
84 typedef std::vector<edm::ParameterSet>
VPSet;
91 for (VPSet::const_iterator builderPSet = builders.begin();
92 builderPSet != builders.end(); ++builderPSet) {
102 const VPSet& rankers = pset.
getParameter<VPSet>(
"ranking");
103 for (VPSet::const_iterator rankerPSet = rankers.begin();
104 rankerPSet != rankers.end(); ++rankerPSet) {
108 pluginType, *rankerPSet));
115 if (pset.
exists(
"outputSelection")) {
117 if (selection !=
"") {
126 produces<reco::JetPiZeroAssociation>();
137 builder.
setup(evt, es);
142 reco::tau::castView<reco::PFJetRefVector>(jetView);
144 std::unique_ptr<reco::JetPiZeroAssociation>
association;
146 if (!jetRefs.
empty()) {
148 evt.
get(jetRefs.
id(), pfJetCollectionHandle);
149 association = std::make_unique<reco::JetPiZeroAssociation>(
reco::PFJetRefProd(pfJetCollectionHandle));
151 association = std::make_unique<reco::JetPiZeroAssociation>();
166 dirtyPiZeros.transfer(dirtyPiZeros.end(),
result);
169 <<
"Exception caught in builder plugin " << builder.
name()
170 <<
", rethrowing" << std::endl;
178 std::vector<reco::RecoTauPiZero> cleanPiZeros;
179 std::set<reco::CandidatePtr> photonsInCleanCollection;
180 while (!dirtyPiZeros.empty()) {
182 std::auto_ptr<reco::RecoTauPiZero>
toAdd(
183 dirtyPiZeros.pop_front().release());
189 std::vector<reco::CandidatePtr> uniqueGammas;
190 std::set_difference(
toAdd->daughterPtrVector().begin(),
191 toAdd->daughterPtrVector().end(),
192 photonsInCleanCollection.begin(),
193 photonsInCleanCollection.end(),
194 std::back_inserter(uniqueGammas));
197 if (uniqueGammas.empty()) {
199 }
else if (uniqueGammas.size() ==
toAdd->daughterPtrVector().size()) {
202 photonsInCleanCollection.insert(
toAdd->daughterPtrVector().begin(),
203 toAdd->daughterPtrVector().end());
204 cleanPiZeros.push_back(*
toAdd);
208 toAdd->clearDaughters();
211 toAdd->addDaughter(gamma);
217 PiZeroList::iterator insertionPoint = std::lower_bound(
219 dirtyPiZeros.insert(insertionPoint,
toAdd);
225 cleanPiZeros.begin(), cleanPiZeros.end(),
233 association->setValue(jet.
key(), cleanPiZeros);
240 const std::vector<reco::RecoTauPiZero>& piZeros, std::ostream&
out) {
241 const unsigned int width = 25;
244 out <<
"* Rankers:" << std::endl;
245 for (rankerList::const_iterator ranker =
rankers_.begin();
246 ranker !=
rankers_.end(); ++ranker) {
247 out <<
"* " << std::setiosflags(std::ios::left)
248 << std::setw(width) << ranker->name()
249 <<
" " << std::resetiosflags(std::ios::left)
250 << 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.
void setMass(double m) final
set particle mass
def create(alignables, pedeDump, additionalData, outputFile, config)
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.
bool empty() const
Is the RefVector empty.
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.
Abs< T >::type abs(const T &t)
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
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
~RecoTauPiZeroProducer() override
T get(const Candidate &c)
std::auto_ptr< PiZeroPredicate > predicate_