00001
00002
00003 #include "RootInputFileSequence.h"
00004 #include "PoolSource.h"
00005 #include "RootFile.h"
00006 #include "RootTree.h"
00007 #include "DuplicateChecker.h"
00008
00009 #include "FWCore/Catalog/interface/FileCatalog.h"
00010 #include "FWCore/Framework/interface/EventPrincipal.h"
00011 #include "FWCore/Framework/interface/FileBlock.h"
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 #include "DataFormats/Provenance/interface/ProductRegistry.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00017 #include "FWCore/Utilities/interface/Algorithms.h"
00018 #include "Utilities/StorageFactory/interface/StorageFactory.h"
00019
00020 #include "CLHEP/Random/RandFlat.h"
00021 #include "TFile.h"
00022
00023 #include <ctime>
00024
00025 namespace edm {
00026 RootInputFileSequence::RootInputFileSequence(
00027 ParameterSet const& pset,
00028 PoolSource const& input,
00029 InputFileCatalog const& catalog,
00030 bool primarySequence) :
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
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 }
00116
00117 std::vector<FileCatalogItem> const&
00118 RootInputFileSequence::fileCatalogItems() const {
00119 return catalog_.fileCatalogItems();
00120 }
00121
00122 void
00123 RootInputFileSequence::endJob() {
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 }
00134
00135 boost::shared_ptr<FileBlock>
00136 RootInputFileSequence::readFile_() {
00137 if (firstFile_) {
00138
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 }
00159
00160 void RootInputFileSequence::closeFile_() {
00161 if (rootFile_) {
00162
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 }
00174
00175 void RootInputFileSequence::initFile(bool skipBadFiles) {
00176
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 }
00209
00210 void RootInputFileSequence::updateProductRegistry() const {
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 }
00217
00218 ProductRegistry const&
00219 RootInputFileSequence::fileProductRegistry() const {
00220 return *rootFile_->productRegistry();
00221 }
00222
00223 bool RootInputFileSequence::nextFile() {
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
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 }
00247
00248 bool RootInputFileSequence::previousFile() {
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
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 }
00273
00274 RootInputFileSequence::~RootInputFileSequence() {
00275 }
00276
00277 boost::shared_ptr<RunPrincipal>
00278 RootInputFileSequence::readRun_() {
00279 return rootFile_->readRun(primarySequence_ ? productRegistry() : rootFile_->productRegistry());
00280 }
00281
00282 boost::shared_ptr<LuminosityBlockPrincipal>
00283 RootInputFileSequence::readLuminosityBlock_() {
00284 return rootFile_->readLumi(primarySequence_ ? productRegistry() : rootFile_->productRegistry(), runPrincipal());
00285 }
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 std::auto_ptr<EventPrincipal>
00302 RootInputFileSequence::readEvent_() {
00303 return rootFile_->readEvent(primarySequence_ ? productRegistry() : rootFile_->productRegistry());
00304 }
00305
00306 std::auto_ptr<EventPrincipal>
00307 RootInputFileSequence::readCurrentEvent() {
00308 return rootFile_->readCurrentEvent(primarySequence_ ?
00309 productRegistry() :
00310 rootFile_->productRegistry());
00311 }
00312
00313 std::auto_ptr<EventPrincipal>
00314 RootInputFileSequence::readIt(EventID const& id, LuminosityBlockNumber_t lumi, bool exact) {
00315 randomAccess_ = true;
00316
00317 bool found = rootFile_->setEntryAtEvent(id.run(), lumi, id.event(), exact);
00318 if (!found) {
00319
00320 if (fileIndexes_.size() == 1) {
00321 return std::auto_ptr<EventPrincipal>(0);
00322 }
00323
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
00328 fileIter_ = fileIterBegin_ + (it - fileIndexes_.begin());
00329 initFile(false);
00330
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
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
00352 return std::auto_ptr<EventPrincipal>(0);
00353 }
00354 std::auto_ptr<EventPrincipal> eptr = readCurrentEvent();
00355 skip(1);
00356 return eptr;
00357 }
00358
00359 boost::shared_ptr<LuminosityBlockPrincipal>
00360 RootInputFileSequence::readIt(LuminosityBlockID const& id) {
00361
00362
00363 bool found = rootFile_->setEntryAtLumi(id);
00364 if (found) {
00365 return readLuminosityBlock_();
00366 }
00367
00368 if (fileIndexes_.size() > 1) {
00369
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
00374 fileIter_ = fileIterBegin_ + (it - fileIndexes_.begin());
00375 initFile(false);
00376
00377 found = rootFile_->setEntryAtLumi(id);
00378 assert (found);
00379 return readLuminosityBlock_();
00380 }
00381 }
00382
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 }
00396
00397 boost::shared_ptr<RunPrincipal>
00398 RootInputFileSequence::readIt(RunID const& id) {
00399
00400
00401 bool found = rootFile_->setEntryAtRun(id);
00402 if (found) {
00403 return readRun_();
00404 }
00405 if (fileIndexes_.size() > 1) {
00406
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
00411 fileIter_ = fileIterBegin_ + (it - fileIndexes_.begin());
00412 initFile(false);
00413
00414 found = rootFile_->setEntryAtRun(id);
00415 assert (found);
00416 return readRun_();
00417 }
00418 }
00419
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 }
00433
00434 InputSource::ItemType
00435 RootInputFileSequence::getNextItemType() {
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 }
00464
00465
00466 void
00467 RootInputFileSequence::rewind_() {
00468 randomAccess_ = false;
00469 firstFile_ = true;
00470 fileIter_ = fileIterBegin_;
00471 if (duplicateChecker_.get() != 0) duplicateChecker_->rewind();
00472 }
00473
00474
00475 void
00476 RootInputFileSequence::rewindFile() {
00477 rootFile_->rewind();
00478 }
00479
00480
00481 void
00482 RootInputFileSequence::skip(int offset) {
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 }
00491
00492 bool const
00493 RootInputFileSequence::primary() const {
00494 return input_.primary();
00495 }
00496
00497 boost::shared_ptr<RunPrincipal>
00498 RootInputFileSequence::runPrincipal() const {
00499 return input_.runPrincipal();
00500 }
00501
00502 ProcessConfiguration const&
00503 RootInputFileSequence::processConfiguration() const {
00504 return input_.processConfiguration();
00505 }
00506
00507 int
00508 RootInputFileSequence::remainingEvents() const {
00509 return input_.remainingEvents();
00510 }
00511
00512 int
00513 RootInputFileSequence::remainingLuminosityBlocks() const {
00514 return input_.remainingLuminosityBlocks();
00515 }
00516
00517 ProductRegistry &
00518 RootInputFileSequence::productRegistryUpdate() const{
00519 return input_.productRegistryUpdate();
00520 }
00521
00522 boost::shared_ptr<ProductRegistry const>
00523 RootInputFileSequence::productRegistry() const{
00524 return input_.productRegistry();
00525 }
00526
00527 void
00528 RootInputFileSequence::dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) {
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 }
00540
00541 void
00542 RootInputFileSequence::readMany_(int number, EventPrincipalVector& result) {
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 }
00553
00554 void
00555 RootInputFileSequence::readMany_(int number, EventPrincipalVector& result, EventID const& id, unsigned int fileSeqNumber) {
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 }
00574
00575 void
00576 RootInputFileSequence::readManyRandom_(int number, EventPrincipalVector& result, unsigned int& fileSeqNumber) {
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 }
00606
00607 void RootInputFileSequence::logFileAction(const char* msg, std::string const& file) {
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 }
00616 }
00617