readMetadata.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Root_detail_readMetadata_h
2 #define art_Framework_IO_Root_detail_readMetadata_h
3 
7 
8 #include "TBranch.h"
9 
10 namespace art {
11  namespace detail {
12  template <typename T>
13  T
14  readMetadata(TTree* md, bool const requireDict = true)
15  {
16  auto branch = md->GetBranch(art::rootNames::metaBranchRootName<T>());
17  assert(branch != nullptr);
18  auto mdField = requireDict ? root::getObjectRequireDict<T>() : T{};
19  auto field_ptr = &mdField;
20  branch->SetAddress(&field_ptr);
22  branch->ResetAddress();
23  return mdField;
24  }
25 
26  template <typename T>
27  bool
28  readMetadata(TTree* md, T& field, bool const requireDict = true)
29  {
30  auto branch = md->GetBranch(art::rootNames::metaBranchRootName<T>());
31  if (branch == nullptr) {
32  return false;
33  }
34  auto mdField = requireDict ? root::getObjectRequireDict<T>() : T{};
35  auto field_ptr = &mdField;
36  branch->SetAddress(&field_ptr);
38  branch->ResetAddress();
39  std::swap(mdField, field);
40  return true;
41  }
42  } // namespace detail
43 } // namespace art
44 
45 #endif /* art_Framework_IO_Root_detail_readMetadata_h */
46 
47 // Local Variables:
48 // mode: c++
49 // End:
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
assert(nhit_max >=nhit_nbins)
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
double T
Definition: Xdiff_gwt.C:5
T readMetadata(TTree *md, bool const requireDict=true)
Definition: readMetadata.h:14