CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/PhysicsTools/MVATrainer/interface/MVATrainerSaveImpl.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_MVATrainer_MVATrainerSaveImpl_h
00002 #define PhysicsTools_MVATrainer_MVATrainerSaveImpl_h
00003 
00004 #include <iostream>
00005 #include <memory>
00006 #include <vector>
00007 #include <string>
00008 
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include "FWCore/Framework/interface/Event.h"
00011 #include "FWCore/Framework/interface/EventSetup.h"
00012 #include "FWCore/Framework/interface/ESHandle.h"
00013 
00014 #include "CondFormats/PhysicsToolsObjects/interface/MVAComputer.h"
00015 
00016 #include "PhysicsTools/MVATrainer/interface/MVATrainerSave.h"
00017 #include "PhysicsTools/MVATrainer/interface/MVATrainerContainerSave.h"
00018 
00019 namespace PhysicsTools {
00020 
00021 template<typename Record_t>
00022 class MVATrainerSaveImpl : public MVATrainerSave {
00023     public:
00024         explicit MVATrainerSaveImpl(const edm::ParameterSet &params) :
00025                 MVATrainerSave(params) {}
00026 
00027     protected:
00028         virtual const Calibration::MVAComputer *
00029         getToPut(const edm::EventSetup& es) const
00030         {
00031                 edm::ESHandle<Calibration::MVAComputer> handle;
00032                 es.get<Record_t>().get("trained", handle);
00033                 return handle.product();
00034         }
00035 
00036         virtual std::string getRecordName() const
00037         { return Record_t::keyForClass().type().name(); }
00038 };
00039 
00040 template<typename Record_t>
00041 class MVATrainerContainerSaveImpl : public MVATrainerContainerSave {
00042     public:
00043         explicit MVATrainerContainerSaveImpl(const edm::ParameterSet &params) :
00044                 MVATrainerContainerSave(params) {}
00045 
00046     protected:
00047         virtual const Calibration::MVAComputerContainer *
00048         getToPut(const edm::EventSetup& es) const
00049         {
00050                 edm::ESHandle<Calibration::MVAComputerContainer> handle;
00051                 es.get<Record_t>().get("trained", handle);
00052                 return handle.product();
00053         }
00054 
00055         virtual const Calibration::MVAComputerContainer *
00056         getToCopy(const edm::EventSetup& es) const
00057         {
00058                 edm::ESHandle<Calibration::MVAComputerContainer> handle;
00059                 es.get<Record_t>().get(handle);
00060                 return handle.product();
00061         }
00062 
00063         virtual std::string getRecordName() const
00064         { return Record_t::keyForClass().type().name(); }
00065 };
00066 
00067 } // namespace PhysicsTools
00068 
00069 #endif // PhysicsTools_MVATrainer_MVATrainerSaveImpl_h