g4tools  5.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::wroot::tree Class Reference
Inheritance diagram for tools::wroot::tree:
Inheritance graph
[legend]
Collaboration diagram for tools::wroot::tree:
Collaboration graph
[legend]

Public Member Functions

virtual const std::string & name () const
 
virtual const std::string & title () const
 
virtual const std::string & store_class_name () const
 
virtual bool stream (buffer &a_buffer) const
 
virtual idirdir ()
 
virtual const idirdir () const
 
 tree (idir &a_dir, const std::string &a_name, const std::string &a_title, bool a_managed=true)
 
virtual ~tree ()
 
std::ostream & out () const
 
const std::vector< branch * > & branches () const
 
uint64 entries () const
 
branchcreate_branch (const std::string &a_name)
 
template<class TYPE >
leaf_ref< TYPE > * create_leaf_ref (const std::string &a_name, const TYPE &a_ref)
 ref : ////////////////////////////////////// More...
 
leaf_string_refcreate_leaf_string_ref (const std::string &a_name, const std::string &a_ref)
 
template<class T >
leaf_elementcreate_std_vector_leaf_ref (const std::string &a_name, const std::vector< T > &a_ref)
 
template<class T >
std_vector_be_ref< T > * create_std_vector_be_ref (const std::string &a_name, const std::vector< T > &a_ref)
 
template<class T >
std_vector_be< T > * create_std_vector_be (const std::string &a_name, const std::vector< T > &a_def=std::vector< T >())
 
template<class T >
std_vector_be_pointer< T > * create_std_vector_be_pointer (const std::string &a_name, std::vector< T > *a_pointer)
 
template<class TYPE >
leaf< TYPE > * create_leaf (const std::string &a_name)
 
leaf_objectcreate_leaf (const std::string &a_name, const iobject &a_obj)
 
bool fill (uint32 &a_nbytes)
 
void reset ()
 
- Public Member Functions inherited from tools::wroot::iobject
virtual ~iobject ()
 
- Public Member Functions inherited from tools::wroot::itree
virtual ~itree ()
 

Protected Member Functions

 tree (const tree &a_from)
 
treeoperator= (const tree &)
 

Protected Attributes

idirm_dir
 
std::ostream & m_out
 
std::string m_name
 
std::string m_title
 
obj_array< branchm_branches
 
uint64 m_entries
 
uint64 m_tot_bytes
 
uint64 m_zip_bytes
 

Detailed Description

Definition at line 17 of file tree.

Constructor & Destructor Documentation

◆ tree() [1/2]

tools::wroot::tree::tree ( idir a_dir,
const std::string &  a_name,
const std::string &  a_title,
bool  a_managed = true 
)
inline

Definition at line 86 of file tree.

87  :m_dir(a_dir)
88  ,m_out(a_dir.file().out())
89  ,m_name(a_name)
90  ,m_title(a_title)
91  ,m_entries(0)
92  ,m_tot_bytes(0)
93  ,m_zip_bytes(0)
94  {
95 #ifdef TOOLS_MEM
96  mem::increment(s_class().c_str());
97 #endif
98  if(a_managed) a_dir.append_object(this); //a_dir takes ownership of tree.
99  }

◆ ~tree()

virtual tools::wroot::tree::~tree ( )
inlinevirtual

Definition at line 100 of file tree.

100  {
101 #ifdef TOOLS_MEM
102  mem::decrement(s_class().c_str());
103 #endif
104  }

◆ tree() [2/2]

tools::wroot::tree::tree ( const tree a_from)
inlineprotected

Definition at line 106 of file tree.

107  :iobject(a_from),itree(a_from)
108  ,m_dir(a_from.m_dir)
109  ,m_out(a_from.m_out)
110  {}

Member Function Documentation

◆ branches()

const std::vector<branch*>& tools::wroot::tree::branches ( ) const
inline

Definition at line 114 of file tree.

114 {return m_branches;}

◆ create_branch()

branch* tools::wroot::tree::create_branch ( const std::string &  a_name)
inline

Definition at line 119 of file tree.

