LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::RootDelayedReader Class Referencefinal

#include "RootDelayedReader.h"

Inheritance diagram for art::RootDelayedReader:
art::DelayedReader

Public Member Functions

 ~RootDelayedReader ()=default
 
 RootDelayedReader (RootDelayedReader const &)=delete
 
RootDelayedReaderoperator= (RootDelayedReader const &)=delete
 
 RootDelayedReader (FileFormatVersion, sqlite3 *db, std::vector< input::EntryNumber > const &entrySet, input::BranchMap const &, cet::exempt_ptr< RootInputTree > tree, int64_t saveMemoryObjectThreshold, cet::exempt_ptr< RootInputFile > primaryFile, cet::exempt_ptr< BranchIDLists const > branchIDLists, BranchType branchType, EventID, bool compactSubRunRanges)
 
std::unique_ptr< EDProductgetProduct (BranchKey const &k, TypeID const &wrapper_type, RangeSet &rs) const
 
void setGroupFinder (cet::exempt_ptr< EDProductGetterFinder const > ep)
 
int openNextSecondaryFile (int idx)
 

Private Member Functions

std::unique_ptr< EDProductgetProduct_ (BranchKey const &, TypeID const &, RangeSet &) const override
 
void setGroupFinder_ (cet::exempt_ptr< EDProductGetterFinder const >) override
 
int openNextSecondaryFile_ (int idx) override
 

Private Attributes

FileFormatVersion fileFormatVersion_
 
sqlite3 * db_
 
std::vector< input::EntryNumber > const entrySet_
 
input::BranchMap const & branches_
 
cet::exempt_ptr< RootInputTreetree_
 
int64_t saveMemoryObjectThreshold_
 
cet::exempt_ptr< EDProductGetterFinder const > groupFinder_
 
cet::exempt_ptr< RootInputFileprimaryFile_
 
cet::exempt_ptr< BranchIDLists const > branchIDLists_
 
BranchType branchType_
 
EventID eventID_
 
bool const compactSubRunRanges_
 

Detailed Description

Definition at line 29 of file RootDelayedReader.h.

Constructor & Destructor Documentation

art::RootDelayedReader::~RootDelayedReader ( )
default
art::RootDelayedReader::RootDelayedReader ( RootDelayedReader const &  )
delete
art::RootDelayedReader::RootDelayedReader ( FileFormatVersion  version,
sqlite3 *  db,
std::vector< input::EntryNumber > const &  entrySet,
input::BranchMap const &  branches,
cet::exempt_ptr< RootInputTree tree,
int64_t  saveMemoryObjectThreshold,
cet::exempt_ptr< RootInputFile primaryFile,
cet::exempt_ptr< BranchIDLists const >  branchIDLists,
BranchType  branchType,
EventID  eID,
bool  compactSubRunRanges 
)

Definition at line 23 of file RootDelayedReader.cc.

References branches_, branchIDLists_, branchType_, compactSubRunRanges_, db_, entrySet_, eventID_, primaryFile_, saveMemoryObjectThreshold_, and tree_.

35  : fileFormatVersion_{version}
36  , db_{db}
37  , entrySet_{entrySet}
38  , branches_{branches}
39  , tree_{tree}
40  , saveMemoryObjectThreshold_{saveMemoryObjectThreshold}
41  , primaryFile_{primaryFile}
42  , branchIDLists_{bidLists}
43  , branchType_{branchType}
44  , eventID_{eID}
45  , compactSubRunRanges_{compactSubRunRanges}
46  {}
std::vector< input::EntryNumber > const entrySet_
cet::exempt_ptr< RootInputFile > primaryFile_
cet::exempt_ptr< RootInputTree > tree_
input::BranchMap const & branches_
cet::exempt_ptr< BranchIDLists const > branchIDLists_
FileFormatVersion fileFormatVersion_

Member Function Documentation

