CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MVATrainerFileSave.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <memory>
3 #include <vector>
4 #include <string>
5 
14 
16 
20 
21 namespace PhysicsTools {
22 
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 }
37 
39  const edm::EventSetup& es)
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(
53  *calib = *toPutCalib;
54 
55  this->calib = calib;
56 }
57 
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 }
77 
78 } // namespace PhysicsTools
std::auto_ptr< Calibration::MVAComputerContainer > calib
T getParameter(std::string const &) const
MVATrainerFileSave(const edm::ParameterSet &params)
virtual void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
static void writeCalibration(const char *filename, const Calibration::MVAComputer *calib)
write calibration object to file
Definition: MVAComputer.cc:276
virtual const Calibration::MVAComputerContainer * getToPut(const edm::EventSetup &es) const =0
std::vector< std::string > getParameterNames() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
static bool isUntrained(const T *ptr)
static const HistoName names[]