CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

edm::PrincipalCache Class Reference

#include <PrincipalCache.h>

List of all members.

Public Member Functions

void adjustEventToNewProductRegistry (boost::shared_ptr< ProductRegistry const > reg)
void adjustIndexesAfterProductRegistryAddition ()
void deleteLowestLumi ()
void deleteLowestRun ()
void deleteLumi (ProcessHistoryID const &phid, int run, int lumi)
void deleteRun (ProcessHistoryID const &phid, int run)
EventPrincipal const & eventPrincipal () const
EventPrincipaleventPrincipal ()
bool insert (boost::shared_ptr< RunPrincipal > rp)
bool insert (boost::shared_ptr< LuminosityBlockPrincipal > lbp)
void insert (boost::shared_ptr< EventPrincipal > ep)
LuminosityBlockPrincipal const & lowestLumi () const
RunPrincipal const & lowestRun () const
LuminosityBlockPrincipal const & lumiPrincipal (ProcessHistoryID const &phid, int run, int lumi) const
LuminosityBlockPrincipallumiPrincipal (ProcessHistoryID const &phid, int run, int lumi)
LuminosityBlockPrincipal const & lumiPrincipal () const
LuminosityBlockPrincipallumiPrincipal ()
boost::shared_ptr
< LuminosityBlockPrincipal
lumiPrincipalPtr (ProcessHistoryID const &phid, int run, int lumi)
boost::shared_ptr
< LuminosityBlockPrincipal
lumiPrincipalPtr ()
bool merge (boost::shared_ptr< RunAuxiliary > aux, boost::shared_ptr< ProductRegistry const > reg)
bool merge (boost::shared_ptr< LuminosityBlockAuxiliary > aux, boost::shared_ptr< ProductRegistry const > reg)
bool noMoreLumis ()
bool noMoreRuns ()
 PrincipalCache ()
RunPrincipal const & runPrincipal (ProcessHistoryID const &phid, int run) const
RunPrincipal const & runPrincipal () const
RunPrincipalrunPrincipal (ProcessHistoryID const &phid, int run)
RunPrincipalrunPrincipal ()
boost::shared_ptr< RunPrincipalrunPrincipalPtr (ProcessHistoryID const &phid, int run)
boost::shared_ptr< RunPrincipalrunPrincipalPtr ()
 ~PrincipalCache ()

Private Types

typedef std::map< LumiKey,
boost::shared_ptr
< LuminosityBlockPrincipal >
>::const_iterator 
ConstLumiIterator
typedef std::map< RunKey,
boost::shared_ptr
< RunPrincipal >
>::const_iterator 
ConstRunIterator
typedef std::map< LumiKey,
boost::shared_ptr
< LuminosityBlockPrincipal >
>::iterator 
LumiIterator
typedef std::map< RunKey,
boost::shared_ptr
< RunPrincipal > >::iterator 
RunIterator

Private Attributes

boost::shared_ptr
< LuminosityBlockPrincipal
currentLumiPrincipal_
boost::shared_ptr< RunPrincipalcurrentRunPrincipal_
boost::shared_ptr< EventPrincipaleventPrincipal_
std::map< LumiKey,
boost::shared_ptr
< LuminosityBlockPrincipal > > 
lumiPrincipals_
std::vector< ProcessHistoryIDprocessHistoryIDs_
std::map< ProcessHistoryID, int > processHistoryIDsMap_
std::map< RunKey,
boost::shared_ptr
< RunPrincipal > > 
runPrincipals_

Detailed Description

Definition at line 64 of file PrincipalCache.h.


Member Typedef Documentation

typedef std::map<LumiKey, boost::shared_ptr<LuminosityBlockPrincipal> >::const_iterator edm::PrincipalCache::ConstLumiIterator [private]

Definition at line 123 of file PrincipalCache.h.

typedef std::map<RunKey, boost::shared_ptr<RunPrincipal> >::const_iterator edm::PrincipalCache::ConstRunIterator [private]

Definition at line 121 of file PrincipalCache.h.

typedef std::map<LumiKey, boost::shared_ptr<LuminosityBlockPrincipal> >::iterator edm::PrincipalCache::LumiIterator [private]

Definition at line 122 of file PrincipalCache.h.

typedef std::map<RunKey, boost::shared_ptr<RunPrincipal> >::iterator edm::PrincipalCache::RunIterator [private]

Definition at line 120 of file PrincipalCache.h.