119  {
120  const ifile& _file = m_dir.file();
121  branch* br = new branch(m_out,_file.byte_swap(),_file.compression(),
122  m_dir.seek_directory(),a_name,m_name,_file.verbose());
123  if(!br) return 0;
124  m_branches.push_back(br);
125  return br;
126  }

◆ create_leaf() [1/2]

template<class TYPE >
leaf<TYPE>* tools::wroot::tree::create_leaf ( const std::string &  a_name)
inline

Definition at line 184 of file tree.

184  {
185  branch* br = create_branch(a_name);
186  if(!br) return 0;
187  return br->create_leaf<TYPE>(a_name);
188  }

◆ create_leaf() [2/2]

leaf_object* tools::wroot::tree::create_leaf ( const std::string &  a_name,
const iobject a_obj 
)
inline

Definition at line 190 of file tree.

190  {
191  const ifile& _file = m_dir.file();
192  branch_object* br = new branch_object(m_out,_file.byte_swap(),_file.compression(),
193  m_dir.seek_directory(),a_name,m_name,_file.verbose());
194  m_branches.push_back(br);
195  return br->create_leaf(a_name,a_obj);
196  }

◆ create_leaf_ref()

template<class TYPE >
leaf_ref<TYPE>* tools::wroot::tree::create_leaf_ref ( const std::string &  a_name,
const TYPE &  a_ref 
)
inline

ref : //////////////////////////////////////

Definition at line 132 of file tree.

132  {
133  branch* br = create_branch(a_name);
134  if(!br) return 0;
135  return br->create_leaf_ref<TYPE>(a_name,a_ref);
136  }

◆ create_leaf_string_ref()

leaf_string_ref* tools::wroot::tree::create_leaf_string_ref ( const std::string &  a_name,
const std::string &  a_ref 
)
inline

Definition at line 138 of file tree.

138  {
139  branch* br = create_branch(a_name);
140  if(!br) return 0;
141  return br->create_leaf_string_ref(a_name,a_ref);
142  }

◆ create_std_vector_be()

template<class T >
std_vector_be<T>* tools::wroot::tree::create_std_vector_be ( const std::string &  a_name,
const std::vector< T > &  a_def = std::vector<T>() 
)
inline

Definition at line 166 of file tree.

166  {
167  const ifile& _file = m_dir.file();
168  std_vector_be<T>* br = new std_vector_be<T>(m_out,_file.byte_swap(),_file.compression(),
169  m_dir.seek_directory(),a_name,m_name,a_def,_file.verbose());
170  m_branches.push_back(br);
171  return br;
172  }

◆ create_std_vector_be_pointer()

template<class T >
std_vector_be_pointer<T>* tools::wroot::tree::create_std_vector_be_pointer ( const std::string &  a_name,
std::vector< T > *  a_pointer 
)
inline

Definition at line 175 of file tree.

175  {
176  const ifile& _file = m_dir.file();
177  std_vector_be_pointer<T>* br = new std_vector_be_pointer<T>(m_out,_file.byte_swap(),_file.compression(),
178  m_dir.seek_directory(),a_name,m_name,a_pointer,_file.verbose());
179  m_branches.push_back(br);
180  return br;
181  }

◆ create_std_vector_be_ref()

template<class T >
std_vector_be_ref<T>* tools::wroot::tree::create_std_vector_be_ref ( const std::string &  a_name,
const std::vector< T > &  a_ref 
)
inline

Definition at line 157 of file tree.

157  {
158  const ifile& _file = m_dir.file();
159  std_vector_be_ref<T>* br = new std_vector_be_ref<T>(m_out,_file.byte_swap(),_file.compression(),
160  m_dir.seek_directory(),a_name,m_name,a_ref,_file.verbose());
161  m_branches.push_back(br);
162  return br;
163  }

◆ create_std_vector_leaf_ref()

template<class T >
leaf_element* tools::wroot::tree::create_std_vector_leaf_ref ( const std::string &  a_name,
const std::vector< T > &  a_ref 
)
inline

Definition at line 145 of file tree.

