CMS 3D CMS Logo

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

edm::PoolSource Class Reference

#include <PoolSource.h>

Inheritance diagram for edm::PoolSource:
edm::VectorInputSource edm::EDInputSource edm::InputSource edm::ProductRegistryHelper

List of all members.

Public Member Functions

 PoolSource (ParameterSet const &pset, InputSourceDescription const &desc)
virtual ~PoolSource ()

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)

Private Member Functions

virtual void closeFile_ ()
virtual void dropUnwantedBranches_ (std::vector< std::string > const &wantedBranches)
virtual void endJob ()
virtual
ProcessingController::ForwardState 
forwardState_ () const
virtual ItemType getNextItemType ()
virtual bool goToEvent_ (EventID const &eventID)
virtual void postForkReacquireResources (boost::shared_ptr< edm::multicore::MessageReceiverForSource >)
virtual void preForkReleaseResources ()
virtual bool randomAccess_ () const
virtual EventPrincipalreadEvent_ ()
virtual boost::shared_ptr
< FileBlock
readFile_ ()
virtual EventPrincipalreadIt (EventID const &id)
virtual boost::shared_ptr
< LuminosityBlockPrincipal
readLuminosityBlock_ (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
virtual boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary_ ()
virtual EventPrincipalreadOneRandom ()
virtual EventPrincipalreadOneRandomWithID (LuminosityBlockID const &lumiID)
virtual EventPrincipalreadOneSequential ()
virtual EventPrincipalreadOneSequentialWithID (LuminosityBlockID const &lumiID)
virtual EventPrincipalreadOneSpecified (EventID const &id)
virtual boost::shared_ptr
< RunPrincipal
readRun_ (boost::shared_ptr< RunPrincipal > rpCache)
virtual boost::shared_ptr
< RunAuxiliary
readRunAuxiliary_ ()
virtual
ProcessingController::ReverseState 
reverseState_ () const
virtual void rewind_ ()
virtual void skip (int offset)

Private Attributes

std::array< std::vector
< BranchID >, NumBranchTypes > 
branchIDsToReplace_
unsigned int numberOfEventsBeforeBigSkip_
std::unique_ptr
< RootInputFileSequence
primaryFileSequence_
boost::shared_ptr
< edm::multicore::MessageReceiverForSource
receiver_
RootServiceChecker rootServiceChecker_
std::unique_ptr< EventPrincipalsecondaryEventPrincipal_
std::unique_ptr
< RootInputFileSequence
secondaryFileSequence_
boost::shared_ptr
< LuminosityBlockPrincipal
secondaryLumiPrincipal_
boost::shared_ptr< RunPrincipalsecondaryRunPrincipal_

Detailed Description

Definition at line 29 of file PoolSource.h.


Constructor & Destructor Documentation

edm::PoolSource::PoolSource ( ParameterSet const &  pset,
InputSourceDescription const &  desc 
) [explicit]

Definition at line 56 of file PoolSource.cc.

References begin, relativeConstraints::empty, end, HDQMDatabaseProducer::fullList, i, edm::InEvent, edm::InLumi, edm::InRun, edm::NumBranchTypes, and findQualityFiles::size.

                                                                                : InputType::SecondarySource)),
    secondaryFileSequence_(catalog(1).empty() ? 0 :
                           new RootInputFileSequence(pset, *this, catalog(1), principalCache(), InputType::SecondaryFile)),
    secondaryRunPrincipal_(),
    secondaryLumiPrincipal_(),
    secondaryEventPrincipal_(secondaryFileSequence_ ? new EventPrincipal(secondaryFileSequence_->fileProductRegistry(), processConfiguration()) : 0),
    branchIDsToReplace_(),
    numberOfEventsBeforeBigSkip_(0) {
    if(secondaryFileSequence_) {
      assert(primary());
      std::array<std::set<BranchID>, NumBranchTypes> idsToReplace;
      ProductRegistry::ProductList const& secondary = secondaryFileSequence_->fileProductRegistry()->productList();
      ProductRegistry::ProductList const& primary = primaryFileSequence_->fileProductRegistry()->productList();
      typedef ProductRegistry::ProductList::const_iterator const_iterator;
      typedef ProductRegistry::ProductList::iterator iterator;
      //this is the registry used by the 'outside' world and only has the primary file information in it at present
      ProductRegistry::ProductList& fullList = productRegistryUpdate().productListUpdator();
      for(const_iterator it = secondary.begin(), itEnd = secondary.end(); it != itEnd; ++it) {
        if(it->second.present()) {
          idsToReplace[it->second.branchType()].insert(it->second.branchID());
          //now make sure this is marked as not dropped else the product will not be 'get'table from the Event
          iterator itFound = fullList.find(it->first);
          if(itFound != fullList.end()) {
            itFound->second.dropped()=false;
          }
        }
      }
      for(const_iterator it = primary.begin(), itEnd = primary.end(); it != itEnd; ++it) {
        if(it->second.present()) idsToReplace[it->second.branchType()].erase(it->second.branchID());
      }
      if(idsToReplace[InEvent].empty() && idsToReplace[InLumi].empty() && idsToReplace[InRun].empty()) {
        secondaryFileSequence_.reset();
      } else {
        for(int i = InEvent; i < NumBranchTypes; ++i) {
          branchIDsToReplace_[i].reserve(idsToReplace[i].size());
          for(std::set<BranchID>::const_iterator it = idsToReplace[i].begin(), itEnd = idsToReplace[i].end();
               it != itEnd; ++it) {
            branchIDsToReplace_[i].push_back(*it);
          }
        }
      }
    }
  }

  PoolSource::~PoolSource() {}
