CMS 3D CMS Logo

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
 
std::shared_ptr< coral::ISessionProxy > isession
 
int maxBrickId
 
int maxRunId
 
int minBrickId
 
int minRunId
 
std::string onlineAuthentication
 
int onlineAuthSys
 
std::string onlineConnect
 

Static Private Attributes

static cond::persistency::KeyListkeyList = 0
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< DTCCBConfig >
typedef std::vector< Triplet > Container
 
typedef std::vector< std::pair< DTCCBConfig *, cond::Time_t > > OldContainer
 
typedef PopConSourceHandler< DTCCBConfigself
 
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)
 
cond::persistency::SessiondbSession () const
 
- 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 47 of file DTKeyedConfigHandler.h.

Constructor & Destructor Documentation

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

Constructor

Definition at line 49 of file DTKeyedConfigHandler.cc.

References gather_cfg::cout, and onlineAuthentication.

49  :
50  copyData( ps.getUntrackedParameter<bool> ( "copyData", true ) ),
51  minBrickId( ps.getUntrackedParameter<int> ( "minBrick", 0 ) ),
52  maxBrickId( ps.getUntrackedParameter<int> ( "maxBrick", 999999999 ) ),
53  minRunId( ps.getUntrackedParameter<int> ( "minRun", 0 ) ),
54  maxRunId( ps.getUntrackedParameter<int> ( "maxRun", 999999999 ) ),
55  dataTag( ps.getParameter<std::string> ( "tag" ) ),
56  onlineConnect( ps.getParameter<std::string> ( "onlineDB" ) ),
58  "onlineAuthentication" ) ),
59  onlineAuthSys( ps.getUntrackedParameter<int>( "onlineAuthSys",1 ) ),
60  brickContainer( ps.getParameter<std::string> ( "container" ) ),
61  connection(),
62  isession() {
63  std::cout << " PopCon application for DT configuration export "
64  << onlineAuthentication << std::endl;
65 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
cond::persistency::ConnectionPool connection
std::shared_ptr< coral::ISessionProxy > isession
DTKeyedConfigHandler::~DTKeyedConfigHandler ( )
virtual

Destructor

Definition at line 70 of file DTKeyedConfigHandler.cc.

70  {
71 }

Member Function Documentation

void DTKeyedConfigHandler::chkConfigList ( )
private

Definition at line 447 of file DTKeyedConfigHandler.cc.

References DTKeyedConfig::add(), brickContainer, gather_cfg::cout, MillePedeFileConverter_cfg::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, DTKeyedConfig::setId(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::service::PoolDBOutputService::writeOne().

Referenced by getNewObjects().

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

References DTCCBConfig::appendConfigKey(), DTCCBConfig::begin(), looper::cfg, chkConfigList(), cond::persistency::ConnectionPool::configure(), DTConfigKey::confKey, DTConfigKey::confType, connection, copyData, gather_cfg::cout, cond::persistency::ConnectionPool::createCoralSession(), dataTag, DTCCBConfig::end(), reco::if(), isession, crabWrapper::key, plotBeamSpotDB::last, cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< DTCCBConfig >::lastPayload(), ntuplemaker::lastRun, popcon::PopConSourceHandler< DTCCBConfig >::m_to_transfer, maxRunId, minRunId, onlineAuthentication, onlineAuthSys, onlineConnect, jetCorrFactors_cfi::payload, findQualityFiles::run, sameConfigList(), DTCCBId::sectorId, cond::persistency::ConnectionPool::setAuthenticationPath(), cond::persistency::ConnectionPool::setAuthenticationSystem(), DTCCBConfig::setFullKey(), DTCCBConfig::setStamp(), relativeConstraints::station, DTCCBId::stationId, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< DTCCBConfig >::tagInfo(), makeMuonMisalignmentScenario::wheel, and DTCCBId::wheelId.

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

Implements popcon::PopConSourceHandler< DTCCBConfig >.

Definition at line 601 of file DTKeyedConfigHandler.cc.

References dataTag.

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

Definition at line 606 of file DTKeyedConfigHandler.cc.

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

Referenced by getNewObjects().

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

Definition at line 639 of file DTKeyedConfigHandler.cc.

References keyList, and list().

Referenced by DTKeyedConfigPopConAnalyzer::analyze().

639  {
640  keyList = list;
641 }
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 79 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

DTCCBConfig* DTKeyedConfigHandler::ccbConfig
private

Definition at line 80 of file DTKeyedConfigHandler.h.

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

Definition at line 82 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

bool DTKeyedConfigHandler::copyData
private

Definition at line 69 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

std::string DTKeyedConfigHandler::dataTag
private

Definition at line 75 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects(), and id().

std::shared_ptr<coral::ISessionProxy> DTKeyedConfigHandler::isession
private

Definition at line 83 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList(), and getNewObjects().

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

Definition at line 88 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList(), and setList().

int DTKeyedConfigHandler::maxBrickId
private

Definition at line 71 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

int DTKeyedConfigHandler::maxRunId
private

Definition at line 73 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

int DTKeyedConfigHandler::minBrickId
private

Definition at line 70 of file DTKeyedConfigHandler.h.

Referenced by chkConfigList().

int DTKeyedConfigHandler::minRunId
private

Definition at line 72 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

std::string DTKeyedConfigHandler::onlineAuthentication
private

Definition at line 77 of file DTKeyedConfigHandler.h.

Referenced by DTKeyedConfigHandler(), and getNewObjects().

int DTKeyedConfigHandler::onlineAuthSys
private

Definition at line 78 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().

std::string DTKeyedConfigHandler::onlineConnect
private

Definition at line 76 of file DTKeyedConfigHandler.h.

Referenced by getNewObjects().