CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RBCEmulator.cc
Go to the documentation of this file.
1 // Include files
2 
3 // local
8 
9 //-----------------------------------------------------------------------------
10 // Implementation file for class : RBCEmulator
11 //
12 // 2008-10-10 : Andres Osorio
13 //-----------------------------------------------------------------------------
14 
15 //=============================================================================
16 // Standard constructor, initializes variables
17 //=============================================================================
18 RBCEmulator::RBCEmulator() : m_rbcinfo{}, m_signal{}, m_input{}, m_logtype{"TestLogic"}, m_debug{false} {
19  m_layersignal[0] = &m_layersignalVec[0];
20  m_layersignal[1] = &m_layersignalVec[1];
21 }
22 
23 RBCEmulator::RBCEmulator(const char* logic_type)
24  : m_rbcinfo{},
25  m_signal{},
26  m_rbcconf{std::make_unique<RBCBasicConfig>(logic_type)},
27  m_input{},
28  m_logtype{logic_type},
29  m_debug{false} {
30  m_layersignal[0] = &m_layersignalVec[0];
31  m_layersignal[1] = &m_layersignalVec[1];
32 }
33 
34 RBCEmulator::RBCEmulator(const char* f_name, const char* logic_type)
35  : m_rbcinfo{},
36  m_signal{std::make_unique<RBCProcessTestSignal>(f_name)},
37  m_rbcconf{std::make_unique<RBCBasicConfig>(logic_type)},
38  m_input{},
39  m_logtype{logic_type},
40  m_debug{false} {
41  m_layersignal[0] = &m_layersignalVec[0];
42  m_layersignal[1] = &m_layersignalVec[1];
43 }
44 
45 //=============================================================================
47  m_rbcconf = std::make_unique<RBCBasicConfig>(rbcspecs, &m_rbcinfo);
48 }
49 
51  bool status(true);
52 
53  status = m_rbcconf->initialise();
54 
55  if (!status) {
56  if (m_debug)
57  std::cout << "RBCEmulator> Problem initialising the Configuration \n";
58  return false;
59  };
60 
61  return true;
62 }
63 
64 void RBCEmulator::setid(int wh, int* sec) { m_rbcinfo.setid(wh, sec); }
65 
67  if (m_debug)
68  std::cout << "RBCEmulator> starting test emulation" << std::endl;
69 
70  std::bitset<2> decision;
71 
72  while (m_signal->next()) {
73  RPCInputSignal* data = m_signal->retrievedata();
74  m_input = dynamic_cast<RBCLinkBoardSignal*>(data)->m_linkboardin;
75 
76  m_rbcconf->rbclogic()->run(m_input, decision);
77 
78  m_layersignal[0] = m_rbcconf->rbclogic()->getlayersignal(0);
79  m_layersignal[1] = m_rbcconf->rbclogic()->getlayersignal(1);
80 
82 
83  if (m_debug)
84  std::cout << decision[0] << " " << decision[1] << std::endl;
85  }
86 
87  if (m_debug)
88  std::cout << "RBCEmulator> end test emulation" << std::endl;
89 }
90 
92  if (m_debug)
93  std::cout << "RBCEmulator> starting emulation" << std::endl;
94 
95  std::bitset<2> decision;
96 
97  in->setWheelId(m_rbcinfo.wheel());
98 
99  m_input = (*in);
100 
101  if (m_debug)
102  std::cout << "RBCEmulator> copied data" << std::endl;
103 
104  //.. mask and force as specified in hardware configuration
105  m_rbcconf->preprocess(m_input);
106 
107  if (m_debug)
108  std::cout << "RBCEmulator> preprocessing done" << std::endl;
109 
110  m_rbcconf->rbclogic()->run(m_input, decision);
111 
112  if (m_debug)
113  std::cout << "RBCEmulator> applying logic" << std::endl;
114 
115  m_layersignal[0] = m_rbcconf->rbclogic()->getlayersignal(0);
116  m_layersignal[1] = m_rbcconf->rbclogic()->getlayersignal(1);
117 
118  m_decision.set(0, decision[0]);
119  m_decision.set(1, decision[1]);
120 
121  if (m_debug) {
122  printlayerinfo();
123  std::cout << decision[0] << " " << decision[1] << std::endl;
124  std::cout << "RBCEmulator> end emulation" << std::endl;
125  }
126 
127  decision.reset();
128 }
129 
131  m_decision.reset();
132  m_layersignal[0]->reset();
133  m_layersignal[1]->reset();
134 }
135 
137  if (m_debug) {
138  std::cout << "RBC --> \n";
140  }
141 }
142 
144  std::cout << "Sector summary by layer: \n";
145  for (int i = 0; i < 6; ++i)
146  std::cout << (*m_layersignal[0])[i] << '\t' << (*m_layersignal[1])[i] << '\n';
147 }
void emulate()
Definition: RBCEmulator.cc:66
std::unique_ptr< ProcessInputSignal > m_signal
Definition: RBCEmulator.h:62
void printinfo() const
Definition: RBCEmulator.cc:136
void printlayerinfo() const
Definition: RBCEmulator.cc:143
bool initialise()
Definition: RBCEmulator.cc:50
list status
Definition: mps_update.py:107
std::unique_ptr< RBCConfiguration > m_rbcconf
Definition: RBCEmulator.h:64
RBCEmulator()
Standard constructor.
Definition: RBCEmulator.cc:18
void setWheelId(int wid)
Definition: RBCInput.h:52
std::bitset< 6 > * m_layersignal[2]
Definition: RBCEmulator.h:68
bool m_debug
Definition: RBCEmulator.h:77
RBCInput m_input
Definition: RBCEmulator.h:66
void printinfo() const
Definition: RBCId.cc:28
int wheel() const
Definition: RBCId.h:28
std::bitset< 2 > m_decision
Definition: RBCEmulator.h:70
void reset()
Definition: RBCEmulator.cc:130
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void setid(int _wh, int *_sec)
Definition: RBCId.h:34
tuple cout
Definition: gather_cfg.py:144
RBCId m_rbcinfo
Definition: RBCEmulator.h:60
void setid(int, int *)
Definition: RBCEmulator.cc:64
void setSpecifications(const RBCBoardSpecs *)
Definition: RBCEmulator.cc:46