Belle II Software development
|
Class to represent the CDC Neurotrigger. More...
#include <NeuroTrigger.h>
Classes | |
struct | Parameters |
Struct to keep neurotrigger parameters. More... | |
Public Member Functions | |
NeuroTrigger () | |
Default constructor. | |
virtual | ~NeuroTrigger () |
Default destructor. | |
void | initialize (const Parameters &p) |
Set parameters and get some network independent parameters. | |
void | initialize (const NeuroTriggerParameters &p) |
std::vector< unsigned > | getRangeIndices (const NeuroTriggerParameters &p, unsigned isector) |
Get indices for sector ranges in parameter lists. | |
std::vector< unsigned > | getRangeIndices (const Parameters &p, unsigned isector) |
void | save (const std::string &filename, const std::string &arrayname="MLPs") |
Save MLPs to file. | |
bool | loadIDHist (const std::string &filename) |
function to load idhist from file | |
bool | load (const std::string &filename, const std::string &arrayname="MLPs") |
Load MLPs from file. | |
void | setConstants () |
Loads parameters from the geometry and precalculates some constants that will be needed. | |
void | setPrecision (const std::vector< unsigned > &precision) |
set fixed point precision | |
void | initializeCollections (std::string hitCollectionName, std::string eventTimeName, const std::string &et_option) |
set the hit collection and event time to required and store the hit collection name | |
void | initializeCollections (std::string hitCollectionName) |
CDCTriggerMLP & | operator[] (unsigned index) |
return reference to a neural network | |
const CDCTriggerMLP & | operator[] (unsigned index) const |
return const reference to a neural network | |
unsigned | nSectors () const |
return number of neural networks | |
void | addMLP (const CDCTriggerMLP &newMLP) |
add an MLP to the list of networks | |
std::vector< int > | selectMLPs (float phi0, float invpt, float theta) |
Select all matching expert MLPs based on the given track parameters. | |
std::vector< int > | selectMLPsTrain (float phi0, float invpt, float theta) |
Select all matching expert MLPs based on the given track parameters. | |
int | selectMLPbyPattern (std::vector< int > &MLPs, unsigned long pattern, const bool neurotrackinputmode) |
Select one MLP from a list of sector indices. | |
void | updateTrack (const CDCTriggerTrack &track) |
Calculate 2D phi position and arclength for the given track and store them. | |
void | updateTrackFix (const CDCTriggerTrack &track) |
Calculate 2D phi position and arclength for the given track and store them. | |
double | getRelId (const CDCTriggerSegmentHit &hit) |
Calculate phi position of a hit relative to 2D track (scaled to number of wires). | |
int | getLowestTime (unsigned isector, RelationVector< CDCTriggerSegmentHit > Hits, bool onlyAxials) |
helper function to get the fastest priority time of given ts array | |
void | getEventTime (unsigned isector, const CDCTriggerTrack &track, std::string et_option, const bool) |
Read out the event time and store it. | |
void | getEventTime (unsigned isector, const CDCTriggerTrack &track) |
DEPRECATED!! Read out the event time and store it. | |
std::string | get_et_option () |
Return value of m_et_option. | |
unsigned long | getInputPattern (unsigned isector, const CDCTriggerTrack &track, const bool neurotrackinputmode) |
Calculate input pattern for MLP. | |
unsigned long | getCompleteHitPattern (unsigned isector, const CDCTriggerTrack &track, const bool neurotrackinputmode) |
Get complete hit pattern of neurotrack. | |
unsigned long | getPureDriftThreshold (unsigned isector, const CDCTriggerTrack &track, const bool neurotrackinputmode) |
Get the drift threshold bits, where the time of the TS was outside of the accepted time window and thus shifted to the allowed maximum within the borders. | |
std::vector< unsigned > | selectHitsHWSim (unsigned isector, const CDCTriggerTrack &track) |
Select hits for each super layer from the ones related to input track. | |
std::vector< unsigned > | selectHits (unsigned isector, const CDCTriggerTrack &track, bool returnAllRelevant=false) |
Select best hits for each super layer. | |
std::vector< float > | getInputVector (unsigned isector, const std::vector< unsigned > &hitIds) |
Calculate input values for MLP. | |
std::vector< float > | runMLP (unsigned isector, const std::vector< float > &input) |
Run an expert MLP. | |
std::vector< float > | runMLPFix (unsigned isector, std::vector< float > input) |
Run an expert MLP with fixed point arithmetic. | |
Private Attributes | |
std::vector< CDCTriggerMLP > | m_MLPs = {} |
List of networks. | |
double | m_radius [9][2] = {} |
Radius of the CDC layers with priority wires (2 per super layer) | |
unsigned | m_TSoffset [10] = {} |
Number of track segments up to super layer. | |
double | m_idRef [9][2] = {} |
2D phi position of current track scaled to number of wires | |
double | m_alpha [9][2] = {} |
2D crossing angle of current track | |
int | m_T0 = 0 |
Event time of current event / track. | |
bool | m_hasT0 = false |
Flag to show if stored event time is valid. | |
std::vector< unsigned > | m_precision |
Fixed point precision in bit after radix point. | |
StoreArray< CDCTriggerSegmentHit > | m_segmentHits |
StoreArray containing the input track segment hits. | |
StoreObjPtr< BinnedEventT0 > | m_eventTime |
StoreObjPtr containing the event time. | |
std::string | m_hitCollectionName |
Name of the StoreArray containing the input track segment hits. | |
DBObjPtr< CDCTriggerNeuroConfig > | m_cdctriggerneuroconfig |
get NNT payload from database. | |
Class to represent the CDC Neurotrigger.
The Neurotrigger consists of one or several Multi Layer Perceptrons. The input values are calculated from track segment hits and a 2D track estimate. The output is a scaled estimate of the z-vertex of the track. In case of several MLPs, each is an expert for a different track parameter region.
Definition at line 40 of file NeuroTrigger.h.
|
inline |
|
inlinevirtual |
|
inline |
add an MLP to the list of networks
Definition at line 167 of file NeuroTrigger.h.
|
inline |
Return value of m_et_option.
Definition at line 229 of file NeuroTrigger.h.
unsigned long getCompleteHitPattern | ( | unsigned | isector, |
const CDCTriggerTrack & | track, | ||
const bool | neurotrackinputmode | ||
) |
Get complete hit pattern of neurotrack.
This does the same as the getInputPattern function, but also shows the axial hit bits. This function was made for the simulation of the hardware debug information "TSVector".
Definition at line 679 of file NeuroTrigger.cc.
void getEventTime | ( | unsigned | isector, |
const CDCTriggerTrack & | track | ||
) |
DEPRECATED!! Read out the event time and store it.
If there is no valid event time, it can be determined from the shortest priority time of all hit candidates, if the option is enabled for the given sector.
void getEventTime | ( | unsigned | isector, |
const CDCTriggerTrack & | track, | ||
std::string | et_option, | ||
const bool | neuroinputmode = false |
||
) |
Read out the event time and store it.
It can be given different options in the et_option ("EventTime option") parameter. The different options are: "etf_only" : only ETF info is used, otherwise an error is thrown. "fastestpriority" : event time is estimated by fastest priority time in selected track segments. if something fails, it is set to 0. "zero" : the event time is set to 0. "etf_or_fastestpriority" : the event time is obtained by the ETF, if not possible, the flag "fastestppriority" is used. "etf_or_zero" : the event time is obtained by the ETF, if
m_T0 = 9999;
find shortest time of related and relevant axial hits RelationVector<CDCTriggerSegmentHit> Hits = track.getRelationsTo<CDCTriggerSegmentHit>(m_hitCollectionName); m_T0 = getLowestTime(isector, Hits, false); if (m_T0 < 9999) { m_hasT0 = true; } else { m_T0 = 0; m_hasT0 = false; }
m_T0 = 9999;
find shortest time of related and relevant axial hits RelationVector<CDCTriggerSegmentHit> Hits = track.getRelationsTo<CDCTriggerSegmentHit>(m_hitCollectionName); m_T0 = getLowestTime(isector, Hits, true); if (m_T0 < 9999) { m_hasT0 = true; } else { m_T0 = 0; m_hasT0 = false; }
Definition at line 485 of file NeuroTrigger.cc.
unsigned long getInputPattern | ( | unsigned | isector, |
const CDCTriggerTrack & | track, | ||
const bool | neurotrackinputmode | ||
) |
Calculate input pattern for MLP.
isector | index of the MLP that will use the input |
track | axial hit relations are taken from given track |
neurotrackinputmode | input mode |
Definition at line 724 of file NeuroTrigger.cc.
vector< float > getInputVector | ( | unsigned | isector, |
const std::vector< unsigned > & | hitIds | ||
) |
Calculate input values for MLP.
isector | index of the MLP that will use the input |
hitIds | hit indices to be used for the input |
Definition at line 993 of file NeuroTrigger.cc.
int getLowestTime | ( | unsigned | isector, |
RelationVector< CDCTriggerSegmentHit > | Hits, | ||
bool | onlyAxials = false |
||
) |
helper function to get the fastest priority time of given ts array
Definition at line 461 of file NeuroTrigger.cc.
unsigned long getPureDriftThreshold | ( | unsigned | isector, |
const CDCTriggerTrack & | track, | ||
const bool | neurotrackinputmode | ||
) |
Get the drift threshold bits, where the time of the TS was outside of the accepted time window and thus shifted to the allowed maximum within the borders.
Note, that to get the same values as from the unpacker, this value has to be combined with the (complement of the) TSVector.
Definition at line 629 of file NeuroTrigger.cc.
vector< unsigned > getRangeIndices | ( | const NeuroTriggerParameters & | p, |
unsigned | isector | ||
) |
Get indices for sector ranges in parameter lists.
Definition at line 260 of file NeuroTrigger.cc.
double getRelId | ( | const CDCTriggerSegmentHit & | hit | ) |
Calculate phi position of a hit relative to 2D track (scaled to number of wires).
Definition at line 448 of file NeuroTrigger.cc.
void initialize | ( | const NeuroTriggerParameters & | p | ) |
Definition at line 35 of file NeuroTrigger.cc.
void initializeCollections | ( | std::string | hitCollectionName | ) |
Definition at line 307 of file NeuroTrigger.cc.
void initializeCollections | ( | std::string | hitCollectionName, |
std::string | eventTimeName, | ||
const std::string & | et_option | ||
) |
set the hit collection and event time to required and store the hit collection name
Definition at line 297 of file NeuroTrigger.cc.
bool load | ( | const std::string & | filename, |
const std::string & | arrayname = "MLPs" |
||
) |
Load MLPs from file.
filename | name of the TFile to read from |
arrayname | name of the TObjArray holding the MLPs in the file |
Definition at line 1148 of file NeuroTrigger.cc.
bool loadIDHist | ( | const std::string & | filename | ) |
function to load idhist from file
Definition at line 1129 of file NeuroTrigger.cc.
|
inline |
|
inline |
|
inline |
vector< float > runMLP | ( | unsigned | isector, |
const std::vector< float > & | input | ||
) |
Run an expert MLP.
isector | index of the MLP |
input | vector of input values |
Definition at line 1027 of file NeuroTrigger.cc.
vector< float > runMLPFix | ( | unsigned | isector, |
std::vector< float > | input | ||
) |
Run an expert MLP with fixed point arithmetic.
Definition at line 1056 of file NeuroTrigger.cc.
void save | ( | const std::string & | filename, |
const std::string & | arrayname = "MLPs" |
||
) |
Save MLPs to file.
filename | name of the TFile to write to |
arrayname | name of the TObjArray holding the MLPs in the file |
Definition at line 1116 of file NeuroTrigger.cc.
vector< unsigned > selectHits | ( | unsigned | isector, |
const CDCTriggerTrack & | track, | ||
bool | returnAllRelevant = false |
||
) |
Select best hits for each super layer.
isector | index of the MLP that will use the input |
track | axial hit relations are taken from given track |
returnAllRelevant | if true, return all relevant hits instead of selecting the best (for making relations) |
Definition at line 855 of file NeuroTrigger.cc.
vector< unsigned > selectHitsHWSim | ( | unsigned | isector, |
const CDCTriggerTrack & | track | ||
) |
Select hits for each super layer from the ones related to input track.
isector | index of the MLP that will use the input |
track | all hit relations are taken from given track |
Definition at line 776 of file NeuroTrigger.cc.
int selectMLPbyPattern | ( | std::vector< int > & | MLPs, |
unsigned long | pattern, | ||
const bool | neurotrackinputmode | ||
) |
Select one MLP from a list of sector indices.
The selected expert either matches the given sector pattern, or has no pattern restriction. An unrestricted expert is returned only if there is no exactly matching expert.
Definition at line 365 of file NeuroTrigger.cc.
vector< int > selectMLPs | ( | float | phi0, |
float | invpt, | ||
float | theta | ||
) |
Select all matching expert MLPs based on the given track parameters.
If the sectors are overlapping, there may be more than one matching expert. During training this is intended, afterwards sectors should be redefined to be unique. For unique geometrical sectors, this function can still find several experts with different sector patterns.
Definition at line 338 of file NeuroTrigger.cc.
vector< int > selectMLPsTrain | ( | float | phi0, |
float | invpt, | ||
float | theta | ||
) |
Select all matching expert MLPs based on the given track parameters.
If the sectors are overlapping, there may be more than one matching expert. During training this is intended, afterwards sectors should be redefined to be unique. For unique geometrical sectors, this function can still find several experts with different sector patterns.
Definition at line 313 of file NeuroTrigger.cc.
void setConstants | ( | ) |
Loads parameters from the geometry and precalculates some constants that will be needed.
Definition at line 280 of file NeuroTrigger.cc.
|
inline |
set fixed point precision
Definition at line 151 of file NeuroTrigger.h.
void updateTrack | ( | const CDCTriggerTrack & | track | ) |
Calculate 2D phi position and arclength for the given track and store them.
Definition at line 402 of file NeuroTrigger.cc.
void updateTrackFix | ( | const CDCTriggerTrack & | track | ) |
Calculate 2D phi position and arclength for the given track and store them.
Definition at line 418 of file NeuroTrigger.cc.
|
private |
2D crossing angle of current track
Definition at line 301 of file NeuroTrigger.h.
|
private |
get NNT payload from database.
Definition at line 322 of file NeuroTrigger.h.
|
private |
StoreObjPtr containing the event time.
Definition at line 318 of file NeuroTrigger.h.
|
private |
Flag to show if stored event time is valid.
Definition at line 305 of file NeuroTrigger.h.
|
private |
Name of the StoreArray containing the input track segment hits.
Definition at line 320 of file NeuroTrigger.h.
|
private |
2D phi position of current track scaled to number of wires
Definition at line 299 of file NeuroTrigger.h.
|
private |
List of networks.
Definition at line 293 of file NeuroTrigger.h.
|
private |
Fixed point precision in bit after radix point.
8 values:
Definition at line 313 of file NeuroTrigger.h.
|
private |
Radius of the CDC layers with priority wires (2 per super layer)
Definition at line 295 of file NeuroTrigger.h.
|
private |
StoreArray containing the input track segment hits.
Definition at line 316 of file NeuroTrigger.h.
|
private |
Event time of current event / track.
Definition at line 303 of file NeuroTrigger.h.
|
private |
Number of track segments up to super layer.
Definition at line 297 of file NeuroTrigger.h.