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" 49 : dataRun(ps.getParameter<
int>(
"run")),
51 onlineConnect(ps.getParameter<
std::
string>(
"onlineDB")),
53 onlineAuthSys(ps.getUntrackedParameter<
int>(
"onlineAuthSys", 1)),
54 brickContainer(ps.getParameter<
std::
string>(
"container")),
55 writeKeys(ps.getParameter<
bool>(
"writeKeys")),
56 writeData(ps.getParameter<
bool>(
"writeData")),
61 std::vector<edm::ParameterSet> dtConfigKeys(ps.
getParameter<std::vector<edm::ParameterSet> >(
"DTConfigKeys"));
62 std::vector<edm::ParameterSet>::const_iterator iter = dtConfigKeys.begin();
63 std::vector<edm::ParameterSet>::const_iterator iend = dtConfigKeys.end();
64 while (iter != iend) {
68 std::cout <<
"config: " << configType <<
" -> " << configKey << std::endl;
88 std::cout <<
"last configuration key already copied for run: " << last << std::endl;
90 std::vector<DTConfigKey> lastKey;
100 std::cout <<
"get last payload" << std::endl;
102 std::cout <<
"get last full key" << std::endl;
103 lastKey = payload->fullKey();
105 std::vector<DTConfigKey>::const_iterator keyIter = lastKey.begin();
106 std::vector<DTConfigKey>::const_iterator keyIend = lastKey.end();
107 while (keyIter != keyIend) {
113 std::cout <<
"configure DbConnection" << std::endl;
118 std::cout <<
"create/open DbSession" << std::endl;
120 std::cout <<
"start transaction" << std::endl;
121 isession->transaction().start(
true);
124 std::cout <<
"retrieve CCB map" << std::endl;
125 std::map<int, DTCCBId> ccbMap;
126 coral::ITable& ccbMapTable =
isession->nominalSchema().tableHandle(
"CCBMAP");
127 std::unique_ptr<coral::IQuery> ccbMapQuery(ccbMapTable.newQuery());
128 ccbMapQuery->addToOutputList(
"CCBID");
129 ccbMapQuery->addToOutputList(
"WHEEL");
130 ccbMapQuery->addToOutputList(
"SECTOR");
131 ccbMapQuery->addToOutputList(
"STATION");
132 coral::ICursor& ccbMapCursor = ccbMapQuery->execute();
133 while (ccbMapCursor.next()) {
134 const coral::AttributeList& row = ccbMapCursor.currentRow();
135 int ccb = row[
"CCBID"].data<
int>();
136 int wheel = row[
"WHEEL"].data<
int>();
137 int sector = row[
"SECTOR"].data<
int>();
138 int station = row[
"STATION"].data<
int>();
142 ccbId.sectorId = sector;
143 ccbMap.insert(std::pair<int, DTCCBId>(ccb, ccbId));
147 std::cout <<
"retrieve brick types" << std::endl;
148 std::map<int, int> bktMap;
149 coral::AttributeList emptyBindVariableList;
150 std::unique_ptr<coral::IQuery> brickTypeQuery(
isession->nominalSchema().newQuery());
151 brickTypeQuery->addToTableList(
"CFGBRICKS");
152 brickTypeQuery->addToTableList(
"BRKT2CSETT");
153 std::string bTypeCondition =
"CFGBRICKS.BRKTYPE=BRKT2CSETT.BRKTYPE";
154 brickTypeQuery->addToOutputList(
"CFGBRICKS.BRKID");
155 brickTypeQuery->addToOutputList(
"BRKT2CSETT.CSETTYPE");
156 brickTypeQuery->setCondition(bTypeCondition, emptyBindVariableList);
157 coral::ICursor& brickTypeCursor = brickTypeQuery->execute();
158 while (brickTypeCursor.next()) {
159 const coral::AttributeList& row = brickTypeCursor.currentRow();
160 int id = row[
"CFGBRICKS.BRKID"].data<
int>();
161 int bt = row[
"BRKT2CSETT.CSETTYPE"].data<
short>();
165 bktMap.insert(std::pair<int, int>(
id, bt));
169 std::cout <<
"retrieve CCB configuration keys" << std::endl;
170 std::map<int, std::map<int, int>*> keyMap;
171 std::map<int, int> cckMap;
172 coral::ITable& ccbRelTable =
isession->nominalSchema().tableHandle(
"CCBRELATIONS");
173 std::unique_ptr<coral::IQuery> ccbRelQuery(ccbRelTable.newQuery());
174 ccbRelQuery->addToOutputList(
"CONFKEY");
175 ccbRelQuery->addToOutputList(
"CCBID");
176 ccbRelQuery->addToOutputList(
"CONFCCBKEY");
177 coral::ICursor& ccbRelCursor = ccbRelQuery->execute();
179 while (ccbRelCursor.next()) {
180 const coral::AttributeList& row = ccbRelCursor.currentRow();
181 int cfg = row[
"CONFKEY"].data<
int>();
182 int ccb = row[
"CCBID"].data<
int>();
183 int key = row[
"CONFCCBKEY"].data<
int>();
188 std::map<int, std::map<int, int>*>::const_iterator keyIter = keyMap.find(cfg);
189 std::map<int, std::map<int, int>*>::const_iterator keyIend = keyMap.end();
190 std::map<int, int>* mapPtr =
nullptr;
192 if (keyIter != keyIend)
193 mapPtr = keyIter->second;
195 keyMap.insert(std::pair<
int, std::map<int, int>*>(cfg, mapPtr =
new std::map<int, int>));
197 std::map<int, int>& mapRef(*mapPtr);
198 mapRef.insert(std::pair<int, int>(ccb, key));
200 if (cckMap.find(key) == cckMap.end())
201 cckMap.insert(std::pair<int, int>(key, ccb));
205 std::cout <<
"retrieve CCB configuration bricks" << std::endl;
206 std::map<int, std::vector<int>*> brkMap;
207 coral::ITable& confBrickTable =
isession->nominalSchema().tableHandle(
"CFG2BRKREL");
208 std::unique_ptr<coral::IQuery> confBrickQuery(confBrickTable.newQuery());
209 confBrickQuery->addToOutputList(
"CONFID");
210 confBrickQuery->addToOutputList(
"BRKID");
211 coral::ICursor& confBrickCursor = confBrickQuery->execute();
213 while (confBrickCursor.next()) {
214 const coral::AttributeList& row = confBrickCursor.currentRow();
215 int key = row[
"CONFID"].data<
int>();
216 int brk = row[
"BRKID"].data<
int>();
218 if (cckMap.find(key) == cckMap.end())
220 std::map<int, std::vector<int>*>::const_iterator brkIter = brkMap.find(key);
221 std::map<int, std::vector<int>*>::const_iterator brkIend = brkMap.end();
223 std::vector<int>* brkPtr =
nullptr;
224 if (brkIter != brkIend)
225 brkPtr = brkIter->second;
227 brkMap.insert(std::pair<
int, std::vector<int>*>(key, brkPtr =
new std::vector<int>));
229 brkPtr->push_back(brk);
236 std::map<int, bool> userBricks;
237 std::map<int, bool>::const_iterator uBrkIter = userBricks.begin();
238 std::map<int, bool>::const_iterator uBrkIend = userBricks.end();
239 std::vector<DTConfigKey>::const_iterator cfgIter =
userConf.begin();
240 std::vector<DTConfigKey>::const_iterator cfgIend =
userConf.end();
241 while (cfgIter != cfgIend) {
246 std::map<int, std::map<int, int>*>::const_iterator keyIter = keyMap.find(cfg);
247 std::map<int, std::map<int, int>*>::const_iterator keyIend = keyMap.end();
248 std::map<int, int>* mapPtr =
nullptr;
249 if (keyIter != keyIend)
250 mapPtr = keyIter->second;
251 if (mapPtr ==
nullptr)
253 std::map<int, int>::const_iterator ccbIter = mapPtr->begin();
254 std::map<int, int>::const_iterator ccbIend = mapPtr->end();
255 while (ccbIter != ccbIend) {
256 const std::pair<int, int>& ccbEntry = *ccbIter++;
258 int ccb = ccbEntry.first;
259 int key = ccbEntry.second;
261 std::map<int, DTCCBId>::const_iterator ccbIter = ccbMap.find(ccb);
262 std::map<int, DTCCBId>::const_iterator ccbIend = ccbMap.end();
263 if (ccbIter == ccbIend)
265 const DTCCBId& chaId = ccbIter->second;
267 std::map<int, std::vector<int>*>::const_iterator brkIter = brkMap.find(key);
268 std::map<int, std::vector<int>*>::const_iterator brkIend = brkMap.end();
269 if (brkIter == brkIend)
271 std::vector<int>* brkPtr = brkIter->second;
272 if (brkPtr ==
nullptr)
275 std::vector<int> bkList;
277 std::map<int, int>::const_iterator bktIter = bktMap.begin();
278 std::map<int, int>::const_iterator bktIend = bktMap.end();
279 std::vector<int>::const_iterator bkiIter = brkPtr->begin();
280 std::vector<int>::const_iterator bkiIend = brkPtr->end();
281 while (bkiIter != bkiIend) {
282 int brickId = *bkiIter++;
283 bktIter = bktMap.find(brickId);
284 if (bktIter == bktIend)
286 if (bktIter->second == cft) {
287 bkList.push_back(brickId);
288 uBrkIter = userBricks.find(brickId);
289 if (uBrkIter == uBrkIend)
290 userBricks.insert(std::pair<int, bool>(brickId,
true));
299 std::cout <<
"writing payload : " <<
sizeof(*fullConf) <<
" ( " << (fullConf->
end() - fullConf->
begin()) <<
" ) " 310 std::cout <<
"open POOL out db " << std::endl;
313 std::map<int, bool>::const_iterator uBrkIter = userBricks.begin();
314 std::map<int, bool>::const_iterator uBrkIend = userBricks.end();
316 coral::ITable& brickConfigTable =
isession->nominalSchema().tableHandle(
"CFGBRICKS");
317 std::unique_ptr<coral::IQuery> brickConfigQuery(brickConfigTable.newQuery());
318 brickConfigQuery->addToOutputList(
"BRKID");
319 brickConfigQuery->addToOutputList(
"BRKNAME");
320 coral::ICursor& brickConfigCursor = brickConfigQuery->execute();
322 std::vector<int> missingList;
323 std::vector<unsigned long long> checkedKeys;
324 while (brickConfigCursor.next()) {
325 const coral::AttributeList& row = brickConfigCursor.currentRow();
326 int brickConfigId = row[
"BRKID"].data<
int>();
327 uBrkIter = userBricks.find(brickConfigId);
328 if (uBrkIter == uBrkIend)
330 if (!(uBrkIter->second))
333 std::cout <<
"brick " << brickConfigId <<
" : " << brickConfigName << std::endl;
334 bool brickFound =
false;
336 std::cout <<
"load brick " << brickConfigId << std::endl;
338 std::cout <<
"get brick..." << std::endl;
340 if (brickCheck.get()) {
341 brickFound = (brickCheck->getId() == brickConfigId);
346 std::cout <<
"brick " << brickConfigId <<
" missing, copy request" << std::endl;
347 missingList.push_back(brickConfigId);
351 std::vector<int>::const_iterator brickIter = missingList.begin();
352 std::vector<int>::const_iterator brickIend = missingList.end();
353 while (brickIter != brickIend) {
354 int brickConfigId = *brickIter++;
355 coral::AttributeList bindVariableList;
356 bindVariableList.extend(
"brickId",
typeid(
int));
357 bindVariableList[
"brickId"].data<
int>() = brickConfigId;
358 std::unique_ptr<coral::IQuery> brickDataQuery(
isession->nominalSchema().newQuery());
359 brickDataQuery->addToTableList(
"CFGRELATIONS");
360 brickDataQuery->addToTableList(
"CONFIGCMDS");
361 std::string brickCondition =
"CONFIGCMDS.CMDID=CFGRELATIONS.CMDID";
362 brickCondition +=
" and CFGRELATIONS.BRKID=:brickId";
363 brickDataQuery->addToOutputList(
"CFGRELATIONS.BRKID");
364 brickDataQuery->addToOutputList(
"CONFIGCMDS.CONFDATA");
365 brickDataQuery->setCondition(brickCondition, bindVariableList);
366 coral::ICursor& brickDataCursor = brickDataQuery->execute();
368 brickData->
setId(brickConfigId);
369 while (brickDataCursor.next()) {
370 const coral::AttributeList& row = brickDataCursor.currentRow();
371 brickData->
add(row[
"CONFIGCMDS.CONFDATA"].data<std::string>());
374 std::cout <<
"now writing brick: " << brickConfigId << std::endl;
384 const std::vector<DTConfigKey>& cfgr) {
385 if (cfgl.size() != cfgr.size())
387 std::map<int, int> lmap;
388 std::vector<DTConfigKey>::const_iterator lIter = cfgl.begin();
389 std::vector<DTConfigKey>::const_iterator lIend = cfgl.end();
390 while (lIter != lIend) {
394 std::map<int, int> rmap;
395 std::vector<DTConfigKey>::const_iterator rIter = cfgr.begin();
396 std::vector<DTConfigKey>::const_iterator rIend = cfgr.end();
397 while (rIter != rIend) {
401 std::map<int, int>::const_iterator lmIter = lmap.begin();
402 std::map<int, int>::const_iterator lmIend = lmap.end();
403 std::map<int, int>::const_iterator rmIter = rmap.begin();
404 std::map<int, int>::const_iterator rmIend = rmap.end();
405 while ((lmIter != lmIend) && (rmIter != rmIend)) {
406 const std::pair<int, int>& lEntry = *lmIter++;
407 const std::pair<int, int>& rEntry = *rmIter++;
408 if (lEntry.first != rEntry.first)
410 if (lEntry.second != rEntry.second)
417 std::vector<DTConfigKey>::const_iterator iter =
userConf.begin();
418 std::vector<DTConfigKey>::const_iterator iend =
userConf.end();
419 while (iter != iend) {
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::Ref< Container > Ref
std::string brickContainer
void add(const std::string &data)
const cond::persistency::KeyList * keyList
std::vector< DTConfigKey > userConf
std::string onlineConnect
static bool sameConfigList(const std::vector< DTConfigKey > &cfgl, const std::vector< DTConfigKey > &cfgr)
std::string onlineAuthentication
const_iterator end() const
OldContainer m_to_transfer
cond::ValidityInterval lastInterval
void setList(const cond::persistency::KeyList *list)
unsigned long long Time_t
void setAuthenticationSystem(int authSysCode)
~DTUserKeyedConfigHandler() override
bool userDiscardedKey(int key)
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
std::string id() const override
DTUserKeyedConfigHandler(const edm::ParameterSet &ps)
void chkConfigList(const std::map< int, bool > &userBricks)
std::shared_ptr< coral::ISessionProxy > isession
std::shared_ptr< T > getUsingKey(unsigned long long key) const
void setFullKey(const std::vector< DTConfigKey > &)
cond::persistency::ConnectionPool connection
const_iterator begin() const
void setAuthenticationPath(const std::string &p)
std::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
void getNewObjects() override
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
cond::TagInfo_t const & tagInfo() const