Belle II Software development
CDCTriggerMLPData::NeuroSet Struct Reference

Struct to keep one set of training data for either training, validation or testing. More...

#include <CDCTriggerMLPData.h>

Public Member Functions

 NeuroSet (int inlen=27)
 
 NeuroSet (std::vector< float > xin, std::vector< float > xout, int xexp, int xrun, int xsubrun, int xevt, int xtrack, unsigned xexpert, int xntracks, int xnnrawz, int xnnrawtheta, float xnnscalez, float xnnscaletheta, float xinphi, float xintheta, float xininvpt, float xinpt)
 

Public Attributes

std::vector< float > input
 
std::vector< float > target
 
int exp
 
int run
 
int subrun
 
int evt
 
int track
 
int ntracks
 
float nnscalez
 
float nnscaletheta
 
int nnrawz
 
int nnrawtheta
 
float inphi
 
float intheta
 
unsigned expert
 
float ininvpt
 
float pt
 
std::string headline
 

Friends

std::ostream & operator<< (std::ostream &out, const NeuroSet &dset)
 
std::istream & operator>> (std::istream &in, NeuroSet &dset)
 

Detailed Description

Struct to keep one set of training data for either training, validation or testing.

Having this struct makes it easier to save the data to an output filestream.

Definition at line 92 of file CDCTriggerMLPData.h.

Constructor & Destructor Documentation

◆ NeuroSet() [1/2]

NeuroSet ( int inlen = 27)
inline

Definition at line 112 of file CDCTriggerMLPData.h.

113 {
114 headline = "Experiment\tRun\tSubrun\tEvent\tTrack\tnTracks\tExpert\tiNodes\toNodes\t";
115 unsigned InputPerSL = inlen / 9; // Suppose always use 9 SL
116 for (unsigned i = 0; i < inlen / InputPerSL; ++i) {
117 headline += "SL" + std::to_string(i) + "-relID\t";
118 headline += "SL" + std::to_string(i) + "-driftT\t";
119 headline += "SL" + std::to_string(i) + "-alpha\t";
120 for (unsigned j = 0; j < InputPerSL - 3; ++j) {
121 headline += "SL" + std::to_string(i) + "-extra_input" + std::to_string(j) + "\t";
122 }
123 }
124 headline += "RecoZ\tRecoTheta\tScaleZ\tRawZ\tScaleTheta\tRawTheta\t2DPhi\t3DTheta\t2DinvPt\t2DPt\n";
125 }

◆ NeuroSet() [2/2]

NeuroSet ( std::vector< float > xin,
std::vector< float > xout,
int xexp,
int xrun,
int xsubrun,
int xevt,
int xtrack,
unsigned xexpert,
int xntracks,
int xnnrawz,
int xnnrawtheta,
float xnnscalez,
float xnnscaletheta,
float xinphi,
float xintheta,
float xininvpt,
float xinpt )
inline

Definition at line 127 of file CDCTriggerMLPData.h.

130 {
131 input = xin;
132 target = xout;
133 exp = xexp;
134 run = xrun;
135 subrun = xsubrun;
136 evt = xevt;
137 track = xtrack;
138 expert = xexpert;
139
140 ntracks = xntracks;
141 nnscalez = xnnscalez;
142 nnscaletheta = xnnscaletheta;
143 nnrawz = xnnrawz;
144 nnrawtheta = xnnrawtheta;
145 inphi = xinphi;
146 intheta = xintheta;
147 ininvpt = xininvpt;
148 pt = xinpt;
149 headline = "Experiment\tRun\tSubrun\tEvent\tTrack\tnTracks\tExpert\tiNodes\toNodes\t";
150 unsigned inlen = input.size();
151 unsigned InputPerSL = inlen / 9; // Suppose always use 9 SL
152 for (unsigned i = 0; i < inlen / InputPerSL; ++i) {
153 headline += "SL" + std::to_string(i) + "-relID\t";
154 headline += "SL" + std::to_string(i) + "-driftT\t";
155 headline += "SL" + std::to_string(i) + "-alpha\t";
156 for (unsigned j = 0; j < InputPerSL - 3; ++j) {
157 headline += "SL" + std::to_string(i) + "-extra_input" + std::to_string(j) + "\t";
158 }
159 }
160 headline += "RecoZ\tRecoTheta\tScaleZ\tRawZ\tScaleTheta\tRawTheta\t2DPhi\t3DTheta\t2DinvPt\t2DPt\n";
161
162 }

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const NeuroSet & dset )
friend

Definition at line 163 of file CDCTriggerMLPData.h.

164 {
165 out << dset.exp << '\t' << dset.run << '\t' << dset.subrun << '\t' << dset.evt << '\t' << dset.track << '\t' << dset.ntracks << '\t'
166 << dset.expert << '\t'
167 << dset.input.size() << '\t' << dset.target.size() << '\t';
168 for (auto indata : dset.input) {out << indata << '\t';}
169 for (auto outdata : dset.target) {out << outdata << '\t';}
170 out << dset.nnscalez << '\t' << dset.nnrawz << '\t' << dset.nnscaletheta << '\t' << dset.nnrawtheta << '\t' << dset.inphi << '\t' <<
171 dset.intheta << '\t' << dset.ininvpt << '\t' << dset.pt;
172 return out;
173 }

