test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // std::auto_ptr<reco::PFTauRefVector> output(
89 // new reco::PFTauRefVector(inputRefs.id()));
90  //std::auto_ptr<OutputType> output(
91  // new OutputType(inputRefs.id()));
92  std::auto_ptr<OutputType> output(new OutputType);
93 
94  BOOST_FOREACH(reco::PFTauRef ref, inputRefs) {
95  if ( (*disc)[ref] > cut_ )
96  output->push_back(T::make(ref));
97  }
98  size_t selected = output->size();
99  evt.put(output);
100  return (!filter_ || selected);
101 }
102 
105 
T getParameter(std::string const &) const
#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)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
RecoTauDiscriminatorRefSelectorImpl< RefVectorBuilder > RecoTauDiscriminatorRefSelector
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
RecoTauDiscriminatorRefSelectorImpl< ConcreteTauBuilder > RecoTauDiscriminatorSelector
edm::RefToBaseVector< reco::PFTau > OutputType
static OutputType::value_type make(const reco::PFTauRef &ref)