CMS 3D CMS Logo

PhysicsTools::MVATrainerContainerSave Class Reference

#include <PhysicsTools/MVATrainer/interface/MVATrainerContainerSave.h>

Inheritance diagram for PhysicsTools::MVATrainerContainerSave:

edm::EDAnalyzer PhysicsTools::MVATrainerContainerSaveImpl< Record_t >

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual void endJob ()
 MVATrainerContainerSave (const edm::ParameterSet &params)

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


Detailed Description

Definition at line 17 of file MVATrainerContainerSave.h.


Constructor & Destructor Documentation

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 }


Member Function Documentation

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 }

void PhysicsTools::MVATrainerContainerSave::endJob ( void   )  [virtual]

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]

Implemented in PhysicsTools::MVATrainerContainerSaveImpl< Record_t >.

Referenced by endJob().

virtual const Calibration::MVAComputerContainer* PhysicsTools::MVATrainerContainerSave::getToCopy ( const edm::EventSetup es  )  const [protected, pure virtual]

Implemented in PhysicsTools::MVATrainerContainerSaveImpl< Record_t >.

Referenced by analyze().

virtual const Calibration::MVAComputerContainer* PhysicsTools::MVATrainerContainerSave::getToPut ( const edm::EventSetup es  )  const [protected, pure virtual]

Implemented in PhysicsTools::MVATrainerContainerSaveImpl< Record_t >.

Referenced by analyze().


Member Data Documentation

std::auto_ptr<Calibration::MVAComputerContainer> PhysicsTools::MVATrainerContainerSave::calib [private]

Definition at line 38 of file MVATrainerContainerSave.h.

Referenced by analyze(), and endJob().

bool PhysicsTools::MVATrainerContainerSave::saved [private]

Definition at line 39 of file MVATrainerContainerSave.h.

Referenced by analyze(), and endJob().

std::vector<std::string> PhysicsTools::MVATrainerContainerSave::toCopy [private]

Definition at line 37 of file MVATrainerContainerSave.h.

Referenced by analyze().

std::vector<std::string> PhysicsTools::MVATrainerContainerSave::toPut [private]

Definition at line 36 of file MVATrainerContainerSave.h.

Referenced by analyze().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:50:12 2009 for CMSSW by  doxygen 1.5.4