test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CandViewRefTriggerBiasRemover.cc
Go to the documentation of this file.
1 /*
2  * CandViewRefTriggerBiasRemover
3  *
4  * Author: Evan K. Friis
5  *
6  * Takes a collection of "triggered" objects and returns produces a collection
7  * that removes all elements that are biased by the trigger. In practice, this
8  * returns an empty colleciton if the size of the input collection is 1, and the
9  * entire collection if the input collection has at least two elements.
10  *
11  * In summary, for any element in the output collection, there exists at least
12  * one *other* element in the output collection that fired the trigger.
13  *
14  */
15 
16 #include <vector>
17 
22 
25 
27  public:
29  void produce(edm::Event&, const edm::EventSetup&) override;
30  private:
32 };
33 
35  const edm::ParameterSet &pset) {
36  src_ = pset.getParameter<edm::InputTag>("triggered");
37  produces<reco::CandidateBaseRefVector>();
38 }
39 
41  const edm::EventSetup& es) {
43  evt.getByLabel(src_, cands);
44  std::auto_ptr<reco::CandidateBaseRefVector> output(
45  new reco::CandidateBaseRefVector(cands));
46  // Only copy the output if there is more than one item in the input
47  size_t nCands = cands->size();
48  if (nCands > 1) {
49  //output->reserve(nCands);
50  for (size_t iCand = 0; iCand < nCands; ++iCand) {
51  output->push_back(cands->refAt(iCand));
52  }
53  }
54  evt.put(output);
55 }
56 
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
CandViewRefTriggerBiasRemover(const edm::ParameterSet &pset)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
void produce(edm::Event &, const edm::EventSetup &) override