CMS 3D CMS Logo

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 //=============================================================================
19  m_rbcinfo{},
20  m_signal{},
21  m_input{},
22  m_logtype{"TestLogic"},
23  m_debug{false}
24  {
27 }
28 
29 RBCEmulator::RBCEmulator( const char * logic_type ):
30  m_rbcinfo{},
31  m_signal{},
32  m_rbcconf{std::make_unique<RBCBasicConfig>(logic_type)},
33  m_input{},
34  m_logtype{logic_type},
35  m_debug{false}
36  {
39 }
40 
41 RBCEmulator::RBCEmulator( const char * f_name , const char * logic_type ):
42  m_rbcinfo{},
43  m_signal{std::make_unique<RBCProcessTestSignal>( f_name )},
44  m_rbcconf{std::make_unique<RBCBasicConfig>(logic_type)},
45  m_input{},
46  m_logtype{ logic_type },
47  m_debug{false}
48  {
51 }
52 
53 //=============================================================================
55 {
56 
57  m_rbcconf = std::make_unique<RBCBasicConfig>(rbcspecs, &m_rbcinfo);
58 
59 }
60 
62 {
63 
64  bool status(true);
65 
66  status = m_rbcconf->initialise();
67 
68  if ( !status ) {
69  if( m_debug ) std::cout << "RBCEmulator> Problem initialising the Configuration \n";
70  return false; };
71 
72  return true;
73 
74 }
75 
76 void RBCEmulator::setid( int wh, int * sec)
77 {
78  m_rbcinfo.setid ( wh, sec);
79 }
80 
82 {
83 
84  if( m_debug ) std::cout << "RBCEmulator> starting test emulation" << std::endl;
85 
86  std::bitset<2> decision;
87 
88  while ( m_signal->next() )
89  {
90 
91  RPCInputSignal * data = m_signal->retrievedata();
92  m_input = dynamic_cast<RBCLinkBoardSignal*>( data )->m_linkboardin ;
93 
94  m_rbcconf->rbclogic()->run( m_input , decision );
95 
96  m_layersignal[0] = m_rbcconf->rbclogic()->getlayersignal( 0 );
97  m_layersignal[1] = m_rbcconf->rbclogic()->getlayersignal( 1 );
98 
100 
101  if ( m_debug ) std::cout << decision[0] << " " << decision[1] << std::endl;
102 
103  }
104 
105  if( m_debug ) std::cout << "RBCEmulator> end test emulation" << std::endl;
106 
107 }
108 
110 {
111 
112  if( m_debug ) std::cout << "RBCEmulator> starting emulation" << std::endl;
113 
114  std::bitset<2> decision;
115 
116  in->setWheelId( m_rbcinfo.wheel() );
117 
118  m_input = (*in);
119 
120  if( m_debug ) std::cout << "RBCEmulator> copied data" << std::endl;
121 
122  //.. mask and force as specified in hardware configuration
123  m_rbcconf->preprocess( m_input );
124 
125  if( m_debug ) std::cout << "RBCEmulator> preprocessing done" << std::endl;
126 
127  m_rbcconf->rbclogic()->run( m_input , decision );
128 
129  if( m_debug ) std::cout << "RBCEmulator> applying logic" << std::endl;
130 
131  m_layersignal[0] = m_rbcconf->rbclogic()->getlayersignal( 0 );
132  m_layersignal[1] = m_rbcconf->rbclogic()->getlayersignal( 1 );
133 
134  m_decision.set(0, decision[0] );
135  m_decision.set(1, decision[1] );
136 
137  if( m_debug ) {
138  printlayerinfo();
139  std::cout << decision[0] << " " << decision[1] << std::endl;
140  std::cout << "RBCEmulator> end emulation" << std::endl;
141  }
142 
143  decision.reset();
144 
145 }
146 
148 {
149 
150  m_decision.reset();
151  m_layersignal[0]->reset();
152  m_layersignal[1]->reset();
153 
154 }
155 
157 {
158 
159  if( m_debug ) {
160  std::cout << "RBC --> \n";
162  }
163 
164 }
165 
167 {
168 
169  std::cout << "Sector summary by layer: \n";
170  for(int i=0; i < 6; ++i)
171  std::cout << (*m_layersignal[0])[i] << '\t'
172  << (*m_layersignal[1])[i] << '\n';
173 
174 }
void emulate()
Definition: RBCEmulator.cc:81
std::unique_ptr< ProcessInputSignal > m_signal
Definition: RBCEmulator.h:63
void printinfo() const
Definition: RBCEmulator.cc:156
void printlayerinfo() const
Definition: RBCEmulator.cc:166
bool initialise()
Definition: RBCEmulator.cc:61
std::unique_ptr< RBCConfiguration > m_rbcconf
Definition: RBCEmulator.h:65
RBCEmulator()
Standard constructor.
Definition: RBCEmulator.cc:18
std::string m_logtype
Definition: RBCEmulator.h:76
void setWheelId(int wid)
Definition: RBCInput.h:54
std::bitset< 6 > * m_layersignal[2]
Definition: RBCEmulator.h:69
bool m_debug
Definition: RBCEmulator.h:78
RBCInput m_input
Definition: RBCEmulator.h:67
void printinfo() const
Definition: RBCId.cc:29
int wheel() const
Definition: RBCId.h:28
std::bitset< 2 > m_decision
Definition: RBCEmulator.h:71
void reset()
Definition: RBCEmulator.cc:147
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::array< std::bitset< 6 >, 2 > m_layersignalVec
Definition: RBCEmulator.h:73
void setid(int _wh, int *_sec)
Definition: RBCId.h:34
RBCId m_rbcinfo
Definition: RBCEmulator.h:61
void setid(int, int *)
Definition: RBCEmulator.cc:76
void setSpecifications(const RBCBoardSpecs *)
Definition: RBCEmulator.cc:54