std::unique_ptr<EDProduct> art::DelayedReader::getProduct ( BranchKey const &  k,
TypeID const &  wrapper_type,
RangeSet rs 
) const
inlineinherited

Definition at line 30 of file DelayedReader.h.

References art::DelayedReader::getProduct_().

33  {
34  return getProduct_(k, wrapper_type, rs);
35  }
virtual std::unique_ptr< EDProduct > getProduct_(BranchKey const &, TypeID const &, RangeSet &) const =0
unique_ptr< EDProduct > art::RootDelayedReader::getProduct_ ( BranchKey const &  bk,
TypeID const &  ty,
RangeSet rs 
) const
overrideprivatevirtual

Implements art::DelayedReader.

Definition at line 56 of file RootDelayedReader.cc.

References branches_, branchIDLists_, branchType_, compactSubRunRanges_, db_, art::disjoint_ranges(), e, entrySet_, eventID_, fileFormatVersion_, art::RangeSet::forRun(), art::RangeSet::forSubRun(), art::input::getEntry(), groupFinder_, art::InRun, art::InSubRun, art::RangeSet::is_valid(), art::RangeSet::merge(), art::overlapping_ranges(), art::input::BranchInfo::productBranch_, art::errors::ProductCannotBeAggregated, art::detail::resolveRangeSet(), art::EventID::runID(), s, art::same_ranges(), saveMemoryObjectThreshold_, art::EventID::subRunID(), std::swap(), tree_, art::TypeID::typeInfo(), and art::FileFormatVersion::value_.

59  {
60  auto iter = branches_.find(bk);
61  assert(iter != branches_.end());
62 
63  input::BranchInfo const& branchInfo = iter->second;
64  TBranch* br{branchInfo.productBranch_};
65  assert(br != nullptr);
66 
67  configureProductIDStreamer(branchIDLists_);
68  configureRefCoreStreamer(groupFinder_);
69  TClass* cl{TClass::GetClass(ty.typeInfo())};
70 
71  auto get_product = [this, cl, br](auto entry) {
72  tree_->setEntryNumber(entry);
73  unique_ptr<EDProduct> p{static_cast<EDProduct*>(cl->New())};
74  EDProduct* pp{p.get()};
75  br->SetAddress(&pp);
76  auto const bytesRead = input::getEntry(br, entry);
77  if ((saveMemoryObjectThreshold_ > -1) &&
78  (bytesRead > saveMemoryObjectThreshold_)) {
79  br->DropBaskets("all");
80  }
81  return p;
82  };
83 
84  // Retrieve first product
85  auto result = get_product(entrySet_[0]);
86 
87  // Retrieve and aggregate subsequent products (if they exist)
88  if (branchType_ == InSubRun || branchType_ == InRun) {
89 
90  // Products from files that did not support RangeSets are
91  // assigned RangeSets that correspond to the entire run/subrun.
92  if (fileFormatVersion_.value_ < 9) {
93  if (branchType_ == InRun) {
95  } else {
97  }
98  configureProductIDStreamer();
99  configureRefCoreStreamer();
100  return result;
101  }
102 
103  // Unfortunately, we cannot use detail::resolveRangeSetInfo in
104  // this case because products that represent a full (Sub)Run are
105  // allowed to be duplicated in an input file. The behavior in
106  // such a case is a NOP.
107  RangeSet mergedRangeSet = detail::resolveRangeSet(db_,
108  "SomeInput"s,
109  branchType_,
110  result->getRangeSetID(),
112 
113  for (auto it = entrySet_.cbegin() + 1, e = entrySet_.cend(); it != e;
114  ++it) {
115  auto p = get_product(*it);
116  auto const id = p->getRangeSetID();
117 
118  RangeSet const& newRS = detail::resolveRangeSet(
119  db_, "SomeInput"s, branchType_, id, compactSubRunRanges_);
120  if (!mergedRangeSet.is_valid() && newRS.is_valid()) {
121  mergedRangeSet = newRS;
122  std::swap(result, p);
123  } else if (art::disjoint_ranges(mergedRangeSet, newRS)) {
124  result->combine(p.get());
125  mergedRangeSet.merge(newRS);
126  } else if (art::same_ranges(mergedRangeSet, newRS)) {
127  // The ranges are the same, so the behavior is a NOP. If
128  // the stakeholders decide that products with the same
129  // ranges should be checked for equality, the condition
130  // will be added here.
131  } else if (art::overlapping_ranges(mergedRangeSet, newRS)) {
133  "RootDelayedReader::getProduct_"}
134  << "\nThe following ranges corresponding to the product:\n"
135  << " '" << bk << "'"
136  << "\ncannot be aggregated\n"
137  << mergedRangeSet << " and\n"
138  << newRS << "\nPlease contact artists@fnal.gov.\n";
139  }
140  // NOP when both RangeSets are invalid
141  }
142  std::swap(rs, mergedRangeSet);
143  }
144 
145  configureProductIDStreamer();
146  configureRefCoreStreamer();
147  return result;
148  }
RunID const & runID() const
Definition: EventID.h:93
SubRunID const & subRunID() const
Definition: EventID.h:105
Float_t s
Definition: plot.C:23
RangeSet resolveRangeSet(RangeSetInfo const &rs)
std::enable_if_t< detail::are_handles< T, U >::value, bool > disjoint_ranges(T const &a, U const &b)
std::vector< input::EntryNumber > const entrySet_
static RangeSet forRun(RunID)
Definition: RangeSet.cc:52
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:58
cet::exempt_ptr< EDProductGetterFinder const > groupFinder_
cet::exempt_ptr< RootInputTree > tree_
std::enable_if_t< detail::are_handles< T, U >::value, bool > overlapping_ranges(T const &a, U const &b)
std::enable_if_t< detail::are_handles< T, U >::value, bool > same_ranges(T const &a, U const &b)
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: getEntry.cc:12
input::BranchMap const & branches_
cet::exempt_ptr< BranchIDLists const > branchIDLists_
Float_t e
Definition: plot.C:34
FileFormatVersion fileFormatVersion_
int art::DelayedReader::openNextSecondaryFile ( int  idx)
inlineinherited
int art::RootDelayedReader::openNextSecondaryFile_ ( int  idx)
overrideprivatevirtual

