Belle II Software development
CDCTriggerMLPData::NeuroSet< inLen, outLen > Struct Template Reference

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

#include <CDCTriggerMLPData.h>

Public Member Functions

 NeuroSet (float xin[inLen], float xout[outLen], 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)
 

Public Attributes

float input [inLen]
 
float target [outLen]
 
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
 
std::string headline
 

Friends

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

Detailed Description

template<const unsigned inLen, const unsigned outLen>
struct Belle2::CDCTriggerMLPData::NeuroSet< inLen, outLen >

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 ( )
inline

Definition at line 110 of file CDCTriggerMLPData.h.

111 {
112 headline = "Experiment\tRun\tSubrun\tEvent\tTrack\tnTracks\tExpert\tiNodes\toNodes\t";
113 for (unsigned i = 0; i < inLen / 3; ++i) {
114 headline += "SL" + std::to_string(i) + "-relID\t";
115 headline += "SL" + std::to_string(i) + "-driftT\t";
116 headline += "SL" + std::to_string(i) + "-alpha\t";
117 }
118 headline += "RecoZ\tRecoTheta\tScaleZ\tRawZ\tScaleTheta\tRawTheta\t2DPhi\t3DTheta\t2DinvPt\n";
119 }

◆ NeuroSet() [2/2]

NeuroSet ( float  xin[inLen],
float  xout[outLen],
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 
)
inline

Definition at line 121 of file CDCTriggerMLPData.h.

123 {
124 for (unsigned i = 0; i < inLen; ++i) {
125 input[i] = xin[i];
126 }
127 for (unsigned i = 0; i < outLen; ++i) {
128 target[i] = xout[i];
129 }
130 exp = xexp;
131 run = xrun;
132 subrun = xsubrun;
133 evt = xevt;
134 track = xtrack;
135 expert = xexpert;
136
137 ntracks = xntracks;
138 nnscalez = xnnscalez;
139 nnscaletheta = xnnscaletheta;
140 nnrawz = xnnrawz;
141 nnrawtheta = xnnrawtheta;
142 inphi = xinphi;
143 intheta = xintheta;
144 ininvpt = xininvpt;
145 headline = "Experiment\tRun\tSubrun\tEvent\tTrack\tnTracks\tExpert\tiNodes\toNodes\t";
146 for (unsigned i = 0; i < inLen / 3; ++i) {
147 headline += "SL" + std::to_string(i) + "-relID\t";
148 headline += "SL" + std::to_string(i) + "-driftT\t";
149 headline += "SL" + std::to_string(i) + "-alpha\t";
150 }
151 headline += "RecoZ\tRecoTheta\tScaleZ\tRawZ\tScaleTheta\tRawTheta\t2DPhi\t3DTheta\t2DinvPt\n";
152
153 }

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 154 of file CDCTriggerMLPData.h.

155 {
156 out << dset.exp << '\t' << dset.run << '\t' << dset.subrun << '\t' << dset.evt << '\t' << dset.track << '\t' << dset.ntracks << '\t'
157 << dset.expert << '\t'
158 << inLen << '\t' << outLen << '\t';
159 for (auto indata : dset.input) {out << indata << '\t';}
160 for (auto outdata : dset.target) {out << outdata << '\t';}
161 out << dset.nnscalez << '\t' << dset.nnrawz << '\t' << dset.nnscaletheta << '\t' << dset.nnrawtheta << '\t' << dset.inphi << '\t' <<
162 dset.intheta << '\t' << dset.ininvpt << '\t';
163 return out;
164 }

◆ operator>>

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

Definition at line 165 of file CDCTriggerMLPData.h.

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

Member Data Documentation

◆ evt

int evt

Definition at line 98 of file CDCTriggerMLPData.h.

◆ exp

int exp

Definition at line 95 of file CDCTriggerMLPData.h.

◆ expert

unsigned expert

Definition at line 107 of file CDCTriggerMLPData.h.

◆ headline

std::string headline

Definition at line 109 of file CDCTriggerMLPData.h.

◆ ininvpt

float ininvpt

Definition at line 108 of file CDCTriggerMLPData.h.

◆ inphi

float inphi

Definition at line 105 of file CDCTriggerMLPData.h.

◆ input

float input[inLen]

Definition at line 93 of file CDCTriggerMLPData.h.

◆ intheta

float intheta

Definition at line 106 of file CDCTriggerMLPData.h.

◆ nnrawtheta

int nnrawtheta

Definition at line 104 of file CDCTriggerMLPData.h.

◆ nnrawz

int nnrawz

Definition at line 103 of file CDCTriggerMLPData.h.

◆ nnscaletheta

float nnscaletheta

Definition at line 102 of file CDCTriggerMLPData.h.

◆ nnscalez

float nnscalez

Definition at line 101 of file CDCTriggerMLPData.h.

◆ ntracks

int ntracks

Definition at line 100 of file CDCTriggerMLPData.h.

◆ run

int run

Definition at line 96 of file CDCTriggerMLPData.h.

◆ subrun

int subrun

Definition at line 97 of file CDCTriggerMLPData.h.

◆ target

float target[outLen]

Definition at line 94 of file CDCTriggerMLPData.h.

◆ track

int track

Definition at line 99 of file CDCTriggerMLPData.h.


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