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 edm::EDConsumerBase 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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

virtual const
Calibration::MVAComputerContainer
getToPut (const edm::EventSetup &es) const =0
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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
 
- 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, AlCaHLTBitMon_QueryRunRegistry::string, 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