CMS 3D CMS Logo

edm::RootInputFileSequence Class Reference

#include <IOPool/Input/src/RootInputFileSequence.h>

List of all members.

Public Types

typedef input::EntryNumber EntryNumber
typedef
VectorInputSource::EventPrincipalVector 
EventPrincipalVector
typedef boost::shared_ptr
< RootFile
RootFileSharedPtr

Public Member Functions

void closeFile_ ()
void dropUnwantedBranches_ (std::vector< std::string > const &wantedBranches)
void endJob ()
ProductRegistry const & fileProductRegistry () const
InputSource::ItemType getNextItemType ()
std::auto_ptr< EventPrincipalreadEvent_ ()
boost::shared_ptr< FileBlockreadFile_ ()
boost::shared_ptr< RunPrincipalreadIt (RunID const &run)
boost::shared_ptr
< LuminosityBlockPrincipal
readIt (LuminosityBlockID const &id)
std::auto_ptr< EventPrincipalreadIt (EventID const &id, LuminosityBlockNumber_t lumi=0U, bool exact=false)
boost::shared_ptr
< LuminosityBlockPrincipal
readLuminosityBlock_ ()
void readMany_ (int number, EventPrincipalVector &result, EventID const &id, unsigned int fileSeqNumber)
void readMany_ (int number, EventPrincipalVector &result)
void readManyRandom_ (int number, EventPrincipalVector &result, unsigned int &fileSeqNumber)
boost::shared_ptr< RunPrincipalreadRun_ ()
void rewind_ ()
 RootInputFileSequence (ParameterSet const &pset, PoolSource const &input, InputFileCatalog const &catalog, bool primarySequence)
void skip (int offset)
virtual ~RootInputFileSequence ()

Private Member Functions

std::vector< FileCatalogItem >
const & 
fileCatalogItems () const
void initFile (bool skipBadFiles)
void logFileAction (const char *msg, std::string const &file)
bool nextFile ()
bool previousFile ()
bool const primary () const
ProcessConfiguration const & processConfiguration () const
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
ProductRegistryproductRegistryUpdate () const
std::auto_ptr< EventPrincipalreadCurrentEvent ()
int remainingEvents () const
int remainingLuminosityBlocks () const
void rewindFile ()
boost::shared_ptr< RunPrincipalrunPrincipal () const
void updateProductRegistry () const

Private Attributes

BranchDescription::MatchMode branchesMustMatch_
InputFileCatalog const & catalog_
bool dropDescendants_
bool dropMetaData_
boost::shared_ptr
< edm::DuplicateChecker
duplicateChecker_
int eventsRemainingInFile_
std::vector< EventIDeventsToProcess_
unsigned int eventsToSkip_
std::vector< boost::shared_ptr
< FileIndex > > 
fileIndexes_
std::vector< FileCatalogItem >
::const_iterator 
fileIter_
std::vector< FileCatalogItem >
::const_iterator 
fileIterBegin_
std::vector< FileCatalogItem >
::const_iterator 
fileIterEnd_
bool firstFile_
CLHEP::RandFlat * flatDistribution_
int forcedRunOffset_
GroupSelectorRules groupSelectorRules_
PoolSource const & input_
bool noEventSort_
BranchDescription::MatchMode parametersMustMatch_
bool primarySequence_
bool randomAccess_
RootFileSharedPtr rootFile_
RunNumber_t setRun_
bool skipBadFiles_
EventNumber_t startAtEvent_
LuminosityBlockNumber_t startAtLumi_
RunNumber_t startAtRun_
unsigned int treeCacheSize_
int const treeMaxVirtualSize_
std::vector< LuminosityBlockIDwhichLumisToSkip_


Detailed Description

Definition at line 42 of file RootInputFileSequence.h.


Member Typedef Documentation

typedef input::EntryNumber edm::RootInputFileSequence::EntryNumber

Definition at line 49 of file RootInputFileSequence.h.

typedef VectorInputSource::EventPrincipalVector edm::RootInputFileSequence::EventPrincipalVector

Definition at line 47 of file RootInputFileSequence.h.

typedef boost::shared_ptr<RootFile> edm::RootInputFileSequence::RootFileSharedPtr

Definition at line 48 of file RootInputFileSequence.h.


Constructor & Destructor Documentation

edm::RootInputFileSequence::RootInputFileSequence ( ParameterSet const &  pset,
PoolSource const &  input,
InputFileCatalog const &  catalog,
bool  primarySequence 
) [explicit]

Definition at line 26 of file RootInputFileSequence.cc.

References branchesMustMatch_, edm::errors::Configuration, duplicateChecker_, eventsToProcess_, fileIter_, fileIterBegin_, fileIterEnd_, flatDistribution_, forcedRunOffset_, StorageFactory::get(), edm::ParameterSet::getUntrackedParameter(), initFile(), edm::Service< T >::isAvailable(), noEventSort_, parametersMustMatch_, primary(), primarySequence_, rootFile_, setRun_, skipBadFiles_, edm::sort_all(), StorageFactory::stagein(), startAtEvent_, edm::BranchDescription::Strict, and updateProductRegistry().

