21 #include "CLHEP/Random/RandFlat.h"
35 fileIterBegin_(fileCatalogItems().
begin()),
36 fileIterEnd_(fileCatalogItems().
end()),
37 fileIter_(fileIterEnd_),
38 fileIterLastOpened_(fileIterEnd_),
43 indexesIntoFiles_(fileCatalogItems().
size()),
44 orderedProcessHistoryIDs_(),
46 eventsRemainingInFile_(0),
54 numberOfEventsToSkip_(primaryFiles ? pset.getUntrackedParameter<unsigned int>(
"skipEvents", 0U) : 0U),
55 noEventSort_(primaryFiles ? pset.getUntrackedParameter<bool>(
"noEventSort",
true) :
false),
56 skipBadFiles_(pset.getUntrackedParameter<bool>(
"skipBadFiles",
false)),
57 treeCacheSize_(pset.getUntrackedParameter<unsigned int>(
"cacheSize", input::
defaultCacheSize)),
58 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize", -1)),
59 setRun_(pset.getUntrackedParameter<unsigned int>(
"setRunNumber", 0U)),
60 groupSelectorRules_(pset,
"inputCommands",
"InputSource"),
61 primaryFiles_(primaryFiles),
63 dropDescendants_(pset.getUntrackedParameter<bool>(
"dropDescendantsOfDroppedBranches", primary())),
64 usingGoToEvent_(
false) {
77 std::string parametersMustMatch = pset.
getUntrackedParameter<std::string>(
"parametersMustMatch", std::string(
"permissive"));
80 std::string branchesMustMatch = pset.
getUntrackedParameter<std::string>(
"branchesMustMatch", std::string(
"permissive"));
97 std::vector<FileCatalogItem>
const&
107 boost::shared_ptr<FileBlock>
121 return boost::shared_ptr<FileBlock>(
new FileBlock);
131 std::auto_ptr<InputSource::FileCloseSentry>
151 !needIndexesForDuplicateChecker &&
153 if (deleteIndexIntoFile) {
164 std::string fallbackName =
fileIter_->fallbackFileName();
165 bool hasFallbackUrl = (!fallbackName.empty()) || (fallbackName ==
fileIter_->fileName());
167 boost::shared_ptr<InputFile> filePtr;
169 std::auto_ptr<InputSource::FileOpenSentry>
171 filePtr.reset(
new InputFile(gSystem->ExpandPathName(
fileIter_->fileName().c_str()),
" Initiating request to open file "));
174 if(!skipBadFiles && !hasFallbackUrl) {
176 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
179 if(!filePtr && (hasFallbackUrl)) {
181 std::auto_ptr<InputSource::FileOpenSentry>
183 filePtr.reset(
new InputFile(gSystem->ExpandPathName(fallbackName.c_str()),
" Fallback request to file "));
188 "RootInputFileSequence::initFile(): Input fallback file " << fallbackName <<
" was not found or could not be opened.\n";
205 indexesIntoFiles_[currentIndexIntoFile] =
rootFile_->indexIntoFileSharedPtr();
207 (
primaryFiles_ ?
"primaryFiles" :
"secondaryFiles") :
"mixingFiles");
211 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
213 LogWarning(
"") <<
"Input file: " <<
fileIter_->fileName() <<
" was not found or could not be opened, and will be skipped.\n";
217 boost::shared_ptr<ProductRegistry const>
241 if(!mergeInfo.empty()) {
271 if(!mergeInfo.empty()) {
286 boost::shared_ptr<RunAuxiliary>
288 boost::shared_ptr<RunAuxiliary>
aux =
rootFile_->readRunAuxiliary_();
292 boost::shared_ptr<LuminosityBlockAuxiliary>
294 boost::shared_ptr<LuminosityBlockAuxiliary>
aux =
rootFile_->readLuminosityBlockAuxiliary_();
298 boost::shared_ptr<RunPrincipal>
303 boost::shared_ptr<LuminosityBlockPrincipal>
422 bool closedOriginalFile =
false;
423 std::vector<FileCatalogItem>::const_iterator originalFile =
fileIter_;
427 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
444 closedOriginalFile =
true;
452 if (closedOriginalFile) {
455 rootFile_->setPosition(originalPosition);
471 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
473 if(*it && (*it)->containsItem(run, lumi, event)) {
478 found =
rootFile_->setEntryAtItem(run, lumi, event);
488 found =
rootFile_->setEntryAtItem(run, lumi, event);
525 boost::shared_ptr<ProductRegistry const>
532 std::vector<std::string>
rules;
533 rules.reserve(wantedBranches.size() + 1);
534 rules.push_back(std::string(
"drop *"));
535 for(std::vector<std::string>::const_iterator it = wantedBranches.begin(), itEnd = wantedBranches.end();
537 rules.push_back(
"keep " + *it +
"_*");
546 for(
int i = 0;
i < number; ++
i) {
552 assert(ev == ep.get());
553 result.push_back(ep);
560 result.reserve(number);
563 CLHEP::HepRandomEngine& engine = rng->getEngine();
571 if(newSeqNumber != currentSeqNumber) {
577 "RootInputFileSequence::readManyRandom_(): Secondary Input file " <<
fileIter_->fileName() <<
" contains no events.\n";
582 for(
int i = 0;
i < number; ++
i) {
590 assert(ev == ep.get());
591 result.push_back(ep);
599 result.reserve(number);
607 unsigned int numberRead = 0;
608 for(
int i = 0;
i < number; ++
i) {
612 if (numberRead == 0) {
624 assert(ev == ep.get());
625 result.push_back(ep);
634 result.reserve(events.size());
635 for (std::vector<EventID>::const_iterator it = events.begin(), itEnd = events.end(); it != itEnd; ++it) {
636 bool found =
skipToItem(it->run(), it->luminosityBlock(), it->event());
639 "RootInputFileSequence::readManySpecified_(): Secondary Input file " <<
641 " does not contain specified event:\n" << *it <<
"\n";
647 "RootInputFileSequence::readManySpecified_(): Secondary Input file " <<
649 " contains specified event " << *it <<
" that cannot be read.\n";
651 assert(ev == ep.get());
652 result.push_back(ep);
659 ->setComment(
"Skip the first 'skipEvents' events that otherwise would have been processed.");
661 ->setComment(
"True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
662 "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
663 "Note 1: Events within the same lumi will always be processed contiguously.\n"
664 "Note 2: Lumis within the same run will always be processed contiguously.\n"
665 "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
667 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
668 "False: Throw exception if missing or unopenable input file.");
670 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
672 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
674 ->setComment(
"If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
675 desc.
addUntracked<
bool>(
"dropDescendantsOfDroppedBranches",
true)
676 ->setComment(
"If True, also drop on input any descendent of any branch dropped on input.");
677 std::string defaultString(
"permissive");
678 desc.
addUntracked<std::string>(
"parametersMustMatch", defaultString)
679 ->setComment(
"'strict': Values of tracked parameters must be unique across all input files.\n"
680 "'permissive': Values of tracked parameters may differ across or within files.");
681 desc.
addUntracked<std::string>(
"branchesMustMatch", defaultString)
682 ->setComment(
"'strict': Branches in each input file must match those in the first file.\n"
683 "'permissive': Branches in each input file may be any subset of those in the first file.");
693 if (!
rootFile_->wasLastEventJustRead()) {
696 std::vector<FileCatalogItem>::const_iterator itr(
fileIter_);
709 if (!
rootFile_->wasFirstEventJustRead()) {
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void stagein(const std::string &url)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
unsigned int EventNumber_t
virtual std::string explainSelf() const
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
unsigned int LuminosityBlockNumber_t
static StorageFactory * get(void)
tuple InputFile
Open Root file and provide MEs ############.
void adjustEventToNewProductRegistry(boost::shared_ptr< ProductRegistry const > reg)
virtual unsigned int const * sourceTTreeCacheSize() const =0
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 addUntrackedParameter(std::string const &name, T const &value)
static void fillDescription(ParameterSetDescription &desc)
author Stefano ARGIRO author Bill Tanenbaum
void updateFromInput(ProductList const &other)
void activateTimeout(const std::string &url)
tuple size
Write out results.