Belle II Software  release-05-01-25
SVDDatabaseImporter.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Laura Zani *
7  * *
8  * This software is provided "as is" without any warranty. *
9  * WARNING: Do not try to fry it with water. Use only olive oil. *
10  **************************************************************************/
11 
12 // Own include
13 #include <svd/calibration/SVDDatabaseImporter.h>
14 
15 // framework - Database
16 #include <framework/database/IntervalOfValidity.h>
17 #include <framework/database/DBImportObjPtr.h>
18 
19 // framework aux
20 #include <framework/logging/Logger.h>
21 
22 // wrapper objects
23 #include <mva/dataobjects/DatabaseRepresentationOfWeightfile.h>
24 
25 #include <boost/property_tree/ptree.hpp>
26 
27 #include <iostream>
28 #include <fstream>
29 #include <sstream>
30 
31 using namespace std;
32 using namespace Belle2;
33 using boost::property_tree::ptree;
34 
35 
36 void SVDDatabaseImporter::importSVDHitTimeNeuralNetwork(string fileName, bool threeSamples)
37 {
38  ifstream xml(fileName);
39  if (!xml.good()) {
40  B2RESULT("ERROR: File not found.\nNeural network from " << fileName << " could not be imported.");
41  return;
42  }
43  string label("SVDTimeNet_6samples");
44  if (threeSamples)
45  label = "SVDTimeNet_3samples";
46  stringstream buffer;
47  buffer << xml.rdbuf();
49  importObj.construct();
50  importObj->m_data = buffer.str();
51 
52  IntervalOfValidity iov(m_firstExperiment, m_firstRun,
53  m_lastExperiment, m_lastRun);
54  importObj.import(iov);
55  B2RESULT("Neural network from " << fileName << " successfully imported.");
56 }
Belle2::IntervalOfValidity
A class that describes the interval of experiments/runs for which an object in the database is valid.
Definition: IntervalOfValidity.h:35
Belle2::DBImportObjPtr::construct
void construct(Args &&... params)
Construct an object of type T in this DBImportObjPtr using the provided constructor arguments.
Definition: DBImportObjPtr.h:57
Belle2::DBImportBase::import
bool import(const IntervalOfValidity &iov)
Import the object to database.
Definition: DBImportBase.cc:38
Belle2::DatabaseRepresentationOfWeightfile::m_data
std::string m_data
Serialized weightfile.
Definition: DatabaseRepresentationOfWeightfile.h:42
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DBImportObjPtr
Class for importing a single object to the database.
Definition: DBImportObjPtr.h:33