CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/PhysicsTools/PatAlgos/interface/EfficiencyLoader.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_PatAlgos_EfficiencyLoader_h
00002 #define PhysicsTools_PatAlgos_EfficiencyLoader_h
00003 
00004 #include "DataFormats/PatCandidates/interface/PATObject.h"
00005 #include "DataFormats/PatCandidates/interface/LookupTableRecord.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "DataFormats/Common/interface/ValueMap.h"
00008 
00009 #include "FWCore/Framework/interface/Event.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/Utilities/interface/InputTag.h"
00012 
00013 
00014 namespace pat { namespace helper {
00015 class EfficiencyLoader {
00016     public:
00018         EfficiencyLoader() {}
00019 
00021         EfficiencyLoader(const edm::ParameterSet &iConfig) ;
00022 
00024         bool enabled() const { return !names_.empty(); }
00025      
00027         void newEvent(const edm::Event &event) const ;
00028 
00030         template<typename T, typename R>
00031         void setEfficiencies( pat::PATObject<T> &obj,  const R & originalRef ) const ;
00032 
00033     private:
00034         std::vector<std::string>   names_;
00035         std::vector<edm::InputTag> tags_;
00036         mutable std::vector<edm::Handle< edm::ValueMap<pat::LookupTableRecord> > > handles_;
00037 }; // class
00038 
00039 template<typename T, typename R>
00040 void
00041 EfficiencyLoader::setEfficiencies( pat::PATObject<T> &obj,  const R & originalRef ) const
00042 {
00043     for (size_t i = 0, n = names_.size(); i < n; ++i) {
00044         obj.setEfficiency(names_[i], (* handles_[i])[originalRef] );
00045     }
00046 }
00047 
00048 } }
00049 
00050 #endif