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"
50 dataRun( ps.getParameter<int> (
"run" ) ),
51 dataTag( ps.getParameter<std::
string> (
"tag" ) ),
52 onlineConnect( ps.getParameter<std::
string> (
"onlineDB" ) ),
53 onlineAuthentication( ps.getParameter<std::
string> (
54 "onlineAuthentication" ) ),
55 onlineAuthSys( ps.getUntrackedParameter<int>(
"onlineAuthSys",1 ) ),
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;
129 std::cout <<
"create/open DbSession" << std::endl;
131 std::cout <<
"start transaction" << std::endl;
132 isession->transaction().start(
true );
135 std::cout <<
"retrieve CCB map" << std::endl;
136 std::map<int,DTCCBId> ccbMap;
137 coral::ITable& ccbMapTable =
138 isession->nominalSchema().tableHandle(
"CCBMAP" );
139 std::auto_ptr<coral::IQuery>
140 ccbMapQuery( ccbMapTable.newQuery() );
141 ccbMapQuery->addToOutputList(
"CCBID" );
142 ccbMapQuery->addToOutputList(
"WHEEL" );
143 ccbMapQuery->addToOutputList(
"SECTOR" );
144 ccbMapQuery->addToOutputList(
"STATION" );
145 coral::ICursor& ccbMapCursor = ccbMapQuery->execute();
146 while( ccbMapCursor.next() ) {
147 const coral::AttributeList& row = ccbMapCursor.currentRow();
148 int ccb = row[
"CCBID" ].data<
int>();
149 int wheel = row[
"WHEEL" ].data<
int>();
150 int sector = row[
"SECTOR" ].data<
int>();
151 int station = row[
"STATION"].data<
int>();
153 ccbId. wheelId = wheel;
155 ccbId. sectorId = sector;
156 ccbMap.insert( std::pair<int,DTCCBId>( ccb, ccbId ) );
160 std::cout <<
"retrieve brick types" << std::endl;
161 std::map<int,int> bktMap;
162 coral::AttributeList emptyBindVariableList;
163 std::auto_ptr<coral::IQuery>
164 brickTypeQuery(
isession->nominalSchema().newQuery() );
165 brickTypeQuery->addToTableList(
"CFGBRICKS" );
166 brickTypeQuery->addToTableList(
"BRKT2CSETT" );
167 std::string bTypeCondition =
"CFGBRICKS.BRKTYPE=BRKT2CSETT.BRKTYPE";
168 brickTypeQuery->addToOutputList(
"CFGBRICKS.BRKID" );
169 brickTypeQuery->addToOutputList(
"BRKT2CSETT.CSETTYPE" );
170 brickTypeQuery->setCondition( bTypeCondition, emptyBindVariableList );
171 coral::ICursor& brickTypeCursor = brickTypeQuery->execute();
172 while( brickTypeCursor.next() ) {
173 const coral::AttributeList& row = brickTypeCursor.currentRow();
174 int id = row[
"CFGBRICKS.BRKID" ].data<
int>();
175 int bt = row[
"BRKT2CSETT.CSETTYPE"].data<
short>();
179 bktMap.insert( std::pair<int,int>(
id, bt ) );
183 std::cout <<
"retrieve CCB configuration keys" << std::endl;
184 std::map<int,std::map<int,int>*> keyMap;
185 std::map<int,int> cckMap;
186 coral::ITable& ccbRelTable =
187 isession->nominalSchema().tableHandle(
"CCBRELATIONS" );
188 std::auto_ptr<coral::IQuery>
189 ccbRelQuery( ccbRelTable.newQuery() );
190 ccbRelQuery->addToOutputList(
"CONFKEY" );
191 ccbRelQuery->addToOutputList(
"CCBID" );
192 ccbRelQuery->addToOutputList(
"CONFCCBKEY" );
193 coral::ICursor& ccbRelCursor = ccbRelQuery->execute();
195 while( ccbRelCursor.next() ) {
196 const coral::AttributeList& row = ccbRelCursor.currentRow();
197 int cfg = row[
"CONFKEY" ].data<
int>();
198 int ccb = row[
"CCBID" ].data<
int>();
199 int key = row[
"CONFCCBKEY"].data<
int>();
203 std::map<int,std::map<int,int>*>::const_iterator keyIter =
205 std::map<int,std::map<int,int>*>::const_iterator keyIend =
207 std::map<int,int>* mapPtr = 0;
209 if ( keyIter != keyIend ) mapPtr = keyIter->second;
211 std::pair<
int,std::map<int,int>*>( cfg,
212 mapPtr =
new std::map<int,int> ) );
214 std::map<int,int>& mapRef( *mapPtr );
215 mapRef.insert( std::pair<int,int>( ccb, key ) );
217 if ( cckMap.find( key ) == cckMap.end() )
218 cckMap.insert( std::pair<int,int>( key, ccb ) );
222 std::cout <<
"retrieve CCB configuration bricks" << std::endl;
223 std::map<int,std::vector<int>*> brkMap;
224 coral::ITable& confBrickTable =
225 isession->nominalSchema().tableHandle(
"CFG2BRKREL" );
226 std::auto_ptr<coral::IQuery>
227 confBrickQuery( confBrickTable.newQuery() );
228 confBrickQuery->addToOutputList(
"CONFID" );
229 confBrickQuery->addToOutputList(
"BRKID" );
230 coral::ICursor& confBrickCursor = confBrickQuery->execute();
232 while( confBrickCursor.next() ) {
233 const coral::AttributeList& row = confBrickCursor.currentRow();
234 int key = row[
"CONFID"].data<
int>();
235 int brk = row[
"BRKID" ].data<
int>();
237 if ( cckMap.find( key ) == cckMap.end() )
continue;
238 std::map<int,std::vector<int>*>::const_iterator brkIter =
240 std::map<int,std::vector<int>*>::const_iterator brkIend =
243 std::vector<int>* brkPtr = 0;
244 if ( brkIter != brkIend ) brkPtr = brkIter->second;
246 std::pair<
int,std::vector<int>*>( key,
247 brkPtr =
new std::vector<int> ) );
249 brkPtr->push_back( brk );
256 std::map<int,bool> userBricks;
257 std::map<int,bool>::const_iterator uBrkIter = userBricks.begin();
258 std::map<int,bool>::const_iterator uBrkIend = userBricks.end();
259 std::vector<DTConfigKey>::const_iterator cfgIter =
userConf.begin();
260 std::vector<DTConfigKey>::const_iterator cfgIend =
userConf.end();
261 while ( cfgIter != cfgIend ) {
266 std::map<int,std::map<int,int>*>::const_iterator keyIter =
268 std::map<int,std::map<int,int>*>::const_iterator keyIend =
270 std::map<int,int>* mapPtr = 0;
271 if ( keyIter != keyIend ) mapPtr = keyIter->second;
272 if ( mapPtr == 0 )
continue;
273 std::map<int,int>::const_iterator ccbIter = mapPtr->begin();
274 std::map<int,int>::const_iterator ccbIend = mapPtr->end();
275 while ( ccbIter != ccbIend ) {
276 const std::pair<int,int>& ccbEntry = *ccbIter++;
278 int ccb = ccbEntry.first;
279 int key = ccbEntry.second;
281 std::map<int,DTCCBId>::const_iterator ccbIter = ccbMap.find( ccb );
282 std::map<int,DTCCBId>::const_iterator ccbIend = ccbMap.end();
283 if ( ccbIter == ccbIend )
continue;
284 const DTCCBId& chaId = ccbIter->second;
286 std::map<int,std::vector<int>*>::const_iterator brkIter =
288 std::map<int,std::vector<int>*>::const_iterator brkIend =
290 if ( brkIter == brkIend )
continue;
291 std::vector<int>* brkPtr = brkIter->second;
292 if ( brkPtr == 0 )
continue;
294 std::vector<int> bkList;
295 bkList.reserve( 20 );
296 std::map<int,int>::const_iterator bktIter = bktMap.begin();
297 std::map<int,int>::const_iterator bktIend = bktMap.end();
298 std::vector<int>::const_iterator bkiIter = brkPtr->begin();
299 std::vector<int>::const_iterator bkiIend = brkPtr->end();
300 while ( bkiIter != bkiIend ) {
301 int brickId = *bkiIter++;
302 bktIter = bktMap.find( brickId );
303 if ( bktIter == bktIend )
continue;
304 if ( bktIter->second == cft ) {
305 bkList.push_back( brickId );
306 uBrkIter = userBricks.find( brickId );
307 if ( uBrkIter == uBrkIend )
308 userBricks.insert( std::pair<int,bool>( brickId,
true ) );
319 std::cout <<
"writing payload : " <<
sizeof( *fullConf )
320 <<
" ( " << ( fullConf->
end() - fullConf->
begin() )
321 <<
" ) " << std::endl;
332 const std::map<int,bool>& userBricks ) {
334 std::cout <<
"open POOL out db " << std::endl;
337 std::map<int,bool>::const_iterator uBrkIter = userBricks.begin();
338 std::map<int,bool>::const_iterator uBrkIend = userBricks.end();
340 coral::ITable& brickConfigTable =
341 isession->nominalSchema().tableHandle(
"CFGBRICKS" );
342 std::auto_ptr<coral::IQuery>
343 brickConfigQuery( brickConfigTable.newQuery() );
344 brickConfigQuery->addToOutputList(
"BRKID" );
345 brickConfigQuery->addToOutputList(
"BRKNAME" );
346 coral::ICursor& brickConfigCursor = brickConfigQuery->execute();
348 std::vector<int> missingList;
349 std::vector<unsigned long long> checkedKeys;
350 while( brickConfigCursor.next() ) {
351 const coral::AttributeList& row = brickConfigCursor.currentRow();
352 int brickConfigId = row[
"BRKID"].data<
int>();
353 uBrkIter = userBricks.find( brickConfigId );
354 if ( uBrkIter == uBrkIend )
continue;
355 if ( !( uBrkIter->second ) )
continue;
358 <<
" : " << brickConfigName << std::endl;
359 checkedKeys.push_back( brickConfigId );
360 bool brickFound =
false;
362 std::cout <<
"load brick " << checkedKeys[0] << std::endl;
365 std::cout <<
"get brick..." << std::endl;
366 boost::shared_ptr<DTKeyedConfig> brickCheck =
368 if ( brickCheck.get() ) {
369 brickFound = ( brickCheck->getId() == brickConfigId );
375 std::cout <<
"brick " << brickConfigId <<
" missing, copy request"
377 missingList.push_back( brickConfigId );
383 std::vector<int>::const_iterator brickIter = missingList.begin();
384 std::vector<int>::const_iterator brickIend = missingList.end();
385 while ( brickIter != brickIend ) {
386 int brickConfigId = *brickIter++;
387 coral::AttributeList bindVariableList;
388 bindVariableList.extend(
"brickId",
typeid(
int) );
389 bindVariableList[
"brickId"].data<
int>() = brickConfigId;
390 std::auto_ptr<coral::IQuery>
391 brickDataQuery(
isession->nominalSchema().newQuery() );
392 brickDataQuery->addToTableList(
"CFGRELATIONS" );
393 brickDataQuery->addToTableList(
"CONFIGCMDS" );
395 brickCondition =
"CONFIGCMDS.CMDID=CFGRELATIONS.CMDID";
396 brickCondition +=
" and CFGRELATIONS.BRKID=:brickId";
397 brickDataQuery->addToOutputList(
"CFGRELATIONS.BRKID" );
398 brickDataQuery->addToOutputList(
"CONFIGCMDS.CONFDATA" );
399 brickDataQuery->setCondition( brickCondition, bindVariableList );
400 coral::ICursor& brickDataCursor = brickDataQuery->execute();
402 brickData->
setId( brickConfigId );
403 while( brickDataCursor.next() ) {
404 const coral::AttributeList& row = brickDataCursor.currentRow();
405 brickData->
add( row[
"CONFIGCMDS.CONFDATA"].data<std::string>() );
408 std::cout <<
"now writing brick: " << brickConfigId << std::endl;
423 const std::vector<DTConfigKey>& cfgl,
424 const std::vector<DTConfigKey>& cfgr ) {
425 if ( cfgl.size() != cfgr.size() )
return false;
426 std::map<int,int> lmap;
427 std::vector<DTConfigKey>::const_iterator lIter = cfgl.begin();
428 std::vector<DTConfigKey>::const_iterator lIend = cfgl.end();
429 while ( lIter != lIend ) {
433 std::map<int,int> rmap;
434 std::vector<DTConfigKey>::const_iterator rIter = cfgr.begin();
435 std::vector<DTConfigKey>::const_iterator rIend = cfgr.end();
436 while ( rIter != rIend ) {
440 std::map<int,int>::const_iterator lmIter = lmap.begin();
441 std::map<int,int>::const_iterator lmIend = lmap.end();
442 std::map<int,int>::const_iterator rmIter = rmap.begin();
443 std::map<int,int>::const_iterator rmIend = rmap.end();
444 while ( ( lmIter != lmIend ) &&
445 ( rmIter != rmIend ) ) {
446 const std::pair<int,int>& lEntry = *lmIter++;
447 const std::pair<int,int>& rEntry = *rmIter++;
448 if ( lEntry.first != rEntry.first )
return false;
449 if ( lEntry.second != rEntry.second )
return false;
456 std::vector<DTConfigKey>::const_iterator iter =
userConf.begin();
457 std::vector<DTConfigKey>::const_iterator iend =
userConf.end();
458 while ( iter != iend ) {
460 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)
boost::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
std::vector< DTConfigKey > userConf
boost::shared_ptr< coral::ISessionProxy > isession
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
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)
bool userDiscardedKey(int key)
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
DTUserKeyedConfigHandler(const edm::ParameterSet &ps)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void chkConfigList(const std::map< int, bool > &userBricks)
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