23 #include "CLHEP/Random/RandFlat.h"
32 unsigned int nStreams,
35 inputType_(inputType),
39 fileIterBegin_(fileCatalogItems().
begin()),
40 fileIterEnd_(fileCatalogItems().
end()),
41 fileIter_(fileIterEnd_),
42 fileIterLastOpened_(fileIterEnd_),
45 indexesIntoFiles_(fileCatalogItems().
size()),
46 orderedProcessHistoryIDs_(),
49 eventsRemainingInFile_(0),
57 initialNumberOfEventsToSkip_(inputType ==
InputType::
Primary ? pset.getUntrackedParameter<unsigned int>(
"skipEvents", 0U) : 0U),
59 skipBadFiles_(pset.getUntrackedParameter<bool>(
"skipBadFiles",
false)),
60 bypassVersionCheck_(pset.getUntrackedParameter<bool>(
"bypassVersionCheck",
false)),
61 treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>(
"cacheSize", roottree::
defaultCacheSize) : 0U),
62 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize", -1)),
63 setRun_(pset.getUntrackedParameter<unsigned int>(
"setRunNumber", 0U)),
64 productSelectorRules_(pset,
"inputCommands",
"InputSource"),
66 dropDescendants_(pset.getUntrackedParameter<bool>(
"dropDescendantsOfDroppedBranches", inputType !=
InputType::
SecondarySource)),
67 labelRawDataLikeMC_(pset.getUntrackedParameter<bool>(
"labelRawDataLikeMC",
true)),
68 usingGoToEvent_(
false),
69 enablePrefetching_(
false),
70 usedFallback_(
false) {
108 std::vector<FileCatalogItem>
const&
118 std::unique_ptr<FileBlock>
132 return std::unique_ptr<FileBlock>(
new FileBlock);
141 std::unique_ptr<InputSource::FileCloseSentry>
161 !needIndexesForDuplicateChecker &&
163 if(deleteIndexIntoFile) {
182 throw cms::Exception(
"LogicalFileNameNotFound",
"RootInputFileSequence::initFile()\n")
183 <<
"Logical file name '" <<
fileIter_->logicalFileName() <<
"' was not found in the file catalog.\n"
184 <<
"If you wanted a local file, you forgot the 'file:' prefix\n"
185 <<
"before the file name in your configuration file.\n";
187 LogWarning(
"") <<
"Input logical file: " <<
fileIter_->logicalFileName() <<
" was not found in the catalog, and will be skipped.\n";
197 bool hasFallbackUrl = !fallbackName.empty() && fallbackName !=
fileIter_->fileName();
199 std::shared_ptr<InputFile> filePtr;
201 std::unique_ptr<InputSource::FileOpenSentry>
208 std::ostringstream
out;
215 ex.addContext(
"Calling RootInputFileSequence::initFile()");
216 std::ostringstream
out;
217 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.";
218 ex.addAdditionalInfo(out.str());
223 if(!filePtr && (hasFallbackUrl)) {
226 std::unique_ptr<InputSource::FileOpenSentry>
228 std::string fallbackFullName = gSystem->ExpandPathName(fallbackName.c_str());
231 filePtr.reset(
new InputFile(fallbackFullName.c_str(),
" Fallback request to file ",
inputType_));
237 ex.addContext(
"Calling RootInputFileSequence::initFile()");
238 std::ostringstream
out;
239 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.\n";
240 out <<
"Fallback Input file " << fallbackName <<
" also could not be opened.";
241 ex.addAdditionalInfo(out.str());
272 currentIndexIntoFile,
281 indexesIntoFiles_[currentIndexIntoFile] =
rootFile_->indexIntoFileSharedPtr();
282 char const* inputType = 0;
293 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
295 LogWarning(
"") <<
"Input file: " <<
fileIter_->fileName() <<
" was not found or could not be opened, and will be skipped.\n";
299 std::shared_ptr<ProductRegistry const>
305 std::shared_ptr<BranchIDListHelper const>
328 if(!mergeInfo.empty()) {
352 if(!mergeInfo.empty()) {
363 std::shared_ptr<RunAuxiliary>
369 std::shared_ptr<LuminosityBlockAuxiliary>
372 return rootFile_->readLuminosityBlockAuxiliary_();
384 rootFile_->readLuminosityBlock_(lumiPrincipal);
434 return rootFile_->containsItem(run, lumi, event);
471 bool atEnd =
rootFile_->skipEvents(offset);
472 if((offset > 0 || atEnd) && !
nextFile()) {
496 bool closedOriginalFile =
false;
497 std::vector<FileCatalogItem>::const_iterator originalFile =
fileIter_;
501 typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
519 closedOriginalFile =
true;
528 if(closedOriginalFile) {
532 rootFile_->setPosition(originalPosition);
541 typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
567 typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
569 if(*it && (*it)->containsItem(run, lumi, event)) {
571 std::vector<FileCatalogItem>::const_iterator currentIter =
fileIter_;
578 found =
rootFile_->setEntryAtItem(run, lumi, event);
619 std::shared_ptr<ProductRegistry const>
626 std::vector<std::string>
rules;
627 rules.reserve(wantedBranches.size() + 1);
628 rules.emplace_back(
"drop *");
630 rules.push_back(
"keep " + branch +
"_*");
668 throw Exception(
errors::Configuration) <<
"RootInputFileSequence::readOneSequentialWithID(): no input files specified for secondary input source.\n";
672 rootFile_->indexIntoFileIter().run() !=
id.run() ||
673 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
680 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
682 found =
rootFile_->readCurrentEvent(cache);
703 "RootInputFileSequence::readOneSpecified(): Secondary Input files" <<
704 " do not contain specified event:\n" <<
id <<
"\n";
707 found =
rootFile_->readCurrentEvent(cache);
723 if(newSeqNumber != currentSeqNumber) {
725 currentSeqNumber = newSeqNumber;
730 "RootInputFileSequence::readOneRandom(): Secondary Input file " <<
fileIter_->fileName() <<
" contains no events.\n";
739 bool found =
rootFile_->readCurrentEvent(cache);
754 rootFile_->indexIntoFileIter().run() !=
id.run() ||
755 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
760 int eventsInLumi = 0;
762 while(
rootFile_->setEntryAtNextEventInLumi(
id.run(),
id.luminosityBlock())) ++eventsInLumi;
765 int eventInLumi = CLHEP::RandFlat::shootInt(engine, eventsInLumi);
766 for(
int i = 0;
i < eventInLumi; ++
i) {
767 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
772 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
774 found =
rootFile_->readCurrentEvent(cache);
777 bool found =
rootFile_->setEntryAtItem(
id.
run(),
id.luminosityBlock(), 0);
789 ->setComment(
"Skip the first 'skipEvents' events that otherwise would have been processed.");
791 ->setComment(
"True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
792 "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
793 "Note 1: Events within the same lumi will always be processed contiguously.\n"
794 "Note 2: Lumis within the same run will always be processed contiguously.\n"
795 "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
797 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
798 "False: Throw exception if missing or unopenable input file.");
800 ->setComment(
"True: Bypass release version check.\n"
801 "False: Throw exception if reading file in a release prior to the release in which the file was written.");
803 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
805 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
807 ->setComment(
"If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
808 desc.
addUntracked<
bool>(
"dropDescendantsOfDroppedBranches",
true)
809 ->setComment(
"If True, also drop on input any descendent of any branch dropped on input.");
812 ->setComment(
"'strict': Branches in each input file must match those in the first file.\n"
813 "'permissive': Branches in each input file may be any subset of those in the first file.");
815 ->setComment(
"If True: replace module label for raw data to match MC. Also use 'LHC' as process.");
828 std::vector<FileCatalogItem>::const_iterator itr(
fileIter_);
841 if(!
rootFile_->wasFirstEventJustRead()) {
853 for(
auto const& branchID : associationsFromSecondary) {
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)
virtual std::string explainSelf() const
unsigned long long EventNumber_t
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.