CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes

edm::EventPrincipal Class Reference

#include <EventPrincipal.h>

Inheritance diagram for edm::EventPrincipal:
edm::Principal edm::EDProductGetter

List of all members.

Public Types

typedef EventAuxiliary Auxiliary
typedef Principal Base
typedef Base::ConstGroupPtr ConstGroupPtr

Public Member Functions

EventAuxiliary const & aux () const
ProductID branchIDToProductID (BranchID const &bid) const
BranchListIndexes const & branchListIndexes () const
boost::shared_ptr< BranchMapperbranchMapperPtr () const
int bunchCrossing () const
void clearEventPrincipal ()
 EventPrincipal (boost::shared_ptr< ProductRegistry const > reg, ProcessConfiguration const &pc, HistoryAppender *historyAppender=0)
EventSelectionIDVector const & eventSelectionIDs () const
EventAuxiliary::ExperimentType ExperimentType () const
void fillEventPrincipal (EventAuxiliary const &aux, boost::shared_ptr< LuminosityBlockPrincipal > lbp, boost::shared_ptr< EventSelectionIDVector > eventSelectionIDs=boost::shared_ptr< EventSelectionIDVector >(), boost::shared_ptr< BranchListIndexes > branchListIndexes=boost::shared_ptr< BranchListIndexes >(), boost::shared_ptr< BranchMapper > mapper=boost::shared_ptr< BranchMapper >(new BranchMapper), DelayedReader *reader=0)
BasicHandle getByProductID (ProductID const &oid) const
WrapperHolder getIt (ProductID const &pid) const
Provenance getProvenance (ProductID const &pid) const
EventID const & id () const
bool isReal () const
LuminosityBlockNumber_t luminosityBlock () const
LuminosityBlockPrincipal const & luminosityBlockPrincipal () const
LuminosityBlockPrincipalluminosityBlockPrincipal ()
bool luminosityBlockPrincipalPtrValid ()
void mergeMappers (EventPrincipal const &other)
void put (ConstBranchDescription const &bd, WrapperOwningHolder const &edp, ProductProvenance const &productProvenance)
void putOnRead (ConstBranchDescription const &bd, void const *product, ProductProvenance const &productProvenance)
RunNumber_t run () const
RunPrincipal const & runPrincipal () const
RunPrincipalrunPrincipal ()
void setLuminosityBlockPrincipal (boost::shared_ptr< LuminosityBlockPrincipal > const &lbp)
void setUnscheduledHandler (boost::shared_ptr< UnscheduledHandler > iHandler)
int storeNumber () const
Timestamp const & time () const
boost::shared_ptr
< UnscheduledHandler
unscheduledHandler () const
 ~EventPrincipal ()

Static Public Attributes

static int const invalidBunchXing = EventAuxiliary::invalidBunchXing
static int const invalidStoreNumber = EventAuxiliary::invalidStoreNumber

Private Member Functions

BranchID pidToBid (ProductID const &pid) const
virtual void resolveProduct_ (Group const &g, bool fillOnDemand) const
virtual bool unscheduledFill (std::string const &moduleLabel) const

Private Attributes

EventAuxiliary aux_
boost::shared_ptr
< BranchListIndexes
branchListIndexes_
std::map< BranchListIndex,
ProcessIndex
branchListIndexToProcessIndex_
boost::shared_ptr< BranchMapperbranchMapperPtr_
boost::shared_ptr
< EventSelectionIDVector
eventSelectionIDs_
boost::shared_ptr
< LuminosityBlockPrincipal
luminosityBlockPrincipal_
std::vector< std::string > moduleLabelsRunning_
boost::shared_ptr
< UnscheduledHandler
unscheduledHandler_

Detailed Description

Definition at line 40 of file EventPrincipal.h.


Member Typedef Documentation

Definition at line 42 of file EventPrincipal.h.

Definition at line 43 of file EventPrincipal.h.

Reimplemented from edm::Principal.

Definition at line 45 of file EventPrincipal.h.


Constructor & Destructor Documentation

edm::EventPrincipal::EventPrincipal ( boost::shared_ptr< ProductRegistry const >  reg,
ProcessConfiguration const &  pc,
HistoryAppender historyAppender = 0 
)
edm::EventPrincipal::~EventPrincipal ( ) [inline]

