CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

PhysicsTools::MVATrainerContainerSave Class Reference

#include <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.

                                                                       :
        toPut(params.getParameter<std::vector<std::string> >("toPut")),
        toCopy(params.getParameter<std::vector<std::string> >("toCopy")),
        saved(false)
{
}

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(), saved, toCopy, and toPut.

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

        const Calibration::MVAComputerContainer *toPutCalib = 0;
        if (!toPut.empty()) {
                toPutCalib = getToPut(es);
                if (MVATrainerLooper::isUntrained(toPutCalib))
                        return;
        }

        const Calibration::MVAComputerContainer *toCopyCalib = 0;
        if (!toCopy.empty())
                toCopyCalib = getToCopy(es);

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

        std::auto_ptr<Calibration::MVAComputerContainer> calib(
                                        new Calibration::MVAComputerContainer);

        for(std::vector<std::string>::const_iterator iter = toCopy.begin();
            iter != toCopy.end(); iter++)
                calib->add(*iter) = toCopyCalib->find(*iter);

        for(std::vector<std::string>::const_iterator iter = toPut.begin();
            iter != toPut.end(); iter++)
                calib->add(*iter) = toPutCalib->find(*iter);

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

Reimplemented from edm::EDAnalyzer.

Definition at line 67 of file MVATrainerContainerSave.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("MVATrainerContainerSave")
                        << "DBService unavailable" << std::endl;

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

        saved = true;
}
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]

Member Data Documentation

Definition at line 38 of file MVATrainerContainerSave.h.

Referenced by analyze(), and endJob().

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().