1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/**
* \class L1GtAlgorithm
*
*
* Description: L1 GT algorithm.
*
* Implementation:
* <TODO: enter implementation details>
*
* \author: Vasile Mihai Ghete - HEPHY Vienna
*
* $Date$
* $Revision$
*
*/
// this class header
#include "CondFormats/L1TObjects/interface/L1GtAlgorithm.h"
// system include files
#include <iostream>
#include <iomanip>
// user include files
// forward declarations
// constructor(s)
// default
L1GtAlgorithm::L1GtAlgorithm() {
// default values for private members not set
// the other private members are C++ initialized
m_algoBitNumber = -1;
m_algoChipNumber = -1;
}
// name only
L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue) : m_algoName(algoNameValue) {
// default values for private members not set
// the other private members are C++ initialized
m_algoBitNumber = -1;
m_algoChipNumber = -1;
}
// name and logical expression
L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue, const std::string& algoLogicalExpressionValue)
: m_algoName(algoNameValue), m_algoLogicalExpression(algoLogicalExpressionValue) {
L1GtLogicParser logicParser(m_algoLogicalExpression);
m_algoRpnVector = logicParser.rpnVector();
// default values for private members not set
m_algoBitNumber = -1;
m_algoChipNumber = -1;
}
// name, logical expression and bit number
L1GtAlgorithm::L1GtAlgorithm(const std::string& algoNameValue,
const std::string& algoLogicalExpressionValue,
const int algoBitNumberValue)
: m_algoName(algoNameValue),
m_algoLogicalExpression(algoLogicalExpressionValue),
m_algoBitNumber(algoBitNumberValue)
{
L1GtLogicParser logicParser(m_algoLogicalExpression);
m_algoRpnVector = logicParser.rpnVector();
// default values for private members not set
m_algoChipNumber = -1;
}
// destructor
L1GtAlgorithm::~L1GtAlgorithm() {
// empty
}
// public methods
// get the condition chip number the algorithm is located on
const int L1GtAlgorithm::algoChipNumber(const int numberConditionChips,
const int pinsOnConditionChip,
const std::vector<int>& orderConditionChip) const {
int posChip = (m_algoBitNumber / pinsOnConditionChip) + 1;
for (int iChip = 0; iChip < numberConditionChips; ++iChip) {
if (posChip == orderConditionChip[iChip]) {
return iChip;
}
}
// chip number not found
return -1;
}
// get the output pin on the condition chip for the algorithm
const int L1GtAlgorithm::algoOutputPin(const int numberConditionChips,
const int pinsOnConditionChip,
const std::vector<int>& orderConditionChip) const {
int iChip = algoChipNumber(numberConditionChips, pinsOnConditionChip, orderConditionChip);
int outputPin = m_algoBitNumber - (orderConditionChip[iChip] - 1) * pinsOnConditionChip + 1;
return outputPin;
}
// print algorithm
void L1GtAlgorithm::print(std::ostream& myCout) const {
myCout << std::endl;
myCout << " Algorithm name: " << m_algoName << std::endl;
myCout << " Algorithm alias: " << m_algoAlias << std::endl;
myCout << " Bit number: " << m_algoBitNumber;
if (m_algoBitNumber < 0) {
myCout << " - not properly initialized! " << std::endl;
} else {
myCout << std::endl;
}
myCout << " Located on chip number: " << m_algoChipNumber;
if (m_algoChipNumber < 0) {
myCout << " - not properly initialized! " << std::endl;
} else {
myCout << std::endl;
}
myCout << " Logical expresssion: " << m_algoLogicalExpression << std::endl;
int rpnVectorSize = m_algoRpnVector.size();
myCout << " RPN vector size: " << rpnVectorSize;
if (rpnVectorSize == 0) {
myCout << " - not properly initialized! " << std::endl;
} else {
myCout << std::endl;
for (int i = 0; i < rpnVectorSize; ++i) {
myCout << " ( " << (m_algoRpnVector[i]).operation << ", " << (m_algoRpnVector[i]).operand << " )"
<< std::endl;
}
}
myCout << std::endl;
}
// output stream operator
std::ostream& operator<<(std::ostream& os, const L1GtAlgorithm& result) {
result.print(os);
return os;
}
|