CMS 3D CMS Logo

L1GctWheelEnergyFpga.cc
Go to the documentation of this file.
3 
5 
7 
8 using std::endl;
9 using std::ostream;
10 using std::vector;
11 
12 //DEFINE STATICS
14 
15 L1GctWheelEnergyFpga::L1GctWheelEnergyFpga(int id, const std::vector<L1GctJetLeafCard*>& leafCards)
16  : L1GctProcessor(),
17  m_id(id),
18  m_inputLeafCards(leafCards),
19  m_inputEx(MAX_LEAF_CARDS),
20  m_inputEy(MAX_LEAF_CARDS),
21  m_inputEt(MAX_LEAF_CARDS),
22  m_inputHt(MAX_LEAF_CARDS),
23  m_outputEx(0),
24  m_outputEy(0),
25  m_outputEt(0),
26  m_outputHt(0),
27  m_setupOk(true),
28  m_outputExPipe(),
29  m_outputEyPipe(),
30  m_outputEtPipe(),
31  m_outputHtPipe() {
32  //Check wheelEnergyFpga setup
33  if (m_id != 0 && m_id != 1) {
34  m_setupOk = false;
35  if (m_verbose) {
36  edm::LogWarning("L1GctSetupError") << "L1GctWheelEnergyFpga::L1GctWheelEnergyFpga() : Wheel Energy Fpga ID "
37  << m_id << " has been incorrectly constructed!\n"
38  << "ID number should be 0 or 1.\n";
39  }
40  }
41 
42  if (m_inputLeafCards.size() != MAX_LEAF_CARDS) {
43  m_setupOk = false;
44  if (m_verbose) {
45  edm::LogWarning("L1GctSetupError") << "L1GctWheelEnergyFpga::L1GctWheelEnergyFpga() : Wheel Energy Fpga ID "
46  << m_id << " has been incorrectly constructed!\n"
47  << "This class needs " << MAX_LEAF_CARDS << " leaf card pointers, yet only "
48  << m_inputLeafCards.size() << " leaf card pointers are present.\n";
49  }
50  }
51 
52  for (unsigned int i = 0; i < m_inputLeafCards.size(); ++i) {
53  if (m_inputLeafCards.at(i) == nullptr) {
54  m_setupOk = false;
55  if (m_verbose) {
56  edm::LogWarning("L1GctSetupError") << "L1GctWheelEnergyFpga::L1GctWheelEnergyFpga() : Wheel Energy Fpga ID "
57  << m_id << " has been incorrectly constructed!\n"
58  << "Input Leaf card pointer " << i << " has not been set!\n";
59  }
60  }
61  }
62  if (!m_setupOk && m_verbose) {
63  edm::LogError("L1GctSetupError") << "L1GctWheelEnergyFpga has been incorrectly constructed";
64  }
65 }
66 
68 
69 ostream& operator<<(ostream& os, const L1GctWheelEnergyFpga& fpga) {
70  os << "===L1GctWheelEnergyFPGA===" << endl;
71  os << "ID : " << fpga.m_id << endl;
72  os << "No. of Input Leaf Cards " << fpga.m_inputLeafCards.size() << endl;
73  for (unsigned i = 0; i < fpga.m_inputLeafCards.size(); i++) {
74  os << "LeafCard* " << i << " = " << fpga.m_inputLeafCards.at(i) << endl;
75  }
76  os << "Input Ex " << endl;
77  for (unsigned i = 0; i < fpga.m_inputEx.size(); i++) {
78  os << fpga.m_inputEx.at(i) << endl;
79  }
80  os << "Input Ey " << endl;
81  for (unsigned i = 0; i < fpga.m_inputEy.size(); i++) {
82  os << fpga.m_inputEy.at(i) << endl;
83  }
84  os << "Input Et " << endl;
85  for (unsigned i = 0; i < fpga.m_inputEt.size(); i++) {
86  os << fpga.m_inputEt.at(i) << endl;
87  }
88  os << "Input Ht " << endl;
89  for (unsigned i = 0; i < fpga.m_inputHt.size(); i++) {
90  os << (fpga.m_inputHt.at(i)) << endl;
91  }
92  os << "Output Ex " << fpga.m_outputEx << endl;
93  os << "Output Ey " << fpga.m_outputEy << endl;
94  os << "Output Et " << fpga.m_outputEt << endl;
95  os << "Output Ht " << fpga.m_outputHt << endl;
96  os << endl;
97  return os;
98 }
99 
101  for (unsigned int i = 0; i < MAX_LEAF_CARDS; i++) {
102  m_inputEx.at(i).reset();
103  m_inputEy.at(i).reset();
104  m_inputEt.at(i).reset();
105  m_inputHt.at(i).reset();
106  }
107  m_outputEx.reset();
108  m_outputEy.reset();
109  m_outputEt.reset();
110  m_outputHt.reset();
111 }
112 
114  m_outputExPipe.reset(numOfBx());
115  m_outputEyPipe.reset(numOfBx());
116  m_outputEtPipe.reset(numOfBx());
117  m_outputHtPipe.reset(numOfBx());
118 }
119 
121  if (m_setupOk) {
122  // Fetch the output values from each of our input leaf cards.
123  for (unsigned int i = 0; i < MAX_LEAF_CARDS; i++) {
124  m_inputEx.at(i) = m_inputLeafCards.at(i)->getOutputEx();
125  m_inputEy.at(i) = m_inputLeafCards.at(i)->getOutputEy();
126  m_inputEt.at(i) = m_inputLeafCards.at(i)->getOutputEt();
127  m_inputHt.at(i) = m_inputLeafCards.at(i)->getOutputHt();
128  }
129  }
130 }
131 
133  if (m_setupOk) {
134  m_outputEx = m_inputEx.at(0) + m_inputEx.at(1) + m_inputEx.at(2);
135  m_outputEy = m_inputEy.at(0) + m_inputEy.at(1) + m_inputEy.at(2);
136  m_outputEt = m_inputEt.at(0) + m_inputEt.at(1) + m_inputEt.at(2);
137  m_outputHt = m_inputHt.at(0) + m_inputHt.at(1) + m_inputHt.at(2);
138  if (m_outputEt.overFlow())
140  if (m_outputHt.overFlow())
142 
143  m_outputExPipe.store(m_outputEx, bxRel());
144  m_outputEyPipe.store(m_outputEy, bxRel());
145  m_outputEtPipe.store(m_outputEt, bxRel());
146  m_outputHtPipe.store(m_outputHt, bxRel());
147  }
148 }
149 
152 void L1GctWheelEnergyFpga::setInputEnergy(unsigned i, int ex, int ey, unsigned et, unsigned ht) {
153  // Set the three input values from this Leaf card
154  if (i < MAX_LEAF_CARDS) { // i >= 0, since i is unsigned
155  m_inputEx.at(i).setValue(ex);
156  m_inputEy.at(i).setValue(ey);
157  m_inputEt.at(i).setValue(et);
158  m_inputHt.at(i).setValue(ht);
159  }
160 }
161 
163 std::vector<L1GctInternEtSum> L1GctWheelEnergyFpga::getInternalEtSums() const {
164  std::vector<L1GctInternEtSum> result;
165  for (int bx = 0; bx < numOfBx(); bx++) {
167  m_outputExPipe.contents.at(bx).overFlow(),
168  static_cast<int16_t>(bx - bxMin())));
170  m_outputEyPipe.contents.at(bx).overFlow(),
171  static_cast<int16_t>(bx - bxMin())));
172  result.push_back(L1GctInternEtSum::fromEmulatorTotalEtOrHt(m_outputEtPipe.contents.at(bx).value(),
173  m_outputEtPipe.contents.at(bx).overFlow(),
174  static_cast<int16_t>(bx - bxMin())));
175  result.push_back(L1GctInternEtSum::fromEmulatorTotalEtOrHt(m_outputHtPipe.contents.at(bx).value(),
176  m_outputHtPipe.contents.at(bx).overFlow(),
177  static_cast<int16_t>(bx - bxMin())));
178  }
179  return result;
180 }
int numOfBx() const
Emulates the energy summing on a GCT Wheel card.
etComponentType m_outputEx
output data
void resetProcessor() override
Separate reset methods for the processor itself and any data stored in pipelines. ...
static const unsigned int MAX_LEAF_CARDS
Max number of leaf card pointers.
void fetchInput() override
get input data from sources; this is the standard way to provide input
bool m_verbose
Flag to control output messages.
Pipeline< etHadType > m_outputHtPipe
std::vector< etHadType > m_inputHt
void setInputEnergy(unsigned i, int ex, int ey, unsigned et, unsigned ht)
set input data; not used in normal operation
Log< level::Error, false > LogError
int bxRel() const
bool overFlow() const
access overflow
ABC for a GCT trigger data processing unit.
Pipeline< etTotalType > m_outputEtPipe
int bxMin() const
Support for multiple beam crossing operation.
std::vector< etComponentType > m_inputEx
the input components from each input card
static L1GctInternEtSum fromEmulatorMissEtxOrEty(int missEtxOrEty, bool overFlow, int16_t bx)
std::vector< etTotalType > m_inputEt
static L1GctInternEtSum fromEmulatorTotalEtOrHt(unsigned totEtOrHt, bool overFlow, int16_t bx)
Pipeline< etComponentType > m_outputExPipe
record the output data history
std::vector< etComponentType > m_inputEy
bool m_setupOk
check the setup
L1GctWheelEnergyFpga(int id, const std::vector< L1GctJetLeafCard *> &leafCards)
Constructor, needs the Leaf cards to be set up first. id should be 0 or 1.
void resetPipelines() override
void reset()
reset value and overflow to zero
ostream & operator<<(ostream &os, const L1GctWheelEnergyFpga &fpga)
void setValue(unsigned value)
Set value from unsigned.
void reset()
reset value and overflow to zero
std::vector< L1GctJetLeafCard * > m_inputLeafCards
the jet leaf card
Pipeline< etComponentType > m_outputEyPipe
Log< level::Warning, false > LogWarning
void process() override
process the data, fill output buffers
static const unsigned int MAX_LEAF_CARDS
Max number of leaf card pointers.
~L1GctWheelEnergyFpga() override
Destructor.
std::vector< L1GctInternEtSum > getInternalEtSums() const
get the Et sums in internal component format