1 |
dgele |
1.1 |
#ifndef PhysicsTools_PatAlgos_EfficiencyLoader_h
|
2 |
|
|
#define PhysicsTools_PatAlgos_EfficiencyLoader_h
|
3 |
|
|
|
4 |
|
|
#include "DataFormats/PatCandidates/interface/PATObject.h"
|
5 |
|
|
#include "DataFormats/PatCandidates/interface/LookupTableRecord.h"
|
6 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
7 |
|
|
#include "DataFormats/Common/interface/ValueMap.h"
|
8 |
|
|
|
9 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
10 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
11 |
|
|
#include "FWCore/ParameterSet/interface/InputTag.h"
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
namespace pat { namespace helper {
|
15 |
|
|
class EfficiencyLoader {
|
16 |
|
|
public:
|
17 |
|
|
/// Empty constructor
|
18 |
|
|
EfficiencyLoader() {}
|
19 |
|
|
|
20 |
|
|
/// Constructor from a PSet
|
21 |
|
|
EfficiencyLoader(const edm::ParameterSet &iConfig) ;
|
22 |
|
|
|
23 |
|
|
/// 'true' if this there is at least one efficiency configured
|
24 |
|
|
bool enabled() const { return !names_.empty(); }
|
25 |
|
|
|
26 |
|
|
/// To be called for each new event, reads in the ValueMaps for efficiencies
|
27 |
|
|
void newEvent(const edm::Event &event) const ;
|
28 |
|
|
|
29 |
|
|
/// Sets the efficiencies for this object, using the reference to the original objects
|
30 |
|
|
template<typename T, typename R>
|
31 |
|
|
void setEfficiencies( pat::PATObject<T> &obj, const R & originalRef ) const ;
|
32 |
|
|
|
33 |
|
|
private:
|
34 |
|
|
std::vector<std::string> names_;
|
35 |
|
|
std::vector<edm::InputTag> tags_;
|
36 |
|
|
mutable std::vector<edm::Handle< edm::ValueMap<pat::LookupTableRecord> > > handles_;
|
37 |
|
|
}; // class
|
38 |
|
|
|
39 |
|
|
template<typename T, typename R>
|
40 |
|
|
void
|
41 |
|
|
EfficiencyLoader::setEfficiencies( pat::PATObject<T> &obj, const R & originalRef ) const
|
42 |
|
|
{
|
43 |
|
|
for (size_t i = 0, n = names_.size(); i < n; ++i) {
|
44 |
|
|
obj.setEfficiency(names_[i], (* handles_[i])[originalRef] );
|
45 |
|
|
}
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
} }
|
49 |
|
|
|
50 |
|
|
#endif
|