Constructor & Destructor Documentation

edm::PrincipalCache::PrincipalCache ( )

Definition at line 9 of file PrincipalCache.cc.

{ }
edm::PrincipalCache::~PrincipalCache ( )

Definition at line 11 of file PrincipalCache.cc.

{ }

Member Function Documentation

void edm::PrincipalCache::adjustEventToNewProductRegistry ( boost::shared_ptr< ProductRegistry const >  reg)

Definition at line 281 of file PrincipalCache.cc.

References eventPrincipal_.

Referenced by edm::StreamerInputSource::deserializeAndMergeWithRegistry(), edm::RootInputFileSequence::nextFile(), and edm::RootInputFileSequence::previousFile().

                                                                                                 {
    if (eventPrincipal_) {
      eventPrincipal_->adjustIndexesAfterProductRegistryAddition();
      bool eventOK = eventPrincipal_->adjustToNewProductRegistry(*reg);
      assert(eventOK);
    }
  }
void edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 289 of file PrincipalCache.cc.

References lumiPrincipals_, and runPrincipals_.

Referenced by edm::RootInputFileSequence::nextFile(), and edm::RootInputFileSequence::previousFile().

                                                                 {
    for (ConstRunIterator it = runPrincipals_.begin(), itEnd = runPrincipals_.end(); it != itEnd; ++it) {
      it->second->adjustIndexesAfterProductRegistryAddition();
    }
    for (ConstLumiIterator it = lumiPrincipals_.begin(), itEnd = lumiPrincipals_.end(); it != itEnd; ++it) {
      it->second->adjustIndexesAfterProductRegistryAddition();
    }
  }
void edm::PrincipalCache::deleteLowestLumi ( )

Definition at line 263 of file PrincipalCache.cc.

References lumiPrincipals_.

                                        {
    lumiPrincipals_.erase(lumiPrincipals_.begin());
  }
void edm::PrincipalCache::deleteLowestRun ( )

Definition at line 259 of file PrincipalCache.cc.

References runPrincipals_.

                                       {
    runPrincipals_.erase(runPrincipals_.begin());
  }
void edm::PrincipalCache::deleteLumi ( ProcessHistoryID const &  phid,
int  run,
int  lumi 
)

Definition at line 274 of file PrincipalCache.cc.

References combine::key, lumiPrincipals_, and processHistoryIDsMap_.

Referenced by edm::EventProcessor::deleteLumiFromCache().

                                                                                 {
    LumiKey key(processHistoryIDsMap_[phid], run, lumi);
    LumiIterator iter = lumiPrincipals_.find(key);
    assert(iter != lumiPrincipals_.end());
    lumiPrincipals_.erase(iter);
  }
void edm::PrincipalCache::deleteRun ( ProcessHistoryID const &  phid,
int  run 
)

Definition at line 267 of file PrincipalCache.cc.

References combine::key, processHistoryIDsMap_, and runPrincipals_.

Referenced by edm::EventProcessor::deleteRunFromCache().

                                                                      {
    RunKey key(processHistoryIDsMap_[phid], run);
    RunIterator iter = runPrincipals_.find(key);
    assert(iter != runPrincipals_.end());
    runPrincipals_.erase(iter);
  }
EventPrincipal const& edm::PrincipalCache::eventPrincipal ( ) const [inline]

Definition at line 90 of file PrincipalCache.h.

References eventPrincipal_.

{return *eventPrincipal_;}
EventPrincipal& edm::PrincipalCache::eventPrincipal ( ) [inline]

Definition at line 89 of file PrincipalCache.h.

References eventPrincipal_.

Referenced by edm::InputSource::eventPrincipalCache().

{return *eventPrincipal_;}
bool edm::PrincipalCache::insert ( boost::shared_ptr< RunPrincipal rp)

Definition at line 208 of file PrincipalCache.cc.

References currentRunPrincipal_, combine::key, processHistoryIDs_, processHistoryIDsMap_, CrabTask::run, and runPrincipals_.

Referenced by edm::InputSource::readAndCacheLumi(), edm::InputSource::readAndCacheRun(), and edm::EventProcessor::runCommon().

                                                              {
    ProcessHistoryID phid = rp->aux().processHistoryID();
    int run = rp->run();
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    if (iphid == processHistoryIDsMap_.end()) {
      processHistoryIDsMap_[phid] = processHistoryIDs_.size();
      processHistoryIDs_.push_back(phid);
      iphid = processHistoryIDsMap_.find(phid);
    }
    RunKey key(iphid->second, run);
    assert(runPrincipals_.find(key) == runPrincipals_.end());
    runPrincipals_[key] = rp;
    currentRunPrincipal_ = rp;
    return true;
  }
bool edm::PrincipalCache::insert ( boost::shared_ptr< LuminosityBlockPrincipal lbp)

Definition at line 224 of file PrincipalCache.cc.

References currentLumiPrincipal_, combine::key, fjr2json::lumi, lumiPrincipals_, processHistoryIDs_, processHistoryIDsMap_, and CrabTask::run.

                                                                           {
    ProcessHistoryID phid = lbp->aux().processHistoryID();
    int run = lbp->run();
    int lumi = lbp->luminosityBlock();
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    if (iphid == processHistoryIDsMap_.end()) {
      processHistoryIDsMap_[phid] = processHistoryIDs_.size();
      processHistoryIDs_.push_back(phid);
      iphid = processHistoryIDsMap_.find(phid);
    }
    LumiKey key(iphid->second, run, lumi);
    assert(lumiPrincipals_.find(key) == lumiPrincipals_.end());
    lumiPrincipals_[key] = lbp;
    currentLumiPrincipal_ = lbp;
    return true;
  }
void edm::PrincipalCache::insert ( boost::shared_ptr< EventPrincipal ep) [inline]

Definition at line 97 of file PrincipalCache.h.

References eventPrincipal_.

LuminosityBlockPrincipal const & edm::PrincipalCache::lowestLumi ( ) const

Definition at line 254 of file PrincipalCache.cc.

References lumiPrincipals_.

                                                                   {
    ConstLumiIterator iter = lumiPrincipals_.begin();
    return *iter->second.get();
  }
RunPrincipal const & edm::PrincipalCache::lowestRun ( ) const

Definition at line 249 of file PrincipalCache.cc.

References runPrincipals_.

                                                      {
    ConstRunIterator iter = runPrincipals_.begin();
    return *iter->second.get();
  }
LuminosityBlockPrincipal const & edm::PrincipalCache::lumiPrincipal ( ) const

Definition at line 149 of file PrincipalCache.cc.

References currentLumiPrincipal_, Exception, and edm::errors::LogicError.

                                                                      {
    if (currentLumiPrincipal_.get() == 0) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::lumiPrincipal\n"
        << "Requested current lumi and it is not initialized (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return *currentLumiPrincipal_.get();
  }
LuminosityBlockPrincipal const & edm::PrincipalCache::lumiPrincipal ( ProcessHistoryID const &  phid,
int  run,
int  lumi 
) const

Definition at line 107 of file PrincipalCache.cc.

References Exception, combine::key, edm::errors::LogicError, lumiPrincipals_, and processHistoryIDsMap_.

                                                                                                                     {
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    ConstLumiIterator iter;
    if (iphid != processHistoryIDsMap_.end()) {
      LumiKey key(iphid->second, run, lumi);
      iter = lumiPrincipals_.find(key);
    }
    if (iphid == processHistoryIDsMap_.end() || iter == lumiPrincipals_.end()) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::lumiPrincipal\n"
        << "Requested a lumi that is not in the cache (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return *iter->second.get();
  }
LuminosityBlockPrincipal & edm::PrincipalCache::lumiPrincipal ( )

Definition at line 139 of file PrincipalCache.cc.

References currentLumiPrincipal_, Exception, and edm::errors::LogicError.

                                                           {
    if (currentLumiPrincipal_.get() == 0) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::lumiPrincipal\n"
        << "Requested current lumi and it is not initialized (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return *currentLumiPrincipal_.get();
  }
LuminosityBlockPrincipal & edm::PrincipalCache::lumiPrincipal ( ProcessHistoryID const &  phid,
int  run,
int  lumi 
)

Definition at line 91 of file PrincipalCache.cc.

References Exception, combine::key, edm::errors::LogicError, lumiPrincipals_, and processHistoryIDsMap_.

Referenced by edm::EventProcessor::beginLumi(), edm::EventProcessor::endLumi(), edm::InputSource::markLumi(), and edm::EventProcessor::writeLumi().

                                                                                                          {
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    LumiIterator iter;
    if (iphid != processHistoryIDsMap_.end()) {
      LumiKey key(iphid->second, run, lumi);
      iter = lumiPrincipals_.find(key);
    }
    if (iphid == processHistoryIDsMap_.end() || iter == lumiPrincipals_.end()) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::lumiPrincipal\n"
        << "Requested a lumi that is not in the cache (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return *iter->second.get();
  }