00030                                       :
00031     input_(input),
00032     catalog_(catalog),
00033     firstFile_(true),
00034     fileIterBegin_(fileCatalogItems().begin()),
00035     fileIterEnd_(fileCatalogItems().end()),
00036     fileIter_(fileIterEnd_),
00037     rootFile_(),
00038     parametersMustMatch_(BranchDescription::Permissive),
00039     branchesMustMatch_(BranchDescription::Permissive),
00040     flatDistribution_(0),
00041     fileIndexes_(fileCatalogItems().size()),
00042     eventsRemainingInFile_(0),
00043     startAtRun_(pset.getUntrackedParameter<unsigned int>("firstRun", 1U)),
00044     startAtLumi_(pset.getUntrackedParameter<unsigned int>("firstLuminosityBlock", 1U)),
00045     startAtEvent_(pset.getUntrackedParameter<unsigned int>("firstEvent", 1U)),
00046     eventsToSkip_(pset.getUntrackedParameter<unsigned int>("skipEvents", 0U)),
00047     whichLumisToSkip_(pset.getUntrackedParameter<std::vector<LuminosityBlockID> >("lumisToSkip", std::vector<LuminosityBlockID>())),
00048     eventsToProcess_(pset.getUntrackedParameter<std::vector<EventID> >("eventsToProcess",std::vector<EventID>())),
00049     noEventSort_(pset.getUntrackedParameter<bool>("noEventSort", false)),
00050     skipBadFiles_(pset.getUntrackedParameter<bool>("skipBadFiles", false)),
00051     treeCacheSize_(pset.getUntrackedParameter<unsigned int>("cacheSize", 0U)),
00052     treeMaxVirtualSize_(pset.getUntrackedParameter<int>("treeMaxVirtualSize", -1)),
00053     forcedRunOffset_(0),
00054     setRun_(pset.getUntrackedParameter<unsigned int>("setRunNumber", 0U)),
00055     groupSelectorRules_(pset, "inputCommands", "InputSource"),
00056     dropMetaData_(pset.getUntrackedParameter<bool>("dropMetaData", false)),
00057     primarySequence_(primarySequence),
00058     randomAccess_(false),
00059     duplicateChecker_(),
00060     dropDescendants_(pset.getUntrackedParameter<bool>("dropDescendantsOfDroppedBranches", true)) {
00061 
00062     if (!primarySequence_) noEventSort_ = false;
00063     if (noEventSort_ && ((startAtEvent_ > 1) || !eventsToProcess_.empty())) {
00064       throw edm::Exception(errors::Configuration)
00065         << "Illegal configuration options passed to PoolSource\n"
00066         << "You cannot request \"noEventSort\" and also set \"firstEvent\"\n"
00067         << "or \"eventsToProcess\".\n";
00068     }
00069 
00070     if (primarySequence_ && primary()) duplicateChecker_.reset(new DuplicateChecker(pset));
00071 
00072     StorageFactory *factory = StorageFactory::get();
00073     for(fileIter_ = fileIterBegin_; fileIter_ != fileIterEnd_; ++fileIter_)
00074       factory->stagein(fileIter_->fileName());
00075 
00076     sort_all(eventsToProcess_);
00077 
00078     std::string parametersMustMatch = pset.getUntrackedParameter<std::string>("parametersMustMatch", std::string("permissive"));
00079     if (parametersMustMatch == std::string("strict")) parametersMustMatch_ = BranchDescription::Strict;
00080 
00081     // "fileMatchMode" is for backward compatibility.
00082     parametersMustMatch = pset.getUntrackedParameter<std::string>("fileMatchMode", std::string("permissive"));
00083     if (parametersMustMatch == std::string("strict")) parametersMustMatch_ = BranchDescription::Strict;
00084 
00085     std::string branchesMustMatch = pset.getUntrackedParameter<std::string>("branchesMustMatch", std::string("permissive"));
00086     if (branchesMustMatch == std::string("strict")) branchesMustMatch_ = BranchDescription::Strict;
00087 
00088     if (primary()) {
00089       for(fileIter_ = fileIterBegin_; fileIter_ != fileIterEnd_; ++fileIter_) {
00090         initFile(skipBadFiles_);
00091         if (rootFile_) break;
00092       }
00093       if (rootFile_) {
00094         forcedRunOffset_ = rootFile_->setForcedRunOffset(setRun_);
00095         if (forcedRunOffset_ < 0) {
00096           throw edm::Exception(errors::Configuration)
00097             << "The value of the 'setRunNumber' parameter must not be\n"
00098             << "less than the first run number in the first input file.\n"
00099             << "'setRunNumber' was " << setRun_ <<", while the first run was "
00100             << setRun_ - forcedRunOffset_ << ".\n";
00101         }
00102         updateProductRegistry();
00103       }
00104     } else {
00105       Service<RandomNumberGenerator> rng;
00106       if (!rng.isAvailable()) {
00107         throw edm::Exception(errors::Configuration)
00108           << "A secondary input source requires the RandomNumberGeneratorService\n"
00109           << "which is not present in the configuration file.  You must add the service\n"
00110           << "in the configuration file or remove the modules that require it.";
00111       }
00112       CLHEP::HepRandomEngine& engine = rng->getEngine();
00113       flatDistribution_ = new CLHEP::RandFlat(engine);
00114     }
00115   }

edm::RootInputFileSequence::~RootInputFileSequence (  )  [virtual]

Definition at line 274 of file RootInputFileSequence.cc.

00274                                                 {
00275   }


Member Function Documentation

void edm::RootInputFileSequence::closeFile_ (  ) 

Definition at line 160 of file RootInputFileSequence.cc.

References duplicateChecker_, eventsToSkip_, input_, logFileAction(), primary(), primarySequence_, and rootFile_.

Referenced by endJob(), and initFile().

