12#include <trg/cdc/NeuroTriggerParameters.h>
13#include <trg/cdc/dataobjects/CDCTriggerMLP.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/datastore/StoreObjPtr.h>
16#include <framework/database/DBObjPtr.h>
17#include <trg/cdc/dataobjects/CDCTriggerSegmentHit.h>
18#include <trg/cdc/dbobjects/CDCTriggerNeuroConfig.h>
19#include <framework/dataobjects/BinnedEventT0.h>
27 class CDCTriggerTrack;
57 std::vector<std::vector<float>>
nHidden = {{3.}};
67 std::vector<std::vector<float>>
phiRange = {{0., 360.}};
69 std::vector<std::vector<float>>
invptRange = {{ -5., 5.}};
71 std::vector<std::vector<float>>
thetaRange = {{17., 150.}};
135 void save(
const std::string& filename,
const std::string& arrayname =
"MLPs");
144 bool load(
const std::string& filename,
const std::string& arrayname =
"MLPs");
155 void initializeCollections(std::string hitCollectionName, std::string eventTimeName,
const std::string& et_option);
176 std::vector<int>
selectMLPs(
float phi0,
float invpt,
float theta);
185 std::vector<int>
selectMLPsTrain(
float phi0,
float invpt,
float theta);
192 int selectMLPbyPattern(std::vector<int>& MLPs,
unsigned long pattern,
const bool neurotrackinputmode);
231 std::string eto =
m_MLPs[0].get_et_option();
232 for (
unsigned int i = 0; i <
m_MLPs.size(); ++i) {
234 B2ERROR(
"Timing options in the expert networks in the CDC Neurotrigger differ!");
273 bool returnAllRelevant =
false);
280 std::vector<float>
getInputVector(
unsigned isector,
const std::vector<unsigned>& hitIds);
286 std::vector<float>
runMLP(
unsigned isector,
const std::vector<float>& input);
289 std::vector<float>
runMLPFix(
unsigned isector, std::vector<float> input);
Class to keep all parameters of an expert MLP for the neuro trigger.
Combination of several CDCHits to a track segment hit for the trigger.
Track created by the CDC trigger.
Class for accessing objects in the database.
Class to represent the CDC Neurotrigger.
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 th...
double m_alpha[9][2]
2D crossing angle of current track
std::vector< CDCTriggerMLP > m_MLPs
List of networks.
double getRelId(const CDCTriggerSegmentHit &hit)
Calculate phi position of a hit relative to 2D track (scaled to number of wires).
DBObjPtr< CDCTriggerNeuroConfig > m_cdctriggerneuroconfig
get NNT payload from database.
virtual ~NeuroTrigger()
Default destructor.
void initialize(const Parameters &p)
Set parameters and get some network independent parameters.
std::vector< unsigned > getRangeIndices(const NeuroTriggerParameters &p, unsigned isector)
Get indices for sector ranges in parameter lists.
std::vector< int > selectMLPs(float phi0, float invpt, float theta)
Select all matching expert MLPs based on the given track parameters.
void updateTrack(const CDCTriggerTrack &track)
Calculate 2D phi position and arclength for the given track and store them.
bool load(const std::string &filename, const std::string &arrayname="MLPs")
Load MLPs from file.
std::vector< unsigned > selectHits(unsigned isector, const CDCTriggerTrack &track, bool returnAllRelevant=false)
Select best hits for each super layer.
std::vector< float > runMLPFix(unsigned isector, std::vector< float > input)
Run an expert MLP with fixed point arithmetic.
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
std::vector< float > getInputVector(unsigned isector, const std::vector< unsigned > &hitIds)
Calculate input values for MLP.
StoreArray< CDCTriggerSegmentHit > m_segmentHits
StoreArray containing the input track segment hits.
int selectMLPbyPattern(std::vector< int > &MLPs, unsigned long pattern, const bool neurotrackinputmode)
Select one MLP from a list of sector indices.
std::vector< unsigned > m_precision
Fixed point precision in bit after radix point.
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.
CDCTriggerMLP & operator[](unsigned index)
return reference to a neural network
int m_T0
Event time of current event / track.
void save(const std::string &filename, const std::string &arrayname="MLPs")
Save MLPs to file.
void getEventTime(unsigned isector, const CDCTriggerTrack &track)
DEPRECATED!! Read out the event time and store it.
const CDCTriggerMLP & operator[](unsigned index) const
return const reference to a neural network
void updateTrackFix(const CDCTriggerTrack &track)
Calculate 2D phi position and arclength for the given track and store them.
std::vector< unsigned > selectHitsHWSim(unsigned isector, const CDCTriggerTrack &track)
Select hits for each super layer from the ones related to input track.
NeuroTrigger()
Default constructor.
bool loadIDHist(const std::string &filename)
function to load idhist from file
std::vector< int > selectMLPsTrain(float phi0, float invpt, float theta)
Select all matching expert MLPs based on the given track parameters.
void setConstants()
Loads parameters from the geometry and precalculates some constants that will be needed.
unsigned m_TSoffset[10]
Number of track segments up to super layer.
void addMLP(const CDCTriggerMLP &newMLP)
add an MLP to the list of networks
double m_radius[9][2]
Radius of the CDC layers with priority wires (2 per super layer)
void setPrecision(const std::vector< unsigned > &precision)
set fixed point precision
StoreObjPtr< BinnedEventT0 > m_eventTime
StoreObjPtr containing the event time.
unsigned long getCompleteHitPattern(unsigned isector, const CDCTriggerTrack &track, const bool neurotrackinputmode)
Get complete hit pattern of neurotrack.
void getEventTime(unsigned isector, const CDCTriggerTrack &track, std::string et_option, const bool)
Read out the event time and store it.
int getLowestTime(unsigned isector, RelationVector< CDCTriggerSegmentHit > Hits, bool onlyAxials)
helper function to get the fastest priority time of given ts array
double m_idRef[9][2]
2D phi position of current track scaled to number of wires
std::string m_hitCollectionName
Name of the StoreArray containing the input track segment hits.
unsigned nSectors() const
return number of neural networks
std::vector< float > runMLP(unsigned isector, const std::vector< float > &input)
Run an expert MLP.
bool m_hasT0
Flag to show if stored event time is valid.
Class for type safe access to objects that are referred to in relations.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
Abstract base class for different kinds of events.
Struct to keep neurotrigger parameters.
std::vector< unsigned long > SLpatternMask
Super layer pattern mask for which MLP is trained for all networks.
std::vector< std::vector< float > > outputScale
Output scale for all networks.
std::vector< unsigned short > maxHitsPerSL
Maximum number of hits in a single super layer for all networks.
bool targetZ
train z as output
unsigned tMax
Maximal drift time, identical for all networks.
bool multiplyHidden
If true, multiply nHidden with number of input nodes.
std::vector< std::vector< float > > thetaRange
Theta region for which MLP is used in degree for all networks.
std::vector< std::vector< float > > phiRange
Phi region for which MLP is used in degree for all networks.
std::vector< std::vector< float > > invptRangeTrain
Charge / Pt region for which MLP is trained in 1/GeV for all networks.
unsigned nMLP
Number of networks.
std::vector< std::vector< float > > phiRangeTrain
Phi region for which MLP is trained in degree for all networks.
std::vector< std::vector< float > > invptRange
Charge / Pt region for which MLP is used in 1/GeV for all networks.
std::vector< unsigned long > SLpattern
Super layer pattern for which MLP is trained for all networks.
bool targetTheta
train theta as output
std::string et_option
Determine, how the event time should be obtained.
std::vector< std::vector< float > > thetaRangeTrain
Theta region for which MLP is trained in degree for all networks.
std::vector< std::vector< float > > nHidden
Number of nodes in each hidden layer for all networks or factor to multiply with number of inputs.