CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes

CondDBESSource Class Reference

#include <CondDBESSource.h>

Inheritance diagram for CondDBESSource:
edm::eventsetup::DataProxyProvider edm::EventSetupRecordIntervalFinder PoolDBESSource

List of all members.

Classes

struct  Stats

Public Types

typedef std::multimap
< std::string, ProxyP
ProxyMap
typedef boost::shared_ptr
< cond::DataProxyWrapperBase
ProxyP
enum  RefreshPolicy {
  NOREFRESH, REFRESH_ALWAYS, REFRESH_OPEN_IOVS, REFRESH_EACH_RUN,
  RECONNECT_EACH_RUN
}

Public Member Functions

 CondDBESSource (const edm::ParameterSet &)
 ~CondDBESSource ()

Protected Member Functions

virtual void newInterval (const edm::eventsetup::EventSetupRecordKey &iRecordType, const edm::ValidityInterval &iInterval)
 called when a new interval of validity occurs for iRecordType
virtual void registerProxies (const edm::eventsetup::EventSetupRecordKey &iRecordKey, KeyedProxies &aProxyList)
virtual void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)

Private Types

typedef std::map< std::string,
cond::TagMetadata
TagCollection

Private Member Functions

void fillTagCollectionFromDB (const std::string &coraldb, const std::string &prefix, const std::string &postfix, const std::string &roottag, std::map< std::string, cond::TagMetadata > &replacement)

Private Attributes

cond::DbConnection m_connection
bool m_doDump
unsigned int m_lastLumi
std::map< std::string,
unsigned int > 
m_lastRecordRuns
unsigned int m_lastRun
RefreshPolicy m_policy
ProxyMap m_proxies
std::map< std::string,
std::pair< cond::DbSession,
std::string > > 
m_sessionPool
Stats m_stats
TagCollection m_tagCollection

Detailed Description

Definition at line 34 of file CondDBESSource.h.


Member Typedef Documentation

typedef std::multimap< std::string, ProxyP> CondDBESSource::ProxyMap

Definition at line 38 of file CondDBESSource.h.

Definition at line 37 of file CondDBESSource.h.

typedef std::map< std::string, cond::TagMetadata > CondDBESSource::TagCollection [private]

Definition at line 65 of file CondDBESSource.h.


Member Enumeration Documentation

Enumerator:
NOREFRESH 
REFRESH_ALWAYS 
REFRESH_OPEN_IOVS 
REFRESH_EACH_RUN 
RECONNECT_EACH_RUN 

Definition at line 40 of file CondDBESSource.h.


Constructor & Destructor Documentation

CondDBESSource::CondDBESSource ( const edm::ParameterSet iConfig) [explicit]

required by eventsetup

Definition at line 110 of file CondDBESSource.cc.

