Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:34

0001 // Include files
0002 
0003 // local
0004 #include "L1Trigger/RPCTechnicalTrigger/interface/RBCEmulator.h"
0005 #include "L1Trigger/RPCTechnicalTrigger/interface/RBCBasicConfig.h"
0006 #include "L1Trigger/RPCTechnicalTrigger/interface/RBCProcessTestSignal.h"
0007 #include "L1Trigger/RPCTechnicalTrigger/interface/RBCLinkBoardSignal.h"
0008 
0009 //-----------------------------------------------------------------------------
0010 // Implementation file for class : RBCEmulator
0011 //
0012 // 2008-10-10 : Andres Osorio
0013 //-----------------------------------------------------------------------------
0014 
0015 //=============================================================================
0016 // Standard constructor, initializes variables
0017 //=============================================================================
0018 RBCEmulator::RBCEmulator() : m_rbcinfo{}, m_signal{}, m_input{}, m_logtype{"TestLogic"}, m_debug{false} {
0019   m_layersignal[0] = &m_layersignalVec[0];
0020   m_layersignal[1] = &m_layersignalVec[1];
0021 }
0022 
0023 RBCEmulator::RBCEmulator(const char* logic_type)
0024     : m_rbcinfo{},
0025       m_signal{},
0026       m_rbcconf{std::make_unique<RBCBasicConfig>(logic_type)},
0027       m_input{},
0028       m_logtype{logic_type},
0029       m_debug{false} {
0030   m_layersignal[0] = &m_layersignalVec[0];
0031   m_layersignal[1] = &m_layersignalVec[1];
0032 }
0033 
0034 RBCEmulator::RBCEmulator(const char* f_name, const char* logic_type)
0035     : m_rbcinfo{},
0036       m_signal{std::make_unique<RBCProcessTestSignal>(f_name)},
0037       m_rbcconf{std::make_unique<RBCBasicConfig>(logic_type)},
0038       m_input{},
0039       m_logtype{logic_type},
0040       m_debug{false} {
0041   m_layersignal[0] = &m_layersignalVec[0];
0042   m_layersignal[1] = &m_layersignalVec[1];
0043 }
0044 
0045 //=============================================================================
0046 void RBCEmulator::setSpecifications(const RBCBoardSpecs* rbcspecs) {
0047   m_rbcconf = std::make_unique<RBCBasicConfig>(rbcspecs, &m_rbcinfo);
0048 }
0049 
0050 bool RBCEmulator::initialise() {
0051   bool status(true);
0052 
0053   status = m_rbcconf->initialise();
0054 
0055   if (!status) {
0056     if (m_debug)
0057       std::cout << "RBCEmulator> Problem initialising the Configuration \n";
0058     return false;
0059   };
0060 
0061   return true;
0062 }
0063 
0064 void RBCEmulator::setid(int wh, int* sec) { m_rbcinfo.setid(wh, sec); }
0065 
0066 void RBCEmulator::emulate() {
0067   if (m_debug)
0068     std::cout << "RBCEmulator> starting test emulation" << std::endl;
0069 
0070   std::bitset<2> decision;
0071 
0072   while (m_signal->next()) {
0073     RPCInputSignal* data = m_signal->retrievedata();
0074     m_input = dynamic_cast<RBCLinkBoardSignal*>(data)->m_linkboardin;
0075 
0076     m_rbcconf->rbclogic()->run(m_input, decision);
0077 
0078     m_layersignal[0] = m_rbcconf->rbclogic()->getlayersignal(0);
0079     m_layersignal[1] = m_rbcconf->rbclogic()->getlayersignal(1);
0080 
0081     printlayerinfo();
0082 
0083     if (m_debug)
0084       std::cout << decision[0] << " " << decision[1] << std::endl;
0085   }
0086 
0087   if (m_debug)
0088     std::cout << "RBCEmulator> end test emulation" << std::endl;
0089 }
0090 
0091 void RBCEmulator::emulate(RBCInput* in) {
0092   if (m_debug)
0093     std::cout << "RBCEmulator> starting emulation" << std::endl;
0094 
0095   std::bitset<2> decision;
0096 
0097   in->setWheelId(m_rbcinfo.wheel());
0098 
0099   m_input = (*in);
0100 
0101   if (m_debug)
0102     std::cout << "RBCEmulator> copied data" << std::endl;
0103 
0104   //.. mask and force as specified in hardware configuration
0105   m_rbcconf->preprocess(m_input);
0106 
0107   if (m_debug)
0108     std::cout << "RBCEmulator> preprocessing done" << std::endl;
0109 
0110   m_rbcconf->rbclogic()->run(m_input, decision);
0111 
0112   if (m_debug)
0113     std::cout << "RBCEmulator> applying logic" << std::endl;
0114 
0115   m_layersignal[0] = m_rbcconf->rbclogic()->getlayersignal(0);
0116   m_layersignal[1] = m_rbcconf->rbclogic()->getlayersignal(1);
0117 
0118   m_decision.set(0, decision[0]);
0119   m_decision.set(1, decision[1]);
0120 
0121   if (m_debug) {
0122     printlayerinfo();
0123     std::cout << decision[0] << " " << decision[1] << std::endl;
0124     std::cout << "RBCEmulator> end emulation" << std::endl;
0125   }
0126 
0127   decision.reset();
0128 }
0129 
0130 void RBCEmulator::reset() {
0131   m_decision.reset();
0132   m_layersignal[0]->reset();
0133   m_layersignal[1]->reset();
0134 }
0135 
0136 void RBCEmulator::printinfo() const {
0137   if (m_debug) {
0138     std::cout << "RBC --> \n";
0139     m_rbcinfo.printinfo();
0140   }
0141 }
0142 
0143 void RBCEmulator::printlayerinfo() const {
0144   std::cout << "Sector summary by layer: \n";
0145   for (int i = 0; i < 6; ++i)
0146     std::cout << (*m_layersignal[0])[i] << '\t' << (*m_layersignal[1])[i] << '\n';
0147 }