145  {
146  const ifile& _file = m_dir.file();
147  std_vector_be_ref<T>* br = new std_vector_be_ref<T>(m_out,_file.byte_swap(),_file.compression(),
148  m_dir.seek_directory(),a_name,m_name,a_ref,_file.verbose());
149  leaf_element* le = br->create_leaf_element(a_name);
150  m_branches.push_back(br);
151  return le;
152  }

◆ dir() [1/2]

virtual idir& tools::wroot::tree::dir ( )
inlinevirtual

Implements tools::wroot::itree.

Definition at line 83 of file tree.

83 {return m_dir;}

◆ dir() [2/2]

virtual const idir& tools::wroot::tree::dir ( ) const
inlinevirtual

Implements tools::wroot::itree.

Definition at line 84 of file tree.

84 {return m_dir;}

◆ entries()

uint64 tools::wroot::tree::entries ( ) const
inline

Definition at line 117 of file tree.

117 {return m_entries;}

◆ fill()

bool tools::wroot::tree::fill ( uint32 a_nbytes)
inline

Definition at line 198 of file tree.

198  {
199  // Fill all branches of a Tree :
200  // This function loops on all the branches of this tree.
201  // For each branch, it copies to the branch buffer (basket) the current
202  // values of the leaves data types.
203  // If a leaf is a simple data type, a simple conversion to a machine
204  // independent format has to be done.
205  a_nbytes = 0;
206  tools_vforcit(branch*,m_branches,it) {
207  //FIXME if ((*it)->testBit(kDoNotProcess)) continue;
208  uint32 n,add_bytes,nout;
209  if(!(*it)->fill(m_dir.file(),n,add_bytes,nout)) {a_nbytes = 0;return false;}
210  a_nbytes += n;
211  m_tot_bytes += add_bytes;
212  m_zip_bytes += nout;
213  }
214 
215  m_entries++;
216 
217  //if (fTotBytes - fSavedBytes > fAutoSave) {
218  // if(!autoSave()) return false;
219  //}
220 
221  return true;
222  }

◆ name()

virtual const std::string& tools::wroot::tree::name ( ) const
inlinevirtual

Implements tools::wroot::iobject.

Definition at line 25 of file tree.

25 {return m_name;}

◆ operator=()

tree& tools::wroot::tree::operator= ( const tree )
inlineprotected

Definition at line 111 of file tree.

111 {return *this;}

◆ out()

std::ostream& tools::wroot::tree::out ( ) const
inline

Definition at line 113 of file tree.

113 {return m_out;}

◆ reset()

void tools::wroot::tree::reset ( )
inline

Definition at line 224 of file tree.

224  {
225  // Reset buffers and entries count in all branches/leaves
226  m_entries = 0;
227  m_tot_bytes = 0;
228  m_zip_bytes = 0;
229  //fSavedBytes = 0;
230  //fTotalBuffers = 0;
231  //fChainOffset = 0;
232  {tools_vforcit(branch*,m_branches,it) (*it)->reset();}
233  }

◆ store_class_name()

virtual const std::string& tools::wroot::tree::store_class_name ( ) const
inlinevirtual

Implements tools::wroot::iobject.

Definition at line 27 of file tree.

27  {
28  static const std::string s_v("TTree");
29  return s_v;
30  }

◆ stream()

virtual bool tools::wroot::tree::stream ( buffer a_buffer) const
inlinevirtual

Implements tools::wroot::iobject.

Definition at line 31 of file tree.