References b, cond::DbConnection::configuration(), cond::DbConnection::configure(), cond::DbConnection::createSession(), alignCSCRings::e, edm::ParameterSet::exists(), fillTagCollectionFromDB(), edm::EventSetupRecordIntervalFinder::findingRecordWithKey(), edm::eventsetup::heterocontainer::HCTypeTag::findType(), reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), align_cfg::globaltag, cond::TagMetadata::labelname, m_connection, m_policy, m_proxies, m_stats, m_tagCollection, CondDBESSource::Stats::nData, cond::DbSession::openReadOnly(), cond::TagMetadata::pfn, RECONNECT_EACH_RUN, cond::TagMetadata::recordname, REFRESH_ALWAYS, REFRESH_EACH_RUN, REFRESH_OPEN_IOVS, alignCSCRings::s, cond::TagMetadata::tag, convertSQLitetoXML_cfg::toGet, edm::eventsetup::EventSetupRecordKey::type(), and edm::eventsetup::DataProxyProvider::usingRecordWithKey().

                                                               :
  m_connection(), 
  m_lastRun(0),  // for the stat
  m_lastLumi(0),  // for the stat
  m_policy( NOREFRESH ),
  m_doDump( iConfig.getUntrackedParameter<bool>( "DumpStat", false ) )
{
  if( iConfig.getUntrackedParameter<bool>( "RefreshAlways", false ) ) {
    m_policy = REFRESH_ALWAYS;
  }
  if( iConfig.getUntrackedParameter<bool>( "RefreshOpenIOVs", false ) ) {
    m_policy = REFRESH_OPEN_IOVS;
  }
  if( iConfig.getUntrackedParameter<bool>( "RefreshEachRun", false ) ) {
    m_policy = REFRESH_EACH_RUN;
  }
  if( iConfig.getUntrackedParameter<bool>( "ReconnectEachRun", false ) ) {
    m_policy = RECONNECT_EACH_RUN;
  }

  Stats s = {0,0,0,0,0,0,0,0};
  m_stats = s;  
  //std::cout<<"CondDBESSource::CondDBESSource"<<std::endl;
  /*parameter set parsing and pool environment setting
   */
  
  // default connection string
  // inproduction used for the global tag
  std::string userconnect= iConfig.getParameter<std::string>("connect");
  

  // connection configuration
  edm::ParameterSet connectionPset = iConfig.getParameter<edm::ParameterSet>( "DBParameters" );
  m_connection.configuration().setParameters( connectionPset );
  m_connection.configure();
  

  // load additional record/tag info it will overwrite the global tag
  std::map<std::string,cond::TagMetadata> replacement;
  if( iConfig.exists( "toGet" ) ) {
    typedef std::vector< edm::ParameterSet > Parameters;
    Parameters toGet = iConfig.getParameter<Parameters>( "toGet" );
    for( Parameters::iterator itToGet = toGet.begin(); itToGet != toGet.end(); ++itToGet ) {
      cond::TagMetadata nm;
      nm.recordname = itToGet->getParameter<std::string>( "record" );
      nm.labelname = itToGet->getUntrackedParameter<std::string>( "label", "" );
      nm.tag = itToGet->getParameter<std::string>( "tag" );
      nm.pfn = itToGet->getUntrackedParameter<std::string>( "connect", userconnect );
      //        nm.objectname=itFound->second;
      std::string recordLabelKey = joinRecordAndLabel( nm.recordname, nm.labelname );
      replacement.insert( std::pair<std::string,cond::TagMetadata>( recordLabelKey, nm ) );
    }
  }
  
  // get the global tag, merge with "replacement" store in "tagCollection"
  std::string globaltag;
  if( iConfig.exists( "globaltag" ) ) 
    globaltag = iConfig.getParameter<std::string>( "globaltag" );
  
  fillTagCollectionFromDB(userconnect,
                          iConfig.getUntrackedParameter<std::string>( "pfnPrefix", "" ),
                          iConfig.getUntrackedParameter<std::string>( "pfnPostfix", "" ),
                          globaltag,
                          replacement);
  
  
  TagCollection::iterator it;
  TagCollection::iterator itBeg = m_tagCollection.begin();
  TagCollection::iterator itEnd = m_tagCollection.end();
 
  std::map<std::string, cond::DbSession> sessions;

  /* load DataProxy Plugin (it is strongly typed due to EventSetup ideosyncrasis)
   * construct proxy
   * contrary to EventSetup the "object-name" is not used as identifier: multiple entries in a record are
   * dinstinguished only by their label...
   * done in two step: first create ProxyWrapper loading ALL required dictionaries
   * this will allow to initialize POOL in one go for each "database"
   * The real initialization of the Data-Proxies is done in the second loop 
   */
  std::vector<cond::DataProxyWrapperBase *> proxyWrappers(m_tagCollection.size());
  size_t ipb=0;
  for(it=itBeg;it!=itEnd;++it){
    proxyWrappers[ipb++] =  
      cond::ProxyFactory::get()->create(buildName(it->second.recordname));
  }
  // now all required libraries have been loaded
  // init sessions and DataProxies
  ipb=0;
  for(it=itBeg;it!=itEnd;++it){
    std::map<std::string, cond::DbSession>::iterator p = sessions.find( it->second.pfn );
    cond::DbSession nsess;
    if (p==sessions.end()) {
      //open db get tag info (i.e. the IOV token...)
      nsess = m_connection.createSession();
      nsess.openReadOnly( it->second.pfn, "" );
      sessions.insert(std::make_pair(it->second.pfn,nsess));
    } else nsess = (*p).second;
    //cond::MetaData metadata(nsess);
    //nsess.transaction().start(true);
    //std::string iovtoken = metadata.getToken(it->tag);
    // owenship...
    ProxyP proxy(proxyWrappers[ipb++]);
   //  instert in the map
    m_proxies.insert(std::make_pair(it->second.recordname, proxy));
    // initialize
    //proxy->lateInit(nsess,iovtoken, 
    //              it->labelname, it->pfn, it->tag
    //      );
    proxy->lateInit(nsess,it->second.tag, 
                    it->second.labelname, it->second.pfn);
    //nsess.transaction().commit();
  }

  // one loaded expose all other tags to the Proxy! 
  CondGetterFromESSource visitor( m_proxies );
  ProxyMap::iterator b = m_proxies.begin();
  ProxyMap::iterator e = m_proxies.end();
  for ( ;b != e; b++ ) {

    (*b).second->proxy()->loadMore( visitor );

    edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType( (*b).first ) );
    if( recordKey.type() != edm::eventsetup::EventSetupRecordKey::TypeTag() ) {
      findingRecordWithKey( recordKey );
      usingRecordWithKey( recordKey );
    }
  }

  m_stats.nData=m_proxies.size();

}
CondDBESSource::~CondDBESSource ( )

