CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Attributes
PhysicsTools::MVATrainerFileSave Class Referenceabstract

#include <MVATrainerFileSave.h>

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

Public Member Functions

virtual void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual void endJob ()
 
 MVATrainerFileSave (const edm::ParameterSet &params)
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Protected Member Functions

virtual const
Calibration::MVAComputerContainer
getToPut (const edm::EventSetup &es) const =0
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

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(), cscdqm::h::names, and toPut.

23  :
24  trained(params.getUntrackedParameter<bool>("trained", true)),
25  saved(false)
26 {
27  std::vector<std::string> names = params.getParameterNames();
28  for(std::vector<std::string>::const_iterator iter = names.begin();
29  iter != names.end(); iter++) {
30  if (iter->c_str()[0] == '@' || *iter == "trained")
31  continue;
32 
33  toPut[*iter] = params.getParameter<std::string>(*iter);
34  }
35 
36 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static const HistoName names[]
std::vector< std::string > getParameterNames() const

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.

40 {
41  if (calib.get() || saved)
42  return;
43 
44  const Calibration::MVAComputerContainer *toPutCalib = getToPut(es);
45  if (MVATrainerLooper::isUntrained(toPutCalib))
46  return;
47 
48  edm::LogInfo("MVATrainerFileSave")
49  << "Got the trained calibration data";
50 
51  std::auto_ptr<Calibration::MVAComputerContainer> calib(
52  new Calibration::MVAComputerContainer);
53  *calib = *toPutCalib;
54 
55  this->calib = calib;
56 }
std::auto_ptr< Calibration::MVAComputerContainer > calib
virtual const Calibration::MVAComputerContainer * getToPut(const edm::EventSetup &es) const =0
static bool isUntrained(const T *ptr)
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().

59 {
60  if (!calib.get() || saved)
61  return;
62 
63  edm::LogInfo("MVATrainerFileSave")
64  << "Saving calibration data into plain MVA files.";
65 
66  for(LabelFileMap::const_iterator iter = toPut.begin();
67  iter != toPut.end(); iter++) {
68  const Calibration::MVAComputer *calibration =
69  &calib->find(iter->first);
70 
71  MVAComputer::writeCalibration(iter->second.c_str(),
72  calibration);
73  }
74 
75  saved = true;
76 }
std::auto_ptr< Calibration::MVAComputerContainer > calib
static void writeCalibration(const char *filename, const Calibration::MVAComputer *calib)
write calibration object to file
Definition: MVAComputer.cc:276
virtual const Calibration::MVAComputerContainer* PhysicsTools::MVATrainerFileSave::getToPut ( const edm::EventSetup es) const
protectedpure virtual

Member Data Documentation

std::auto_ptr<Calibration::MVAComputerContainer> PhysicsTools::MVATrainerFileSave::calib
private

Definition at line 36 of file MVATrainerFileSave.h.

Referenced by analyze(), and endJob().

bool PhysicsTools::MVATrainerFileSave::saved
private

Definition at line 37 of file MVATrainerFileSave.h.

Referenced by analyze(), and endJob().

LabelFileMap PhysicsTools::MVATrainerFileSave::toPut
private

Definition at line 35 of file MVATrainerFileSave.h.

Referenced by endJob(), and MVATrainerFileSave().

bool PhysicsTools::MVATrainerFileSave::trained
protected