File indexing completed on 2024-04-06 12:23:46
0001 #ifndef PhysicsTools_PatAlgos_KinResolutionsLoader_h
0002 #define PhysicsTools_PatAlgos_KinResolutionsLoader_h
0003
0004 #include "DataFormats/PatCandidates/interface/PATObject.h"
0005
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/ConsumesCollector.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010
0011 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0013
0014 #include "FWCore/Utilities/interface/ESGetToken.h"
0015
0016 #include "PhysicsTools/PatAlgos/interface/KinematicResolutionProvider.h"
0017 #include "PhysicsTools/PatAlgos/interface/KinematicResolutionRcd.h"
0018
0019 namespace pat {
0020 namespace helper {
0021 class KinResolutionsLoader {
0022 public:
0023
0024 KinResolutionsLoader() {}
0025
0026
0027 KinResolutionsLoader(const edm::ParameterSet &iConfig, edm::ConsumesCollector);
0028
0029
0030 bool enabled() const { return !patlabels_.empty(); }
0031
0032
0033 void newEvent(const edm::Event &event, const edm::EventSetup &setup);
0034
0035
0036 template <typename T>
0037 void setResolutions(pat::PATObject<T> &obj) const;
0038
0039
0040 static void fillDescription(edm::ParameterSetDescription &iDesc);
0041
0042 private:
0043
0044 std::vector<std::string> patlabels_;
0045
0046 std::vector<edm::ESGetToken<KinematicResolutionProvider, KinematicResolutionRcd>> estokens_;
0047
0048 std::vector<KinematicResolutionProvider const *> resolutions_;
0049 };
0050
0051 template <typename T>
0052 void KinResolutionsLoader::setResolutions(pat::PATObject<T> &obj) const {
0053 for (size_t i = 0, n = patlabels_.size(); i < n; ++i) {
0054 obj.setKinResolution(resolutions_[i]->getResolution(obj), patlabels_[i]);
0055 }
0056 }
0057
0058 }
0059 }
0060
0061 #endif