00160                                          {
00161     if (rootFile_) {
00162     // Account for events skipped in the file.
00163       eventsToSkip_ = rootFile_->eventsToSkip();
00164       {
00165         std::auto_ptr<InputSource::FileCloseSentry> 
00166           sentry((primarySequence_ && primary()) ? new InputSource::FileCloseSentry(input_) : 0);
00167         rootFile_->close(primary());
00168       }
00169       logFileAction("  Closed file ", rootFile_->file());
00170       rootFile_.reset();
00171       if (duplicateChecker_.get() != 0) duplicateChecker_->inputFileClosed();
00172     }
00173   }

void edm::RootInputFileSequence::dropUnwantedBranches_ ( std::vector< std::string > const &  wantedBranches  ) 

Definition at line 528 of file RootInputFileSequence.cc.

References edm::ParameterSet::addUntrackedParameter(), groupSelectorRules_, it, and python::EventAnalyzer_cfg::pset.

00528                                                                                          {
00529     std::vector<std::string> rules;
00530     rules.reserve(wantedBranches.size() + 1);
00531     rules.push_back(std::string("drop *")); 
00532     for (std::vector<std::string>::const_iterator it = wantedBranches.begin(), itEnd = wantedBranches.end();
00533         it != itEnd; ++it) {
00534       rules.push_back("keep " + *it + "_*");
00535     }
00536     ParameterSet pset;
00537     pset.addUntrackedParameter("inputCommands", rules);
00538     groupSelectorRules_ = GroupSelectorRules(pset, "inputCommands", "InputSource");
00539   }

void edm::RootInputFileSequence::endJob ( void   ) 

Definition at line 123 of file RootInputFileSequence.cc.

References closeFile_(), logFileAction(), primary(), and rootFile_.

00123                                 {
00124     if (primary()) {
00125       closeFile_();
00126     } else {
00127       if (rootFile_) {
00128         rootFile_->close(true);
00129         logFileAction("  Closed file ", rootFile_->file());
00130         rootFile_.reset();
00131       }
00132     }
00133   }

std::vector< FileCatalogItem > const & edm::RootInputFileSequence::fileCatalogItems (  )  const [private]

Definition at line 118 of file RootInputFileSequence.cc.

References catalog_, and edm::InputFileCatalog::fileCatalogItems().

Referenced by readManyRandom_().

00118                                                 {
00119     return catalog_.fileCatalogItems();
00120   }

ProductRegistry const & edm::RootInputFileSequence::fileProductRegistry (  )  const

Definition at line 219 of file RootInputFileSequence.cc.

References rootFile_.

00219                                                    {
00220     return *rootFile_->productRegistry();
00221   }

InputSource::ItemType edm::RootInputFileSequence::getNextItemType (  ) 

Definition at line 435 of file RootInputFileSequence.cc.

References fileIter_, fileIterEnd_, firstFile_, edm::InputSource::IsEvent, edm::InputSource::IsFile, edm::InputSource::IsLumi, edm::InputSource::IsRun, edm::InputSource::IsStop, edm::FileIndex::kEnd, edm::FileIndex::kEvent, edm::FileIndex::kLumi, edm::FileIndex::kRun, randomAccess_, rootFile_, and skip().

00435                                          {
00436     if (fileIter_ == fileIterEnd_) {
00437       return InputSource::IsStop;
00438     }
00439     if (firstFile_) {
00440       return InputSource::IsFile;
00441     }
00442     if (rootFile_) {
00443       if (randomAccess_) {
00444         skip(0);
00445         if (fileIter_== fileIterEnd_) {
00446           return InputSource::IsStop;
00447         }
00448       }
00449       FileIndex::EntryType entryType = rootFile_->getNextEntryTypeWanted();
00450       if (entryType == FileIndex::kEvent) {
00451         return InputSource::IsEvent;
00452       } else if (entryType == FileIndex::kLumi) {
00453         return InputSource::IsLumi;
00454       } else if (entryType == FileIndex::kRun) {
00455         return InputSource::IsRun;
00456       }
00457       assert(entryType == FileIndex::kEnd);
00458     }
00459     if (fileIter_ + 1 == fileIterEnd_) {
00460       return InputSource::IsStop;
00461     }
00462     return InputSource::IsFile;
00463   }

void edm::RootInputFileSequence::initFile ( bool  skipBadFiles  )  [private]

Definition at line 175 of file RootInputFileSequence.cc.

References catalog_, closeFile_(), dropDescendants_, dropMetaData_, duplicateChecker_, e, eventsToProcess_, eventsToSkip_, cms::Exception::explainSelf(), fileIndexes_, fileIter_, fileIterBegin_, edm::errors::FileOpenError, forcedRunOffset_, groupSelectorRules_, input_, logFileAction(), noEventSort_, primary(), primarySequence_, processConfiguration(), edm::InputSource::processingMode(), remainingEvents(), remainingLuminosityBlocks(), rootFile_, startAtEvent_, startAtLumi_, startAtRun_, treeCacheSize_, treeMaxVirtualSize_, edm::FileCatalog::url(), and whichLumisToSkip_.

Referenced by nextFile(), previousFile(), readFile_(), readIt(), readMany_(), readManyRandom_(), and RootInputFileSequence().

