CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
DTKeyedConfigHandler Class Reference

#include <DTKeyedConfigHandler.h>

Inheritance diagram for DTKeyedConfigHandler:
popcon::PopConSourceHandler< DTCCBConfig >

Public Member Functions

 DTKeyedConfigHandler (const edm::ParameterSet &ps)
 
void getNewObjects () override
 
std::string id () const override
 
void setList (const cond::persistency::KeyList *list)
 
 ~DTKeyedConfigHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< DTCCBConfig >
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const *, std::string const > operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Private Member Functions

void chkConfigList ()
 

Static Private Member Functions

static bool sameConfigList (const std::vector< DTConfigKey > &cfgl, const std::vector< DTConfigKey > &cfgr)
 

Private Attributes

std::string brickContainer
 
DTCCBConfigccbConfig
 
cond::persistency::ConnectionPool connection
 
bool copyData
 
std::string dataTag
 
std::shared_ptr< coral::ISessionProxy > isession
 
const cond::persistency::KeyListkeyList = nullptr
 
int maxBrickId
 
int maxRunId
 
int minBrickId
 
int minRunId
 
std::string onlineAuthentication
 
int onlineAuthSys
 
std::string onlineConnect
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< DTCCBConfig >
typedef std::map< Time_t, std::shared_ptr< DTCCBConfig > > Container
 
typedef std::unique_ptr< DTCCBConfigRef
 
typedef PopConSourceHandler< DTCCBConfigself
 
typedef cond::Time_t Time_t
 
typedef DTCCBConfig value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< DTCCBConfig >
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< DTCCBConfig >
Container m_iovs
 
std::vector< std::pair< DTCCBConfig *, Time_t > > m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Description:

Date
2010/05/14 11:43:08
Revision
1.2
Author
Paolo Ronchese INFN Padova

Definition at line 46 of file DTKeyedConfigHandler.h.

Constructor & Destructor Documentation

◆ DTKeyedConfigHandler()

DTKeyedConfigHandler::DTKeyedConfigHandler ( const edm::ParameterSet ps)

Constructor

Definition at line 48 of file DTKeyedConfigHandler.cc.

References gather_cfg::cout, and onlineAuthentication.

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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
cond::persistency::ConnectionPool connection
T getUntrackedParameter(std::string const &, T const &) const
std::shared_ptr< coral::ISessionProxy > isession

◆ ~DTKeyedConfigHandler()

DTKeyedConfigHandler::~DTKeyedConfigHandler ( )
override

Destructor

Definition at line 67 of file DTKeyedConfigHandler.cc.

67 {}

Member Function Documentation

◆ chkConfigList()

void DTKeyedConfigHandler::chkConfigList ( )
private

Definition at line 435 of file DTKeyedConfigHandler.cc.

