Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-28 03:59:13

0001 #include "PhysicsTools/PatAlgos/interface/KinResolutionsLoader.h"
0002 #include "PhysicsTools/PatAlgos/interface/KinematicResolutionRcd.h"
0003 
0004 #include <algorithm>
0005 
0006 using pat::helper::KinResolutionsLoader;
0007 
0008 KinResolutionsLoader::KinResolutionsLoader(const edm::ParameterSet &iConfig, edm::ConsumesCollector iCollector) {
0009   // Get the names (sorted)
0010   patlabels_ = iConfig.getParameterNamesForType<std::string>();
0011 
0012   // get the InputTags
0013   estokens_.reserve(patlabels_.size());
0014   for (auto const &label : patlabels_) {
0015     estokens_.emplace_back(iCollector.esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>(label))));
0016   }
0017   // prepare the resolutions
0018   resolutions_.resize(patlabels_.size());
0019 
0020   // 'default' maps to empty string
0021   for (std::vector<std::string>::iterator it = patlabels_.begin(), ed = patlabels_.end(); it != ed; ++it) {
0022     if (*it == "default")
0023       *it = "";
0024   }
0025 }
0026 
0027 void KinResolutionsLoader::newEvent(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0028   for (size_t i = 0, n = patlabels_.size(); i < n; ++i) {
0029     resolutions_[i] = &iSetup.getData(estokens_[i]);
0030   }
0031 }
0032 
0033 void KinResolutionsLoader::fillDescription(edm::ParameterSetDescription &iDesc) {
0034   iDesc.add<bool>("addResolutions", false)->setComment("Add resolutions into this PAT Object");
0035   edm::ParameterSetDescription resolutionPSet;
0036   resolutionPSet.setAllowAnything();
0037   iDesc.addOptional("resolutions", resolutionPSet)->setComment("Resolution values to get from EventSetup");
0038 }