Definition at line 245 of file CondDBESSource.cc.

References b, gather_cfg::cout, alignCSCRings::e, cond::BasePayloadProxy::gstats, m_doDump, m_proxies, m_stats, CondDBESSource::Stats::nActualReconnect, CondDBESSource::Stats::nActualRefresh, CondDBESSource::Stats::nData, CondDBESSource::Stats::nLumi, CondDBESSource::Stats::nReconnect, CondDBESSource::Stats::nRefresh, CondDBESSource::Stats::nRun, and CondDBESSource::Stats::nSet.

                                {
  //dump info FIXME: find a more suitable place...
  if (m_doDump) {
    std::cout << "CondDBESSource Statistics" << std::endl
              << "DataProxy " << m_stats.nData
              << " setInterval " << m_stats.nSet
              << " Runs " << m_stats.nRun
              << " Lumis " << m_stats.nLumi
              << " Refresh " << m_stats.nRefresh
              << " Actual Refresh " << m_stats.nActualRefresh
              << " Reconnect " << m_stats.nReconnect
              << " Actual Reconnect " << m_stats.nActualReconnect;
    std::cout << std::endl;
    std::cout << "Global Proxy Statistics" << std::endl
              << "proxy " << cond::BasePayloadProxy::gstats.nProxy
              << " make " << cond::BasePayloadProxy::gstats.nMake
              << " load " << cond::BasePayloadProxy::gstats.nLoad;
    std::cout << std::endl;


    ProxyMap::iterator b= m_proxies.begin();
    ProxyMap::iterator e= m_proxies.end();
    for ( ;b != e; b++ ) {
      dumpInfo( std::cout, (*b).first, *(*b).second );
      std::cout << "\n" << std::endl;
    }

    // FIXME
    // We shall eventually close transaction and session...
  }
}

Member Function Documentation

void CondDBESSource::fillTagCollectionFromDB ( const std::string &  coraldb,
const std::string &  prefix,
const std::string &  postfix,
const std::string &  roottag,
std::map< std::string, cond::TagMetadata > &  replacement 
) [private]

Definition at line 523 of file CondDBESSource.cc.

References cond::Auth::COND_READER_ROLE, cond::DbConnection::createSession(), NewTree::fid, cond::TagCollectionRetriever::getTagCollection(), cond::TagMetadata::labelname, m_connection, m_tagCollection, cond::TagMetadata::objectname, cond::DbSession::open(), cond::TagMetadata::pfn, cond::TagMetadata::recordname, python::CommonUtils::session, cond::TagMetadata::tag, and cond::DbSession::transaction().

