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 treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>(
"cacheSize", roottree::
defaultCacheSize) : 0U),
59 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize", -1)),
60 setRun_(pset.getUntrackedParameter<unsigned int>(
"setRunNumber", 0U)),
61 groupSelectorRules_(pset,
"inputCommands",
"InputSource"),
63 dropDescendants_(pset.getUntrackedParameter<bool>(
"dropDescendantsOfDroppedBranches", inputType !=
InputType::
SecondarySource)),
64 labelRawDataLikeMC_(pset.getUntrackedParameter<bool>(
"labelRawDataLikeMC",
true)),
65 usingGoToEvent_(
false) {
83 std::string parametersMustMatch = pset.
getUntrackedParameter<std::string>(
"parametersMustMatch", std::string(
"permissive"));
86 std::string branchesMustMatch = pset.
getUntrackedParameter<std::string>(
"branchesMustMatch", std::string(
"permissive"));
103 std::vector<FileCatalogItem>
const&
113 boost::shared_ptr<FileBlock>
127 return boost::shared_ptr<FileBlock>(
new FileBlock);
136 std::unique_ptr<InputSource::FileCloseSentry>
156 !needIndexesForDuplicateChecker &&
158 if(deleteIndexIntoFile) {
177 throw cms::Exception(
"LogicalFileNameNotFound",
"RootInputFileSequence::initFile()\n")
178 <<
"Logical file name '" <<
fileIter_->logicalFileName() <<
"' was not found in the file catalog.\n"
179 <<
"If you wanted a local file, you forgot the 'file:' prefix\n"
180 <<
"before the file name in your configuration file.\n";
182 LogWarning(
"") <<
"Input logical file: " <<
fileIter_->logicalFileName() <<
" was not found in the catalog, and will be skipped.\n";
188 std::string fallbackName =
fileIter_->fallbackFileName();
189 bool hasFallbackUrl = !fallbackName.empty() && fallbackName !=
fileIter_->fileName();
191 boost::shared_ptr<InputFile> filePtr;
193 std::unique_ptr<InputSource::FileOpenSentry>
195 filePtr.reset(
new InputFile(gSystem->ExpandPathName(
fileIter_->fileName().c_str()),
" Initiating request to open file "));
200 std::ostringstream
out;
202 std::string
pfn(gSystem->ExpandPathName(fallbackName.c_str()));
207 ex.addContext(
"Calling RootInputFileSequence::initFile()");
209 ex <<
"Input file " <<
fileIter_->fileName() <<
" was not found, could not be opened, or is corrupted.\n";
214 if(!filePtr && (hasFallbackUrl)) {
216 std::unique_ptr<InputSource::FileOpenSentry>
218 filePtr.reset(
new InputFile(gSystem->ExpandPathName(fallbackName.c_str()),
" Fallback request to file "));
224 ex.addContext(
"Calling RootInputFileSequence::initFile()");
226 ex <<
"Input file " <<
fileIter_->fileName() <<
" was not found, could not be opened, or is corrupted.\n";
227 ex <<
"Fallback Input file " << fallbackName <<
" also was not found, could not be opened, or is corrupted.\n";
246 currentIndexIntoFile,
252 indexesIntoFiles_[currentIndexIntoFile] =
rootFile_->indexIntoFileSharedPtr();
253 char const* inputType = 0;
264 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
266 LogWarning(
"") <<
"Input file: " <<
fileIter_->fileName() <<
" was not found or could not be opened, and will be skipped.\n";
270 boost::shared_ptr<ProductRegistry const>
295 if(!mergeInfo.empty()) {
325 if(!mergeInfo.empty()) {
340 boost::shared_ptr<RunAuxiliary>
345 boost::shared_ptr<LuminosityBlockAuxiliary>
347 return rootFile_->readLuminosityBlockAuxiliary_();
350 boost::shared_ptr<RunPrincipal>
355 boost::shared_ptr<LuminosityBlockPrincipal>
474 bool closedOriginalFile =
false;
475 std::vector<FileCatalogItem>::const_iterator originalFile =
fileIter_;
479 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
496 closedOriginalFile =
true;
504 if(closedOriginalFile) {
507 rootFile_->setPosition(originalPosition);
516 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
541 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
543 if(*it && (*it)->containsItem(run, lumi, event)) {
545 std::vector<FileCatalogItem>::const_iterator currentIter =
fileIter_;
551 found =
rootFile_->setEntryAtItem(run, lumi, event);
582 boost::shared_ptr<ProductRegistry const>
589 std::vector<std::string>
rules;
590 rules.reserve(wantedBranches.size() + 1);
591 rules.emplace_back(
"drop *");
592 for(std::vector<std::string>::const_iterator it = wantedBranches.begin(), itEnd = wantedBranches.end();
594 rules.push_back(
"keep " + *it +
"_*");
633 rootFile_->indexIntoFileIter().run() !=
id.run() ||
634 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
640 bool nextFound =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
657 "RootInputFileSequence::readOneSpecified(): Secondary Input file " <<
659 " does not contain specified event:\n" <<
id <<
"\n";
673 CLHEP::HepRandomEngine& engine = rng->getEngine();
681 if(newSeqNumber != currentSeqNumber) {
683 currentSeqNumber = newSeqNumber;
688 "RootInputFileSequence::readOneRandom(): Secondary Input file " <<
fileIter_->fileName() <<
" contains no events.\n";
713 CLHEP::HepRandomEngine& engine = rng->getEngine();
718 rootFile_->indexIntoFileIter().run() !=
id.run() ||
719 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
724 int eventsInLumi = 0;
725 while(
rootFile_->setEntryAtNextEventInLumi(
id.run(),
id.luminosityBlock())) ++eventsInLumi;
729 for(
int i = 0;
i < eventInLumi; ++
i) {
730 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
734 bool nextFound =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
748 ->setComment(
"Skip the first 'skipEvents' events that otherwise would have been processed.");
750 ->setComment(
"True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
751 "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
752 "Note 1: Events within the same lumi will always be processed contiguously.\n"
753 "Note 2: Lumis within the same run will always be processed contiguously.\n"
754 "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
756 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
757 "False: Throw exception if missing or unopenable input file.");
759 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
761 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
763 ->setComment(
"If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
764 desc.
addUntracked<
bool>(
"dropDescendantsOfDroppedBranches",
true)
765 ->setComment(
"If True, also drop on input any descendent of any branch dropped on input.");
766 std::string defaultString(
"permissive");
767 desc.
addUntracked<std::string>(
"parametersMustMatch", defaultString)
768 ->setComment(
"'strict': Values of tracked parameters must be unique across all input files.\n"
769 "'permissive': Values of tracked parameters may differ across or within files.");
770 desc.
addUntracked<std::string>(
"branchesMustMatch", defaultString)
771 ->setComment(
"'strict': Branches in each input file must match those in the first file.\n"
772 "'permissive': Branches in each input file may be any subset of those in the first file.");
774 ->setComment(
"If True: replace module label for raw data to match MC. Also use 'LHC' as process.");
787 std::vector<FileCatalogItem>::const_iterator itr(
fileIter_);
800 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.