edm::PoolSource::~PoolSource ( ) [virtual]

Definition at line 104 of file PoolSource.cc.

References secondaryFileSequence_.


Member Function Documentation

void edm::PoolSource::closeFile_ ( ) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 122 of file PoolSource.cc.

void edm::PoolSource::dropUnwantedBranches_ ( std::vector< std::string > const &  wantedBranches) [private, virtual]

Implements edm::VectorInputSource.

Definition at line 302 of file PoolSource.cc.

void edm::PoolSource::endJob ( void  ) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 107 of file PoolSource.cc.

void edm::PoolSource::fillDescriptions ( ConfigurationDescriptions descriptions) [static]

Reimplemented from edm::InputSource.

Definition at line 308 of file PoolSource.cc.

ProcessingController::ForwardState edm::PoolSource::forwardState_ ( ) const [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 325 of file PoolSource.cc.

InputSource::ItemType edm::PoolSource::getNextItemType ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 215 of file PoolSource.cc.

References edm::InputSource::decreaseRemainingEventsBy(), edm::InputSource::IsStop, numberOfEventsBeforeBigSkip_, primaryFileSequence_, edm::InputSource::principalCache(), receiver_, and edm::InputSource::remainingEvents().

                                          {
      receiver_->receive();
      unsigned long toSkip = receiver_->numberToSkip();
      if(0 != toSkip) {
        primaryFileSequence_->skipEvents(toSkip, principalCache());
        decreaseRemainingEventsBy(toSkip);
      }
      numberOfEventsBeforeBigSkip_ = receiver_->numberOfConsecutiveIndices();
      if(0 == numberOfEventsBeforeBigSkip_ or 0==remainingEvents()) {
        return IsStop;
      }
    }
    return primaryFileSequence_->getNextItemType();;
  }

  void
bool edm::PoolSource::goToEvent_ ( EventID const &  eventID) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 267 of file PoolSource.cc.

void edm::PoolSource::postForkReacquireResources ( boost::shared_ptr< edm::multicore::MessageReceiverForSource iReceiver) [private, virtual]

Definition at line 238 of file PoolSource.cc.

void edm::PoolSource::preForkReleaseResources ( ) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 233 of file PoolSource.cc.

