22 #include "CLHEP/Random/RandFlat.h"
31 unsigned int nStreams,
34 inputType_(inputType),
38 fileIterBegin_(fileCatalogItems().
begin()),
39 fileIterEnd_(fileCatalogItems().
end()),
40 fileIter_(fileIterEnd_),
41 fileIterLastOpened_(fileIterEnd_),
44 indexesIntoFiles_(fileCatalogItems().
size()),
45 orderedProcessHistoryIDs_(),
48 eventsRemainingInFile_(0),
56 initialNumberOfEventsToSkip_(inputType ==
InputType::
Primary ? pset.getUntrackedParameter<unsigned int>(
"skipEvents", 0U) : 0U),
58 skipBadFiles_(pset.getUntrackedParameter<bool>(
"skipBadFiles",
false)),
59 bypassVersionCheck_(pset.getUntrackedParameter<bool>(
"bypassVersionCheck",
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) {
107 std::vector<FileCatalogItem>
const&
117 std::unique_ptr<FileBlock>
131 return std::unique_ptr<FileBlock>(
new FileBlock);
140 std::unique_ptr<InputSource::FileCloseSentry>
160 !needIndexesForDuplicateChecker &&
162 if(deleteIndexIntoFile) {
181 throw cms::Exception(
"LogicalFileNameNotFound",
"RootInputFileSequence::initFile()\n")
182 <<
"Logical file name '" <<
fileIter_->logicalFileName() <<
"' was not found in the file catalog.\n"
183 <<
"If you wanted a local file, you forgot the 'file:' prefix\n"
184 <<
"before the file name in your configuration file.\n";
186 LogWarning(
"") <<
"Input logical file: " <<
fileIter_->logicalFileName() <<
" was not found in the catalog, and will be skipped.\n";
196 bool hasFallbackUrl = !fallbackName.empty() && fallbackName !=
fileIter_->fileName();
198 std::shared_ptr<InputFile> filePtr;
200 std::unique_ptr<InputSource::FileOpenSentry>
207 std::ostringstream
out;
214 ex.addContext(
"Calling RootInputFileSequence::initFile()");
215 std::ostringstream
out;
216 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.";
217 ex.addAdditionalInfo(out.str());
222 if(!filePtr && (hasFallbackUrl)) {
225 std::unique_ptr<InputSource::FileOpenSentry>
227 std::string fallbackFullName = gSystem->ExpandPathName(fallbackName.c_str());
230 filePtr.reset(
new InputFile(fallbackFullName.c_str(),
" Fallback request to file ",
inputType_));
236 ex.addContext(
"Calling RootInputFileSequence::initFile()");
237 std::ostringstream
out;
238 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.\n";
239 out <<
"Fallback Input file " << fallbackName <<
" also could not be opened.";
240 ex.addAdditionalInfo(out.str());
269 currentIndexIntoFile,
278 indexesIntoFiles_[currentIndexIntoFile] =
rootFile_->indexIntoFileSharedPtr();
279 char const* inputType = 0;
290 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
292 LogWarning(
"") <<
"Input file: " <<
fileIter_->fileName() <<
" was not found or could not be opened, and will be skipped.\n";
296 std::shared_ptr<ProductRegistry const>
302 std::shared_ptr<BranchIDListHelper const>
325 if(!mergeInfo.empty()) {
349 if(!mergeInfo.empty()) {
360 std::shared_ptr<RunAuxiliary>
366 std::shared_ptr<LuminosityBlockAuxiliary>
369 return rootFile_->readLuminosityBlockAuxiliary_();
381 rootFile_->readLuminosityBlock_(lumiPrincipal);
431 return rootFile_->containsItem(run, lumi, event);
468 bool atEnd =
rootFile_->skipEvents(offset);
469 if((offset > 0 || atEnd) && !
nextFile()) {
493 bool closedOriginalFile =
false;
494 std::vector<FileCatalogItem>::const_iterator originalFile =
fileIter_;
498 typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
516 closedOriginalFile =
true;
525 if(closedOriginalFile) {
529 rootFile_->setPosition(originalPosition);
538 typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
564 typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
566 if(*it && (*it)->containsItem(run, lumi, event)) {
568 std::vector<FileCatalogItem>::const_iterator currentIter =
fileIter_;
575 found =
rootFile_->setEntryAtItem(run, lumi, event);
616 std::shared_ptr<ProductRegistry const>
623 std::vector<std::string>
rules;
624 rules.reserve(wantedBranches.size() + 1);
625 rules.emplace_back(
"drop *");
627 rules.push_back(
"keep " + branch +
"_*");
665 throw Exception(
errors::Configuration) <<
"RootInputFileSequence::readOneSequentialWithID(): no input files specified for secondary input source.\n";
669 rootFile_->indexIntoFileIter().run() !=
id.run() ||
670 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
677 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
679 found =
rootFile_->readCurrentEvent(cache);
700 "RootInputFileSequence::readOneSpecified(): Secondary Input files" <<
701 " do not contain specified event:\n" <<
id <<
"\n";
704 found =
rootFile_->readCurrentEvent(cache);
720 if(newSeqNumber != currentSeqNumber) {
722 currentSeqNumber = newSeqNumber;
727 "RootInputFileSequence::readOneRandom(): Secondary Input file " <<
fileIter_->fileName() <<
" contains no events.\n";
736 bool found =
rootFile_->readCurrentEvent(cache);
751 rootFile_->indexIntoFileIter().run() !=
id.run() ||
752 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
757 int eventsInLumi = 0;
759 while(
rootFile_->setEntryAtNextEventInLumi(
id.run(),
id.luminosityBlock())) ++eventsInLumi;
762 int eventInLumi = CLHEP::RandFlat::shootInt(engine, eventsInLumi);
763 for(
int i = 0;
i < eventInLumi; ++
i) {
764 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
769 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
771 found =
rootFile_->readCurrentEvent(cache);
774 bool found =
rootFile_->setEntryAtItem(
id.
run(),
id.luminosityBlock(), 0);
786 ->setComment(
"Skip the first 'skipEvents' events that otherwise would have been processed.");
788 ->setComment(
"True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
789 "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
790 "Note 1: Events within the same lumi will always be processed contiguously.\n"
791 "Note 2: Lumis within the same run will always be processed contiguously.\n"
792 "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
794 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
795 "False: Throw exception if missing or unopenable input file.");
797 ->setComment(
"True: Bypass release version check.\n"
798 "False: Throw exception if reading file in a release prior to the release in which the file was written.");
800 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
802 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
804 ->setComment(
"If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
805 desc.
addUntracked<
bool>(
"dropDescendantsOfDroppedBranches",
true)
806 ->setComment(
"If True, also drop on input any descendent of any branch dropped on input.");
809 ->setComment(
"'strict': Branches in each input file must match those in the first file.\n"
810 "'permissive': Branches in each input file may be any subset of those in the first file.");
812 ->setComment(
"If True: replace module label for raw data to match MC. Also use 'LHC' as process.");
825 std::vector<FileCatalogItem>::const_iterator itr(
fileIter_);
838 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)
LuminosityBlockNumber_t luminosityBlock() const
unsigned int const defaultCacheSize
unsigned int LuminosityBlockNumber_t
static std::string const input
static StorageFactory * get(void)
tuple InputFile
Open Root file and provide MEs ############.
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
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
static EntryNumber_t const invalidEntry
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)
volatile std::atomic< bool > shutdown_flag false
tuple size
Write out results.