boost::shared_ptr< LuminosityBlockPrincipal > edm::PrincipalCache::lumiPrincipalPtr ( ProcessHistoryID const &  phid,
int  run,
int  lumi 
)

Definition at line 123 of file PrincipalCache.cc.

References Exception, combine::key, edm::errors::LogicError, lumiPrincipals_, and processHistoryIDsMap_.

Referenced by edm::InputSource::luminosityBlockPrincipal(), edm::InputSource::readAndCacheLumi(), and edm::EventProcessor::readAndProcessEvent().

                                                                                                                            {
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    LumiIterator iter;
    if (iphid != processHistoryIDsMap_.end()) {
      LumiKey key(iphid->second, run, lumi);
      iter = lumiPrincipals_.find(key);
    }
    if (iphid == processHistoryIDsMap_.end() || iter == lumiPrincipals_.end()) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::lumiPrincipalPtr\n"
        << "Requested a lumi that is not in the cache (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return iter->second;
  }
boost::shared_ptr< LuminosityBlockPrincipal > edm::PrincipalCache::lumiPrincipalPtr ( )

Definition at line 159 of file PrincipalCache.cc.

References currentLumiPrincipal_, Exception, and edm::errors::LogicError.

                                                                             {
    if (currentLumiPrincipal_.get() == 0) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::lumiPrincipalPtr\n"
        << "Requested current lumi and it is not initialized (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return currentLumiPrincipal_;
  }
bool edm::PrincipalCache::merge ( boost::shared_ptr< LuminosityBlockAuxiliary aux,
boost::shared_ptr< ProductRegistry const >  reg 
)

Definition at line 188 of file PrincipalCache.cc.

References currentLumiPrincipal_, combine::key, fjr2json::lumi, lumiPrincipals_, processHistoryIDsMap_, and CrabTask::run.

                                                                                                                      {
    ProcessHistoryID phid = aux->processHistoryID();
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    LumiIterator iter;
    if (iphid != processHistoryIDsMap_.end()) {
      int run = aux->run();
      int lumi = aux->luminosityBlock();
      LumiKey key(iphid->second, run, lumi);
      iter = lumiPrincipals_.find(key);
    }
    if (iphid == processHistoryIDsMap_.end() || iter == lumiPrincipals_.end()) {
      return false;
    }
    bool lumiOK = iter->second->adjustToNewProductRegistry(*reg);
    assert(lumiOK);
    iter->second->mergeAuxiliary(*aux);
    currentLumiPrincipal_ = iter->second;
    return true;
  }
bool edm::PrincipalCache::merge ( boost::shared_ptr< RunAuxiliary aux,
boost::shared_ptr< ProductRegistry const >  reg 
)

Definition at line 169 of file PrincipalCache.cc.

References currentRunPrincipal_, combine::key, processHistoryIDsMap_, CrabTask::run, and runPrincipals_.

Referenced by edm::InputSource::readAndCacheLumi(), and edm::InputSource::readAndCacheRun().

                                                                                                          {
    ProcessHistoryID phid = aux->processHistoryID();
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    RunIterator iter;
    if (iphid != processHistoryIDsMap_.end()) {
      int run = aux->run();
      RunKey key(iphid->second, run);
      iter = runPrincipals_.find(key);
    }
    if (iphid == processHistoryIDsMap_.end() || iter == runPrincipals_.end()) {
      return false;
    }
    bool runOK = iter->second->adjustToNewProductRegistry(*reg);
    assert(runOK);
    iter->second->mergeAuxiliary(*aux);
    currentRunPrincipal_ = iter->second;
    return true;
  }
bool edm::PrincipalCache::noMoreLumis ( )

Definition at line 245 of file PrincipalCache.cc.

References lumiPrincipals_.

                                   {
    return lumiPrincipals_.empty();
  }
bool edm::PrincipalCache::noMoreRuns ( )

Definition at line 241 of file PrincipalCache.cc.

References runPrincipals_.

                                  {
    return runPrincipals_.empty();
  }
RunPrincipal & edm::PrincipalCache::runPrincipal ( )

Definition at line 61 of file PrincipalCache.cc.