bool edm::PoolSource::randomAccess_ ( ) const [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 320 of file PoolSource.cc.

EventPrincipal * edm::PoolSource::readEvent_ ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 182 of file PoolSource.cc.

References branchIDsToReplace_, edm::EventID::event(), Exception, edm::EventPrincipal::id(), edm::InEvent, edm::EventPrincipal::luminosityBlock(), edm::EventPrincipal::mergeMappers(), edm::errors::MismatchedInputFiles, edm::Principal::recombine(), edm::EventPrincipal::run(), secondaryEventPrincipal_, secondaryFileSequence_, and secondaryLumiPrincipal_.

                                                                        {
      bool found = secondaryFileSequence_->skipToItem(primaryPrincipal->run(),
                                                      primaryPrincipal->luminosityBlock(),
                                                      primaryPrincipal->id().event());
      if(found) {
        EventPrincipal* secondaryPrincipal = secondaryFileSequence_->readEvent(*secondaryEventPrincipal_, secondaryLumiPrincipal_);
        checkConsistency(*primaryPrincipal, *secondaryPrincipal);
        checkHistoryConsistency(*primaryPrincipal, *secondaryPrincipal);
        primaryPrincipal->recombine(*secondaryPrincipal, branchIDsToReplace_[InEvent]);
        primaryPrincipal->mergeMappers(*secondaryPrincipal);
        secondaryEventPrincipal_->clearPrincipal();
      } else {
        throw Exception(errors::MismatchedInputFiles, "PoolSource::readEvent_") <<
          primaryPrincipal->id() << " is not found in the secondary input files\n";
      }
    }
    if(receiver_) {
      --numberOfEventsBeforeBigSkip_;
    }
    return primaryPrincipal;
  }

  EventPrincipal*
boost::shared_ptr< FileBlock > edm::PoolSource::readFile_ ( ) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 114 of file PoolSource.cc.

References edm::FileBlock::HasSecondaryFileSequence.

                               {
      fb->setNotFastClonable(FileBlock::HasSecondaryFileSequence);
    }
    return fb;
  }

  void PoolSource::closeFile_() {
EventPrincipal * edm::PoolSource::readIt ( EventID const &  id) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 208 of file PoolSource.cc.

boost::shared_ptr< LuminosityBlockPrincipal > edm::PoolSource::readLuminosityBlock_ ( boost::shared_ptr< LuminosityBlockPrincipal lbCache) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 159 of file PoolSource.cc.

References branchIDsToReplace_, edm::InLumi, edm::InputSource::processConfiguration(), secondaryFileSequence_, secondaryLumiPrincipal_, and secondaryRunPrincipal_.

                {
        boost::shared_ptr<LuminosityBlockAuxiliary> secondaryAuxiliary = secondaryFileSequence_->readLuminosityBlockAuxiliary_();
        checkConsistency(primaryPrincipal->aux(), *secondaryAuxiliary);
        boost::shared_ptr<LuminosityBlockPrincipal> lbp(new LuminosityBlockPrincipal(secondaryAuxiliary, secondaryFileSequence_->fileProductRegistry(), processConfiguration(), secondaryRunPrincipal_));
        secondaryLumiPrincipal_ = secondaryFileSequence_->readLuminosityBlock_(lbp);
        checkHistoryConsistency(*primaryPrincipal, *secondaryLumiPrincipal_);
        primaryPrincipal->recombine(*secondaryLumiPrincipal_, branchIDsToReplace_[InLumi]);
      } else {
        throw Exception(errors::MismatchedInputFiles, "PoolSource::readLuminosityBlock_")
          << " Run " << primaryPrincipal->run()
          << " LuminosityBlock " << primaryPrincipal->luminosityBlock()
          << " is not found in the secondary input files\n";
      }
      return primaryPrincipal;
    }
    return primaryFileSequence_->readLuminosityBlock_(lbCache);
  }

  EventPrincipal*
boost::shared_ptr< LuminosityBlockAuxiliary > edm::PoolSource::readLuminosityBlockAuxiliary_ ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 132 of file PoolSource.cc.

EventPrincipal * edm::PoolSource::readOneRandom ( ) [private, virtual]

Implements edm::VectorInputSource.

Definition at line 272 of file PoolSource.cc.

EventPrincipal * edm::PoolSource::readOneRandomWithID ( LuminosityBlockID const &  lumiID) [private, virtual]

