Belle II Software prerelease-10-00-00a
trg-grl-writedb.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <framework/database/DBImportObjPtr.h>
10#include <trg/grl/dbobjects/TRGGRLConfig.h>
11#include <fstream>
12
13using namespace Belle2;
14
15#define ONLINE 0
16//#define ONLINE 1
17
18void setgrlconfig()
19{
20
21 const int N_config = 1;
22
23 const int run[N_config][4] = { //itnitial exp, initial run, end exp, end run
24 {0, 0, -1, -1} // 0
25 };
26
27 float ecltaunn_threshold[N_config] = {
28 -1
29 };
30 unsigned ecltaunn_nMLP[N_config] = {
31 1
32 };
33 bool ecltaunn_multiplyHidden[N_config] = {
34 false
35 };
36 std::vector<std::vector<float>> ecltaunn_nHidden[N_config];
37 ecltaunn_nHidden[0].push_back(std::vector<float>(2, 64));
38 unsigned ecltaunn_n_cdc_sector[N_config] = {
39 0
40 };
41 unsigned ecltaunn_n_ecl_sector[N_config] = {
42 1
43 };
44 std::vector<float> ecltaunn_i_cdc_sector[N_config];
45 ecltaunn_i_cdc_sector[0].push_back(0 * 35 * 3);
46
47 std::vector<float> ecltaunn_i_ecl_sector[N_config]; //only 24 is supported for now
48 ecltaunn_i_ecl_sector[0].push_back(1 * 6 * 4);
49
50 char wfilename[N_config][10][1000] = {
51 "/home/t2k/taichiro/public/grl/weights.dat"
52 };
53 std::vector<std::vector<float>> ecltaunn_weight[N_config];
54 for (int i = 0; i < N_config; i++) {
55 for (unsigned j = 0; j < ecltaunn_nMLP[i]; j++) {
56 std::ifstream wfile(wfilename[i][j]);
57 if (!wfile.is_open()) {
58 return;
59 } else {
60 float element;
61 std::vector<float> ecltaunn_weight_temp;
62 while (wfile >> element) {
63 ecltaunn_weight_temp.push_back(element);
64 }
65 ecltaunn_weight[i].push_back(ecltaunn_weight_temp);
66 }
67 }
68 }
69
70 char bfilename[N_config][10][1000] = {
71 "/home/t2k/taichiro/public/grl/bias.dat"
72 };
73 std::vector<std::vector<float>> ecltaunn_bias[N_config];
74 for (int i = 0; i < N_config; i++) {
75 for (unsigned j = 0; j < ecltaunn_nMLP[i]; j++) {
76 std::ifstream bfile(bfilename[i][j]);
77 if (!bfile.is_open()) {
78 return;
79 } else {
80 float element;
81 std::vector<float> ecltaunn_bias_temp;
82 while (bfile >> element) {
83 ecltaunn_bias_temp.push_back(element);
84 }
85 ecltaunn_bias[i].push_back(ecltaunn_bias_temp);
86 }
87 }
88 }
89
91 db_grlconfig.construct();
92 if (ONLINE == 0) {
93 for (int i = 0; i < N_config; i++) {
94 IntervalOfValidity iov(run[i][0], run[i][1], run[i][2], run[i][3]);
95 db_grlconfig->set_ecltaunn_threshold(ecltaunn_threshold[i]);
96 db_grlconfig->set_ecltaunn_nMLP(ecltaunn_nMLP[i]);
97 db_grlconfig->set_ecltaunn_multiplyHidden(ecltaunn_multiplyHidden[i]);
98 db_grlconfig->set_ecltaunn_nHidden(ecltaunn_nHidden[i]);
99 db_grlconfig->set_ecltaunn_n_cdc_sector(ecltaunn_n_cdc_sector[i]);
100 db_grlconfig->set_ecltaunn_n_ecl_sector(ecltaunn_n_ecl_sector[i]);
101 db_grlconfig->set_ecltaunn_i_cdc_sector(ecltaunn_i_cdc_sector[i]);
102 db_grlconfig->set_ecltaunn_i_ecl_sector(ecltaunn_i_ecl_sector[i]);
103 db_grlconfig->set_ecltaunn_weight(ecltaunn_weight[i]);
104 db_grlconfig->set_ecltaunn_bias(ecltaunn_bias[i]);
105 db_grlconfig.import(iov);
106 }
107 } else if (ONLINE == 1) {
108 for (int i = N_config - 1; i < N_config; i++) {
109 IntervalOfValidity iov(0, 0, -1, -1);
110 db_grlconfig->set_ecltaunn_threshold(ecltaunn_threshold[i]);
111 db_grlconfig->set_ecltaunn_nMLP(ecltaunn_nMLP[i]);
112 db_grlconfig->set_ecltaunn_multiplyHidden(ecltaunn_multiplyHidden[i]);
113 db_grlconfig->set_ecltaunn_nHidden(ecltaunn_nHidden[i]);
114 db_grlconfig->set_ecltaunn_n_cdc_sector(ecltaunn_n_cdc_sector[i]);
115 db_grlconfig->set_ecltaunn_n_ecl_sector(ecltaunn_n_ecl_sector[i]);
116 db_grlconfig->set_ecltaunn_i_cdc_sector(ecltaunn_i_cdc_sector[i]);
117 db_grlconfig->set_ecltaunn_i_ecl_sector(ecltaunn_i_ecl_sector[i]);
118 db_grlconfig->set_ecltaunn_weight(ecltaunn_weight[i]);
119 db_grlconfig->set_ecltaunn_bias(ecltaunn_bias[i]);
120 db_grlconfig.import(iov);
121 }
122 }
123}
124
125int main()
126{
127
128 setgrlconfig();
129
130}
131
132
bool import(const IntervalOfValidity &iov)
Import the object to database.
Class for importing a single object to the database.
void construct(Args &&... params)
Construct an object of type T in this DBImportObjPtr using the provided constructor arguments.
A class that describes the interval of experiments/runs for which an object in the database is valid.
Abstract base class for different kinds of events.