25 #include "RelationalAccess/ISchema.h"
26 #include "RelationalAccess/ITable.h"
27 #include "RelationalAccess/ICursor.h"
28 #include "RelationalAccess/IQuery.h"
29 #include "CoralBase/AttributeList.h"
30 #include "CoralBase/AttributeSpecification.h"
31 #include "CoralBase/Attribute.h"
48 dataRun( ps.getParameter<int> (
"run" ) ),
49 dataTag( ps.getParameter<std::
string> (
"tag" ) ),
50 onlineConnect( ps.getParameter<std::
string> (
"onlineDB" ) ),
51 onlineAuthentication( ps.getParameter<std::
string> (
52 "onlineAuthentication" ) ),
53 brickContainer( ps.getParameter<std::
string> (
"container" ) ),
54 writeKeys( ps.getParameter<bool> (
"writeKeys" ) ),
55 writeData( ps.getParameter<bool> (
"writeData" ) ),
58 std::cout <<
" PopCon application for DT configuration export "
61 std::vector<edm::ParameterSet> dtConfigKeys (
62 ps.
getParameter< std::vector<edm::ParameterSet> >(
"DTConfigKeys" )
64 std::vector<edm::ParameterSet>::const_iterator
iter = dtConfigKeys.begin();
65 std::vector<edm::ParameterSet>::const_iterator iend = dtConfigKeys.end();
66 while ( iter != iend ) {
71 << configType <<
" -> "
72 << configKey << std::endl;
94 std::cout <<
"last configuration key already copied for run: "
97 std::vector<DTConfigKey> lastKey;
108 std::cout <<
"get last payload" << std::endl;
110 std::cout <<
"get last full key" << std::endl;
111 lastKey = payload->fullKey();
113 std::vector<DTConfigKey>::const_iterator keyIter = lastKey.begin();
114 std::vector<DTConfigKey>::const_iterator keyIend = lastKey.end();
115 while ( keyIter != keyIend ) {
121 std::cout <<
"configure DbConnection" << std::endl;
125 std::cout <<
"create/open DbSession" << std::endl;
127 std::cout <<
"start transaction" << std::endl;
131 std::cout <<
"retrieve CCB map" << std::endl;
132 std::map<int,DTCCBId> ccbMap;
133 coral::ITable& ccbMapTable =
135 std::auto_ptr<coral::IQuery>
136 ccbMapQuery( ccbMapTable.newQuery() );
137 ccbMapQuery->addToOutputList(
"CCBID" );
138 ccbMapQuery->addToOutputList(
"WHEEL" );
139 ccbMapQuery->addToOutputList(
"SECTOR" );
140 ccbMapQuery->addToOutputList(
"STATION" );
141 coral::ICursor& ccbMapCursor = ccbMapQuery->execute();
142 while( ccbMapCursor.next() ) {
143 const coral::AttributeList& row = ccbMapCursor.currentRow();
144 int ccb = row[
"CCBID" ].data<
int>();
145 int wheel = row[
"WHEEL" ].data<
int>();
146 int sector = row[
"SECTOR" ].data<
int>();
147 int station = row[
"STATION"].data<
int>();
149 ccbId. wheelId = wheel;
151 ccbId. sectorId = sector;
152 ccbMap.insert( std::pair<int,DTCCBId>( ccb, ccbId ) );
156 std::cout <<
"retrieve brick types" << std::endl;
157 std::map<int,int> bktMap;
158 coral::AttributeList emptyBindVariableList;
159 std::auto_ptr<coral::IQuery>
161 brickTypeQuery->addToTableList(
"CFGBRICKS" );
162 brickTypeQuery->addToTableList(
"BRKT2CSETT" );
163 std::string bTypeCondition =
"CFGBRICKS.BRKTYPE=BRKT2CSETT.BRKTYPE";
164 brickTypeQuery->addToOutputList(
"CFGBRICKS.BRKID" );
165 brickTypeQuery->addToOutputList(
"BRKT2CSETT.CSETTYPE" );
166 brickTypeQuery->setCondition( bTypeCondition, emptyBindVariableList );
167 coral::ICursor& brickTypeCursor = brickTypeQuery->execute();
168 while( brickTypeCursor.next() ) {
169 const coral::AttributeList& row = brickTypeCursor.currentRow();
170 int id = row[
"CFGBRICKS.BRKID" ].data<
int>();
171 int bt = row[
"BRKT2CSETT.CSETTYPE"].data<
short>();
175 bktMap.insert( std::pair<int,int>(
id, bt ) );
179 std::cout <<
"retrieve CCB configuration keys" << std::endl;
180 std::map<int,std::map<int,int>*> keyMap;
181 std::map<int,int> cckMap;
182 coral::ITable& ccbRelTable =
184 std::auto_ptr<coral::IQuery>
185 ccbRelQuery( ccbRelTable.newQuery() );
186 ccbRelQuery->addToOutputList(
"CONFKEY" );
187 ccbRelQuery->addToOutputList(
"CCBID" );
188 ccbRelQuery->addToOutputList(
"CONFCCBKEY" );
189 coral::ICursor& ccbRelCursor = ccbRelQuery->execute();
191 while( ccbRelCursor.next() ) {
192 const coral::AttributeList& row = ccbRelCursor.currentRow();
193 int cfg = row[
"CONFKEY" ].data<
int>();
194 int ccb = row[
"CCBID" ].data<
int>();
195 int key = row[
"CONFCCBKEY"].data<
int>();
199 std::map<int,std::map<int,int>*>::const_iterator keyIter =
201 std::map<int,std::map<int,int>*>::const_iterator keyIend =
203 std::map<int,int>* mapPtr = 0;
205 if ( keyIter != keyIend ) mapPtr = keyIter->second;
207 std::pair<
int,std::map<int,int>*>( cfg,
208 mapPtr =
new std::map<int,int> ) );
210 std::map<int,int>& mapRef( *mapPtr );
211 mapRef.insert( std::pair<int,int>( ccb, key ) );
213 if ( cckMap.find( key ) == cckMap.end() )
214 cckMap.insert( std::pair<int,int>( key, ccb ) );
218 std::cout <<
"retrieve CCB configuration bricks" << std::endl;
219 std::map<int,std::vector<int>*> brkMap;
220 coral::ITable& confBrickTable =
222 std::auto_ptr<coral::IQuery>
223 confBrickQuery( confBrickTable.newQuery() );
224 confBrickQuery->addToOutputList(
"CONFID" );
225 confBrickQuery->addToOutputList(
"BRKID" );
226 coral::ICursor& confBrickCursor = confBrickQuery->execute();
228 while( confBrickCursor.next() ) {
229 const coral::AttributeList& row = confBrickCursor.currentRow();
230 int key = row[
"CONFID"].data<
int>();
231 int brk = row[
"BRKID" ].data<
int>();
233 if ( cckMap.find( key ) == cckMap.end() )
continue;
234 std::map<int,std::vector<int>*>::const_iterator brkIter =
236 std::map<int,std::vector<int>*>::const_iterator brkIend =
239 std::vector<int>* brkPtr = 0;
240 if ( brkIter != brkIend ) brkPtr = brkIter->second;
242 std::pair<
int,std::vector<int>*>( key,
243 brkPtr =
new std::vector<int> ) );
245 brkPtr->push_back( brk );
252 std::map<int,bool> userBricks;
253 std::map<int,bool>::const_iterator uBrkIter = userBricks.begin();
254 std::map<int,bool>::const_iterator uBrkIend = userBricks.end();
255 std::vector<DTConfigKey>::const_iterator cfgIter =
userConf.begin();
256 std::vector<DTConfigKey>::const_iterator cfgIend =
userConf.end();
257 while ( cfgIter != cfgIend ) {
262 std::map<int,std::map<int,int>*>::const_iterator keyIter =
264 std::map<int,std::map<int,int>*>::const_iterator keyIend =
266 std::map<int,int>* mapPtr = 0;
267 if ( keyIter != keyIend ) mapPtr = keyIter->second;
268 if ( mapPtr == 0 )
continue;
269 std::map<int,int>::const_iterator ccbIter = mapPtr->begin();
270 std::map<int,int>::const_iterator ccbIend = mapPtr->end();
271 while ( ccbIter != ccbIend ) {
272 const std::pair<int,int>& ccbEntry = *ccbIter++;
274 int ccb = ccbEntry.first;
275 int key = ccbEntry.second;
277 std::map<int,DTCCBId>::const_iterator ccbIter = ccbMap.find( ccb );
278 std::map<int,DTCCBId>::const_iterator ccbIend = ccbMap.end();
279 if ( ccbIter == ccbIend )
continue;
280 const DTCCBId& chaId = ccbIter->second;
282 std::map<int,std::vector<int>*>::const_iterator brkIter =
284 std::map<int,std::vector<int>*>::const_iterator brkIend =
286 if ( brkIter == brkIend )
continue;
287 std::vector<int>* brkPtr = brkIter->second;
288 if ( brkPtr == 0 )
continue;
290 std::vector<int> bkList;
291 bkList.reserve( 20 );
292 std::map<int,int>::const_iterator bktIter = bktMap.begin();
293 std::map<int,int>::const_iterator bktIend = bktMap.end();
294 std::vector<int>::const_iterator bkiIter = brkPtr->begin();
295 std::vector<int>::const_iterator bkiIend = brkPtr->end();
296 while ( bkiIter != bkiIend ) {
297 int brickId = *bkiIter++;
298 bktIter = bktMap.find( brickId );
299 if ( bktIter == bktIend )
continue;
300 if ( bktIter->second == cft ) {
301 bkList.push_back( brickId );
302 uBrkIter = userBricks.find( brickId );
303 if ( uBrkIter == uBrkIend )
304 userBricks.insert( std::pair<int,bool>( brickId,
true ) );
315 std::cout <<
"writing payload : " <<
sizeof( *fullConf )
316 <<
" ( " << ( fullConf->
end() - fullConf->
begin() )
317 <<
" ) " << std::endl;
329 const std::map<int,bool>& userBricks ) {
331 std::cout <<
"open POOL out db " << std::endl;
334 std::map<int,bool>::const_iterator uBrkIter = userBricks.begin();
335 std::map<int,bool>::const_iterator uBrkIend = userBricks.end();
337 coral::ITable& brickConfigTable =
339 std::auto_ptr<coral::IQuery>
340 brickConfigQuery( brickConfigTable.newQuery() );
341 brickConfigQuery->addToOutputList(
"BRKID" );
342 brickConfigQuery->addToOutputList(
"BRKNAME" );
343 coral::ICursor& brickConfigCursor = brickConfigQuery->execute();
345 std::vector<int> missingList;
346 std::vector<unsigned long long> checkedKeys;
347 while( brickConfigCursor.next() ) {
348 const coral::AttributeList& row = brickConfigCursor.currentRow();
349 int brickConfigId = row[
"BRKID"].data<
int>();
350 uBrkIter = userBricks.find( brickConfigId );
351 if ( uBrkIter == uBrkIend )
continue;
352 if ( !( uBrkIter->second ) )
continue;
355 <<
" : " << brickConfigName << std::endl;
356 checkedKeys.push_back( brickConfigId );
357 bool brickFound =
false;
359 std::cout <<
"load brick " << checkedKeys[0] << std::endl;
362 std::cout <<
"get brick..." << std::endl;
363 boost::shared_ptr<DTKeyedConfig> brickCheck =
365 if ( brickCheck.get() ) {
366 brickFound = ( brickCheck->getId() == brickConfigId );
372 std::cout <<
"brick " << brickConfigId <<
" missing, copy request"
374 missingList.push_back( brickConfigId );
380 std::vector<int>::const_iterator brickIter = missingList.begin();
381 std::vector<int>::const_iterator brickIend = missingList.end();
382 while ( brickIter != brickIend ) {
383 int brickConfigId = *brickIter++;
384 coral::AttributeList bindVariableList;
385 bindVariableList.extend(
"brickId",
typeid(
int) );
386 bindVariableList[
"brickId"].data<
int>() = brickConfigId;
387 std::auto_ptr<coral::IQuery>
389 brickDataQuery->addToTableList(
"CFGRELATIONS" );
390 brickDataQuery->addToTableList(
"CONFIGCMDS" );
392 brickCondition =
"CONFIGCMDS.CMDID=CFGRELATIONS.CMDID";
393 brickCondition +=
" and CFGRELATIONS.BRKID=:brickId";
394 brickDataQuery->addToOutputList(
"CFGRELATIONS.BRKID" );
395 brickDataQuery->addToOutputList(
"CONFIGCMDS.CONFDATA" );
396 brickDataQuery->setCondition( brickCondition, bindVariableList );
397 coral::ICursor& brickDataCursor = brickDataQuery->execute();
399 brickData->
setId( brickConfigId );
400 while( brickDataCursor.next() ) {
401 const coral::AttributeList& row = brickDataCursor.currentRow();
402 brickData->
add( row[
"CONFIGCMDS.CONFDATA"].data<std::string>() );
405 std::cout <<
"now writing brick: " << brickConfigId << std::endl;
420 const std::vector<DTConfigKey>& cfgl,
421 const std::vector<DTConfigKey>& cfgr ) {
422 if ( cfgl.size() != cfgr.size() )
return false;
423 std::map<int,int> lmap;
424 std::vector<DTConfigKey>::const_iterator lIter = cfgl.begin();
425 std::vector<DTConfigKey>::const_iterator lIend = cfgl.end();
426 while ( lIter != lIend ) {
430 std::map<int,int> rmap;
431 std::vector<DTConfigKey>::const_iterator rIter = cfgr.begin();
432 std::vector<DTConfigKey>::const_iterator rIend = cfgr.end();
433 while ( rIter != rIend ) {
437 std::map<int,int>::const_iterator lmIter = lmap.begin();
438 std::map<int,int>::const_iterator lmIend = lmap.end();
439 std::map<int,int>::const_iterator rmIter = rmap.begin();
440 std::map<int,int>::const_iterator rmIend = rmap.end();
441 while ( ( lmIter != lmIend ) &&
442 ( rmIter != rmIend ) ) {
443 const std::pair<int,int>& lEntry = *lmIter++;
444 const std::pair<int,int>& rEntry = *rmIter++;
445 if ( lEntry.first != rEntry.first )
return false;
446 if ( lEntry.second != rEntry.second )
return false;
453 std::vector<DTConfigKey>::const_iterator
iter =
userConf.begin();
454 std::vector<DTConfigKey>::const_iterator iend =
userConf.end();
455 while ( iter != iend ) {
457 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)
void start(bool readOnly=true)
std::vector< DTConfigKey > userConf
std::string onlineConnect
static bool sameConfigList(const std::vector< DTConfigKey > &cfgl, const std::vector< DTConfigKey > &cfgr)
virtual ~DTUserKeyedConfigHandler()
boost::shared_ptr< T > get(size_t n) const
Transaction & transaction()
std::string onlineAuthentication
const_iterator end() const
OldContainer m_to_transfer
cond::ValidityInterval lastInterval
static cond::persistency::KeyList * keyList
unsigned long long Time_t
Session createSession(const std::string &connectionString, bool writeCapable=false, BackendType backType=DEFAULT_DB)
coral::ISchema & nominalSchema()
bool userDiscardedKey(int key)
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
DTUserKeyedConfigHandler(const edm::ParameterSet &ps)
void chkConfigList(const std::map< int, bool > &userBricks)
cond::persistency::Session 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)
static void setList(cond::persistency::KeyList *list)
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