CMS 3D CMS Logo

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 
20 
23 
29 
31  public:
33  ~PFTauViewRefSelector() override {}
34  bool filter(edm::Event& evt, const edm::EventSetup& es) override;
35  private:
38  std::unique_ptr<StringCutObjectSelector<reco::PFTau> > outputSelector_;
39  bool filter_;
40 };
41 
43  src_ = pset.getParameter<edm::InputTag>("src");
44  std::string cut = pset.getParameter<std::string>("cut");
45  filter_ = pset.exists("filter") ? pset.getParameter<bool>("filter") : false;
46  outputSelector_ = std::make_unique<StringCutObjectSelector<reco::PFTau>>(cut);
47  produces<reco::PFTauRefVector>();
48 }
49 
50 bool
52  auto output = std::make_unique<reco::PFTauRefVector>();
53  // Get the input collection to clean
55  evt.getByLabel(src_, input);
56  // Cast the input candidates to Refs to real taus
57  reco::PFTauRefVector inputRefs =
58  reco::tau::castView<reco::PFTauRefVector>(input);
59 
60  for(auto const& tau : inputRefs) {
61  if (outputSelector_.get() && (*outputSelector_)(*tau)) {
62  output->push_back(tau);
63  }
64  }
65  size_t outputSize = output->size();
66  evt.put(std::move(output));
67  // Filter if desired and no objects passed our cut
68  return !(filter_ && outputSize == 0);
69 }
70 
72 
75 typedef SingleObjectSelector<
79 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
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:48
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::unique_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
bool filter(edm::Event &evt, const edm::EventSetup &es) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
PFTauViewRefSelector(const edm::ParameterSet &pset)
def move(src, dest)
Definition: eostools.py:511