CMS 3D CMS Logo

L1GctGlobalEnergyAlgos.cc
Go to the documentation of this file.
2 
4 
8 
10 
11 using std::endl;
12 using std::max;
13 using std::ostream;
14 using std::vector;
15 
16 L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos(const std::vector<L1GctWheelEnergyFpga*>& wheelFpga,
17  const std::vector<L1GctWheelJetFpga*>& wheelJetFpga)
18  : L1GctProcessor(),
19  m_plusWheelFpga(wheelFpga.at(1)),
20  m_minusWheelFpga(wheelFpga.at(0)),
21  m_plusWheelJetFpga(wheelJetFpga.at(1)),
22  m_minusWheelJetFpga(wheelJetFpga.at(0)),
23  m_metComponents(0, 0, L1GctMet::cordicTranslate),
24  m_mhtComponents(0, 0, L1GctMet::useHtMissLut),
25  m_exValPlusWheel(),
26  m_eyValPlusWheel(),
27  m_etValPlusWheel(),
28  m_htValPlusWheel(),
29  m_exVlMinusWheel(),
30  m_eyVlMinusWheel(),
31  m_etVlMinusWheel(),
32  m_htVlMinusWheel(),
33  m_exValPlusPipe(),
34  m_eyValPlusPipe(),
35  m_etValPlusPipe(),
36  m_htValPlusPipe(),
37  m_exVlMinusPipe(),
38  m_eyVlMinusPipe(),
39  m_etVlMinusPipe(),
40  m_htVlMinusPipe(),
41  m_outputEtMiss(),
42  m_outputEtMissPhi(),
43  m_outputEtSum(),
44  m_outputEtHad(),
45  m_setupOk(true) {
46  if (wheelFpga.size() != 2) {
47  m_setupOk = false;
48  if (m_verbose) {
49  edm::LogWarning("L1GctSetupError") << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() : Global Energy Algos "
50  "has been incorrectly constructed!\n"
51  << "This class needs two wheel card pointers. "
52  << "Number of wheel card pointers present is " << wheelFpga.size() << ".\n";
53  }
54  }
55 
56  if (wheelJetFpga.size() != 2) {
57  m_setupOk = false;
58  if (m_verbose) {
59  edm::LogWarning("L1GctSetupError") << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() : Global Energy Algos "
60  "has been incorrectly constructed!\n"
61  << "This class needs two wheel jet fpga pointers. "
62  << "Number of wheel jet fpga pointers present is " << wheelJetFpga.size()
63  << ".\n";
64  }
65  }
66 
67  if (m_plusWheelFpga == nullptr) {
68  m_setupOk = false;
69  if (m_verbose) {
70  edm::LogWarning("L1GctSetupError")
71  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() has been incorrectly constructed!\n"
72  << "Plus Wheel Fpga pointer has not been set!\n";
73  }
74  }
75  if (m_minusWheelFpga == nullptr) {
76  m_setupOk = false;
77  if (m_verbose) {
78  edm::LogWarning("L1GctSetupError")
79  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() has been incorrectly constructed!\n"
80  << "Minus Wheel Fpga pointer has not been set!\n";
81  }
82  }
83  if (m_plusWheelJetFpga == nullptr) {
84  m_setupOk = false;
85  if (m_verbose) {
86  edm::LogWarning("L1GctSetupError")
87  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() has been incorrectly constructed!\n"
88  << "Plus Wheel Jet Fpga pointer has not been set!\n";
89  }
90  }
91  if (m_minusWheelJetFpga == nullptr) {
92  m_setupOk = false;
93  if (m_verbose) {
94  edm::LogWarning("L1GctSetupError")
95  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() has been incorrectly constructed!\n"
96  << "Minus Wheel Jet Fpga pointer has not been set!\n";
97  }
98  }
99 
100  // Set the scale for missing Et and missing Ht
101  // Missing Et has one extra bit of precision added in the (Ex, Ey)
102  // conversion step, so we reverse this here.
104  // Missing Ht has its own bit shifting before the LUT, so we don't
105  // need any extra
107 
108  // Setup to perform the Hf sums
109  m_hfSumProcessor = new L1GctGlobalHfSumAlgos(wheelJetFpga);
110 
112 
113  if (!m_setupOk && m_verbose) {
114  edm::LogError("L1GctSetupError") << "L1GctGlobalEnergyAlgos has been incorrectly constructed";
115  }
116 }
117 
119  if (m_hfSumProcessor != nullptr) {
120  delete m_hfSumProcessor;
121  }
122 }
123 
124 ostream& operator<<(ostream& os, const L1GctGlobalEnergyAlgos& fpga) {
125  os << "===L1GctGlobalEnergyAlgos===" << endl;
126  os << "WheelEnergyFpga* minus = " << fpga.m_minusWheelFpga << endl;
127  os << "WheelEnergyFpga* plus = " << fpga.m_plusWheelFpga << endl;
128  os << "WheelJetFpga* minus = " << fpga.m_minusWheelJetFpga << endl;
129  os << "WheelJetFpga* plus = " << fpga.m_plusWheelJetFpga << endl;
130  os << "Inputs from Plus wheel:" << endl;
131  os << " Ex " << fpga.m_exValPlusWheel << "\n Ey " << fpga.m_eyValPlusWheel << endl;
132  os << " Et " << fpga.m_etValPlusWheel << "\n Ht " << fpga.m_htValPlusWheel << endl;
133  os << "Inputs from Minus wheel:" << endl;
134  os << " Ex " << fpga.m_exVlMinusWheel << "\n Ey " << fpga.m_eyVlMinusWheel << endl;
135  os << " Et " << fpga.m_etVlMinusWheel << "\n Ht " << fpga.m_htVlMinusWheel << endl;
136  int bxZero = -fpga.bxMin();
137  if (bxZero >= 0 && bxZero < fpga.numOfBx()) {
138  os << "Output Etmiss " << fpga.m_outputEtMiss.contents.at(bxZero) << endl;
139  os << "Output Etmiss Phi " << fpga.m_outputEtMissPhi.contents.at(bxZero) << endl;
140  os << "Output EtSum " << fpga.m_outputEtSum.contents.at(bxZero) << endl;
141  os << "Output EtHad " << fpga.m_outputEtHad.contents.at(bxZero) << endl;
142  }
143  os << *fpga.m_hfSumProcessor;
144 
145  return os;
146 }
147 
152 }
153 
155 void L1GctGlobalEnergyAlgos::setBxRange(const int firstBx, const int numberOfBx) {
156  L1GctProcessor::setBxRange(firstBx, numberOfBx);
157  m_hfSumProcessor->setBxRange(firstBx, numberOfBx);
158 }
159 
163 }
164 
178 }
179 
181  m_outputEtMiss.reset(numOfBx());
182  m_outputEtMissPhi.reset(numOfBx());
183  m_outputEtSum.reset(numOfBx());
184  m_outputEtHad.reset(numOfBx());
185  m_outputHtMiss.reset(numOfBx());
186  m_outputHtMissPhi.reset(numOfBx());
187 
188  m_exValPlusPipe.reset(numOfBx());
189  m_eyValPlusPipe.reset(numOfBx());
190  m_etValPlusPipe.reset(numOfBx());
191  m_htValPlusPipe.reset(numOfBx());
192  m_hxValPlusPipe.reset(numOfBx());
193  m_hyValPlusPipe.reset(numOfBx());
194 
195  m_exVlMinusPipe.reset(numOfBx());
196  m_eyVlMinusPipe.reset(numOfBx());
197  m_etVlMinusPipe.reset(numOfBx());
198  m_htVlMinusPipe.reset(numOfBx());
199  m_hxVlMinusPipe.reset(numOfBx());
200  m_hyVlMinusPipe.reset(numOfBx());
201 }
202 
204  if (m_setupOk) {
205  // input from WheelEnergyFpgas
212 
219 
221  }
222 }
223 
224 // process the event
226  if (m_setupOk) {
227  // Store the inputs in pipelines
234 
241 
242  // Process to produce the outputs
243  etComponentType ExSum, EySum;
244  etmiss_vec EtMissing, HtMissing;
245 
246  //
247  //-----------------------------------------------------------------------------
248  // Form the Ex and Ey sums
251  // Execute the missing Et algorithm
252  // Rotate by pi to evaluate MISSING Et.
253  // Implement this in the same way as the firmware
254  m_metComponents.setComponents(ExSum, EySum);
255  EtMissing = m_metComponents.metVector();
256  if (EtMissing.phi.value() > 35) {
257  EtMissing.phi.setValue(EtMissing.phi.value() - 36);
258  } else {
259  EtMissing.phi.setValue(EtMissing.phi.value() + 36);
260  }
261  if (EtMissing.mag.value() == etMissMaxValue)
262  EtMissing.mag.setOverFlow(true);
263 
264  m_outputEtMiss.store(EtMissing.mag, bxRel());
265  m_outputEtMissPhi.store(EtMissing.phi, bxRel());
266 
267  //
268  //-----------------------------------------------------------------------------
269  // Form the Hx and Hy sums
272  // Execute the missing Et algorithm
273  // Implement this in the same way as the firmware
274  m_mhtComponents.setComponents(ExSum, EySum);
275  HtMissing = m_mhtComponents.metVector();
276  if (HtMissing.phi.value() > 8) {
277  HtMissing.phi.setValue(HtMissing.phi.value() - 9);
278  } else {
279  HtMissing.phi.setValue(HtMissing.phi.value() + 9);
280  }
281 
282  // Store 7 bits of magnitude and 5 bits of phi angle.
283  static const unsigned MAX_HT_VALUE = 0x7f;
284  static const unsigned PHI_HT_MASK = 0x1f;
285  if ((HtMissing.mag.value() > MAX_HT_VALUE) || (HtMissing.mag.overFlow())) {
286  HtMissing.mag.setValue(MAX_HT_VALUE);
287  }
288  HtMissing.phi.setValue(HtMissing.phi.value() & PHI_HT_MASK);
289  m_outputHtMiss.store(HtMissing.mag, bxRel());
290  m_outputHtMissPhi.store(HtMissing.phi, bxRel());
291 
292  //
293  //-----------------------------------------------------------------------------
294  // Form the Et and Ht sums
296  if (ettTemp.overFlow())
297  ettTemp.setValue(etTotalMaxValue);
299  if (httTemp.overFlow())
300  httTemp.setValue(etHadMaxValue);
301  m_outputEtSum.store(ettTemp, bxRel());
302  m_outputEtHad.store(httTemp, bxRel());
303 
305  }
306 }
307 
308 //----------------------------------------------------------------------------------------------
309 // load setup info (for HtMiss calculation)
310 //
312  // The jetFinders add an LSB when converting to x and y components,
313  // so the scale lsb for htx and hty is half the lsb for htt.
315 }
316 
318 
319 //----------------------------------------------------------------------------------------------
320 // check setup
321 //
323  return (m_setupOk && m_hfSumProcessor != nullptr && m_hfSumProcessor->setupOk());
324 }
325 
326 //----------------------------------------------------------------------------------------------
327 // set input data per wheel: x component of missing Et
328 //
329 void L1GctGlobalEnergyAlgos::setInputWheelEx(unsigned wheel, int energy, bool overflow) {
330  if (wheel == 0) {
331  m_exValPlusWheel.setValue(energy);
332  m_exValPlusWheel.setOverFlow(overflow);
333  } else if (wheel == 1) {
334  m_exVlMinusWheel.setValue(energy);
335  m_exVlMinusWheel.setOverFlow(overflow);
336  }
337 }
338 
339 //----------------------------------------------------------------------------------------------
340 // set input data per wheel: y component of missing Et
341 //
342 void L1GctGlobalEnergyAlgos::setInputWheelEy(unsigned wheel, int energy, bool overflow) {
343  if (wheel == 0) {
344  m_eyValPlusWheel.setValue(energy);
345  m_eyValPlusWheel.setOverFlow(overflow);
346  } else if (wheel == 1) {
347  m_eyVlMinusWheel.setValue(energy);
348  m_eyVlMinusWheel.setOverFlow(overflow);
349  }
350 }
351 
352 //----------------------------------------------------------------------------------------------
353 // set input data per wheel: scalar sum of Et
354 //
355 void L1GctGlobalEnergyAlgos::setInputWheelEt(unsigned wheel, unsigned energy, bool overflow) {
356  if (wheel == 0) {
357  m_etValPlusWheel.setValue(energy);
358  m_etValPlusWheel.setOverFlow(overflow);
359  } else if (wheel == 1) {
360  m_etVlMinusWheel.setValue(energy);
361  m_etVlMinusWheel.setOverFlow(overflow);
362  }
363 }
364 
365 //----------------------------------------------------------------------------------------------
366 // set input data per wheel: sum of transverse energy in jets (Ht)
367 //
368 void L1GctGlobalEnergyAlgos::setInputWheelHt(unsigned wheel, unsigned energy, bool overflow) {
369  if (wheel == 0) {
370  m_htValPlusWheel.setValue(energy);
371  m_htValPlusWheel.setOverFlow(overflow);
372  } else if (wheel == 1) {
373  m_htVlMinusWheel.setValue(energy);
374  m_htVlMinusWheel.setOverFlow(overflow);
375  }
376 }
377 
378 //----------------------------------------------------------------------------------------------
379 // set input data per wheel: x component of Ht
380 //
381 void L1GctGlobalEnergyAlgos::setInputWheelHx(unsigned wheel, unsigned energy, bool overflow) {
382  if (wheel == 0) {
383  m_hxValPlusWheel.setValue(energy);
384  m_hxValPlusWheel.setOverFlow(overflow);
385  } else if (wheel == 1) {
386  m_hxVlMinusWheel.setValue(energy);
387  m_hxVlMinusWheel.setOverFlow(overflow);
388  }
389 }
390 
391 //----------------------------------------------------------------------------------------------
392 // set input data per wheel: y component of Ht
393 //
394 void L1GctGlobalEnergyAlgos::setInputWheelHy(unsigned wheel, unsigned energy, bool overflow) {
395  if (wheel == 0) {
396  m_hyValPlusWheel.setValue(energy);
397  m_hyValPlusWheel.setOverFlow(overflow);
398  } else if (wheel == 1) {
399  m_hyVlMinusWheel.setValue(energy);
400  m_hyVlMinusWheel.setOverFlow(overflow);
401  }
402 }
void setOverFlow(bool oflow)
set the overflow bit
void reset()
complete reset of processor
bool setupOk() const
check setup
void process() override
process the data, fill output buffers
void fetchInput() override
get input data from sources; this is the standard way to provide input
bool setupOk() const
check setup
void reset()
clear internal buffers
htComponentType getOutputHy() const
Pipeline< etMissType > m_outputHtMiss
void setOverFlow(bool oflow)
set the overflow bit
friend std::ostream & operator<<(std::ostream &os, const L1GctGlobalEnergyAlgos &fpga)
Overload << operator.
Emulates the GCT summing and packing of Hf Et sums and tower-over-threshold counts.
Pipeline< etComponentType > m_eyVlMinusPipe
Pipeline< etComponentType > m_exValPlusPipe
bool m_verbose
Flag to control output messages.
void fetchInput() override
get input data from sources
void setInputWheelEx(unsigned wheel, int energy, bool overflow)
set input Ex value per wheel (0 or 1); not used in normal operation
Pipeline< etMissPhiType > m_outputHtMissPhi
Pipeline< etComponentType > m_hyVlMinusPipe
Pipeline< etComponentType > m_hxVlMinusPipe
etComponentType getOutputEy() const
get output Ey value
Pipeline< etComponentType > m_hxValPlusPipe
int bxRel() const
void setInputWheelHy(unsigned wheel, unsigned energy, bool overflow)
void setJetFinderParams(const L1GctJetFinderParams *const jfpars)
int bxMin() const
Support for multiple beam crossing operation.
etMissPhiType phi
Definition: L1GctMet.h:30
L1GctWheelJetFpga * m_plusWheelJetFpga
int numOfBx() const
double getHtLsbGeV() const
Stores Level-1 missing Et in (Ex, Ey) form, allowing it to be retrieved as (magnitude, angle)
Definition: L1GctMet.h:20
void setComponents(const unsigned ex, const unsigned ey)
Definition: L1GctMet.h:41
void setHtMissScale(const L1CaloEtScale *const scale)
ABC for a GCT trigger data processing unit.
void setEtScale(const L1CaloEtScale *const fn)
Definition: L1GctMet.cc:302
unsigned value() const
access value as unsigned
Pipeline< etHadType > m_outputEtHad
L1GctWheelEnergyFpga * m_minusWheelFpga
void setInputWheelHx(unsigned wheel, unsigned energy, bool overflow)
set input Ht component values per wheel (0 or 1); not used in normal operation
etComponentType getOutputEx() const
get output Ex value
L1GctGlobalEnergyAlgos(const std::vector< L1GctWheelEnergyFpga * > &WheelFpga, const std::vector< L1GctWheelJetFpga * > &WheelJetFpga)
Constructor needs the Wheel card Fpgas set up first.
Pipeline< etTotalType > m_etValPlusPipe
L1GctGlobalHfSumAlgos * m_hfSumProcessor
Emulates the GCT global energy algorithms.
void process() override
process the data, fill output buffers
Pipeline< etComponentType > m_hyValPlusPipe
void setBxRange(const int firstBx, const int numberOfBx)
define the bunch crossing range to process
void setBxRange(const int firstBx, const int numberOfBx)
define the bunch crossing range to process
void setValue(int value)
set value from signed int
Pipeline< etHadType > m_htValPlusPipe
etHadType getOutputHt() const
get the output Ht
void setInputWheelHt(unsigned wheel, unsigned energy, bool overflow)
set input Ht value per wheel (0 or 1); not used in normal operation
L1GctWheelJetFpga * m_minusWheelJetFpga
Pipeline< etComponentType > m_exVlMinusPipe
void setInputWheelEy(unsigned wheel, int energy, bool overflow)
set input Ey value per wheel (0 or 1); not used in normal operation
Pipeline< etMissPhiType > m_outputEtMissPhi
L1GctWheelEnergyFpga * m_plusWheelFpga
Pipeline< etComponentType > m_eyValPlusPipe
etmiss_vec metVector() const
Definition: L1GctMet.cc:16
etTotalType getOutputEt() const
get output Et value
Pipeline< etMissType > m_outputEtMiss
void reset()
reset value and overflow to zero
htComponentType getOutputHx() const
get the output Ht components
void setValue(unsigned value)
Set value from unsigned.
~L1GctGlobalEnergyAlgos() override
Destructor.
Pipeline< etHadType > m_htVlMinusPipe
void reset()
reset value and overflow to zero
etMissType mag
Definition: L1GctMet.h:29
void setNextBx(const int bx)
partially clear buffers
bool overFlow() const
access overflow
void setNextBx(const int bxnum)
clear input data buffers and process a new bunch crossing
Pipeline< etTotalType > m_outputEtSum
Pipeline< etTotalType > m_etVlMinusPipe
void resetProcessor() override
Separate reset methods for the processor itself and any data stored in pipelines. ...
void setInputWheelEt(unsigned wheel, unsigned energy, bool overflow)
set input Et value per wheel (0 or 1); not used in normal operation
void setBitShift(const unsigned nbits)
Definition: L1GctMet.h:62
void setEtComponentLsb(const double lsb)
Definition: L1GctMet.cc:304