Referenced by CondDBESSource().

                                                                                          {

  std::set< cond::TagMetadata > tagcoll;
 
 if ( !roottag.empty() ) {
   if ( coraldb.empty() ) 
     throw cond::Exception( std::string( "ESSource: requested global tag ") + roottag + std::string( " but not connection string given" ) );
   cond::DbSession session = m_connection.createSession();
   session.open( coraldb, cond::Auth::COND_READER_ROLE, true );
   session.transaction().start( true );
   cond::TagCollectionRetriever tagRetriever( session, prefix, postfix );
   tagRetriever.getTagCollection( roottag,tagcoll );
   session.transaction().commit();
  } 

  std::set<cond::TagMetadata>::iterator tagCollIter;
  std::set<cond::TagMetadata>::iterator tagCollBegin = tagcoll.begin();
  std::set<cond::TagMetadata>::iterator tagCollEnd = tagcoll.end();

  // FIXME the logic is a bit perverse: can be surely linearized (at least simplified!) ....
  for( tagCollIter = tagCollBegin; tagCollIter != tagCollEnd; ++tagCollIter ) {
    std::string recordLabelKey = joinRecordAndLabel( tagCollIter->recordname, tagCollIter->labelname );
    std::map<std::string,cond::TagMetadata>::iterator fid = replacement.find( recordLabelKey );
    if( fid != replacement.end() ) {
      cond::TagMetadata tagMetadata;
      tagMetadata.recordname = tagCollIter->recordname;
      tagMetadata.labelname = tagCollIter->labelname;
      tagMetadata.pfn = fid->second.pfn;
      tagMetadata.tag = fid->second.tag;
      tagMetadata.objectname = tagCollIter->objectname;
      m_tagCollection.insert( std::make_pair( recordLabelKey, tagMetadata ) );
      replacement.erase( fid );
      edm::LogInfo( "CondDBESSource" ) << "Replacing connection string \"" << tagCollIter->pfn
                                       << "\" and tag \"" << tagCollIter->tag
                                       << "\" for record \"" << tagMetadata.recordname
                                       << "\" and label \"" << tagMetadata.labelname
                                       << "\" with connection string \"" << tagMetadata.pfn
                                       << "\" and tag " << tagMetadata.tag
                                       << "\"; from CondDBESSource::fillTagCollectionFromDB";
    } else {
      m_tagCollection.insert( std::make_pair( recordLabelKey, *tagCollIter) );
    }
  }
  std::map<std::string,cond::TagMetadata>::iterator replacementIter;
  std::map<std::string,cond::TagMetadata>::iterator replacementBegin = replacement.begin();
  std::map<std::string,cond::TagMetadata>::iterator replacementEnd = replacement.end();
  for( replacementIter = replacementBegin; replacementIter != replacementEnd; ++replacementIter ){
    //std::cout<<"appending"<<std::endl;
    //std::cout<<"pfn "<<replacementIter->second.pfn<<std::endl;
    //std::cout<<"objectname "<<replacementIter->second.objectname<<std::endl;
    //std::cout<<"tag "<<replacementIter->second.tag<<std::endl;
    //std::cout<<"recordname "<<replacementIter->second.recordname<<std::endl;
    m_tagCollection.insert( *replacementIter );
  }
}
void CondDBESSource::newInterval ( const edm::eventsetup::EventSetupRecordKey iRecordType,
const edm::ValidityInterval iInterval 
) [protected, virtual]

called when a new interval of validity occurs for iRecordType

Implements edm::eventsetup::DataProxyProvider.

Definition at line 513 of file CondDBESSource.cc.

References edm::eventsetup::DataProxyProvider::invalidateProxies().

{
  //LogDebug ("CondDBESSource")<<"newInterval";
  invalidateProxies(iRecordType);
}
void CondDBESSource::registerProxies ( const edm::eventsetup::EventSetupRecordKey iRecordKey,
KeyedProxies aProxyList 
) [protected, virtual]

Implements edm::eventsetup::DataProxyProvider.

Definition at line 491 of file CondDBESSource.cc.

References b, alignCSCRings::e, combine::key, m_proxies, edm::eventsetup::EventSetupRecordKey::name(), and AlCaHLTBitMon_ParallelJobs::p.

                                                                                                             {
  std::string recordname=iRecordKey.name();

  ProxyMap::const_iterator b = m_proxies.lower_bound(recordname);
  ProxyMap::const_iterator e = m_proxies.upper_bound(recordname);
  if ( b == e) {
    edm::LogInfo( "CondDBESSource" ) << "No DataProxy (Pluging) found for record \""<< recordname
                                     << "\"; from CondDBESSource::registerProxies";
    return;
  }

  for (ProxyMap::const_iterator p=b;p!=e;++p) {  
    if(0 != (*p).second.get()) {
      edm::eventsetup::TypeTag type =  (*p).second->type(); 
      edm::eventsetup::DataKey key( type, edm::eventsetup::IdTags((*p).second->label().c_str()) );
      aProxyList.push_back(KeyedProxies::value_type(key,(*p).second->edmProxy()));
    }
  }
}
void CondDBESSource::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey iKey,
const edm::IOVSyncValue iTime,
edm::ValidityInterval oInterval 
) [protected, virtual]

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 283 of file CondDBESSource.cc.

