ATLAS Offline Software
TBranchAuxDynReader.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TBRANCHAUXDYNREADER_H
6 #define TBRANCHAUXDYNREADER_H
7 
10 
11 #include <map>
12 #include <string>
13 
14 #include "TDataType.h"
15 class TTree;
16 class TClass;
17 class TBranch;
18 
20 {
21 public :
22 
23  struct BranchInfo
24  {
26 
27  TBranch* branch = 0;
28  TClass* tclass = 0;
29  EDataType edtyp = kOther_t;
30 
31  // to handle type differences
32  bool needsSE = false;
33  TClass* SE_tclass = 0;
34  EDataType SE_edt = kOther_t;
35 
36  bool isPackedContainer = false;
38 
40  std::string attribName;
41 
42  void setAddress(void* data);
43  };
44 
45  TBranchAuxDynReader(TTree *tree, TBranch *base_branch);
46 
47  void init(bool standalone);
48 
49  virtual void addReaderToObject(void* object, size_t ttree_row, std::recursive_mutex* iomtx = nullptr ) override final;
50 
51  void addBytes(size_t bytes);
52 
53  virtual size_t getBytesRead() const override final;
54 
55  virtual void resetBytesRead() override final;
56 
57  virtual const SG::auxid_set_t& auxIDs() const override final;
58 
59  BranchInfo& getBranchInfo(const SG::auxid_t& auxid, const SG::AuxStoreInternal& store);
60 
61  virtual ~TBranchAuxDynReader() {}
62 
63 protected:
64  // auxids that could be found in registry for attribute names from the file
66 
67  std::string m_baseBranchName;
68  // counter for bytes read
69  size_t m_bytesRead = 0;
70  // offset of the AxuStoreHolder base class in the objects read by the Reader
72  bool m_initialized = false;
73  std::string m_key;
74 
75  TTree* m_tree = nullptr;
76  // map of attribute name to TBranch* as read from the file
77  std::map<std::string, TBranch*> m_branchMap;
78  // map auxid -> branch info. not sure if it can be different from m_branchMap
79  std::map<SG::auxid_t, BranchInfo> m_branchInfos;
80 
81 private:
82  SG::auxid_t initBranch (bool standalone, const std::string& attr, TBranch* branch);
83 };
84 
85 
86 
87 
88 inline void TBranchAuxDynReader::addBytes(size_t bytes) {
89  m_bytesRead += bytes;
90 }
91 
92 inline size_t TBranchAuxDynReader::getBytesRead() const {
93  return m_bytesRead;
94 }
95 
97  m_bytesRead = 0;
98 }
99 
101  return m_auxids;
102 }
103 
104 
105 #endif
TBranchAuxDynReader::initBranch
SG::auxid_t initBranch(bool standalone, const std::string &attr, TBranch *branch)
Definition: TBranchAuxDynReader.cxx:184
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
TBranchAuxDynReader::BranchInfo::Initialized
@ Initialized
Definition: TBranchAuxDynReader.h:25
TBranchAuxDynReader::BranchInfo::SE_tclass
TClass * SE_tclass
Definition: TBranchAuxDynReader.h:33
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
TBranchAuxDynReader::m_branchInfos
std::map< SG::auxid_t, BranchInfo > m_branchInfos
Definition: TBranchAuxDynReader.h:79
TBranchAuxDynReader::BranchInfo
Definition: TBranchAuxDynReader.h:24
TBranchAuxDynReader::BranchInfo::branch
TBranch * branch
Definition: TBranchAuxDynReader.h:27
tree
TChain * tree
Definition: tile_monitor.h:30
TBranchAuxDynReader::init
void init(bool standalone)
Definition: TBranchAuxDynReader.cxx:229
TBranchAuxDynReader::m_bytesRead
size_t m_bytesRead
Definition: TBranchAuxDynReader.h:69
TBranchAuxDynReader::BranchInfo::status
enum Status status
Definition: TBranchAuxDynReader.h:37
TBranchAuxDynReader::BranchInfo::edtyp
EDataType edtyp
Definition: TBranchAuxDynReader.h:29
TBranchAuxDynReader::BranchInfo::auxid
SG::auxid_t auxid
Definition: TBranchAuxDynReader.h:39
TBranchAuxDynReader::BranchInfo::NotFound
@ NotFound
Definition: TBranchAuxDynReader.h:25
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
TBranchAuxDynReader::BranchInfo::NotInitialized
@ NotInitialized
Definition: TBranchAuxDynReader.h:25
TBranchAuxDynReader::m_storeHolderOffset
int m_storeHolderOffset
Definition: TBranchAuxDynReader.h:71
TBranchAuxDynReader::auxIDs
virtual const SG::auxid_set_t & auxIDs() const override final
Definition: TBranchAuxDynReader.h:100
TBranchAuxDynReader::BranchInfo::tclass
TClass * tclass
Definition: TBranchAuxDynReader.h:28
TBranchAuxDynReader::m_baseBranchName
std::string m_baseBranchName
Definition: TBranchAuxDynReader.h:67
TBranchAuxDynReader::BranchInfo::TypeError
@ TypeError
Definition: TBranchAuxDynReader.h:25
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
TBranchAuxDynReader::BranchInfo::Status
Status
Definition: TBranchAuxDynReader.h:25
TBranchAuxDynReader::TBranchAuxDynReader
TBranchAuxDynReader(TTree *tree, TBranch *base_branch)
Definition: TBranchAuxDynReader.cxx:153
TBranchAuxDynReader::BranchInfo::isPackedContainer
bool isPackedContainer
Definition: TBranchAuxDynReader.h:36
TBranchAuxDynReader::m_branchMap
std::map< std::string, TBranch * > m_branchMap
Definition: TBranchAuxDynReader.h:77
TBranchAuxDynReader::addReaderToObject
virtual void addReaderToObject(void *object, size_t ttree_row, std::recursive_mutex *iomtx=nullptr) override final
Attach specialized AuxStore for reading dynamic attributes.
Definition: TBranchAuxDynReader.cxx:331
TBranchAuxDynReader::BranchInfo::SE_edt
EDataType SE_edt
Definition: TBranchAuxDynReader.h:34
TBranchAuxDynReader::addBytes
void addBytes(size_t bytes)
Definition: TBranchAuxDynReader.h:88
TBranchAuxDynReader::BranchInfo::needsSE
bool needsSE
Definition: TBranchAuxDynReader.h:32
TBranchAuxDynReader
Definition: TBranchAuxDynReader.h:20
TBranchAuxDynReader::m_initialized
bool m_initialized
Definition: TBranchAuxDynReader.h:72
TBranchAuxDynReader::resetBytesRead
virtual void resetBytesRead() override final
Definition: TBranchAuxDynReader.h:96
TBranchAuxDynReader::BranchInfo::setAddress
void setAddress(void *data)
Definition: TBranchAuxDynReader.cxx:125
RootAuxDynIO::IRootAuxDynReader
Definition: RootAuxDynIO.h:75
TBranchAuxDynReader::getBranchInfo
BranchInfo & getBranchInfo(const SG::auxid_t &auxid, const SG::AuxStoreInternal &store)
Definition: TBranchAuxDynReader.cxx:242
TBranchAuxDynReader::BranchInfo::attribName
std::string attribName
Definition: TBranchAuxDynReader.h:40
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61
RootAuxDynIO.h
TBranchAuxDynReader::m_key
std::string m_key
Definition: TBranchAuxDynReader.h:73
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
TBranchAuxDynReader::getBytesRead
virtual size_t getBytesRead() const override final
Definition: TBranchAuxDynReader.h:92
TBranchAuxDynReader::m_tree
TTree * m_tree
Definition: TBranchAuxDynReader.h:75
AuxStoreInternal.h
An auxiliary data store that holds data internally.
TBranchAuxDynReader::m_auxids
SG::auxid_set_t m_auxids
Definition: TBranchAuxDynReader.h:65