CMS 3D CMS Logo

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