References cond::DbConnection::createSession(), edm::IOVSyncValue::eventID(), edm::ValidityInterval::first(), cond::fromIOVSyncValue(), edm::ValidityInterval::invalidInterval(), edm::ValidityInterval::last(), cond::limitedIOVSyncValue(), edm::IOVSyncValue::luminosityBlockNumber(), m_connection, m_lastLumi, m_lastRecordRuns, m_lastRun, m_policy, m_proxies, m_sessionPool, m_stats, m_tagCollection, max(), min, CondDBESSource::Stats::nActualReconnect, CondDBESSource::Stats::nActualRefresh, edm::eventsetup::EventSetupRecordKey::name(), CondDBESSource::Stats::nLumi, CondDBESSource::Stats::nReconnect, CondDBESSource::Stats::nRefresh, CondDBESSource::Stats::nRun, CondDBESSource::Stats::nSet, cond::DbSession::openReadOnly(), RECONNECT_EACH_RUN, REFRESH_ALWAYS, REFRESH_EACH_RUN, REFRESH_OPEN_IOVS, errorMatrix2Lands_multiChannel::start, edm::IOVSyncValue::time(), cond::TIMELIMIT(), dtNoiseCalibration_cfg::timetype, cond::timeTypeNames(), cond::timeTypeSpecs, and cond::toIOVSyncValue().

                                                                                                                                          {

  std::string recordname=iKey.name();
  
  edm::LogInfo( "CondDBESSource" ) << "Getting data for record \""<< recordname
                                   << "\" to be consumed by "<< iTime.eventID() << ", timestamp: " << iTime.time().value()
                                   << "; from CondDBESSource::setIntervalFor";
  
  m_stats.nSet++;
  //{
    // not really required, keep here for the time being
    if(iTime.eventID().run()!=m_lastRun) {
      m_lastRun=iTime.eventID().run();
      m_stats.nRun++;
    }
    if(iTime.luminosityBlockNumber()!=m_lastLumi) {
      m_lastLumi=iTime.luminosityBlockNumber();
      m_stats.nLumi++;
    }
    //}
 
  bool doRefresh = false;
  if( m_policy == REFRESH_EACH_RUN || m_policy == RECONNECT_EACH_RUN ) {
    // find out the last run number for the proxy of the specified record
    std::map<std::string,unsigned int>::iterator iRec = m_lastRecordRuns.find( recordname );
    if( iRec != m_lastRecordRuns.end() ){
      unsigned int lastRecordRun = iRec->second;
      if( lastRecordRun != m_lastRun ){
        // a refresh is required!
        doRefresh = true;
        iRec->second = m_lastRun;
        edm::LogInfo( "CondDBESSource" ) << "Preparing refresh for record \"" << recordname 
                                         << "\" since there has been a transition from run "
                                         << lastRecordRun << " to run " << m_lastRun
                                         << "; from CondDBESSource::setIntervalFor";
      }
    } else {
      doRefresh = true;
      m_lastRecordRuns.insert( std::make_pair( recordname, m_lastRun ) );
      edm::LogInfo( "CondDBESSource" ) << "Preparing refresh for record \"" << recordname 
                                       << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value()
                                       << "; from CondDBESSource::setIntervalFor";
    }
    if ( !doRefresh )
      edm::LogInfo( "CondDBESSource" ) << "Though enabled, refresh not needed for record \"" << recordname 
                                       << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value()
                                       << "; from CondDBESSource::setIntervalFor";
  } else if( m_policy == REFRESH_ALWAYS || m_policy == REFRESH_OPEN_IOVS ) {
    doRefresh = true;
    edm::LogInfo( "CondDBESSource" ) << "Forcing refresh for record \"" << recordname 
                                     << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value()
                                     << "; from CondDBESSource::setIntervalFor";
  }

  oInterval = edm::ValidityInterval::invalidInterval();

  // compute the smallest interval (assume all objects have the same timetype....)                                                                                                          
  cond::ValidityInterval recordValidity(1,cond::TIMELIMIT);
  cond::TimeType timetype;
  bool userTime=true;

 //FIXME use equal_range
  ProxyMap::const_iterator pmBegin = m_proxies.lower_bound(recordname);
  ProxyMap::const_iterator pmEnd = m_proxies.upper_bound(recordname);
  if ( pmBegin == pmEnd ) {
    edm::LogInfo( "CondDBESSource" ) << "No DataProxy (Pluging) found for record \""<< recordname
                                     << "\"; from CondDBESSource::setIntervalFor";
    return;
  }
  
  for ( ProxyMap::const_iterator pmIter = pmBegin; pmIter != pmEnd; ++pmIter ) {

    edm::LogInfo( "CondDBESSource" ) << "Processing record \"" << recordname
                                     << "\" and label \""<< pmIter->second->label()
                                     << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value()
                                     << "; from CondDBESSource::setIntervalFor";

    timetype = (*pmIter).second->proxy()->timetype();
    
    cond::Time_t abtime = cond::fromIOVSyncValue( iTime, timetype );
    userTime = ( 0 == abtime );
    
    //std::cout<<"abtime "<<abtime<<std::endl;

    if (userTime) return; //  oInterval invalid to avoid that make is called...


    
    if( doRefresh ) {

      std::string recKey = joinRecordAndLabel( recordname, pmIter->second->label() );
      TagCollection::const_iterator tcIter = m_tagCollection.find( recKey ); 
      if ( tcIter == m_tagCollection.end() ) {
        edm::LogInfo( "CondDBESSource" ) << "No Tag found for record \""<< recordname
                                         << "\" and label \""<< pmIter->second->label()
                                         << "\"; from CondDBESSource::setIntervalFor";
        return;
      }

      // first reconnect if required
      if( m_policy == RECONNECT_EACH_RUN ) {
        edm::LogInfo( "CondDBESSource" ) << "Checking if the session must be closed and re-opened for getting correct conditions"
                                         << "; from CondDBESSource::setIntervalFor";
        std::stringstream transId;
        //transId << "long" << m_lastRun;
        transId << m_lastRun;
        std::map<std::string,std::pair<cond::DbSession,std::string> >::iterator iSess = m_sessionPool.find( tcIter->second.pfn );
        cond::DbSession theSession;
        bool reopen = false;
        if( iSess != m_sessionPool.end() ){
          if( iSess->second.second != transId.str() ) {
            // the available session is open for a different run: reopen
            reopen = true;
            iSess->second.second = transId.str();
          }
          theSession = iSess->second.first;
        } else {
          // no available session: probably first run analysed... 
          theSession = m_connection.createSession(); 
          m_sessionPool.insert(std::make_pair( tcIter->second.pfn,std::make_pair(theSession,transId.str()) )); 
          reopen = true;
        } 
        if( reopen ){
          theSession.openReadOnly( tcIter->second.pfn, transId.str() );
          edm::LogInfo( "CondDBESSource" ) << "Re-opening the session with connection string " << tcIter->second.pfn
                                           << " and new transaction Id " <<  transId.str()
                                           << "; from CondDBESSource::setIntervalFor";
        }
        
        edm::LogInfo( "CondDBESSource" ) << "Reconnecting to \"" << tcIter->second.pfn
                                         << "\" for getting new payload for record \"" << recordname 
                                         << "\" and label \""<< pmIter->second->label()
                                         << "\" from IOV tag \"" << tcIter->second.tag
                                         << "\" to be consumed by " << iTime.eventID() << ", timestamp: " << iTime.time().value()
                                         << "; from CondDBESSource::setIntervalFor";
        bool isSizeIncreased = pmIter->second->proxy()->refresh( theSession );
        if( isSizeIncreased )
          edm::LogInfo( "CondDBESSource" ) << "After reconnecting, an increased size of the IOV sequence labeled by tag \"" << tcIter->second.tag
                                           << "\" was found; from CondDBESSource::setIntervalFor";
        m_stats.nActualReconnect += isSizeIncreased;
        m_stats.nReconnect++;
      } else {
        edm::LogInfo( "CondDBESSource" ) << "Refreshing IOV sequence labeled by tag \"" << tcIter->second.tag
                                         << "\" for getting new payload for record \"" << recordname
                                         << "\" and label \""<< pmIter->second->label()
                                         << "\" to be consumed by " << iTime.eventID() << ", timestamp: " << iTime.time().value()
                                         << "; from CondDBESSource::setIntervalFor";
        bool isSizeIncreased = pmIter->second->proxy()->refresh();
        if( isSizeIncreased )
          edm::LogInfo( "CondDBESSource" ) << "After refreshing, an increased size of the IOV sequence labeled by tag \"" << tcIter->second.tag
                                           << "\" was found; from CondDBESSource::setIntervalFor";
        m_stats.nActualRefresh += isSizeIncreased;
        m_stats.nRefresh++;
      }

    }

    /*
      // make oInterval valid For Ever
    {
     oInterval = edm::ValidityInterval(cond::toIOVSyncValue(recordValidity.first,  cond::runnumber, true), 
                                       cond::toIOVSyncValue(recordValidity.second, cond::runnumber, false));
     return;
    }    
    */

    //query the IOVSequence
    cond::ValidityInterval validity = (*pmIter).second->proxy()->setIntervalFor( abtime );
    
    edm::LogInfo( "CondDBESSource" ) << "Validity coming from IOV sequence for record \"" << recordname
                                     << "\" and label \""<< pmIter->second->label()
                                     << "\": (" << validity.first << ", " << validity.second
                                     << ") for time (type: "<< cond::timeTypeNames( timetype ) << ") " << abtime
                                     << "; from CondDBESSource::setIntervalFor";
    
    recordValidity.first = std::max(recordValidity.first,validity.first);
    recordValidity.second = std::min(recordValidity.second,validity.second);
  }      
  
  if( m_policy == REFRESH_OPEN_IOVS ) {
    doRefresh = ( recordValidity.second == cond::timeTypeSpecs[timetype].endValue );
    edm::LogInfo( "CondDBESSource" ) << "Validity for record \"" << recordname
                                     << "\" and the corresponding label(s) coming from Condition DB: (" << recordValidity.first 
                                     << ", "<< recordValidity.first 
                                     << ") as the last IOV element in the IOV sequence is infinity"
                                     << "; from CondDBESSource::setIntervalFor";
  }
  
  // to force refresh we set end-value to the minimum such an IOV can extend to: current run or lumiblock
    
  if ( (!userTime) && recordValidity.second !=0 ) {
    edm::IOVSyncValue start = cond::toIOVSyncValue(recordValidity.first, timetype, true);
    edm::IOVSyncValue stop = doRefresh  ? cond::limitedIOVSyncValue (iTime, timetype)
      : cond::toIOVSyncValue(recordValidity.second, timetype, false);
       
    oInterval = edm::ValidityInterval( start, stop );
   }
  
  edm::LogInfo( "CondDBESSource" ) << "Setting validity for record \"" << recordname 
                                   << "\" and corresponding label(s): starting at " << oInterval.first().eventID() << ", timestamp: " << oInterval.first().time().value()
                                   << ", ending at "<< oInterval.last().eventID() << ", timestamp: " << oInterval.last().time().value()
                                   << ", for "<< iTime.eventID() << ", timestamp: " << iTime.time().value()
                                   << "; from CondDBESSource::setIntervalFor";
}

