CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MVATrainerContainerSave.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <memory>
3 #include <vector>
4 #include <string>
5 
14 
18 
20 
23 
24 namespace PhysicsTools {
25 
27  const edm::ParameterSet &params) :
28  toPut(params.getParameter<std::vector<std::string> >("toPut")),
29  toCopy(params.getParameter<std::vector<std::string> >("toCopy")),
30  saved(false)
31 {
32 }
33 
35  const edm::EventSetup& es)
36 {
37  if (calib.get() || saved)
38  return;
39 
40  const Calibration::MVAComputerContainer *toPutCalib = 0;
41  if (!toPut.empty()) {
42  toPutCalib = getToPut(es);
43  if (MVATrainerLooper::isUntrained(toPutCalib))
44  return;
45  }
46 
47  const Calibration::MVAComputerContainer *toCopyCalib = 0;
48  if (!toCopy.empty())
49  toCopyCalib = getToCopy(es);
50 
51  edm::LogInfo("MVATrainerSave") << "Got the trained calibration data";
52 
53  std::auto_ptr<Calibration::MVAComputerContainer> calib(
55 
56  for(std::vector<std::string>::const_iterator iter = toCopy.begin();
57  iter != toCopy.end(); iter++)
58  calib->add(*iter) = toCopyCalib->find(*iter);
59 
60  for(std::vector<std::string>::const_iterator iter = toPut.begin();
61  iter != toPut.end(); iter++)
62  calib->add(*iter) = toPutCalib->find(*iter);
63 
64  this->calib = calib;
65 }
66 
68 {
69  if (!calib.get() || saved)
70  return;
71 
72  edm::LogInfo("MVATrainerSave") << "Saving calibration data in CondDB.";
73 
75  if (!dbService.isAvailable())
76  throw cms::Exception("MVATrainerContainerSave")
77  << "DBService unavailable" << std::endl;
78 
80  calib.release(), dbService->beginOfTime(),
81  dbService->endOfTime(), getRecordName().c_str());
82 
83  saved = true;
84 }
85 
86 } // namespace PhysicsTools
virtual const MVAComputer & find(const std::string &label) const
Definition: MVAComputer.cc:192
virtual std::string getRecordName() const =0
virtual const Calibration::MVAComputerContainer * getToPut(const edm::EventSetup &es) const =0
bool isAvailable() const
Definition: Service.h:46
virtual const Calibration::MVAComputerContainer * getToCopy(const edm::EventSetup &es) const =0
virtual void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
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
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
MVATrainerContainerSave(const edm::ParameterSet &params)
volatile std::atomic< bool > shutdown_flag false
static bool isUntrained(const T *ptr)
std::auto_ptr< Calibration::MVAComputerContainer > calib