CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/RecoTauTag/TauTagTools/plugins/CandViewRefTriggerBiasRemover.cc

Go to the documentation of this file.
00001 /*
00002  * CandViewRefTriggerBiasRemover
00003  *
00004  * Author: Evan K. Friis
00005  *
00006  * Takes a collection of "triggered" objects and returns produces a collection
00007  * that removes all elements that are biased by the trigger.  In practice, this
00008  * returns an empty colleciton if the size of the input collection is 1, and the
00009  * entire collection if the input collection has at least two elements.
00010  *
00011  * In summary, for any element in the output collection, there exists at least
00012  * one *other* element in the output collection that fired the trigger.
00013  *
00014  */
00015 
00016 #include <vector>
00017 
00018 #include "FWCore/Framework/interface/Frameworkfwd.h"
00019 #include "FWCore/Framework/interface/EDProducer.h"
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00022 
00023 #include "DataFormats/Candidate/interface/Candidate.h"
00024 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00025 
00026 class CandViewRefTriggerBiasRemover : public edm::EDProducer {
00027   public:
00028     CandViewRefTriggerBiasRemover(const edm::ParameterSet &pset);
00029     void produce(edm::Event&, const edm::EventSetup&);
00030   private:
00031     edm::InputTag src_;
00032 };
00033 
00034 CandViewRefTriggerBiasRemover::CandViewRefTriggerBiasRemover(
00035     const edm::ParameterSet &pset) {
00036   src_ = pset.getParameter<edm::InputTag>("triggered");
00037   produces<reco::CandidateBaseRefVector>();
00038 }
00039 
00040 void CandViewRefTriggerBiasRemover::produce(edm::Event& evt,
00041                                             const edm::EventSetup& es) {
00042   edm::Handle<edm::View<reco::Candidate> > cands;
00043   evt.getByLabel(src_, cands);
00044   std::auto_ptr<reco::CandidateBaseRefVector> output(
00045       new reco::CandidateBaseRefVector(cands));
00046   // Only copy the output if there is more than one item in the input
00047   size_t nCands = cands->size();
00048   if (nCands > 1) {
00049     //output->reserve(nCands);
00050     for (size_t iCand = 0; iCand < nCands; ++iCand) {
00051       output->push_back(cands->refVector().at(iCand));
00052     }
00053   }
00054   evt.put(output);
00055 }
00056 
00057 #include "FWCore/Framework/interface/MakerMacros.h"
00058 DEFINE_FWK_MODULE(CandViewRefTriggerBiasRemover);