CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/PhysicsTools/MVAComputer/src/MVAComputerESSourceBase.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <string>
00003 #include <memory>
00004 #include <vector>
00005 #include <map>
00006 
00007 #include <boost/shared_ptr.hpp>
00008 
00009 #include "FWCore/Utilities/interface/Exception.h"
00010 #include "FWCore/Framework/interface/ESProducer.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 #include "FWCore/ParameterSet/interface/Entry.h"
00013 #include "FWCore/ParameterSet/interface/FileInPath.h"
00014 
00015 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
00016 #include "PhysicsTools/MVAComputer/interface/MVAComputer.h"
00017 #include "PhysicsTools/MVAComputer/interface/MVAComputerESSourceBase.h"
00018 
00019 namespace PhysicsTools {
00020 
00021 MVAComputerESSourceBase::MVAComputerESSourceBase(
00022                                         const edm::ParameterSet &params)
00023 {
00024         std::vector<std::string> names = params.getParameterNames();
00025         for(std::vector<std::string>::const_iterator iter = names.begin();
00026             iter != names.end(); iter++) {
00027                 if (iter->c_str()[0] == '@')
00028                         continue;
00029 
00030                 const edm::Entry &entry = params.retrieve(*iter);
00031 
00032                 std::string path;
00033                 if (entry.typeCode() == 'F')
00034                         path = entry.getFileInPath().fullPath();
00035                 else 
00036                         path = entry.getString();
00037 
00038                 mvaCalibrations[*iter] = path;
00039         }
00040 }
00041 
00042 MVAComputerESSourceBase::~MVAComputerESSourceBase()
00043 {
00044 }
00045 
00046 MVAComputerESSourceBase::ReturnType
00047 MVAComputerESSourceBase::produce() const
00048 {
00049         ReturnType container(new Calibration::MVAComputerContainer);
00050 
00051         for(LabelFileMap::const_iterator iter = mvaCalibrations.begin();
00052             iter != mvaCalibrations.end(); iter++) {
00053                 std::auto_ptr<Calibration::MVAComputer> calibration(
00054                         MVAComputer::readCalibration(iter->second.c_str()));
00055 
00056                 container->add(iter->first) = *calibration;
00057         }
00058 
00059         return container;
00060 }
00061 
00062 } // namespace PhysicsTools