Member Data Documentation

Definition at line 59 of file CondDBESSource.h.

Referenced by CondDBESSource(), fillTagCollectionFromDB(), and setIntervalFor().

bool CondDBESSource::m_doDump [private]

Definition at line 88 of file CondDBESSource.h.

Referenced by ~CondDBESSource().

unsigned int CondDBESSource::m_lastLumi [private]

Definition at line 85 of file CondDBESSource.h.

Referenced by setIntervalFor().

std::map<std::string,unsigned int> CondDBESSource::m_lastRecordRuns [private]

Definition at line 69 of file CondDBESSource.h.

Referenced by setIntervalFor().

unsigned int CondDBESSource::m_lastRun [private]

Definition at line 84 of file CondDBESSource.h.

Referenced by setIntervalFor().

Definition at line 86 of file CondDBESSource.h.

Referenced by CondDBESSource(), and setIntervalFor().

Definition at line 62 of file CondDBESSource.h.

Referenced by CondDBESSource(), registerProxies(), setIntervalFor(), and ~CondDBESSource().

std::map<std::string,std::pair<cond::DbSession,std::string> > CondDBESSource::m_sessionPool [private]

Definition at line 68 of file CondDBESSource.h.

Referenced by setIntervalFor().

Definition at line 82 of file CondDBESSource.h.

Referenced by CondDBESSource(), setIntervalFor(), and ~CondDBESSource().

Definition at line 67 of file CondDBESSource.h.

Referenced by CondDBESSource(), fillTagCollectionFromDB(), and setIntervalFor().