LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::detail::InfoDumperInputFile Class Reference

#include "InfoDumperInputFile.h"

Public Types

using EntryNumber = input::EntryNumber
 
using EntryNumbers = input::EntryNumbers
 

Public Member Functions

 InfoDumperInputFile (std::string const &filename)
 
void print_process_history (std::ostream &) const
 
void print_range_sets (std::ostream &, bool compactRanges) const
 
void print_event_list (std::ostream &) const
 
void print_file_index (std::ostream &) const
 
void print_branchIDLists (std::ostream &os) const
 
TFile * tfile () const
 

Private Member Functions

RunAuxiliary getAuxiliary (TTree *tree, EntryNumber const entry) const
 
RangeSet getRangeSet (TTree *tree, EntryNumbers const &entries, sqlite3 *db, std::string const &filename, bool compactRanges) const
 

Private Attributes

std::unique_ptr< TFile > file_
 
BranchIDLists branchIDLists_ {}
 
ProcessHistoryMap pHistMap_
 
FileIndex fileIndex_
 
FileFormatVersion fileFormatVersion_
 

Detailed Description

Definition at line 23 of file InfoDumperInputFile.h.

Member Typedef Documentation

Constructor & Destructor Documentation

art::detail::InfoDumperInputFile::InfoDumperInputFile ( std::string const &  filename)

Definition at line 61 of file InfoDumperInputFile.cc.

References branchIDLists_, file_, fileFormatVersion_, fileIndex_, art::rootNames::metaDataTreeName(), pHistMap_, art::detail::readFileIndex(), and art::detail::readMetadata().

63  : file_{openFile(filename)}
64 {
65  using namespace art::rootNames;
66  std::unique_ptr<TTree> md{
67  static_cast<TTree*>(file_->Get(metaDataTreeName().data()))};
68 
69  fileFormatVersion_ = detail::readMetadata<FileFormatVersion>(md.get());
70 
71  // Read BranchID lists if they exist
73 
74  // Read file index
75  auto findexPtr = &fileIndex_;
76  art::detail::readFileIndex(file_.get(), md.get(), findexPtr);
77 
78  // Read ProcessHistory
79  pHistMap_ = detail::readMetadata<ProcessHistoryMap>(md.get());
80 }
void readFileIndex(TFile *file, TTree *metaDataTree, FileIndex *&findexPtr)
Definition: readFileIndex.h:20
std::string const & metaDataTreeName()
Definition: rootNames.cc:41
std::unique_ptr< TFile > file_
T readMetadata(TTree *md, bool const requireDict=true)
Definition: readMetadata.h:13

Member Function Documentation

art::RunAuxiliary art::detail::InfoDumperInputFile::getAuxiliary ( TTree *  tree,
EntryNumber const  entry 
) const
private

Definition at line 210 of file InfoDumperInputFile.cc.

References art::BranchTypeToAuxiliaryBranchName(), and art::InRun.

Referenced by getRangeSet(), and tfile().

212 {
213  auto aux = std::make_unique<RunAuxiliary>();
214  auto pAux = aux.get();
215  TBranch* auxBranch =
216  tree->GetBranch(BranchTypeToAuxiliaryBranchName(InRun).c_str());
217  auxBranch->SetAddress(&pAux);
218  tree->LoadTree(entry);
219  auxBranch->GetEntry(entry);
220  return *aux;
221 }
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const bt)
Definition: BranchType.cc:83
art::RangeSet art::detail::InfoDumperInputFile::getRangeSet ( TTree *  tree,
EntryNumbers const &  entries,
sqlite3 *  db,
std::string const &  filename,
bool  compactRanges 
) const
private

Definition at line 224 of file InfoDumperInputFile.cc.

References e, getAuxiliary(), art::InRun, art::detail::resolveRangeSet(), and art::detail::resolveRangeSetInfo().

Referenced by print_range_sets(), and tfile().

