23 #include "CLHEP/Random/RandFlat.h"
34 inputType_(inputType),
38 fileIterBegin_(fileCatalogItems().
begin()),
39 fileIterEnd_(fileCatalogItems().
end()),
40 fileIter_(fileIterEnd_),
41 fileIterLastOpened_(fileIterEnd_),
46 indexesIntoFiles_(fileCatalogItems().
size()),
47 orderedProcessHistoryIDs_(),
49 eventsRemainingInFile_(0),
57 initialNumberOfEventsToSkip_(inputType ==
InputType::
Primary ? pset.getUntrackedParameter<unsigned int>(
"skipEvents", 0U) : 0U),
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 productSelectorRules_(pset,
"inputCommands",
"InputSource"),
65 dropDescendants_(pset.getUntrackedParameter<bool>(
"dropDescendantsOfDroppedBranches", inputType !=
InputType::
SecondarySource)),
66 labelRawDataLikeMC_(pset.getUntrackedParameter<bool>(
"labelRawDataLikeMC",
true)),
67 usingGoToEvent_(
false),
68 enablePrefetching_(
false),
69 usedFallback_(
false) {
110 std::vector<FileCatalogItem>
const&
120 std::unique_ptr<FileBlock>
134 return std::unique_ptr<FileBlock>(
new FileBlock);
143 std::unique_ptr<InputSource::FileCloseSentry>
163 !needIndexesForDuplicateChecker &&
165 if(deleteIndexIntoFile) {
184 throw cms::Exception(
"LogicalFileNameNotFound",
"RootInputFileSequence::initFile()\n")
185 <<
"Logical file name '" <<
fileIter_->logicalFileName() <<
"' was not found in the file catalog.\n"
186 <<
"If you wanted a local file, you forgot the 'file:' prefix\n"
187 <<
"before the file name in your configuration file.\n";
189 LogWarning(
"") <<
"Input logical file: " <<
fileIter_->logicalFileName() <<
" was not found in the catalog, and will be skipped.\n";
198 bool hasFallbackUrl = !fallbackName.empty() && fallbackName !=
fileIter_->fileName();
200 boost::shared_ptr<InputFile> filePtr;
202 std::unique_ptr<InputSource::FileOpenSentry>
204 filePtr.reset(
new InputFile(gSystem->ExpandPathName(
fileIter_->fileName().c_str()),
" Initiating request to open file "));
209 std::ostringstream
out;
216 ex.addContext(
"Calling RootInputFileSequence::initFile()");
217 std::ostringstream
out;
218 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.";
219 ex.addAdditionalInfo(out.str());
224 if(!filePtr && (hasFallbackUrl)) {
226 std::unique_ptr<InputSource::FileOpenSentry>
228 filePtr.reset(
new InputFile(gSystem->ExpandPathName(fallbackName.c_str()),
" Fallback request to file "));
235 ex.addContext(
"Calling RootInputFileSequence::initFile()");
236 std::ostringstream
out;
237 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.\n";
238 out <<
"Fallback Input file " << fallbackName <<
" also could not be opened.";
239 ex.addAdditionalInfo(out.str());
259 currentIndexIntoFile,
267 char const* inputType = 0;
278 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
280 LogWarning(
"") <<
"Input file: " <<
fileIter_->fileName() <<
" was not found or could not be opened, and will be skipped.\n";
284 boost::shared_ptr<ProductRegistry const>
290 boost::shared_ptr<BranchIDListHelper const>
314 if(!mergeInfo.empty()) {
339 if(!mergeInfo.empty()) {
350 boost::shared_ptr<RunAuxiliary>
355 boost::shared_ptr<LuminosityBlockAuxiliary>
357 return rootFile_->readLuminosityBlockAuxiliary_();
360 boost::shared_ptr<RunPrincipal>
362 return rootFile_->readRun_(runPrincipal);
365 boost::shared_ptr<LuminosityBlockPrincipal>
367 return rootFile_->readLumi(lumiPrincipal);
385 return rootFile_->readEvent(eventPrincipal);
442 bool atEnd =
rootFile_->skipEvents(offset);
443 if((offset > 0 || atEnd) && !
nextFile()) {
467 bool closedOriginalFile =
false;
468 std::vector<FileCatalogItem>::const_iterator originalFile =
fileIter_;
472 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
489 closedOriginalFile =
true;
497 if(closedOriginalFile) {
500 rootFile_->setPosition(originalPosition);
509 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
534 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
536 if(*it && (*it)->containsItem(run, lumi, event)) {
538 std::vector<FileCatalogItem>::const_iterator currentIter =
fileIter_;
544 found =
rootFile_->setEntryAtItem(run, lumi, event);
575 boost::shared_ptr<ProductRegistry const>
582 std::vector<std::string>
rules;
583 rules.reserve(wantedBranches.size() + 1);
584 rules.emplace_back(
"drop *");
585 for(std::vector<std::string>::const_iterator it = wantedBranches.begin(), itEnd = wantedBranches.end();
587 rules.push_back(
"keep " + *it +
"_*");
622 throw Exception(
errors::Configuration) <<
"RootInputFileSequence::readOneSequentialWithID(): no input files specified for secondary input source.\n";
626 rootFile_->indexIntoFileIter().run() !=
id.run() ||
627 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
633 bool nextFound =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
653 "RootInputFileSequence::readOneSpecified(): Secondary Input files" <<
654 " do not contain specified event:\n" <<
id <<
"\n";
668 CLHEP::HepRandomEngine& engine = rng->getEngine();
676 if(newSeqNumber != currentSeqNumber) {
678 currentSeqNumber = newSeqNumber;
683 "RootInputFileSequence::readOneRandom(): Secondary Input file " <<
fileIter_->fileName() <<
" contains no events.\n";
708 CLHEP::HepRandomEngine& engine = rng->getEngine();
713 rootFile_->indexIntoFileIter().run() !=
id.run() ||
714 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
719 int eventsInLumi = 0;
720 while(
rootFile_->setEntryAtNextEventInLumi(
id.run(),
id.luminosityBlock())) ++eventsInLumi;
724 for(
int i = 0;
i < eventInLumi; ++
i) {
725 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
729 bool nextFound =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
743 ->setComment(
"Skip the first 'skipEvents' events that otherwise would have been processed.");
745 ->setComment(
"True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
746 "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
747 "Note 1: Events within the same lumi will always be processed contiguously.\n"
748 "Note 2: Lumis within the same run will always be processed contiguously.\n"
749 "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
751 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
752 "False: Throw exception if missing or unopenable input file.");
754 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
756 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
758 ->setComment(
"If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
759 desc.
addUntracked<
bool>(
"dropDescendantsOfDroppedBranches",
true)
760 ->setComment(
"If True, also drop on input any descendent of any branch dropped on input.");
763 ->setComment(
"'strict': Values of tracked parameters must be unique across all input files.\n"
764 "'permissive': Values of tracked parameters may differ across or within files.");
766 ->setComment(
"'strict': Branches in each input file must match those in the first file.\n"
767 "'permissive': Branches in each input file may be any subset of those in the first file.");
769 ->setComment(
"If True: replace module label for raw data to match MC. Also use 'LHC' as process.");
782 std::vector<FileCatalogItem>::const_iterator itr(
fileIter_);
795 if(!
rootFile_->wasFirstEventJustRead()) {
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void stagein(const std::string &url)
static void fillDescription(ParameterSetDescription &desc, char const *parameterName)
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)
LuminosityBlockNumber_t luminosityBlock() const
unsigned int const defaultCacheSize
unsigned int LuminosityBlockNumber_t
static StorageFactory * get(void)
tuple InputFile
Open Root file and provide MEs ############.
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)
void updateFromInput(ProductList const &other)
void activateTimeout(const std::string &url)
tuple size
Write out results.