21 #include "CLHEP/Random/RandFlat.h"
27 std::string
const streamerInfo = std::string(
"StreamerInfo");
38 fileIterBegin_(fileCatalogItems().
begin()),
39 fileIterEnd_(fileCatalogItems().
end()),
40 fileIter_(fileIterEnd_),
41 fileIterLastOpened_(fileIterEnd_),
46 indexesIntoFiles_(fileCatalogItems().
size()),
47 orderedProcessHistoryIDs_(),
49 eventsRemainingInFile_(0),
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),
66 dropDescendants_(pset.getUntrackedParameter<bool>(
"dropDescendantsOfDroppedBranches", primary())),
67 usingGoToEvent_(
false) {
85 std::string parametersMustMatch = pset.
getUntrackedParameter<std::string>(
"parametersMustMatch", std::string(
"permissive"));
88 std::string branchesMustMatch = pset.
getUntrackedParameter<std::string>(
"branchesMustMatch", std::string(
"permissive"));
105 std::vector<FileCatalogItem>
const&
115 boost::shared_ptr<FileBlock>
129 return boost::shared_ptr<FileBlock>(
new FileBlock);
138 std::auto_ptr<InputSource::FileCloseSentry>
158 !needIndexesForDuplicateChecker &&
160 if (deleteIndexIntoFile) {
171 std::string fallbackName =
fileIter_->fallbackFileName();
172 bool hasFallbackUrl = (!fallbackName.empty()) || (fallbackName ==
fileIter_->fileName());
174 boost::shared_ptr<InputFile> filePtr;
176 std::auto_ptr<InputSource::FileOpenSentry>
178 filePtr.reset(
new InputFile(gSystem->ExpandPathName(
fileIter_->fileName().c_str()),
" Initiating request to open file "));
181 if(!skipBadFiles && !hasFallbackUrl) {
182 if(e.
explainSelf().find(streamerInfo) != std::string::npos) {
184 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" could not be read properly.\n" <<
185 "Possibly the format is incompatible with the current release.\n";
188 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found, could not be opened, or is corrupted.\n";
191 if(!filePtr && (hasFallbackUrl)) {
193 std::auto_ptr<InputSource::FileOpenSentry>
195 filePtr.reset(
new InputFile(gSystem->ExpandPathName(fallbackName.c_str()),
" Fallback request to file "));
199 if(e.
explainSelf().find(streamerInfo) != std::string::npos) {
201 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" could not be read properly.\n" <<
202 "Possibly the format is incompatible with the current release.\n";
205 "RootInputFileSequence::initFile(): Input fallback file " << fallbackName <<
" was not found, could not be opened, or is corrupted.\n";
222 indexesIntoFiles_[currentIndexIntoFile] =
rootFile_->indexIntoFileSharedPtr();
224 (
primaryFiles_ ?
"primaryFiles" :
"secondaryFiles") :
"mixingFiles");
228 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
230 LogWarning(
"") <<
"Input file: " <<
fileIter_->fileName() <<
" was not found or could not be opened, and will be skipped.\n";
234 boost::shared_ptr<ProductRegistry const>
258 if(!mergeInfo.empty()) {
288 if(!mergeInfo.empty()) {
303 boost::shared_ptr<RunAuxiliary>
305 boost::shared_ptr<RunAuxiliary>
aux =
rootFile_->readRunAuxiliary_();
309 boost::shared_ptr<LuminosityBlockAuxiliary>
311 boost::shared_ptr<LuminosityBlockAuxiliary>
aux =
rootFile_->readLuminosityBlockAuxiliary_();
315 boost::shared_ptr<RunPrincipal>
320 boost::shared_ptr<LuminosityBlockPrincipal>
439 bool closedOriginalFile =
false;
440 std::vector<FileCatalogItem>::const_iterator originalFile =
fileIter_;
444 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
461 closedOriginalFile =
true;
469 if (closedOriginalFile) {
472 rootFile_->setPosition(originalPosition);
488 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
490 if(*it && (*it)->containsItem(run, lumi, event)) {
495 found =
rootFile_->setEntryAtItem(run, lumi, event);
505 found =
rootFile_->setEntryAtItem(run, lumi, event);
542 boost::shared_ptr<ProductRegistry const>
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();
554 rules.push_back(
"keep " + *it +
"_*");
563 for(
int i = 0;
i < number; ++
i) {
569 assert(ev == ep.get());
570 result.push_back(ep);
580 result.reserve(number);
583 CLHEP::HepRandomEngine& engine = rng->getEngine();
591 if(newSeqNumber != currentSeqNumber) {
593 currentSeqNumber = newSeqNumber;
598 "RootInputFileSequence::readManyRandom_(): Secondary Input file " <<
fileIter_->fileName() <<
" contains no events.\n";
603 for(
int i = 0;
i < number; ++
i) {
611 assert(ev == ep.get());
612 result.push_back(ep);
623 result.reserve(number);
631 unsigned int numberRead = 0;
632 for(
int i = 0;
i < number; ++
i) {
636 if (numberRead == 0) {
648 assert(ev == ep.get());
649 result.push_back(ep);
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());
663 "RootInputFileSequence::readManySpecified_(): Secondary Input file " <<
665 " does not contain specified event:\n" << *it <<
"\n";
671 "RootInputFileSequence::readManySpecified_(): Secondary Input file " <<
673 " contains specified event " << *it <<
" that cannot be read.\n";
675 assert(ev == ep.get());
676 result.push_back(ep);
683 ->setComment(
"Skip the first 'skipEvents' events that otherwise would have been processed.");
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).");
691 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
692 "False: Throw exception if missing or unopenable input file.");
694 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
696 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
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.");
717 if (!
rootFile_->wasLastEventJustRead()) {
720 std::vector<FileCatalogItem>::const_iterator itr(
fileIter_);
733 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 const defaultCacheSize
unsigned int LuminosityBlockNumber_t
static StorageFactory * get(void)
tuple InputFile
Open Root file and provide MEs ############.
void adjustEventToNewProductRegistry(boost::shared_ptr< ProductRegistry const > reg)
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.