8#include <trg/cdc/dataobjects/CDCTriggerMLP.h>
14 nNodes{27, 27, 2}, trained(false), targetVars(3), outputScale{ -1., 1., -1., 1.},
15 phiRangeUse{0., 2. * M_PI}, invptRangeUse{ -5., 5.}, thetaRangeUse{0., M_PI},
16 phiRangeTrain{0., 2. * M_PI}, invptRangeTrain{ -5., 5.}, thetaRangeTrain{0., M_PI},
17 maxHitsPerSL(1), SLpattern(0), SLpatternMask(0), tMax(256),
27 et_option(
"etf_or_fastestpriority")
33 unsigned short targets,
34 std::vector<float>& outputscale,
35 std::vector<float>& phirangeUse,
36 std::vector<float>& invptrangeUse,
37 std::vector<float>& thetarangeUse,
38 std::vector<float>& phirangeTrain,
39 std::vector<float>& invptrangeTrain,
40 std::vector<float>& thetarangeTrain,
41 unsigned short maxHits,
42 unsigned long pattern,
43 unsigned long patternMask,
45 const std::string& etoption):
46 nNodes(nodes), trained(false), targetVars(targets), outputScale(outputscale),
47 phiRangeUse(phirangeUse), invptRangeUse(invptrangeUse), thetaRangeUse(thetarangeUse),
48 phiRangeTrain(phirangeTrain), invptRangeTrain(invptrangeTrain), thetaRangeTrain(thetarangeTrain),
49 maxHitsPerSL(maxHits), SLpattern(pattern), SLpatternMask(patternMask),
71 for (
unsigned il = 1; il <
nLayers() - 1; ++il) {
141 scale = pow(2, floor(log2(scale)));
143 return scale * (relId - offset);
149 std::vector<float> scaled;
150 scaled.assign(target.size(), 0.);
151 for (
unsigned i = 0; i < target.size(); ++i) {
160 std::vector<float> unscaled;
161 unscaled.assign(target.size(), 0.);
162 for (
unsigned i = 0; i < target.size(); ++i) {
unsigned nWeightsCal() const
calculate number of weights from number of nodes
std::vector< unsigned short > nNodes
Number of nodes in each layer, not including bias nodes.
std::vector< float > phiRangeUse
Phi region in radian for which this expert is used.
std::vector< float > unscaleTarget(std::vector< float > target) const
scale target value from [-1, 1] to outputScale
CDCTriggerMLP()
default constructor.
std::vector< float > invptRangeTrain
Charge / Pt region in 1/GeV for which this expert is trained.
std::vector< float > scaleTarget(std::vector< float > target) const
scale target value from outputScale to [-1, 1]
std::vector< float > outputScale
Output[i] of the MLP is scaled from [-1, 1] to [outputScale[2i], outputScale[2i+1]].
bool inThetaRangeTrain(float theta) const
check whether given theta value is in training sector
std::vector< float > relevantID
Hits must be within ID region around 2D track to be used as input.
std::vector< float > thetaRangeUse
Theta region in radian for which this expert is trained.
bool inPtRangeTrain(float pt) const
check whether given pt value is in training sector
float scaleId(double relId, unsigned iSL) const
scale relative TS ID from relevant range to approximately [-1, 1] (to facilitate the FPGA implementat...
bool inInvptRangeUse(float invpt) const
check whether given 1/pt value is in sector
bool isRelevant(float relId, unsigned iSL) const
check whether given relative TS ID is in relevant range
unsigned short targetVars
output variables: 1: z, 2: theta, 3: (z, theta)
std::vector< float > weights
Weights of the network.
bool inPhiRangeUse(float phi) const
check whether given phi value is in sector
unsigned nLayers() const
get number of layers
std::vector< float > phiRangeTrain
Phi region in radian for which this expert is used.
std::vector< float > thetaRangeTrain
Theta region in radian for which this expert is trained.
std::vector< float > invptRangeUse
Charge / Pt region in 1/GeV for which this expert is used.
bool inInvptRangeTrain(float invpt) const
check whether given 1/pt value is in training sector
bool inThetaRangeUse(float theta) const
check whether given theta value is in sector
bool inPtRangeUse(float pt) const
check whether given pt value is in sector
unsigned nWeights() const
get number of weights from length of weights vector
int thetaIndex() const
get target index for theta (-1 if no output is trained for theta)
int zIndex() const
get target index for z (-1 if no output is trained for z)
bool inPhiRangeTrain(float phi) const
check whether given phi value is in training sector
Abstract base class for different kinds of events.