CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
DTKeyedConfigHandler Class Reference

#include <DTKeyedConfigHandler.h>

Inheritance diagram for DTKeyedConfigHandler:
popcon::PopConSourceHandler< DTCCBConfig >

Public Member Functions

 DTKeyedConfigHandler (const edm::ParameterSet &ps)
 
void getNewObjects ()
 
std::string id () const
 
virtual ~DTKeyedConfigHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< DTCCBConfig >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Static Public Member Functions

static void setList (cond::persistency::KeyList *list)
 

Private Member Functions

void chkConfigList ()
 

Static Private Member Functions

static bool sameConfigList (const std::vector< DTConfigKey > &cfgl, const std::vector< DTConfigKey > &cfgr)
 

Private Attributes

std::string brickContainer
 
DTCCBConfigccbConfig
 
cond::persistency::ConnectionPool connection
 
bool copyData
 
std::string dataTag
 
cond::persistency::Session isession
 
int maxBrickId
 
int maxRunId
 
int minBrickId
 
int minRunId
 
std::string onlineAuthentication
 
std::string onlineConnect
 

Static Private Attributes

static cond::persistency::KeyListkeyList = 0
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< DTCCBConfig >
typedef std::vector< TripletContainer
 
typedef std::vector< std::pair
< DTCCBConfig *, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< DTCCBConfig
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef DTCCBConfig value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< DTCCBConfig >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< DTCCBConfig >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Description:

Date:
2010/05/14 11:43:08
Revision:
1.2
Author
Paolo Ronchese INFN Padova

Definition at line 42 of file DTKeyedConfigHandler.h.

Constructor & Destructor Documentation

DTKeyedConfigHandler::DTKeyedConfigHandler ( const edm::ParameterSet ps)

Constructor

Definition at line 47 of file DTKeyedConfigHandler.cc.

References gather_cfg::cout, and onlineAuthentication.