Implements edm::VectorInputSource.

Definition at line 278 of file PoolSource.cc.

EventPrincipal * edm::PoolSource::readOneSequential ( ) [private, virtual]

Implements edm::VectorInputSource.

Definition at line 284 of file PoolSource.cc.

EventPrincipal * edm::PoolSource::readOneSequentialWithID ( LuminosityBlockID const &  lumiID) [private, virtual]

Implements edm::VectorInputSource.

Definition at line 290 of file PoolSource.cc.

EventPrincipal * edm::PoolSource::readOneSpecified ( EventID const &  id) [private, virtual]

Implements edm::VectorInputSource.

Definition at line 296 of file PoolSource.cc.

boost::shared_ptr< RunPrincipal > edm::PoolSource::readRun_ ( boost::shared_ptr< RunPrincipal rpCache) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 137 of file PoolSource.cc.

References branchIDsToReplace_, edm::InRun, edm::InputSource::processConfiguration(), secondaryFileSequence_, and secondaryRunPrincipal_.

                {
        boost::shared_ptr<RunAuxiliary> secondaryAuxiliary = secondaryFileSequence_->readRunAuxiliary_();
        checkConsistency(primaryPrincipal->aux(), *secondaryAuxiliary);
        boost::shared_ptr<RunPrincipal> rp(new RunPrincipal(secondaryAuxiliary, secondaryFileSequence_->fileProductRegistry(), processConfiguration()));
        secondaryRunPrincipal_ = secondaryFileSequence_->readRun_(rp);
        checkHistoryConsistency(*primaryPrincipal, *secondaryRunPrincipal_);
        primaryPrincipal->recombine(*secondaryRunPrincipal_, branchIDsToReplace_[InRun]);
      } else {
        throw Exception(errors::MismatchedInputFiles, "PoolSource::readRun_")
          << " Run " << primaryPrincipal->run()
          << " is not found in the secondary input files\n";
      }
      return primaryPrincipal;
    }
    return primaryFileSequence_->readRun_(rpCache);
  }

  boost::shared_ptr<LuminosityBlockPrincipal>
boost::shared_ptr< RunAuxiliary > edm::PoolSource::readRunAuxiliary_ ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 127 of file PoolSource.cc.

ProcessingController::ReverseState edm::PoolSource::reverseState_ ( ) const [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 330 of file PoolSource.cc.

void edm::PoolSource::rewind_ ( ) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 248 of file PoolSource.cc.

References numberOfEventsBeforeBigSkip_, primaryFileSequence_, edm::InputSource::principalCache(), and receiver_.

                  {
      unsigned int numberToSkip = receiver_->numberToSkip();
      if(0 != numberToSkip) {
        primaryFileSequence_->skipEvents(numberToSkip, principalCache());
      }
      numberOfEventsBeforeBigSkip_ = receiver_->numberOfConsecutiveIndices();
    }

  }

  // Advance "offset" events.  Offset can be positive or negative (or zero).
void edm::PoolSource::skip ( int  offset) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 262 of file PoolSource.cc.


Member Data Documentation

std::array<std::vector<BranchID>, NumBranchTypes> edm::PoolSource::branchIDsToReplace_ [private]

Definition at line 69 of file PoolSource.h.

Referenced by readEvent_(), readLuminosityBlock_(), and readRun_().

Definition at line 73 of file PoolSource.h.

Referenced by getNextItemType(), and rewind_().

Definition at line 64 of file PoolSource.h.

Referenced by getNextItemType(), and rewind_().

Definition at line 72 of file PoolSource.h.

Referenced by getNextItemType(), and rewind_().

Definition at line 63 of file PoolSource.h.

Definition at line 68 of file PoolSource.h.

Referenced by readEvent_().

Definition at line 65 of file PoolSource.h.

Referenced by readEvent_(), readLuminosityBlock_(), readRun_(), and ~PoolSource().

Definition at line 67 of file PoolSource.h.

Referenced by readEvent_(), and readLuminosityBlock_().

Definition at line 66 of file PoolSource.h.

Referenced by readLuminosityBlock_(), and readRun_().