CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTKeyedConfigHandler.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Paolo Ronchese INFN Padova
5  *
6  */
7 
8 //-----------------------
9 // This Class' Header --
10 //-----------------------
12 
13 //-------------------------------
14 // Collaborating Class Headers --
15 //-------------------------------
18 
23 
24 #include "RelationalAccess/ISessionProxy.h"
25 #include "RelationalAccess/ITransaction.h"
26 #include "RelationalAccess/ISchema.h"
27 #include "RelationalAccess/ITable.h"
28 #include "RelationalAccess/ICursor.h"
29 #include "RelationalAccess/IQuery.h"
30 #include "CoralBase/AttributeList.h"
31 #include "CoralBase/AttributeSpecification.h"
32 #include "CoralBase/Attribute.h"
33 
34 //---------------
35 // C++ Headers --
36 //---------------
37 
38 #include <iostream>
39 
40 //-------------------
41 // Initializations --
42 //-------------------
44 
45 //----------------
46 // Constructors --
47 //----------------
49  copyData( ps.getUntrackedParameter<bool> ( "copyData", true ) ),
50  minBrickId( ps.getUntrackedParameter<int> ( "minBrick", 0 ) ),
51  maxBrickId( ps.getUntrackedParameter<int> ( "maxBrick", 999999999 ) ),
52  minRunId( ps.getUntrackedParameter<int> ( "minRun", 0 ) ),
53  maxRunId( ps.getUntrackedParameter<int> ( "maxRun", 999999999 ) ),
54  dataTag( ps.getParameter<std::string> ( "tag" ) ),
55  onlineConnect( ps.getParameter<std::string> ( "onlineDB" ) ),
56  onlineAuthentication( ps.getParameter<std::string> (
57  "onlineAuthentication" ) ),
58  onlineAuthSys( ps.getUntrackedParameter<int>( "onlineAuthSys",1 ) ),
59  brickContainer( ps.getParameter<std::string> ( "container" ) ),
60  connection(),
61  isession() {
62  std::cout << " PopCon application for DT configuration export "
63  << onlineAuthentication << std::endl;
64 }
65 
66 //--------------
67 // Destructor --
68 //--------------
70 }
71 
72 //--------------
73 // Operations --
74 //--------------
76 
77  //to access the information on the tag inside the offline database:
78  cond::TagInfo const & ti = tagInfo();
79  unsigned int last = ti.lastInterval.first;
80  std::cout << "last configuration key already copied for run: "
81  << last << std::endl;
82 
83  std::vector<DTConfigKey> lastKey;
84  std::cout << "check for last " << std::endl;
85  if ( last == 0 ) {
86  DTCCBConfig* dummyConf = new DTCCBConfig( dataTag );
87  dummyConf->setStamp( 0 );
88  dummyConf->setFullKey( lastKey );
89  cond::Time_t snc = 1;
90  std::cout << "write dummy " << std::endl;
91  m_to_transfer.push_back( std::make_pair( dummyConf, snc ) );
92  }
93  else {
94  std::cout << "get last payload" << std::endl;
95  Ref payload = lastPayload();
96  std::cout << "get last full key" << std::endl;
97  lastKey = payload->fullKey();
98  std::cout << "last key: " << std::endl;
99  std::vector<DTConfigKey>::const_iterator keyIter = lastKey.begin();
100  std::vector<DTConfigKey>::const_iterator keyIend = lastKey.end();
101  while ( keyIter != keyIend ) {
102  const DTConfigKey& cfgKeyList = *keyIter++;
103  std::cout << cfgKeyList.confType << " : "
104  << cfgKeyList.confKey << std::endl;
105  }
106  }
107 
108  //to access the information on last successful log entry for this tag:
109 // cond::LogDBEntry const & lde = logDBEntry();
110 
111  //to access the lastest payload (Ref is a smart pointer)
112 // Ref payload = lastPayload();
113 
114  if ( !copyData ) return;
115 
116  unsigned lastRun = last;
117  std::cout << "check for new runs since " << lastRun << std::endl;
118 
119  std::cout << "configure DbConnection" << std::endl;
120  // conn->configure( cond::CmsDefaults );
124  std::cout << "create/open DbSession" << std::endl;
126  std::cout << "start transaction" << std::endl;
127  isession->transaction().start( true );
128 
129  // =========== Update configuration data
130  chkConfigList();
131  // =========== Find latest runs
132  std::cout << "get run config..." << std::endl;
133  std::map<int,std::vector<int>*> runMap;
134  std::map<int,std::vector<DTConfigKey>*> rhcMap;
135  coral::ITable& runHistoryTable =
136  isession->nominalSchema().tableHandle( "RUNHISTORY" );
137  std::auto_ptr<coral::IQuery>
138  runHistoryQuery( runHistoryTable.newQuery() );
139  runHistoryQuery->addToOutputList( "RUN" );
140  runHistoryQuery->addToOutputList( "RHID" );
141  coral::ICursor& runHistoryCursor = runHistoryQuery->execute();
142  while( runHistoryCursor.next() ) {
143  const coral::AttributeList& row = runHistoryCursor.currentRow();
144  int runId = row[ "RUN"].data<int>();
145  int rhcId = static_cast<int>( row["RHID"].data<int>() );
146  // ----------- ignore already copied runs
147  if ( static_cast<unsigned>( runId ) <= lastRun ) continue;
148  // ----------- ignore runs outside required range
149  if ( runId < minRunId ) continue;
150  if ( runId > maxRunId ) continue;
151  std::cout << "schedule config key copy for run "
152  << runId << " ---> RHID " << rhcId << std::endl;
153  // ----------- retrieve or create RH relation list for this run
154  std::vector<int>* rhlPtr = 0;
155  std::map<int,std::vector<int>*>::const_iterator runIter;
156  if ( ( runIter = runMap.find( runId ) ) != runMap.end() )
157  rhlPtr = runIter->second;
158  else runMap.insert( std::pair<int,std::vector<int>*>( runId,
159  rhlPtr = new std::vector<int> ) );
160  // ----------- append RH relation to the list
161  rhlPtr->push_back( rhcId );
162  // ----------- create key list for this RH relation
163  if ( rhcMap.find( rhcId ) == rhcMap.end() )
164  rhcMap.insert( std::pair<int,std::vector<DTConfigKey>*>( rhcId,
165  new std::vector<DTConfigKey> ) );
166  }
167  if ( !runMap.size() ) std::cout << "no new run found" << std::endl;
168 
169  // =========== get ccb identifiers map
170  std::cout << "retrieve CCB map" << std::endl;
171  std::map<int,DTCCBId> ccbMap;
172  coral::ITable& ccbMapTable =
173  isession->nominalSchema().tableHandle( "CCBMAP" );
174  std::auto_ptr<coral::IQuery>
175  ccbMapQuery( ccbMapTable.newQuery() );
176  ccbMapQuery->addToOutputList( "CCBID" );
177  ccbMapQuery->addToOutputList( "WHEEL" );
178  ccbMapQuery->addToOutputList( "SECTOR" );
179  ccbMapQuery->addToOutputList( "STATION" );
180  coral::ICursor& ccbMapCursor = ccbMapQuery->execute();
181  while( ccbMapCursor.next() ) {
182  const coral::AttributeList& row = ccbMapCursor.currentRow();
183  int ccb = row["CCBID" ].data<int>();
184  int wheel = row["WHEEL" ].data<int>();
185  int sector = row["SECTOR" ].data<int>();
186  int station = row["STATION"].data<int>();
187  DTCCBId ccbId;
188  ccbId. wheelId = wheel;
189  ccbId.stationId = station;
190  ccbId. sectorId = sector;
191  ccbMap.insert( std::pair<int,DTCCBId>( ccb, ccbId ) );
192  }
193 
194  // =========== get brick types
195  std::cout << "retrieve brick types" << std::endl;
196  std::map<int,int> bktMap;
197  coral::AttributeList emptyBindVariableList;
198  std::auto_ptr<coral::IQuery>
199  brickTypeQuery( isession->nominalSchema().newQuery() );
200  brickTypeQuery->addToTableList( "CFGBRICKS" );
201  brickTypeQuery->addToTableList( "BRKT2CSETT" );
202  // ----------- join brick type (1-11) to subsystem part (1-6)
203  std::string bTypeCondition = "CFGBRICKS.BRKTYPE=BRKT2CSETT.BRKTYPE";
204  brickTypeQuery->addToOutputList( "CFGBRICKS.BRKID" );
205  brickTypeQuery->addToOutputList( "BRKT2CSETT.CSETTYPE" );
206  brickTypeQuery->setCondition( bTypeCondition, emptyBindVariableList );
207  coral::ICursor& brickTypeCursor = brickTypeQuery->execute();
208  while( brickTypeCursor.next() ) {
209  const coral::AttributeList& row = brickTypeCursor.currentRow();
210  int id = row["CFGBRICKS.BRKID" ].data<int>();
211  int bt = row["BRKT2CSETT.CSETTYPE"].data<short>();
212 // std::cout << "brick " << id << " type " << bt << std::endl;
213 // @@FIX - TEMPORARY PATCH
214 // if ( bt > 3 ) bt = 3;
215  bktMap.insert( std::pair<int,int>( id, bt ) );
216  }
217 
218  // =========== get RH relations
219  std::cout << "retrieve RH relations" << std::endl;
220  std::map<int,int> cfgMap;
221  coral::ITable& rhcRelTable =
222  isession->nominalSchema().tableHandle( "RHRELATIONS" );
223  std::auto_ptr<coral::IQuery>
224  rhcRelQuery( rhcRelTable.newQuery() );
225  rhcRelQuery->addToOutputList( "RHID" );
226  rhcRelQuery->addToOutputList( "CONFKEY" );
227  rhcRelQuery->addToOutputList( "CSETTYPEID" );
228  coral::ICursor& rhcRelCursor = rhcRelQuery->execute();
229  while( rhcRelCursor.next() ) {
230  const coral::AttributeList& row = rhcRelCursor.currentRow();
231  int rhc = row["RHID" ].data<int>();
232  int key = row["CONFKEY" ].data<int>();
233  int cfg = row["CSETTYPEID"].data<int>();
234  // ----------- check for used RH relations, skip unused
235  std::map<int,std::vector<DTConfigKey>*>::iterator rhcIter =
236  rhcMap.find( rhc );
237  std::map<int,std::vector<DTConfigKey>*>::iterator rhcIend =
238  rhcMap.end();
239  if ( rhcIter == rhcIend ) continue;
240  std::vector<DTConfigKey>* keyPtr = rhcIter->second;
241  DTConfigKey confList;
242  confList.confType = cfg;
243  confList.confKey = key;
244  keyPtr->push_back( confList );
245  // ----------- flag config key as used
246  if ( cfgMap.find( cfg ) == cfgMap.end() )
247  cfgMap.insert( std::pair<int,int>( key, rhc ) );
248  }
249 
250  // =========== get ccb config keys
251  std::cout << "retrieve CCB configuration keys" << std::endl;
252  std::map<int,std::map<int,int>*> keyMap;
253  std::map<int,int> cckMap;
254  coral::ITable& ccbRelTable =
255  isession->nominalSchema().tableHandle( "CCBRELATIONS" );
256  std::auto_ptr<coral::IQuery>
257  ccbRelQuery( ccbRelTable.newQuery() );
258  ccbRelQuery->addToOutputList( "CONFKEY" );
259  ccbRelQuery->addToOutputList( "CCBID" );
260  ccbRelQuery->addToOutputList( "CONFCCBKEY" );
261  coral::ICursor& ccbRelCursor = ccbRelQuery->execute();
262  while( ccbRelCursor.next() ) {
263  const coral::AttributeList& row = ccbRelCursor.currentRow();
264  int cfg = row["CONFKEY" ].data<int>();
265  int ccb = row["CCBID" ].data<int>();
266  int key = row["CONFCCBKEY"].data<int>();
267  // ----------- check for used configurations, skip unused
268  if ( cfgMap.find( cfg ) == cfgMap.end() ) continue;
269  // ----------- retrieve or create ccb id-key map for this configuration
270  std::map<int,int>* mapPtr = 0;
271  std::map<int,std::map<int,int>*>::const_iterator keyIter;
272  if ( ( keyIter = keyMap.find( cfg ) ) != keyMap.end() )
273  mapPtr = keyIter->second;
274  else keyMap.insert( std::pair<int,std::map<int,int>*>( cfg,
275  mapPtr = new std::map<int,int> ) );
276 // std::map<int,std::map<int,int>*>::const_iterator keyIter =
277 // keyMap.find( cfg );
278 // std::map<int,std::map<int,int>*>::const_iterator keyIend =
279 // keyMap.end();
280 // if ( keyIter != keyIend ) mapPtr = keyIter->second;
281 // else keyMap.insert(
282 // std::pair<int,std::map<int,int>*>( cfg,
283 // mapPtr = new std::map<int,int> ) );
284  // ----------- store config key for this ccb
285  std::map<int,int>& mapRef( *mapPtr );
286  mapRef.insert( std::pair<int,int>( ccb, key ) );
287  // ----------- flag ccb config key as used
288  if ( cckMap.find( key ) == cckMap.end() )
289  cckMap.insert( std::pair<int,int>( key, ccb ) );
290  }
291 
292  // =========== get brick keys
293  std::cout << "retrieve CCB configuration bricks" << std::endl;
294  std::map<int,std::vector<int>*> brkMap;
295  coral::ITable& confBrickTable =
296  isession->nominalSchema().tableHandle( "CFG2BRKREL" );
297  std::auto_ptr<coral::IQuery>
298  confBrickQuery( confBrickTable.newQuery() );
299  confBrickQuery->addToOutputList( "CONFID" );
300  confBrickQuery->addToOutputList( "BRKID" );
301  coral::ICursor& confBrickCursor = confBrickQuery->execute();
302  while( confBrickCursor.next() ) {
303  const coral::AttributeList& row = confBrickCursor.currentRow();
304  int key = row["CONFID"].data<int>();
305  int brk = row["BRKID" ].data<int>();
306  // ----------- check for used ccb config key, skip unused
307  if ( cckMap.find( key ) == cckMap.end() ) continue;
308 // std::map<int,std::vector<int>*>::const_iterator brkIter =
309 // brkMap.find( key );
310 // std::map<int,std::vector<int>*>::const_iterator brkIend =
311 // brkMap.end();
312  // ----------- retrieve or create brick list for this ccb config
313  std::vector<int>* brkPtr = 0;
314  std::map<int,std::vector<int>*>::const_iterator brkIter;
315 //check for new ccb config key
316  if ( ( brkIter = brkMap.find( key ) ) != brkMap.end() )
317  brkPtr = brkIter->second;
318  else brkMap.insert( std::pair<int,std::vector<int>*>( key,
319  brkPtr = new std::vector<int> ) );
320 // if ( brkIter != brkIend ) brkPtr = brkIter->second;
321 // else brkMap.insert(
322 // std::pair<int,std::vector<int>*>( key,
323 // brkPtr = new std::vector<int> ) );
324  // ----------- store brick key
325  brkPtr->push_back( brk );
326  }
327 
328  // =========== loop over new runs
329  std::map<int,std::vector<int>*>::const_iterator runIter = runMap.begin();
330  std::map<int,std::vector<int>*>::const_iterator runIend = runMap.end();
331  while ( runIter != runIend ) {
332  const std::pair<int,std::vector<int>*>& runEntry = *runIter++;
333  // ----------- get full configuration
334  int run = runEntry.first;
335  std::vector<DTConfigKey> cfl;
336  // ----------- get RH relation list
337  std::vector<int>* rhlPtr = runEntry.second;
338  std::vector<int>::const_iterator rhlIter = rhlPtr->begin();
339  std::vector<int>::const_iterator rhlIend = rhlPtr->end();
340  // ----------- loop over RH relations
341  while ( rhlIter != rhlIend ) {
342  int rhc = *rhlIter++;
343  std::cout << "retrieve configuration bricks for run " << run
344  << " ---> RH " << rhc << std::endl;
345 // std::map<int,std::vector<DTConfigKey>*>::const_iterator
346 // rhcIter = rhcMap.find( rhc );
347 // std::map<int,std::vector<DTConfigKey>*>::const_iterator
348 // rhcIend = rhcMap.end();
349  std::map<int,std::vector<DTConfigKey>*>::const_iterator rhcIter;
350  // ----------- redundant check
351  if ( ( rhcIter = rhcMap.find( rhc ) ) == rhcMap.end() ) continue;
352  std::vector<DTConfigKey>* listPtr = rhcIter->second;
353  // ----------- redundant check
354  if ( listPtr == 0 ) continue;
355  std::vector<DTConfigKey>::const_iterator bkiIter = listPtr->begin();
356  std::vector<DTConfigKey>::const_iterator bkiIend = listPtr->end();
357  while ( bkiIter != bkiIend ) cfl.push_back( *bkiIter++ );
358  }
359  if ( sameConfigList( cfl, lastKey ) ) continue;
360  lastKey = cfl;
361  DTCCBConfig* fullConf = new DTCCBConfig( dataTag );
362  // set run and full configuration in payload
363  fullConf->setStamp( run );
364  fullConf->setFullKey( cfl );
365 
366  std::vector<DTConfigKey>::const_iterator cfgIter = cfl.begin();
367  std::vector<DTConfigKey>::const_iterator cfgIend = cfl.end();
368  while ( cfgIter != cfgIend ) {
369  const DTConfigKey& cfgEntry = *cfgIter++;
370  int cft = cfgEntry.confType;
371  int cfg = cfgEntry.confKey;
372 
373  // =========== retrieve ccb config map
374 // std::map<int,std::map<int,int>*>::const_iterator keyIter =
375 // keyMap.find( cfg );
376 // std::map<int,std::map<int,int>*>::const_iterator keyIend =
377 // keyMap.end();
378  std::map<int,int>* mapPtr = 0;
379  std::map<int,std::map<int,int>*>::const_iterator keyIter;
380  // ----------- redundant check
381 // if ( keyIter != keyIend )
382  if ( ( keyIter = keyMap.find( cfg ) ) != keyMap.end() )
383  mapPtr = keyIter->second;
384  if ( mapPtr == 0 ) continue;
385  std::map<int,int>::const_iterator ccmIter = mapPtr->begin();
386  std::map<int,int>::const_iterator ccmIend = mapPtr->end();
387  while ( ccmIter != ccmIend ) {
388  const std::pair<int,int>& ccmEntry = *ccmIter++;
389  // ----------- get ccb config key
390  int ccb = ccmEntry.first;
391  int key = ccmEntry.second;
392  // retrieve chamber id
393 // std::map<int,DTCCBId>::const_iterator ccbIter = ccbMap.find( ccb );
394 // std::map<int,DTCCBId>::const_iterator ccbIend = ccbMap.end();
395  std::map<int,DTCCBId>::const_iterator ccbIter;
396  // ----------- redundant check
397 // if ( ccbIter == ccbIend ) continue;
398  if ( ( ccbIter = ccbMap.find( ccb ) ) == ccbMap.end() ) continue;
399  const DTCCBId& chaId = ccbIter->second;
400  // ----------- retrieve brick id list
401 // std::map<int,std::vector<int>*>::const_iterator brkIter =
402 // brkMap.find( key );
403 // std::map<int,std::vector<int>*>::const_iterator brkIend =
404 // brkMap.end();
405 // if ( brkIter == brkIend ) continue;
406  std::map<int,std::vector<int>*>::const_iterator brkIter;
407  if ( ( brkIter = brkMap.find( key ) ) == brkMap.end() ) continue;
408  std::vector<int>* brkPtr = brkIter->second;
409  // ----------- redundant check
410  if ( brkPtr == 0 ) continue;
411  // ----------- set brick id lists in payload
412  std::vector<int> bkList;
413  bkList.reserve( 20 );
414 // std::map<int,int>::const_iterator bktIter = bktMap.begin();
415 // std::map<int,int>::const_iterator bktIend = bktMap.end();
416  std::map<int,int>::const_iterator bktIter;
417  std::vector<int>::const_iterator bkiIter = brkPtr->begin();
418  std::vector<int>::const_iterator bkiIend = brkPtr->end();
419  while ( bkiIter != bkiIend ) {
420  int brickId = *bkiIter++;
421 // bktIter = bktMap.find( brickId );
422  // ----------- redundant check
423  if ( ( bktIter = bktMap.find( brickId ) ) == bktMap.end() ) continue;
424  if ( bktIter->second == cft ) bkList.push_back( brickId );
425  }
426  fullConf->appendConfigKey( chaId.wheelId,
427  chaId.stationId,
428  chaId.sectorId,
429  bkList );
430  }
431  }
432  cond::Time_t snc = runEntry.first;
433  m_to_transfer.push_back( std::make_pair( fullConf, snc ) );
434  std::cout << "writing payload : " << sizeof( *fullConf )
435  << " ( " << ( fullConf->end() - fullConf->begin() )
436  << " ) " << std::endl;
437  }
438 
439  isession->transaction().commit();
440 
441  return;
442 
443 }
444 
445 
447 
448  std::cout << "open POOL out db " << std::endl;
450 
451  std::cout << "start queries " << std::endl;
452  std::map<int,bool> activeConfigMap;
453  coral::ITable& fullConfigTable =
454  isession->nominalSchema().tableHandle( "CONFIGSETS" );
455  std::auto_ptr<coral::IQuery>
456  fullConfigQuery( fullConfigTable.newQuery() );
457  fullConfigQuery->addToOutputList( "CONFKEY" );
458  fullConfigQuery->addToOutputList( "NAME" );
459  fullConfigQuery->addToOutputList( "RUN" );
460  coral::ICursor& fullConfigCursor = fullConfigQuery->execute();
461  while( fullConfigCursor.next() ) {
462  const coral::AttributeList& row = fullConfigCursor.currentRow();
463  int fullConfigId = row["CONFKEY"].data<int>();
464  int fullConfigRN = row["RUN" ].data<int>();
465  if ( fullConfigRN ) activeConfigMap.insert(
466  std::pair<int,bool>( fullConfigId, true ) );
467  else activeConfigMap.insert(
468  std::pair<int,bool>( fullConfigId, false ) );
469  std::string fullConfigName = row["NAME"].data<std::string>();
470  }
471 
472 // std::cout << " =============== CCB config list" << std::endl;
473  std::map<int,bool> activeCCBCfgMap;
474  coral::ITable& fullCCBCfgTable =
475  isession->nominalSchema().tableHandle( "CCBRELATIONS" );
476  std::auto_ptr<coral::IQuery>
477  fullCCBCfgQuery( fullCCBCfgTable.newQuery() );
478  fullCCBCfgQuery->addToOutputList( "CONFKEY" );
479  fullCCBCfgQuery->addToOutputList( "CONFCCBKEY" );
480  coral::ICursor& fullCCBCfgCursor = fullCCBCfgQuery->execute();
481  while( fullCCBCfgCursor.next() ) {
482  const coral::AttributeList& row = fullCCBCfgCursor.currentRow();
483  int fullConfigId = row["CONFKEY" ].data<int>();
484  int fullCCBCfgId = row["CONFCCBKEY"].data<int>();
485 // std::map<int,bool>::const_iterator cfgIter =
486 // activeConfigMap.find( fullConfigId );
487  std::map<int,bool>::const_iterator cfgIter;
488  if ( ( cfgIter = activeConfigMap.find( fullConfigId ) )
489  == activeConfigMap.end() ) continue;
490  if ( !( cfgIter->second ) ) continue;
491  if ( activeCCBCfgMap.find( fullCCBCfgId ) ==
492  activeCCBCfgMap.end() )
493  activeCCBCfgMap.insert( std::pair<int,bool>( fullCCBCfgId, true ) );
494  }
495 
496 // std::cout << " =============== config brick list" << std::endl;
497  std::map<int,bool> activeCfgBrkMap;
498  coral::ITable& ccbConfBrkTable =
499  isession->nominalSchema().tableHandle( "CFG2BRKREL" );
500  std::auto_ptr<coral::IQuery>
501  ccbConfBrickQuery( ccbConfBrkTable.newQuery() );
502  ccbConfBrickQuery->addToOutputList( "CONFID" );
503  ccbConfBrickQuery->addToOutputList( "BRKID" );
504  coral::ICursor& ccbConfBrickCursor = ccbConfBrickQuery->execute();
505  while( ccbConfBrickCursor.next() ) {
506  const coral::AttributeList& row = ccbConfBrickCursor.currentRow();
507  int fullCCBCfgId = row["CONFID"].data<int>();
508  int ccbConfBrkId = row["BRKID" ].data<int>();
509 // std::map<int,bool>::const_iterator ccbIter =
510 // activeCCBCfgMap.find( fullCCBCfgId );
511  std::map<int,bool>::const_iterator ccbIter;
512  if ( ( ccbIter = activeCCBCfgMap.find( fullCCBCfgId ) )
513  == activeCCBCfgMap.end() ) continue;
514  if ( !( ccbIter->second ) ) continue;
515  if ( activeCfgBrkMap.find( ccbConfBrkId ) ==
516  activeCfgBrkMap.end() )
517  activeCfgBrkMap.insert( std::pair<int,bool>( ccbConfBrkId, true ) );
518  }
519 
520 // std::cout << " ===============" << std::endl;
521 
522  coral::ITable& brickConfigTable =
523  isession->nominalSchema().tableHandle( "CFGBRICKS" );
524  std::auto_ptr<coral::IQuery>
525  brickConfigQuery( brickConfigTable.newQuery() );
526  brickConfigQuery->addToOutputList( "BRKID" );
527  brickConfigQuery->addToOutputList( "BRKNAME" );
528  coral::ICursor& brickConfigCursor = brickConfigQuery->execute();
529  DTKeyedConfig* brickData = 0;
530  std::vector<int> missingList;
531  std::vector<unsigned long long> checkedKeys;
532  while( brickConfigCursor.next() ) {
533  const coral::AttributeList& row = brickConfigCursor.currentRow();
534  int brickConfigId = row["BRKID"].data<int>();
535  if ( brickConfigId < minBrickId ) continue;
536  if ( brickConfigId > maxBrickId ) continue;
537 // std::map<int,bool>::const_iterator brkIter =
538 // activeCfgBrkMap.find( brickConfigId );
539  std::map<int,bool>::const_iterator brkIter;
540  if ( ( brkIter = activeCfgBrkMap.find( brickConfigId ) )
541  == activeCfgBrkMap.end() ) continue;
542  if ( !( brkIter->second ) ) continue;
543  std::string brickConfigName = row["BRKNAME"].data<std::string>();
544  std::cout << "brick " << brickConfigId
545  << " : " << brickConfigName << std::endl;
546  checkedKeys.push_back( brickConfigId );
547  bool brickFound = false;
548  try {
549  keyList->load( checkedKeys );
550  boost::shared_ptr<DTKeyedConfig> brickCheck = keyList->get<DTKeyedConfig>( 0 );
551  if ( brickCheck.get() ) brickFound =
552  ( brickCheck->getId() == brickConfigId );
553  }
554  catch ( std::exception e ) {
555  }
556  if ( !brickFound ) {
557  std::cout << "brick " << brickConfigId << " missing, copy request"
558  << std::endl;
559  missingList.push_back( brickConfigId );
560  }
561  checkedKeys.clear();
562  }
563  keyList->load( checkedKeys );
564 
565  std::vector<int>::const_iterator brickIter = missingList.begin();
566  std::vector<int>::const_iterator brickIend = missingList.end();
567  while ( brickIter != brickIend ) {
568  int brickConfigId = *brickIter++;
569 // std::cout << "get data for brick: " << brickConfigId << std::endl;
570  coral::AttributeList bindVariableList;
571  bindVariableList.extend( "brickId", typeid(int) );
572  bindVariableList["brickId"].data<int>() = brickConfigId;
573  std::auto_ptr<coral::IQuery>
574  brickDataQuery( isession->nominalSchema().newQuery() );
575  brickDataQuery->addToTableList( "CFGRELATIONS" );
576  brickDataQuery->addToTableList( "CONFIGCMDS" );
578  brickCondition = "CONFIGCMDS.CMDID=CFGRELATIONS.CMDID";
579  brickCondition += " and CFGRELATIONS.BRKID=:brickId";
580  brickDataQuery->addToOutputList( "CFGRELATIONS.BRKID" );
581  brickDataQuery->addToOutputList( "CONFIGCMDS.CONFDATA" );
582  brickDataQuery->setCondition( brickCondition, bindVariableList );
583  coral::ICursor& brickDataCursor = brickDataQuery->execute();
584  brickData = new DTKeyedConfig();
585  brickData->setId( brickConfigId );
586  while( brickDataCursor.next() ) {
587  const coral::AttributeList& row = brickDataCursor.currentRow();
588  brickData->add( row["CONFIGCMDS.CONFDATA"].data<std::string>() );
589  }
590  cond::KeyedElement k( brickData, brickConfigId );
591  std::cout << "now writing brick: " << brickConfigId << std::endl;
592  outdb->writeOne( k.m_obj, k.m_key, brickContainer );
593  }
594 
595  return;
596 
597 }
598 
599 
601  return dataTag;
602 }
603 
604 
606  const std::vector<DTConfigKey>& cfgl,
607  const std::vector<DTConfigKey>& cfgr ) {
608  if ( cfgl.size() != cfgr.size() ) return false;
609  std::map<int,int> lmap;
610  std::vector<DTConfigKey>::const_iterator lIter = cfgl.begin();
611  std::vector<DTConfigKey>::const_iterator lIend = cfgl.end();
612  while ( lIter != lIend ) {
613  const DTConfigKey& entry = *lIter++;
614  lmap.insert( std::pair<int,int>( entry.confType, entry.confKey ) );
615  }
616  std::map<int,int> rmap;
617  std::vector<DTConfigKey>::const_iterator rIter = cfgr.begin();
618  std::vector<DTConfigKey>::const_iterator rIend = cfgr.end();
619  while ( rIter != rIend ) {
620  const DTConfigKey& entry = *rIter++;
621  rmap.insert( std::pair<int,int>( entry.confType, entry.confKey ) );
622  }
623  std::map<int,int>::const_iterator lmIter = lmap.begin();
624  std::map<int,int>::const_iterator lmIend = lmap.end();
625  std::map<int,int>::const_iterator rmIter = rmap.begin();
626  std::map<int,int>::const_iterator rmIend = rmap.end();
627  while ( ( lmIter != lmIend ) &&
628  ( rmIter != rmIend ) ) {
629  const std::pair<int,int>& lEntry = *lmIter++;
630  const std::pair<int,int>& rEntry = *rmIter++;
631  if ( lEntry.first != rEntry.first ) return false;
632  if ( lEntry.second != rEntry.second ) return false;
633  }
634  return true;
635 }
636 
637 
639  keyList = list;
640 }
641 
tuple cfg
Definition: looper.py:293
cond::persistency::ConnectionPool connection
int wheelId
Definition: DTCCBConfig.h:45
void setStamp(int s)
Definition: DTCCBConfig.cc:174
void add(const std::string &data)
boost::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
boost::shared_ptr< T > get(size_t n) const
Definition: KeyList.h:39
const_iterator end() const
Definition: DTCCBConfig.cc:291
int sectorId
Definition: DTCCBConfig.h:47
cond::ValidityInterval lastInterval
Definition: Types.h:73
static cond::persistency::KeyList * keyList
BaseKeyed * m_obj
Definition: KeyedElement.h:35
unsigned long long Time_t
Definition: Time.h:16
int stationId
Definition: DTCCBConfig.h:46
static void setList(cond::persistency::KeyList *list)
void setAuthenticationSystem(int authSysCode)
static bool sameConfigList(const std::vector< DTConfigKey > &cfgl, const std::vector< DTConfigKey > &cfgr)
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
boost::shared_ptr< coral::ISessionProxy > isession
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::string id() const
void setId(int id)
if(dp >Float(M_PI)) dp-
tuple cout
Definition: gather_cfg.py:145
void setFullKey(const std::vector< DTConfigKey > &)
Definition: DTCCBConfig.cc:169
void load(const std::vector< unsigned long long > &keys)
Definition: KeyList.cc:14
DTKeyedConfigHandler(const edm::ParameterSet &ps)
const_iterator begin() const
Definition: DTCCBConfig.cc:286
void setAuthenticationPath(const std::string &p)
cond::Time_t m_key
Definition: KeyedElement.h:37
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:238
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
cond::TagInfo_t const & tagInfo() const