CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Attributes

PhysicsTools::MVATrainerFileSave Class Reference

#include <MVATrainerFileSave.h>

Inheritance diagram for PhysicsTools::MVATrainerFileSave:
edm::EDAnalyzer PhysicsTools::MVATrainerFileSaveImpl< Record_t >

List of all members.

Public Member Functions

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

Protected Member Functions

virtual const
Calibration::MVAComputerContainer
getToPut (const edm::EventSetup &es) const =0

Protected Attributes

bool trained

Private Types

typedef std::map< std::string,
std::string > 
LabelFileMap

Private Attributes

std::auto_ptr
< Calibration::MVAComputerContainer
calib
bool saved
LabelFileMap toPut

Detailed Description

Definition at line 17 of file MVATrainerFileSave.h.


Member Typedef Documentation

typedef std::map<std::string, std::string> PhysicsTools::MVATrainerFileSave::LabelFileMap [private]

Definition at line 33 of file MVATrainerFileSave.h.


Constructor & Destructor Documentation

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

Definition at line 23 of file MVATrainerFileSave.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), h::names, and toPut.

                                                                    :
        trained(params.getUntrackedParameter<bool>("trained", true)),
        saved(false)
{
        std::vector<std::string> names = params.getParameterNames();
        for(std::vector<std::string>::const_iterator iter = names.begin();
            iter != names.end(); iter++) {
                if (iter->c_str()[0] == '@' || *iter == "trained")
                        continue;

                toPut[*iter] = params.getParameter<std::string>(*iter);
        }

}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 38 of file MVATrainerFileSave.cc.

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

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

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

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

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 58 of file MVATrainerFileSave.cc.

References calib, saved, toPut, and PhysicsTools::MVAComputer::writeCalibration().

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

        edm::LogInfo("MVATrainerFileSave")
                << "Saving calibration data into plain MVA files.";

        for(LabelFileMap::const_iterator iter = toPut.begin();
            iter != toPut.end(); iter++) {
                const Calibration::MVAComputer *calibration =
                                                &calib->find(iter->first);

                MVAComputer::writeCalibration(iter->second.c_str(),
                                              calibration);
        }

        saved = true;
}
virtual const Calibration::MVAComputerContainer* PhysicsTools::MVATrainerFileSave::getToPut ( const edm::EventSetup es) const [protected, pure virtual]

Member Data Documentation

Definition at line 36 of file MVATrainerFileSave.h.

Referenced by analyze(), and endJob().

Definition at line 37 of file MVATrainerFileSave.h.

Referenced by analyze(), and endJob().

Definition at line 35 of file MVATrainerFileSave.h.

Referenced by endJob(), and MVATrainerFileSave().