CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFTauViewRefSelector.cc
Go to the documentation of this file.
1 /* \class CandViewRefSelector
2  *
3  * PFTau Selector based on a configurable cut.
4  * Reads a edm::View<PFTau> as input
5  * and saves a vector of references
6  * Usage:
7  *
8  * module selectedCands = PFTauViewRefSelector {
9  * InputTag src = myCollection
10  * string cut = "pt > 15.0"
11  * };
12  *
13  * \author: Luca Lista, INFN
14  * \modifications: Evan Friis, UC Davis
15  *
16  */
17 
18 #include <boost/foreach.hpp>
19 
22 
25 
31 
33  public:
34  explicit PFTauViewRefSelector(const edm::ParameterSet &pset);
36  bool filter(edm::Event& evt, const edm::EventSetup& es) override;
37  private:
40  std::auto_ptr<StringCutObjectSelector<reco::PFTau> > outputSelector_;
41  bool filter_;
42 };
43 
45  src_ = pset.getParameter<edm::InputTag>("src");
46  std::string cut = pset.getParameter<std::string>("cut");
47  filter_ = pset.exists("filter") ? pset.getParameter<bool>("filter") : false;
49  produces<reco::PFTauRefVector>();
50 }
51 
52 bool
54  std::auto_ptr<reco::PFTauRefVector> output(new reco::PFTauRefVector());
55  // Get the input collection to clean
57  evt.getByLabel(src_, input);
58  // Cast the input candidates to Refs to real taus
59  reco::PFTauRefVector inputRefs =
60  reco::tau::castView<reco::PFTauRefVector>(input);
61 
62  BOOST_FOREACH(const reco::PFTauRef &tau, inputRefs) {
63  if (outputSelector_.get() && (*outputSelector_)(*tau)) {
64  output->push_back(tau);
65  }
66  }
67  size_t outputSize = output->size();
68  evt.put(output);
69  // Filter if desired and no objects passed our cut
70  return !(filter_ && outputSize == 0);
71 }
72 
74 
77 typedef SingleObjectSelector<
81 
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool exists(std::string const &parameterName) const
checks if a parameter exists
SingleObjectSelector< edm::View< reco::Jet >, StringCutObjectSelector< reco::Jet, true > > JetViewRefSelector
static std::string const input
Definition: EdmProvDump.cc:44
bool filter(edm::Event &evt, const edm::EventSetup &es) override
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
PFTauViewRefSelector(const edm::ParameterSet &pset)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64