229 {
230  auto resolve_info = [db, &filename](auto const id, bool const compact) {
231  return detail::resolveRangeSetInfo(db, filename, InRun, id, compact);
232  };
233 
234  auto auxResult = getAuxiliary(tree, entries[0]);
235  auto rangeSetInfo = resolve_info(auxResult.rangeSetID(), compactRanges);
236 
237  for (auto i = entries.cbegin() + 1, e = entries.cend(); i != e; ++i) {
238  auto const& tmpAux = getAuxiliary(tree, *i);
239  rangeSetInfo.update(resolve_info(tmpAux.rangeSetID(), compactRanges),
240  compactRanges);
241  }
242 
243  return resolveRangeSet(rangeSetInfo);
244 }
RangeSetInfo resolveRangeSetInfo(sqlite3 *, std::string const &filename, BranchType, unsigned RangeSetID, bool compact)
RangeSet resolveRangeSet(RangeSetInfo const &rs)
RunAuxiliary getAuxiliary(TTree *tree, EntryNumber const entry) const
Float_t e
Definition: plot.C:34
void art::detail::InfoDumperInputFile::print_branchIDLists ( std::ostream &  os) const

Definition at line 130 of file InfoDumperInputFile.cc.

References branchIDLists_, fileFormatVersion_, art::errors::FileReadError, art::detail::orderedProcessNamesCollection(), pHistMap_, and art::FileFormatVersion::value_.

Referenced by print_branchIDLists().

131 {
132  if (fileFormatVersion_.value_ >= 10) {
133  std::ostringstream oss;
134  oss << " BranchIDLists are not stored for art/ROOT files with a format\n"
135  << " version of \"" << fileFormatVersion_ << "\".\n";
137  "InfoDumperInputFile::print_branchIDLists:\n"}
138  << oss.str();
139  }
140 
141  auto const& processNames = orderedProcessNamesCollection(pHistMap_);
142  // For older file format versions, there cannot be more than one
143  // ordered process name, due to the compatibility requirements that
144  // were enforced in generating the file.
145  assert(processNames.size() == 1ull);
146 
147  os << "\n List of BranchIDs produced for this file. The BranchIDs are\n"
148  << " grouped according to the process in which they were produced. The\n"
149  << " processes are presented in chronological order; however within each "
150  "process,\n"
151  << " the order of listed BranchIDs is not meaningful.\n";
152  unsigned i{};
153  for (auto const& process : processNames.front()) {
154  os << "\n Process " << i + 1 << ": " << process << '\n';
155  for (auto const& bid : branchIDLists_[i]) {
156  os << " " << bid << '\n';
157  }
158  ++i;
159  }
160 }
std::vector< std::vector< std::string > > orderedProcessNamesCollection(ProcessHistoryMap const &pHistMap)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void art::detail::InfoDumperInputFile::print_event_list ( std::ostream &  os) const

Definition at line 83 of file InfoDumperInputFile.cc.

References fileIndex_, and art::FileIndex::print_event_list().

Referenced by print_event_list().

84 {
86 }
void print_event_list(std::ostream &os) const
Definition: FileIndex.cc:256
void art::detail::InfoDumperInputFile::print_file_index ( std::ostream &  os) const

Definition at line 89 of file InfoDumperInputFile.cc.

References fileIndex_.

Referenced by print_file_index().

90 {
91  os << fileIndex_;
92 }
void art::detail::InfoDumperInputFile::print_process_history ( std::ostream &  os) const

Definition at line 95 of file InfoDumperInputFile.cc.

References art::detail::orderedProcessNamesCollection(), pHistMap_, and art::right().

Referenced by print_process_history().

96 {
97  auto const& processNamesCollection = orderedProcessNamesCollection(pHistMap_);
98  bool printHistoryLabel{false};
99  if (processNamesCollection.empty()) {
100  os << "\n No process history was recorded for this file.\n";
101  return;
102  } else if (processNamesCollection.size() > 1ull) {
103  printHistoryLabel = true;
104  os << "\n This file was produced with multiple processing histories.\n";
105  }
106 
107  // Relying on a single character will be problematic if the
108  // process-names collection has more than 26 elements. Hopefully,
109  // nobody will produce a job that involves the concatenation of more
110  // than 26 inconsistent process histories. If so, we'll solve the
111  // process-history labeling below issue once we come to it.
112  char hl{'A'};
113 
114  for (auto const& processNames : processNamesCollection) {
115  unsigned i{1u};
116  if (printHistoryLabel) {
117  os << "\n Chronological list of process names for process history: "
118  << hl++ << "\n\n";
119  } else {
120  os << "\n Chronological list of process names for processes that\n"
121  << " produced this file.\n\n";
122  }
123  for (auto const& process : processNames) {
124  os << ' ' << std::setw(4) << std::right << i++ << ". " << process << '\n';
125  }
126  }
127 }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
std::vector< std::vector< std::string > > orderedProcessNamesCollection(ProcessHistoryMap const &pHistMap)
void art::detail::InfoDumperInputFile::print_range_sets ( std::ostream &  os,
bool  compactRanges 
) const

