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 46 of file DTKeyedConfigHandler.cc.

References gather_cfg::cout, and onlineAuthentication.

46  :
47  copyData( ps.getUntrackedParameter<bool> ( "copyData", true ) ),
48  minBrickId( ps.getUntrackedParameter<int> ( "minBrick", 0 ) ),
49  maxBrickId( ps.getUntrackedParameter<int> ( "maxBrick", 999999999 ) ),
50  minRunId( ps.getUntrackedParameter<int> ( "minRun", 0 ) ),
51  maxRunId( ps.getUntrackedParameter<int> ( "maxRun", 999999999 ) ),
52  dataTag( ps.getParameter<std::string> ( "tag" ) ),
53  onlineConnect( ps.getParameter<std::string> ( "onlineDB" ) ),
55  "onlineAuthentication" ) ),
56  brickContainer( ps.getParameter<std::string> ( "container" ) ),
57  connection(),
58  isession() {
59  std::cout << " PopCon application for DT configuration export "
60  << onlineAuthentication << std::endl;
61 }
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 66 of file DTKeyedConfigHandler.cc.

66  {
67 }

Member Function Documentation

void DTKeyedConfigHandler::chkConfigList ( )
private

Definition at line 444 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().

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

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

Implements popcon::PopConSourceHandler< DTCCBConfig >.

Definition at line 598 of file DTKeyedConfigHandler.cc.

References dataTag.

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

Definition at line 603 of file DTKeyedConfigHandler.cc.

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

Referenced by getNewObjects().

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

Definition at line 636 of file DTKeyedConfigHandler.cc.

References keyList, and list().

Referenced by DTKeyedConfigPopConAnalyzer::analyze().

636  {
637  keyList = list;
638 }
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().