00175                                                         {
00176     // close the currently open file, any, and delete the RootFile object.
00177     closeFile_();
00178     boost::shared_ptr<TFile> filePtr;
00179     try {
00180       logFileAction("  Initiating request to open file ", fileIter_->fileName());
00181       std::auto_ptr<InputSource::FileOpenSentry> 
00182         sentry((primarySequence_ && primary()) ? new InputSource::FileOpenSentry(input_) : 0);
00183       filePtr.reset(TFile::Open(fileIter_->fileName().c_str()));
00184     }
00185     catch (cms::Exception e) {
00186       if (!skipBadFiles) {
00187         throw edm::Exception(edm::errors::FileOpenError) << e.explainSelf() << "\n" <<
00188            "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " was not found or could not be opened.\n";
00189       }
00190     }
00191     if (filePtr && !filePtr->IsZombie()) {
00192       logFileAction("  Successfully opened file ", fileIter_->fileName());
00193       rootFile_ = RootFileSharedPtr(new RootFile(fileIter_->fileName(), catalog_.url(),
00194           processConfiguration(), fileIter_->logicalFileName(), filePtr,
00195           startAtRun_, startAtLumi_, startAtEvent_, eventsToSkip_, whichLumisToSkip_,
00196           remainingEvents(), remainingLuminosityBlocks(), treeCacheSize_, treeMaxVirtualSize_,
00197           input_.processingMode(),
00198           forcedRunOffset_, eventsToProcess_, noEventSort_,
00199           dropMetaData_, groupSelectorRules_, !primarySequence_, duplicateChecker_, dropDescendants_));
00200       fileIndexes_[fileIter_ - fileIterBegin_] = rootFile_->fileIndexSharedPtr();
00201     } else {
00202       if (!skipBadFiles) {
00203         throw edm::Exception(edm::errors::FileOpenError) <<
00204            "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " was not found or could not be opened.\n";
00205       }
00206       LogWarning("") << "Input file: " << fileIter_->fileName() << " was not found or could not be opened, and will be skipped.\n";
00207     }
00208   }

void edm::RootInputFileSequence::logFileAction ( const char *  msg,
std::string const &  file 
) [private]

Definition at line 607 of file RootInputFileSequence.cc.

References edm::FlushMessageLog(), primarySequence_, and t.

Referenced by closeFile_(), endJob(), and initFile().

00607                                                                                   {
00608     if (primarySequence_) {
00609       time_t t = time(0);
00610       char ts[] = "dd-Mon-yyyy hh:mm:ss TZN     ";
00611       strftime( ts, strlen(ts)+1, "%d-%b-%Y %H:%M:%S %Z", localtime(&t) );
00612       edm::LogAbsolute("fileAction") << ts << msg << file;
00613       edm::FlushMessageLog();
00614     }
00615   }

bool edm::RootInputFileSequence::nextFile (  )  [private]

Definition at line 223 of file RootInputFileSequence.cc.

References branchesMustMatch_, fileIter_, fileIterBegin_, fileIterEnd_, initFile(), edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, parametersMustMatch_, primarySequence_, productRegistryUpdate(), rootFile_, and skipBadFiles_.

Referenced by readFile_(), and skip().

00223                                        {
00224     if(fileIter_ != fileIterEnd_) ++fileIter_;
00225     if(fileIter_ == fileIterEnd_) {
00226       if (primarySequence_) {
00227         return false;
00228       } else {
00229         fileIter_ = fileIterBegin_;
00230       }
00231     }
00232 
00233     initFile(skipBadFiles_);
00234 
00235     if (primarySequence_ && rootFile_) {
00236       // make sure the new product registry is compatible with the main one
00237       std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(),
00238                                                             fileIter_->fileName(),
00239                                                             parametersMustMatch_,
00240                                                             branchesMustMatch_);
00241       if (!mergeInfo.empty()) {
00242         throw edm::Exception(errors::MismatchedInputFiles,"RootInputFileSequence::nextFile()") << mergeInfo;
00243       }
00244     }
00245     return true;
00246   }

bool edm::RootInputFileSequence::previousFile (  )  [private]

Definition at line 248 of file RootInputFileSequence.cc.

References branchesMustMatch_, fileIter_, fileIterBegin_, fileIterEnd_, initFile(), edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, parametersMustMatch_, primarySequence_, productRegistryUpdate(), and rootFile_.

Referenced by skip().

00248                                            {
00249     if(fileIter_ == fileIterBegin_) {
00250       if (primarySequence_) {
00251         return false;
00252       } else {
00253         fileIter_ = fileIterEnd_;
00254       }
00255     }
00256     --fileIter_;
00257 
00258     initFile(false);
00259 
00260     if (primarySequence_ && rootFile_) {
00261       // make sure the new product registry is compatible to the main one
00262       std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(),
00263                                                             fileIter_->fileName(),
00264                                                             parametersMustMatch_,
00265                                                             branchesMustMatch_);
00266       if (!mergeInfo.empty()) {
00267         throw edm::Exception(errors::MismatchedInputFiles,"RootInputFileSequence::previousEvent()") << mergeInfo;
00268       }
00269     }
00270     if (rootFile_) rootFile_->setToLastEntry();
00271     return true;
00272   }

bool const edm::RootInputFileSequence::primary (  )  const [private]

Definition at line 493 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::primary().

Referenced by closeFile_(), endJob(), initFile(), readFile_(), and RootInputFileSequence().

00493                                        {
00494     return input_.primary();
00495   }

ProcessConfiguration const & edm::RootInputFileSequence::processConfiguration (  )  const [private]

Definition at line 503 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::processConfiguration().

Referenced by initFile().

00503                                                     {
00504     return input_.processConfiguration();
00505   }

boost::shared_ptr< ProductRegistry const > edm::RootInputFileSequence::productRegistry (  )  const [private]

Definition at line 523 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::productRegistry().

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

00523                                               {
00524     return input_.productRegistry();
00525   }

ProductRegistry & edm::RootInputFileSequence::productRegistryUpdate (  )  const [private]

Definition at line 518 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::productRegistryUpdate().

Referenced by nextFile(), previousFile(), readFile_(), and updateProductRegistry().

00518                                                     {
00519     return input_.productRegistryUpdate();
00520   }

std::auto_ptr< EventPrincipal > edm::RootInputFileSequence::readCurrentEvent (  )  [private]

Definition at line 307 of file RootInputFileSequence.cc.

References primarySequence_, productRegistry(), and rootFile_.

Referenced by readIt(), readMany_(), and readManyRandom_().

00307                                           {
00308     return rootFile_->readCurrentEvent(primarySequence_ ?
00309                                        productRegistry() :
00310                                        rootFile_->productRegistry()); 
00311   }

std::auto_ptr< EventPrincipal > edm::RootInputFileSequence::readEvent_ (  ) 

Definition at line 302 of file RootInputFileSequence.cc.

References primarySequence_, productRegistry(), and rootFile_.

00302                                     {
00303     return rootFile_->readEvent(primarySequence_ ? productRegistry() : rootFile_->productRegistry()); 
00304   }

boost::shared_ptr< FileBlock > edm::RootInputFileSequence::readFile_ (  ) 

Definition at line 136 of file RootInputFileSequence.cc.

References firstFile_, initFile(), nextFile(), primary(), productRegistry(), productRegistryUpdate(), rootFile_, edm::ProductRegistry::setNextID(), edm::ProductRegistry::setProductIDs(), and skipBadFiles_.

00136                                    {
00137     if (firstFile_) {
00138       // The first input file has already been opened, or a rewind has occurred.
00139       firstFile_ = false;
00140       if (!rootFile_) {
00141         initFile(skipBadFiles_);
00142       }
00143     } else {
00144       if (!nextFile()) {
00145         assert(0);
00146       }
00147     }
00148     if (!rootFile_) {
00149       return boost::shared_ptr<FileBlock>(new FileBlock);
00150     }
00151     if (primary()) {
00152       productRegistryUpdate().setProductIDs(rootFile_->productRegistry()->nextID());
00153       if (rootFile_->productRegistry()->nextID() > productRegistry()->nextID()) {
00154         productRegistryUpdate().setNextID(rootFile_->productRegistry()->nextID());
00155       }
00156     }
00157     return rootFile_->createFileBlock();
00158   }

boost::shared_ptr< RunPrincipal > edm::RootInputFileSequence::readIt ( RunID const &  run  ) 

Definition at line 398 of file RootInputFileSequence.cc.

References fileIndexes_, fileIter_, fileIterBegin_, initFile(), it, readRun_(), and rootFile_.

00398                                                {
00399 
00400     // Attempt to find run in currently open input file.
00401     bool found = rootFile_->setEntryAtRun(id);
00402     if (found) {
00403       return readRun_();
00404     }
00405     if (fileIndexes_.size() > 1) {
00406       // Look for run in files previously opened without reopening unnecessary files.
00407       typedef std::vector<boost::shared_ptr<FileIndex> >::const_iterator Iter;
00408       for (Iter it = fileIndexes_.begin(), itEnd = fileIndexes_.end(); it != itEnd; ++it) {
00409         if (*it && (*it)->containsRun(id.run(), true)) {
00410           // We found it. Close the currently open file, and open the correct one.
00411           fileIter_ = fileIterBegin_ + (it - fileIndexes_.begin());
00412           initFile(false);
00413           // Now get the event from the correct file.
00414           found = rootFile_->setEntryAtRun(id);
00415           assert (found);
00416           return readRun_();
00417         }
00418       }
00419       // Look for run in files not yet opened.
00420       for (Iter it = fileIndexes_.begin(), itEnd = fileIndexes_.end(); it != itEnd; ++it) {
00421         if (!*it) {
00422           fileIter_ = fileIterBegin_ + (it - fileIndexes_.begin());
00423           initFile(false);
00424           found = rootFile_->setEntryAtRun(id);
00425           if (found) {
00426             return readRun_();
00427           }
00428         }
00429       }
00430     }
00431     return boost::shared_ptr<RunPrincipal>();
00432   }

boost::shared_ptr< LuminosityBlockPrincipal > edm::RootInputFileSequence::readIt ( LuminosityBlockID const &  id  ) 

Definition at line 360 of file RootInputFileSequence.cc.

References fileIndexes_, fileIter_, fileIterBegin_, initFile(), it, readLuminosityBlock_(), and rootFile_.

00360                                                            {
00361 
00362     // Attempt to find lumi in currently open input file.
00363     bool found = rootFile_->setEntryAtLumi(id);
00364     if (found) {
00365       return readLuminosityBlock_();
00366     }
00367 
00368     if (fileIndexes_.size() > 1) {
00369       // Look for lumi in files previously opened without reopening unnecessary files.
00370       typedef std::vector<boost::shared_ptr<FileIndex> >::const_iterator Iter;
00371       for (Iter it = fileIndexes_.begin(), itEnd = fileIndexes_.end(); it != itEnd; ++it) {
00372         if (*it && (*it)->containsLumi(id.run(), id.luminosityBlock(), true)) {
00373           // We found it. Close the currently open file, and open the correct one.
00374           fileIter_ = fileIterBegin_ + (it - fileIndexes_.begin());
00375           initFile(false);
00376           // Now get the lumi from the correct file.
00377           found = rootFile_->setEntryAtLumi(id);
00378           assert (found);
00379           return readLuminosityBlock_();
00380         }
00381       }
00382       // Look for lumi in files not yet opened.
00383       for (Iter it = fileIndexes_.begin(), itEnd = fileIndexes_.end(); it != itEnd; ++it) {
00384         if (!*it) {
00385           fileIter_ = fileIterBegin_ + (it - fileIndexes_.begin());
00386           initFile(false);
00387           found = rootFile_->setEntryAtLumi(id);
00388           if (found) {
00389             return readLuminosityBlock_();
00390           }
00391         }
00392       }
00393     }
00394     return boost::shared_ptr<LuminosityBlockPrincipal>();
00395   }

std::auto_ptr< EventPrincipal > edm::RootInputFileSequence::readIt ( EventID const &  id,
LuminosityBlockNumber_t  lumi = 0U,
bool  exact = false 
)

Definition at line 314 of file RootInputFileSequence.cc.

References edm::event, fileIndexes_, fileIter_, fileIterBegin_, initFile(), it, randomAccess_, readCurrentEvent(), rootFile_, edm::run, and skip().

00314                                                                                            {
00315     randomAccess_ = true;
00316     // Attempt to find event in currently open input file.
00317     bool found = rootFile_->setEntryAtEvent(id.run(), lumi, id.event(), exact);
00318     if (!found) {
00319       // If only one input file, give up now, to save time.
00320       if (fileIndexes_.size() == 1) {
00321         return std::auto_ptr<EventPrincipal>(0);
00322       }
00323       // Look for event in files previously opened without reopening unnecessary files.
00324       typedef std::vector<boost::shared_ptr<FileIndex> >::const_iterator Iter;
00325       for (Iter it = fileIndexes_.begin(), itEnd = fileIndexes_.end(); it != itEnd; ++it) {
00326         if (*it && (*it)->containsEvent(id.run(), lumi, id.event(), exact)) {
00327           // We found it. Close the currently open file, and open the correct one.
00328           fileIter_ = fileIterBegin_ + (it - fileIndexes_.begin());
00329           initFile(false);
00330           // Now get the event from the correct file.
00331           found = rootFile_->setEntryAtEvent(id.run(), lumi, id.event(), exact);
00332           assert (found);
00333           std::auto_ptr<EventPrincipal> ep = readCurrentEvent();
00334           skip(1);
00335           return ep;
00336         }
00337       }
00338       // Look for event in files not yet opened.
00339       for (Iter it = fileIndexes_.begin(), itEnd = fileIndexes_.end(); it != itEnd; ++it) {
00340         if (!*it) {
00341           fileIter_ = fileIterBegin_ + (it - fileIndexes_.begin());
00342           initFile(false);
00343           found = rootFile_->setEntryAtEvent(id.run(), lumi, id.event(), exact);
00344           if (found) {
00345             std::auto_ptr<EventPrincipal> ep = readCurrentEvent();
00346             skip(1);
00347             return ep;
00348           }
00349         }
00350       }
00351       // Not found
00352       return std::auto_ptr<EventPrincipal>(0);
00353     }
00354     std::auto_ptr<EventPrincipal> eptr = readCurrentEvent();
00355     skip(1);
00356     return eptr;
00357   }

boost::shared_ptr< LuminosityBlockPrincipal > edm::RootInputFileSequence::readLuminosityBlock_ (  ) 

Definition at line 283 of file RootInputFileSequence.cc.

References primarySequence_, productRegistry(), rootFile_, and runPrincipal().

Referenced by readIt().

00283                                               {
00284     return rootFile_->readLumi(primarySequence_ ? productRegistry() : rootFile_->productRegistry(), runPrincipal()); 
00285   }

void edm::RootInputFileSequence::readMany_ ( int  number,
EventPrincipalVector result,
EventID const &  id,
unsigned int  fileSeqNumber 
)

Definition at line 555 of file RootInputFileSequence.cc.

References e, edm::event, fileIter_, fileIterBegin_, i, initFile(), readCurrentEvent(), rewindFile(), rootFile_, and edm::run.

00555                                                                                                                           {
00556     unsigned int currentSeqNumber = fileIter_ - fileIterBegin_;
00557     if (currentSeqNumber != fileSeqNumber) {
00558       fileIter_ = fileIterBegin_ + fileSeqNumber;
00559       initFile(false);
00560     }
00561     rootFile_->setEntryAtEvent(id.run(), 0U, id.event(), false);
00562     for (int i = 0; i < number; ++i) {
00563       std::auto_ptr<EventPrincipal> ev = readCurrentEvent();
00564       if (ev.get() == 0) {
00565         rewindFile();
00566         ev = readCurrentEvent();
00567         assert(ev.get() != 0);
00568       }
00569       VectorInputSource::EventPrincipalVectorElement e(ev.release());
00570       result.push_back(e);
00571       rootFile_->nextEventEntry();
00572     }
00573   }

void edm::RootInputFileSequence::readMany_ ( int  number,
EventPrincipalVector result 
)

Definition at line 542 of file RootInputFileSequence.cc.

References e, i, readCurrentEvent(), and rootFile_.

00542                                                                            {
00543     for (int i = 0; i < number; ++i) {
00544       std::auto_ptr<EventPrincipal> ev = readCurrentEvent();
00545       if (ev.get() == 0) {
00546         return;
00547       }
00548       VectorInputSource::EventPrincipalVectorElement e(ev.release());
00549       result.push_back(e);
00550       rootFile_->nextEventEntry();
00551     }
00552   }

void edm::RootInputFileSequence::readManyRandom_ ( int  number,
EventPrincipalVector result,
unsigned int fileSeqNumber 
)

Definition at line 576 of file RootInputFileSequence.cc.

References e, eventsRemainingInFile_, fileCatalogItems(), fileIter_, fileIterBegin_, flatDistribution_, i, initFile(), edm::errors::NotFound, readCurrentEvent(), rewindFile(), rootFile_, size, and skipBadFiles_.

00576                                                                                                               {
00577     skipBadFiles_ = false;
00578     unsigned int currentSeqNumber = fileIter_ - fileIterBegin_;
00579     while (eventsRemainingInFile_ < number) {
00580       fileIter_ = fileIterBegin_ + flatDistribution_->fireInt(fileCatalogItems().size());
00581       unsigned int newSeqNumber = fileIter_ - fileIterBegin_;
00582       if (newSeqNumber != currentSeqNumber) {
00583         initFile(false);
00584       }
00585       eventsRemainingInFile_ = rootFile_->eventTree().entries();
00586       if (eventsRemainingInFile_ == 0) {
00587         throw edm::Exception(edm::errors::NotFound) <<
00588            "RootInputFileSequence::readManyRandom_(): Secondary Input file " << fileIter_->fileName() << " contains no events.\n";
00589       }
00590       rootFile_->setAtEventEntry(flatDistribution_->fireInt(eventsRemainingInFile_));
00591     }
00592     fileSeqNumber = fileIter_ - fileIterBegin_;
00593     for (int i = 0; i < number; ++i) {
00594       std::auto_ptr<EventPrincipal> ev = readCurrentEvent();
00595       if (ev.get() == 0) {
00596         rewindFile();
00597         ev = readCurrentEvent();
00598         assert(ev.get() != 0);
00599       }
00600        VectorInputSource::EventPrincipalVectorElement e(ev.release());
00601       result.push_back(e);
00602       --eventsRemainingInFile_;
00603       rootFile_->nextEventEntry();
00604     }
00605   }

boost::shared_ptr< RunPrincipal > edm::RootInputFileSequence::readRun_ (  ) 

Definition at line 278 of file RootInputFileSequence.cc.

References primarySequence_, productRegistry(), and rootFile_.

Referenced by readIt().

00278                                   {
00279     return rootFile_->readRun(primarySequence_ ? productRegistry() : rootFile_->productRegistry()); 
00280   }

int edm::RootInputFileSequence::remainingEvents (  )  const [private]

Definition at line 508 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::remainingEvents().

Referenced by initFile().

00508                                                {
00509     return input_.remainingEvents();
00510   }

int edm::RootInputFileSequence::remainingLuminosityBlocks (  )  const [private]

Definition at line 513 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::remainingLuminosityBlocks().

Referenced by initFile().

00513                                                          {
00514     return input_.remainingLuminosityBlocks();
00515   }

void edm::RootInputFileSequence::rewind_ (  ) 

Definition at line 467 of file RootInputFileSequence.cc.

References duplicateChecker_, fileIter_, fileIterBegin_, firstFile_, and randomAccess_.

00467                                  {
00468     randomAccess_ = false;
00469     firstFile_ = true;
00470     fileIter_ = fileIterBegin_;
00471     if (duplicateChecker_.get() != 0) duplicateChecker_->rewind();
00472   }

void edm::RootInputFileSequence::rewindFile (  )  [private]

Definition at line 476 of file RootInputFileSequence.cc.

References rootFile_.

Referenced by readMany_(), and readManyRandom_().

00476                                     {
00477     rootFile_->rewind();
00478   }

boost::shared_ptr< RunPrincipal > edm::RootInputFileSequence::runPrincipal (  )  const [private]

Definition at line 498 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::runPrincipal().

Referenced by readLuminosityBlock_().

00498                                             {
00499     return input_.runPrincipal();
00500   }

void edm::RootInputFileSequence::skip ( int  offset  ) 

Definition at line 482 of file RootInputFileSequence.cc.

References nextFile(), previousFile(), randomAccess_, and rootFile_.

Referenced by getNextItemType(), and readIt().

00482                                         {
00483     randomAccess_ = true;
00484     while (offset != 0) {
00485       offset = rootFile_->skipEvents(offset);
00486       if (offset > 0 && !nextFile()) return;
00487       if (offset < 0 && !previousFile()) return;
00488     }
00489     rootFile_->skipEvents(0);
00490   }

void edm::RootInputFileSequence::updateProductRegistry (  )  const [private]

Definition at line 210 of file RootInputFileSequence.cc.

References edm::ProductRegistry::copyProduct(), it, productRegistryUpdate(), and rootFile_.

Referenced by RootInputFileSequence().

00210                                                           {
00211     ProductRegistry::ProductList const& prodList = rootFile_->productRegistry()->productList();
00212     for (ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end();
00213         it != itEnd; ++it) {
00214       productRegistryUpdate().copyProduct(it->second);
00215     }
00216   }


Member Data Documentation

BranchDescription::MatchMode edm::RootInputFileSequence::branchesMustMatch_ [private]

Definition at line 93 of file RootInputFileSequence.h.

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

InputFileCatalog const& edm::RootInputFileSequence::catalog_ [private]

Definition at line 86 of file RootInputFileSequence.h.

Referenced by fileCatalogItems(), and initFile().

bool edm::RootInputFileSequence::dropDescendants_ [private]

Definition at line 116 of file RootInputFileSequence.h.

Referenced by initFile().

bool edm::RootInputFileSequence::dropMetaData_ [private]

Definition at line 111 of file RootInputFileSequence.h.

Referenced by initFile().

boost::shared_ptr<edm::DuplicateChecker> edm::RootInputFileSequence::duplicateChecker_ [private]

