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