Definition at line 52 of file EventPrincipal.h.

{}

Member Function Documentation

EventAuxiliary const& edm::EventPrincipal::aux ( ) const [inline]
ProductID edm::EventPrincipal::branchIDToProductID ( BranchID const &  bid) const

Definition at line 175 of file EventPrincipal.cc.

References branchListIndexToProcessIndex_, Exception, i, instance, edm::BranchID::isValid(), and edm::errors::NotFound.

Referenced by fillEventPrincipal(), and edm::Event::makeProductID().

                                                               {
    if(!bid.isValid()) {
      throw Exception(errors::NotFound, "InvalidID")
        << "branchIDToProductID: invalid BranchID supplied\n";
    }
    typedef BranchIDListHelper::BranchIDToIndexMap BIDToIndexMap;
    typedef BIDToIndexMap::const_iterator Iter;
    typedef std::pair<Iter, Iter> IndexRange;

    BIDToIndexMap const& branchIDToIndexMap = BranchIDListRegistry::instance()->extra().branchIDToIndexMap();
    IndexRange range = branchIDToIndexMap.equal_range(bid);
    for(Iter it = range.first; it != range.second; ++it) {
      BranchListIndex blix = it->second.first;
      std::map<BranchListIndex, ProcessIndex>::const_iterator i = branchListIndexToProcessIndex_.find(blix);
      if(i != branchListIndexToProcessIndex_.end()) {
        ProductIndex productIndex = it->second.second;
        ProcessIndex processIndex = i->second;
        return ProductID(processIndex+1, productIndex+1);
      }
    }
    // cannot throw, because some products may legitimately not have product ID's (e.g. pile-up).
    return ProductID();
  }
BranchListIndexes const & edm::EventPrincipal::branchListIndexes ( ) const
boost::shared_ptr<BranchMapper> edm::EventPrincipal::branchMapperPtr ( ) const [inline]
int edm::EventPrincipal::bunchCrossing ( ) const [inline]

Definition at line 93 of file EventPrincipal.h.

References aux(), and edm::EventAuxiliary::bunchCrossing().

                              {
      return aux().bunchCrossing();
    }
void edm::EventPrincipal::clearEventPrincipal ( )
EventSelectionIDVector const & edm::EventPrincipal::eventSelectionIDs ( ) const
EventAuxiliary::ExperimentType edm::EventPrincipal::ExperimentType ( ) const [inline]

Definition at line 89 of file EventPrincipal.h.

References aux(), and edm::EventAuxiliary::experimentType().

                                                        {
      return aux().experimentType();
    }
void edm::EventPrincipal::fillEventPrincipal ( EventAuxiliary const &  aux,
boost::shared_ptr< LuminosityBlockPrincipal lbp,
boost::shared_ptr< EventSelectionIDVector eventSelectionIDs = boost::shared_ptr<EventSelectionIDVector>(),
boost::shared_ptr< BranchListIndexes branchListIndexes = boost::shared_ptr<BranchListIndexes>(),
boost::shared_ptr< BranchMapper mapper = boost::shared_ptr<BranchMapper>(new BranchMapper),
DelayedReader reader = 0 
)

Definition at line 49 of file EventPrincipal.cc.

References aux(), aux_, edm::Principal::begin(), branchIDToProductID(), branchListIndexes(), branchListIndexes_, branchListIndexToProcessIndex_, branchMapperPtr(), branchMapperPtr_, edm::Principal::end(), eventSelectionIDs(), eventSelectionIDs_, edm::Principal::fillPrincipal(), edm::InEvent, luminosityBlockPrincipal_, edm::EventAuxiliary::processHistoryID(), edm::Principal::processHistoryID(), edm::Principal::productRegistry(), and edm::Principal::reader().

