Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:41

0001 #include <iostream>
0002 #include <string>
0003 #include <memory>
0004 #include <vector>
0005 #include <map>
0006 
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 #include "FWCore/Framework/interface/ESProducer.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/ParameterSet/interface/Entry.h"
0011 #include "FWCore/ParameterSet/interface/FileInPath.h"
0012 
0013 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
0014 #include "PhysicsTools/MVAComputer/interface/MVAComputer.h"
0015 #include "PhysicsTools/MVAComputer/interface/MVAComputerESSourceBase.h"
0016 
0017 namespace PhysicsTools {
0018 
0019   MVAComputerESSourceBase::MVAComputerESSourceBase(const edm::ParameterSet &params) {
0020     std::vector<std::string> names = params.getParameterNames();
0021     for (std::vector<std::string>::const_iterator iter = names.begin(); iter != names.end(); iter++) {
0022       if (iter->c_str()[0] == '@')
0023         continue;
0024 
0025       const edm::Entry &entry = params.retrieve(*iter);
0026 
0027       std::string path;
0028       if (entry.typeCode() == 'F')
0029         path = entry.getFileInPath().fullPath();
0030       else
0031         path = entry.getString();
0032 
0033       mvaCalibrations[*iter] = path;
0034     }
0035   }
0036 
0037   MVAComputerESSourceBase::~MVAComputerESSourceBase() {}
0038 
0039   MVAComputerESSourceBase::ReturnType MVAComputerESSourceBase::produce() const {
0040     auto container = std::make_unique<Calibration::MVAComputerContainer>();
0041 
0042     for (LabelFileMap::const_iterator iter = mvaCalibrations.begin(); iter != mvaCalibrations.end(); iter++) {
0043       std::unique_ptr<Calibration::MVAComputer> calibration(MVAComputer::readCalibration(iter->second.c_str()));
0044 
0045       container->add(iter->first) = *calibration;
0046     }
0047 
0048     return container;
0049   }
0050 
0051 }  // namespace PhysicsTools