30 RootInputFileSequence::RootInputFileSequence(
63 map<string const, vector<string>
const> secondaryFilesMap;
65 std::vector<Config::SecondaryFile> secondaryFiles;
72 if (globals.nthreads() != 1 && globals.nschedules() != 1) {
75 "An error occurred while creating the RootInput source.\n"}
76 <<
"This art process is using " << globals.nthreads()
77 <<
" thread(s) and " << globals.nschedules() <<
" schedule(s).\n" 78 <<
"Secondary file names can be used only when 1 thread and 1 " 79 "schedule are specified.\n" 80 <<
"This is done by specifying '-j=1' at the command line.\n";
83 for (
auto const&
val : secondaryFiles) {
84 auto const a =
val.a();
85 auto const b =
val.b();
88 <<
"Empty filename found as value of an \"a\" parameter!\n";
90 for (
auto const&
name :
b) {
93 <<
"Empty secondary filename found as value of an \"b\" " 97 secondaryFilesMap.emplace(
a, b);
103 for (
auto const& primaryFileName : primaryFileNames) {
104 vector<string> secondaries;
105 auto SFMI = secondaryFilesMap.find(primaryFileName);
106 if (SFMI == secondaryFilesMap.end()) {
111 if (!SFMI->second.size()) {
116 stk.emplace_back(SFMI->second.cbegin(), SFMI->second.cend());
118 auto val = stk.back();
120 if (
val.first ==
val.second) {
124 auto const& fn = *
val.first;
126 secondaries.push_back(fn);
127 auto SI = secondaryFilesMap.find(fn);
128 if (SI == secondaryFilesMap.end()) {
130 if (
val.first ==
val.second) {
134 stk.emplace_back(
val.first,
val.second);
137 if (!SI->second.size()) {
139 if (
val.first ==
val.second) {
143 stk.emplace_back(
val.first,
val.second);
146 stk.emplace_back(
val.first,
val.second);
147 stk.emplace_back(SI->second.cbegin(), SI->second.cend());
152 bool const haveFirstRun{
config().hasFirstRun(firstRun)};
154 bool const haveFirstSubRun{
config().hasFirstSubRun(firstSubRun)};
156 bool const haveFirstEvent{
config().hasFirstEvent(firstEvent)};
159 SubRunID const firstSubRunID{haveFirstSubRun ?
168 <<
"Illegal configuration options passed to RootInput\n" 169 <<
"You cannot request \"noEventSort\" and also set \"firstEvent\".\n";
176 <<
"RootInputFileSequence looking for next file with a pending close!";
199 <<
" does not correspond to a valid run number in [" 208 <<
"The value of the 'setRunNumber' parameter must not be\n" 209 <<
"less than the first run number in the first input file.\n" 210 <<
"'setRunNumber' was " <<
setRun_ <<
", while the first run was " 216 <<
"Source parameter readParameterSets was set to false: parameter set " 218 <<
"will NOT be available in this or subsequent jobs using output from " 220 <<
"Check your experiment's policy on this issue to avoid future " 222 <<
"with analysis reproducibility.\n";
226 <<
"Source parameter compactEventRanges was set to true: enabling " 227 "compact event ranges\n" 228 <<
"creates a history that can cause file concatenation problems if a " 229 "given SubRun spans\n" 230 <<
"multiple input files. Use with care.\n";
241 return rootFile_->eventIDForFileIndexPosition();
252 (!
found) && it != itEnd;
254 if (*it && (*it)->contains(eID, exact)) {
259 found =
rootFile_->setEntry_Event(eID, exact);
267 found =
rootFile_->setEntry_Event(eID, exact);
270 return rootFile_->eventIDForFileIndexPosition();
280 return rootFile_->eventIDForFileIndexPosition();
283 vector<FileCatalogItem>
const&
295 std::unique_ptr<FileBlock>
298 std::unique_ptr<FileBlock> result;
326 <<
" does not correspond to a valid run number in [" 335 <<
"The value of the 'setRunNumber' parameter must not be\n" 336 <<
"less than the first run number in the first input file.\n" 337 <<
"'setRunNumber' was " <<
setRun_ <<
", while the first run was " 382 std::unique_ptr<TFile> filePtr;
392 <<
"\nRootInputFileSequence::initFile(): Input file " 394 <<
" was not found or could not be opened.\n";
397 if (!filePtr || filePtr->IsZombie()) {
400 <<
"RootInputFileSequence::initFile(): Input file " 402 <<
" was not found or could not be opened.\n";
406 <<
" was not found or could not be opened, and will be skipped.\n";
411 vector<string> empty_vs;
449 std::unique_ptr<RootInputFile>
454 std::unique_ptr<TFile> filePtr;
462 <<
"\nRootInputFileSequence::openSecondaryFile(): Input file " << name
463 <<
" was not found or could not be opened.\n";
465 if (!filePtr || filePtr->IsZombie()) {
467 <<
"RootInputFileSequence::openSecondaryFile(): Input file " << name
468 <<
" was not found or could not be opened.\n";
471 vector<string> empty_secondary_filenames;
472 return std::make_unique<RootInputFile>(
name,
495 empty_secondary_filenames,
551 if (*I && (*I)->contains(
id, exact)) {
555 found =
rootFile_->setEntry_Event(
id, exact);
564 found =
rootFile_->setEntry_Event(
id, exact);
574 unique_ptr<EventPrincipal>
593 std::unique_ptr<RangeSetHandler>
599 std::unique_ptr<RangeSetHandler>
602 return rootFile_->subRunRangeSetHandler();
622 if (*it && (*it)->contains(
id,
true)) {
643 std::unique_ptr<SubRunPrincipal>
665 if (*I && (*I)->contains(
id,
true)) {
686 std::unique_ptr<RunPrincipal>
699 auto const entryType =
rootFile_->getNextEntryTypeWanted();
723 <<
"RootInputFileSequence::rewind_() " 724 <<
"cannot rollback on non-searchable file catalogs.";
744 while (offset != 0) {
void logFileAction(const char *msg, std::string const &file)
std::string const & logicalFileName() const
IDNumber_t< Level::SubRun > SubRunNumber_t
static SubRunID firstSubRun()
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
IDNumber_t< Level::Event > EventNumber_t
static Globals * instance()
static EventID firstEvent()
std::string const & fileName() const
cet::coded_exception< error, detail::translate > exception
IDNumber_t< Level::Run > RunNumber_t