CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

PhysicsTools::MVATrainerSave Class Reference

#include <MVATrainerSave.h>

Inheritance diagram for PhysicsTools::MVATrainerSave:
edm::EDAnalyzer PhysicsTools::MVATrainerSaveImpl< Record_t >

List of all members.

Public Member Functions

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

Protected Member Functions

virtual std::string getRecordName () const =0
virtual const
Calibration::MVAComputer
getToPut (const edm::EventSetup &es) const =0

Private Attributes

std::auto_ptr
< Calibration::MVAComputer
calib
bool saved

Detailed Description

Definition at line 16 of file MVATrainerSave.h.


Constructor & Destructor Documentation

PhysicsTools::MVATrainerSave::MVATrainerSave ( const edm::ParameterSet params) [explicit]

Definition at line 26 of file MVATrainerSave.cc.

                                                            :
        saved(false)
{
}

Member Function Documentation

void PhysicsTools::MVATrainerSave::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 31 of file MVATrainerSave.cc.

References calib, getToPut(), PhysicsTools::MVATrainerLooper::isUntrained(), and saved.

{
        if (calib.get() || saved)
                return;

        const Calibration::MVAComputer *toPutCalib = getToPut(es);
        if (MVATrainerLooper::isUntrained(toPutCalib))
                return;

        edm::LogInfo("MVATrainerSave") << "Got the trained calibration data";

        std::auto_ptr<Calibration::MVAComputer> calib(
                                                new Calibration::MVAComputer);
        *calib = *toPutCalib;

        this->calib = calib;
}
void PhysicsTools::MVATrainerSave::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file MVATrainerSave.cc.

References calib, getRecordName(), edm::Service< T >::isAvailable(), and saved.

{
        if (!calib.get() || saved)
                return;

        edm::LogInfo("MVATrainerSave") << "Saving calibration data in CondDB.";

        edm::Service<cond::service::PoolDBOutputService> dbService;
        if (!dbService.isAvailable())
                throw cms::Exception("MVATrainerSave")
                        << "DBService unavailable" << std::endl;

        dbService->createNewIOV<Calibration::MVAComputer>(
                calib.release(), dbService->beginOfTime(),
                dbService->endOfTime(), getRecordName().c_str());

        saved = true;
}
virtual std::string PhysicsTools::MVATrainerSave::getRecordName ( ) const [protected, pure virtual]
virtual const Calibration::MVAComputer* PhysicsTools::MVATrainerSave::getToPut ( const edm::EventSetup es) const [protected, pure virtual]

Member Data Documentation

Definition at line 32 of file MVATrainerSave.h.

Referenced by analyze(), and endJob().

Definition at line 33 of file MVATrainerSave.h.

Referenced by analyze(), and endJob().