Belle II Software  release-05-02-19
CDCTriggerNeuroConfig.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Felix Meggendorfer *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <TObject.h>
13 #include <TFile.h>
14 #include <trg/cdc/dataobjects/CDCTriggerMLP.h>
15 #include <string>
16 
17 namespace Belle2 {
28  class CDCTriggerNeuroConfig: public TObject {
29  public:
32 
34  virtual ~CDCTriggerNeuroConfig() {};
35 
36  struct B2FormatLine {
37  B2FormatLine() : start(0), end(0), offset(0), name("None") {}
39  int start;
41  int end;
43  int offset;
45  std::string name;
47  std::string description;
48  };
50  void setB2Format(const std::vector<B2FormatLine>& format)
51  {
52  for (auto line : format) {
54  }
55  }
57  B2FormatLine getB2FormatLine(const std::string& name) const
58  {
59  B2FormatLine ret;
60  for (auto line : m_B2Format) {
61  if (name == line.name) {
62  ret = line;
63  continue;
64  }
65  }
66  return ret;
67  }
68 
70  void addB2FormatLine(const B2FormatLine& line)
71  {
72  m_B2Format.push_back(line);
73  }
75  void addB2FormatLine(int start, int end, int offset, const std::string& name, const std::string& description)
76  {
77  B2FormatLine b;
78  b.start = start;
79  b.end = end;
80  b.offset = offset;
81  b.name = name;
82  b.description = description;
84  }
86  void setNNName(const std::string& filename)
87  {
88  if (filename.size() <= 255) {
89  m_NNName = filename;
90  }
91  }
93  void loadMLPs(const std::string& filename, const std::string& arrayname)
94  {
95  TFile datafile(filename.c_str(), "READ");
96  TObjArray* MLPs = (TObjArray*)datafile.Get(arrayname.c_str());
97  if (!MLPs) {
98  datafile.Close();
99  }
100  m_MLPs.clear();
101  for (int isector = 0; isector < MLPs->GetEntriesFast(); ++isector) {
102  CDCTriggerMLP* expert = dynamic_cast<CDCTriggerMLP*>(MLPs->At(isector));
103  if (expert) m_MLPs.push_back(*expert);
104  }
105  MLPs->Clear();
106  delete MLPs;
107  datafile.Close();
108  }
110  void setNNNotes(const std::string& notes)
111  {
112  if (notes.size() <= 255) {
113  m_NNNotes = notes;
114  }
115  }
117  void setUseETF(bool b)
118  {
119  m_useETF = b;
120  }
122  void setPPNotes(const std::string& notes)
123  {
124  if (notes.size() <= 255) {
125  m_PPNotes = notes;
126  }
127  }
129  void setNNTFirmwareVersionID(const std::string& version)
130  {
131  if (version.size() <= 255) {
132  m_NNTFirmwareVersionID = version;
133  }
134  }
136  void setNNTFirmwareComment(const std::string& notes)
137  {
138  if (notes.size() <= 255) {
139  m_NNTFirmwareComment = notes;
140  }
141  }
143  std::vector<B2FormatLine> getB2Format() const {return m_B2Format;}
145  std::string getNNName() const {return m_NNName;}
147  std::vector<CDCTriggerMLP> getMLPs() const {return m_MLPs;}
149  std::string getNNNotes() const {return m_NNNotes;}
151  bool getUseETF() const {return m_useETF;}
153  std::string getPPNotes() const {return m_PPNotes;}
155  std::string getNNTFirmwareVersionID() const {return m_NNTFirmwareVersionID;}
157  std::string getNNTFirmwareComment() const {return m_NNTFirmwareComment;}
158 
159  private:
161  std::vector<B2FormatLine> m_B2Format = {};
162 
164  std::string m_NNName;
165 
167  std::vector<CDCTriggerMLP> m_MLPs;
168 
170  std::string m_NNNotes;
171 
174  bool m_useETF = false;
175 
177  std::string m_PPNotes;
178 
180  std::string m_NNTFirmwareVersionID;
181 
183  std::string m_NNTFirmwareComment;
184 
186  };
188 } // end of namespace Belle2
189 
Belle2::CDCTriggerNeuroConfig::ClassDef
ClassDef(CDCTriggerNeuroConfig, 3)
ClassDef, must be the last term before the closing {}.
Belle2::CDCTriggerNeuroConfig::CDCTriggerNeuroConfig
CDCTriggerNeuroConfig()
constructor
Definition: CDCTriggerNeuroConfig.h:39
Belle2::CDCTriggerNeuroConfig::getMLPs
std::vector< CDCTriggerMLP > getMLPs() const
return loaded CDCTriggerMPL objects
Definition: CDCTriggerNeuroConfig.h:155
Belle2::CDCTriggerNeuroConfig::setB2Format
void setB2Format(const std::vector< B2FormatLine > &format)
function to directly set b2link format
Definition: CDCTriggerNeuroConfig.h:58
Belle2::CDCTriggerNeuroConfig::addB2FormatLine
void addB2FormatLine(const B2FormatLine &line)
function to add line to b2link format, overloaded
Definition: CDCTriggerNeuroConfig.h:78
Belle2::CDCTriggerNeuroConfig::getB2Format
std::vector< B2FormatLine > getB2Format() const
return b2link format
Definition: CDCTriggerNeuroConfig.h:151
Belle2::CDCTriggerNeuroConfig::m_B2Format
std::vector< B2FormatLine > m_B2Format
B2Format.
Definition: CDCTriggerNeuroConfig.h:169
Belle2::CDCTriggerNeuroConfig::m_NNNotes
std::string m_NNNotes
short field for notes
Definition: CDCTriggerNeuroConfig.h:178
Belle2::CDCTriggerNeuroConfig::B2FormatLine::end
int end
end bit number in B2Link
Definition: CDCTriggerNeuroConfig.h:49
Belle2::CDCTriggerNeuroConfig::setNNName
void setNNName(const std::string &filename)
set name of neural network version
Definition: CDCTriggerNeuroConfig.h:94
Belle2::CDCTriggerNeuroConfig::m_MLPs
std::vector< CDCTriggerMLP > m_MLPs
weights of expert networks
Definition: CDCTriggerNeuroConfig.h:175
Belle2::CDCTriggerNeuroConfig::getUseETF
bool getUseETF() const
return bool wether ETF is used or not
Definition: CDCTriggerNeuroConfig.h:159
Belle2::CDCTriggerNeuroConfig::getB2FormatLine
B2FormatLine getB2FormatLine(const std::string &name) const
function to return right line of b2link format
Definition: CDCTriggerNeuroConfig.h:65
Belle2::CDCTriggerNeuroConfig::m_useETF
bool m_useETF
switch wether the ETF is used or the first priority time of the TSF is used during preprocessing
Definition: CDCTriggerNeuroConfig.h:182
Belle2::CDCTriggerNeuroConfig::m_PPNotes
std::string m_PPNotes
short field for notes
Definition: CDCTriggerNeuroConfig.h:185
Belle2::CDCTriggerNeuroConfig::m_NNTFirmwareVersionID
std::string m_NNTFirmwareVersionID
Firmware Version ID.
Definition: CDCTriggerNeuroConfig.h:188
Belle2::CDCTriggerNeuroConfig::B2FormatLine::offset
int offset
offset of information in B2Link
Definition: CDCTriggerNeuroConfig.h:51
Belle2::CDCTriggerNeuroConfig::B2FormatLine::start
int start
start bit number in B2Link
Definition: CDCTriggerNeuroConfig.h:47
Belle2::CDCTriggerNeuroConfig::setNNTFirmwareVersionID
void setNNTFirmwareVersionID(const std::string &version)
set the firmware version id
Definition: CDCTriggerNeuroConfig.h:137
Belle2::CDCTriggerNeuroConfig::getNNTFirmwareVersionID
std::string getNNTFirmwareVersionID() const
return firmware version
Definition: CDCTriggerNeuroConfig.h:163
Belle2::CDCTriggerNeuroConfig::getNNTFirmwareComment
std::string getNNTFirmwareComment() const
returncomment on firmware version
Definition: CDCTriggerNeuroConfig.h:165
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCTriggerNeuroConfig::getPPNotes
std::string getPPNotes() const
return notes on preprocessing
Definition: CDCTriggerNeuroConfig.h:161
Belle2::CDCTriggerNeuroConfig::addB2FormatLine
void addB2FormatLine(int start, int end, int offset, const std::string &name, const std::string &description)
function to add line to b2link format, overloaded
Definition: CDCTriggerNeuroConfig.h:83
Belle2::CDCTriggerNeuroConfig::setUseETF
void setUseETF(bool b)
set bool wether ETF is used or not
Definition: CDCTriggerNeuroConfig.h:125
Belle2::CDCTriggerNeuroConfig
The payload class for all CDC Neurotrigger information.
Definition: CDCTriggerNeuroConfig.h:36
Belle2::CDCTriggerNeuroConfig::setPPNotes
void setPPNotes(const std::string &notes)
add some notes about the preprocessing
Definition: CDCTriggerNeuroConfig.h:130
Belle2::CDCTriggerNeuroConfig::m_NNTFirmwareComment
std::string m_NNTFirmwareComment
Short comment on Firmware.
Definition: CDCTriggerNeuroConfig.h:191
Belle2::CDCTriggerNeuroConfig::B2FormatLine
Definition: CDCTriggerNeuroConfig.h:44
Belle2::CDCTriggerNeuroConfig::m_NNName
std::string m_NNName
Used neurotrigger filename.
Definition: CDCTriggerNeuroConfig.h:172
Belle2::CDCTriggerNeuroConfig::~CDCTriggerNeuroConfig
virtual ~CDCTriggerNeuroConfig()
destructor
Definition: CDCTriggerNeuroConfig.h:42
Belle2::CDCTriggerNeuroConfig::setNNTFirmwareComment
void setNNTFirmwareComment(const std::string &notes)
add a comment to the firmware version
Definition: CDCTriggerNeuroConfig.h:144
Belle2::CDCTriggerNeuroConfig::B2FormatLine::description
std::string description
description of information in B2link
Definition: CDCTriggerNeuroConfig.h:55
Belle2::CDCTriggerNeuroConfig::setNNNotes
void setNNNotes(const std::string &notes)
add some notes to the verison of MLPS
Definition: CDCTriggerNeuroConfig.h:118
Belle2::CDCTriggerNeuroConfig::getNNNotes
std::string getNNNotes() const
return neural network notes
Definition: CDCTriggerNeuroConfig.h:157
Belle2::CDCTriggerNeuroConfig::B2FormatLine::name
std::string name
name of information in B2link
Definition: CDCTriggerNeuroConfig.h:53
Belle2::CDCTriggerNeuroConfig::loadMLPs
void loadMLPs(const std::string &filename, const std::string &arrayname)
load MLP objects from file
Definition: CDCTriggerNeuroConfig.h:101
Belle2::CDCTriggerNeuroConfig::getNNName
std::string getNNName() const
return neural network name
Definition: CDCTriggerNeuroConfig.h:153
Belle2::CDCTriggerMLP
Class to keep all parameters of an expert MLP for the neuro trigger.
Definition: CDCTriggerMLP.h:13