Referenced by edm::StreamerInputSource::deserializeEvent(), edm::RawInputSource::makeEvent(), edm::ConfigurableInputSource::reallyReadEvent(), and edm::SubProcess::write().

                               {
    fillPrincipal(aux.processHistoryID(), reader);
    aux_ = aux;
    luminosityBlockPrincipal_ = lbp;
    if(eventSelectionIDs) {
      eventSelectionIDs_ = eventSelectionIDs;
    }
    aux_.setProcessHistoryID(processHistoryID());

    branchMapperPtr_ = mapper;

    if(branchListIndexes) {
      branchListIndexes_ = branchListIndexes;
    }

    if(productRegistry().productProduced(InEvent)) {
      // Add index into BranchIDListRegistry for products produced this process
      branchListIndexes_->push_back(productRegistry().producedBranchListIndex());
    }

    // Fill in helper map for Branch to ProductID mapping
    for(BranchListIndexes::const_iterator
        it = branchListIndexes_->begin(),
        itEnd = branchListIndexes_->end();
        it != itEnd; ++it) {
      ProcessIndex pix = it - branchListIndexes_->begin();
      branchListIndexToProcessIndex_.insert(std::make_pair(*it, pix));
    }

    // Fill in the product ID's in the groups.
    for(const_iterator it = this->begin(), itEnd = this->end(); it != itEnd; ++it) {
      (*it)->setProvenance(branchMapperPtr(), processHistoryID(), branchIDToProductID((*it)->branchDescription().branchID()));
    }
  }
BasicHandle edm::EventPrincipal::getByProductID ( ProductID const &  oid) const

Definition at line 210 of file EventPrincipal.cc.

References Exception, g, edm::Principal::getGroup(), pidToBid(), edm::errors::ProductNotFound, and edm::throwProductDeletedException().

Referenced by edm::Event::getByProductID_(), and getIt().

                                                           {
    BranchID bid = pidToBid(pid);
    ConstGroupPtr const g = getGroup(bid, true, true);
    if(g == 0) {
      boost::shared_ptr<cms::Exception> whyFailed(new Exception(errors::ProductNotFound, "InvalidID"));
      *whyFailed
        << "get by product ID: no product with given id: " << pid << "\n";
      return BasicHandle(whyFailed);
    }

    // Was this already deleted?
    if(g->productWasDeleted()) {
      throwProductDeletedException(pid,g);
    }
    // Check for case where we tried on demand production and
    // it failed to produce the object
    if(g->onDemand()) {
      boost::shared_ptr<cms::Exception> whyFailed(new Exception(errors::ProductNotFound, "InvalidID"));
      *whyFailed
        << "get by product ID: no product with given id: " << pid << "\n"
        << "onDemand production failed to produce it.\n";
      return BasicHandle(whyFailed);
    }
    return BasicHandle(g->productData());
  }
WrapperHolder edm::EventPrincipal::getIt ( ProductID const &  pid) const [virtual]

Reimplemented from edm::Principal.

Definition at line 237 of file EventPrincipal.cc.

References getByProductID(), and edm::BasicHandle::wrapperHolder().

                                                  {
    return getByProductID(pid).wrapperHolder();
  }
Provenance edm::EventPrincipal::getProvenance ( ProductID const &  pid) const

Definition at line 242 of file EventPrincipal.cc.

References pidToBid().

Referenced by edm::Event::getProvenance(), and edm::RootOutputFile::insertAncestors().

                                                          {
    BranchID bid = pidToBid(pid);
    return getProvenance(bid);
  }
EventID const& edm::EventPrincipal::id ( void  ) const [inline]
bool edm::EventPrincipal::isReal ( ) const [inline]

Definition at line 85 of file EventPrincipal.h.

References aux(), and edm::EventAuxiliary::isRealData().

                        {
      return aux().isRealData();
    }
LuminosityBlockNumber_t edm::EventPrincipal::luminosityBlock ( ) const [inline]
LuminosityBlockPrincipal& edm::EventPrincipal::luminosityBlockPrincipal ( ) [inline]

Definition at line 67 of file EventPrincipal.h.

References luminosityBlockPrincipal_.

LuminosityBlockPrincipal const& edm::EventPrincipal::luminosityBlockPrincipal ( ) const [inline]

Definition at line 63 of file EventPrincipal.h.

References luminosityBlockPrincipal_.

Referenced by runPrincipal().

bool edm::EventPrincipal::luminosityBlockPrincipalPtrValid ( ) [inline]

Definition at line 71 of file EventPrincipal.h.

