37#include <trg/cdc/dataobjects/CDCTriggerMLP.h>
44main(
int argc,
char* argv[])
48 cout <<
"Program needs at least 3 arguments:" << endl
49 <<
" 1: MLP rootfile" << endl
50 <<
" 2: precision for MLP weights" << endl
51 <<
" 3: output filename" << endl;
54 string MLPFilename = argv[1];
55 unsigned precisionWeights = atoi(argv[2]);
57 TFile MLPFile(MLPFilename.c_str(),
"READ");
58 if (!MLPFile.IsOpen()) {
59 cout <<
"Could not open file " << MLPFilename << endl;
62 TObjArray* MLPs = (TObjArray*)MLPFile.Get(
"MLPs");
65 cout <<
"File " << MLPFilename <<
" does not contain key MLPs" << endl;
70 ofstream weightstream(argv[3]);
71 for (
int isector = 0; isector < MLPs->GetEntriesFast(); ++isector) {
74 cout <<
"Wrong type " << MLPs->At(isector)->ClassName()
75 <<
", ignoring this entry." << endl;
79 weightstream << isector << endl;
81 for (
unsigned isl = 0; isl < 9; ++isl) {
82 weightstream << expert->getIDRange(isl)[0] <<
" "
83 << expert->getIDRange(isl)[1] <<
" ";
87 unsigned pattern = expert->getSLpatternUnmasked();
88 weightstream << pattern <<
" " << expert->getSLpatternMask() << endl;
90 vector<unsigned> nNodes = {};
91 for (
unsigned il = 0; il < expert->nLayers(); ++il) {
92 nNodes.push_back(expert->nNodesLayer(il));
93 weightstream << nNodes.back() <<
" ";
97 vector<float> weights = expert->getWeights();
100 for (
unsigned iw = 0; iw < weights.size(); ++iw) {
101 double weight = weights[iw];
103 if (iw < ((nNodes[0] + 1) * nNodes[1])) {
104 unsigned isl = (iw % (nNodes[0] + 1)) / 3;
105 if (isl < 9 && !((pattern >> isl) & 1)) weight = 0;
107 if (weight < minWeight) minWeight = weight;
108 if (weight > maxWeight) maxWeight = weight;
109 weightstream << round(weight * (1 << precisionWeights)) <<
" ";
111 weightstream << endl;
112 cout << weights.size() <<
" weights in [" << minWeight <<
"," << maxWeight <<
"]" << endl;
117 weightstream.close();
Class to keep all parameters of an expert MLP for the neuro trigger.
Abstract base class for different kinds of events.