References currentRunPrincipal_, Exception, and edm::errors::LogicError.

                                              {
    if (currentRunPrincipal_.get() == 0) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::runPrincipal\n"
        << "Requested current run and it is not initialized (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return *currentRunPrincipal_.get();
  }
RunPrincipal & edm::PrincipalCache::runPrincipal ( ProcessHistoryID const &  phid,
int  run 
)

Definition at line 13 of file PrincipalCache.cc.

References Exception, combine::key, edm::errors::LogicError, processHistoryIDsMap_, and runPrincipals_.

Referenced by edm::EventProcessor::beginRun(), edm::EventProcessor::endRun(), edm::InputSource::markRun(), and edm::EventProcessor::writeRun().

                                                                                   {
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    RunIterator iter;
    if (iphid != processHistoryIDsMap_.end()) {
      RunKey key(iphid->second, run);
      iter = runPrincipals_.find(key);
    }
    if (iphid == processHistoryIDsMap_.end() || iter == runPrincipals_.end()) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::runPrincipal\n"
        << "Requested a run that is not in the cache (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return *iter->second.get();
  }
RunPrincipal const & edm::PrincipalCache::runPrincipal ( ProcessHistoryID const &  phid,
int  run 
) const

Definition at line 29 of file PrincipalCache.cc.

References Exception, combine::key, edm::errors::LogicError, processHistoryIDsMap_, and runPrincipals_.

                                                                                              {
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    ConstRunIterator iter;
    if (iphid != processHistoryIDsMap_.end()) {
      RunKey key(iphid->second, run);
      iter = runPrincipals_.find(key);
    }
    if (iphid == processHistoryIDsMap_.end() || iter == runPrincipals_.end()) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::runPrincipal\n"
        << "Requested a run that is not in the cache (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return *iter->second.get();
  }
RunPrincipal const & edm::PrincipalCache::runPrincipal ( ) const

Definition at line 71 of file PrincipalCache.cc.

References currentRunPrincipal_, Exception, and edm::errors::LogicError.

                                                         {
    if (currentRunPrincipal_.get() == 0) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::runPrincipal\n"
        << "Requested current run and it is not initialized (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return *currentRunPrincipal_.get();
  }
boost::shared_ptr< RunPrincipal > edm::PrincipalCache::runPrincipalPtr ( ProcessHistoryID const &  phid,
int  run 
)

Definition at line 45 of file PrincipalCache.cc.

References Exception, combine::key, edm::errors::LogicError, processHistoryIDsMap_, and runPrincipals_.

Referenced by edm::InputSource::readAndCacheLumi(), edm::InputSource::readAndCacheRun(), and edm::InputSource::runPrincipal().

                                                                                                     {
    std::map<ProcessHistoryID, int>::const_iterator iphid = processHistoryIDsMap_.find(phid);
    RunIterator iter;
    if (iphid != processHistoryIDsMap_.end()) {
      RunKey key(iphid->second, run);
      iter = runPrincipals_.find(key);
    }
    if (iphid == processHistoryIDsMap_.end() || iter == runPrincipals_.end()) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::runPrincipalPtr\n"
        << "Requested a run that is not in the cache (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return iter->second;
  }
boost::shared_ptr< RunPrincipal > edm::PrincipalCache::runPrincipalPtr ( )

Definition at line 81 of file PrincipalCache.cc.

References currentRunPrincipal_, Exception, and edm::errors::LogicError.

                                                                {
    if (currentRunPrincipal_.get() == 0) {
      throw edm::Exception(edm::errors::LogicError)
        << "PrincipalCache::runPrincipalPtr\n"
        << "Requested current run and it is not initialized (should never happen)\n"
        << "Contact a Framework Developer\n";
    }
    return currentRunPrincipal_;
  }

Member Data Documentation

Definition at line 130 of file PrincipalCache.h.

Referenced by insert(), lumiPrincipal(), lumiPrincipalPtr(), and merge().

Definition at line 129 of file PrincipalCache.h.

Referenced by insert(), merge(), runPrincipal(), and runPrincipalPtr().

Definition at line 128 of file PrincipalCache.h.

Referenced by adjustEventToNewProductRegistry(), eventPrincipal(), and insert().

std::map<LumiKey, boost::shared_ptr<LuminosityBlockPrincipal> > edm::PrincipalCache::lumiPrincipals_ [private]

Definition at line 117 of file PrincipalCache.h.

Referenced by insert().

std::map<RunKey, boost::shared_ptr<RunPrincipal> > edm::PrincipalCache::runPrincipals_ [private]