CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 //=============================================================================
19 
20  m_signal = NULL;
21  m_logtype = std::string("TestLogic");
22  m_rbcinfo = new RBCId();
23  m_input = new RBCInput();
24 
25  m_layersignal[0] = new std::bitset<6>();
26  m_layersignal[1] = new std::bitset<6>();
27  m_layersignalVec.push_back( m_layersignal[0] );
28  m_layersignalVec.push_back( m_layersignal[1] );
29 
30  m_debug = false;
31 
32 }
33 
34 RBCEmulator::RBCEmulator( const char * logic_type ) {
35 
36  m_signal = NULL;
37  m_logtype = std::string( logic_type );
38  m_rbcinfo = new RBCId();
39  m_input = new RBCInput();
40  m_rbcconf = dynamic_cast<RBCConfiguration*> (new RBCBasicConfig(logic_type));
41 
42  m_layersignal[0] = new std::bitset<6>();
43  m_layersignal[1] = new std::bitset<6>();
44  m_layersignalVec.push_back( m_layersignal[0] );
45  m_layersignalVec.push_back( m_layersignal[1] );
46 
47  m_debug = false;
48 
49 }
50 
51 RBCEmulator::RBCEmulator( const char * f_name , const char * logic_type ) {
52 
53  m_signal = dynamic_cast<ProcessInputSignal*>(new RBCProcessTestSignal( f_name ));
54  m_logtype = std::string( logic_type );
55  m_rbcinfo = new RBCId();
56  m_input = new RBCInput();
57  m_rbcconf = dynamic_cast<RBCConfiguration*> (new RBCBasicConfig(logic_type));
58 
59  m_layersignal[0] = new std::bitset<6>();
60  m_layersignal[1] = new std::bitset<6>();
61  m_layersignalVec.push_back( m_layersignal[0] );
62  m_layersignalVec.push_back( m_layersignal[1] );
63 
64  m_debug = false;
65 
66 }
67 
68 //=============================================================================
69 // Destructor
70 //=============================================================================
72 
73  if (m_signal) delete m_signal;
74  if (m_rbcconf) delete m_rbcconf;
75  if (m_rbcinfo) delete m_rbcinfo;
76  if (m_input) delete m_input;
77 
78  std::vector<std::bitset<6>*>::iterator itr;
79  for(itr = m_layersignalVec.begin(); itr != m_layersignalVec.end(); ++itr)
80  delete (*itr);
81 
82 }
83 
84 //=============================================================================
86 {
87 
88  m_rbcconf = dynamic_cast<RBCConfiguration*> (new RBCBasicConfig(rbcspecs, m_rbcinfo));
89 
90 }
91 
93 {
94 
95  bool status(true);
96 
97  status = m_rbcconf->initialise();
98 
99  if ( !status ) {
100  if( m_debug ) std::cout << "RBCEmulator> Problem initialising the Configuration \n";
101  return 0; };
102 
103  return 1;
104 
105 }
106 
107 void RBCEmulator::setid( int wh, int * sec)
108 {
109  m_rbcinfo->setid ( wh, sec);
110 }
111 
113 {
114 
115  if( m_debug ) std::cout << "RBCEmulator> starting test emulation" << std::endl;
116 
117  std::bitset<2> decision;
118 
119  while ( m_signal->next() )
120  {
121 
123  (*m_input) = * dynamic_cast<RBCLinkBoardSignal*>( data )->m_linkboardin ;
124 
125  m_rbcconf->m_rbclogic->run( (*m_input) , decision );
126 
129 
130  printlayerinfo();
131 
132  if ( m_debug ) std::cout << decision[0] << " " << decision[1] << std::endl;
133 
134  }
135 
136  if( m_debug ) std::cout << "RBCEmulator> end test emulation" << std::endl;
137 
138 }
139 
141 {
142 
143  if( m_debug ) std::cout << "RBCEmulator> starting emulation" << std::endl;
144 
145  std::bitset<2> decision;
146 
147  in->setWheelId( m_rbcinfo->wheel() );
148 
149  (*m_input) = (*in);
150 
151  if( m_debug ) std::cout << "RBCEmulator> copied data" << std::endl;
152 
153  //.. mask and force as specified in hardware configuration
155 
156  if( m_debug ) std::cout << "RBCEmulator> preprocessing done" << std::endl;
157 
158  m_rbcconf->m_rbclogic->run( (*m_input) , decision );
159 
160  if( m_debug ) std::cout << "RBCEmulator> applying logic" << std::endl;
161 
164 
165  m_decision.set(0, decision[0] );
166  m_decision.set(1, decision[1] );
167 
168  if( m_debug ) {
169  printlayerinfo();
170  std::cout << decision[0] << " " << decision[1] << std::endl;
171  std::cout << "RBCEmulator> end emulation" << std::endl;
172  }
173 
174  decision.reset();
175 
176 }
177 
179 {
180 
181  m_decision.reset();
182  m_layersignal[0]->reset();
183  m_layersignal[1]->reset();
184 
185 }
186 
188 {
189 
190  if( m_debug ) {
191  std::cout << "RBC --> \n";
192  m_rbcinfo->printinfo();
193  }
194 
195 }
196 
198 {
199 
200  std::cout << "Sector summary by layer: \n";
201  for(int i=0; i < 6; ++i)
202  std::cout << (*m_layersignal[0])[i] << '\t'
203  << (*m_layersignal[1])[i] << '\n';
204 
205 }
void emulate()
Definition: RBCEmulator.cc:112
int i
Definition: DBlmapReader.cc:9
void run(const RBCInput &, std::bitset< 2 > &)
Definition: RBCLogicUnit.cc:76
virtual RPCInputSignal * retrievedata()=0
virtual ~RBCEmulator()
Destructor.
Definition: RBCEmulator.cc:71
void printinfo()
Definition: RBCId.cc:41
void printlayerinfo()
Definition: RBCEmulator.cc:197
bool initialise()
Definition: RBCEmulator.cc:92
ProcessInputSignal * m_signal
Definition: RBCEmulator.h:63
#define NULL
Definition: scimark2.h:8
RBCEmulator()
Standard constructor.
Definition: RBCEmulator.cc:18
Definition: RBCId.h:16
std::string m_logtype
Definition: RBCEmulator.h:79
void setWheelId(int wid)
Definition: RBCInput.h:77
std::bitset< 6 > * getlayersignal(int _idx)
Definition: RBCLogicUnit.h:36
std::bitset< 6 > * m_layersignal[2]
Definition: RBCEmulator.h:69
virtual void preprocess(RBCInput &)=0
bool m_debug
Definition: RBCEmulator.h:81
RBCLogicUnit * m_rbclogic
int wheel() const
Definition: RBCId.h:27
virtual int next()=0
RBCId * m_rbcinfo
Definition: RBCEmulator.h:57
std::bitset< 2 > m_decision
Definition: RBCEmulator.h:71
std::vector< std::bitset< 6 > * > m_layersignalVec
Definition: RBCEmulator.h:73
virtual bool initialise()=0
RBCConfiguration * m_rbcconf
Definition: RBCEmulator.h:65
void reset()
Definition: RBCEmulator.cc:178
void setid(int _wh, int *_sec)
Definition: RBCId.h:33
tuple cout
Definition: gather_cfg.py:121
tuple status
Definition: ntuplemaker.py:245
void setid(int, int *)
Definition: RBCEmulator.cc:107
void setSpecifications(const RBCBoardSpecs *)
Definition: RBCEmulator.cc:85
void printinfo()
Definition: RBCEmulator.cc:187
RBCInput * m_input
Definition: RBCEmulator.h:67