References DTKeyedConfig::add(), brickContainer, gather_cfg::cout, cppFunctionSkipper::exception, cond::persistency::KeyList::getUsingKey(), isession, dqmdumpme::k, keyList, maxBrickId, minBrickId, DTKeyedConfig::setId(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::service::PoolDBOutputService::writeOneIOV().

Referenced by getNewObjects().

435  {
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  std::vector<int> missingList;
510  while (brickConfigCursor.next()) {
511  const coral::AttributeList& row = brickConfigCursor.currentRow();
512  int brickConfigId = row["BRKID"].data<int>();
513  if (brickConfigId < minBrickId)
514  continue;
515  if (brickConfigId > maxBrickId)
516  continue;
517  // std::map<int,bool>::const_iterator brkIter =
518  // activeCfgBrkMap.find( brickConfigId );
519  std::map<int, bool>::const_iterator brkIter;
520  if ((brkIter = activeCfgBrkMap.find(brickConfigId)) == activeCfgBrkMap.end())
521  continue;
522  if (!(brkIter->second))
523  continue;
524  std::string brickConfigName = row["BRKNAME"].data<std::string>();
525  std::cout << "brick " << brickConfigId << " : " << brickConfigName << std::endl;
526  bool brickFound = false;
527  try {
528  std::shared_ptr<DTKeyedConfig> brickCheck = keyList->getUsingKey<DTKeyedConfig>(brickConfigId);
529  if (brickCheck.get())
530  brickFound = (brickCheck->getId() == brickConfigId);
531  } catch (std::exception const&) {
532  }
533  if (!brickFound) {
534  std::cout << "brick " << brickConfigId << " missing, copy request" << std::endl;
535  missingList.push_back(brickConfigId);
536  }
537  }
538 
539  std::vector<int>::const_iterator brickIter = missingList.begin();
540  std::vector<int>::const_iterator brickIend = missingList.end();
541  while (brickIter != brickIend) {
542  int brickConfigId = *brickIter++;
543  // std::cout << "get data for brick: " << brickConfigId << std::endl;
544  coral::AttributeList bindVariableList;
545  bindVariableList.extend("brickId", typeid(int));
546  bindVariableList["brickId"].data<int>() = brickConfigId;
547  std::unique_ptr<coral::IQuery> brickDataQuery(isession->nominalSchema().newQuery());
548  brickDataQuery->addToTableList("CFGRELATIONS");
549  brickDataQuery->addToTableList("CONFIGCMDS");
550  std::string brickCondition = "CONFIGCMDS.CMDID=CFGRELATIONS.CMDID";
551  brickCondition += " and CFGRELATIONS.BRKID=:brickId";
552  brickDataQuery->addToOutputList("CFGRELATIONS.BRKID");
553  brickDataQuery->addToOutputList("CONFIGCMDS.CONFDATA");
554  brickDataQuery->setCondition(brickCondition, bindVariableList);
555  coral::ICursor& brickDataCursor = brickDataQuery->execute();
556  DTKeyedConfig brickData;
557  brickData.setId(brickConfigId);
558  while (brickDataCursor.next()) {
559  const coral::AttributeList& row = brickDataCursor.currentRow();
560  brickData.add(row["CONFIGCMDS.CONFDATA"].data<std::string>());
561  }
562  cond::KeyedElement k(&brickData, brickConfigId);
563  std::cout << "now writing brick: " << brickConfigId << std::endl;
564  outdb->writeOneIOV(*(k.m_obj), k.m_key, brickContainer);
565  }
566 
567  return;
568 }
void add(const std::string &data)
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
std::shared_ptr< coral::ISessionProxy > isession
void setId(int id)
std::shared_ptr< T > getUsingKey(unsigned long long key) const
Definition: KeyList.h:57
const cond::persistency::KeyList * keyList

◆ getNewObjects()

void DTKeyedConfigHandler::getNewObjects ( )
overridevirtual

Operations

Implements popcon::PopConSourceHandler< DTCCBConfig >.

Definition at line 72 of file DTKeyedConfigHandler.cc.

References DTCCBConfig::appendConfigKey(), DTCCBConfig::begin(), looper::cfg, chkConfigList(), cond::persistency::ConnectionPool::configure(), DTConfigKey::confKey, DTConfigKey::confType, connection, copyData, gather_cfg::cout, cond::persistency::ConnectionPool::createCoralSession(), dataTag, DTCCBConfig::end(), ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), isession, submitPVResolutionJobs::key, dqmdumpme::last, cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< DTCCBConfig >::lastPayload(), beamSpotPI::lastRun, popcon::PopConSourceHandler< DTCCBConfig >::m_to_transfer, maxRunId, minRunId, onlineAuthentication, onlineAuthSys, onlineConnect, jetsAK4_Puppi_cff::payload, writedatasetfile::run, sameConfigList(), nano_mu_digi_cff::sector, DTCCBId::sectorId, cond::persistency::ConnectionPool::setAuthenticationPath(), cond::persistency::ConnectionPool::setAuthenticationSystem(), DTCCBConfig::setFullKey(), DTCCBConfig::setStamp(), cond::Iov_t::since, relativeConstraints::station, DTCCBId::stationId, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< DTCCBConfig >::tagInfo(), makeMuonMisalignmentScenario::wheel, and DTCCBId::wheelId.

72  {
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 }
cond::persistency::ConnectionPool connection
int wheelId
Definition: DTCCBConfig.h:42
Iov_t lastInterval
Definition: Types.h:73
void setStamp(int s)
Definition: DTCCBConfig.cc:121
Time_t since
Definition: Types.h:53
int sectorId
Definition: DTCCBConfig.h:44
cond::TagInfo_t const & tagInfo() const
unsigned long long Time_t
Definition: Time.h:14
int stationId
Definition: DTCCBConfig.h:43
void setAuthenticationSystem(int authSysCode)
static bool sameConfigList(const std::vector< DTConfigKey > &cfgl, const std::vector< DTConfigKey > &cfgr)
std::vector< std::pair< DTCCBConfig *, Time_t > > m_to_transfer
key
prepare the HTCondor submission files and eventually submit them
std::shared_ptr< coral::ISessionProxy > isession
const_iterator end() const
Definition: DTCCBConfig.cc:207
const_iterator begin() const
Definition: DTCCBConfig.cc:205
void setFullKey(const std::vector< DTConfigKey > &)
Definition: DTCCBConfig.cc:119
void setAuthenticationPath(const std::string &p)
std::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:168

