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 }
operator<<
ostream & operator<<(ostream &os, const L1GctWheelEnergyFpga &fpga)
Definition: L1GctWheelEnergyFpga.cc:69
L1GctUnsignedInt::setValue
void setValue(unsigned value)
Set value from unsigned.
Definition: L1GctUnsignedInt.h:111
L1GctInternEtSum::fromEmulatorMissEtxOrEty
static L1GctInternEtSum fromEmulatorMissEtxOrEty(int missEtxOrEty, bool overFlow, int16_t bx)
Definition: L1GctInternEtSum.cc:129
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
L1GctWheelEnergyFpga::getInternalEtSums
std::vector< L1GctInternEtSum > getInternalEtSums() const
get the Et sums in internal component format
Definition: L1GctWheelEnergyFpga.cc:163
L1GctWheelEnergyFpga::m_outputEyPipe
Pipeline< etComponentType > m_outputEyPipe
Definition: L1GctWheelEnergyFpga.h:122
L1GctProcessor::numOfBx
int numOfBx() const
Definition: L1GctProcessor.h:79
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
L1GctProcessor::bxRel
int bxRel() const
Definition: L1GctProcessor.h:81
L1GctWheelEnergyFpga::m_inputLeafCards
std::vector< L1GctJetLeafCard * > m_inputLeafCards
the jet leaf card
Definition: L1GctWheelEnergyFpga.h:103
L1GctWheelJetFpga::MAX_LEAF_CARDS
static const unsigned int MAX_LEAF_CARDS
Max number of leaf card pointers.
Definition: L1GctWheelJetFpga.h:39
L1GctWheelEnergyFpga::m_outputEt
etTotalType m_outputEt
Definition: L1GctWheelEnergyFpga.h:114
L1GctWheelEnergyFpga::m_outputHt
etHadType m_outputHt
Definition: L1GctWheelEnergyFpga.h:115
L1GctWheelEnergyFpga::setInputEnergy
void setInputEnergy(unsigned i, int ex, int ey, unsigned et, unsigned ht)
set input data; not used in normal operation
Definition: L1GctWheelEnergyFpga.cc:152
L1GctWheelEnergyFpga.h
L1GctWheelEnergyFpga::~L1GctWheelEnergyFpga
~L1GctWheelEnergyFpga() override
Destructor.
Definition: L1GctWheelEnergyFpga.cc:67
L1GctWheelEnergyFpga::htTotalMaxValue
Definition: L1GctWheelEnergyFpga.h:39
L1GctWheelEnergyFpga::m_outputEtPipe
Pipeline< etTotalType > m_outputEtPipe
Definition: L1GctWheelEnergyFpga.h:123
L1GctWheelEnergyFpga::m_outputEx
etComponentType m_outputEx
output data
Definition: L1GctWheelEnergyFpga.h:112
edm::LogWarning
Definition: MessageLogger.h:141
L1GctWheelJetFpga.h
funct::true
true
Definition: Factorize.h:173
L1GctWheelEnergyFpga::process
void process() override
process the data, fill output buffers
Definition: L1GctWheelEnergyFpga.cc:132
L1GctInternEtSum::fromEmulatorTotalEtOrHt
static L1GctInternEtSum fromEmulatorTotalEtOrHt(unsigned totEtOrHt, bool overFlow, int16_t bx)
Definition: L1GctInternEtSum.cc:119
L1GctWheelEnergyFpga::m_setupOk
bool m_setupOk
check the setup
Definition: L1GctWheelEnergyFpga.h:118
edm::LogError
Definition: MessageLogger.h:183
L1GctWheelEnergyFpga
Emulates the energy summing on a GCT Wheel card.
Definition: L1GctWheelEnergyFpga.h:30
L1GctWheelEnergyFpga::m_inputEx
std::vector< etComponentType > m_inputEx
the input components from each input card
Definition: L1GctWheelEnergyFpga.h:106
L1GctProcessor::m_verbose
bool m_verbose
Flag to control output messages.
Definition: L1GctProcessor.h:109
L1GctWheelEnergyFpga::etTotalMaxValue
Definition: L1GctWheelEnergyFpga.h:38
L1GctWheelEnergyFpga::m_id
int m_id
algo ID
Definition: L1GctWheelEnergyFpga.h:100
L1GctProcessor::bxMin
int bxMin() const
Support for multiple beam crossing operation.
Definition: L1GctProcessor.h:77
L1GctWheelEnergyFpga::m_inputEt
std::vector< etTotalType > m_inputEt
Definition: L1GctWheelEnergyFpga.h:108
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
L1GctWheelEnergyFpga::m_inputEy
std::vector< etComponentType > m_inputEy
Definition: L1GctWheelEnergyFpga.h:107
L1GctWheelEnergyFpga::m_outputEy
etComponentType m_outputEy
Definition: L1GctWheelEnergyFpga.h:113
L1GctWheelEnergyFpga::MAX_LEAF_CARDS
static const unsigned int MAX_LEAF_CARDS
Max number of leaf card pointers.
Definition: L1GctWheelEnergyFpga.h:43
L1GctWheelEnergyFpga::L1GctWheelEnergyFpga
L1GctWheelEnergyFpga(int id, const std::vector< L1GctJetLeafCard * > &leafCards)
Constructor, needs the Leaf cards to be set up first. id should be 0 or 1.
Definition: L1GctWheelEnergyFpga.cc:15
L1GctWheelEnergyFpga::m_outputExPipe
Pipeline< etComponentType > m_outputExPipe
record the output data history
Definition: L1GctWheelEnergyFpga.h:121
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
L1GctUnsignedInt::reset
void reset()
reset value and overflow to zero
Definition: L1GctUnsignedInt.h:41
L1GctUnsignedInt::overFlow
bool overFlow() const
access overflow
Definition: L1GctUnsignedInt.h:56
L1GctWheelEnergyFpga::m_inputHt
std::vector< etHadType > m_inputHt
Definition: L1GctWheelEnergyFpga.h:109
L1GctWheelEnergyFpga::fetchInput
void fetchInput() override
get input data from sources; this is the standard way to provide input
Definition: L1GctWheelEnergyFpga.cc:120
L1GctJetLeafCard.h
mps_fire.result
result
Definition: mps_fire.py:303
L1GctWheelEnergyFpga::resetProcessor
void resetProcessor() override
Separate reset methods for the processor itself and any data stored in pipelines.
Definition: L1GctWheelEnergyFpga.cc:100
L1GctWheelEnergyFpga::m_outputHtPipe
Pipeline< etHadType > m_outputHtPipe
Definition: L1GctWheelEnergyFpga.h:124
L1GctProcessor
ABC for a GCT trigger data processing unit.
Definition: L1GctProcessor.h:22
L1GctWheelEnergyFpga::resetPipelines
void resetPipelines() override
Definition: L1GctWheelEnergyFpga.cc:113
L1GctTwosComplement::reset
void reset()
reset value and overflow to zero
Definition: L1GctTwosComplement.h:132