CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTCCBConfig.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2009/10/30 10:39:05 $
5  * $Revision: 1.8 $
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"
19 
20 //---------------
21 // C++ Headers --
22 //---------------
23 #include <iostream>
24 #include <sstream>
25 #include <vector>
26 
27 //-------------------
28 // Initializations --
29 //-------------------
30 
31 
32 //----------------
33 // Constructors --
34 //----------------
36  dataVersion( " " ) {
37  dataList.reserve( 1000 );
38  dBuf = 0;
39 }
40 
41 
42 DTCCBConfig::DTCCBConfig( const std::string& version ):
43  dataVersion( version ) {
44  dataList.reserve( 1000 );
45  dBuf = 0;
46 }
47 
48 
50  wheelId( 0 ),
51  stationId( 0 ),
52  sectorId( 0 ) {
53 }
54 
55 
57  confType( 0 ),
58  confKey ( 0 ) {
59 }
60 
61 
62 //--------------
63 // Destructor --
64 //--------------
66  resetMap();
67 // DTDataBuffer< int,std::vector<int>* >::dropBuffer( mapName() );
68  delete dBuf;
69 }
70 
71 
73 }
74 
75 
77 }
78 
79 
80 //--------------
81 // Operations --
82 //--------------
83 std::vector<DTConfigKey> DTCCBConfig::fullKey() const {
84  return fullConfigKey;
85 }
86 
87 
88 int DTCCBConfig::stamp() const {
89  return timeStamp;
90 }
91 
92 
93 int DTCCBConfig::configKey( int wheelId,
94  int stationId,
95  int sectorId,
96  std::vector<int>& confKey ) const {
97 
98  confKey.clear();
99 // std::string mName = mapName();
100 // DTBufferTree< int,std::vector<int>* >* dBuf =
101 // DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
102 // if ( dBuf == 0 ) {
103 // cacheMap();
104 // dBuf =
105 // DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
106 // }
107  if ( dBuf == 0 ) cacheMap();
108 
109  std::vector<int> chanKey;
110  chanKey.reserve(3);
111  chanKey.push_back( wheelId );
112  chanKey.push_back( stationId );
113  chanKey.push_back( sectorId );
114  std::vector<int>* confPtr;
115  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), confPtr );
116  if ( !searchStatus ) confKey = *confPtr;
117 
118  return searchStatus;
119 
120 }
121 
122 
124  std::vector<int>& confKey ) const {
125  return configKey( id.wheel(),
126  id.station(),
127  id.sector(),
128  confKey );
129 }
130 
131 
134 
135  ccb_config_map keyList;
136  std::vector< std::pair<DTCCBId,int>* > tempList;
137  const_iterator d_iter = begin();
138  const_iterator d_iend = end();
139  while ( d_iter != d_iend ) tempList.push_back(
140  new std::pair<DTCCBId,int>( *d_iter++ ) );
141  std::vector< std::pair<DTCCBId,int>* >::iterator t_iter = tempList.begin();
142  std::vector< std::pair<DTCCBId,int>* >::iterator t_iend = tempList.end();
143  while ( t_iter != t_iend ) {
144  std::pair<DTCCBId,int>* ptr = *t_iter++;
145  if ( ptr == 0 ) continue;
146  DTCCBId& ccbId = ptr->first;
147  std::vector<int> cfgKeys;
148  cfgKeys.push_back( ptr->second );
149  std::vector< std::pair<DTCCBId,int>* >::iterator n_iter( t_iter );
150  while( n_iter != t_iend ) {
151  std::pair<DTCCBId,int>*& pck = *n_iter++;
152  if ( pck == 0 ) continue;
153  DTCCBId& chkId = pck->first;
154  if ( ( chkId. wheelId == ccbId. wheelId ) &&
155  ( chkId.stationId == ccbId.stationId ) &&
156  ( chkId. sectorId == ccbId. sectorId ) ) {
157  cfgKeys.push_back( pck->second );
158  delete pck;
159  pck = 0;
160  }
161  }
162  keyList.push_back( std::pair< DTCCBId,std::vector<int> >( ccbId,
163  cfgKeys ) );
164  delete ptr;
165  }
166  return keyList;
167 
168 }
169 
170 
171 const
172 std::string& DTCCBConfig::version() const {
173  return dataVersion;
174 }
175 
176 
177 std::string& DTCCBConfig::version() {
178  return dataVersion;
179 }
180 
181 
183  resetMap();
184 // DTDataBuffer< int,std::vector<int>* >::dropBuffer( mapName() );
185  delete dBuf;
186  dBuf = 0;
187  dataList.clear();
188  return;
189 }
190 
191 
192 void DTCCBConfig::setFullKey( std::vector<DTConfigKey> key ) {
193  fullConfigKey = key;
194 }
195 
196 
198  timeStamp = s;
199 }
200 
201 
202 int DTCCBConfig::setConfigKey( int wheelId,
203  int stationId,
204  int sectorId,
205  const std::vector<int>& confKey ) {
206 
207 // std::string mName = mapName();
208 // DTBufferTree< int,std::vector<int>* >* dBuf =
209 // DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
210 // if ( dBuf == 0 ) {
211 // cacheMap();
212 // dBuf =
213 // DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
214 // }
215  if ( dBuf == 0 ) cacheMap();
216 
217  std::vector<int> chanKey;
218  chanKey.reserve(3);
219  chanKey.push_back( wheelId );
220  chanKey.push_back( stationId );
221  chanKey.push_back( sectorId );
222 
223  std::vector<int>* confPtr;
224  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), confPtr );
225 
226  if ( !searchStatus ) {
227  std::vector< std::pair<DTCCBId,int> > tempList;
228  const_iterator iter = dataList.begin();
229  const_iterator iend = dataList.end();
230  while ( iter != iend ) {
231  const DTCCBId& ccbId( iter->first );
232 // if ( ( ccbId. wheelId == wheelId ) &&
233 // ( ccbId.stationId == stationId ) &&
234 // ( ccbId. sectorId == sectorId ) ) tempList.push_back( *iter );
235  if ( ( ccbId. wheelId != wheelId ) ||
236  ( ccbId.stationId != stationId ) ||
237  ( ccbId. sectorId != sectorId ) ) tempList.push_back( *iter );
238  ++iter;
239  }
240  dataList = tempList;
241  DTCCBId ccbId;
242  ccbId. wheelId = wheelId;
243  ccbId.stationId = stationId;
244  ccbId. sectorId = sectorId;
245  std::vector<int>::const_iterator cfgIter = confKey.begin();
246  std::vector<int>::const_iterator cfgIend = confKey.end();
247  while ( cfgIter != cfgIend ) dataList.push_back( std::pair<DTCCBId,int>(
248  ccbId, *cfgIter++ ) );
249  *confPtr = confKey;
250  return -1;
251  }
252  else {
253  dBuf->insert( chanKey.begin(),
254  chanKey.end(), new std::vector<int>( confKey ) );
255  DTCCBId ccbId;
256  ccbId. wheelId = wheelId;
257  ccbId.stationId = stationId;
258  ccbId. sectorId = sectorId;
259  std::vector<int>::const_iterator cfgIter = confKey.begin();
260  std::vector<int>::const_iterator cfgIend = confKey.end();
261  while ( cfgIter != cfgIend ) dataList.push_back( std::pair<DTCCBId,int>(
262  ccbId, *cfgIter++ ) );
263  return 0;
264  }
265 
266 }
267 
268 
270  const std::vector<int>& confKey ) {
271  return setConfigKey( id.wheel(),
272  id.station(),
273  id.sector(),
274  confKey );
275 }
276 
277 
279  int stationId,
280  int sectorId,
281  const std::vector<int>& confKey ) {
282 
283 // std::string mName = mapName();
284 // DTBufferTree< int,std::vector<int>* >* dBuf =
285 // DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
286 // if ( dBuf == 0 ) {
287 // cacheMap();
288 // dBuf =
289 // DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
290 // }
291  if ( dBuf == 0 ) cacheMap();
292 
293  std::vector<int> chanKey;
294  chanKey.reserve(3);
295  chanKey.push_back( wheelId );
296  chanKey.push_back( stationId );
297  chanKey.push_back( sectorId );
298 
299  DTCCBId ccbId;
300  ccbId. wheelId = wheelId;
301  ccbId.stationId = stationId;
302  ccbId. sectorId = sectorId;
303  std::vector<int>::const_iterator iter = confKey.begin();
304  std::vector<int>::const_iterator iend = confKey.end();
305  int key;
306 
307  std::vector<int>* confPtr;
308  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), confPtr );
309 
310  if ( searchStatus ) {
311  dBuf->insert( chanKey.begin(),
312  chanKey.end(), confPtr = new std::vector<int>( confKey ) );
313  }
314 
315  while ( iter != iend ) {
316  key = *iter++;
317  dataList.push_back( std::pair<DTCCBId,int>( ccbId, key ) );
318  confPtr->push_back( key );
319  }
320 
321  if ( !searchStatus ) {
322  return -1;
323  }
324  else {
325  return 0;
326  }
327 
328 }
329 
330 
332  const std::vector<int>& confKey ) {
333  return appendConfigKey( id.wheel(),
334  id.station(),
335  id.sector(),
336  confKey );
337 }
338 
339 
341  return dataList.begin();
342 }
343 
344 
346  return dataList.end();
347 }
348 
349 
350 /*
351 std::string DTCCBConfig::mapName() const {
352  std::stringstream name;
353  name << dataVersion << "_map_CCBConfig" << this;
354  return name.str();
355 }
356 */
357 
358 
359 void DTCCBConfig::cacheMap() const {
360 
361 // std::string mName = mapName();
362 // DTBufferTree< int,std::vector<int>* >* dBuf =
363 // DTDataBuffer< int,std::vector<int>* >::openBuffer( mName );
365  pBuf = const_cast<DTBufferTree< int,std::vector<int>* >**>( &dBuf );
366  *pBuf = new DTBufferTree< int,std::vector<int>* >;
367  dBuf->setDefault( 0 );
368 
369  const_iterator iter = dataList.begin();
370  const_iterator iend = dataList.end();
371  std::vector<int> chanKey;
372  chanKey.reserve(3);
373  while ( iter != iend ) {
374 
375  const DTCCBId& chan = iter->first;
376 
377  chanKey.clear();
378  chanKey.push_back( chan. wheelId );
379  chanKey.push_back( chan.stationId );
380  chanKey.push_back( chan. sectorId );
381  std::vector<int>* ccbConfPtr;
382  int searchStatus = dBuf->find( chanKey.begin(),
383  chanKey.end(), ccbConfPtr );
384  if ( searchStatus ) dBuf->insert( chanKey.begin(),
385  chanKey.end(),
386  ccbConfPtr = new std::vector<int> );
387  ccbConfPtr->push_back( iter->second );
388 
389  iter++;
390 
391  }
392 
393 }
394 
395 
396 void DTCCBConfig::resetMap() const {
397 // std::string mName = mapName();
398 // DTBufferTree< int,std::vector<int>* >* dBuf =
399 // DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
400  if ( dBuf != 0 ) {
401  std::vector< std::vector<int>* > list( dBuf->contList() );
402  std::vector< std::vector<int>* >::const_iterator iter = list.begin();
403  std::vector< std::vector<int>* >::const_iterator iend = list.end();
404  while ( iter != iend ) delete *iter++;
405  }
406  return;
407 }
408 
409 
void setFullKey(std::vector< DTConfigKey >)
Definition: DTCCBConfig.cc:192
void setStamp(int s)
Definition: DTCCBConfig.cc:197
std::vector< std::pair< DTCCBId, int > > dataList
Definition: DTCCBConfig.h:127
int insert(ElementKey fKey, ElementKey lKey, const Content &cont)
std::vector< DTConfigKey > fullConfigKey
Definition: DTCCBConfig.h:126
const std::string & version() const
access version
Definition: DTCCBConfig.cc:172
int configKey(int wheelId, int stationId, int sectorId, std::vector< int > &confKey) const
Definition: DTCCBConfig.cc:93
const_iterator end() const
Definition: DTCCBConfig.cc:345
void cacheMap() const
read and store full content
Definition: DTCCBConfig.cc:359
ccb_config_map configKeyMap() const
Definition: DTCCBConfig.cc:133
std::vector< std::pair< DTCCBId, int > >::const_iterator const_iterator
Access methods to data.
Definition: DTCCBConfig.h:118
int stationId
Definition: DTCCBConfig.h:44
void resetMap() const
Definition: DTCCBConfig.cc:396
static void setDefault(const Content &def)
std::vector< Content > contList()
std::vector< std::pair< DTCCBId, std::vector< int > > > ccb_config_map
Definition: DTCCBConfig.h:87
std::vector< DTConfigKey > fullKey() const
get content
Definition: DTCCBConfig.cc:83
std::string dataVersion
Definition: DTCCBConfig.h:125
int find(ElementKey fKey, ElementKey lKey, Content &cont)
virtual ~DTCCBConfig()
Definition: DTCCBConfig.cc:65
int stamp() const
Definition: DTCCBConfig.cc:88
list key
Definition: combine.py:13
void clear()
reset content
Definition: DTCCBConfig.cc:182
int setConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:202
string s
Definition: asciidump.py:422
const_iterator begin() const
Definition: DTCCBConfig.cc:340
DTBufferTree< int, std::vector< int > * > * dBuf
Definition: DTCCBConfig.h:129
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:278
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run