Belle II Software  release-06-00-14
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 
15 namespace Belle2 {
26  class CDCTriggerNeuroConfig: public TObject {
27  public:
30 
32  virtual ~CDCTriggerNeuroConfig() {};
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  {
75  B2FormatLine b;
76  b.start = start;
77  b.end = end;
78  b.offset = offset;
79  b.name = name;
80  b.description = description;
81  addB2FormatLine(b);
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  }
98  m_MLPs.clear();
99  for (int isector = 0; isector < MLPs->GetEntriesFast(); ++isector) {
100  CDCTriggerMLP* expert = dynamic_cast<CDCTriggerMLP*>(MLPs->At(isector));
101  if (expert) m_MLPs.push_back(*expert);
102  }
103  MLPs->Clear();
104  delete MLPs;
105  datafile.Close();
106  }
108  void setNNNotes(const std::string& notes)
109  {
110  if (notes.size() <= 255) {
111  m_NNNotes = notes;
112  }
113  }
115  void setUseETF(bool b)
116  {
117  m_useETF = b;
118  }
120  void setPPNotes(const std::string& notes)
121  {
122  if (notes.size() <= 255) {
123  m_PPNotes = notes;
124  }
125  }
127  void setNNTFirmwareVersionID(const std::string& version)
128  {
129  if (version.size() <= 255) {
130  m_NNTFirmwareVersionID = version;
131  }
132  }
134  void setNNTFirmwareComment(const std::string& notes)
135  {
136  if (notes.size() <= 255) {
137  m_NNTFirmwareComment = notes;
138  }
139  }
141  std::vector<B2FormatLine> getB2Format() const {return m_B2Format;}
143  std::string getNNName() const {return m_NNName;}
145  std::vector<CDCTriggerMLP> getMLPs() const {return m_MLPs;}
147  std::string getNNNotes() const {return m_NNNotes;}
149  bool getUseETF() const {return m_useETF;}
151  std::string getPPNotes() const {return m_PPNotes;}
153  std::string getNNTFirmwareVersionID() const {return m_NNTFirmwareVersionID;}
155  std::string getNNTFirmwareComment() const {return m_NNTFirmwareComment;}
156 
157  private:
159  std::vector<B2FormatLine> m_B2Format = {};
160 
162  std::string m_NNName;
163 
165  std::vector<CDCTriggerMLP> m_MLPs;
166 
168  std::string m_NNNotes;
169 
172  bool m_useETF = false;
173 
175  std::string m_PPNotes;
176 
179 
181  std::string m_NNTFirmwareComment;
182 
184  };
186 } // end of namespace Belle2
187 
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 > 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
std::vector< CDCTriggerMLP > getMLPs() const
return loaded CDCTriggerMPL objects
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::vector< B2FormatLine > getB2Format() const
return b2link format
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
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