CMS 3D CMS Logo

PFTauViewRefDiscriminantSelector.cc
Go to the documentation of this file.
1 /*
2  * Produce a RefVector of PFTaus that pass a given selection on
3  * the input discriminator collection.
4  *
5  * Parameters:
6  * InputTag src = View of PFTaus
7  * InputTag disc = discriinator
8  * double cut
9  *
10  * Author: Evan K. Friis (UC Davis)
11  *
12  */
13 
14 #include <boost/foreach.hpp>
15 #include <memory>
16 
25 
27  public:
28  typedef std::vector<reco::PFTau> OutputType;
30  return *ref;
31  }
32 };
33 
35  public:
38  return edm::RefToBase<reco::PFTau>(ref);
39  }
40 };
41 
43  public:
46  return ref;
47  }
48 };
49 
50 
51 template<typename T>
53  public:
56  bool filter(edm::Event &evt, const edm::EventSetup &es) override;
57  private:
58  typedef typename T::OutputType OutputType;
61  double cut_;
62  bool filter_;
63 };
64 
65 template<typename T>
67  const edm::ParameterSet &pset) {
68  src_ = pset.getParameter<edm::InputTag>("src");
69  discriminatorSrc_ = pset.getParameter<edm::InputTag>("discriminator");
70  cut_ = pset.getParameter<double>("cut");
71  filter_ = pset.getParameter<bool>("filter");
72  //produces<reco::PFTauRefVector>();
73  produces<OutputType>();
74 }
75 
76 
77 template<typename T>
79  const edm::EventSetup &es) {
81  evt.getByLabel(src_, input);
82  reco::PFTauRefVector inputRefs =
83  reco::tau::castView<reco::PFTauRefVector>(input);
84 
86  evt.getByLabel(discriminatorSrc_, disc);
87 
88 // auto output = std::make_unique<reco::PFTauRefVector>(inputRefs.id());
89  //auto output = std::make_unique<OutputType>(inputRefs.id());
90  auto output = std::make_unique<OutputType>();
91 
92  BOOST_FOREACH(reco::PFTauRef ref, inputRefs) {
93  if ( (*disc)[ref] > cut_ )
94  output->push_back(T::make(ref));
95  }
96  size_t selected = output->size();
97  evt.put(std::move(output));
98  return (!filter_ || selected);
99 }
100 
103 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
S make(const edm::ParameterSet &cfg)
std::vector< reco::PFTau > OutputType
static std::string const input
Definition: EdmProvDump.cc:44
RecoTauDiscriminatorRefSelectorImpl(const edm::ParameterSet &pset)
static OutputType::value_type make(const reco::PFTauRef &ref)
bool filter(edm::Event &evt, const edm::EventSetup &es) override
static OutputType::value_type make(const reco::PFTauRef &ref)
RecoTauDiscriminatorRefSelectorImpl< RefVectorBuilder > RecoTauDiscriminatorRefSelector
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:464
RecoTauDiscriminatorRefSelectorImpl< ConcreteTauBuilder > RecoTauDiscriminatorSelector
edm::RefToBaseVector< reco::PFTau > OutputType
static OutputType::value_type make(const reco::PFTauRef &ref)
def move(src, dest)
Definition: eostools.py:510