29 #include "RelationalAccess/ISchema.h"
30 #include "RelationalAccess/ITable.h"
31 #include "RelationalAccess/ICursor.h"
32 #include "RelationalAccess/IQuery.h"
33 #include "CoralBase/AttributeList.h"
34 #include "CoralBase/AttributeSpecification.h"
35 #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 brickContainer( ps.getParameter<std::
string> (
"container" ) ),
57 writeKeys( ps.getParameter<bool> (
"writeKeys" ) ),
58 writeData( ps.getParameter<bool> (
"writeData" ) ),
61 std::cout <<
" PopCon application for DT configuration export "
64 std::vector<edm::ParameterSet> dtConfigKeys (
65 ps.
getParameter< std::vector<edm::ParameterSet> >(
"DTConfigKeys" )
67 std::vector<edm::ParameterSet>::const_iterator iter = dtConfigKeys.begin();
68 std::vector<edm::ParameterSet>::const_iterator iend = dtConfigKeys.end();
69 while ( iter != iend ) {
74 << configType <<
" -> "
75 << configKey << std::endl;
97 std::cout <<
"last configuration key already copied for run: "
100 std::vector<DTConfigKey> lastKey;
111 std::cout <<
"get last payload" << std::endl;
113 std::cout <<
"get last full key" << std::endl;
114 lastKey = payload->fullKey();
116 std::vector<DTConfigKey>::const_iterator keyIter = lastKey.begin();
117 std::vector<DTConfigKey>::const_iterator keyIend = lastKey.end();
118 while ( keyIter != keyIend ) {
124 std::cout <<
"configure DbConnection" << std::endl;
128 std::cout <<
"create DbSession" << std::endl;
130 std::cout <<
"open session" << std::endl;
132 std::cout <<
"start transaction" << std::endl;
136 std::cout <<
"retrieve CCB map" << std::endl;
137 std::map<int,DTCCBId> ccbMap;
138 coral::ITable& ccbMapTable =
140 std::auto_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::auto_ptr<coral::IQuery>
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 =
189 std::auto_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 = 0;
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 =
227 std::auto_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 = 0;
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 = 0;
272 if ( keyIter != keyIend ) mapPtr = keyIter->second;
273 if ( mapPtr == 0 )
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 == 0 )
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;
334 const std::map<int,bool>& userBricks ) {
336 std::cout <<
"open POOL out db " << std::endl;
339 std::map<int,bool>::const_iterator uBrkIter = userBricks.begin();
340 std::map<int,bool>::const_iterator uBrkIend = userBricks.end();
342 coral::ITable& brickConfigTable =
344 std::auto_ptr<coral::IQuery>
345 brickConfigQuery( brickConfigTable.newQuery() );
346 brickConfigQuery->addToOutputList(
"BRKID" );
347 brickConfigQuery->addToOutputList(
"BRKNAME" );
348 coral::ICursor& brickConfigCursor = brickConfigQuery->execute();
350 std::vector<int> missingList;
351 std::vector<unsigned long long> checkedKeys;
352 while( brickConfigCursor.next() ) {
353 const coral::AttributeList& row = brickConfigCursor.currentRow();
354 int brickConfigId = row[
"BRKID"].data<
int>();
355 uBrkIter = userBricks.find( brickConfigId );
356 if ( uBrkIter == uBrkIend )
continue;
357 if ( !( uBrkIter->second ) )
continue;
360 <<
" : " << brickConfigName << std::endl;
361 checkedKeys.push_back( brickConfigId );
362 bool brickFound =
false;
364 std::cout <<
"load brick " << checkedKeys[0] << std::endl;
367 std::cout <<
"get brick..." << std::endl;
370 if ( brickCheck != 0 ) {
371 brickFound = ( brickCheck->
getId() == brickConfigId );
377 std::cout <<
"brick " << brickConfigId <<
" missing, copy request"
379 missingList.push_back( brickConfigId );
385 std::vector<int>::const_iterator brickIter = missingList.begin();
386 std::vector<int>::const_iterator brickIend = missingList.end();
387 while ( brickIter != brickIend ) {
388 int brickConfigId = *brickIter++;
389 coral::AttributeList bindVariableList;
390 bindVariableList.extend(
"brickId",
typeid(
int) );
391 bindVariableList[
"brickId"].data<
int>() = brickConfigId;
392 std::auto_ptr<coral::IQuery>
394 brickDataQuery->addToTableList(
"CFGRELATIONS" );
395 brickDataQuery->addToTableList(
"CONFIGCMDS" );
397 brickCondition =
"CONFIGCMDS.CMDID=CFGRELATIONS.CMDID";
398 brickCondition +=
" and CFGRELATIONS.BRKID=:brickId";
399 brickDataQuery->addToOutputList(
"CFGRELATIONS.BRKID" );
400 brickDataQuery->addToOutputList(
"CONFIGCMDS.CONFDATA" );
401 brickDataQuery->setCondition( brickCondition, bindVariableList );
402 coral::ICursor& brickDataCursor = brickDataQuery->execute();
404 brickData->
setId( brickConfigId );
405 while( brickDataCursor.next() ) {
406 const coral::AttributeList& row = brickDataCursor.currentRow();
407 brickData->
add( row[
"CONFIGCMDS.CONFDATA"].data<std::string>() );
410 std::cout <<
"now writing brick: " << brickConfigId << std::endl;
425 const std::vector<DTConfigKey>& cfgl,
426 const std::vector<DTConfigKey>& cfgr ) {
427 if ( cfgl.size() != cfgr.size() )
return false;
428 std::map<int,int> lmap;
429 std::vector<DTConfigKey>::const_iterator lIter = cfgl.begin();
430 std::vector<DTConfigKey>::const_iterator lIend = cfgl.end();
431 while ( lIter != lIend ) {
435 std::map<int,int> rmap;
436 std::vector<DTConfigKey>::const_iterator rIter = cfgr.begin();
437 std::vector<DTConfigKey>::const_iterator rIend = cfgr.end();
438 while ( rIter != rIend ) {
442 std::map<int,int>::const_iterator lmIter = lmap.begin();
443 std::map<int,int>::const_iterator lmIend = lmap.end();
444 std::map<int,int>::const_iterator rmIter = rmap.begin();
445 std::map<int,int>::const_iterator rmIend = rmap.end();
446 while ( ( lmIter != lmIend ) &&
447 ( rmIter != rmIend ) ) {
448 const std::pair<int,int>& lEntry = *lmIter++;
449 const std::pair<int,int>& rEntry = *rmIter++;
450 if ( lEntry.first != rEntry.first )
return false;
451 if ( lEntry.second != rEntry.second )
return false;
458 std::vector<DTConfigKey>::const_iterator iter =
userConf.begin();
459 std::vector<DTConfigKey>::const_iterator iend =
userConf.end();
460 while ( iter != iend ) {
462 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 load(std::vector< unsigned long long > const &keys)
DbTransaction & transaction()
void open(const std::string &connectionString, bool readOnly=false)
void add(const std::string &data)
std::vector< DTConfigKey > userConf
int commit()
commit transaction.
static void setList(cond::KeyList *list)
DbConnectionConfiguration & configuration()
std::string onlineConnect
static bool sameConfigList(const std::vector< DTConfigKey > &cfgl, const std::vector< DTConfigKey > &cfgr)
virtual ~DTUserKeyedConfigHandler()
std::string onlineAuthentication
const_iterator end() const
OldContainer m_to_transfer
cond::TagInfo const & tagInfo() const
int start(bool readOnly=false)
start transaction
unsigned long long Time_t
std::pair< std::string, MonitorElement * > entry
T const * get(int n) const
bool userDiscardedKey(int key)
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
DTUserKeyedConfigHandler(const edm::ParameterSet &ps)
DbSession createSession() const
coral::ISchema & nominalSchema()
void setAuthenticationPath(const std::string &p)
void chkConfigList(const std::map< int, bool > &userBricks)
cond::ValidityInterval lastInterval
void setFullKey(const std::vector< DTConfigKey > &)
cond::DbConnection connection
const_iterator begin() const
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
static cond::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