CMS 3D CMS Logo

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