Belle II Software development
CDCTriggerNeuroConfig.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#pragma once
9
10#include <TObject.h>
11#include <TFile.h>
12#include <trg/cdc/dataobjects/CDCTriggerMLP.h>
13#include <string>
14
15namespace Belle2 {
26 class CDCTriggerNeuroConfig: public TObject {
27 public:
30
33
34 struct B2FormatLine {
35 B2FormatLine() : start(0), end(0), offset(0), name("None") {}
37 int start;
39 int end;
41 int offset;
43 std::string name;
45 std::string description;
46 };
48 void setB2Format(const std::vector<B2FormatLine>& format)
49 {
50 for (auto line : format) {
51 addB2FormatLine(line);
52 }
53 }
55 B2FormatLine getB2FormatLine(const std::string& name) const
56 {
57 B2FormatLine ret;
58 for (auto line : m_B2Format) {
59 if (name == line.name) {
60 ret = line;
61 continue;
62 }
63 }
64 return ret;
65 }
66
68 void addB2FormatLine(const B2FormatLine& line)
69 {
70 m_B2Format.push_back(line);
71 }
73 void addB2FormatLine(int start, int end, int offset, const std::string& name, const std::string& description)
74 {
76 b.start = start;
77 b.end = end;
78 b.offset = offset;
79 b.name = name;
80 b.description = description;
82 }
84 void setNNName(const std::string& filename)
85 {
86 if (filename.size() <= 255) {
87 m_NNName = filename;
88 }
89 }
91 void loadMLPs(const std::string& filename, const std::string& arrayname)
92 {
93 TFile datafile(filename.c_str(), "READ");
94 TObjArray* MLPs = (TObjArray*)datafile.Get(arrayname.c_str());
95 if (!MLPs) {
96 datafile.Close();
97 return;
98 }
99 m_MLPs.clear();
100 for (int isector = 0; isector < MLPs->GetEntriesFast(); ++isector) {
101 CDCTriggerMLP* expert = dynamic_cast<CDCTriggerMLP*>(MLPs->At(isector));
102 if (expert) m_MLPs.push_back(*expert);
103 }
104 MLPs->Clear();
105 delete MLPs;
106 datafile.Close();
107 }
109 void setNNNotes(const std::string& notes)
110 {
111 if (notes.size() <= 255) {
112 m_NNNotes = notes;
113 }
114 }
116 void setUseETF(bool b)
117 {
118 m_useETF = b;
119 }
121 void setPPNotes(const std::string& notes)
122 {
123 if (notes.size() <= 255) {
124 m_PPNotes = notes;
125 }
126 }
128 void setNNTFirmwareVersionID(const std::string& version)
129 {
130 if (version.size() <= 255) {
131 m_NNTFirmwareVersionID = version;
132 }
133 }
135 void setNNTFirmwareComment(const std::string& notes)
136 {
137 if (notes.size() <= 255) {
138 m_NNTFirmwareComment = notes;
139 }
140 }
142 std::vector<B2FormatLine> getB2Format() const {return m_B2Format;}
144 std::string getNNName() const {return m_NNName;}
146 std::vector<CDCTriggerMLP> getMLPs() const {return m_MLPs;}
148 std::string getNNNotes() const {return m_NNNotes;}
150 bool getUseETF() const {return m_useETF;}
152 std::string getPPNotes() const {return m_PPNotes;}
156 std::string getNNTFirmwareComment() const {return m_NNTFirmwareComment;}
157
158 private:
160 std::vector<B2FormatLine> m_B2Format = {};
161
163 std::string m_NNName;
164
166 std::vector<CDCTriggerMLP> m_MLPs;
167
169 std::string m_NNNotes;
170
173 bool m_useETF = false;
174
176 std::string m_PPNotes;
177
180
183
185 };
187} // end of namespace Belle2
188
Class to keep all parameters of an expert MLP for the neuro trigger.
Definition: CDCTriggerMLP.h:20
The payload class for all CDC Neurotrigger information.
std::vector< CDCTriggerMLP > getMLPs() const
return loaded CDCTriggerMPL objects
std::vector< CDCTriggerMLP > m_MLPs
weights of expert networks
bool m_useETF
switch wether the ETF is used or the first priority time of the TSF is used during preprocessing
std::string m_NNTFirmwareComment
Short comment on Firmware.
void setB2Format(const std::vector< B2FormatLine > &format)
function to directly set b2link format
void setNNTFirmwareVersionID(const std::string &version)
set the firmware version id
std::string m_NNNotes
short field for notes
std::string m_NNName
Used neurotrigger filename.
void setNNName(const std::string &filename)
set name of neural network version
void setPPNotes(const std::string &notes)
add some notes about the preprocessing
std::string getPPNotes() const
return notes on preprocessing
void setNNTFirmwareComment(const std::string &notes)
add a comment to the firmware version
B2FormatLine getB2FormatLine(const std::string &name) const
function to return right line of b2link format
std::string getNNTFirmwareVersionID() const
return firmware version
std::string getNNNotes() const
return neural network notes
void setNNNotes(const std::string &notes)
add some notes to the verison of MLPS
std::string getNNName() const
return neural network name
virtual ~CDCTriggerNeuroConfig()
destructor
std::vector< B2FormatLine > m_B2Format
B2Format.
void setUseETF(bool b)
set bool wether ETF is used or not
std::vector< B2FormatLine > getB2Format() const
return b2link format
void loadMLPs(const std::string &filename, const std::string &arrayname)
load MLP objects from file
std::string getNNTFirmwareComment() const
returncomment on firmware version
bool getUseETF() const
return bool wether ETF is used or not
void addB2FormatLine(int start, int end, int offset, const std::string &name, const std::string &description)
function to add line to b2link format, overloaded
void addB2FormatLine(const B2FormatLine &line)
function to add line to b2link format, overloaded
std::string m_NNTFirmwareVersionID
Firmware Version ID.
std::string m_PPNotes
short field for notes
ClassDef(CDCTriggerNeuroConfig, 3)
ClassDef, must be the last term before the closing {}.
Abstract base class for different kinds of events.
std::string description
description of information in B2link
std::string name
name of information in B2link
int offset
offset of information in B2Link