CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTLVStatus.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2010/01/20 18:20:08 $
5  * $Revision: 1.2 $
6  * \author Paolo Ronchese INFN Padova
7  *
8  */
9 
10 //----------------------
11 // This Class' Header --
12 //----------------------
14 
15 //-------------------------------
16 // Collaborating Class Headers --
17 //-------------------------------
18 //#include "CondFormats/DTObjects/interface/DTDataBuffer.h"
20 
21 //---------------
22 // C++ Headers --
23 //---------------
24 #include <iostream>
25 #include <sstream>
26 
27 //-------------------
28 // Initializations --
29 //-------------------
30 
31 
32 //----------------
33 // Constructors --
34 //----------------
36  dataVersion( " " ) {
37  dataList.reserve( 10 );
38  dBuf = 0;
39 }
40 
41 
42 DTLVStatus::DTLVStatus( const std::string& version ):
43  dataVersion( version ) {
44  dataList.reserve( 10 );
45  dBuf = 0;
46 }
47 
48 
50  wheelId( 0 ),
51  stationId( 0 ),
52  sectorId( 0 ) {
53 }
54 
55 
57  flagCFE( 0 ),
58  flagDFE( 0 ),
59  flagCMC( 0 ),
60  flagDMC( 0 ) {
61 }
62 
63 
64 //--------------
65 // Destructor --
66 //--------------
68 // DTDataBuffer<int,int>::dropBuffer( mapName() );
69  delete dBuf;
70 }
71 
72 
74 }
75 
76 
78 }
79 
80 
81 //--------------
82 // Operations --
83 //--------------
84 int DTLVStatus::get( int wheelId,
85  int stationId,
86  int sectorId,
87  int& flagCFE,
88  int& flagDFE,
89  int& flagCMC,
90  int& flagDMC ) const {
91  flagCFE = 0;
92  flagDFE = 0;
93  flagCMC = 0;
94  flagDMC = 0;
95 
96 // std::string mName = mapName();
97 // DTBufferTree<int,int>* dBuf =
98 // DTDataBuffer<int,int>::findBuffer( mName );
99 // if ( dBuf == 0 ) {
100 // cacheMap();
101 // dBuf =
102 // DTDataBuffer<int,int>::findBuffer( mName );
103 // }
104  if ( dBuf == 0 ) cacheMap();
105 
106  std::vector<int> chanKey;
107  chanKey.reserve(3);
108  chanKey.push_back( wheelId );
109  chanKey.push_back( stationId );
110  chanKey.push_back( sectorId );
111  int ientry;
112  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
113  if ( !searchStatus ) {
114  const DTLVStatusData& data( dataList[ientry].second );
115  flagCFE = data.flagCFE;
116  flagDFE = data.flagDFE;
117  flagCMC = data.flagCMC;
118  flagDMC = data.flagDMC;
119  }
120 
121  return searchStatus;
122 
123 }
124 
125 
127  int& flagCFE,
128  int& flagDFE,
129  int& flagCMC,
130  int& flagDMC ) const {
131  return get( id.wheel(),
132  id.station(),
133  id.sector(),
134  flagCFE,
135  flagDFE,
136  flagCMC,
137  flagDMC );
138 }
139 
140 
141 const
142 std::string& DTLVStatus::version() const {
143  return dataVersion;
144 }
145 
146 
147 std::string& DTLVStatus::version() {
148  return dataVersion;
149 }
150 
151 
153 // DTDataBuffer<int,int>::dropBuffer( mapName() );
154  delete dBuf;
155  dBuf = 0;
156  dataList.clear();
157  return;
158 }
159 
160 
161 int DTLVStatus::set( int wheelId,
162  int stationId,
163  int sectorId,
164  int flagCFE,
165  int flagDFE,
166  int flagCMC,
167  int flagDMC ) {
168 
169 // std::string mName = mapName();
170 // DTBufferTree<int,int>* dBuf =
171 // DTDataBuffer<int,int>::findBuffer( mName );
172 // if ( dBuf == 0 ) {
173 // cacheMap();
174 // dBuf =
175 // DTDataBuffer<int,int>::findBuffer( mName );
176 // }
177  if ( dBuf == 0 ) cacheMap();
178  std::vector<int> chanKey;
179  chanKey.reserve(3);
180  chanKey.push_back( wheelId );
181  chanKey.push_back( stationId );
182  chanKey.push_back( sectorId );
183  int ientry;
184  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
185 
186  if ( !searchStatus ) {
187  DTLVStatusData& data( dataList[ientry].second );
188  data.flagCFE = flagCFE;
189  data.flagDFE = flagDFE;
190  data.flagCMC = flagCMC;
191  data.flagDMC = flagDMC;
192  return -1;
193  }
194  else {
196  key. wheelId = wheelId;
197  key.stationId = stationId;
198  key. sectorId = sectorId;
200  data.flagCFE = flagCFE;
201  data.flagDFE = flagDFE;
202  data.flagCMC = flagCMC;
203  data.flagDMC = flagDMC;
204  ientry = dataList.size();
205  dataList.push_back( std::pair<DTLVStatusId,
206  DTLVStatusData>( key, data ) );
207  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
208  return 0;
209  }
210 
211  return 99;
212 
213 }
214 
215 
217  int flagCFE,
218  int flagDFE,
219  int flagCMC,
220  int flagDMC ) {
221  return set( id.wheel(),
222  id.station(),
223  id.sector(),
224  flagCFE,
225  flagDFE,
226  flagCMC,
227  flagDMC );
228 }
229 
230 
231 int DTLVStatus::setFlagCFE( int wheelId,
232  int stationId,
233  int sectorId,
234  int flag ) {
235  int flagCFE;
236  int flagDFE;
237  int flagCMC;
238  int flagDMC;
239  get( wheelId,
240  stationId,
241  sectorId,
242  flagCFE,
243  flagDFE,
244  flagCMC,
245  flagDMC );
246  return set( wheelId,
247  stationId,
248  sectorId,
249  flag,
250  flagDFE,
251  flagCMC,
252  flagDMC );
253 }
254 
255 
257  int flag ) {
258  return setFlagCFE( id.wheel(),
259  id.station(),
260  id.sector(),
261  flag );
262 }
263 
264 
265 int DTLVStatus::setFlagDFE( int wheelId,
266  int stationId,
267  int sectorId,
268  int flag ) {
269  int flagCFE;
270  int flagDFE;
271  int flagCMC;
272  int flagDMC;
273  get( wheelId,
274  stationId,
275  sectorId,
276  flagCFE,
277  flagDFE,
278  flagCMC,
279  flagDMC );
280  return set( wheelId,
281  stationId,
282  sectorId,
283  flagCFE,
284  flag,
285  flagCMC,
286  flagDMC );
287 }
288 
289 
291  int flag ) {
292  return setFlagDFE( id.wheel(),
293  id.station(),
294  id.sector(),
295  flag );
296 }
297 
298 
299 int DTLVStatus::setFlagCMC( int wheelId,
300  int stationId,
301  int sectorId,
302  int flag ) {
303  int flagCFE;
304  int flagDFE;
305  int flagCMC;
306  int flagDMC;
307  get( wheelId,
308  stationId,
309  sectorId,
310  flagCFE,
311  flagDFE,
312  flagCMC,
313  flagDMC );
314  return set( wheelId,
315  stationId,
316  sectorId,
317  flagCFE,
318  flagDFE,
319  flag,
320  flagDMC );
321 }
322 
323 
325  int flag ) {
326  return setFlagCMC( id.wheel(),
327  id.station(),
328  id.sector(),
329  flag );
330 }
331 
332 
333 int DTLVStatus::setFlagDMC( int wheelId,
334  int stationId,
335  int sectorId,
336  int flag ) {
337  int flagCFE;
338  int flagDFE;
339  int flagCMC;
340  int flagDMC;
341  get( wheelId,
342  stationId,
343  sectorId,
344  flagCFE,
345  flagDFE,
346  flagCMC,
347  flagDMC );
348  return set( wheelId,
349  stationId,
350  sectorId,
351  flagCFE,
352  flagDFE,
353  flagCMC,
354  flag );
355 }
356 
357 
359  int flag ) {
360  return setFlagDMC( id.wheel(),
361  id.station(),
362  id.sector(),
363  flag );
364 }
365 
366 
368  return dataList.begin();
369 }
370 
371 
373  return dataList.end();
374 }
375 
376 
377 std::string DTLVStatus::mapName() const {
378  std::stringstream name;
379  name << dataVersion << "_map_Mtime" << this;
380  return name.str();
381 }
382 
383 
384 void DTLVStatus::cacheMap() const {
385 
386 // std::string mName = mapName();
387 // DTBufferTree<int,int>* dBuf =
388 // DTDataBuffer<int,int>::openBuffer( mName );
389  DTBufferTree<int,int>** pBuf;
390  pBuf = const_cast<DTBufferTree<int,int>**>( &dBuf );
391  *pBuf = new DTBufferTree<int,int>;
392 
393  int entryNum = 0;
394  int entryMax = dataList.size();
395  std::vector<int> chanKey;
396  chanKey.reserve(3);
397  while ( entryNum < entryMax ) {
398 
399  const DTLVStatusId& chan = dataList[entryNum].first;
400 
401  chanKey.clear();
402  chanKey.push_back( chan. wheelId );
403  chanKey.push_back( chan.stationId );
404  chanKey.push_back( chan. sectorId );
405  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
406 
407  }
408 
409  return;
410 
411 }
412 
long int flag
Definition: mlp_lapack.h:47
int get(int wheelId, int stationId, int sectorId, int &flagCFE, int &flagDFE, int &flagCMC, int &flagDMC) const
get content
Definition: DTLVStatus.cc:84
int set(int wheelId, int stationId, int sectorId, int flagCFE, int flagDFE, int flagCMC, int flagDMC)
Definition: DTLVStatus.cc:161
const std::string & version() const
access version
Definition: DTLVStatus.cc:142
std::string dataVersion
Definition: DTLVStatus.h:146
void clear()
reset content
Definition: DTLVStatus.cc:152
int setFlagDMC(int wheelId, int stationId, int sectorId, int flag)
Definition: DTLVStatus.cc:333
int insert(ElementKey fKey, ElementKey lKey, const Content &cont)
const_iterator end() const
Definition: DTLVStatus.cc:372
DTBufferTree< int, int > * dBuf
Definition: DTLVStatus.h:150
std::vector< std::pair< DTLVStatusId, DTLVStatusData > > dataList
Definition: DTLVStatus.h:148
std::string mapName() const
Definition: DTLVStatus.cc:377
U second(std::pair< T, U > const &p)
std::vector< std::pair< DTLVStatusId, DTLVStatusData > >::const_iterator const_iterator
Access methods to data.
Definition: DTLVStatus.h:140
int setFlagCFE(int wheelId, int stationId, int sectorId, int flag)
Definition: DTLVStatus.cc:231
const_iterator begin() const
Definition: DTLVStatus.cc:367
int find(ElementKey fKey, ElementKey lKey, Content &cont)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
list key
Definition: combine.py:13
int setFlagDFE(int wheelId, int stationId, int sectorId, int flag)
Definition: DTLVStatus.cc:265
void cacheMap() const
read and store full content
Definition: DTLVStatus.cc:384
int setFlagCMC(int wheelId, int stationId, int sectorId, int flag)
Definition: DTLVStatus.cc:299