Reimplemented from art::DelayedReader.

Definition at line 152 of file RootDelayedReader.cc.

References branchType_, eventID_, art::InEvent, art::InRun, art::InSubRun, primaryFile_, art::EventID::runID(), and art::EventID::subRunID().

153  {
154  // idx being a number we can actually use is a precondition of
155  // this function.
156  assert(!(idx < 0));
157 
158  // Note:
159  //
160  // Return code of -2 means stop, -1 means event-not-found,
161  // otherwise 0 for success.
162  //
163  auto const& sfnm = primaryFile_->secondaryFileNames();
164  assert(!(static_cast<decltype(sfnm.size())>(idx) > sfnm.size()));
165  if (sfnm.empty()) { // No configured secondary files.
166  return -2;
167  }
168  auto const& sf = primaryFile_->secondaryFiles();
169  if (static_cast<decltype(sfnm.size())>(idx) == sfnm.size()) {
170  // We're done.
171  return -2;
172  }
173 
174  if (!sf[idx]) {
175  primaryFile_->openSecondaryFile(idx);
176  }
177 
178  switch (branchType_) {
179  case InEvent: {
180  if (!sf[idx]->readEventForSecondaryFile(eventID_)) {
181  return -1;
182  }
183  } break;
184  case InSubRun: {
185  if (!sf[idx]->readSubRunForSecondaryFile(eventID_.subRunID())) {
186  return -1;
187  }
188  } break;
189  case InRun: {
190  if (!sf[idx]->readRunForSecondaryFile(eventID_.runID())) {
191  return -1;
192  }
193  } break;
194  default: {
195  assert(false && "RootDelayedReader encountered an unknown BranchType!");
196  return -2;
197  }
198  }
199  return 0;
200  }
RunID const & runID() const
Definition: EventID.h:93
SubRunID const & subRunID() const
Definition: EventID.h:105
cet::exempt_ptr< RootInputFile > primaryFile_
RootDelayedReader& art::RootDelayedReader::operator= ( RootDelayedReader const &  )
delete
void art::DelayedReader::setGroupFinder ( cet::exempt_ptr< EDProductGetterFinder const >  ep)
inlineinherited

