Belle II Software development
CDCTriggerMLPData Class Reference

Struct for training data of a single MLP for the neuro trigger. More...

#include <CDCTriggerMLPData.h>

Inheritance diagram for CDCTriggerMLPData:

Classes

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

Public Member Functions

 CDCTriggerMLPData ()
 default constructor.
 
 ~CDCTriggerMLPData ()
 destructor, empty because we don't allocate memory anywhere.
 
void addCounters (unsigned nWires)
 add hit counters for a layer with nWires
 
void addHit (unsigned iSL, int iTS)
 increase counter for super layer and track segment number in super layer.
 
void countTrack ()
 increase track counter
 
template<unsigned inLen, unsigned outLen>
void addSample (const NeuroSet< inLen, outLen > &dsample)
 
void addSample (const std::vector< float > &input, const std::vector< float > &target, const int &expnumber, const int &runnumber, const int &subrunnumber, const int &eventnumber, const int &tracknumber)
 add a pair of input and target
 
short getTrackCounter () const
 get track counter
 
unsigned short getHitCounter (unsigned iSL, int iTS) const
 get hit counter for super layer and track segment number is super layer.
 
unsigned nSamples () const
 get number of samples (same for input and target)
 
const std::vector< float > & getInput (unsigned i) const
 get input vector of sample i
 
const std::vector< float > & getTarget (unsigned i) const
 get target value of sample i
 
const std::vector< int > & getevtList () const
 
const std::vector< int > & getEvtList () const
 
const std::vector< int > & getExpList () const
 
const std::vector< int > & getRunList () const
 
const std::vector< int > & getSubRunList () const
 
const std::vector< int > & getTrackList () const
 
const int & getevtnum (unsigned i) const
 

Private Member Functions

 ClassDef (CDCTriggerMLPData, 3)
 Needed to make the ROOT object storable.
 

Private Attributes

std::vector< std::vector< float > > m_inputSamples
 list of input vectors for network training.
 
std::vector< std::vector< float > > m_targetSamples
 list of target values for network training.
 
std::vector< std::vector< unsigned short > > m_hitCounters
 hit counter of active track segment IDs, used to determine the relevant id range for an MLP.
 
short m_trackCounter
 number of tracks used for the hit counter.
 
std::vector< int > m_expList
 Vectors for experiment, run, event and tracknumber.
 
std::vector< int > m_runList
 
std::vector< int > m_subRunList
 
std::vector< int > m_evtList
 List for debug purposes to store the event number for every entry of input/target vector.
 
std::vector< int > m_trackList
 

Detailed Description

Struct for training data of a single MLP for the neuro trigger.

Definition at line 27 of file CDCTriggerMLPData.h.

Constructor & Destructor Documentation

◆ CDCTriggerMLPData()

CDCTriggerMLPData ( )
inline

default constructor.

Definition at line 248 of file CDCTriggerMLPData.h.

std::vector< std::vector< float > > m_inputSamples
list of input vectors for network training.
std::vector< std::vector< float > > m_targetSamples
list of target values for network training.
short m_trackCounter
number of tracks used for the hit counter.
std::vector< std::vector< unsigned short > > m_hitCounters
hit counter of active track segment IDs, used to determine the relevant id range for an MLP.

◆ ~CDCTriggerMLPData()

~CDCTriggerMLPData ( )
inline

destructor, empty because we don't allocate memory anywhere.

Definition at line 250 of file CDCTriggerMLPData.h.

250{ }

Member Function Documentation

◆ addCounters()

void addCounters ( unsigned  nWires)
inline

add hit counters for a layer with nWires

Definition at line 253 of file CDCTriggerMLPData.h.

254 {
255 std::vector<unsigned short> counters;
256 counters.assign(nWires, 0);
257 m_hitCounters.push_back(counters);
258 }

◆ addHit()

void addHit ( unsigned  iSL,
int  iTS 
)

increase counter for super layer and track segment number in super layer.

track segment number can be negative. hits in the wrong hemisphere (not in [-nWires/4, nWires/4]) are skipped.

Definition at line 13 of file CDCTriggerMLPData.cc.

14{
15 if (iSL < m_hitCounters.size()) {
16 int N = m_hitCounters[iSL].size();
17 // shift negative indices
18 if (iTS < 0) iTS += N;
19 // check the range
20 // 0, N: hit is on the track
21 // [0, N/4]: hit is in quadrant left of the track
22 // [N/4, 3N/4]: hit is in hemisphere opposite of the track (skipped)
23 // [3N/4, N]: hit is in quadrant right of the track
24 if ((0 <= iTS && iTS <= N / 4) || (3 * N / 4 <= iTS && iTS < N)) {
25 ++m_hitCounters[iSL][iTS];
26 }
27 }
28}

◆ addSample() [1/2]

void addSample ( const NeuroSet< inLen, outLen > &  dsample)
inline

Definition at line 266 of file CDCTriggerMLPData.h.

267 {
268 std::vector<float> in(dsample.input, dsample.input + sizeof dsample.input / sizeof dsample.input[0]);
269 m_inputSamples.push_back(in);
270 std::vector<float> out(dsample.target, dsample.target + sizeof dsample.target / sizeof dsample.target[0]);
271 m_targetSamples.push_back(out);
272 m_expList.push_back(dsample.exp);
273 m_runList.push_back(dsample.run);
274 m_subRunList.push_back(dsample.subrun);
275 m_evtList.push_back(dsample.evt);
276 m_trackList.push_back(dsample.track);
277
278 }
std::vector< int > m_evtList
List for debug purposes to store the event number for every entry of input/target vector.
std::vector< int > m_expList
Vectors for experiment, run, event and tracknumber.

