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/ProcessTestSignal.h"
0005 #include "L1Trigger/RPCTechnicalTrigger/interface/RBCLinkBoardGLSignal.h"
0006 
0007 //-----------------------------------------------------------------------------
0008 // Implementation file for class : ProcessTestSignal
0009 //
0010 // 2008-11-17 : Andres Osorio
0011 //-----------------------------------------------------------------------------
0012 
0013 //=============================================================================
0014 // Standard constructor, initializes variables
0015 //=============================================================================
0016 ProcessTestSignal::ProcessTestSignal(const char* f_name) : m_in{} {
0017   m_in.open(f_name);
0018 
0019   if (!m_in.is_open()) {
0020     std::cout << "ProcessTestSignal> cannot open file" << std::endl;
0021   } else {
0022     std::cout << "ProcessTestSignal> file is now open" << std::endl;
0023   }
0024 
0025   m_lbin = std::make_unique<RBCLinkBoardGLSignal>(&m_data);
0026 }
0027 //=============================================================================
0028 // Destructor
0029 //=============================================================================
0030 ProcessTestSignal::~ProcessTestSignal() { m_in.close(); }
0031 
0032 //=============================================================================
0033 int ProcessTestSignal::next() {
0034   reset();
0035 
0036   if (m_in.fail())
0037     return 0;
0038 
0039   for (int j = 0; j < 5; ++j) {
0040     auto& block = m_vecdata.emplace_back();
0041     (m_in) >> (*block);
0042   }
0043 
0044   builddata();
0045 
0046   if (m_in.eof())
0047     return 0;
0048   return 1;
0049 }
0050 
0051 void ProcessTestSignal::showfirst() {
0052   rewind();
0053   for (auto& d : m_vecdata)
0054     std::cout << (*d);
0055   rewind();
0056 }
0057 
0058 void ProcessTestSignal::rewind() {
0059   m_in.clear();
0060   m_in.seekg(0, std::ios::beg);
0061 }
0062 
0063 void ProcessTestSignal::reset() { m_vecdata.clear(); }
0064 
0065 void ProcessTestSignal::builddata() {
0066   int _code(0);
0067   for (auto& d : m_vecdata) {
0068     for (int k = 0; k < 6; ++k) {
0069       _code = 10000 * (d->m_wheel) + 100 * d->m_sec1[k] + 1 * d->m_sec2[k];
0070       RBCInput* _signal = &(d->m_orsignals[k]);
0071       _signal->needmapping = true;
0072       m_data.insert(std::make_pair(_code, _signal));
0073     }
0074   }
0075 }