Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:58:09

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       /// Empty constructor
0024       KinResolutionsLoader() {}
0025 
0026       /// Constructor from a PSet
0027       KinResolutionsLoader(const edm::ParameterSet &iConfig, edm::ConsumesCollector);
0028 
0029       /// 'true' if this there is at least one efficiency configured
0030       bool enabled() const { return !patlabels_.empty(); }
0031 
0032       /// To be called for each new event, reads in the EventSetup object
0033       void newEvent(const edm::Event &event, const edm::EventSetup &setup);
0034 
0035       /// Sets the efficiencies for this object, using the reference to the original objects
0036       template <typename T>
0037       void setResolutions(pat::PATObject<T> &obj) const;
0038 
0039       /// Method for documentation and validation of PSet
0040       static void fillDescription(edm::ParameterSetDescription &iDesc);
0041 
0042     private:
0043       /// Labels of the resolutions in PAT
0044       std::vector<std::string> patlabels_;
0045       /// Labels of the KinematicResolutionProvider in the EventSetup
0046       std::vector<edm::ESGetToken<KinematicResolutionProvider, KinematicResolutionRcd>> estokens_;
0047       /// Handles to the EventSetup
0048       std::vector<KinematicResolutionProvider const *> resolutions_;
0049     };  // class
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   }  // namespace helper
0059 }  // namespace pat
0060 
0061 #endif