CMS 3D CMS Logo

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  auto output = std::make_unique<reco::CandidateBaseRefVector>(cands);
45  // Only copy the output if there is more than one item in the input
46  size_t nCands = cands->size();
47  if (nCands > 1) {
48  //output->reserve(nCands);
49  for (size_t iCand = 0; iCand < nCands; ++iCand) {
50  output->push_back(cands->refAt(iCand));
51  }
52  }
53  evt.put(std::move(output));
54 }
55 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
CandViewRefTriggerBiasRemover(const edm::ParameterSet &pset)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511