CMS 3D CMS Logo

L1GctWheelEnergyFpga.cc

Go to the documentation of this file.
00001 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctWheelEnergyFpga.h"
00002 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctWheelJetFpga.h"
00003 
00004 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetLeafCard.h"
00005 
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 
00008 using std::vector;
00009 using std::ostream;
00010 using std::endl;
00011 
00012 //DEFINE STATICS
00013 const unsigned int L1GctWheelEnergyFpga::MAX_LEAF_CARDS = L1GctWheelJetFpga::MAX_LEAF_CARDS;
00014 
00015 L1GctWheelEnergyFpga::L1GctWheelEnergyFpga(int id, vector<L1GctJetLeafCard*> leafCards) :
00016   L1GctProcessor(),
00017   m_id(id),
00018   m_inputLeafCards(leafCards),
00019   m_inputEx(MAX_LEAF_CARDS),
00020   m_inputEy(MAX_LEAF_CARDS),
00021   m_inputEt(MAX_LEAF_CARDS),
00022   m_setupOk(true)
00023 {
00024   //Check wheelEnergyFpga setup
00025   if(m_id != 0 && m_id != 1)
00026     {
00027       m_setupOk = false;
00028       if (m_verbose) {
00029         edm::LogWarning("L1GctSetupError")
00030           << "L1GctWheelEnergyFpga::L1GctWheelEnergyFpga() : Wheel Energy Fpga ID " << m_id << " has been incorrectly constructed!\n"
00031           << "ID number should be 0 or 1.\n";
00032       } 
00033     }
00034   
00035   if(m_inputLeafCards.size() != MAX_LEAF_CARDS)
00036     {
00037       m_setupOk = false;
00038       if (m_verbose) {
00039         edm::LogWarning("L1GctSetupError")
00040           << "L1GctWheelEnergyFpga::L1GctWheelEnergyFpga() : Wheel Energy Fpga ID " << m_id << " has been incorrectly constructed!\n"
00041           << "This class needs " << MAX_LEAF_CARDS << " leaf card pointers, yet only " << m_inputLeafCards.size()
00042           << " leaf card pointers are present.\n";
00043       }
00044     }
00045   
00046   for(unsigned int i = 0; i < m_inputLeafCards.size(); ++i)
00047     {
00048       if(m_inputLeafCards.at(i) == 0)
00049         {
00050           m_setupOk = false;
00051           if (m_verbose) {
00052             edm::LogWarning("L1GctSetupError")
00053               << "L1GctWheelEnergyFpga::L1GctWheelEnergyFpga() : Wheel Energy Fpga ID " << m_id << " has been incorrectly constructed!\n"
00054               << "Input Leaf card pointer " << i << " has not been set!\n";
00055           }
00056         }
00057     }
00058   if (!m_setupOk && m_verbose) {
00059     edm::LogError("L1GctSetupError") << "L1GctWheelEnergyFpga has been incorrectly constructed";
00060   }
00061 }
00062 
00063 L1GctWheelEnergyFpga::~L1GctWheelEnergyFpga()
00064 {
00065 }
00066 
00067 ostream& operator << (ostream& os, const L1GctWheelEnergyFpga& fpga)
00068 {
00069   os << "===L1GctWheelEnergyFPGA===" << endl;
00070   os << "ID : " << fpga.m_id << endl;
00071   os << "No. of Input Leaf Cards " << fpga.m_inputLeafCards.size() << endl;
00072   for(unsigned i=0; i < fpga.m_inputLeafCards.size(); i++)
00073     {
00074       os << "LeafCard* " << i << " = " << fpga.m_inputLeafCards.at(i) << endl;
00075     } 
00076   os << "Input Ex " << endl;
00077   for(unsigned i=0; i < fpga.m_inputEx.size(); i++)
00078     {
00079       os << fpga.m_inputEx.at(i) << endl;
00080     } 
00081   os << "Input Ey " << endl;
00082   for(unsigned i=0; i < fpga.m_inputEy.size(); i++)
00083     {
00084       os << fpga.m_inputEy.at(i) << endl;
00085     } 
00086   os << "Input Et " << endl;
00087   for(unsigned i=0; i < fpga.m_inputEt.size(); i++)
00088     {
00089       os << fpga.m_inputEt.at(i) << endl;
00090     } 
00091   os << "Output Ex " << fpga.m_outputEx << endl;
00092   os << "Output Ey " << fpga.m_outputEy << endl;
00093   os << "Output Et " << fpga.m_outputEt << endl;
00094   os << endl;
00095   return os;
00096 }
00097 
00098 void L1GctWheelEnergyFpga::resetProcessor()
00099 {
00100   for (unsigned int i=0; i<MAX_LEAF_CARDS; i++) {
00101     m_inputEx.at(i).reset();
00102     m_inputEy.at(i).reset();
00103     m_inputEt.at(i).reset();
00104   }
00105   m_outputEx.reset();
00106   m_outputEy.reset();
00107   m_outputEt.reset();
00108 }
00109 
00110 void L1GctWheelEnergyFpga::fetchInput()
00111 {
00112   if (m_setupOk) {
00113     // Fetch the output values from each of our input leaf cards.
00114     for (unsigned int i=0; i<MAX_LEAF_CARDS; i++) {
00115       m_inputEx.at(i) = m_inputLeafCards.at(i)->getOutputEx();
00116       m_inputEy.at(i) = m_inputLeafCards.at(i)->getOutputEy();
00117       m_inputEt.at(i) = m_inputLeafCards.at(i)->getOutputEt();
00118     }
00119   }
00120 }
00121 
00122 void L1GctWheelEnergyFpga::process()
00123 {
00124   if (m_setupOk) {
00125     m_outputEx = m_inputEx.at(0) + m_inputEx.at(1) + m_inputEx.at(2);
00126     m_outputEy = m_inputEy.at(0) + m_inputEy.at(1) + m_inputEy.at(2);
00127     m_outputEt = m_inputEt.at(0) + m_inputEt.at(1) + m_inputEt.at(2);
00128 
00129   }
00130 }
00131 
00132 
00135 void L1GctWheelEnergyFpga::setInputEnergy(unsigned i, int ex, int ey, unsigned et)
00136 {
00137   // Set the three input values from this Leaf card
00138   if (i>=0 && i<MAX_LEAF_CARDS) {
00139     m_inputEx.at(i).setValue(ex);
00140     m_inputEy.at(i).setValue(ey);
00141     m_inputEt.at(i).setValue(et);
00142   }
00143 
00144 }
00145 

Generated on Tue Jun 9 17:40:11 2009 for CMSSW by  doxygen 1.5.4