CMS 3D CMS Logo

MVATrainerSave.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  saved(false)
28 {
29 }
30 
32  const edm::EventSetup& es)
33 {
34  if (calib.get() || saved)
35  return;
36 
37  const Calibration::MVAComputer *toPutCalib = getToPut(es);
38  if (MVATrainerLooper::isUntrained(toPutCalib))
39  return;
40 
41  edm::LogInfo("MVATrainerSave") << "Got the trained calibration data";
42 
43  std::unique_ptr<Calibration::MVAComputer> calib(
45  *calib = *toPutCalib;
46 
47  this->calib = std::move(calib);
48 }
49 
51 {
52  if (!calib.get() || saved)
53  return;
54 
55  edm::LogInfo("MVATrainerSave") << "Saving calibration data in CondDB.";
56 
58  if (!dbService.isAvailable())
59  throw cms::Exception("MVATrainerSave")
60  << "DBService unavailable" << std::endl;
61 
63  calib.release(), dbService->beginOfTime(),
64  dbService->endOfTime(), getRecordName());
65 
66  saved = true;
67 }
68 
69 } // namespace PhysicsTools
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
std::unique_ptr< Calibration::MVAComputer > calib
virtual std::string getRecordName() const =0
bool isAvailable() const
Definition: Service.h:46
virtual const Calibration::MVAComputer * getToPut(const edm::EventSetup &es) const =0
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
MVATrainerSave(const edm::ParameterSet &params)
static bool isUntrained(const T *ptr)
def move(src, dest)
Definition: eostools.py:510
Definition: event.py:1