Belle II Software development
GRLNeuroTrainerModule.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 GRLNEUROTRAINERMODULE_H
10#define GRLNEUROTRAINERMODULE_H
11
12#include <framework/core/Module.h>
13
14#include <trg/grl/GRLNeuro.h>
15#include <trg/grl/dataobjects/GRLMLPData.h>
16
17#include <TH1D.h>
18
19namespace Belle2 {
30 public:
33
36
40 virtual void initialize() override;
41
45 virtual void event() override;
46
48 virtual void terminate() override;
49
52 void updateRelevantID(unsigned isector);
53
55 void train(unsigned isector);
56
61 void saveTraindata(const std::string& filename, const std::string& arrayname = "trainSets");
62
68 bool loadTraindata(const std::string& filename, const std::string& arrayname = "trainSets");
69
70 protected:
71 //module parameters
79 std::string m_filename;
81 std::string m_trainFilename;
83 std::string m_logFilename;
85 std::string m_arrayname;
87 std::string m_trainArrayname;
91 bool m_load;
105 double m_wMax;
116
120 std::vector<GRLMLPData> m_trainSets;
121
122 //..ECL look up tables
123 std::vector<int> TCThetaID;
124 std::vector<float> TCPhiLab;
125 std::vector<float> TCcotThetaLab;
126 std::vector<float> TCPhiCOM;
127 std::vector<float> TCThetaCOM;
128 std::vector<float> TC1GeV;
130 double radtodeg = 0;
131
137 int n_sector = 0;
138
140 std::vector<TH1D*> h_cdc2d_phi_sig;
141 std::vector<TH1D*> h_cdc2d_pt_sig;
142 std::vector<TH1D*> h_selE_sig;
143 std::vector<TH1D*> h_selPhi_sig;
144 std::vector<TH1D*> h_selTheta_sig;
145 std::vector<TH1D*> h_result_sig;
146 std::vector<TH1D*> h_cdc2d_phi_bg;
147 std::vector<TH1D*> h_cdc2d_pt_bg;
148 std::vector<TH1D*> h_selE_bg;
149 std::vector<TH1D*> h_selPhi_bg;
150 std::vector<TH1D*> h_selTheta_bg;
151 std::vector<TH1D*> h_result_bg;
152 std::vector<TH1D*> h_ncdc_sig;
153 std::vector<TH1D*> h_ncdcf_sig;
154 std::vector<TH1D*> h_ncdcs_sig;
155 std::vector<TH1D*> h_ncdci_sig;
156 std::vector<TH1D*> h_necl_sig;
157 std::vector<TH1D*> h_ncdc_bg;
158 std::vector<TH1D*> h_ncdcf_bg;
159 std::vector<TH1D*> h_ncdcs_bg;
160 std::vector<TH1D*> h_ncdci_bg;
161 std::vector<TH1D*> h_necl_bg;
162
164 std::vector<int> scale_bg;
165
166 };
168}
169
170#endif
The trainer module for the neural networks of the CDC trigger.
bool loadTraindata(const std::string &filename, const std::string &arrayname="trainSets")
Load saved training samples.
int m_maxEpochs
Maximal number of training epochs.
GRLNeuroTrainerModule()
Constructor, for setting module description and parameters.
int m_nValid
Number of validation samples.
bool m_load
Switch to load saved parameters from a previous run.
double radtodeg
convert radian to degree
virtual void initialize() override
Initialize the module.
std::string m_TrgECLClusterName
Name of the StoreArray containing the ECL clusters.
int m_checkInterval
Training is stopped if validation error is higher than checkInterval epochs ago, i....
GRLNeuro m_GRLNeuro
Instance of the NeuroTrigger.
virtual void event() override
Called once for each event.
int n_cdc_sector
Number of CDC sectors.
GRLNeuro::Parameters m_parameters
Parameters for the NeuroTrigger.
void updateRelevantID(unsigned isector)
calculate and set the relevant id range for given sector based on hit counters of the track segments.
double m_wMax
Limit for weights.
std::string m_arrayname
Name of the TObjArray holding the networks.
virtual void terminate() override
Do the training for all sectors.
bool m_multiplyNTrain
Switch to multiply number of samples with number of weights.
int m_nThreads
Number of threads for training.
int m_nTest
Number of test samples.
std::string m_GRLCollectionName
Name of the StoreObj containing the input GRL.
std::string m_logFilename
Name of file where training log is stored.
std::string m_trainFilename
Name of file where training samples are stored.
void train(unsigned isector)
Train a single MLP.
std::string m_2DfinderCollectionName
Name of the StoreArray containing the input 2D tracks.
int n_ecl_sector
Number of ECL sectors.
std::vector< TH1D * > h_cdc2d_phi_sig
Histograms for monitoring.
double m_nTrainMin
Minimal number of training samples.
virtual ~GRLNeuroTrainerModule()
Destructor.
std::string m_filename
Name of file where network weights etc.
std::vector< GRLMLPData > m_trainSets
Sets of training data for all sectors.
void saveTraindata(const std::string &filename, const std::string &arrayname="trainSets")
Save all training samples.
std::vector< int > scale_bg
BG scale factor for training.
double m_nTrainMax
Maximal number of training samples.
bool m_saveDebug
If true, save training curve and parameter distribution of training data.
std::string m_trainArrayname
Name of the TObjArray holding the training samples.
int n_sector
Number of Total sectors.
int m_repeatTrain
Number of training runs with different random start weights.
Class to represent the GRL Neuro.
Definition: GRLNeuro.h:35
Base class for Modules.
Definition: Module.h:72
Abstract base class for different kinds of events.
Struct to keep neurotrigger parameters.
Definition: GRLNeuro.h:41