◆ operator>>

std::istream & operator>> ( std::istream & in,
NeuroSet & dset )
friend

Definition at line 174 of file CDCTriggerMLPData.h.

175 {
176 std::string help;
177 help = "";
178 std::getline(in, help, '\t');
179 if (help.length() < 2) {return in;}
180 dset.exp = std::stoi(help);
181 help = "";
182 std::getline(in, help, '\t');
183 dset.run = std::stoi(help);
184 help = "";
185 std::getline(in, help, '\t');
186 dset.subrun = std::stoi(help);
187 help = "";
188 std::getline(in, help, '\t');
189 dset.evt = std::stoi(help);
190 help = "";
191 std::getline(in, help, '\t');
192 dset.track = std::stoi(help);
193 help = "";
194 std::getline(in, help, '\t');
195 dset.ntracks = std::stoi(help);
196 help = "";
197 std::getline(in, help, '\t');
198 dset.expert = std::stoul(help);
199 // check if input and target size match:
200 std::string insize = "";
201 std::string outsize = "";
202 std::getline(in, insize, '\t');
203 dset.input.assign(std::stoul(insize), -1);
204 /*
205 if (std::stoul(insize) != inLen) {
206 B2ERROR("Input and output format of neurotrigger training data does not match!");
207 }
208 */
209 std::getline(in, outsize, '\t');
210 dset.target.assign(std::stoul(outsize), -1);
211 /*
212 if (std::stoul(outsize) != outLen) {
213 B2ERROR("Input and output format of neurotrigger training data does not match!");
214 }
215 */
216 for (unsigned i = 0; i < std::stoul(insize); ++i) {
217 help = "";
218 std::getline(in, help, '\t');
219 try {
220 dset.input[i] = std::stof(help);
221 } catch (const std::out_of_range& oor) {
222 B2WARNING("out of range error: " << help << " is not in float range!");
223 dset.input[i] = 0.;
224 }
225 }
226 for (unsigned i = 0; i < std::stoul(outsize); ++i) {
227 help = "";
228 std::getline(in, help, '\t');
229 try {
230 dset.target[i] = std::stof(help);
231 } catch (const std::out_of_range& oor) {
232 B2WARNING("out of range error: " << help << " is not in float range!");
233 dset.target[i] = 0.;
234 }
235 }
236 help = "";
237 std::getline(in, help, '\t');
238 dset.nnscalez = std::stof(help);
239 help = "";
240 std::getline(in, help, '\t');
241 dset.nnrawz = std::stoi(help);
242 help = "";
243 std::getline(in, help, '\t');
244 dset.nnscaletheta = std::stof(help);
245 help = "";
246 std::getline(in, help, '\t');
247 dset.nnrawtheta = std::stoi(help);
248 help = "";
249 std::getline(in, help, '\t');
250 dset.inphi = std::stof(help);
251 help = "";
252 std::getline(in, help, '\t');
253 dset.intheta = std::stof(help);
254 help = "";
255 std::getline(in, help, '\t');
256 dset.ininvpt = std::stof(help);
257 help = "";
258 return in;
259 }

Member Data Documentation

◆ evt

int evt

Definition at line 99 of file CDCTriggerMLPData.h.

◆ exp

int exp

Definition at line 96 of file CDCTriggerMLPData.h.

◆ expert

unsigned expert

Definition at line 108 of file CDCTriggerMLPData.h.

◆ headline

std::string headline

Definition at line 111 of file CDCTriggerMLPData.h.

◆ ininvpt

float ininvpt

Definition at line 109 of file CDCTriggerMLPData.h.

◆ inphi

float inphi

Definition at line 106 of file CDCTriggerMLPData.h.

◆ input

std::vector<float> input

Definition at line 94 of file CDCTriggerMLPData.h.

◆ intheta

float intheta

Definition at line 107 of file CDCTriggerMLPData.h.

◆ nnrawtheta

int nnrawtheta

Definition at line 105 of file CDCTriggerMLPData.h.

◆ nnrawz

int nnrawz

Definition at line 104 of file CDCTriggerMLPData.h.

◆ nnscaletheta

float nnscaletheta

Definition at line 103 of file CDCTriggerMLPData.h.

◆ nnscalez

float nnscalez

Definition at line 102 of file CDCTriggerMLPData.h.

◆ ntracks

int ntracks

Definition at line 101 of file CDCTriggerMLPData.h.

◆ pt

float pt

Definition at line 110 of file CDCTriggerMLPData.h.

◆ run

int run

Definition at line 97 of file CDCTriggerMLPData.h.

◆ subrun

int subrun

Definition at line 98 of file CDCTriggerMLPData.h.

◆ target

std::vector<float> target

Definition at line 95 of file CDCTriggerMLPData.h.

◆ track

int track

Definition at line 100 of file CDCTriggerMLPData.h.


The documentation for this struct was generated from the following file: