test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GctGlobalEnergyAlgos.cc
Go to the documentation of this file.
2 
4 
8 
10 
11 using std::ostream;
12 using std::endl;
13 using std::vector;
14 using std::max;
15 
16 L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos(const std::vector<L1GctWheelEnergyFpga*>& wheelFpga,
17  const std::vector<L1GctWheelJetFpga*>& wheelJetFpga) :
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(), m_eyValPlusWheel(),
26  m_etValPlusWheel(), m_htValPlusWheel(),
27  m_exVlMinusWheel(), m_eyVlMinusWheel(),
28  m_etVlMinusWheel(), m_htVlMinusWheel(),
29  m_exValPlusPipe(), m_eyValPlusPipe(),
30  m_etValPlusPipe(), m_htValPlusPipe(),
31  m_exVlMinusPipe(), m_eyVlMinusPipe(),
32  m_etVlMinusPipe(), m_htVlMinusPipe(),
33  m_outputEtMiss(), m_outputEtMissPhi(),
34  m_outputEtSum(), m_outputEtHad(),
35  m_setupOk(true)
36 {
37  if(wheelFpga.size() != 2)
38  {
39  m_setupOk = false;
40  if (m_verbose) {
41  edm::LogWarning("L1GctSetupError")
42  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() : Global Energy Algos has been incorrectly constructed!\n"
43  << "This class needs two wheel card pointers. "
44  << "Number of wheel card pointers present is " << wheelFpga.size() << ".\n";
45  }
46  }
47 
48  if(wheelJetFpga.size() != 2)
49  {
50  m_setupOk = false;
51  if (m_verbose) {
52  edm::LogWarning("L1GctSetupError")
53  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() : Global Energy Algos has been incorrectly constructed!\n"
54  << "This class needs two wheel jet fpga pointers. "
55  << "Number of wheel jet fpga pointers present is " << wheelJetFpga.size() << ".\n";
56  }
57  }
58 
59  if(m_plusWheelFpga == 0)
60  {
61  m_setupOk = false;
62  if (m_verbose) {
63  edm::LogWarning("L1GctSetupError")
64  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() has been incorrectly constructed!\n"
65  << "Plus Wheel Fpga pointer has not been set!\n";
66  }
67  }
68  if(m_minusWheelFpga == 0)
69  {
70  m_setupOk = false;
71  if (m_verbose) {
72  edm::LogWarning("L1GctSetupError")
73  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() has been incorrectly constructed!\n"
74  << "Minus Wheel Fpga pointer has not been set!\n";
75  }
76  }
77  if(m_plusWheelJetFpga == 0)
78  {
79  m_setupOk = false;
80  if (m_verbose) {
81  edm::LogWarning("L1GctSetupError")
82  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() has been incorrectly constructed!\n"
83  << "Plus Wheel Jet Fpga pointer has not been set!\n";
84  }
85  }
86  if(m_minusWheelJetFpga == 0)
87  {
88  m_setupOk = false;
89  if (m_verbose) {
90  edm::LogWarning("L1GctSetupError")
91  << "L1GctGlobalEnergyAlgos::L1GctGlobalEnergyAlgos() has been incorrectly constructed!\n"
92  << "Minus Wheel Jet Fpga pointer has not been set!\n";
93  }
94  }
95 
96  // Set the scale for missing Et and missing Ht
97  // Missing Et has one extra bit of precision added in the (Ex, Ey)
98  // conversion step, so we reverse this here.
100  // Missing Ht has its own bit shifting before the LUT, so we don't
101  // need any extra
103 
104  // Setup to perform the Hf sums
105  m_hfSumProcessor = new L1GctGlobalHfSumAlgos(wheelJetFpga);
106 
108 
109  if (!m_setupOk && m_verbose) {
110  edm::LogError("L1GctSetupError") << "L1GctGlobalEnergyAlgos has been incorrectly constructed";
111  }
112 }
113 
115 {
116  if (m_hfSumProcessor != 0) {
117  delete m_hfSumProcessor;
118  }
119 }
120 
121 ostream& operator << (ostream& os, const L1GctGlobalEnergyAlgos& fpga)
122 {
123  os << "===L1GctGlobalEnergyAlgos===" << endl;
124  os << "WheelEnergyFpga* minus = " << fpga.m_minusWheelFpga << endl;
125  os << "WheelEnergyFpga* plus = " << fpga.m_plusWheelFpga << endl;
126  os << "WheelJetFpga* minus = " << fpga.m_minusWheelJetFpga << endl;
127  os << "WheelJetFpga* plus = " << fpga.m_plusWheelJetFpga << endl;
128  os << "Inputs from Plus wheel:" << endl;
129  os << " Ex " << fpga.m_exValPlusWheel << "\n Ey " << fpga.m_eyValPlusWheel << endl;
130  os << " Et " << fpga.m_etValPlusWheel << "\n Ht " << fpga.m_htValPlusWheel << endl;
131  os << "Inputs from Minus wheel:" << endl;
132  os << " Ex " << fpga.m_exVlMinusWheel << "\n Ey " << fpga.m_eyVlMinusWheel << endl;
133  os << " Et " << fpga.m_etVlMinusWheel << "\n Ht " << fpga.m_htVlMinusWheel << endl;
134  int bxZero = -fpga.bxMin();
135  if (bxZero>=0 && bxZero<fpga.numOfBx()) {
136  os << "Output Etmiss " << fpga.m_outputEtMiss.contents.at(bxZero) << endl;
137  os << "Output Etmiss Phi " << fpga.m_outputEtMissPhi.contents.at(bxZero) << endl;
138  os << "Output EtSum " << fpga.m_outputEtSum.contents.at(bxZero) << endl;
139  os << "Output EtHad " << fpga.m_outputEtHad.contents.at(bxZero) << endl;
140  }
141  os << *fpga.m_hfSumProcessor;
142 
143  return os;
144 }
145 
150 }
151 
153 void L1GctGlobalEnergyAlgos::setBxRange(const int firstBx, const int numberOfBx) {
154  L1GctProcessor::setBxRange(firstBx, numberOfBx);
155  m_hfSumProcessor->setBxRange(firstBx, numberOfBx);
156 }
157 
161 }
162 
176 }
177 
179  m_outputEtMiss.reset (numOfBx());
180  m_outputEtMissPhi.reset (numOfBx());
181  m_outputEtSum.reset (numOfBx());
182  m_outputEtHad.reset (numOfBx());
183  m_outputHtMiss.reset (numOfBx());
184  m_outputHtMissPhi.reset (numOfBx());
185 
186  m_exValPlusPipe.reset (numOfBx());
187  m_eyValPlusPipe.reset (numOfBx());
188  m_etValPlusPipe.reset (numOfBx());
189  m_htValPlusPipe.reset (numOfBx());
190  m_hxValPlusPipe.reset (numOfBx());
191  m_hyValPlusPipe.reset (numOfBx());
192 
193  m_exVlMinusPipe.reset (numOfBx());
194  m_eyVlMinusPipe.reset (numOfBx());
195  m_etVlMinusPipe.reset (numOfBx());
196  m_htVlMinusPipe.reset (numOfBx());
197  m_hxVlMinusPipe.reset (numOfBx());
198  m_hyVlMinusPipe.reset (numOfBx());
199 
200 }
201 
203  if (m_setupOk) {
204  // input from WheelEnergyFpgas
211 
218 
220  }
221 }
222 
223 
224 // process the event
226 {
227  if (m_setupOk) {
228  // Store the inputs in pipelines
235 
242 
243  // Process to produce the outputs
244  etComponentType ExSum, EySum;
245  etmiss_vec EtMissing, HtMissing;
246 
247  //
248  //-----------------------------------------------------------------------------
249  // Form the Ex and Ey sums
252  // Execute the missing Et algorithm
253  // Rotate by pi to evaluate MISSING Et.
254  // Implement this in the same way as the firmware
255  m_metComponents.setComponents(ExSum, EySum);
256  EtMissing = m_metComponents.metVector();
257  if (EtMissing.phi.value() > 35) {
258  EtMissing.phi.setValue(EtMissing.phi.value() - 36);
259  } else {
260  EtMissing.phi.setValue(EtMissing.phi.value() + 36);
261  }
262  if (EtMissing.mag.value() == etMissMaxValue) 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()) ettTemp.setValue(etTotalMaxValue);
298  if (httTemp.overFlow()) httTemp.setValue(etHadMaxValue);
299  m_outputEtSum.store (ettTemp, bxRel());
300  m_outputEtHad.store (httTemp, bxRel());
301 
303  }
304 }
305 
306 //----------------------------------------------------------------------------------------------
307 // load setup info (for HtMiss calculation)
308 //
310 {
311  // The jetFinders add an LSB when converting to x and y components,
312  // so the scale lsb for htx and hty is half the lsb for htt.
314 }
315 
317 {
319 }
320 
321 //----------------------------------------------------------------------------------------------
322 // check setup
323 //
325  return (m_setupOk &&
326  m_hfSumProcessor != 0 &&
328 }
329 
330 
331 //----------------------------------------------------------------------------------------------
332 // set input data per wheel: x component of missing Et
333 //
334 void L1GctGlobalEnergyAlgos::setInputWheelEx(unsigned wheel, int energy, bool overflow)
335 {
336  if (wheel==0) {
337  m_exValPlusWheel.setValue(energy);
338  m_exValPlusWheel.setOverFlow(overflow);
339  } else if (wheel==1) {
340  m_exVlMinusWheel.setValue(energy);
341  m_exVlMinusWheel.setOverFlow(overflow);
342  }
343 }
344 
345 //----------------------------------------------------------------------------------------------
346 // set input data per wheel: y component of missing Et
347 //
348 void L1GctGlobalEnergyAlgos::setInputWheelEy(unsigned wheel, int energy, bool overflow)
349 {
350  if (wheel==0) {
351  m_eyValPlusWheel.setValue(energy);
352  m_eyValPlusWheel.setOverFlow(overflow);
353  } else if (wheel==1) {
354  m_eyVlMinusWheel.setValue(energy);
355  m_eyVlMinusWheel.setOverFlow(overflow);
356  }
357 }
358 
359 //----------------------------------------------------------------------------------------------
360 // set input data per wheel: scalar sum of Et
361 //
362 void L1GctGlobalEnergyAlgos::setInputWheelEt(unsigned wheel, unsigned energy, bool overflow)
363 {
364  if (wheel==0) {
365  m_etValPlusWheel.setValue(energy);
366  m_etValPlusWheel.setOverFlow(overflow);
367  } else if (wheel==1) {
368  m_etVlMinusWheel.setValue(energy);
369  m_etVlMinusWheel.setOverFlow(overflow);
370  }
371 }
372 
373 //----------------------------------------------------------------------------------------------
374 // set input data per wheel: sum of transverse energy in jets (Ht)
375 //
376 void L1GctGlobalEnergyAlgos::setInputWheelHt(unsigned wheel, unsigned energy, bool overflow)
377 {
378  if (wheel==0) {
379  m_htValPlusWheel.setValue(energy);
380  m_htValPlusWheel.setOverFlow(overflow);
381  } else if (wheel==1) {
382  m_htVlMinusWheel.setValue(energy);
383  m_htVlMinusWheel.setOverFlow(overflow);
384  }
385 }
386 
387 
388 //----------------------------------------------------------------------------------------------
389 // set input data per wheel: x component of Ht
390 //
391 void L1GctGlobalEnergyAlgos::setInputWheelHx(unsigned wheel, unsigned energy, bool overflow)
392 {
393  if (wheel==0) {
394  m_hxValPlusWheel.setValue(energy);
395  m_hxValPlusWheel.setOverFlow(overflow);
396  } else if (wheel==1) {
397  m_hxVlMinusWheel.setValue(energy);
398  m_hxVlMinusWheel.setOverFlow(overflow);
399  }
400 }
401 
402 
403 //----------------------------------------------------------------------------------------------
404 // set input data per wheel: y component of Ht
405 //
406 void L1GctGlobalEnergyAlgos::setInputWheelHy(unsigned wheel, unsigned energy, bool overflow)
407 {
408  if (wheel==0) {
409  m_hyValPlusWheel.setValue(energy);
410  m_hyValPlusWheel.setOverFlow(overflow);
411  } else if (wheel==1) {
412  m_hyVlMinusWheel.setValue(energy);
413  m_hyVlMinusWheel.setOverFlow(overflow);
414  }
415 }
416 
417 
void setOverFlow(bool oflow)
set the overflow bit
void reset()
complete reset of processor
bool setupOk() const
check setup
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
Emulates the GCT summing and packing of Hf Et sums and tower-over-threshold counts.
Pipeline< etTotalType > m_etVlMinusPipe
bool m_verbose
Flag to control output messages.
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
etComponentType getOutputEy() const
get output Ey value
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:32
Pipeline< etComponentType > m_exValPlusPipe
virtual void fetchInput()
get input data from sources; this is the standard way to provide input
L1GctWheelJetFpga * m_plusWheelJetFpga
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
Pipeline< etComponentType > m_eyVlMinusPipe
int numOfBx() const
double getHtLsbGeV() const
virtual void process()
process the data, fill output buffers
Pipeline< etComponentType > m_hyVlMinusPipe
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:43
void setHtMissScale(const L1CaloEtScale *const scale)
ABC for a GCT trigger data processing unit.
void setEtScale(const L1CaloEtScale *const fn)
Definition: L1GctMet.cc:318
unsigned value() const
access value as unsigned
Pipeline< etHadType > m_outputEtHad
virtual void resetProcessor()
Separate reset methods for the processor itself and any data stored in pipelines. ...
virtual void fetchInput()
get input data from sources
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.
L1GctGlobalHfSumAlgos * m_hfSumProcessor
Emulates the GCT global energy algorithms.
virtual void process()
process the data, fill output buffers
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
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
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
Pipeline< etComponentType > m_hyValPlusPipe
L1GctWheelEnergyFpga * m_plusWheelFpga
etmiss_vec metVector() const
Definition: L1GctMet.cc:27
etTotalType getOutputEt() const
get output Et value
Pipeline< etComponentType > m_eyValPlusPipe
Pipeline< etMissType > m_outputEtMiss
Pipeline< etComponentType > m_exVlMinusPipe
void reset()
reset value and overflow to zero
htComponentType getOutputHx() const
get the output Ht components
void setValue(unsigned value)
Set value from unsigned.
Pipeline< etComponentType > m_hxVlMinusPipe
void reset()
reset value and overflow to zero
Pipeline< etHadType > m_htValPlusPipe
etMissType mag
Definition: L1GctMet.h:31
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_etValPlusPipe
Pipeline< etComponentType > m_hxValPlusPipe
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:58
void setEtComponentLsb(const double lsb)
Definition: L1GctMet.cc:323
Pipeline< etHadType > m_htVlMinusPipe