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 convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
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 ()
 
void sort ()
 
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 = 0
 
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::vector< Triplet > Container
 
typedef std::vector< std::pair< DTCCBConfig *, cond::Time_t > > OldContainer
 
typedef PopConSourceHandler< DTCCBConfigself
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef DTCCBConfig value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< DTCCBConfig >
int add (value_type *payload, Summary *summary, Time_t time)
 
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< DTCCBConfig >
OldContainer 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 ( 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
T getUntrackedParameter(std::string const &, T const &) const
cond::persistency::ConnectionPool connection
std::shared_ptr< coral::ISessionProxy > isession
DTKeyedConfigHandler::~DTKeyedConfigHandler ( )
override

Destructor

Definition at line 67 of file DTKeyedConfigHandler.cc.

67 {}

Member Function Documentation

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, cond::KeyedElement::m_key, cond::KeyedElement::m_obj, maxBrickId, minBrickId, DTKeyedConfig::setId(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::service::PoolDBOutputService::writeOne().

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  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 }
void add(const std::string &data)
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
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
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(), isession, crabWrapper::key, dqmdumpme::last, cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< DTCCBConfig >::lastPayload(), SiStripBadComponentsDQMServiceTemplate_cfg::lastRun, popcon::PopConSourceHandler< DTCCBConfig >::m_to_transfer, maxRunId, minRunId, onlineAuthentication, onlineAuthSys, onlineConnect, jets_cff::payload, writedatasetfile::run, sameConfigList(), DTCCBId::sectorId, cond::persistency::ConnectionPool::setAuthenticationPath(), cond::persistency::ConnectionPool::setAuthenticationSystem(), DTCCBConfig::setFullKey(), DTCCBConfig::setStamp(), 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 const& ti = tagInfo();
75  unsigned int last = ti.lastInterval.first;
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
void setStamp(int s)
Definition: DTCCBConfig.cc:119
const_iterator end() const
Definition: DTCCBConfig.cc:205
int sectorId
Definition: DTCCBConfig.h:44
cond::ValidityInterval lastInterval
Definition: Types.h:74
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::shared_ptr< coral::ISessionProxy > isession
void setFullKey(const std::vector< DTConfigKey > &)
Definition: DTCCBConfig.cc:117
const_iterator begin() const
Definition: DTCCBConfig.cc:203
void setAuthenticationPath(const std::string &p)
std::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:166
cond::TagInfo_t const & tagInfo() const
std::string DTKeyedConfigHandler::id ( ) const
overridevirtual

Implements popcon::PopConSourceHandler< DTCCBConfig >.

Definition at line 571 of file DTKeyedConfigHandler.cc.

References dataTag.

571 { return dataTag; }
bool DTKeyedConfigHandler::sameConfigList ( const std::vector< DTConfigKey > &  cfgl,
const std::vector< DTConfigKey > &  cfgr 
)
staticprivate

Definition at line 573 of file DTKeyedConfigHandler.cc.

References DTConfigKey::confKey, DTConfigKey::confType, and mps_splice::entry.

Referenced by getNewObjects().

573  {
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 }
void DTKeyedConfigHandler::setList ( const cond::persistency::KeyList list)

Definition at line 605 of file DTKeyedConfigHandler.cc.

References keyList, and list().

Referenced by DTKeyedConfigPopConAnalyzer::analyze().

605 { keyList = list; }
const cond::persistency::KeyList * keyList
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

Member Data Documentation

std::string DTKeyedConfigHandler::brickContainer
private

Definition at line 75 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

DTCCBConfig* DTKeyedConfigHandler::ccbConfig
private

Definition at line 76 of file DTKeyedConfigHandler.h.

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

Definition at line 78 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

bool DTKeyedConfigHandler::copyData
private

Definition at line 65 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

std::string DTKeyedConfigHandler::dataTag
private

Definition at line 71 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects(), and id().

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

Definition at line 79 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList(), and getNewObjects().

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

Definition at line 83 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList(), and setList().

int DTKeyedConfigHandler::maxBrickId
private

Definition at line 67 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

int DTKeyedConfigHandler::maxRunId
private

Definition at line 69 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

int DTKeyedConfigHandler::minBrickId
private

Definition at line 66 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

int DTKeyedConfigHandler::minRunId
private

Definition at line 68 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

std::string DTKeyedConfigHandler::onlineAuthentication
private

Definition at line 73 of file DTKeyedConfigHandler.h.

Referenced by DTKeyedConfigHandler(), and getNewObjects().

int DTKeyedConfigHandler::onlineAuthSys
private

Definition at line 74 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

std::string DTKeyedConfigHandler::onlineConnect
private

Definition at line 72 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().