47  :
48  copyData( ps.getUntrackedParameter<bool> ( "copyData", true ) ),
49  minBrickId( ps.getUntrackedParameter<int> ( "minBrick", 0 ) ),
50  maxBrickId( ps.getUntrackedParameter<int> ( "maxBrick", 999999999 ) ),
51  minRunId( ps.getUntrackedParameter<int> ( "minRun", 0 ) ),
52  maxRunId( ps.getUntrackedParameter<int> ( "maxRun", 999999999 ) ),
53  dataTag( ps.getParameter<std::string> ( "tag" ) ),
54  onlineConnect( ps.getParameter<std::string> ( "onlineDB" ) ),
56  "onlineAuthentication" ) ),
57  brickContainer( ps.getParameter<std::string> ( "container" ) ),
58  connection(),
59  isession() {
60  std::cout << " PopCon application for DT configuration export "
61  << onlineAuthentication << std::endl;
62 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
cond::persistency::ConnectionPool connection
cond::persistency::Session isession
tuple cout
Definition: gather_cfg.py:121
DTKeyedConfigHandler::~DTKeyedConfigHandler ( )
virtual

Destructor

Definition at line 67 of file DTKeyedConfigHandler.cc.

67  {
68 }

Member Function Documentation

void DTKeyedConfigHandler::chkConfigList ( )
private

Definition at line 445 of file DTKeyedConfigHandler.cc.

References DTKeyedConfig::add(), brickContainer, gather_cfg::cout, alignCSCRings::e, cppFunctionSkipper::exception, cond::persistency::KeyList::get(), isession, gen::k, keyList, cond::persistency::KeyList::load(), cond::KeyedElement::m_key, cond::KeyedElement::m_obj, maxBrickId, minBrickId, cond::persistency::Session::nominalSchema(), DTKeyedConfig::setId(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::service::PoolDBOutputService::writeOne().

Referenced by getNewObjects().

445  {
446 
447  std::cout << "open POOL out db " << std::endl;
449 
450  std::cout << "start queries " << std::endl;
451  std::map<int,bool> activeConfigMap;
452  coral::ITable& fullConfigTable =
453  isession.nominalSchema().tableHandle( "CONFIGSETS" );
454  std::auto_ptr<coral::IQuery>
455  fullConfigQuery( fullConfigTable.newQuery() );
456  fullConfigQuery->addToOutputList( "CONFKEY" );
457  fullConfigQuery->addToOutputList( "NAME" );
458  fullConfigQuery->addToOutputList( "RUN" );
459  coral::ICursor& fullConfigCursor = fullConfigQuery->execute();
460  while( fullConfigCursor.next() ) {
461  const coral::AttributeList& row = fullConfigCursor.currentRow();
462  int fullConfigId = row["CONFKEY"].data<int>();
463  int fullConfigRN = row["RUN" ].data<int>();
464  if ( fullConfigRN ) activeConfigMap.insert(
465  std::pair<int,bool>( fullConfigId, true ) );
466  else activeConfigMap.insert(
467  std::pair<int,bool>( fullConfigId, false ) );
468  std::string fullConfigName = row["NAME"].data<std::string>();
469  }
470 
471 // std::cout << " =============== CCB config list" << std::endl;
472  std::map<int,bool> activeCCBCfgMap;
473  coral::ITable& fullCCBCfgTable =
474  isession.nominalSchema().tableHandle( "CCBRELATIONS" );
475  std::auto_ptr<coral::IQuery>
476  fullCCBCfgQuery( fullCCBCfgTable.newQuery() );
477  fullCCBCfgQuery->addToOutputList( "CONFKEY" );
478  fullCCBCfgQuery->addToOutputList( "CONFCCBKEY" );
479  coral::ICursor& fullCCBCfgCursor = fullCCBCfgQuery->execute();
480  while( fullCCBCfgCursor.next() ) {
481  const coral::AttributeList& row = fullCCBCfgCursor.currentRow();
482  int fullConfigId = row["CONFKEY" ].data<int>();
483  int fullCCBCfgId = row["CONFCCBKEY"].data<int>();
484 // std::map<int,bool>::const_iterator cfgIter =
485 // activeConfigMap.find( fullConfigId );
486  std::map<int,bool>::const_iterator cfgIter;
487  if ( ( cfgIter = activeConfigMap.find( fullConfigId ) )
488  == activeConfigMap.end() ) continue;
489  if ( !( cfgIter->second ) ) continue;
490  if ( activeCCBCfgMap.find( fullCCBCfgId ) ==
491  activeCCBCfgMap.end() )
492  activeCCBCfgMap.insert( std::pair<int,bool>( fullCCBCfgId, true ) );
493  }
494 
495 // std::cout << " =============== config brick list" << std::endl;
496  std::map<int,bool> activeCfgBrkMap;
497  coral::ITable& ccbConfBrkTable =
498  isession.nominalSchema().tableHandle( "CFG2BRKREL" );
499  std::auto_ptr<coral::IQuery>
500  ccbConfBrickQuery( ccbConfBrkTable.newQuery() );
501  ccbConfBrickQuery->addToOutputList( "CONFID" );
502  ccbConfBrickQuery->addToOutputList( "BRKID" );
503  coral::ICursor& ccbConfBrickCursor = ccbConfBrickQuery->execute();
504  while( ccbConfBrickCursor.next() ) {
505  const coral::AttributeList& row = ccbConfBrickCursor.currentRow();
506  int fullCCBCfgId = row["CONFID"].data<int>();
507  int ccbConfBrkId = row["BRKID" ].data<int>();
508 // std::map<int,bool>::const_iterator ccbIter =
509 // activeCCBCfgMap.find( fullCCBCfgId );
510  std::map<int,bool>::const_iterator ccbIter;
511  if ( ( ccbIter = activeCCBCfgMap.find( fullCCBCfgId ) )
512  == activeCCBCfgMap.end() ) continue;
513  if ( !( ccbIter->second ) ) continue;
514  if ( activeCfgBrkMap.find( ccbConfBrkId ) ==
515  activeCfgBrkMap.end() )
516  activeCfgBrkMap.insert( std::pair<int,bool>( ccbConfBrkId, true ) );
517  }
518 
519 // std::cout << " ===============" << std::endl;
520 
521  coral::ITable& brickConfigTable =
522  isession.nominalSchema().tableHandle( "CFGBRICKS" );
523  std::auto_ptr<coral::IQuery>
524  brickConfigQuery( brickConfigTable.newQuery() );
525  brickConfigQuery->addToOutputList( "BRKID" );
526  brickConfigQuery->addToOutputList( "BRKNAME" );
527  coral::ICursor& brickConfigCursor = brickConfigQuery->execute();
528  DTKeyedConfig* brickData = 0;
529  std::vector<int> missingList;
530  std::vector<unsigned long long> checkedKeys;
531  while( brickConfigCursor.next() ) {
532  const coral::AttributeList& row = brickConfigCursor.currentRow();
533  int brickConfigId = row["BRKID"].data<int>();
534  if ( brickConfigId < minBrickId ) continue;
535  if ( brickConfigId > maxBrickId ) continue;
536 // std::map<int,bool>::const_iterator brkIter =
537 // activeCfgBrkMap.find( brickConfigId );
538  std::map<int,bool>::const_iterator brkIter;
539  if ( ( brkIter = activeCfgBrkMap.find( brickConfigId ) )
540  == activeCfgBrkMap.end() ) continue;
541  if ( !( brkIter->second ) ) continue;
542  std::string brickConfigName = row["BRKNAME"].data<std::string>();
543  std::cout << "brick " << brickConfigId
544  << " : " << brickConfigName << std::endl;
545  checkedKeys.push_back( brickConfigId );
546  bool brickFound = false;
547  try {
548  keyList->load( checkedKeys );
549  boost::shared_ptr<DTKeyedConfig> brickCheck = keyList->get<DTKeyedConfig>( 0 );
550  if ( brickCheck.get() ) brickFound =
551  ( brickCheck->getId() == brickConfigId );
552  }
553  catch ( std::exception e ) {
554  }
555  if ( !brickFound ) {
556  std::cout << "brick " << brickConfigId << " missing, copy request"
557  << std::endl;
558  missingList.push_back( brickConfigId );
559  }
560  checkedKeys.clear();
561  }
562  keyList->load( checkedKeys );
563 
564  std::vector<int>::const_iterator brickIter = missingList.begin();
565  std::vector<int>::const_iterator brickIend = missingList.end();
566  while ( brickIter != brickIend ) {
567  int brickConfigId = *brickIter++;
568 // std::cout << "get data for brick: " << brickConfigId << std::endl;
569  coral::AttributeList bindVariableList;
570  bindVariableList.extend( "brickId", typeid(int) );
571  bindVariableList["brickId"].data<int>() = brickConfigId;
572  std::auto_ptr<coral::IQuery>
573  brickDataQuery( isession.nominalSchema().newQuery() );
574  brickDataQuery->addToTableList( "CFGRELATIONS" );
575  brickDataQuery->addToTableList( "CONFIGCMDS" );
577  brickCondition = "CONFIGCMDS.CMDID=CFGRELATIONS.CMDID";
578  brickCondition += " and CFGRELATIONS.BRKID=:brickId";
579  brickDataQuery->addToOutputList( "CFGRELATIONS.BRKID" );
580  brickDataQuery->addToOutputList( "CONFIGCMDS.CONFDATA" );
581  brickDataQuery->setCondition( brickCondition, bindVariableList );
582  coral::ICursor& brickDataCursor = brickDataQuery->execute();
583  brickData = new DTKeyedConfig();
584  brickData->setId( brickConfigId );
585  while( brickDataCursor.next() ) {
586  const coral::AttributeList& row = brickDataCursor.currentRow();
587  brickData->add( row["CONFIGCMDS.CONFDATA"].data<std::string>() );
588  }
589  cond::KeyedElement k( brickData, brickConfigId );
590  std::cout << "now writing brick: " << brickConfigId << std::endl;
591  outdb->writeOne( k.m_obj, k.m_key, brickContainer );
592  }
593 
594  return;
595 
596 }
void add(const std::string &data)
boost::shared_ptr< T > get(size_t n) const
Definition: KeyList.h:39
cond::persistency::Session isession
static cond::persistency::KeyList * keyList
coral::ISchema & nominalSchema()
Definition: Session.cc:195
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
int k[5][pyjets_maxn]
void setId(int id)
tuple cout
Definition: gather_cfg.py:121
void load(const std::vector< unsigned long long > &keys)
Definition: KeyList.cc:14
void DTKeyedConfigHandler::getNewObjects ( )
virtual

Operations

Implements popcon::PopConSourceHandler< DTCCBConfig >.

Definition at line 73 of file DTKeyedConfigHandler.cc.

References DTCCBConfig::appendConfigKey(), DTCCBConfig::begin(), chkConfigList(), cond::persistency::Session::close(), cond::persistency::Transaction::commit(), cond::persistency::ConnectionPool::configure(), DTConfigKey::confKey, DTConfigKey::confType, connection, copyData, gather_cfg::cout, cond::persistency::ConnectionPool::createSession(), dataTag, DTCCBConfig::end(), reco::if(), isession, combine::key, prof2calltree::last, cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< DTCCBConfig >::lastPayload(), MergeJob_cfg::lastRun, popcon::PopConSourceHandler< DTCCBConfig >::m_to_transfer, maxRunId, minRunId, cond::persistency::Session::nominalSchema(), onlineAuthentication, onlineConnect, DTTTrigCorrFirst::run, sameConfigList(), DTCCBId::sectorId, cond::persistency::ConnectionPool::setAuthenticationPath(), DTCCBConfig::setFullKey(), DTCCBConfig::setStamp(), cond::persistency::Transaction::start(), relativeConstraints::station, DTCCBId::stationId, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< DTCCBConfig >::tagInfo(), cond::persistency::Session::transaction(), and DTCCBId::wheelId.

73  {
74 
75  //to access the information on the tag inside the offline database:
76  cond::TagInfo const & ti = tagInfo();
77  unsigned int last = ti.lastInterval.first;
78  std::cout << "last configuration key already copied for run: "
79  << last << std::endl;
80 
81  std::vector<DTConfigKey> lastKey;
82  std::cout << "check for last " << std::endl;
83  if ( last == 0 ) {
84  DTCCBConfig* dummyConf = new DTCCBConfig( dataTag );
85  dummyConf->setStamp( 0 );
86  dummyConf->setFullKey( lastKey );
87  cond::Time_t snc = 1;
88  std::cout << "write dummy " << std::endl;
89  m_to_transfer.push_back( std::make_pair( dummyConf, snc ) );
90  }
91  else {
92  std::cout << "get last payload" << std::endl;
93  Ref payload = lastPayload();
94  std::cout << "get last full key" << std::endl;
95  lastKey = payload->fullKey();
96  std::cout << "last key: " << std::endl;
97  std::vector<DTConfigKey>::const_iterator keyIter = lastKey.begin();
98  std::vector<DTConfigKey>::const_iterator keyIend = lastKey.end();
99  while ( keyIter != keyIend ) {
100  const DTConfigKey& cfgKeyList = *keyIter++;
101  std::cout << cfgKeyList.confType << " : "
102  << cfgKeyList.confKey << std::endl;
103  }
104  }
105 
106  //to access the information on last successful log entry for this tag:
107 // cond::LogDBEntry const & lde = logDBEntry();
108 
109  //to access the lastest payload (Ref is a smart pointer)
110 // Ref payload = lastPayload();
111 
112  if ( !copyData ) return;
113 
114  unsigned lastRun = last;
115  std::cout << "check for new runs since " << lastRun << std::endl;
116 
117  std::cout << "configure DbConnection" << std::endl;
118  // conn->configure( cond::CmsDefaults );
121  std::cout << "create/open DbSession" << std::endl;
123  std::cout << "start transaction" << std::endl;
125 
126  // =========== Update configuration data
127  chkConfigList();
128 
129  // =========== Find latest runs
130  std::cout << "get run config..." << std::endl;
131  std::map<int,std::vector<int>*> runMap;
132  std::map<int,std::vector<DTConfigKey>*> rhcMap;
133  coral::ITable& runHistoryTable =
134  isession.nominalSchema().tableHandle( "RUNHISTORY" );
135  std::auto_ptr<coral::IQuery>
136  runHistoryQuery( runHistoryTable.newQuery() );
137  runHistoryQuery->addToOutputList( "RUN" );
138  runHistoryQuery->addToOutputList( "RHID" );
139  coral::ICursor& runHistoryCursor = runHistoryQuery->execute();
140  while( runHistoryCursor.next() ) {
141  const coral::AttributeList& row = runHistoryCursor.currentRow();
142  int runId = row[ "RUN"].data<int>();
143  int rhcId = static_cast<int>( row["RHID"].data<int>() );
144  // ----------- ignore already copied runs
145  if ( static_cast<unsigned>( runId ) <= lastRun ) continue;
146  // ----------- ignore runs outside required range
147  if ( runId < minRunId ) continue;
148  if ( runId > maxRunId ) continue;
149  std::cout << "schedule config key copy for run "
150  << runId << " ---> RHID " << rhcId << std::endl;
151  // ----------- retrieve or create RH relation list for this run
152  std::vector<int>* rhlPtr = 0;
153  std::map<int,std::vector<int>*>::const_iterator runIter;
154  if ( ( runIter = runMap.find( runId ) ) != runMap.end() )
155  rhlPtr = runIter->second;
156  else runMap.insert( std::pair<int,std::vector<int>*>( runId,
157  rhlPtr = new std::vector<int> ) );
158  // ----------- append RH relation to the list
159  rhlPtr->push_back( rhcId );
160  // ----------- create key list for this RH relation
161  if ( rhcMap.find( rhcId ) == rhcMap.end() )
162  rhcMap.insert( std::pair<int,std::vector<DTConfigKey>*>( rhcId,
163  new std::vector<DTConfigKey> ) );
164  }
165  if ( !runMap.size() ) std::cout << "no new run found" << std::endl;
166 
167  // =========== get ccb identifiers map
168  std::cout << "retrieve CCB map" << std::endl;
169  std::map<int,DTCCBId> ccbMap;
170  coral::ITable& ccbMapTable =
171  isession.nominalSchema().tableHandle( "CCBMAP" );
172  std::auto_ptr<coral::IQuery>
173  ccbMapQuery( ccbMapTable.newQuery() );
174  ccbMapQuery->addToOutputList( "CCBID" );
175  ccbMapQuery->addToOutputList( "WHEEL" );
176  ccbMapQuery->addToOutputList( "SECTOR" );
177  ccbMapQuery->addToOutputList( "STATION" );
178  coral::ICursor& ccbMapCursor = ccbMapQuery->execute();
179  while( ccbMapCursor.next() ) {
180  const coral::AttributeList& row = ccbMapCursor.currentRow();
181  int ccb = row["CCBID" ].data<int>();
182  int wheel = row["WHEEL" ].data<int>();
183  int sector = row["SECTOR" ].data<int>();
184  int station = row["STATION"].data<int>();
185  DTCCBId ccbId;
186  ccbId. wheelId = wheel;
187  ccbId.stationId = station;
188  ccbId. sectorId = sector;
189  ccbMap.insert( std::pair<int,DTCCBId>( ccb, ccbId ) );
190  }
191 
192  // =========== get brick types
193  std::cout << "retrieve brick types" << std::endl;
194  std::map<int,int> bktMap;
195  coral::AttributeList emptyBindVariableList;
196  std::auto_ptr<coral::IQuery>
197  brickTypeQuery( isession.nominalSchema().newQuery() );
198  brickTypeQuery->addToTableList( "CFGBRICKS" );
199  brickTypeQuery->addToTableList( "BRKT2CSETT" );
200  // ----------- join brick type (1-11) to subsystem part (1-6)
201  std::string bTypeCondition = "CFGBRICKS.BRKTYPE=BRKT2CSETT.BRKTYPE";
202  brickTypeQuery->addToOutputList( "CFGBRICKS.BRKID" );
203  brickTypeQuery->addToOutputList( "BRKT2CSETT.CSETTYPE" );
204  brickTypeQuery->setCondition( bTypeCondition, emptyBindVariableList );
205  coral::ICursor& brickTypeCursor = brickTypeQuery->execute();
206  while( brickTypeCursor.next() ) {
207  const coral::AttributeList& row = brickTypeCursor.currentRow();
208  int id = row["CFGBRICKS.BRKID" ].data<int>();
209  int bt = row["BRKT2CSETT.CSETTYPE"].data<short>();
210 // std::cout << "brick " << id << " type " << bt << std::endl;
211 // @@FIX - TEMPORARY PATCH
212 // if ( bt > 3 ) bt = 3;
213  bktMap.insert( std::pair<int,int>( id, bt ) );
214  }
215 
216  // =========== get RH relations
217  std::cout << "retrieve RH relations" << std::endl;
218  std::map<int,int> cfgMap;
219  coral::ITable& rhcRelTable =
220  isession.nominalSchema().tableHandle( "RHRELATIONS" );
221  std::auto_ptr<coral::IQuery>
222  rhcRelQuery( rhcRelTable.newQuery() );
223  rhcRelQuery->addToOutputList( "RHID" );
224  rhcRelQuery->addToOutputList( "CONFKEY" );
225  rhcRelQuery->addToOutputList( "CSETTYPEID" );
226  coral::ICursor& rhcRelCursor = rhcRelQuery->execute();
227  while( rhcRelCursor.next() ) {
228  const coral::AttributeList& row = rhcRelCursor.currentRow();
229  int rhc = row["RHID" ].data<int>();
230  int key = row["CONFKEY" ].data<int>();
231  int cfg = row["CSETTYPEID"].data<int>();
232  // ----------- check for used RH relations, skip unused
233  std::map<int,std::vector<DTConfigKey>*>::iterator rhcIter =
234  rhcMap.find( rhc );
235  std::map<int,std::vector<DTConfigKey>*>::iterator rhcIend =
236  rhcMap.end();
237  if ( rhcIter == rhcIend ) continue;
238  std::vector<DTConfigKey>* keyPtr = rhcIter->second;
239  DTConfigKey confList;
240  confList.confType = cfg;
241  confList.confKey = key;
242  keyPtr->push_back( confList );
243  // ----------- flag config key as used
244  if ( cfgMap.find( cfg ) == cfgMap.end() )
245  cfgMap.insert( std::pair<int,int>( key, rhc ) );
246  }
247 
248  // =========== get ccb config keys
249  std::cout << "retrieve CCB configuration keys" << std::endl;
250  std::map<int,std::map<int,int>*> keyMap;
251  std::map<int,int> cckMap;
252  coral::ITable& ccbRelTable =
253  isession.nominalSchema().tableHandle( "CCBRELATIONS" );
254  std::auto_ptr<coral::IQuery>
255  ccbRelQuery( ccbRelTable.newQuery() );
256  ccbRelQuery->addToOutputList( "CONFKEY" );
257  ccbRelQuery->addToOutputList( "CCBID" );
258  ccbRelQuery->addToOutputList( "CONFCCBKEY" );
259  coral::ICursor& ccbRelCursor = ccbRelQuery->execute();
260  while( ccbRelCursor.next() ) {
261  const coral::AttributeList& row = ccbRelCursor.currentRow();
262  int cfg = row["CONFKEY" ].data<int>();
263  int ccb = row["CCBID" ].data<int>();
264  int key = row["CONFCCBKEY"].data<int>();
265  // ----------- check for used configurations, skip unused
266  if ( cfgMap.find( cfg ) == cfgMap.end() ) continue;
267  // ----------- retrieve or create ccb id-key map for this configuration
268  std::map<int,int>* mapPtr = 0;
269  std::map<int,std::map<int,int>*>::const_iterator keyIter;
270  if ( ( keyIter = keyMap.find( cfg ) ) != keyMap.end() )
271  mapPtr = keyIter->second;
272  else keyMap.insert( std::pair<int,std::map<int,int>*>( cfg,
273  mapPtr = new std::map<int,int> ) );
274 // std::map<int,std::map<int,int>*>::const_iterator keyIter =
275 // keyMap.find( cfg );
276 // std::map<int,std::map<int,int>*>::const_iterator keyIend =
277 // keyMap.end();
278 // if ( keyIter != keyIend ) mapPtr = keyIter->second;
279 // else keyMap.insert(
280 // std::pair<int,std::map<int,int>*>( cfg,
281 // mapPtr = new std::map<int,int> ) );
282  // ----------- store config key for this ccb
283  std::map<int,int>& mapRef( *mapPtr );
284  mapRef.insert( std::pair<int,int>( ccb, key ) );
285  // ----------- flag ccb config key as used
286  if ( cckMap.find( key ) == cckMap.end() )
287  cckMap.insert( std::pair<int,int>( key, ccb ) );
288  }
289 
290  // =========== get brick keys
291  std::cout << "retrieve CCB configuration bricks" << std::endl;
292  std::map<int,std::vector<int>*> brkMap;
293  coral::ITable& confBrickTable =
294  isession.nominalSchema().tableHandle( "CFG2BRKREL" );
295  std::auto_ptr<coral::IQuery>
296  confBrickQuery( confBrickTable.newQuery() );
297  confBrickQuery->addToOutputList( "CONFID" );
298  confBrickQuery->addToOutputList( "BRKID" );
299  coral::ICursor& confBrickCursor = confBrickQuery->execute();
300  while( confBrickCursor.next() ) {
301  const coral::AttributeList& row = confBrickCursor.currentRow();
302  int key = row["CONFID"].data<int>();
303  int brk = row["BRKID" ].data<int>();
304  // ----------- check for used ccb config key, skip unused
305  if ( cckMap.find( key ) == cckMap.end() ) continue;
306 // std::map<int,std::vector<int>*>::const_iterator brkIter =
307 // brkMap.find( key );
308 // std::map<int,std::vector<int>*>::const_iterator brkIend =
309 // brkMap.end();
310  // ----------- retrieve or create brick list for this ccb config
311  std::vector<int>* brkPtr = 0;
312  std::map<int,std::vector<int>*>::const_iterator brkIter;
313 //check for new ccb config key
314  if ( ( brkIter = brkMap.find( key ) ) != brkMap.end() )
315  brkPtr = brkIter->second;
316  else brkMap.insert( std::pair<int,std::vector<int>*>( key,
317  brkPtr = new std::vector<int> ) );
318 // if ( brkIter != brkIend ) brkPtr = brkIter->second;
319 // else brkMap.insert(
320 // std::pair<int,std::vector<int>*>( key,
321 // brkPtr = new std::vector<int> ) );
322  // ----------- store brick key
323  brkPtr->push_back( brk );
324  }
325 
326  // =========== loop over new runs
327  std::map<int,std::vector<int>*>::const_iterator runIter = runMap.begin();
328  std::map<int,std::vector<int>*>::const_iterator runIend = runMap.end();
329  while ( runIter != runIend ) {
330  const std::pair<int,std::vector<int>*>& runEntry = *runIter++;
331  // ----------- get full configuration
332  int run = runEntry.first;
333  std::vector<DTConfigKey> cfl;
334  // ----------- get RH relation list
335  std::vector<int>* rhlPtr = runEntry.second;
336  std::vector<int>::const_iterator rhlIter = rhlPtr->begin();
337  std::vector<int>::const_iterator rhlIend = rhlPtr->end();
338  // ----------- loop over RH relations
339  while ( rhlIter != rhlIend ) {
340  int rhc = *rhlIter++;
341  std::cout << "retrieve configuration bricks for run " << run
342  << " ---> RH " << rhc << std::endl;
343 // std::map<int,std::vector<DTConfigKey>*>::const_iterator
344 // rhcIter = rhcMap.find( rhc );
345 // std::map<int,std::vector<DTConfigKey>*>::const_iterator
346 // rhcIend = rhcMap.end();
347  std::map<int,std::vector<DTConfigKey>*>::const_iterator rhcIter;
348  // ----------- redundant check
349  if ( ( rhcIter = rhcMap.find( rhc ) ) == rhcMap.end() ) continue;
350  std::vector<DTConfigKey>* listPtr = rhcIter->second;
351  // ----------- redundant check
352  if ( listPtr == 0 ) continue;
353  std::vector<DTConfigKey>::const_iterator bkiIter = listPtr->begin();
354  std::vector<DTConfigKey>::const_iterator bkiIend = listPtr->end();
355  while ( bkiIter != bkiIend ) cfl.push_back( *bkiIter++ );
356  }
357  if ( sameConfigList( cfl, lastKey ) ) continue;
358  lastKey = cfl;
359  DTCCBConfig* fullConf = new DTCCBConfig( dataTag );
360  // set run and full configuration in payload
361  fullConf->setStamp( run );
362  fullConf->setFullKey( cfl );
363 
364  std::vector<DTConfigKey>::const_iterator cfgIter = cfl.begin();
365  std::vector<DTConfigKey>::const_iterator cfgIend = cfl.end();
366  while ( cfgIter != cfgIend ) {
367  const DTConfigKey& cfgEntry = *cfgIter++;
368  int cft = cfgEntry.confType;
369  int cfg = cfgEntry.confKey;
370 
371  // =========== retrieve ccb config map
372 // std::map<int,std::map<int,int>*>::const_iterator keyIter =
373 // keyMap.find( cfg );
374 // std::map<int,std::map<int,int>*>::const_iterator keyIend =
375 // keyMap.end();
376  std::map<int,int>* mapPtr = 0;
377  std::map<int,std::map<int,int>*>::const_iterator keyIter;
378  // ----------- redundant check
379 // if ( keyIter != keyIend )
380  if ( ( keyIter = keyMap.find( cfg ) ) != keyMap.end() )
381  mapPtr = keyIter->second;
382  if ( mapPtr == 0 ) continue;
383  std::map<int,int>::const_iterator ccmIter = mapPtr->begin();
384  std::map<int,int>::const_iterator ccmIend = mapPtr->end();
385  while ( ccmIter != ccmIend ) {
386  const std::pair<int,int>& ccmEntry = *ccmIter++;
387  // ----------- get ccb config key
388  int ccb = ccmEntry.first;
389  int key = ccmEntry.second;
390  // retrieve chamber id
391 // std::map<int,DTCCBId>::const_iterator ccbIter = ccbMap.find( ccb );
392 // std::map<int,DTCCBId>::const_iterator ccbIend = ccbMap.end();
393  std::map<int,DTCCBId>::const_iterator ccbIter;
394  // ----------- redundant check
395 // if ( ccbIter == ccbIend ) continue;
396  if ( ( ccbIter = ccbMap.find( ccb ) ) == ccbMap.end() ) continue;
397  const DTCCBId& chaId = ccbIter->second;
398  // ----------- retrieve brick id list
399 // std::map<int,std::vector<int>*>::const_iterator brkIter =
400 // brkMap.find( key );
401 // std::map<int,std::vector<int>*>::const_iterator brkIend =
402 // brkMap.end();
403 // if ( brkIter == brkIend ) continue;
404  std::map<int,std::vector<int>*>::const_iterator brkIter;
405  if ( ( brkIter = brkMap.find( key ) ) == brkMap.end() ) continue;
406  std::vector<int>* brkPtr = brkIter->second;
407  // ----------- redundant check
408  if ( brkPtr == 0 ) continue;
409  // ----------- set brick id lists in payload
410  std::vector<int> bkList;
411  bkList.reserve( 20 );
412 // std::map<int,int>::const_iterator bktIter = bktMap.begin();
413 // std::map<int,int>::const_iterator bktIend = bktMap.end();
414  std::map<int,int>::const_iterator bktIter;
415  std::vector<int>::const_iterator bkiIter = brkPtr->begin();
416  std::vector<int>::const_iterator bkiIend = brkPtr->end();
417  while ( bkiIter != bkiIend ) {
418  int brickId = *bkiIter++;
419 // bktIter = bktMap.find( brickId );
420  // ----------- redundant check
421  if ( ( bktIter = bktMap.find( brickId ) ) == bktMap.end() ) continue;
422  if ( bktIter->second == cft ) bkList.push_back( brickId );
423  }
424  fullConf->appendConfigKey( chaId.wheelId,
425  chaId.stationId,
426  chaId.sectorId,
427  bkList );
428  }
429  }
430  cond::Time_t snc = runEntry.first;
431  m_to_transfer.push_back( std::make_pair( fullConf, snc ) );
432  std::cout << "writing payload : " << sizeof( *fullConf )
433  << " ( " << ( fullConf->end() - fullConf->begin() )
434  << " ) " << std::endl;
435  }
436 
438  isession.close();
439 
440  return;
441 
442 }
cond::persistency::ConnectionPool connection
int wheelId
Definition: DTCCBConfig.h:43
void setStamp(int s)
Definition: DTCCBConfig.cc:197
void start(bool readOnly=true)
Definition: Session.cc:22
Transaction & transaction()
Definition: Session.cc:66
const_iterator end() const
Definition: DTCCBConfig.cc:345
int sectorId
Definition: DTCCBConfig.h:45
cond::persistency::Session isession
cond::ValidityInterval lastInterval
Definition: Types.h:65
unsigned long long Time_t
Definition: Time.h:16
int stationId
Definition: DTCCBConfig.h:44
static bool sameConfigList(const std::vector< DTConfigKey > &cfgl, const std::vector< DTConfigKey > &cfgr)
Session createSession(const std::string &connectionString, bool writeCapable=false, BackendType backType=DEFAULT_DB)
coral::ISchema & nominalSchema()
Definition: Session.cc:195
list key
Definition: combine.py:13
if(dp >Float(M_PI)) dp-
tuple cout
Definition: gather_cfg.py:121
void setFullKey(const std::vector< DTConfigKey > &)
Definition: DTCCBConfig.cc:192
const_iterator begin() const
Definition: DTCCBConfig.cc:340
void setAuthenticationPath(const std::string &p)
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
Definition: DTCCBConfig.cc:278
cond::TagInfo_t const & tagInfo() const
std::string DTKeyedConfigHandler::id ( void  ) const
virtual

Implements popcon::PopConSourceHandler< DTCCBConfig >.

Definition at line 599 of file DTKeyedConfigHandler.cc.

References dataTag.

599  {
600  return dataTag;
601 }
bool DTKeyedConfigHandler::sameConfigList ( const std::vector< DTConfigKey > &  cfgl,
const std::vector< DTConfigKey > &  cfgr 
)
staticprivate

Definition at line 604 of file DTKeyedConfigHandler.cc.

References DTConfigKey::confKey, and DTConfigKey::confType.

Referenced by getNewObjects().

606  {
607  if ( cfgl.size() != cfgr.size() ) return false;
608  std::map<int,int> lmap;
609  std::vector<DTConfigKey>::const_iterator lIter = cfgl.begin();
610  std::vector<DTConfigKey>::const_iterator lIend = cfgl.end();
611  while ( lIter != lIend ) {
612  const DTConfigKey& entry = *lIter++;
613  lmap.insert( std::pair<int,int>( entry.confType, entry.confKey ) );
614  }
615  std::map<int,int> rmap;
616  std::vector<DTConfigKey>::const_iterator rIter = cfgr.begin();
617  std::vector<DTConfigKey>::const_iterator rIend = cfgr.end();
618  while ( rIter != rIend ) {
619  const DTConfigKey& entry = *rIter++;
620  rmap.insert( std::pair<int,int>( entry.confType, entry.confKey ) );
621  }
622  std::map<int,int>::const_iterator lmIter = lmap.begin();
623  std::map<int,int>::const_iterator lmIend = lmap.end();
624  std::map<int,int>::const_iterator rmIter = rmap.begin();
625  std::map<int,int>::const_iterator rmIend = rmap.end();
626  while ( ( lmIter != lmIend ) &&
627  ( rmIter != rmIend ) ) {
628  const std::pair<int,int>& lEntry = *lmIter++;
629  const std::pair<int,int>& rEntry = *rmIter++;
630  if ( lEntry.first != rEntry.first ) return false;
631  if ( lEntry.second != rEntry.second ) return false;
632  }
633  return true;
634 }
void DTKeyedConfigHandler::setList ( cond::persistency::KeyList list)
static

Definition at line 637 of file DTKeyedConfigHandler.cc.

References keyList, and list().

Referenced by DTKeyedConfigPopConAnalyzer::analyze().

637  {
638  keyList = list;
639 }
static cond::persistency::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

Member Data Documentation

std::string DTKeyedConfigHandler::brickContainer
private

Definition at line 73 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

DTCCBConfig* DTKeyedConfigHandler::ccbConfig
private

Definition at line 74 of file DTKeyedConfigHandler.h.

cond::persistency::ConnectionPool DTKeyedConfigHandler::connection
private

Definition at line 76 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

bool DTKeyedConfigHandler::copyData
private

Definition at line 64 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

std::string DTKeyedConfigHandler::dataTag
private

Definition at line 70 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects(), and id().

cond::persistency::Session DTKeyedConfigHandler::isession
private

Definition at line 77 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList(), and getNewObjects().

cond::persistency::KeyList * DTKeyedConfigHandler::keyList = 0
staticprivate

Definition at line 82 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList(), and setList().

int DTKeyedConfigHandler::maxBrickId
private

Definition at line 66 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

int DTKeyedConfigHandler::maxRunId
private

Definition at line 68 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

int DTKeyedConfigHandler::minBrickId
private

Definition at line 65 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

int DTKeyedConfigHandler::minRunId
private

Definition at line 67 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

std::string DTKeyedConfigHandler::onlineAuthentication
private

Definition at line 72 of file DTKeyedConfigHandler.h.

Referenced by DTKeyedConfigHandler(), and getNewObjects().

std::string DTKeyedConfigHandler::onlineConnect
private

Definition at line 71 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().