Definition at line 38 of file DelayedReader.h.

References art::DelayedReader::setGroupFinder_().

Referenced by art::EventPrincipal::EventPrincipal(), art::ResultsPrincipal::ResultsPrincipal(), art::RunPrincipal::RunPrincipal(), and art::SubRunPrincipal::SubRunPrincipal().

39  {
40  setGroupFinder_(ep);
41  }
virtual void setGroupFinder_(cet::exempt_ptr< EDProductGetterFinder const >)
void art::RootDelayedReader::setGroupFinder_ ( cet::exempt_ptr< EDProductGetterFinder const >  groupFinder)
overrideprivatevirtual

Reimplemented from art::DelayedReader.

Definition at line 49 of file RootDelayedReader.cc.

References groupFinder_.

51  {
52  groupFinder_ = groupFinder;
53  }
cet::exempt_ptr< EDProductGetterFinder const > groupFinder_

Member Data Documentation

input::BranchMap const& art::RootDelayedReader::branches_
private

Definition at line 60 of file RootDelayedReader.h.

Referenced by getProduct_(), and RootDelayedReader().

cet::exempt_ptr<BranchIDLists const> art::RootDelayedReader::branchIDLists_
private

Definition at line 66 of file RootDelayedReader.h.

Referenced by getProduct_(), and RootDelayedReader().

BranchType art::RootDelayedReader::branchType_
private

Definition at line 67 of file RootDelayedReader.h.

Referenced by getProduct_(), openNextSecondaryFile_(), and RootDelayedReader().

bool const art::RootDelayedReader::compactSubRunRanges_
private

Definition at line 69 of file RootDelayedReader.h.

Referenced by getProduct_(), and RootDelayedReader().

sqlite3* art::RootDelayedReader::db_
private

Definition at line 58 of file RootDelayedReader.h.

Referenced by getProduct_(), and RootDelayedReader().

std::vector<input::EntryNumber> const art::RootDelayedReader::entrySet_
private

Definition at line 59 of file RootDelayedReader.h.

Referenced by getProduct_(), and RootDelayedReader().

EventID art::RootDelayedReader::eventID_
private

Definition at line 68 of file RootDelayedReader.h.

Referenced by getProduct_(), openNextSecondaryFile_(), and RootDelayedReader().

FileFormatVersion art::RootDelayedReader::fileFormatVersion_
private

Definition at line 57 of file RootDelayedReader.h.

Referenced by getProduct_().

cet::exempt_ptr<EDProductGetterFinder const> art::RootDelayedReader::groupFinder_
private

Definition at line 63 of file RootDelayedReader.h.

Referenced by getProduct_(), and setGroupFinder_().

cet::exempt_ptr<RootInputFile> art::RootDelayedReader::primaryFile_
private

Definition at line 64 of file RootDelayedReader.h.

Referenced by openNextSecondaryFile_(), and RootDelayedReader().

int64_t art::RootDelayedReader::saveMemoryObjectThreshold_
private

Definition at line 62 of file RootDelayedReader.h.

Referenced by getProduct_(), and RootDelayedReader().

cet::exempt_ptr<RootInputTree> art::RootDelayedReader::tree_
private

Definition at line 61 of file RootDelayedReader.h.

Referenced by getProduct_(), and RootDelayedReader().


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