References luminosityBlockPrincipal_.

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

                                            {
      return (luminosityBlockPrincipal_) ? true : false;
    }
void edm::EventPrincipal::mergeMappers ( EventPrincipal const &  other) [inline]

Definition at line 146 of file EventPrincipal.h.

References branchMapperPtr(), and branchMapperPtr_.

Referenced by edm::PoolSource::readEvent_().

                                                   {
      branchMapperPtr_->mergeMappers(other.branchMapperPtr());
    }
BranchID edm::EventPrincipal::pidToBid ( ProductID const &  pid) const [private]
void edm::EventPrincipal::put ( ConstBranchDescription const &  bd,
WrapperOwningHolder const &  edp,
ProductProvenance const &  productProvenance 
)

Definition at line 105 of file EventPrincipal.cc.

References edm::ConstBranchDescription::branchID(), branchMapperPtr(), edm::Principal::checkUniquenessAndType(), Exception, g, edm::Principal::getExistingGroup(), edm::errors::InsertFailure, edm::WrapperHolder::isValid(), and edm::Group::putProduct().

Referenced by edm::Event::commit_aux().

                                                    {

    // assert commented out for DaqSource.  When DaqSource no longer uses put(), the assert can be restored.
    //assert(produced());
    if(!edp.isValid()) {
      throw Exception(errors::InsertFailure, "Null Pointer")
        << "put: Cannot put because ptr to product is null."
        << "\n";
    }
    branchMapperPtr()->insertIntoSet(productProvenance);
    Group* g = getExistingGroup(bd.branchID());
    assert(g);
    checkUniquenessAndType(edp, g);
    // Group assumes ownership
    g->putProduct(edp, productProvenance);
  }
void edm::EventPrincipal::putOnRead ( ConstBranchDescription const &  bd,
void const *  product,
ProductProvenance const &  productProvenance 
)

Definition at line 126 of file EventPrincipal.cc.

References edm::ConstBranchDescription::branchID(), branchMapperPtr(), edm::Principal::checkUniquenessAndType(), g, edm::Principal::getExistingGroup(), edm::ProductData::getInterface(), edm::ConstBranchDescription::produced(), edm::Group::productData(), and edm::Group::putProduct().

Referenced by edm::StreamerInputSource::deserializeEvent().

                                                    {

    assert(!bd.produced());
    branchMapperPtr()->insertIntoSet(productProvenance);
    Group* g = getExistingGroup(bd.branchID());
    assert(g);
    WrapperOwningHolder const edp(product, g->productData().getInterface());
    checkUniquenessAndType(edp, g);
    // Group assumes ownership
    g->putProduct(edp, productProvenance);
  }
void edm::EventPrincipal::resolveProduct_ ( Group const &  g,
bool  fillOnDemand 
) const [private, virtual]

Reimplemented from edm::Principal.

Definition at line 142 of file EventPrincipal.cc.

References edm::Group::branchDescription(), edm::Principal::checkUniquenessAndType(), edm::ProductData::getInterface(), edm::getProduct(), edm::ConstBranchDescription::moduleLabel(), edm::Group::onDemand(), edm::ConstBranchDescription::produced(), edm::Group::product(), edm::Group::productData(), edm::Group::productUnavailable(), edm::Group::putProduct(), edm::Principal::reader(), and unscheduledFill().

                                                                         {
    // Try unscheduled production.
    if(g.onDemand()) {
      if(fillOnDemand) {
        unscheduledFill(g.branchDescription().moduleLabel());
      }
      return;
    }

    if(g.branchDescription().produced()) return; // nothing to do.
    if(g.product()) return; // nothing to do.
    if(g.productUnavailable()) return; // nothing to do.
    if(!reader()) return; // nothing to do.

    // must attempt to load from persistent store
    BranchKey const bk = BranchKey(g.branchDescription());
    WrapperOwningHolder edp(reader()->getProduct(bk, g.productData().getInterface(), this));

    // Now fix up the Group
    checkUniquenessAndType(edp, &g);
    g.putProduct(edp);
  }
RunNumber_t edm::EventPrincipal::run ( void  ) const [inline]

Definition at line 109 of file EventPrincipal.h.

