Belle II Software development
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 }
54 };
55 std::vector<std::vector<float>> ecltaunn_weight[N_config];
56 for (int i = 0; i < N_config; i++) {
57 for (unsigned j = 0; j < ecltaunn_nMLP[i]; j++) {
58 std::ifstream wfile(wfilename[i][j]);
59 if (!wfile.is_open()) {
60 return;
61 } else {
62 float element;
63 std::vector<float> ecltaunn_weight_temp;
64 while (wfile >> element) {
65 ecltaunn_weight_temp.push_back(element);
66 }
67 ecltaunn_weight[i].push_back(ecltaunn_weight_temp);
68 }
69 }
70 }
71
72 char bfilename[N_config][10][1000] = {{{
73 "/home/t2k/taichiro/public/grl/bias.dat"
74 }
75 }
76 };
77 std::vector<std::vector<float>> ecltaunn_bias[N_config];
78 for (int i = 0; i < N_config; i++) {
79 for (unsigned j = 0; j < ecltaunn_nMLP[i]; j++) {
80 std::ifstream bfile(bfilename[i][j]);
81 if (!bfile.is_open()) {
82 return;
83 } else {
84 float element;
85 std::vector<float> ecltaunn_bias_temp;
86 while (bfile >> element) {
87 ecltaunn_bias_temp.push_back(element);
88 }
89 ecltaunn_bias[i].push_back(ecltaunn_bias_temp);
90 }
91 }
92 }
93
95 db_grlconfig.construct();
96 if (ONLINE == 0) {
97 for (int i = 0; i < N_config; i++) {
98 IntervalOfValidity iov(run[i][0], run[i][1], run[i][2], run[i][3]);
99 db_grlconfig->set_ecltaunn_threshold(ecltaunn_threshold[i]);
100 db_grlconfig->set_ecltaunn_nMLP(ecltaunn_nMLP[i]);
101 db_grlconfig->set_ecltaunn_multiplyHidden(ecltaunn_multiplyHidden[i]);
102 db_grlconfig->set_ecltaunn_nHidden(ecltaunn_nHidden[i]);
103 db_grlconfig->set_ecltaunn_n_cdc_sector(ecltaunn_n_cdc_sector[i]);
104 db_grlconfig->set_ecltaunn_n_ecl_sector(ecltaunn_n_ecl_sector[i]);
105 db_grlconfig->set_ecltaunn_i_cdc_sector(ecltaunn_i_cdc_sector[i]);
106 db_grlconfig->set_ecltaunn_i_ecl_sector(ecltaunn_i_ecl_sector[i]);
107 db_grlconfig->set_ecltaunn_weight(ecltaunn_weight[i]);
108 db_grlconfig->set_ecltaunn_bias(ecltaunn_bias[i]);
109 db_grlconfig.import(iov);
110 }
111 } else if (ONLINE == 1) {
112 for (int i = N_config - 1; i < N_config; i++) {
113 IntervalOfValidity iov(0, 0, -1, -1);
114 db_grlconfig->set_ecltaunn_threshold(ecltaunn_threshold[i]);
115 db_grlconfig->set_ecltaunn_nMLP(ecltaunn_nMLP[i]);
116 db_grlconfig->set_ecltaunn_multiplyHidden(ecltaunn_multiplyHidden[i]);
117 db_grlconfig->set_ecltaunn_nHidden(ecltaunn_nHidden[i]);
118 db_grlconfig->set_ecltaunn_n_cdc_sector(ecltaunn_n_cdc_sector[i]);
119 db_grlconfig->set_ecltaunn_n_ecl_sector(ecltaunn_n_ecl_sector[i]);
120 db_grlconfig->set_ecltaunn_i_cdc_sector(ecltaunn_i_cdc_sector[i]);
121 db_grlconfig->set_ecltaunn_i_ecl_sector(ecltaunn_i_ecl_sector[i]);
122 db_grlconfig->set_ecltaunn_weight(ecltaunn_weight[i]);
123 db_grlconfig->set_ecltaunn_bias(ecltaunn_bias[i]);
124 db_grlconfig.import(iov);
125 }
126 }
127}
128
129int main()
130{
131
132 setgrlconfig();
133
134}
135
136
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.