14 #include "cetlib/container_algorithms.h" 30 RootInputFileSequence::RootInputFileSequence(
61 map<string const, vector<string>
const> secondaryFilesMap;
63 std::vector<Config::SecondaryFile> secondaryFiles;
65 for (
auto const& val : secondaryFiles) {
66 auto const a = val.a();
67 auto const b = val.b();
70 <<
"Empty filename found as value of an \"a\" parameter!\n";
72 for (
auto const& name : b) {
75 <<
"Empty secondary filename found as value of an \"b\" " 79 secondaryFilesMap.emplace(a, b);
85 for (
auto const& primaryFileName : primaryFileNames) {
86 vector<string> secondaries;
87 auto SFMI = secondaryFilesMap.find(primaryFileName);
88 if (SFMI == secondaryFilesMap.end()) {
93 if (!SFMI->second.size()) {
98 stk.emplace_back(SFMI->second.cbegin(), SFMI->second.cend());
100 auto val = stk.back();
102 if (val.first == val.second) {
106 auto const& fn = *val.first;
108 secondaries.push_back(fn);
109 auto SI = secondaryFilesMap.find(fn);
110 if (SI == secondaryFilesMap.end()) {
112 if (val.first == val.second) {
116 stk.emplace_back(val.first, val.second);
119 if (!SI->second.size()) {
121 if (val.first == val.second) {
125 stk.emplace_back(val.first, val.second);
128 stk.emplace_back(val.first, val.second);
129 stk.emplace_back(SI->second.cbegin(), SI->second.cend());
134 bool const haveFirstRun{config().hasFirstRun(firstRun)};
136 bool const haveFirstSubRun{config().hasFirstSubRun(firstSubRun)};
138 bool const haveFirstEvent{config().hasFirstEvent(firstEvent)};
141 SubRunID const firstSubRunID{haveFirstSubRun ?
150 <<
"Illegal configuration options passed to RootInput\n" 151 <<
"You cannot request \"noEventSort\" and also set \"firstEvent\".\n";
158 <<
"RootInputFileSequence looking for next file with a pending close!";
171 if (config().setRunNumber(
setRun_)) {
179 <<
" does not correspond to a valid run number in [" 188 <<
"The value of the 'setRunNumber' parameter must not be\n" 189 <<
"less than the first run number in the first input file.\n" 190 <<
"'setRunNumber' was " <<
setRun_ <<
", while the first run was " 196 <<
"Source parameter readParameterSets was set to false: parameter set " 198 <<
"will NOT be available in this or subsequent jobs using output from " 200 <<
"Check your experiment's policy on this issue to avoid future " 202 <<
"with analysis reproducibility.\n";
206 <<
"Source parameter compactEventRanges was set to true: enabling " 207 "compact event ranges\n" 208 <<
"creates a history that can cause file concatenation problems if a " 209 "given SubRun spans\n" 210 <<
"multiple input files. Use with care.\n";
221 return rootFile_->eventIDForFileIndexPosition();
232 (!found) && it != itEnd;
234 if (*it && (*it)->contains(eID, exact)) {
241 return rootFile_->eventIDForFileIndexPosition();
256 return rootFile_->eventIDForFileIndexPosition();
259 vector<FileCatalogItem>
const&
271 std::unique_ptr<FileBlock>
285 return std::make_unique<RootFileBlock>();
321 std::unique_ptr<TFile> filePtr;
331 <<
"\nRootInputFileSequence::initFile(): Input file " 333 <<
" was not found or could not be opened.\n";
336 if (!filePtr || filePtr->IsZombie()) {
339 <<
"RootInputFileSequence::initFile(): Input file " 341 <<
" was not found or could not be opened.\n";
345 <<
" was not found or could not be opened, and will be skipped.\n";
350 vector<string> empty_vs;
374 exempt_ptr<RootInputFile>{
nullptr},
388 std::unique_ptr<RootInputFile>
391 exempt_ptr<RootInputFile> primaryFile)
393 std::unique_ptr<TFile> filePtr;
401 <<
"\nRootInputFileSequence::openSecondaryFile(): Input file " << name
402 <<
" was not found or could not be opened.\n";
404 if (!filePtr || filePtr->IsZombie()) {
406 <<
"RootInputFileSequence::openSecondaryFile(): Input file " << name
407 <<
" was not found or could not be opened.\n";
410 vector<string> empty_secondary_filenames;
411 return std::make_unique<RootInputFile>(name,
434 empty_secondary_filenames,
474 unique_ptr<EventPrincipal>
481 unique_ptr<EventPrincipal> eptr(
readEvent_());
492 if (*I && (*I)->contains(
id, exact)) {
518 unique_ptr<EventPrincipal>
537 std::unique_ptr<RangeSetHandler>
543 std::unique_ptr<RangeSetHandler>
546 return rootFile_->subRunRangeSetHandler();
549 std::unique_ptr<SubRunPrincipal>
551 cet::exempt_ptr<RunPrincipal> rp)
559 return std::unique_ptr<SubRunPrincipal>{
nullptr};
568 if (*it && (*it)->contains(
id,
true)) {
587 return std::unique_ptr<SubRunPrincipal>{
nullptr};
590 std::unique_ptr<SubRunPrincipal>
596 std::unique_ptr<RunPrincipal>
607 return std::unique_ptr<RunPrincipal>{
nullptr};
612 if (*I && (*I)->contains(
id,
true)) {
632 return std::unique_ptr<RunPrincipal>{
nullptr};
635 std::unique_ptr<RunPrincipal>
677 <<
"RootInputFileSequence::rewind_() " 678 <<
"cannot rollback on non-searchable file catalogs.";
698 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 EventID firstEvent()
std::string const & fileName() const
cet::coded_exception< error, detail::translate > exception
IDNumber_t< Level::Run > RunNumber_t