21 #include "CLHEP/Random/RandFlat.h"
33 inputType_(inputType),
36 fileIterBegin_(fileCatalogItems().
begin()),
37 fileIterEnd_(fileCatalogItems().
end()),
38 fileIter_(fileIterEnd_),
39 fileIterLastOpened_(fileIterEnd_),
44 indexesIntoFiles_(fileCatalogItems().
size()),
45 orderedProcessHistoryIDs_(),
47 eventsRemainingInFile_(0),
55 numberOfEventsToSkip_(inputType ==
InputType::
Primary ? pset.getUntrackedParameter<unsigned int>(
"skipEvents", 0U) : 0U),
57 skipBadFiles_(pset.getUntrackedParameter<bool>(
"skipBadFiles",
false)),
58 bypassVersionCheck_(pset.getUntrackedParameter<bool>(
"bypassVersionCheck",
false)),
59 treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>(
"cacheSize", roottree::
defaultCacheSize) : 0U),
60 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize", -1)),
61 setRun_(pset.getUntrackedParameter<unsigned int>(
"setRunNumber", 0U)),
62 groupSelectorRules_(pset,
"inputCommands",
"InputSource"),
64 dropDescendants_(pset.getUntrackedParameter<bool>(
"dropDescendantsOfDroppedBranches", inputType !=
InputType::
SecondarySource)),
65 labelRawDataLikeMC_(pset.getUntrackedParameter<bool>(
"labelRawDataLikeMC",
true)),
66 usingGoToEvent_(
false) {
84 std::string parametersMustMatch = pset.
getUntrackedParameter<std::string>(
"parametersMustMatch", std::string(
"permissive"));
87 std::string branchesMustMatch = pset.
getUntrackedParameter<std::string>(
"branchesMustMatch", std::string(
"permissive"));
104 std::vector<FileCatalogItem>
const&
114 boost::shared_ptr<FileBlock>
128 return boost::shared_ptr<FileBlock>(
new FileBlock);
137 std::unique_ptr<InputSource::FileCloseSentry>
157 !needIndexesForDuplicateChecker &&
159 if(deleteIndexIntoFile) {
178 throw cms::Exception(
"LogicalFileNameNotFound",
"RootInputFileSequence::initFile()\n")
179 <<
"Logical file name '" <<
fileIter_->logicalFileName() <<
"' was not found in the file catalog.\n"
180 <<
"If you wanted a local file, you forgot the 'file:' prefix\n"
181 <<
"before the file name in your configuration file.\n";
183 LogWarning(
"") <<
"Input logical file: " <<
fileIter_->logicalFileName() <<
" was not found in the catalog, and will be skipped.\n";
189 std::string fallbackName =
fileIter_->fallbackFileName();
190 bool hasFallbackUrl = !fallbackName.empty() && fallbackName !=
fileIter_->fileName();
192 boost::shared_ptr<InputFile> filePtr;
194 std::unique_ptr<InputSource::FileOpenSentry>
196 filePtr.reset(
new InputFile(gSystem->ExpandPathName(
fileIter_->fileName().c_str()),
" Initiating request to open file "));
201 std::ostringstream
out;
203 std::string
pfn(gSystem->ExpandPathName(fallbackName.c_str()));
208 ex.addContext(
"Calling RootInputFileSequence::initFile()");
210 ex <<
"Input file " <<
fileIter_->fileName() <<
" was not found, could not be opened, or is corrupted.\n";
215 if(!filePtr && (hasFallbackUrl)) {
217 std::unique_ptr<InputSource::FileOpenSentry>
219 filePtr.reset(
new InputFile(gSystem->ExpandPathName(fallbackName.c_str()),
" Fallback request to file "));
225 ex.addContext(
"Calling RootInputFileSequence::initFile()");
227 ex <<
"Input file " <<
fileIter_->fileName() <<
" was not found, could not be opened, or is corrupted.\n";
228 ex <<
"Fallback Input file " << fallbackName <<
" also was not found, could not be opened, or is corrupted.\n";
247 currentIndexIntoFile,
254 indexesIntoFiles_[currentIndexIntoFile] =
rootFile_->indexIntoFileSharedPtr();
255 char const* inputType = 0;
266 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
268 LogWarning(
"") <<
"Input file: " <<
fileIter_->fileName() <<
" was not found or could not be opened, and will be skipped.\n";
272 boost::shared_ptr<ProductRegistry const>
297 if(!mergeInfo.empty()) {
327 if(!mergeInfo.empty()) {
342 boost::shared_ptr<RunAuxiliary>
347 boost::shared_ptr<LuminosityBlockAuxiliary>
349 return rootFile_->readLuminosityBlockAuxiliary_();
352 boost::shared_ptr<RunPrincipal>
357 boost::shared_ptr<LuminosityBlockPrincipal>
476 bool closedOriginalFile =
false;
477 std::vector<FileCatalogItem>::const_iterator originalFile =
fileIter_;
481 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
498 closedOriginalFile =
true;
506 if(closedOriginalFile) {
509 rootFile_->setPosition(originalPosition);
518 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
543 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
545 if(*it && (*it)->containsItem(run, lumi, event)) {
547 std::vector<FileCatalogItem>::const_iterator currentIter =
fileIter_;
553 found =
rootFile_->setEntryAtItem(run, lumi, event);
584 boost::shared_ptr<ProductRegistry const>
591 std::vector<std::string>
rules;
592 rules.reserve(wantedBranches.size() + 1);
593 rules.emplace_back(
"drop *");
594 for(std::vector<std::string>::const_iterator it = wantedBranches.begin(), itEnd = wantedBranches.end();
596 rules.push_back(
"keep " + *it +
"_*");
631 throw Exception(
errors::Configuration) <<
"RootInputFileSequence::readOneSequentialWithID(): no input files specified for secondary input source.\n";
635 rootFile_->indexIntoFileIter().run() !=
id.run() ||
636 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
642 bool nextFound =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
662 "RootInputFileSequence::readOneSpecified(): Secondary Input files" <<
663 " do not contain specified event:\n" <<
id <<
"\n";
677 CLHEP::HepRandomEngine& engine = rng->getEngine();
685 if(newSeqNumber != currentSeqNumber) {
687 currentSeqNumber = newSeqNumber;
692 "RootInputFileSequence::readOneRandom(): Secondary Input file " <<
fileIter_->fileName() <<
" contains no events.\n";
717 CLHEP::HepRandomEngine& engine = rng->getEngine();
722 rootFile_->indexIntoFileIter().run() !=
id.run() ||
723 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
728 int eventsInLumi = 0;
729 while(
rootFile_->setEntryAtNextEventInLumi(
id.run(),
id.luminosityBlock())) ++eventsInLumi;
733 for(
int i = 0;
i < eventInLumi; ++
i) {
734 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
738 bool nextFound =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
752 ->setComment(
"Skip the first 'skipEvents' events that otherwise would have been processed.");
754 ->setComment(
"True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
755 "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
756 "Note 1: Events within the same lumi will always be processed contiguously.\n"
757 "Note 2: Lumis within the same run will always be processed contiguously.\n"
758 "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
760 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
761 "False: Throw exception if missing or unopenable input file.");
763 ->setComment(
"True: Bypass release version check.\n"
764 "False: Throw exception if reading file in a release prior to the release in which the file was written.");
766 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
768 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
770 ->setComment(
"If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
771 desc.
addUntracked<
bool>(
"dropDescendantsOfDroppedBranches",
true)
772 ->setComment(
"If True, also drop on input any descendent of any branch dropped on input.");
773 std::string defaultString(
"permissive");
774 desc.
addUntracked<std::string>(
"parametersMustMatch", defaultString)
775 ->setComment(
"'strict': Values of tracked parameters must be unique across all input files.\n"
776 "'permissive': Values of tracked parameters may differ across or within files.");
777 desc.
addUntracked<std::string>(
"branchesMustMatch", defaultString)
778 ->setComment(
"'strict': Branches in each input file must match those in the first file.\n"
779 "'permissive': Branches in each input file may be any subset of those in the first file.");
781 ->setComment(
"If True: replace module label for raw data to match MC. Also use 'LHC' as process.");
794 std::vector<FileCatalogItem>::const_iterator itr(
fileIter_);
807 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.