◆ addSample() [2/2]

void addSample ( const std::vector< float > &  input,
const std::vector< float > &  target,
const int &  expnumber,
const int &  runnumber,
const int &  subrunnumber,
const int &  eventnumber,
const int &  tracknumber 
)
inline

add a pair of input and target

Definition at line 281 of file CDCTriggerMLPData.h.

283 {
284 m_inputSamples.push_back(input);
285 m_targetSamples.push_back(target);
286 m_expList.push_back(expnumber);
287 m_runList.push_back(runnumber);
288 m_subRunList.push_back(subrunnumber);
289 m_evtList.push_back(eventnumber);
290 m_trackList.push_back(tracknumber);
291 }

◆ countTrack()

void countTrack ( )
inline

increase track counter

Definition at line 264 of file CDCTriggerMLPData.h.

264{ ++m_trackCounter; }

◆ getevtList()

const std::vector< int > & getevtList ( ) const
inline

Definition at line 305 of file CDCTriggerMLPData.h.

305{ return getEvtList(); }

◆ getEvtList()

const std::vector< int > & getEvtList ( ) const
inline

Definition at line 306 of file CDCTriggerMLPData.h.

306{ return m_evtList; }

◆ getevtnum()

const int & getevtnum ( unsigned  i) const
inline

Definition at line 311 of file CDCTriggerMLPData.h.

311{ return m_evtList[i]; }

◆ getExpList()

const std::vector< int > & getExpList ( ) const
inline

Definition at line 307 of file CDCTriggerMLPData.h.

307{ return m_expList; }

◆ getHitCounter()

unsigned short getHitCounter ( unsigned  iSL,
int  iTS 
) const

get hit counter for super layer and track segment number is super layer.

track segment number can be negative.

Returns
counter or 0 (for invalid input)

Definition at line 31 of file CDCTriggerMLPData.cc.

32{
33 if (iSL < m_hitCounters.size()) {
34 if (iTS < 0) iTS += m_hitCounters[iSL].size();
35 if (0 <= iTS && (unsigned)iTS < m_hitCounters[iSL].size()) {
36 return m_hitCounters[iSL][iTS];
37 }
38 }
39 return 0;
40}

◆ getInput()

const std::vector< float > & getInput ( unsigned  i) const
inline

get input vector of sample i

Definition at line 302 of file CDCTriggerMLPData.h.

302{ return m_inputSamples[i]; }

◆ getRunList()

const std::vector< int > & getRunList ( ) const
inline

Definition at line 308 of file CDCTriggerMLPData.h.

308{ return m_runList; }

◆ getSubRunList()

const std::vector< int > & getSubRunList ( ) const
inline

Definition at line 309 of file CDCTriggerMLPData.h.

309{ return m_subRunList; }

◆ getTarget()

const std::vector< float > & getTarget ( unsigned  i) const
inline

get target value of sample i

Definition at line 304 of file CDCTriggerMLPData.h.

304{ return m_targetSamples[i]; }

◆ getTrackCounter()

short getTrackCounter ( ) const
inline

get track counter

Definition at line 294 of file CDCTriggerMLPData.h.

294{ return m_trackCounter; }

◆ getTrackList()

const std::vector< int > & getTrackList ( ) const
inline

Definition at line 310 of file CDCTriggerMLPData.h.

310{ return m_trackList; }

◆ nSamples()

unsigned nSamples ( ) const
inline

get number of samples (same for input and target)

Definition at line 300 of file CDCTriggerMLPData.h.

300{ return m_targetSamples.size(); }

Member Data Documentation

◆ m_evtList

std::vector<int> m_evtList
private

List for debug purposes to store the event number for every entry of input/target vector.

Definition at line 327 of file CDCTriggerMLPData.h.

◆ m_expList

std::vector<int> m_expList
private

Vectors for experiment, run, event and tracknumber.

Definition at line 323 of file CDCTriggerMLPData.h.

◆ m_hitCounters

std::vector<std::vector<unsigned short> > m_hitCounters
private

hit counter of active track segment IDs, used to determine the relevant id range for an MLP.

Definition at line 319 of file CDCTriggerMLPData.h.

◆ m_inputSamples

std::vector<std::vector<float> > m_inputSamples
private

list of input vectors for network training.

Definition at line 314 of file CDCTriggerMLPData.h.

◆ m_runList

std::vector<int> m_runList
private

Definition at line 324 of file CDCTriggerMLPData.h.

◆ m_subRunList

std::vector<int> m_subRunList
private

Definition at line 325 of file CDCTriggerMLPData.h.

◆ m_targetSamples

std::vector<std::vector<float> > m_targetSamples
private

list of target values for network training.

Definition at line 316 of file CDCTriggerMLPData.h.

◆ m_trackCounter

short m_trackCounter
private

number of tracks used for the hit counter.

Definition at line 321 of file CDCTriggerMLPData.h.

◆ m_trackList

std::vector<int> m_trackList
private

Definition at line 328 of file CDCTriggerMLPData.h.


The documentation for this class was generated from the following files: