CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RootInputFileSequence.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
4 #include "PoolSource.h"
5 #include "RootFile.h"
6 #include "RootTree.h"
7 #include "DuplicateChecker.h"
8 
20 
21 #include "CLHEP/Random/RandFlat.h"
22 #include "InputFile.h"
23 #include "TSystem.h"
24 
25 namespace edm {
26  namespace {
27  std::string const streamerInfo = std::string("StreamerInfo");
28  }
30  ParameterSet const& pset,
31  PoolSource const& input,
33  PrincipalCache& cache,
34  bool primaryFiles) :
35  input_(input),
36  catalog_(catalog),
37  firstFile_(true),
38  fileIterBegin_(fileCatalogItems().begin()),
39  fileIterEnd_(fileCatalogItems().end()),
40  fileIter_(fileIterEnd_),
41  fileIterLastOpened_(fileIterEnd_),
42  rootFile_(),
43  parametersMustMatch_(BranchDescription::Permissive),
44  branchesMustMatch_(BranchDescription::Permissive),
45  flatDistribution_(),
46  indexesIntoFiles_(fileCatalogItems().size()),
47  orderedProcessHistoryIDs_(),
48  eventSkipperByID_(primaryFiles ? EventSkipperByID::create(pset).release() : 0),
49  eventsRemainingInFile_(0),
50  // The default value provided as the second argument to the getUntrackedParameter function call
51  // is not used when the ParameterSet has been validated and the parameters are not optional
52  // in the description. This is currently true when PoolSource is the primary input source.
53  // The modules that use PoolSource as a SecSource have not defined their fillDescriptions function
54  // yet, so the ParameterSet does not get validated yet. As soon as all the modules with a SecSource
55  // have defined descriptions, the defaults in the getUntrackedParameterSet function calls can
56  // and should be deleted from the code.
57  numberOfEventsToSkip_(primaryFiles ? pset.getUntrackedParameter<unsigned int>("skipEvents", 0U) : 0U),
58  noEventSort_(primaryFiles ? pset.getUntrackedParameter<bool>("noEventSort", true) : false),
59  skipBadFiles_(pset.getUntrackedParameter<bool>("skipBadFiles", false)),
60  treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>("cacheSize", roottree::defaultCacheSize) : 0U),
61  treeMaxVirtualSize_(pset.getUntrackedParameter<int>("treeMaxVirtualSize", -1)),
62  setRun_(pset.getUntrackedParameter<unsigned int>("setRunNumber", 0U)),
63  groupSelectorRules_(pset, "inputCommands", "InputSource"),
64  primaryFiles_(primaryFiles),
65  duplicateChecker_(primaryFiles ? new DuplicateChecker(pset) : 0),
66  dropDescendants_(pset.getUntrackedParameter<bool>("dropDescendantsOfDroppedBranches", primary())),
67  usingGoToEvent_(false) {
68 
69  //we now allow the site local config to specify what the TTree cache size should be
71  if(treeCacheSize_ != 0U && pSLC.isAvailable() && pSLC->sourceTTreeCacheSize()) {
72  treeCacheSize_ = *(pSLC->sourceTTreeCacheSize());
73  }
74 
75  if(primaryFiles_) {
76  //NOTE: we do not want to stage in secondary files since we can be given a list of
77  // thousands of files and prestaging all those files can cause a site to fail
80  factory->activateTimeout(fileIter_->fileName());
81  factory->stagein(fileIter_->fileName());
82  }
83  }
84 
85  std::string parametersMustMatch = pset.getUntrackedParameter<std::string>("parametersMustMatch", std::string("permissive"));
86  if(parametersMustMatch == std::string("strict")) parametersMustMatch_ = BranchDescription::Strict;
87 
88  std::string branchesMustMatch = pset.getUntrackedParameter<std::string>("branchesMustMatch", std::string("permissive"));
89  if(branchesMustMatch == std::string("strict")) branchesMustMatch_ = BranchDescription::Strict;
90 
91  if(primary()) {
94  if(rootFile_) break;
95  }
96  if(rootFile_) {
97  productRegistryUpdate().updateFromInput(rootFile_->productRegistry()->productList());
98  if(numberOfEventsToSkip_ != 0) {
100  }
101  }
102  }
103  }
104 
105  std::vector<FileCatalogItem> const&
107  return catalog_.fileCatalogItems();
108  }
109 
110  void
112  closeFile_();
113  }
114 
115  boost::shared_ptr<FileBlock>
117  if(firstFile_) {
118  // The first input file has already been opened.
119  firstFile_ = false;
120  if(!rootFile_) {
122  }
123  } else {
124  if(!nextFile(cache)) {
125  assert(0);
126  }
127  }
128  if(!rootFile_) {
129  return boost::shared_ptr<FileBlock>(new FileBlock);
130  }
131  return rootFile_->createFileBlock();
132  }
133 
135  // close the currently open file, if any, and delete the RootFile object.
136  if(rootFile_) {
137  if (primary()) {
138  std::auto_ptr<InputSource::FileCloseSentry>
140  rootFile_->close();
141  if(duplicateChecker_) duplicateChecker_->inputFileClosed();
142  }
143  rootFile_.reset();
144  }
145  }
146 
147  void RootInputFileSequence::initFile(bool skipBadFiles) {
148  // We are really going to close the open file.
149 
150  // If this is the primary sequence, we are not duplicate checking across files
151  // and we are not using random access to find events, then we can delete the
152  // IndexIntoFile for the file we are closing. If we can't delete all of it,
153  // then we can delete the parts we do not need.
155  size_t currentIndexIntoFile = fileIterLastOpened_ - fileIterBegin_;
156  bool needIndexesForDuplicateChecker = duplicateChecker_ && duplicateChecker_->checkingAllFiles() && !duplicateChecker_->checkDisabled();
157  bool deleteIndexIntoFile = primaryFiles_ &&
158  !needIndexesForDuplicateChecker &&
160  if (deleteIndexIntoFile) {
161  indexesIntoFiles_[currentIndexIntoFile].reset();
162  } else {
163  if (indexesIntoFiles_[currentIndexIntoFile]) indexesIntoFiles_[currentIndexIntoFile]->inputFileClosed();
164  }
166  }
167  closeFile_();
168 
169  // Determine whether we have a fallback URL specified; if so, prepare it;
170  // Only valid if it is non-empty and differs from the original filename.
171  std::string fallbackName = fileIter_->fallbackFileName();
172  bool hasFallbackUrl = (!fallbackName.empty()) || (fallbackName == fileIter_->fileName());
173 
174  boost::shared_ptr<InputFile> filePtr;
175  try {
176  std::auto_ptr<InputSource::FileOpenSentry>
178  filePtr.reset(new InputFile(gSystem->ExpandPathName(fileIter_->fileName().c_str()), " Initiating request to open file "));
179  }
180  catch (cms::Exception const& e) {
181  if(!skipBadFiles && !hasFallbackUrl) {
182  if(e.explainSelf().find(streamerInfo) != std::string::npos) {
183  throw Exception(errors::FileReadError) << e.explainSelf() << "\n" <<
184  "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " could not be read properly.\n" <<
185  "Possibly the format is incompatible with the current release.\n";
186  }
187  throw Exception(errors::FileOpenError) << e.explainSelf() << "\n" <<
188  "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " was not found, could not be opened, or is corrupted.\n";
189  }
190  }
191  if(!filePtr && (hasFallbackUrl)) {
192  try {
193  std::auto_ptr<InputSource::FileOpenSentry>
195  filePtr.reset(new InputFile(gSystem->ExpandPathName(fallbackName.c_str()), " Fallback request to file "));
196  }
197  catch (cms::Exception const& e) {
198  if(!skipBadFiles) {
199  if(e.explainSelf().find(streamerInfo) != std::string::npos) {
200  throw Exception(errors::FileReadError) << e.explainSelf() << "\n" <<
201  "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " could not be read properly.\n" <<
202  "Possibly the format is incompatible with the current release.\n";
203  }
204  throw Exception(errors::FileOpenError) << e.explainSelf() << "\n" <<
205  "RootInputFileSequence::initFile(): Input fallback file " << fallbackName << " was not found, could not be opened, or is corrupted.\n";
206  }
207  }
208  }
209  if(filePtr) {
210  std::vector<boost::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile = fileIter_ - fileIterBegin_;
211  rootFile_ = RootFileSharedPtr(new RootFile(fileIter_->fileName(),
212  processConfiguration(), fileIter_->logicalFileName(), filePtr,
216  setRun_,
217  noEventSort_,
220 
222  indexesIntoFiles_[currentIndexIntoFile] = rootFile_->indexIntoFileSharedPtr();
223  rootFile_->reportOpened(primary() ?
224  (primaryFiles_ ? "primaryFiles" : "secondaryFiles") : "mixingFiles");
225  } else {
226  if(!skipBadFiles) {
228  "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " was not found or could not be opened.\n";
229  }
230  LogWarning("") << "Input file: " << fileIter_->fileName() << " was not found or could not be opened, and will be skipped.\n";
231  }
232  }
233 
234  boost::shared_ptr<ProductRegistry const>
236  return rootFile_->productRegistry();
237  }
238 
241  if(fileIter_ == fileIterEnd_) {
242  if(primaryFiles_) {
243  return false;
244  } else {
246  }
247  }
248 
250 
251  if(primaryFiles_ && rootFile_) {
252  size_t size = productRegistry()->size();
253  // make sure the new product registry is compatible with the main one
254  std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(),
255  fileIter_->fileName(),
258  if(!mergeInfo.empty()) {
259  throw Exception(errors::MismatchedInputFiles,"RootInputFileSequence::nextFile()") << mergeInfo;
260  }
261  if (productRegistry()->size() > size) {
263  }
265  }
266  return true;
267  }
268 
270  if(fileIter_ == fileIterBegin_) {
271  if(primaryFiles_) {
272  return false;
273  } else {
275  }
276  }
277  --fileIter_;
278 
279  initFile(false);
280 
281  if(primaryFiles_ && rootFile_) {
282  size_t size = productRegistry()->size();
283  // make sure the new product registry is compatible to the main one
284  std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(),
285  fileIter_->fileName(),
288  if(!mergeInfo.empty()) {
289  throw Exception(errors::MismatchedInputFiles,"RootInputFileSequence::previousEvent()") << mergeInfo;
290  }
291  if (productRegistry()->size() > size) {
293  }
295  }
296  if(rootFile_) rootFile_->setToLastEntry();
297  return true;
298  }
299 
301  }
302 
303  boost::shared_ptr<RunAuxiliary>
305  boost::shared_ptr<RunAuxiliary> aux = rootFile_->readRunAuxiliary_();
306  return aux;
307  }
308 
309  boost::shared_ptr<LuminosityBlockAuxiliary>
311  boost::shared_ptr<LuminosityBlockAuxiliary> aux = rootFile_->readLuminosityBlockAuxiliary_();
312  return aux;
313  }
314 
315  boost::shared_ptr<RunPrincipal>
316  RootInputFileSequence::readRun_(boost::shared_ptr<RunPrincipal> rpCache) {
317  return rootFile_->readRun_(rpCache);
318  }
319 
320  boost::shared_ptr<LuminosityBlockPrincipal>
321  RootInputFileSequence::readLuminosityBlock_(boost::shared_ptr<LuminosityBlockPrincipal> lbCache) {
322  return rootFile_->readLumi(lbCache);
323  }
324 
325  // readEvent() is responsible for setting up the EventPrincipal.
326  //
327  // 1. create an EventPrincipal with a unique EventID
328  // 2. For each entry in the provenance, put in one Group,
329  // holding the Provenance for the corresponding EDProduct.
330  // 3. set up the caches in the EventPrincipal to know about this
331  // Group.
332  //
333  // We do *not* create the EDProduct instance (the equivalent of reading
334  // the branch containing this EDProduct. That will be done by the Delayed Reader,
335  // when it is asked to do so.
336  //
337 
339  RootInputFileSequence::readEvent(EventPrincipal& cache, boost::shared_ptr<LuminosityBlockPrincipal> lb) {
340  return rootFile_->readEvent(cache, rootFile_, lb);
341  }
342 
345  if(fileIter_ == fileIterEnd_) {
346  return InputSource::IsStop;
347  }
348  if(firstFile_) {
349  return InputSource::IsFile;
350  }
351  if(rootFile_) {
352  IndexIntoFile::EntryType entryType = rootFile_->getNextEntryTypeWanted();
353  if(entryType == IndexIntoFile::kEvent) {
354  return InputSource::IsEvent;
355  } else if(entryType == IndexIntoFile::kLumi) {
356  return InputSource::IsLumi;
357  } else if(entryType == IndexIntoFile::kRun) {
358  return InputSource::IsRun;
359  }
360  assert(entryType == IndexIntoFile::kEnd);
361  }
362  if(fileIter_ + 1 == fileIterEnd_) {
363  return InputSource::IsStop;
364  }
365  return InputSource::IsFile;
366  }
367 
368  // Rewind to before the first event that was read.
369  void
371  if (fileIter_ != fileIterBegin_) {
372  closeFile_();
374  }
375  if (!rootFile_) {
376  initFile(false);
377  }
378  rewindFile();
379  firstFile_ = true;
380  }
381 
382  // Rewind to the beginning of the current file
383  void
385  rootFile_->rewind();
386  }
387 
388  void
390  //NOTE: Need to handle duplicate checker
391  // Also what if skipBadFiles_==true and the first time we succeeded but after a reset we fail?
392  if(primary()) {
393  firstFile_ = true;
396  if(rootFile_) break;
397  }
398  if(rootFile_) {
399  if(numberOfEventsToSkip_ != 0) {
401  }
402  }
403  }
404  }
405 
406  // Advance "offset" events. Offset can be positive or negative (or zero).
407  bool
409  assert (numberOfEventsToSkip_ == 0 || numberOfEventsToSkip_ == offset);
411  while(numberOfEventsToSkip_ != 0) {
412  bool atEnd = rootFile_->skipEvents(numberOfEventsToSkip_);
413  if((numberOfEventsToSkip_ > 0 || atEnd) && !nextFile(cache)) {
415  return false;
416  }
417  if(numberOfEventsToSkip_ < 0 && !previousFile(cache)) {
420  return false;
421  }
422  }
423  return true;
424  }
425 
426  bool
428  usingGoToEvent_ = true;
429  if (rootFile_) {
430  if (rootFile_->goToEvent(eventID)) {
431  return true;
432  }
433  // If only one input file, give up now, to save time.
434  if(rootFile_ && indexesIntoFiles_.size() == 1) {
435  return false;
436  }
437  // Save the current file and position so that we can restore them
438  // if we fail to restore the desired event
439  bool closedOriginalFile = false;
440  std::vector<FileCatalogItem>::const_iterator originalFile = fileIter_;
441  IndexIntoFile::IndexIntoFileItr originalPosition = rootFile_->indexIntoFileIter();
442 
443  // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files.
444  typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
445  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
446  if(*it && (*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) {
447  // We found it. Close the currently open file, and open the correct one.
448  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
449  initFile(false);
450  // Now get the item from the correct file.
451  bool found = rootFile_->goToEvent(eventID);
452  assert (found);
453  return true;
454  }
455  }
456  // Look for item in files not yet opened.
457  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
458  if(!*it) {
459  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
460  initFile(false);
461  closedOriginalFile = true;
462  if ((*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) {
463  if (rootFile_->goToEvent(eventID)) {
464  return true;
465  }
466  }
467  }
468  }
469  if (closedOriginalFile) {
470  fileIter_ = originalFile;
471  initFile(false);
472  rootFile_->setPosition(originalPosition);
473  }
474  }
475  return false;
476  }
477 
478  bool
480  // Attempt to find item in currently open input file.
481  bool found = rootFile_ && rootFile_->setEntryAtItem(run, lumi, event);
482  if(!found) {
483  // If only one input file, give up now, to save time.
484  if(rootFile_ && indexesIntoFiles_.size() == 1) {
485  return false;
486  }
487  // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files.
488  typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
489  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
490  if(*it && (*it)->containsItem(run, lumi, event)) {
491  // We found it. Close the currently open file, and open the correct one.
492  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
493  initFile(false);
494  // Now get the item from the correct file.
495  found = rootFile_->setEntryAtItem(run, lumi, event);
496  assert (found);
497  return true;
498  }
499  }
500  // Look for item in files not yet opened.
501  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
502  if(!*it) {
503  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
504  initFile(false);
505  found = rootFile_->setEntryAtItem(run, lumi, event);
506  if(found) {
507  return true;
508  }
509  }
510  }
511  // Not found
512  return false;
513  }
514  return true;
515  }
516 
517  bool const
519  return input_.primary();
520  }
521 
522  ProcessConfiguration const&
524  return input_.processConfiguration();
525  }
526 
527  int
529  return input_.remainingEvents();
530  }
531 
532  int
535  }
536 
539  return input_.productRegistryUpdate();
540  }
541 
542  boost::shared_ptr<ProductRegistry const>
544  return input_.productRegistry();
545  }
546 
547  void
548  RootInputFileSequence::dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) {
549  std::vector<std::string> rules;
550  rules.reserve(wantedBranches.size() + 1);
551  rules.push_back(std::string("drop *"));
552  for(std::vector<std::string>::const_iterator it = wantedBranches.begin(), itEnd = wantedBranches.end();
553  it != itEnd; ++it) {
554  rules.push_back("keep " + *it + "_*");
555  }
557  pset.addUntrackedParameter("inputCommands", rules);
558  groupSelectorRules_ = GroupSelectorRules(pset, "inputCommands", "InputSource");
559  }
560 
561  void
563  for(int i = 0; i < number; ++i) {
564  boost::shared_ptr<EventPrincipal> ep(new EventPrincipal(rootFile_->productRegistry(), processConfiguration()));
565  EventPrincipal* ev = rootFile_->readCurrentEvent(*ep, rootFile_);
566  if(ev == 0) {
567  return;
568  }
569  assert(ev == ep.get());
570  result.push_back(ep);
571  rootFile_->nextEventEntry();
572  }
573  }
574 
575  void
576  RootInputFileSequence::readManyRandom(int number, EventPrincipalVector& result, unsigned int& fileSeqNumber) {
577  if(0 != number && (fileIterEnd_ == fileIterBegin_) ) {
578  throw Exception(errors::Configuration) << "RootInputFileSequence::readManyRandom(): no input files specified.\n";
579  }
580  result.reserve(number);
581  if (!flatDistribution_) {
583  CLHEP::HepRandomEngine& engine = rng->getEngine();
584  flatDistribution_.reset(new CLHEP::RandFlat(engine));
585  }
586  skipBadFiles_ = false;
587  unsigned int currentSeqNumber = fileIter_ - fileIterBegin_;
588  while(eventsRemainingInFile_ < number) {
589  fileIter_ = fileIterBegin_ + flatDistribution_->fireInt(fileCatalogItems().size());
590  unsigned int newSeqNumber = fileIter_ - fileIterBegin_;
591  if(newSeqNumber != currentSeqNumber) {
592  initFile(false);
593  currentSeqNumber = newSeqNumber;
594  }
595  eventsRemainingInFile_ = rootFile_->eventTree().entries();
596  if(eventsRemainingInFile_ == 0) {
597  throw Exception(errors::NotFound) <<
598  "RootInputFileSequence::readManyRandom_(): Secondary Input file " << fileIter_->fileName() << " contains no events.\n";
599  }
600  rootFile_->setAtEventEntry(flatDistribution_->fireInt(eventsRemainingInFile_));
601  }
602  fileSeqNumber = fileIter_ - fileIterBegin_;
603  for(int i = 0; i < number; ++i) {
604  boost::shared_ptr<EventPrincipal> ep(new EventPrincipal(rootFile_->productRegistry(), processConfiguration()));
605  EventPrincipal* ev = rootFile_->readCurrentEvent(*ep, rootFile_);
606  if(ev == 0) {
607  rewindFile();
608  ev = rootFile_->readCurrentEvent(*ep, rootFile_);
609  assert(ev != 0);
610  }
611  assert(ev == ep.get());
612  result.push_back(ep);
614  rootFile_->nextEventEntry();
615  }
616  }
617 
618  void
619  RootInputFileSequence::readManySequential(int number, EventPrincipalVector& result, unsigned int& fileSeqNumber) {
620  if(0 != number && (fileIterEnd_ == fileIterBegin_) ) {
621  throw Exception(errors::Configuration) << "RootInputFileSequence::readManySequential(): no input files specified.\n";
622  }
623  result.reserve(number);
624  skipBadFiles_ = false;
625  if (fileIter_ == fileIterEnd_ || !rootFile_) {
627  initFile(false);
628  rootFile_->setAtEventEntry(0);
629  }
630  fileSeqNumber = fileIter_ - fileIterBegin_;
631  unsigned int numberRead = 0;
632  for(int i = 0; i < number; ++i) {
633  boost::shared_ptr<EventPrincipal> ep(new EventPrincipal(rootFile_->productRegistry(), processConfiguration()));
634  EventPrincipal* ev = rootFile_->readCurrentEvent(*ep, rootFile_);
635  if(ev == 0) {
636  if (numberRead == 0) {
637  ++fileIter_;
638  fileSeqNumber = fileIter_ - fileIterBegin_;
639  if (fileIter_ == fileIterEnd_) {
640  return;
641  }
642  initFile(false);
643  rootFile_->setAtEventEntry(0);
644  return readManySequential(number, result, fileSeqNumber);
645  }
646  return;
647  }
648  assert(ev == ep.get());
649  result.push_back(ep);
650  ++numberRead;
651  rootFile_->nextEventEntry();
652  }
653  }
654 
655  void
657  skipBadFiles_ = false;
658  result.reserve(events.size());
659  for (std::vector<EventID>::const_iterator it = events.begin(), itEnd = events.end(); it != itEnd; ++it) {
660  bool found = skipToItem(it->run(), it->luminosityBlock(), it->event());
661  if (!found) {
662  throw Exception(errors::NotFound) <<
663  "RootInputFileSequence::readManySpecified_(): Secondary Input file " <<
664  fileIter_->fileName() <<
665  " does not contain specified event:\n" << *it << "\n";
666  }
667  boost::shared_ptr<EventPrincipal> ep(new EventPrincipal(rootFile_->productRegistry(), processConfiguration()));
668  EventPrincipal* ev = rootFile_->readCurrentEvent(*ep, rootFile_);
669  if (ev == 0) {
671  "RootInputFileSequence::readManySpecified_(): Secondary Input file " <<
672  fileIter_->fileName() <<
673  " contains specified event " << *it << " that cannot be read.\n";
674  }
675  assert(ev == ep.get());
676  result.push_back(ep);
677  }
678  }
679 
680  void
682  desc.addUntracked<unsigned int>("skipEvents", 0U)
683  ->setComment("Skip the first 'skipEvents' events that otherwise would have been processed.");
684  desc.addUntracked<bool>("noEventSort", true)
685  ->setComment("True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
686  "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
687  "Note 1: Events within the same lumi will always be processed contiguously.\n"
688  "Note 2: Lumis within the same run will always be processed contiguously.\n"
689  "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
690  desc.addUntracked<bool>("skipBadFiles", false)
691  ->setComment("True: Ignore any missing or unopenable input file.\n"
692  "False: Throw exception if missing or unopenable input file.");
693  desc.addUntracked<unsigned int>("cacheSize", roottree::defaultCacheSize)
694  ->setComment("Size of ROOT TTree prefetch cache. Affects performance.");
695  desc.addUntracked<int>("treeMaxVirtualSize", -1)
696  ->setComment("Size of ROOT TTree TBasket cache. Affects performance.");
697  desc.addUntracked<unsigned int>("setRunNumber", 0U)
698  ->setComment("If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
699  desc.addUntracked<bool>("dropDescendantsOfDroppedBranches", true)
700  ->setComment("If True, also drop on input any descendent of any branch dropped on input.");
701  std::string defaultString("permissive");
702  desc.addUntracked<std::string>("parametersMustMatch", defaultString)
703  ->setComment("'strict': Values of tracked parameters must be unique across all input files.\n"
704  "'permissive': Values of tracked parameters may differ across or within files.");
705  desc.addUntracked<std::string>("branchesMustMatch", defaultString)
706  ->setComment("'strict': Branches in each input file must match those in the first file.\n"
707  "'permissive': Branches in each input file may be any subset of those in the first file.");
708 
709  GroupSelectorRules::fillDescription(desc, "inputCommands");
712  }
713 
716  if (rootFile_) {
717  if (!rootFile_->wasLastEventJustRead()) {
719  }
720  std::vector<FileCatalogItem>::const_iterator itr(fileIter_);
721  if (itr != fileIterEnd_) ++itr;
722  if (itr != fileIterEnd_) {
724  }
726  }
728  }
729 
732  if (rootFile_) {
733  if (!rootFile_->wasFirstEventJustRead()) {
735  }
736  if (fileIter_ != fileIterBegin_) {
738  }
740  }
742  }
743 }
RunNumber_t run() const
Definition: EventID.h:42
void readManySequential(int number, EventPrincipalVector &result, unsigned int &fileSeqNumber)
boost::shared_ptr< RunPrincipal > readRun_(boost::shared_ptr< RunPrincipal > rpCache)
ProcessingController::ForwardState forwardState() const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
boost::shared_ptr< ProductRegistry const > fileProductRegistry() const
int i
Definition: DBlmapReader.cc:9
std::vector< boost::shared_ptr< IndexIntoFile > > indexesIntoFiles_
void stagein(const std::string &url)
void initFile(bool skipBadFiles)
bool goToEvent(EventID const &eventID, PrincipalCache &cache)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
RootInputFileSequence(ParameterSet const &pset, PoolSource const &input, InputFileCatalog const &catalog, PrincipalCache &cache, bool primaryFiles)
ProcessConfiguration const & processConfiguration() const
unsigned int EventNumber_t
Definition: EventID.h:30
EventPrincipal * readEvent(EventPrincipal &cache, boost::shared_ptr< LuminosityBlockPrincipal > lb)
bool const primary() const
Accessor for primary input source flag.
Definition: InputSource.h:193
VectorInputSource::EventPrincipalVector EventPrincipalVector
virtual std::string explainSelf() const
Definition: Exception.cc:56
boost::shared_ptr< RunAuxiliary > readRunAuxiliary_()
std::vector< FileCatalogItem >::const_iterator fileIter_
tuple lumi
Definition: fjr2json.py:41
ProductRegistry & productRegistryUpdate() const
GroupSelectorRules groupSelectorRules_
boost::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_()
ProcessingMode processingMode() const
RunsLumisAndEvents (default), RunsAndLumis, or Runs.
Definition: InputSource.h:233
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
static void fillDescription(ParameterSetDescription &desc)
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode parametersMustMatch=BranchDescription::Permissive, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
static void fillDescription(ParameterSetDescription &desc, char const *parameterName)
void adjustIndexesAfterProductRegistryAddition()
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:43
unsigned int const defaultCacheSize
Definition: RootTree.h:39
uint16_t size_type
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
static void fillDescription(ParameterSetDescription &desc)
bool skipEvents(int offset, PrincipalCache &cache)
static StorageFactory * get(void)
tuple InputFile
Open Root file and provide MEs ############.
void adjustEventToNewProductRegistry(boost::shared_ptr< ProductRegistry const > reg)
void reset(PrincipalCache &cache)
boost::shared_ptr< LuminosityBlockPrincipal > readLuminosityBlock_(boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
int remainingEvents() const
Definition: InputSource.h:176
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
void readManySpecified(std::vector< EventID > const &events, EventPrincipalVector &result)
std::vector< FileCatalogItem > const & fileCatalogItems() const
tuple result
Definition: query.py:137
bool isAvailable() const
Definition: Service.h:47
boost::shared_ptr< DuplicateChecker > duplicateChecker_
void readMany(int number, EventPrincipalVector &result)
#define end
Definition: vmac.h:38
unsigned int offset(bool)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches)
bool nextFile(PrincipalCache &cache)
tuple input
Definition: collect_tpl.py:10
boost::shared_ptr< FileBlock > readFile_(PrincipalCache &cache)
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:203
ProductRegistry & productRegistryUpdate() const
Definition: InputSource.h:299
void readManyRandom(int number, EventPrincipalVector &result, unsigned int &fileSeqNumber)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
boost::shared_ptr< ProductRegistry const > productRegistry() const
Accessor for product registry.
Definition: InputSource.h:161
static void fillDescription(ParameterSetDescription &desc)
#define begin
Definition: vmac.h:31
author Stefano ARGIRO author Bill Tanenbaum
tuple events
Definition: patZpeak.py:19
InputSource::ItemType getNextItemType()
boost::shared_ptr< EventSkipperByID > eventSkipperByID_
void updateFromInput(ProductList const &other)
bool previousFile(PrincipalCache &cache)
void activateTimeout(const std::string &url)
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
int remainingLuminosityBlocks() const
Definition: InputSource.h:184
unsigned int RunNumber_t
Definition: EventRange.h:32
BranchDescription::MatchMode branchesMustMatch_
ProcessConfiguration const & processConfiguration() const
Accessor for Process Configuration.
Definition: InputSource.h:190
ProcessingController::ReverseState reverseState() const
boost::scoped_ptr< CLHEP::RandFlat > flatDistribution_
BranchDescription::MatchMode parametersMustMatch_
SurfaceDeformation * create(int type, const std::vector< double > &params)
tuple size
Write out results.
boost::shared_ptr< RootFile > RootFileSharedPtr
std::vector< FileCatalogItem > const & fileCatalogItems() const
boost::shared_ptr< ProductRegistry const > productRegistry() const
InputFileCatalog const & catalog_