25 #include "RelationalAccess/ISessionProxy.h" 26 #include "RelationalAccess/ITransaction.h" 27 #include "RelationalAccess/ISchema.h" 28 #include "RelationalAccess/ITable.h" 29 #include "RelationalAccess/ICursor.h" 30 #include "RelationalAccess/IQuery.h" 31 #include "CoralBase/AttributeList.h" 32 #include "CoralBase/AttributeSpecification.h" 33 #include "CoralBase/Attribute.h" 51 dataRun( ps.getParameter<
int> (
"run" ) ),
52 dataTag( ps.getParameter<
std::
string> (
"tag" ) ),
53 onlineConnect( ps.getParameter<
std::
string> (
"onlineDB" ) ),
54 onlineAuthentication( ps.getParameter<
std::
string> (
55 "onlineAuthentication" ) ),
56 onlineAuthSys( ps.getUntrackedParameter<
int>(
"onlineAuthSys",1 ) ),
57 brickContainer( ps.getParameter<
std::
string> (
"container" ) ),
58 writeKeys( ps.getParameter<
bool> (
"writeKeys" ) ),
59 writeData( ps.getParameter<
bool> (
"writeData" ) ),
62 std::cout <<
" PopCon application for DT configuration export " 65 std::vector<edm::ParameterSet> dtConfigKeys (
66 ps.
getParameter< std::vector<edm::ParameterSet> >(
"DTConfigKeys" )
68 std::vector<edm::ParameterSet>::const_iterator iter = dtConfigKeys.begin();
69 std::vector<edm::ParameterSet>::const_iterator iend = dtConfigKeys.end();
70 while ( iter != iend ) {
75 << configType <<
" -> " 76 << configKey << std::endl;
98 std::cout <<
"last configuration key already copied for run: " 101 std::vector<DTConfigKey> lastKey;
112 std::cout <<
"get last payload" << std::endl;
114 std::cout <<
"get last full key" << std::endl;
115 lastKey = payload->fullKey();
117 std::vector<DTConfigKey>::const_iterator keyIter = lastKey.begin();
118 std::vector<DTConfigKey>::const_iterator keyIend = lastKey.end();
119 while ( keyIter != keyIend ) {
125 std::cout <<
"configure DbConnection" << std::endl;
130 std::cout <<
"create/open DbSession" << std::endl;
132 std::cout <<
"start transaction" << std::endl;
133 isession->transaction().start(
true );
136 std::cout <<
"retrieve CCB map" << std::endl;
137 std::map<int,DTCCBId> ccbMap;
138 coral::ITable& ccbMapTable =
139 isession->nominalSchema().tableHandle(
"CCBMAP" );
140 std::unique_ptr<coral::IQuery>
141 ccbMapQuery( ccbMapTable.newQuery() );
142 ccbMapQuery->addToOutputList(
"CCBID" );
143 ccbMapQuery->addToOutputList(
"WHEEL" );
144 ccbMapQuery->addToOutputList(
"SECTOR" );
145 ccbMapQuery->addToOutputList(
"STATION" );
146 coral::ICursor& ccbMapCursor = ccbMapQuery->execute();
147 while( ccbMapCursor.next() ) {
148 const coral::AttributeList& row = ccbMapCursor.currentRow();
149 int ccb = row[
"CCBID" ].data<
int>();
150 int wheel = row[
"WHEEL" ].data<
int>();
151 int sector = row[
"SECTOR" ].data<
int>();
152 int station = row[
"STATION"].data<
int>();
154 ccbId. wheelId =
wheel;
156 ccbId. sectorId = sector;
157 ccbMap.insert( std::pair<int,DTCCBId>( ccb, ccbId ) );
161 std::cout <<
"retrieve brick types" << std::endl;
162 std::map<int,int> bktMap;
163 coral::AttributeList emptyBindVariableList;
164 std::unique_ptr<coral::IQuery>
165 brickTypeQuery(
isession->nominalSchema().newQuery() );
166 brickTypeQuery->addToTableList(
"CFGBRICKS" );
167 brickTypeQuery->addToTableList(
"BRKT2CSETT" );
168 std::string bTypeCondition =
"CFGBRICKS.BRKTYPE=BRKT2CSETT.BRKTYPE";
169 brickTypeQuery->addToOutputList(
"CFGBRICKS.BRKID" );
170 brickTypeQuery->addToOutputList(
"BRKT2CSETT.CSETTYPE" );
171 brickTypeQuery->setCondition( bTypeCondition, emptyBindVariableList );
172 coral::ICursor& brickTypeCursor = brickTypeQuery->execute();
173 while( brickTypeCursor.next() ) {
174 const coral::AttributeList& row = brickTypeCursor.currentRow();
175 int id = row[
"CFGBRICKS.BRKID" ].data<
int>();
176 int bt = row[
"BRKT2CSETT.CSETTYPE"].data<
short>();
180 bktMap.insert( std::pair<int,int>(
id, bt ) );
184 std::cout <<
"retrieve CCB configuration keys" << std::endl;
185 std::map<int,std::map<int,int>*> keyMap;
186 std::map<int,int> cckMap;
187 coral::ITable& ccbRelTable =
188 isession->nominalSchema().tableHandle(
"CCBRELATIONS" );
189 std::unique_ptr<coral::IQuery>
190 ccbRelQuery( ccbRelTable.newQuery() );
191 ccbRelQuery->addToOutputList(
"CONFKEY" );
192 ccbRelQuery->addToOutputList(
"CCBID" );
193 ccbRelQuery->addToOutputList(
"CONFCCBKEY" );
194 coral::ICursor& ccbRelCursor = ccbRelQuery->execute();
196 while( ccbRelCursor.next() ) {
197 const coral::AttributeList& row = ccbRelCursor.currentRow();
198 int cfg = row[
"CONFKEY" ].data<
int>();
199 int ccb = row[
"CCBID" ].data<
int>();
200 int key = row[
"CONFCCBKEY"].data<
int>();
204 std::map<int,std::map<int,int>*>::const_iterator keyIter =
206 std::map<int,std::map<int,int>*>::const_iterator keyIend =
208 std::map<int,int>* mapPtr =
nullptr;
210 if ( keyIter != keyIend ) mapPtr = keyIter->second;
212 std::pair<
int,std::map<int,int>*>( cfg,
213 mapPtr =
new std::map<int,int> ) );
215 std::map<int,int>& mapRef( *mapPtr );
216 mapRef.insert( std::pair<int,int>( ccb, key ) );
218 if ( cckMap.find( key ) == cckMap.end() )
219 cckMap.insert( std::pair<int,int>( key, ccb ) );
223 std::cout <<
"retrieve CCB configuration bricks" << std::endl;
224 std::map<int,std::vector<int>*> brkMap;
225 coral::ITable& confBrickTable =
226 isession->nominalSchema().tableHandle(
"CFG2BRKREL" );
227 std::unique_ptr<coral::IQuery>
228 confBrickQuery( confBrickTable.newQuery() );
229 confBrickQuery->addToOutputList(
"CONFID" );
230 confBrickQuery->addToOutputList(
"BRKID" );
231 coral::ICursor& confBrickCursor = confBrickQuery->execute();
233 while( confBrickCursor.next() ) {
234 const coral::AttributeList& row = confBrickCursor.currentRow();
235 int key = row[
"CONFID"].data<
int>();
236 int brk = row[
"BRKID" ].data<
int>();
238 if ( cckMap.find( key ) == cckMap.end() )
continue;
239 std::map<int,std::vector<int>*>::const_iterator brkIter =
241 std::map<int,std::vector<int>*>::const_iterator brkIend =
244 std::vector<int>* brkPtr =
nullptr;
245 if ( brkIter != brkIend ) brkPtr = brkIter->second;
247 std::pair<
int,std::vector<int>*>( key,
248 brkPtr =
new std::vector<int> ) );
250 brkPtr->push_back( brk );
257 std::map<int,bool> userBricks;
258 std::map<int,bool>::const_iterator uBrkIter = userBricks.begin();
259 std::map<int,bool>::const_iterator uBrkIend = userBricks.end();
260 std::vector<DTConfigKey>::const_iterator cfgIter =
userConf.begin();
261 std::vector<DTConfigKey>::const_iterator cfgIend =
userConf.end();
262 while ( cfgIter != cfgIend ) {
267 std::map<int,std::map<int,int>*>::const_iterator keyIter =
269 std::map<int,std::map<int,int>*>::const_iterator keyIend =
271 std::map<int,int>* mapPtr =
nullptr;
272 if ( keyIter != keyIend ) mapPtr = keyIter->second;
273 if ( mapPtr ==
nullptr )
continue;
274 std::map<int,int>::const_iterator ccbIter = mapPtr->begin();
275 std::map<int,int>::const_iterator ccbIend = mapPtr->end();
276 while ( ccbIter != ccbIend ) {
277 const std::pair<int,int>& ccbEntry = *ccbIter++;
279 int ccb = ccbEntry.first;
280 int key = ccbEntry.second;
282 std::map<int,DTCCBId>::const_iterator ccbIter = ccbMap.find( ccb );
283 std::map<int,DTCCBId>::const_iterator ccbIend = ccbMap.end();
284 if ( ccbIter == ccbIend )
continue;
285 const DTCCBId& chaId = ccbIter->second;
287 std::map<int,std::vector<int>*>::const_iterator brkIter =
289 std::map<int,std::vector<int>*>::const_iterator brkIend =
291 if ( brkIter == brkIend )
continue;
292 std::vector<int>* brkPtr = brkIter->second;
293 if ( brkPtr ==
nullptr )
continue;
295 std::vector<int> bkList;
296 bkList.reserve( 20 );
297 std::map<int,int>::const_iterator bktIter = bktMap.begin();
298 std::map<int,int>::const_iterator bktIend = bktMap.end();
299 std::vector<int>::const_iterator bkiIter = brkPtr->begin();
300 std::vector<int>::const_iterator bkiIend = brkPtr->end();
301 while ( bkiIter != bkiIend ) {
302 int brickId = *bkiIter++;
303 bktIter = bktMap.find( brickId );
304 if ( bktIter == bktIend )
continue;
305 if ( bktIter->second == cft ) {
306 bkList.push_back( brickId );
307 uBrkIter = userBricks.find( brickId );
308 if ( uBrkIter == uBrkIend )
309 userBricks.insert( std::pair<int,bool>( brickId,
true ) );
320 std::cout <<
"writing payload : " <<
sizeof( *fullConf )
321 <<
" ( " << ( fullConf->
end() - fullConf->
begin() )
322 <<
" ) " << std::endl;
333 const std::map<int,bool>& userBricks ) {
335 std::cout <<
"open POOL out db " << std::endl;
338 std::map<int,bool>::const_iterator uBrkIter = userBricks.begin();
339 std::map<int,bool>::const_iterator uBrkIend = userBricks.end();
341 coral::ITable& brickConfigTable =
342 isession->nominalSchema().tableHandle(
"CFGBRICKS" );
343 std::unique_ptr<coral::IQuery>
344 brickConfigQuery( brickConfigTable.newQuery() );
345 brickConfigQuery->addToOutputList(
"BRKID" );
346 brickConfigQuery->addToOutputList(
"BRKNAME" );
347 coral::ICursor& brickConfigCursor = brickConfigQuery->execute();
349 std::vector<int> missingList;
350 std::vector<unsigned long long> checkedKeys;
351 while( brickConfigCursor.next() ) {
352 const coral::AttributeList& row = brickConfigCursor.currentRow();
353 int brickConfigId = row[
"BRKID"].data<
int>();
354 uBrkIter = userBricks.find( brickConfigId );
355 if ( uBrkIter == uBrkIend )
continue;
356 if ( !( uBrkIter->second ) )
continue;
359 <<
" : " << brickConfigName << std::endl;
360 checkedKeys.push_back( brickConfigId );
361 bool brickFound =
false;
363 std::cout <<
"load brick " << checkedKeys[0] << std::endl;
366 std::cout <<
"get brick..." << std::endl;
367 std::shared_ptr<DTKeyedConfig> brickCheck =
369 if ( brickCheck.get() ) {
370 brickFound = ( brickCheck->getId() == brickConfigId );
376 std::cout <<
"brick " << brickConfigId <<
" missing, copy request" 378 missingList.push_back( brickConfigId );
384 std::vector<int>::const_iterator brickIter = missingList.begin();
385 std::vector<int>::const_iterator brickIend = missingList.end();
386 while ( brickIter != brickIend ) {
387 int brickConfigId = *brickIter++;
388 coral::AttributeList bindVariableList;
389 bindVariableList.extend(
"brickId",
typeid(
int) );
390 bindVariableList[
"brickId"].data<
int>() = brickConfigId;
391 std::unique_ptr<coral::IQuery>
392 brickDataQuery(
isession->nominalSchema().newQuery() );
393 brickDataQuery->addToTableList(
"CFGRELATIONS" );
394 brickDataQuery->addToTableList(
"CONFIGCMDS" );
396 brickCondition =
"CONFIGCMDS.CMDID=CFGRELATIONS.CMDID";
397 brickCondition +=
" and CFGRELATIONS.BRKID=:brickId";
398 brickDataQuery->addToOutputList(
"CFGRELATIONS.BRKID" );
399 brickDataQuery->addToOutputList(
"CONFIGCMDS.CONFDATA" );
400 brickDataQuery->setCondition( brickCondition, bindVariableList );
401 coral::ICursor& brickDataCursor = brickDataQuery->execute();
403 brickData->
setId( brickConfigId );
404 while( brickDataCursor.next() ) {
405 const coral::AttributeList& row = brickDataCursor.currentRow();
406 brickData->
add( row[
"CONFIGCMDS.CONFDATA"].data<std::string>() );
409 std::cout <<
"now writing brick: " << brickConfigId << std::endl;
424 const std::vector<DTConfigKey>& cfgl,
425 const std::vector<DTConfigKey>& cfgr ) {
426 if ( cfgl.size() != cfgr.size() )
return false;
427 std::map<int,int> lmap;
428 std::vector<DTConfigKey>::const_iterator lIter = cfgl.begin();
429 std::vector<DTConfigKey>::const_iterator lIend = cfgl.end();
430 while ( lIter != lIend ) {
434 std::map<int,int> rmap;
435 std::vector<DTConfigKey>::const_iterator rIter = cfgr.begin();
436 std::vector<DTConfigKey>::const_iterator rIend = cfgr.end();
437 while ( rIter != rIend ) {
441 std::map<int,int>::const_iterator lmIter = lmap.begin();
442 std::map<int,int>::const_iterator lmIend = lmap.end();
443 std::map<int,int>::const_iterator rmIter = rmap.begin();
444 std::map<int,int>::const_iterator rmIend = rmap.end();
445 while ( ( lmIter != lmIend ) &&
446 ( rmIter != rmIend ) ) {
447 const std::pair<int,int>& lEntry = *lmIter++;
448 const std::pair<int,int>& rEntry = *rmIter++;
449 if ( lEntry.first != rEntry.first )
return false;
450 if ( lEntry.second != rEntry.second )
return false;
457 std::vector<DTConfigKey>::const_iterator iter =
userConf.begin();
458 std::vector<DTConfigKey>::const_iterator iend =
userConf.end();
459 while ( iter != iend ) {
461 if ( entry.
confKey == key )
return false;
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)
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
static cond::persistency::KeyList * keyList
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)
std::shared_ptr< T > get(size_t n) const
void chkConfigList(const std::map< int, bool > &userBricks)
std::shared_ptr< coral::ISessionProxy > isession
void setFullKey(const std::vector< DTConfigKey > &)
void load(const std::vector< unsigned long long > &keys)
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)
static void setList(cond::persistency::KeyList *list)
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