31  {
32  unsigned int c;
33  if(!a_buffer.write_version(5,c)) return false;
34 
35  if(!Named_stream(a_buffer,m_name,m_title)) return false;
36 
37  // Beurk.
38  if(!AttLine_stream(a_buffer)) return false;
39  if(!AttFill_stream(a_buffer)) return false;
40  if(!AttMarker_stream(a_buffer)) return false;
41 
42  double fEntries = (double)m_entries;
43  if(!a_buffer.write(fEntries)) return false;
44 
45  double fTotBytes = (double)m_tot_bytes;
46  double fZipBytes = (double)m_zip_bytes;
47  if(!a_buffer.write(fTotBytes)) return false;
48  if(!a_buffer.write(fZipBytes)) return false;
49  if(!a_buffer.write((double)0)) return false; //fSavedBytes
50  if(!a_buffer.write((int)0)) return false; //fTimerInterval
51  if(!a_buffer.write((int)25)) return false; //fScanField (25)
52  if(!a_buffer.write((int)0)) return false; //fUpdate
53  if(!a_buffer.write((int)1000000000)) return false; //fMaxEntryLoop
54  int fMaxVirtualSize = 0;
55  int fAutoSave = 100000000;
56  if(!a_buffer.write(fMaxVirtualSize)) return false;
57  if(!a_buffer.write(fAutoSave)) return false;
58  if(!a_buffer.write((int)1000000)) return false; //fEstimate;
59 
60  if(!m_branches.stream(a_buffer)) return false;
61 
62  {obj_array<base_leaf> m_leaves;
63  tools_vforcit(branch*,m_branches,itb) {
64  const std::vector<base_leaf*>& leaves = (*itb)->leaves();
65  tools_vforcit(base_leaf*,leaves,itl) {
66  m_leaves.push_back(*itl); //WARNING : ownership touchy.
67  }
68  }
69  if(!m_leaves.stream(a_buffer)) return false;
70  m_leaves.clear();} //WARNING : important.
71 
72  // fIndexValues (TArrayD).
73  if(!a_buffer.write_array(std::vector<double>())) return false; //TArrayD
74  // fIndex (TArrayI).
75  if(!a_buffer.write_array(std::vector<int>())) return false; //TArrayI
76 
77  if(!a_buffer.set_byte_count(c)) return false;
78  return true;
79  }

◆ title()

virtual const std::string& tools::wroot::tree::title ( ) const
inlinevirtual

Implements tools::wroot::iobject.

Definition at line 26 of file tree.

26 {return m_title;}

Member Data Documentation

◆ m_branches

obj_array<branch> tools::wroot::tree::m_branches
protected

Definition at line 241 of file tree.

◆ m_dir

idir& tools::wroot::tree::m_dir
protected

Definition at line 235 of file tree.

◆ m_entries

uint64 tools::wroot::tree::m_entries
protected

Definition at line 242 of file tree.

◆ m_name

std::string tools::wroot::tree::m_name
protected

Definition at line 238 of file tree.

◆ m_out

std::ostream& tools::wroot::tree::m_out
protected

Definition at line 236 of file tree.

◆ m_title

std::string tools::wroot::tree::m_title
protected

Definition at line 239 of file tree.

◆ m_tot_bytes

uint64 tools::wroot::tree::m_tot_bytes
protected

Definition at line 243 of file tree.

◆ m_zip_bytes

uint64 tools::wroot::tree::m_zip_bytes
protected

Definition at line 244 of file tree.


The documentation for this class was generated from the following file:
tools::wroot::tree::m_title
std::string m_title
Definition: tree:239
tools::wroot::tree::m_dir
idir & m_dir
Definition: tree:235
tools::wroot::tree::create_branch
branch * create_branch(const std::string &a_name)
Definition: tree:119
tools::wroot::tree::m_tot_bytes
uint64 m_tot_bytes
Definition: tree:243
tools::wroot::idir::file
virtual ifile & file()=0
tools::wroot::tree::m_out
std::ostream & m_out
Definition: tree:236
tools::wroot::Named_stream
bool Named_stream(buffer &a_buffer, const std::string &a_name, const std::string &a_title)
Definition: named:23
tools::wroot::idir::seek_directory
virtual seek seek_directory() const =0
tools::wroot::tree::m_zip_bytes
uint64 m_zip_bytes
Definition: tree:244
tools::wroot::tree::m_name
std::string m_name
Definition: tree:238
tools::wroot::tree::m_entries
uint64 m_entries
Definition: tree:242
tools::wroot::AttFill_stream
bool AttFill_stream(buffer &a_buffer)
Definition: named:137
tools::wroot::AttLine_stream
bool AttLine_stream(buffer &a_buffer)
Definition: named:124
tools::wroot::AttMarker_stream
bool AttMarker_stream(buffer &a_buffer)
Definition: named:148
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::wroot::tree::m_branches
obj_array< branch > m_branches
Definition: tree:241