Belle II Software development
GRLNeuro.h
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#ifndef GRLNEURO_H
10#define GRLNEURO_H
11
12#include <trg/grl/dataobjects/GRLMLP.h>
13#include <framework/datastore/StoreArray.h>
14#include <framework/datastore/StoreObjPtr.h>
15#include <framework/database/DBObjPtr.h>
16//#include <trg/cdc/dbobjects/CDCTriggerNeuroConfig.h>
17//#include <framework/dataobjects/BinnedEventT0.h>
18
19namespace Belle2 {
24
35 class GRLNeuro {
36 public:
41 struct Parameters {
47 unsigned nMLP;
52 std::vector<std::vector<float>> nHidden;
54 bool targetresult = true;
56 bool multiplyHidden = false;
58 std::vector<std::vector<float>> outputScale = {{ -1., 1.}};
59
61 unsigned n_cdc_sector;
62 std::vector<float> i_cdc_sector;
64 unsigned n_ecl_sector;
65 std::vector<float> i_ecl_sector;
66 };
67
68
69
72
74 virtual ~GRLNeuro() {}
75
77 void initialize(const Parameters& p);
78
80 GRLMLP& operator[](unsigned index) { return m_MLPs[index]; }
82 const GRLMLP& operator[](unsigned index) const { return m_MLPs[index]; }
84 unsigned nSectors() const { return m_MLPs.size(); }
85
90 void save(const std::string& filename, const std::string& arrayname = "MLPs");
97 bool load(unsigned isector, const std::string& wfilename, const std::string& bfilename);
104 bool load(unsigned isector, std::vector<float> weight, std::vector<float> bias);
105
110 float runMLP(unsigned isector, const std::vector<float>& input);
111
112 private:
114 std::vector<GRLMLP> m_MLPs = {};
115
116 };
117
118}
119#endif
Class to keep all parameters of an expert MLP for the neuro trigger.
Definition GRLMLP.h:21
GRLMLP & operator[](unsigned index)
return reference to a neural network
Definition GRLNeuro.h:80
void initialize(const Parameters &p)
Set parameters and get some network independent parameters.
Definition GRLNeuro.cc:284
virtual ~GRLNeuro()
Default destructor.
Definition GRLNeuro.h:74
bool load(unsigned isector, const std::string &wfilename, const std::string &bfilename)
Load MLPs from file.
Definition GRLNeuro.cc:528
void save(const std::string &filename, const std::string &arrayname="MLPs")
Save MLPs to file.
float runMLP(unsigned isector, const std::vector< float > &input)
Run an expert MLP.
Definition GRLNeuro.cc:387
GRLNeuro()
Default constructor.
Definition GRLNeuro.h:71
const GRLMLP & operator[](unsigned index) const
return const reference to a neural network
Definition GRLNeuro.h:82
std::vector< GRLMLP > m_MLPs
List of networks.
Definition GRLNeuro.h:114
unsigned nSectors() const
return number of neural networks
Definition GRLNeuro.h:84
Abstract base class for different kinds of events.
Struct to keep neurotrigger parameters.
Definition GRLNeuro.h:41
std::vector< std::vector< float > > outputScale
Output scale for all networks.
Definition GRLNeuro.h:58
bool multiplyHidden
If true, multiply nHidden with number of input nodes.
Definition GRLNeuro.h:56
unsigned nMLP
Number of networks.
Definition GRLNeuro.h:47
bool targetresult
train result as output
Definition GRLNeuro.h:54
unsigned n_ecl_sector
Number of ECL sectors.
Definition GRLNeuro.h:64
std::vector< std::vector< float > > nHidden
Number of nodes in each hidden layer for all networks or factor to multiply with number of inputs.
Definition GRLNeuro.h:52
unsigned n_cdc_sector
Number of CDC sectors.
Definition GRLNeuro.h:61