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 <memory>
15 
24 
26  public:
27  typedef std::vector<reco::PFTau> OutputType;
29  return *ref;
30  }
31 };
32 
34  public:
37  return edm::RefToBase<reco::PFTau>(ref);
38  }
39 };
40 
42  public:
45  return ref;
46  }
47 };
48 
49 
50 template<typename T>
52  public:
55  bool filter(edm::Event &evt, const edm::EventSetup &es) override;
56  private:
57  typedef typename T::OutputType OutputType;
60  double cut_;
61  bool filter_;
62 };
63 
64 template<typename T>
66  const edm::ParameterSet &pset) {
67  src_ = pset.getParameter<edm::InputTag>("src");
68  discriminatorSrc_ = pset.getParameter<edm::InputTag>("discriminator");
69  cut_ = pset.getParameter<double>("cut");
70  filter_ = pset.getParameter<bool>("filter");
71  //produces<reco::PFTauRefVector>();
72  produces<OutputType>();
73 }
74 
75 
76 template<typename T>
78  const edm::EventSetup &es) {
80  evt.getByLabel(src_, input);
81  reco::PFTauRefVector inputRefs =
82  reco::tau::castView<reco::PFTauRefVector>(input);
83 
85  evt.getByLabel(discriminatorSrc_, disc);
86 
87 // auto output = std::make_unique<reco::PFTauRefVector>(inputRefs.id());
88  //auto output = std::make_unique<OutputType>(inputRefs.id());
89  auto output = std::make_unique<OutputType>();
90 
91  for(const auto& ref : inputRefs) {
92  if ( (*disc)[ref] > cut_ )
93  output->push_back(T::make(ref));
94  }
95  size_t selected = output->size();
96  evt.put(std::move(output));
97  return (!filter_ || selected);
98 }
99 
102 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
S make(const edm::ParameterSet &cfg)
std::vector< reco::PFTau > OutputType
static std::string const input
Definition: EdmProvDump.cc:48
RecoTauDiscriminatorRefSelectorImpl(const edm::ParameterSet &pset)
static OutputType::value_type make(const reco::PFTauRef &ref)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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:480
RecoTauDiscriminatorRefSelectorImpl< ConcreteTauBuilder > RecoTauDiscriminatorSelector
edm::RefToBaseVector< reco::PFTau > OutputType
static OutputType::value_type make(const reco::PFTauRef &ref)
def move(src, dest)
Definition: eostools.py:511