Definition at line 163 of file InfoDumperInputFile.cc.

References art::BranchTypeToProductTreeName(), art::FileIndex::cbegin(), art::FileIndex::cend(), file_, fileFormatVersion_, fileIndex_, getRangeSet(), art::InRun, art::FileIndex::kRun, art::detail::rangeSetFromFileIndex(), and art::FileFormatVersion::value_.

Referenced by print_range_sets().

166 {
167  auto it = fileIndex_.cbegin();
168  auto const cend = fileIndex_.cend();
169  constexpr cet::HorizontalRule rule{30};
170  std::string const rep{compactRanges ? "compact" : "full (default)"};
171 
172  if (fileFormatVersion_.value_ < 9) {
173  os << '\n'
174  << "*** This file has a format version of \"" << fileFormatVersion_
175  << "\" and therefore\n"
176  << "*** does not contain range-set information. The printout below is\n"
177  << "*** the range set art would assign to this file.\n\n"
178  << "Representation: " << rep << '\n'
179  << rule('-') << '\n';
180 
181  for (auto const& element : fileIndex_) {
182  if (element.getEntryType() != art::FileIndex::kRun)
183  continue;
184  auto const& rs = rangeSetFromFileIndex(
185  fileIndex_, element.eventID_.runID(), compactRanges);
186  os << rs << '\n';
187  }
188  return;
189  }
190 
191  auto* tree =
192  static_cast<TTree*>(file_->Get(BranchTypeToProductTreeName(InRun).c_str()));
193  SQLite3Wrapper db{file_.get(), "RootFileDB"};
194 
195  os << "Representation: " << rep << '\n' << rule('-') << '\n';
196  while (it != cend) {
197  if (it->getEntryType() != art::FileIndex::kRun) {
198  ++it;
199  continue;
200  }
201  // getEntryNumbers increments iterator!
202  auto const& entries = getEntryNumbers(it, cend);
203  auto const& rs =
204  getRangeSet(tree, entries, db, file_->GetName(), compactRanges);
205  os << rs << '\n';
206  }
207 }
std::string const & BranchTypeToProductTreeName(BranchType const bt)
Definition: BranchType.cc:71
const_iterator cbegin() const
Definition: FileIndex.h:103
RangeSet rangeSetFromFileIndex(FileIndex const &fileIndex, RunID runID, bool compactRanges)
const_iterator cend() const
Definition: FileIndex.h:119
std::unique_ptr< TFile > file_
RangeSet getRangeSet(TTree *tree, EntryNumbers const &entries, sqlite3 *db, std::string const &filename, bool compactRanges) const
TFile* art::detail::InfoDumperInputFile::tfile ( ) const
inline

Definition at line 35 of file InfoDumperInputFile.h.

References file_, getAuxiliary(), and getRangeSet().

Referenced by db_to_file().

36  {
37  return file_.get();
38  }
std::unique_ptr< TFile > file_

Member Data Documentation

BranchIDLists art::detail::InfoDumperInputFile::branchIDLists_ {}
private

Definition at line 50 of file InfoDumperInputFile.h.

Referenced by InfoDumperInputFile(), and print_branchIDLists().

std::unique_ptr<TFile> art::detail::InfoDumperInputFile::file_
private

Definition at line 49 of file InfoDumperInputFile.h.

Referenced by InfoDumperInputFile(), print_range_sets(), and tfile().

FileFormatVersion art::detail::InfoDumperInputFile::fileFormatVersion_
private
FileIndex art::detail::InfoDumperInputFile::fileIndex_
private
ProcessHistoryMap art::detail::InfoDumperInputFile::pHistMap_
private

The documentation for this class was generated from the following files: