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! | |
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 > | getInputVectorDefault (unsigned isector, const std::vector< unsigned > &hitIds) |
Calculate input values for MLP Default mode. | |
std::vector< float > | getInputVector_fullhit (unsigned isector, const std::vector< unsigned > &hitIds) |
Calculate input values for MLP in full hit mode. | |
std::vector< float > | getInputVector_extrahit (unsigned isector, const std::vector< unsigned > &hitIds) |
Calculate input values for MLP in extra hit mode. | |
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][5] = {{0}} |
Radius of the CDC layers with priority wires (2 per super layer) | |
unsigned | m_TSoffset [10] = {0} |
Number of track segments up to super layer. | |
double | m_idRef [9][5] = {{0}} |
2D phi position of current track scaled to number of wires | |
double | m_alpha [9][5] = {{0}} |
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. | |
int | m_AdditionWireMode = 0 |
Switch for addtional input modes. | |
int | m_AdditionInputPerSL = 0 |
Value for additional input. | |
int | m_TMin = -20 |
Min Drift time limitation for ETF case only. | |
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 684 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 490 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 729 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 1206 of file NeuroTrigger.cc.
vector< float > getInputVector_extrahit | ( | unsigned | isector, |
const std::vector< unsigned > & | hitIds ) |
Calculate input values for MLP in extra hit mode.
isector | index of the MLP that will use the input |
hitIds | hit indices to be used for the input |
Full LR table do not show large difference, comment for now if want to include, please also add LUT which not include here if(UseFullLR) { unsigned int lutpattern = hitpattern*2; if(m_segmentHits[ihit]->getPriorityPosition()==2) lutpattern +=1; LRV = (iSL==0)?m_innerLUT[lutpattern]:m_outerLUT[lutpattern]; } else
Definition at line 999 of file NeuroTrigger.cc.
vector< float > getInputVector_fullhit | ( | unsigned | isector, |
const std::vector< unsigned > & | hitIds ) |
Calculate input values for MLP in full hit mode.
isector | index of the MLP that will use the input |
hitIds | hit indices to be used for the input |
Definition at line 1139 of file NeuroTrigger.cc.
vector< float > getInputVectorDefault | ( | unsigned | isector, |
const std::vector< unsigned > & | hitIds ) |
Calculate input values for MLP Default mode.
isector | index of the MLP that will use the input |
hitIds | hit indices to be used for the input |
Definition at line 1219 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 466 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 634 of file NeuroTrigger.cc.
vector< unsigned > getRangeIndices | ( | const NeuroTriggerParameters & | p, |
unsigned | isector ) |
Get indices for sector ranges in parameter lists.
Definition at line 264 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 453 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 312 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 302 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 1374 of file NeuroTrigger.cc.
bool loadIDHist | ( | const std::string & | filename | ) |
function to load idhist from file
Definition at line 1355 of file NeuroTrigger.cc.
|
inline |
return number of neural networks
Definition at line 164 of file NeuroTrigger.h.
|
inline |
return reference to a neural network
Definition at line 159 of file NeuroTrigger.h.
|
inline |
return const reference to a neural network
Definition at line 161 of file NeuroTrigger.h.
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 1253 of file NeuroTrigger.cc.
vector< float > runMLPFix | ( | unsigned | isector, |
std::vector< float > | input ) |
Run an expert MLP with fixed point arithmetic.
Definition at line 1282 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 1342 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 860 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 781 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 370 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 343 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 318 of file NeuroTrigger.cc.
void setConstants | ( | ) |
Loads parameters from the geometry and precalculates some constants that will be needed.
Definition at line 284 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 407 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 423 of file NeuroTrigger.cc.
|
private |
Value for additional input.
Definition at line 330 of file NeuroTrigger.h.
|
private |
Switch for addtional input modes.
Definition at line 328 of file NeuroTrigger.h.
|
private |
|
private |
get NNT payload from database.
Definition at line 352 of file NeuroTrigger.h.
|
private |
StoreObjPtr containing the event time.
Definition at line 348 of file NeuroTrigger.h.
|
private |
Flag to show if stored event time is valid.
Definition at line 326 of file NeuroTrigger.h.
|
private |
Name of the StoreArray containing the input track segment hits.
Definition at line 350 of file NeuroTrigger.h.
|
private |
2D phi position of current track scaled to number of wires
Definition at line 320 of file NeuroTrigger.h.
|
private |
|
private |
Fixed point precision in bit after radix point.
8 values:
Definition at line 343 of file NeuroTrigger.h.
|
private |
Radius of the CDC layers with priority wires (2 per super layer)
Definition at line 316 of file NeuroTrigger.h.
|
private |
StoreArray containing the input track segment hits.
Definition at line 346 of file NeuroTrigger.h.
|
private |
Event time of current event / track.
Definition at line 324 of file NeuroTrigger.h.
|
private |
Min Drift time limitation for ETF case only.
Definition at line 332 of file NeuroTrigger.h.
|
private |