◆ id()

std::string DTKeyedConfigHandler::id ( ) const
overridevirtual

Implements popcon::PopConSourceHandler< DTCCBConfig >.

Definition at line 570 of file DTKeyedConfigHandler.cc.

References dataTag.

570 { return dataTag; }

◆ sameConfigList()

bool DTKeyedConfigHandler::sameConfigList ( const std::vector< DTConfigKey > &  cfgl,
const std::vector< DTConfigKey > &  cfgr 
)
staticprivate

Definition at line 572 of file DTKeyedConfigHandler.cc.

References mps_splice::entry.

Referenced by getNewObjects().

572  {
573  if (cfgl.size() != cfgr.size())
574  return false;
575  std::map<int, int> lmap;
576  std::vector<DTConfigKey>::const_iterator lIter = cfgl.begin();
577  std::vector<DTConfigKey>::const_iterator lIend = cfgl.end();
578  while (lIter != lIend) {
579  const DTConfigKey& entry = *lIter++;
580  lmap.insert(std::pair<int, int>(entry.confType, entry.confKey));
581  }
582  std::map<int, int> rmap;
583  std::vector<DTConfigKey>::const_iterator rIter = cfgr.begin();
584  std::vector<DTConfigKey>::const_iterator rIend = cfgr.end();
585  while (rIter != rIend) {
586  const DTConfigKey& entry = *rIter++;
587  rmap.insert(std::pair<int, int>(entry.confType, entry.confKey));
588  }
589  std::map<int, int>::const_iterator lmIter = lmap.begin();
590  std::map<int, int>::const_iterator lmIend = lmap.end();
591  std::map<int, int>::const_iterator rmIter = rmap.begin();
592  std::map<int, int>::const_iterator rmIend = rmap.end();
593  while ((lmIter != lmIend) && (rmIter != rmIend)) {
594  const std::pair<int, int>& lEntry = *lmIter++;
595  const std::pair<int, int>& rEntry = *rmIter++;
596  if (lEntry.first != rEntry.first)
597  return false;
598  if (lEntry.second != rEntry.second)
599  return false;
600  }
601  return true;
602 }

◆ setList()

void DTKeyedConfigHandler::setList ( const cond::persistency::KeyList list)

Definition at line 604 of file DTKeyedConfigHandler.cc.

References keyList.

Referenced by DTKeyedConfigPopConAnalyzer::analyze().

604 { keyList = list; }
const cond::persistency::KeyList * keyList

Member Data Documentation

◆ brickContainer

std::string DTKeyedConfigHandler::brickContainer
private

Definition at line 75 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

◆ ccbConfig

DTCCBConfig* DTKeyedConfigHandler::ccbConfig
private

Definition at line 76 of file DTKeyedConfigHandler.h.

◆ connection

cond::persistency::ConnectionPool DTKeyedConfigHandler::connection
private

Definition at line 78 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

◆ copyData

bool DTKeyedConfigHandler::copyData
private

Definition at line 65 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

◆ dataTag

std::string DTKeyedConfigHandler::dataTag
private

Definition at line 71 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects(), and id().

◆ isession

std::shared_ptr<coral::ISessionProxy> DTKeyedConfigHandler::isession
private

Definition at line 79 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList(), and getNewObjects().

◆ keyList

const cond::persistency::KeyList* DTKeyedConfigHandler::keyList = nullptr
private

Definition at line 83 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList(), and setList().

◆ maxBrickId

int DTKeyedConfigHandler::maxBrickId
private

Definition at line 67 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

◆ maxRunId

int DTKeyedConfigHandler::maxRunId
private

Definition at line 69 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

◆ minBrickId

int DTKeyedConfigHandler::minBrickId
private

Definition at line 66 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

◆ minRunId

int DTKeyedConfigHandler::minRunId
private

Definition at line 68 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

◆ onlineAuthentication

std::string DTKeyedConfigHandler::onlineAuthentication
private

Definition at line 73 of file DTKeyedConfigHandler.h.

Referenced by DTKeyedConfigHandler(), and getNewObjects().

◆ onlineAuthSys

int DTKeyedConfigHandler::onlineAuthSys
private

Definition at line 74 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

◆ onlineConnect

std::string DTKeyedConfigHandler::onlineConnect
private

Definition at line 72 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().