Definition at line 114 of file RootInputFileSequence.h.

Referenced by closeFile_(), initFile(), rewind_(), and RootInputFileSequence().

int edm::RootInputFileSequence::eventsRemainingInFile_ [private]

Definition at line 97 of file RootInputFileSequence.h.

Referenced by readManyRandom_().

std::vector<EventID> edm::RootInputFileSequence::eventsToProcess_ [private]

Definition at line 103 of file RootInputFileSequence.h.

Referenced by initFile(), and RootInputFileSequence().

unsigned int edm::RootInputFileSequence::eventsToSkip_ [private]

Definition at line 101 of file RootInputFileSequence.h.

Referenced by closeFile_(), and initFile().

std::vector<boost::shared_ptr<FileIndex> > edm::RootInputFileSequence::fileIndexes_ [private]

Definition at line 95 of file RootInputFileSequence.h.

Referenced by initFile(), and readIt().

std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIter_ [private]

Definition at line 90 of file RootInputFileSequence.h.

Referenced by getNextItemType(), initFile(), nextFile(), previousFile(), readIt(), readMany_(), readManyRandom_(), rewind_(), and RootInputFileSequence().

std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIterBegin_ [private]

Definition at line 88 of file RootInputFileSequence.h.

Referenced by initFile(), nextFile(), previousFile(), readIt(), readMany_(), readManyRandom_(), rewind_(), and RootInputFileSequence().

std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIterEnd_ [private]

Definition at line 89 of file RootInputFileSequence.h.

Referenced by getNextItemType(), nextFile(), previousFile(), and RootInputFileSequence().

bool edm::RootInputFileSequence::firstFile_ [private]

Definition at line 87 of file RootInputFileSequence.h.

Referenced by getNextItemType(), readFile_(), and rewind_().

CLHEP::RandFlat* edm::RootInputFileSequence::flatDistribution_ [private]

Definition at line 94 of file RootInputFileSequence.h.

Referenced by readManyRandom_(), and RootInputFileSequence().

int edm::RootInputFileSequence::forcedRunOffset_ [private]

Definition at line 108 of file RootInputFileSequence.h.

Referenced by initFile(), and RootInputFileSequence().

GroupSelectorRules edm::RootInputFileSequence::groupSelectorRules_ [private]

Definition at line 110 of file RootInputFileSequence.h.

Referenced by dropUnwantedBranches_(), and initFile().

PoolSource const& edm::RootInputFileSequence::input_ [private]

Definition at line 85 of file RootInputFileSequence.h.

Referenced by closeFile_(), initFile(), primary(), processConfiguration(), productRegistry(), productRegistryUpdate(), remainingEvents(), remainingLuminosityBlocks(), and runPrincipal().

bool edm::RootInputFileSequence::noEventSort_ [private]

Definition at line 104 of file RootInputFileSequence.h.

Referenced by initFile(), and RootInputFileSequence().

BranchDescription::MatchMode edm::RootInputFileSequence::parametersMustMatch_ [private]

Definition at line 92 of file RootInputFileSequence.h.

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

bool edm::RootInputFileSequence::primarySequence_ [private]

Definition at line 112 of file RootInputFileSequence.h.

Referenced by closeFile_(), initFile(), logFileAction(), nextFile(), previousFile(), readCurrentEvent(), readEvent_(), readLuminosityBlock_(), readRun_(), and RootInputFileSequence().

bool edm::RootInputFileSequence::randomAccess_ [private]

Definition at line 113 of file RootInputFileSequence.h.

Referenced by getNextItemType(), readIt(), rewind_(), and skip().

RootFileSharedPtr edm::RootInputFileSequence::rootFile_ [private]

Definition at line 91 of file RootInputFileSequence.h.

Referenced by closeFile_(), endJob(), fileProductRegistry(), getNextItemType(), initFile(), nextFile(), previousFile(), readCurrentEvent(), readEvent_(), readFile_(), readIt(), readLuminosityBlock_(), readMany_(), readManyRandom_(), readRun_(), rewindFile(), RootInputFileSequence(), skip(), and updateProductRegistry().

RunNumber_t edm::RootInputFileSequence::setRun_ [private]

Definition at line 109 of file RootInputFileSequence.h.

Referenced by RootInputFileSequence().

bool edm::RootInputFileSequence::skipBadFiles_ [private]

Definition at line 105 of file RootInputFileSequence.h.

Referenced by nextFile(), readFile_(), readManyRandom_(), and RootInputFileSequence().

EventNumber_t edm::RootInputFileSequence::startAtEvent_ [private]

Definition at line 100 of file RootInputFileSequence.h.

Referenced by initFile(), and RootInputFileSequence().

LuminosityBlockNumber_t edm::RootInputFileSequence::startAtLumi_ [private]

Definition at line 99 of file RootInputFileSequence.h.

Referenced by initFile().

RunNumber_t edm::RootInputFileSequence::startAtRun_ [private]

Definition at line 98 of file RootInputFileSequence.h.

Referenced by initFile().

unsigned int edm::RootInputFileSequence::treeCacheSize_ [private]

Definition at line 106 of file RootInputFileSequence.h.

Referenced by initFile().

int const edm::RootInputFileSequence::treeMaxVirtualSize_ [private]

Definition at line 107 of file RootInputFileSequence.h.

Referenced by initFile().

std::vector<LuminosityBlockID> edm::RootInputFileSequence::whichLumisToSkip_ [private]

Definition at line 102 of file RootInputFileSequence.h.

Referenced by initFile().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:44:13 2009 for CMSSW by  doxygen 1.5.4