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