References id(), and edm::EventID::run().

Referenced by edm::InputSource::readEvent(), and edm::PoolSource::readEvent_().

                            {
      return id().run();
    }
RunPrincipal const & edm::EventPrincipal::runPrincipal ( ) const

Definition at line 95 of file EventPrincipal.cc.

References luminosityBlockPrincipal(), and edm::LuminosityBlockPrincipal::runPrincipal().

                                     {
    return luminosityBlockPrincipal().runPrincipal();
  }
RunPrincipal & edm::EventPrincipal::runPrincipal ( )

Definition at line 100 of file EventPrincipal.cc.

References luminosityBlockPrincipal(), and edm::LuminosityBlockPrincipal::runPrincipal().

                               {
    return luminosityBlockPrincipal().runPrincipal();
  }
void edm::EventPrincipal::setLuminosityBlockPrincipal ( boost::shared_ptr< LuminosityBlockPrincipal > const &  lbp)
void edm::EventPrincipal::setUnscheduledHandler ( boost::shared_ptr< UnscheduledHandler iHandler)

Definition at line 248 of file EventPrincipal.cc.

References unscheduledHandler_.

Referenced by edm::Schedule::setupOnDemandSystem().

                                                                                    {
    unscheduledHandler_ = iHandler;
  }
int edm::EventPrincipal::storeNumber ( ) const [inline]

Definition at line 97 of file EventPrincipal.h.

References aux(), and edm::EventAuxiliary::storeNumber().

                            {
      return aux().storeNumber();
    }
Timestamp const& edm::EventPrincipal::time ( ) const [inline]
bool edm::EventPrincipal::unscheduledFill ( std::string const &  moduleLabel) const [private, virtual]

Implements edm::Principal.

Definition at line 268 of file EventPrincipal.cc.

References Exception, edm::find_in_all(), i, edm::errors::LogicError, moduleLabelsRunning_, and unscheduledHandler_.

Referenced by resolveProduct_().

                                                                    {

    // If it is a module already currently running in unscheduled
    // mode, then there is a circular dependency related to which
    // EDProducts modules require and produce.  There is no safe way
    // to recover from this.  Here we check for this problem and throw
    // an exception.
    std::vector<std::string>::const_iterator i =
      find_in_all(moduleLabelsRunning_, moduleLabel);

    if(i != moduleLabelsRunning_.end()) {
      throw Exception(errors::LogicError)
        << "Hit circular dependency while trying to run an unscheduled module.\n"
        << "Current implementation of unscheduled execution cannot always determine\n"
        << "the proper order for module execution.  It is also possible the modules\n"
        << "have a built in circular dependence that will not work with any order.\n"
        << "In the first case, scheduling some or all required modules in paths will help.\n"
        << "In the second case, the modules themselves will have to be fixed.\n";
    }

    moduleLabelsRunning_.push_back(moduleLabel);

    if(unscheduledHandler_) {
      unscheduledHandler_->tryToFill(moduleLabel, *const_cast<EventPrincipal*>(this));
    }
    moduleLabelsRunning_.pop_back();
    return true;
  }
boost::shared_ptr< UnscheduledHandler > edm::EventPrincipal::unscheduledHandler ( ) const

Definition at line 253 of file EventPrincipal.cc.

References unscheduledHandler_.

Referenced by edm::WorkerT< T >::implDoBegin().

                                           {
     return unscheduledHandler_;
  }

Member Data Documentation

Definition at line 162 of file EventPrincipal.h.

Referenced by aux(), clearEventPrincipal(), and fillEventPrincipal().

Definition at line 178 of file EventPrincipal.h.

Referenced by branchIDToProductID(), clearEventPrincipal(), and fillEventPrincipal().

Definition at line 174 of file EventPrincipal.h.

Referenced by clearEventPrincipal(), eventSelectionIDs(), and fillEventPrincipal().

Definition at line 46 of file EventPrincipal.h.

Definition at line 47 of file EventPrincipal.h.

std::vector<std::string> edm::EventPrincipal::moduleLabelsRunning_ [mutable, private]

Definition at line 172 of file EventPrincipal.h.

Referenced by clearEventPrincipal(), and unscheduledFill().