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