#include <PhysicsTools/MVATrainer/interface/MVATrainerContainerSave.h>
Public Member Functions | |
virtual void | analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) |
virtual void | endJob () |
MVATrainerContainerSave (const edm::ParameterSet ¶ms) | |
Protected Member Functions | |
virtual std::string | getRecordName () const =0 |
virtual const Calibration::MVAComputerContainer * | getToCopy (const edm::EventSetup &es) const =0 |
virtual const Calibration::MVAComputerContainer * | getToPut (const edm::EventSetup &es) const =0 |
Private Attributes | |
std::auto_ptr < Calibration::MVAComputerContainer > | calib |
bool | saved |
std::vector< std::string > | toCopy |
std::vector< std::string > | toPut |
Definition at line 17 of file MVATrainerContainerSave.h.
PhysicsTools::MVATrainerContainerSave::MVATrainerContainerSave | ( | const edm::ParameterSet & | params | ) | [explicit] |
Definition at line 26 of file MVATrainerContainerSave.cc.
00027 : 00028 toPut(params.getParameter<std::vector<std::string> >("toPut")), 00029 toCopy(params.getParameter<std::vector<std::string> >("toCopy")), 00030 saved(false) 00031 { 00032 }
void PhysicsTools::MVATrainerContainerSave::analyze | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 34 of file MVATrainerContainerSave.cc.
References calib, PhysicsTools::Calibration::MVAComputerContainer::find(), getToCopy(), getToPut(), PhysicsTools::MVATrainerLooper::isUntrained(), iter, saved, toCopy, and toPut.
00036 { 00037 if (calib.get() || saved) 00038 return; 00039 00040 const Calibration::MVAComputerContainer *toPutCalib = 0; 00041 if (!toPut.empty()) { 00042 toPutCalib = getToPut(es); 00043 if (MVATrainerLooper::isUntrained(toPutCalib)) 00044 return; 00045 } 00046 00047 const Calibration::MVAComputerContainer *toCopyCalib = 0; 00048 if (!toCopy.empty()) 00049 toCopyCalib = getToCopy(es); 00050 00051 edm::LogInfo("MVATrainerSave") << "Got the trained calibration data"; 00052 00053 std::auto_ptr<Calibration::MVAComputerContainer> calib( 00054 new Calibration::MVAComputerContainer); 00055 00056 for(std::vector<std::string>::const_iterator iter = toCopy.begin(); 00057 iter != toCopy.end(); iter++) 00058 calib->add(*iter) = toCopyCalib->find(*iter); 00059 00060 for(std::vector<std::string>::const_iterator iter = toPut.begin(); 00061 iter != toPut.end(); iter++) 00062 calib->add(*iter) = toPutCalib->find(*iter); 00063 00064 this->calib = calib; 00065 }
Reimplemented from edm::EDAnalyzer.
Definition at line 67 of file MVATrainerContainerSave.cc.
References calib, lat::endl(), getRecordName(), edm::Service< T >::isAvailable(), and saved.
00068 { 00069 if (!calib.get() || saved) 00070 return; 00071 00072 edm::LogInfo("MVATrainerSave") << "Saving calibration data in CondDB."; 00073 00074 edm::Service<cond::service::PoolDBOutputService> dbService; 00075 if (!dbService.isAvailable()) 00076 throw cms::Exception("MVATrainerContainerSave") 00077 << "DBService unavailable" << std::endl; 00078 00079 dbService->createNewIOV<Calibration::MVAComputerContainer>( 00080 calib.release(), dbService->beginOfTime(), 00081 dbService->endOfTime(), getRecordName().c_str()); 00082 00083 saved = true; 00084 }
virtual std::string PhysicsTools::MVATrainerContainerSave::getRecordName | ( | ) | const [protected, pure virtual] |
virtual const Calibration::MVAComputerContainer* PhysicsTools::MVATrainerContainerSave::getToCopy | ( | const edm::EventSetup & | es | ) | const [protected, pure virtual] |
virtual const Calibration::MVAComputerContainer* PhysicsTools::MVATrainerContainerSave::getToPut | ( | const edm::EventSetup & | es | ) | const [protected, pure virtual] |
std::auto_ptr<Calibration::MVAComputerContainer> PhysicsTools::MVATrainerContainerSave::calib [private] |
std::vector<std::string> PhysicsTools::MVATrainerContainerSave::toCopy [private] |
std::vector<std::string> PhysicsTools::MVATrainerContainerSave::toPut [private] |