Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBranch.cxx
Go to the documentation of this file.
1// @(#)root/tree:$Id$
2// Author: Rene Brun 12/01/96
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TBranchCacheInfo.h"
13
14#include "TBranch.h"
15
16#include "Bytes.h"
17#include "Compression.h"
18#include "TBasket.h"
19#include "TBranchBrowsable.h"
20#include "TBrowser.h"
21#include "TBuffer.h"
22#include "TClass.h"
23#include "TBufferFile.h"
24#include "TClonesArray.h"
25#include "TFile.h"
26#include "TLeaf.h"
27#include "TLeafB.h"
28#include "TLeafC.h"
29#include "TLeafD.h"
30#include "TLeafD32.h"
31#include "TLeafF.h"
32#include "TLeafF16.h"
33#include "TLeafI.h"
34#include "TLeafL.h"
35#include "TLeafG.h"
36#include "TLeafO.h"
37#include "TLeafObject.h"
38#include "TLeafS.h"
39#include "TMessage.h"
40#include "TROOT.h"
41#include "TSystem.h"
42#include "TMath.h"
43#include "TTree.h"
44#include "TTreeCache.h"
45#include "TTreeCacheUnzip.h"
46#include "TVirtualMutex.h"
47#include "TVirtualPad.h"
48#include "TVirtualPerfStats.h"
49#include "strlcpy.h"
50#include "snprintf.h"
51
52#include "TBranchIMTHelper.h"
53
54#include "ROOT/TIOFeatures.hxx"
55
56#include <atomic>
57#include <cstddef>
58#include <cstring>
59#include <cstdio>
60
61
63
64/** \class TBranch
65\ingroup tree
66
67A TTree is a list of TBranches
68
69A TBranch supports:
70 - The list of TLeaf describing this branch.
71 - The list of TBasket (branch buffers).
72
73See TBranch structure in TTree.
74
75See also specialized branches:
76 - TBranchObject in case the branch is one object
77 - TBranchClones in case the branch is an array of clone objects
78*/
79
81
82
83
84////////////////////////////////////////////////////////////////////////////////
85/// Default constructor. Used for I/O by default.
86
88: TNamed()
89, TAttFill(0, 1001)
90, fCompress(0)
91, fBasketSize(32000)
92, fEntryOffsetLen(1000)
93, fWriteBasket(0)
94, fEntryNumber(0)
95, fExtraBasket(nullptr)
96, fOffset(0)
97, fMaxBaskets(10)
98, fNBaskets(0)
99, fSplitLevel(0)
100, fNleaves(0)
101, fReadBasket(0)
102, fReadEntry(-1)
103, fFirstBasketEntry(-1)
104, fNextBasketEntry(-1)
105, fCurrentBasket(0)
106, fEntries(0)
107, fFirstEntry(0)
108, fTotBytes(0)
109, fZipBytes(0)
110, fBranches()
111, fLeaves()
112, fBaskets(fMaxBaskets)
113, fBasketBytes(0)
114, fBasketEntry(0)
115, fBasketSeek(0)
116, fTree(0)
117, fMother(0)
118, fParent(0)
119, fAddress(0)
120, fDirectory(0)
121, fFileName("")
122, fEntryBuffer(0)
123, fTransientBuffer(0)
124, fBrowsables(0)
125, fBulk(*this)
126, fSkipZip(kFALSE)
127, fReadLeaves(&TBranch::ReadLeavesImpl)
128, fFillLeaves(&TBranch::FillLeavesImpl)
129{
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// Create a Branch as a child of a Tree
135///
136/// * address is the address of the first item of a structure
137/// or the address of a pointer to an object (see example in TTree.cxx).
138/// * leaflist is the concatenation of all the variable names and types
139/// separated by a colon character :
140/// The variable name and the variable type are separated by a
141/// slash (/). The variable type must be 1 character. (Characters
142/// after the first are legal and will be appended to the visible
143/// name of the leaf, but have no effect.) If no type is given, the
144/// type of the variable is assumed to be the same as the previous
145/// variable. If the first variable does not have a type, it is
146/// assumed of type F by default. The list of currently supported
147/// types is given below:
148/// - `C` : a character string terminated by the 0 character
149/// - `B` : an 8 bit signed integer (`Char_t`)
150/// - `b` : an 8 bit unsigned integer (`UChar_t`)
151/// - `S` : a 16 bit signed integer (`Short_t`)
152/// - `s` : a 16 bit unsigned integer (`UShort_t`)
153/// - `I` : a 32 bit signed integer (`Int_t`)
154/// - `i` : a 32 bit unsigned integer (`UInt_t`)
155/// - `F` : a 32 bit floating point (`Float_t`)
156/// - `f` : a 24 bit floating point with truncated mantissa (`Float16_t`)
157/// - `D` : a 64 bit floating point (`Double_t`)
158/// - `d` : a 24 bit truncated floating point (`Double32_t`)
159/// - `L` : a 64 bit signed integer (`Long64_t`)
160/// - `l` : a 64 bit unsigned integer (`ULong64_t`)
161/// - `G` : a long signed integer (`Long_t`, which `sizeof` is platform dependent), stored as a 64 bit integer but usually held in memory as a 64 bit integer on 64 bit machines and 32 bit on 32 bit machines. Due to this difference, this data type is **not cross-platform**.
162/// - `g` : a long unsigned integer (`ULong_t`, which `sizeof` is platform dependent), stored as a 64 bit unsigned integer but held in memory usually as a 64 bit integer on 64 bit machines and 32 bit on 32 bit machines. Due to this difference, this data type is **not cross-platform**.
163/// - `O` : [the letter `o`, not a zero] a boolean (`Bool_t`)
164///
165/// Arrays of values are supported with the following syntax:
166/// - If leaf name has the form var[nelem], where nelem is alphanumeric, then
167/// if nelem is a leaf name, it is used as the variable size of the array,
168/// otherwise return 0.
169/// The leaf referred to by nelem **MUST** be an int (/I),
170/// - If leaf name has the form var[nelem], where nelem is a non-negative integers, then
171/// it is used as the fixed size of the array.
172/// - If leaf name has the form of a multi dimension array (e.g. var[nelem][nelem2])
173/// where nelem and nelem2 are non-negative integers) then
174/// it is used as a 2 dimensional array of fixed size.
175/// - In case of the truncated floating point types (Float16_t and Double32_t) you can
176/// furthermore specify the range in the style [xmin,xmax] or [xmin,xmax,nbits] after
177/// the type character. See `TStreamerElement::GetRange()` for further information.
178/// - Any of other form is not supported.
179///
180/// Note that the TTree will assume that all the item are contiguous in memory.
181/// On some platform, this is not always true of the member of a struct or a class,
182/// due to padding and alignment. Sorting your data member in order of decreasing
183/// sizeof usually leads to their being contiguous in memory.
184///
185/// * bufsize is the buffer size in bytes for this branch
186/// The default value is 32000 bytes and should be ok for most cases.
187/// You can specify a larger value (e.g. 256000) if your Tree is not split
188/// and each entry is large (Megabytes)
189/// A small value for bufsize is optimum if you intend to access
190/// the entries in the Tree randomly and your Tree is in split mode.
191///
192/// See an example of a Branch definition in the TTree constructor.
193///
194/// Note that in case the data type is an object, this branch can contain
195/// only this object.
196///
197/// Note that this function is invoked by TTree::Branch
198
199TBranch::TBranch(TTree *tree, const char *name, void *address, const char *leaflist, Int_t basketsize, Int_t compress)
200 : TNamed(name, leaflist)
201, TAttFill(0, 1001)
202, fCompress(compress)
203, fBasketSize((basketsize < 100) ? 100 : basketsize)
204, fEntryOffsetLen(0)
205, fWriteBasket(0)
206, fEntryNumber(0)
207, fExtraBasket(nullptr)
208, fIOFeatures(tree ? tree->GetIOFeatures().GetFeatures() : 0)
209, fOffset(0)
210, fMaxBaskets(10)
211, fNBaskets(0)
212, fSplitLevel(0)
213, fNleaves(0)
214, fReadBasket(0)
215, fReadEntry(-1)
216, fFirstBasketEntry(-1)
217, fNextBasketEntry(-1)
218, fCurrentBasket(0)
219, fEntries(0)
220, fFirstEntry(0)
221, fTotBytes(0)
222, fZipBytes(0)
223, fBranches()
224, fLeaves()
225, fBaskets(fMaxBaskets)
226, fBasketBytes(0)
227, fBasketEntry(0)
228, fBasketSeek(0)
229, fTree(tree)
230, fMother(0)
231, fParent(0)
232, fAddress((char *)address)
233, fDirectory(fTree->GetDirectory())
234, fFileName("")
235, fEntryBuffer(0)
236, fTransientBuffer(0)
237, fBrowsables(0)
238, fBulk(*this)
239, fSkipZip(kFALSE)
240, fReadLeaves(&TBranch::ReadLeavesImpl)
241, fFillLeaves(&TBranch::FillLeavesImpl)
242{
243 Init(name,leaflist,compress);
244}
245
246////////////////////////////////////////////////////////////////////////////////
247/// Create a Branch as a child of another Branch
248///
249/// See documentation for
250/// TBranch::TBranch(TTree *, const char *, void *, const char *, Int_t, Int_t)
251
252TBranch::TBranch(TBranch *parent, const char *name, void *address, const char *leaflist, Int_t basketsize,
253 Int_t compress)
254: TNamed(name, leaflist)
255, TAttFill(0, 1001)
256, fCompress(compress)
257, fBasketSize((basketsize < 100) ? 100 : basketsize)
258, fEntryOffsetLen(0)
259, fWriteBasket(0)
260, fEntryNumber(0)
261, fExtraBasket(nullptr)
262, fIOFeatures(parent->fIOFeatures)
263, fOffset(0)
264, fMaxBaskets(10)
265, fNBaskets(0)
266, fSplitLevel(0)
267, fNleaves(0)
268, fReadBasket(0)
269, fReadEntry(-1)
270, fFirstBasketEntry(-1)
271, fNextBasketEntry(-1)
272, fCurrentBasket(0)
273, fEntries(0)
274, fFirstEntry(0)
275, fTotBytes(0)
276, fZipBytes(0)
277, fBranches()
278, fLeaves()
279, fBaskets(fMaxBaskets)
280, fBasketBytes(0)
281, fBasketEntry(0)
282, fBasketSeek(0)
283, fTree(parent ? parent->GetTree() : 0)
284, fMother(parent ? parent->GetMother() : 0)
285, fParent(parent)
286, fAddress((char *)address)
287, fDirectory(fTree ? fTree->GetDirectory() : 0)
288, fFileName("")
289, fEntryBuffer(0)
290, fTransientBuffer(0)
291, fBrowsables(0)
292, fBulk(*this)
293, fSkipZip(kFALSE)
294, fReadLeaves(&TBranch::ReadLeavesImpl)
295, fFillLeaves(&TBranch::FillLeavesImpl)
296{
297 Init(name,leaflist,compress);
298}
299
300void TBranch::Init(const char* name, const char* leaflist, Int_t compress)
301{
302 // Initialization routine called from the constructor. This should NOT be made virtual.
303
305 if ((compress == -1) && fTree->GetDirectory()) {
306 TFile* bfile = fTree->GetDirectory()->GetFile();
307 if (bfile) {
309 }
310 }
311
315
316 for (Int_t i = 0; i < fMaxBaskets; ++i) {
317 fBasketBytes[i] = 0;
318 fBasketEntry[i] = 0;
319 fBasketSeek[i] = 0;
320 }
321
322 //
323 // Decode the leaflist (search for : as separator).
324 //
325
326 char* nameBegin = const_cast<char*>(leaflist);
327 Int_t offset = 0;
328 auto len = strlen(leaflist);
329 // FIXME: Make these string streams instead.
330 char* leafname = new char[len + 1];
331 char* leaftype = new char[320];
332 // Note: The default leaf type is a float.
333 strlcpy(leaftype, "F",320);
334 char* pos = const_cast<char*>(leaflist);
335 const char* leaflistEnd = leaflist + len;
336 for (; pos <= leaflistEnd; ++pos) {
337 // -- Scan leaf specification and create leaves.
338 if ((*pos == ':') || (*pos == 0)) {
339 // -- Reached end of a leaf spec, create a leaf.
340 Int_t lenName = pos - nameBegin;
341 char* ctype = 0;
342 if (lenName) {
343 strncpy(leafname, nameBegin, lenName);
344 leafname[lenName] = 0;
345 ctype = strstr(leafname, "/");
346 if (ctype) {
347 *ctype = 0;
348 strlcpy(leaftype, ctype + 1,320);
349 }
350 }
351 if (lenName == 0 || ctype == leafname) {
352 Warning("TBranch","No name was given to the leaf number '%d' in the leaflist of the branch '%s'.",fNleaves,name);
353 snprintf(leafname, len + 1, "__noname%d", fNleaves);
354 }
355 TLeaf* leaf = 0;
356 if (leaftype[1] == '[' && !strchr(leaftype, ',')) {
357 Warning("TBranch", "Array size for branch '%s' must be specified after leaf name, not after the type name!", name);
358 // and continue for backward compatibility?
359 } else if (leaftype[1] && !strchr(leaftype, ',')) {
360 Warning("TBranch", "Extra characters after type tag '%s' for branch '%s'; must be one character.", leaftype, name);
361 // and continue for backward compatibility?
362 }
363 if (*leaftype == 'C') {
364 leaf = new TLeafC(this, leafname, leaftype);
365 } else if (*leaftype == 'O') {
366 leaf = new TLeafO(this, leafname, leaftype);
367 } else if (*leaftype == 'B') {
368 leaf = new TLeafB(this, leafname, leaftype);
369 } else if (*leaftype == 'b') {
370 leaf = new TLeafB(this, leafname, leaftype);
371 leaf->SetUnsigned();
372 } else if (*leaftype == 'S') {
373 leaf = new TLeafS(this, leafname, leaftype);
374 } else if (*leaftype == 's') {
375 leaf = new TLeafS(this, leafname, leaftype);
376 leaf->SetUnsigned();
377 } else if (*leaftype == 'I') {
378 leaf = new TLeafI(this, leafname, leaftype);
379 } else if (*leaftype == 'i') {
380 leaf = new TLeafI(this, leafname, leaftype);
381 leaf->SetUnsigned();
382 } else if (*leaftype == 'F') {
383 leaf = new TLeafF(this, leafname, leaftype);
384 } else if (*leaftype == 'f') {
385 leaf = new TLeafF16(this, leafname, leaftype);
386 } else if (*leaftype == 'L') {
387 leaf = new TLeafL(this, leafname, leaftype);
388 } else if (*leaftype == 'l') {
389 leaf = new TLeafL(this, leafname, leaftype);
390 leaf->SetUnsigned();
391 } else if (*leaftype == 'D') {
392 leaf = new TLeafD(this, leafname, leaftype);
393 } else if (*leaftype == 'd') {
394 leaf = new TLeafD32(this, leafname, leaftype);
395 } else if (*leaftype == 'G') {
396 leaf = new TLeafG(this, leafname, leaftype);
397 } else if (*leaftype == 'g') {
398 leaf = new TLeafG(this, leafname, leaftype);
399 leaf->SetUnsigned();
400 }
401 if (!leaf) {
402 Error("TLeaf", "Illegal data type for %s/%s", name, leaflist);
403 delete[] leaftype;
404 delete [] leafname;
405 MakeZombie();
406 return;
407 }
408 if (leaf->IsZombie()) {
409 delete leaf;
410 leaf = 0;
411 auto msg = "Illegal leaf: %s/%s. If this is a variable size C array it's possible that the branch holding the size is not available.";
412 Error("TBranch", msg, name, leaflist);
413 delete [] leafname;
414 delete[] leaftype;
415 MakeZombie();
416 return;
417 }
418 leaf->SetBranch(this);
419 leaf->SetAddress((char*) (fAddress + offset));
420 leaf->SetOffset(offset);
421 if (leaf->GetLeafCount()) {
422 // -- Leaf is a varying length array, we need an offset array.
423 fEntryOffsetLen = 1000;
424 }
425 if (leaf->InheritsFrom(TLeafC::Class())) {
426 // -- Leaf is a character string, we need an offset array.
427 fEntryOffsetLen = 1000;
428 }
429 ++fNleaves;
430 fLeaves.Add(leaf);
431 fTree->GetListOfLeaves()->Add(leaf);
432 if (*pos == 0) {
433 // -- We reached the end of the leaf specification.
434 break;
435 }
436 nameBegin = pos + 1;
437 offset += leaf->GetLenType() * leaf->GetLen();
438 }
439 }
440 delete[] leafname;
441 leafname = 0;
442 delete[] leaftype;
443 leaftype = 0;
444
445}
446
447////////////////////////////////////////////////////////////////////////////////
448/// Destructor.
449
451{
452 delete fBrowsables;
453 fBrowsables = 0;
454
455 // Note: We do *not* have ownership of the buffer.
456 fEntryBuffer = 0;
457
458 delete [] fBasketSeek;
459 fBasketSeek = 0;
460
461 delete [] fBasketEntry;
462 fBasketEntry = 0;
463
464 delete [] fBasketBytes;
465 fBasketBytes = 0;
466
468 delete fExtraBasket;
470 fNBaskets = 0;
471 fCurrentBasket = 0;
473 fNextBasketEntry = -1;
474
475 // Remove our leaves from our tree's list of leaves.
476 if (fTree) {
478 if (lst && lst->GetLast()!=-1) {
479 lst->RemoveAll(&fLeaves);
480 }
481 }
482 // And delete our leaves.
483 fLeaves.Delete();
484
486
487 // If we are in a directory and that directory is not the same
488 // directory that our tree is in, then try to find an open file
489 // with the name fFileName. If we find one, delete that file.
490 // We are attempting to close any alternate file which we have
491 // been directed to write our baskets to.
492 // FIXME: We make no attempt to check if someone else might be
493 // using this file. This is very user hostile. A violation
494 // of the principle of least surprises.
495 //
496 // Warning. Must use FindObject by name instead of fDirectory->GetFile()
497 // because two branches may point to the same file and the file
498 // may have already been deleted in the previous branch.
499 if (fDirectory && (!fTree || fDirectory != fTree->GetDirectory())) {
500 TString bFileName( GetRealFileName() );
501
503 TFile* file = (TFile*)gROOT->GetListOfFiles()->FindObject(bFileName);
504 if (file){
505 file->Close();
506 delete file;
507 file = 0;
508 }
509 }
510
511 fTree = 0;
512 fDirectory = 0;
513
514 if (fTransientBuffer) {
515 delete fTransientBuffer;
517 }
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// Returns the transient buffer currently used by this TBranch for reading/writing baskets.
522
524{
525 if (fTransientBuffer) {
528 }
529 return fTransientBuffer;
530 }
532 return fTransientBuffer;
533}
534
535////////////////////////////////////////////////////////////////////////////////
536/// Add the basket to this branch.
537///
538/// Warning: if the basket are not 'flushed/copied' in the same
539/// order as they were created, this will induce a slow down in
540/// the insert (since we'll need to move all the record that are
541/// entere 'too early').
542/// Warning we also assume that the __current__ write basket is
543/// not present (aka has been removed) or is empty (no entries).
544
545void TBranch::AddBasket(TBasket& b, Bool_t ondisk, Long64_t startEntry)
546{
547 TBasket *basket = &b;
548
549 basket->SetBranch(this);
550
551 if (fWriteBasket >= fMaxBaskets) {
553 }
554 Int_t where = fWriteBasket;
555
556 if (where && startEntry < fBasketEntry[where-1]) {
557 // Need to find the right location and move the possible baskets
558
559 if (!ondisk) {
560 Warning("AddBasket","The assumption that out-of-order basket only comes from disk based ntuple is false.");
561 }
562
563 if (startEntry < fBasketEntry[0]) {
564 where = 0;
565 } else {
566 for(Int_t i=fWriteBasket-1; i>=0; --i) {
567 if (fBasketEntry[i] < startEntry) {
568 where = i+1;
569 break;
570 } else if (fBasketEntry[i] == startEntry) {
571 Error("AddBasket","An out-of-order basket matches the entry number of an existing basket.");
572 }
573 }
574 }
575
576 if (where < fWriteBasket) {
577 // We shall move the content of the array
578 for (Int_t j=fWriteBasket; j > where; --j) {
579 fBasketEntry[j] = fBasketEntry[j-1];
580 fBasketBytes[j] = fBasketBytes[j-1];
581 fBasketSeek[j] = fBasketSeek[j-1];
582 }
583 }
584 }
585 fBasketEntry[where] = startEntry;
586
587 TBasket *existing = (TBasket*)fBaskets.At(fWriteBasket);
588 if (existing && existing->GetNevBuf()) {
589 Fatal("AddBasket", "Dropping non-empty 'write' basket in %s %s",
590 GetTree()->GetName(), GetName());
591 }
592 delete existing;
593 if (ondisk) {
594 fBasketBytes[where] = basket->GetNbytes(); // not for in mem
595 fBasketSeek[where] = basket->GetSeekKey(); // not for in mem
597 ++fWriteBasket;
598 } else {
599 ++fNBaskets;
600 // The basket we are adding becomes the new 'write' basket.
603 }
604
605 fEntries += basket->GetNevBuf();
606 fEntryNumber += basket->GetNevBuf();
607 if (ondisk) {
608 fTotBytes += basket->GetObjlen() + basket->GetKeylen() ;
609 fZipBytes += basket->GetNbytes();
610 fTree->AddTotBytes(basket->GetObjlen() + basket->GetKeylen());
611 fTree->AddZipBytes(basket->GetNbytes());
612 }
613}
614
615////////////////////////////////////////////////////////////////////////////////
616/// Add the start entry of the write basket (not yet created)
617
619{
620 if (fWriteBasket >= fMaxBaskets) {
622 }
623 Int_t where = fWriteBasket;
624
625 if (where && startEntry < fBasketEntry[where-1]) {
626 // Need to find the right location and move the possible baskets
627
628 Fatal("AddBasket","The last basket must have the highest entry number (%s/%lld/%d).",GetName(),startEntry,fWriteBasket);
629
630 }
631 // The first basket (should) always start at zero. If we are asked to update
632 // it, this likely to be from merging 'empty' branches (base class node and the likes)
633 if (where) {
634 fBasketEntry[where] = startEntry;
636 }
637}
638
639////////////////////////////////////////////////////////////////////////////////
640/// Loop on all leaves of this branch to back fill Basket buffer.
641///
642/// Use this routine instead of TBranch::Fill when filling a branch individually
643/// to catch up with the number of entries already in the TTree.
644///
645/// First it calls TBranch::Fill and then if the number of entries of the branch
646/// reach one of TTree cluster's boundary, the basket is flushed.
647///
648/// The function returns the number of bytes committed to the memory basket.
649/// If a write error occurs, the number of bytes returned is -1.
650/// If no data are written, because e.g. the branch is disabled,
651/// the number of bytes returned is 0.
652///
653/// To insure that the baskets of each cluster are located close by in the
654/// file, when back-filling multiple branches make sure to call BackFill
655/// for the same entry for all the branches consecutively
656/// ~~~ {.cpp}
657/// for( auto e = 0; e < tree->GetEntries(); ++e ) { // loop over entries.
658/// for( auto branch : branchCollection) {
659/// ... Make change to the data associated with the branch ...
660/// branch->BackFill();
661/// }
662/// }
663/// // Since we loop over all the branches for each new entry
664/// // all the baskets for a cluster are consecutive in the file.
665/// ~~~
666/// rather than doing all the entries of one branch at a time.
667/// ~~~ {.cpp}
668/// // Do NOT do things in the following order, it will lead to
669/// // poorly clustered files.
670/// for(auto branch : branchCollection) {
671/// for( auto e = 0; e < tree->GetEntries(); ++e ) { // loop over entries.
672/// ... Make change to the data associated with the branch ...
673/// branch->BackFill();
674/// }
675/// }
676/// // Since we loop over all the entries for one branch
677/// // all the baskets for that branch are consecutive.
678/// ~~~
679
681
682 // Get the end of the next cluster.
683 auto cluster = GetTree()->GetClusterIterator( GetEntries() );
684 cluster.Next();
685 auto endCluster = cluster.GetNextEntry();
686
687 auto result = FillImpl(nullptr);
688
689 if ( result && GetEntries() >= endCluster ) {
690 FlushBaskets();
691 }
692
693 return result;
694}
695
696////////////////////////////////////////////////////////////////////////////////
697/// Browser interface.
698
700{
701 if (fNleaves > 1) {
703 } else {
704 // Get the name and strip any extra brackets
705 // in order to get the full arrays.
706 TString name = GetName();
707 Int_t pos = name.First('[');
708 if (pos!=kNPOS) name.Remove(pos);
709
710 GetTree()->Draw(name, "", b ? b->GetDrawOption() : "");
711 if (gPad) gPad->Update();
712 }
713}
714
715 ///////////////////////////////////////////////////////////////////////////////
716 /// Loop on all branch baskets. If the file where branch buffers reside is
717 /// writable, free the disk space associated to the baskets of the branch,
718 /// then call Reset(). If the option contains "all", delete also the baskets
719 /// for the subbranches.
720 /// The branch is reset.
721 ///
722 /// NOTE that this function must be used with extreme care. Deleting branch baskets
723 /// fragments the file and may introduce inefficiencies when adding new entries
724 /// in the Tree or later on when reading the Tree.
725
727{
728 TString opt = option;
729 opt.ToLower();
730 TFile *file = GetFile(0);
731
733 for(Int_t i=0; i<fWriteBasket; i++) {
734 if (fBasketSeek[i]) file->MakeFree(fBasketSeek[i],fBasketSeek[i]+fBasketBytes[i]-1);
735 }
736 }
737
738 // process subbranches
739 if (opt.Contains("all")) {
741 Int_t nb = lb->GetEntriesFast();
742 for (Int_t j = 0; j < nb; j++) {
743 TBranch* branch = (TBranch*) lb->UncheckedAt(j);
744 if (branch) branch->DeleteBaskets("all");
745 }
746 }
747 DropBaskets("all");
748 Reset();
749}
750
751////////////////////////////////////////////////////////////////////////////////
752/// Loop on all branch baskets. Drop all baskets from memory except readbasket.
753/// If the option contains "all", drop all baskets including
754/// read- and write-baskets (unless they are not stored individually on disk).
755/// The option "all" also lead to DropBaskets being called on the sub-branches.
756
758{
759 Bool_t all = kFALSE;
760 if (options && options[0]) {
761 TString opt = options;
762 opt.ToLower();
763 if (opt.Contains("all")) all = kTRUE;
764 }
765
766 TBasket *basket;
767 Int_t nbaskets = fBaskets.GetEntriesFast();
768
769 if ( (fNBaskets>1) || all ) {
770 //slow case
771 for (Int_t i=0;i<nbaskets;i++) {
772 basket = (TBasket*)fBaskets.UncheckedAt(i);
773 if (!basket) continue;
774 if ((i == fReadBasket || i == fWriteBasket) && !all) continue;
775 // if the basket is not yet on file but already has event in it
776 // we must continue to avoid dropping the basket (and thus losing data)
777 if (fBasketBytes[i]==0 && basket->GetNevBuf() > 0) continue;
778 basket->DropBuffers();
779 --fNBaskets;
781 if (basket == fCurrentBasket) {
782 fCurrentBasket = 0;
784 fNextBasketEntry = -1;
785 }
786 delete basket;
787 }
788
789 // process subbranches
790 if (all) {
792 Int_t nb = lb->GetEntriesFast();
793 for (Int_t j = 0; j < nb; j++) {
794 TBranch* branch = (TBranch*) lb->UncheckedAt(j);
795 if (!branch) continue;
796 branch->DropBaskets("all");
797 }
798 }
799 } else {
800 //fast case
801 if (nbaskets > 0) {
802 Int_t i = fBaskets.GetLast();
803 basket = (TBasket*)fBaskets.UncheckedAt(i);
804 if (basket && fBasketBytes[i]!=0) {
805 basket->DropBuffers();
806 if (basket == fCurrentBasket) {
807 fCurrentBasket = 0;
809 fNextBasketEntry = -1;
810 }
811 delete basket;
812 fBaskets.AddAt(0,i);
813 fBaskets.SetLast(-1);
814 fNBaskets = 0;
815 }
816 }
817 }
818
819}
820
821////////////////////////////////////////////////////////////////////////////////
822/// Increase BasketEntry buffer of a minimum of 10 locations
823/// and a maximum of 50 per cent of current size.
824
826{
827 Int_t newsize = TMath::Max(10,Int_t(1.5*fMaxBaskets));
830 newsize*sizeof(Long64_t),fMaxBaskets*sizeof(Long64_t));
832 newsize*sizeof(Long64_t),fMaxBaskets*sizeof(Long64_t));
833
834 fMaxBaskets = newsize;
835
836 fBaskets.Expand(newsize);
837
838 for (Int_t i=fWriteBasket;i<fMaxBaskets;i++) {
839 fBasketBytes[i] = 0;
840 fBasketEntry[i] = 0;
841 fBasketSeek[i] = 0;
842 }
843}
844
845////////////////////////////////////////////////////////////////////////////////
846/// Loop on all leaves of this branch to fill Basket buffer.
847///
848/// If TBranchIMTHelper is non-null and it is time to WriteBasket, then we will
849/// use TBB to compress in parallel.
850///
851/// The function returns the number of bytes committed to the memory basket.
852/// If a write error occurs, the number of bytes returned is -1.
853/// If no data are written, because e.g. the branch is disabled,
854/// the number of bytes returned is 0.
855
857{
858 if (TestBit(kDoNotProcess)) {
859 return 0;
860 }
861
863 if (!basket) {
864 basket = fTree->CreateBasket(this); // create a new basket
865 if (!basket) return 0;
866 ++fNBaskets;
868 }
869 TBuffer* buf = basket->GetBufferRef();
870
871 // Fill basket buffer.
872
873 Int_t nsize = 0;
874
875 if (buf->IsReading()) {
876 basket->SetWriteMode();
877 }
878
880 buf->ResetMap();
881 }
882
883 Int_t lnew = 0;
884 Int_t nbytes = 0;
885
886 if (fEntryBuffer) {
887 nbytes = FillEntryBuffer(basket,buf,lnew);
888 } else {
889 Int_t lold = buf->Length();
890 basket->Update(lold);
891 ++fEntries;
892 ++fEntryNumber;
893 (this->*fFillLeaves)(*buf);
894 if (buf->GetMapCount()) {
895 // The map is used.
897 }
898 lnew = buf->Length();
899 nbytes = lnew - lold;
900 }
901
902 if (fEntryOffsetLen) {
903 Int_t nevbuf = basket->GetNevBuf();
904 // Total size in bytes of EntryOffset table.
905 nsize = nevbuf * sizeof(Int_t);
906 } else {
907 if (!basket->GetNevBufSize()) {
908 basket->SetNevBufSize(nbytes);
909 }
910 }
911
912 // Should we create a new basket?
913 // fSkipZip force one entry per buffer (old stuff still maintained for CDF)
914 // Transfer full compressed buffer only
915
916 // If GetAutoFlush() is less than zero, then we are determining the end of the autocluster
917 // based upon the number of bytes already flushed. This is incompatible with one-basket-per-cluster
918 // (since we will grow the basket indefinitely and never flush!). Hence, we wait until the
919 // first event cluster is written out and *then* enable one-basket-per-cluster mode.
920 bool noFlushAtCluster = !fTree->TestBit(TTree::kOnlyFlushAtCluster) || (fTree->GetAutoFlush() < 0);
921
922 if (noFlushAtCluster && !fTree->TestBit(TTree::kCircular) &&
924 ((lnew + (2 * nsize) + nbytes) >= fBasketSize))) {
925 Int_t nout = WriteBasketImpl(basket, fWriteBasket, imtHelper);
926 if (nout < 0) Error("TBranch::Fill", "Failed to write out basket.\n");
927 return (nout >= 0) ? nbytes : -1;
928 }
929 return nbytes;
930}
931
932////////////////////////////////////////////////////////////////////////////////
933/// Copy the data from fEntryBuffer into the current basket.
934
936{
937 Int_t nbytes = 0;
938 Int_t objectStart = 0;
939 Int_t last = 0;
940 Int_t lold = buf->Length();
941
942 // Handle the special case of fEntryBuffer != 0
943 if (fEntryBuffer->IsA() == TMessage::Class()) {
944 objectStart = 8;
945 }
947 // The buffer given as input has not been decompressed.
948 if (basket->GetNevBuf()) {
949 // If the basket already contains entry we need to close it
950 // out. (This is because we can only transfer full compressed
951 // buffer)
953 // And restart from scratch
954 return Fill();
955 }
956 Int_t startpos = fEntryBuffer->Length();
958 static TBasket toread_fLast;
960 toread_fLast.Streamer(*fEntryBuffer);
962 last = toread_fLast.GetLast();
963 // last now contains the decompressed number of bytes.
964 fEntryBuffer->SetBufferOffset(startpos);
965 buf->SetBufferOffset(0);
967 basket->Update(lold);
968 } else {
969 // We are required to copy starting at the version number (so not
970 // including the class name.
971 // See if byte count is here, if not it class still be a newClass
972 const UInt_t kNewClassTag = 0xFFFFFFFF;
973 const UInt_t kByteCountMask = 0x40000000; // OR the byte count with this
974 UInt_t tag = 0;
975 UInt_t startpos = fEntryBuffer->Length();
976 fEntryBuffer->SetBufferOffset(objectStart);
977 *fEntryBuffer >> tag;
978 if (tag & kByteCountMask) {
979 *fEntryBuffer >> tag;
980 }
981 if (tag == kNewClassTag) {
982 UInt_t maxsize = 256;
983 char* s = new char[maxsize];
984 Int_t name_start = fEntryBuffer->Length();
985 fEntryBuffer->ReadString(s, maxsize); // Reads at most maxsize - 1 characters, plus null at end.
986 while (strlen(s) == (maxsize - 1)) {
987 // The classname is too large, try again with a large buffer.
988 fEntryBuffer->SetBufferOffset(name_start);
989 maxsize *= 2;
990 delete[] s;
991 s = new char[maxsize];
992 fEntryBuffer->ReadString(s, maxsize); // Reads at most maxsize - 1 characters, plus null at end
993 }
994 delete[] s;
995 } else {
996 fEntryBuffer->SetBufferOffset(objectStart);
997 }
998 objectStart = fEntryBuffer->Length();
999 fEntryBuffer->SetBufferOffset(startpos);
1000 basket->Update(lold, objectStart - fEntryBuffer->GetBufferDisplacement());
1001 }
1002 fEntries++;
1003 fEntryNumber++;
1004 UInt_t len = 0;
1005 UInt_t startpos = fEntryBuffer->Length();
1006 if (startpos > UInt_t(objectStart)) {
1007 // We assume this buffer have just been directly filled
1008 // the current position in the buffer indicates the end of the object!
1009 len = fEntryBuffer->Length() - objectStart;
1010 } else {
1011 // The buffer have been acquired either via TSocket or via
1012 // TBuffer::SetBuffer(newloc,newsize)
1013 // Only the actual size of the memory buffer gives us an hint about where
1014 // the object ends.
1015 len = fEntryBuffer->BufferSize() - objectStart;
1016 }
1017 buf->WriteBuf(fEntryBuffer->Buffer() + objectStart, len);
1019 // The original buffer came pre-compressed and thus the buffer Length
1020 // does not really show the really object size
1021 // lnew = nbytes = basket->GetLast();
1022 nbytes = last;
1023 lnew = last;
1024 } else {
1025 lnew = buf->Length();
1026 nbytes = lnew - lold;
1027 }
1028
1029 return nbytes;
1030}
1031
1032////////////////////////////////////////////////////////////////////////////////
1033/// Find the immediate sub-branch with passed name.
1034
1036{
1037 // We allow the user to pass only the last dotted component of the name.
1038 std::string longnm;
1039 longnm.reserve(fName.Length()+strlen(name)+3);
1040 longnm = fName.Data();
1041 if (longnm[longnm.length()-1]==']') {
1042 std::size_t dim = longnm.find_first_of("[");
1043 if (dim != std::string::npos) {
1044 longnm.erase(dim);
1045 }
1046 }
1047 if (longnm[longnm.length()-1] != '.') {
1048 longnm += '.';
1049 }
1050 longnm += name;
1051 UInt_t namelen = strlen(name);
1052
1053 Int_t nbranches = fBranches.GetEntries();
1054 TBranch* branch = 0;
1055 for(Int_t i = 0; i < nbranches; ++i) {
1056 branch = (TBranch*) fBranches.UncheckedAt(i);
1057
1058 const char *brname = branch->fName.Data();
1059 UInt_t brlen = branch->fName.Length();
1060 if (brname[brlen-1]==']') {
1061 const char *dim = strchr(brname,'[');
1062 if (dim) {
1063 brlen = dim - brname;
1064 }
1065 }
1066 if (namelen == brlen /* same effective size */
1067 && strncmp(name,brname,brlen) == 0) {
1068 return branch;
1069 }
1070 if (brlen == (size_t)longnm.length()
1071 && strncmp(longnm.c_str(),brname,brlen) == 0) {
1072 return branch;
1073 }
1074 }
1075 return 0;
1076}
1077
1078////////////////////////////////////////////////////////////////////////////////
1079/// Find the leaf corresponding to the name 'searchname'.
1080
1081TLeaf* TBranch::FindLeaf(const char* searchname)
1082{
1083 TString leafname;
1084 TString leaftitle;
1085 TString longname;
1086 TString longtitle;
1087
1088 // We allow the user to pass only the last dotted component of the name.
1089 TIter next(GetListOfLeaves());
1090 TLeaf* leaf = 0;
1091 while ((leaf = (TLeaf*) next())) {
1092 leafname = leaf->GetName();
1093 Ssiz_t dim = leafname.First('[');
1094 if (dim >= 0) leafname.Remove(dim);
1095
1096 if (leafname == searchname) return leaf;
1097
1098 // The leaf element contains the branch name in its name, let's use the title.
1099 leaftitle = leaf->GetTitle();
1100 dim = leaftitle.First('[');
1101 if (dim >= 0) leaftitle.Remove(dim);
1102
1103 if (leaftitle == searchname) return leaf;
1104
1105 TBranch* branch = leaf->GetBranch();
1106 if (branch) {
1107 longname.Form("%s.%s",branch->GetName(),leafname.Data());
1108 dim = longname.First('[');
1109 if (dim>=0) longname.Remove(dim);
1110 if (longname == searchname) return leaf;
1111
1112 // The leaf element contains the branch name in its name.
1113 longname.Form("%s.%s",branch->GetName(),searchname);
1114 if (longname==leafname) return leaf;
1115
1116 longtitle.Form("%s.%s",branch->GetName(),leaftitle.Data());
1117 dim = longtitle.First('[');
1118 if (dim>=0) longtitle.Remove(dim);
1119 if (longtitle == searchname) return leaf;
1120
1121 // The following is for the case where the branch is only
1122 // a sub-branch. Since we do not see it through
1123 // TTree::GetListOfBranches, we need to see it indirectly.
1124 // This is the less sturdy part of this search ... it may
1125 // need refining ...
1126 if (strstr(searchname, ".") && !strcmp(searchname, branch->GetName())) return leaf;
1127 }
1128 }
1129 return 0;
1130}
1131
1132////////////////////////////////////////////////////////////////////////////////
1133/// Flush to disk all the baskets of this branch and any of subbranches.
1134/// Return the number of bytes written or -1 in case of write error.
1135
1137{
1138 UInt_t nerror = 0;
1139 Int_t nbytes = 0;
1140
1141 Int_t maxbasket = fWriteBasket + 1;
1142 // The following protection is not necessary since we should always
1143 // have fWriteBasket < fBasket.GetSize()
1144 //if (fBaskets.GetSize() < maxbasket) {
1145 // maxbasket = fBaskets.GetSize();
1146 //}
1147 for(Int_t i=0; i != maxbasket; ++i) {
1148 if (fBaskets.UncheckedAt(i)) {
1149 Int_t nwrite = FlushOneBasket(i);
1150 if (nwrite<0) {
1151 ++nerror;
1152 } else {
1153 nbytes += nwrite;
1154 }
1155 }
1156 }
1158 for (Int_t i = 0; i < len; ++i) {
1159 TBranch* branch = (TBranch*) fBranches.UncheckedAt(i);
1160 if (!branch) {
1161 continue;
1162 }
1163 Int_t nwrite = branch->FlushBaskets();
1164 if (nwrite<0) {
1165 ++nerror;
1166 } else {
1167 nbytes += nwrite;
1168 }
1169 }
1170 if (nerror) {
1171 return -1;
1172 } else {
1173 return nbytes;
1174 }
1175}
1176
1177////////////////////////////////////////////////////////////////////////////////
1178/// If we have a write basket in memory and it contains some entries and
1179/// has not yet been written to disk, we write it and delete it from memory.
1180/// Return the number of bytes written;
1181
1183{
1184 Int_t nbytes = 0;
1186 TBasket *basket = (TBasket*)fBaskets.UncheckedAt(ibasket);
1187
1188 if (basket) {
1189 if (basket->GetNevBuf()
1190 && fBasketSeek[ibasket]==0) {
1191 // If the basket already contains entry we need to close it out.
1192 // (This is because we can only transfer full compressed buffer)
1193
1194 if (basket->GetBufferRef()->IsReading()) {
1195 basket->SetWriteMode();
1196 }
1197 nbytes = WriteBasket(basket,ibasket);
1198
1199 } else {
1200 // If the basket is empty or has already been written.
1201 if ((Int_t)ibasket==fWriteBasket) {
1202 // Nothing to do.
1203 } else {
1204 basket->DropBuffers();
1205 if (basket == fCurrentBasket) {
1206 fCurrentBasket = 0;
1207 fFirstBasketEntry = -1;
1208 fNextBasketEntry = -1;
1209 }
1210 delete basket;
1211 --fNBaskets;
1212 fBaskets[ibasket] = 0;
1213 }
1214 }
1215 }
1216 }
1217 return nbytes;
1218}
1219
1220////////////////////////////////////////////////////////////////////////////////
1221/// Return pointer to basket basketnumber in this Branch
1222///
1223/// If a new buffer must be created and the user_buffer argument is non-null,
1224/// then the memory in the user_buffer will be shared with the returned TBasket.
1225
1226TBasket* TBranch::GetBasketImpl(Int_t basketnumber, TBuffer *user_buffer)
1227{
1228 // This counter in the sequential case collects errors coming also from
1229 // different files (suppose to have a program reading f1.root, f2.root ...)
1230 // In the mt case, it is made atomic: it safely collects errors from
1231 // different files processed simultaneously.
1232 static std::atomic<Int_t> nerrors(0);
1233
1234 // reference to an existing basket in memory ?
1235 if (basketnumber <0 || basketnumber > fWriteBasket) return 0;
1236 TBasket *basket = (TBasket*)fBaskets.UncheckedAt(basketnumber);
1237 if (basket) return basket;
1238 if (basketnumber == fWriteBasket) return 0;
1239
1240 // create/decode basket parameters from buffer
1241 TFile *file = GetFile(0);
1242 if (file == 0) {
1243 return 0;
1244 }
1245 // if cluster pre-fetching or retaining is on, do not re-use existing baskets
1246 // unless a new cluster is used.
1248 basket = GetFreshCluster(user_buffer);
1249 else
1250 basket = GetFreshBasket(basketnumber, user_buffer);
1251
1252 // fSkipZip is old stuff still maintained for CDF
1254 if (fBasketBytes[basketnumber] == 0) {
1255 fBasketBytes[basketnumber] = basket->ReadBasketBytes(fBasketSeek[basketnumber],file);
1256 }
1257 //add branch to cache (if any)
1258 {
1259 R__LOCKGUARD_IMT(gROOTMutex); // Lock for parallel TTree I/O
1261 if (pf){
1262 if (pf->IsLearning()) pf->LearnBranch(this, kFALSE);
1263 if (fSkipZip) pf->SetSkipZip();
1264 }
1265 }
1266
1267 //now read basket
1268 Int_t badread = basket->ReadBasketBuffers(fBasketSeek[basketnumber],fBasketBytes[basketnumber],file);
1269 if (R__unlikely(badread || basket->GetSeekKey() != fBasketSeek[basketnumber] || basket->IsZombie())) {
1270 nerrors++;
1271 if (nerrors > 10) return 0;
1272 if (nerrors == 10) {
1273 printf(" file probably overwritten: stopping reporting error messages\n");
1274 if (fBasketSeek[basketnumber] > 2000000000) {
1275 printf("===>File is more than 2 Gigabytes\n");
1276 return 0;
1277 }
1278 if (fBasketSeek[basketnumber] > 1000000000) {
1279 printf("===>Your file is may be bigger than the maximum file size allowed on your system\n");
1280 printf(" Check your AFS maximum file size limit for example\n");
1281 return 0;
1282 }
1283 }
1284 Error("GetBasket","File: %s at byte:%lld, branch:%s, entry:%lld, badread=%d, nerrors=%d, basketnumber=%d",file->GetName(),basket->GetSeekKey(),GetName(),fReadEntry,badread,nerrors.load(),basketnumber);
1285 return 0;
1286 }
1287
1288 ++fNBaskets;
1289
1290 fCacheInfo.SetUsed(basketnumber);
1291 auto perfStats = GetTree()->GetPerfStats();
1292 if (perfStats)
1293 perfStats->SetUsed(this, basketnumber);
1294
1295 fBaskets.AddAt(basket,basketnumber);
1296 return basket;
1297}
1298
1299////////////////////////////////////////////////////////////////////////////////
1300/// Return address of basket in the file
1301
1303{
1304 if (basketnumber <0 || basketnumber > fWriteBasket) return 0;
1305 return fBasketSeek[basketnumber];
1306}
1307
1308////////////////////////////////////////////////////////////////////////////////
1309/// Returns (and, if 0, creates) browsable objects for this branch
1310/// See TVirtualBranchBrowsable::FillListOfBrowsables.
1311
1313 if (fBrowsables) return fBrowsables;
1314 fBrowsables=new TList();
1316 return fBrowsables;
1317}
1318
1319////////////////////////////////////////////////////////////////////////////////
1320/// Return the name of the user class whose content is stored in this branch,
1321/// if any. If this branch was created using the 'leaflist' technique, this
1322/// function returns an empty string.
1323
1324const char * TBranch::GetClassName() const
1325{
1326 return "";
1327}
1328
1329////////////////////////////////////////////////////////////////////////////////
1330/// Return icon name depending on type of branch.
1331
1332const char* TBranch::GetIconName() const
1333{
1334 if (IsFolder())
1335 return "TBranchElement-folder";
1336 else
1337 return "TBranchElement-leaf";
1338}
1339
1340////////////////////////////////////////////////////////////////////////////////
1341/// A helper function to locate the correct basket - and its first entry.
1342/// Extracted to a common private function because it is needed by both GetEntry
1343/// and GetBulkEntries. It should not be called directly.
1344///
1345/// If a new basket must be constructed and the user_buffer is provided, then
1346/// the user_buffer will back the memory of the newly-constructed basket.
1347///
1348/// Assumes that this branch is enabled.
1349///
1350/// Returns -1 if the entry does not exist
1351/// Returns -2 in case of error
1352/// Returns the index of the basket in case of success.
1354 TBuffer *user_buffer)
1355{
1356 Long64_t updatedNext = fNextBasketEntry;
1357 Long64_t entry = fReadEntry;
1358 if (R__likely(fCurrentBasket && fFirstBasketEntry <= entry && entry < fNextBasketEntry)) {
1359 // We have found the basket containing this entry.
1360 // make sure basket buffers are in memory.
1361 basket = fCurrentBasket;
1363 return fReadBasket;
1364 } else {
1365 if ((entry < fFirstEntry) || (entry >= fEntryNumber)) {
1366 return -1;
1367 }
1369 Long64_t last = fNextBasketEntry - 1;
1370 // Are we still in the same ReadBasket?
1371 if ((entry < first) || (entry > last)) {
1373 if (fReadBasket < 0) {
1374 fNextBasketEntry = -1;
1375 Error("GetBasketAndFirst", "In the branch %s, no basket contains the entry %lld\n", GetName(), entry);
1376 return -2;
1377 }
1378 if (fReadBasket == fWriteBasket) {
1380 } else {
1382 }
1383 updatedNext = fNextBasketEntry;
1385 }
1386 // We have found the basket containing this entry.
1387 // make sure basket buffers are in memory.
1389 if (!basket) {
1390 basket = GetBasketImpl(fReadBasket, user_buffer);
1391 if (!basket) {
1392 fCurrentBasket = 0;
1393 fFirstBasketEntry = -1;
1394 fNextBasketEntry = -1;
1395 return -2;
1396 }
1397 if (fTree->GetClusterPrefetch()) {
1398 TTree::TClusterIterator clusterIterator = fTree->GetClusterIterator(entry);
1399 clusterIterator.Next();
1400 Int_t nextClusterEntry = clusterIterator.GetNextEntry();
1401 for (Int_t i = fReadBasket + 1; i < fMaxBaskets && fBasketEntry[i] < nextClusterEntry; i++) {
1402 GetBasket(i);
1403 }
1404 }
1405 // Getting the next basket might reset the current one and
1406 // cause a reset of the first / next basket entries back to -1.
1408 fNextBasketEntry = updatedNext;
1409 if (user_buffer) {
1410 // Disassociate basket from memory buffer for bulk IO
1411 // When the user provides a memory buffer (i.e., for bulk IO), we should
1412 // make sure to drop all references to that buffer in the TTree afterward.
1413 fCurrentBasket = nullptr;
1414 fBaskets[fReadBasket] = nullptr;
1415 } else {
1416 fCurrentBasket = basket;
1417 }
1418 } else {
1419 fCurrentBasket = basket;
1420 }
1421 return fReadBasket;
1422 }
1423}
1424
1425////////////////////////////////////////////////////////////////////////////////
1426/// Returns true if this branch supports bulk IO, false otherwise.
1427///
1428/// This will return true if all the various preconditions necessary hold true
1429/// to perform bulk IO (reasonable type, single TLeaf, etc); the bulk IO may
1430/// still fail, depending on the contents of the individual TBaskets loaded.
1432 return (fNleaves == 1) &&
1433 (static_cast<TLeaf*>(fLeaves.UncheckedAt(0))->GetDeserializeType() != TLeaf::DeserializeType::kExternal);
1434}
1435
1436////////////////////////////////////////////////////////////////////////////////
1437/// Read as many events as possible into the given buffer, using zero-copy
1438/// mechanisms.
1439///
1440/// Returns -1 in case of a failure. On success, returns a (non-zero) number of
1441/// events of the type held by this branch currently in the buffer.
1442///
1443/// On success, the caller should be able to access the contents of buf as
1444///
1445/// static_cast<T*>(buf.GetCurrent())
1446///
1447/// where T is the type stored on this branch. The array's length is the return
1448/// value of this function.
1449///
1450/// NOTES:
1451/// - This interface is meant to be used by higher-level, type-safe wrappers, not
1452/// by end-users.
1453/// - This only returns events
1454///
1455
1457{
1458 // TODO: eventually support multiple leaves.
1459 if (R__unlikely(fNleaves != 1)) return -1;
1460 TLeaf *leaf = static_cast<TLeaf*>(fLeaves.UncheckedAt(0));
1462 return -1;
1463 }
1464
1465 // Remember which entry we are reading.
1466 fReadEntry = entry;
1467
1468 Bool_t enabled = !TestBit(kDoNotProcess);
1469 if (R__unlikely(!enabled)) return -1;
1470 TBasket *basket = nullptr;
1472 Int_t result = GetBasketAndFirst(basket, first, &user_buf);
1473 if (R__unlikely(result < 0)) return -1;
1474 // Only support reading from full clusters.
1475 if (R__unlikely(entry != first)) {
1476 //printf("Failed to read from full cluster; first entry is %ld; requested entry is %ld.\n", first, entry);
1477 return -1;
1478 }
1479
1480 basket->PrepareBasket(entry);
1481 TBuffer* buf = basket->GetBufferRef();
1482
1483 // Test for very old ROOT files.
1484 if (R__unlikely(!buf)) {
1485 Error("GetBulkEntries", "Failed to get a new buffer.\n");
1486 return -1;
1487 }
1488 // Test for displacements, which aren't supported in fast mode.
1489 if (R__unlikely(basket->GetDisplacement())) {
1490 Error("GetBulkEntries", "Basket has displacement.\n");
1491 return -1;
1492 }
1493
1494 if (&user_buf != buf) {
1495 // The basket was already in memory and might (and might not) be backed by persistent
1496 // storage.
1498 if (fBasketSeek[fReadBasket]) {
1499 // It is backed, so we can be destructive
1500 user_buf.SetBuffer(buf->Buffer(), buf->BufferSize());
1502 fCurrentBasket = nullptr;
1503 fBaskets[fReadBasket] = nullptr;
1504 } else {
1505 // This is the only copy, we can't return it as is to the user, just make a copy.
1506 if (user_buf.BufferSize() < buf->BufferSize()) {
1507 user_buf.AutoExpand(buf->BufferSize());
1508 }
1509 memcpy(user_buf.Buffer(), buf->Buffer(), buf->BufferSize());
1510 }
1511 }
1512
1513 Int_t bufbegin = basket->GetKeylen();
1514 user_buf.SetBufferOffset(bufbegin);
1515
1517 //printf("Requesting %d events; fNextBasketEntry=%lld; first=%lld.\n", N, fNextBasketEntry, first);
1518 if (R__unlikely(!leaf->ReadBasketFast(user_buf, N))) {
1519 Error("GetBulkEntries", "Leaf failed to read.\n");
1520 return -1;
1521 }
1522 user_buf.SetBufferOffset(bufbegin);
1523
1524 if (fCurrentBasket == nullptr) {
1525 R__ASSERT(fExtraBasket == nullptr && "fExtraBasket should have been set to nullptr by GetFreshBasket");
1526 fExtraBasket = basket;
1527 basket->DisownBuffer();
1528 }
1529
1530 return N;
1531}
1532
1533// TODO: Template this and the call above; only difference is the TLeaf function (ReadBasketFast vs
1534// ReadBasketSerialized
1536{
1537 // TODO: eventually support multiple leaves.
1538 if (R__unlikely(fNleaves != 1)) { return -1; }
1539 TLeaf *leaf = static_cast<TLeaf*>(fLeaves.UncheckedAt(0));
1541 Error("GetEntriesSerialized", "Encountered a branch with destructive deserialization; failing.");
1542 return -1;
1543 }
1544
1545 // Remember which entry we are reading.
1546 fReadEntry = entry;
1547
1548 Bool_t enabled = !TestBit(kDoNotProcess);
1549 if (R__unlikely(!enabled)) { return -1; }
1550 TBasket *basket = nullptr;
1552 Int_t result = GetBasketAndFirst(basket, first, &user_buf);
1553 if (R__unlikely(result < 0)) { return -1; }
1554 // Only support reading from full clusters.
1555 if (R__unlikely(entry != first)) {
1556 Error("GetEntriesSerialized", "Failed to read from full cluster; first entry is %lld; requested entry is %lld.\n", first, entry);
1557 return -1;
1558 }
1559
1560 basket->PrepareBasket(entry);
1561 TBuffer* buf = basket->GetBufferRef();
1562
1563 // Test for very old ROOT files.
1564 if (R__unlikely(!buf)) {
1565 Error("GetEntriesSerialized", "Failed to get a new buffer.\n");
1566 return -1;
1567 }
1568 // Test for displacements, which aren't supported in fast mode.
1569 if (R__unlikely(basket->GetDisplacement())) {
1570 Error("GetEntriesSerialized", "Basket has displacement.\n");
1571 return -1;
1572 }
1573
1574 if (&user_buf != buf) {
1575 // The basket was already in memory and might (and might not) be backed by persistent
1576 // storage.
1578 if (fBasketSeek[fReadBasket]) {
1579 // It is backed, so we can be destructive
1580 user_buf.SetBuffer(buf->Buffer(), buf->BufferSize());
1582 fCurrentBasket = nullptr;
1583 fBaskets[fReadBasket] = nullptr;
1584 } else {
1585 // This is the only copy, we can't return it as is to the user, just make a copy.
1586 if (user_buf.BufferSize() < buf->BufferSize()) {
1587 user_buf.AutoExpand(buf->BufferSize());
1588 }
1589 memcpy(user_buf.Buffer(), buf->Buffer(), buf->BufferSize());
1590 }
1591 }
1592
1593 Int_t bufbegin = basket->GetKeylen();
1594 user_buf.SetBufferOffset(bufbegin);
1595
1597 //Info("GetEntriesSerialized", "Requesting %d events; fNextBasketEntry=%lld; first=%lld.\n", N, fNextBasketEntry, first);
1598
1599 user_buf.SetBufferOffset(bufbegin);
1600
1601 if (count_buf) {
1602 TLeaf *count_leaf = leaf->GetLeafCount();
1603 if (count_leaf) {
1604 //printf("Getting leaf count entries.\n");
1605 TBranch *count_branch = count_leaf->GetBranch();
1606 if (R__unlikely(count_branch->GetEntriesSerialized(entry, *count_buf) < 0)) {
1607 Error("GetEntriesSerialized", "Failed to read count leaf.\n");
1608 return -1;
1609 }
1610 } else {
1611 // TODO: if you ask for a count on a fixed-size branch, maybe we should
1612 // just fail?
1613 Int_t entry_count_serialized;
1614 char *tmp_ptr = reinterpret_cast<char*>(&entry_count_serialized);
1615 tobuf(tmp_ptr, leaf->GetLenType() * leaf->GetNdata());
1616 Int_t cur_offset = count_buf->GetCurrent() - count_buf->Buffer();
1617 for (int idx=0; idx<N; idx++) {
1618 *count_buf << entry_count_serialized;
1619 }
1620 count_buf->SetBufferOffset(cur_offset);
1621 }
1622 }
1623
1624 if (fCurrentBasket == nullptr) {
1625 R__ASSERT(fExtraBasket == nullptr && "fExtraBasket should have been set to nullptr by GetFreshBasket");
1626 fExtraBasket = basket;
1627 basket->DisownBuffer();
1628 }
1629
1630 return N;
1631}
1632
1633////////////////////////////////////////////////////////////////////////////////
1634/// Read all leaves of entry and return total number of bytes read.
1635///
1636/// The input argument "entry" is the entry number in the current tree.
1637/// In case of a TChain, the entry number in the current Tree must be found
1638/// before calling this function. For example:
1639///
1640///~~~ {.cpp}
1641/// TChain* chain = ...;
1642/// Long64_t localEntry = chain->LoadTree(entry);
1643/// branch->GetEntry(localEntry);
1644///~~~
1645///
1646/// The function returns the number of bytes read from the input buffer.
1647/// If entry does not exist, the function returns 0.
1648/// If an I/O error occurs, the function returns -1.
1649///
1650/// See IMPORTANT REMARKS in TTree::GetEntry.
1651
1653{
1654 // Remember which entry we are reading.
1655 fReadEntry = entry;
1656
1657 if (R__unlikely(TestBit(kDoNotProcess) && !getall)) { return 0; }
1658
1659 TBasket *basket; // will be initialized in the if/then clauses.
1661
1662 Int_t result = GetBasketAndFirst(basket, first, nullptr);
1663 if (R__unlikely(result < 0)) { return result + 1; }
1664
1665 basket->PrepareBasket(entry);
1666 TBuffer* buf = basket->GetBufferRef();
1667
1668 // This test necessary to read very old Root files (NvE).
1669 if (R__unlikely(!buf)) {
1670 TFile* file = GetFile(0);
1671 if (!file) return -1;
1673 buf = basket->GetBufferRef();
1674 }
1675
1676 // Set entry offset in buffer.
1678 buf->ResetMap();
1679 }
1680 if (R__unlikely(!buf->IsReading())) {
1681 basket->SetReadMode();
1682 }
1683
1684 Int_t* entryOffset = basket->GetEntryOffset();
1685 Int_t bufbegin = 0;
1686 if (entryOffset) {
1687 bufbegin = entryOffset[entry-first];
1688 buf->SetBufferOffset(bufbegin);
1689 Int_t* displacement = basket->GetDisplacement();
1690 if (R__unlikely(displacement)) {
1691 buf->SetBufferDisplacement(displacement[entry-first]);
1692 }
1693 } else {
1694 bufbegin = basket->GetKeylen() + ((entry-first) * basket->GetNevBufSize());
1695 buf->SetBufferOffset(bufbegin);
1696 }
1697
1698 // Int_t bufbegin = buf->Length();
1699 (this->*fReadLeaves)(*buf);
1700 return buf->Length() - bufbegin;
1701}
1702
1703////////////////////////////////////////////////////////////////////////////////
1704/// Read all leaves of an entry and export buffers to real objects in a TClonesArray list.
1705///
1706/// Returns total number of bytes read.
1707
1709{
1710 // Remember which entry we are reading.
1711 fReadEntry = entry;
1712
1713 if (TestBit(kDoNotProcess)) {
1714 return 0;
1715 }
1716 if ((entry < 0) || (entry >= fEntryNumber)) {
1717 return 0;
1718 }
1719 Int_t nbytes = 0;
1721 Long64_t last = fNextBasketEntry - 1;
1722 // Are we still in the same ReadBasket?
1723 if ((entry < first) || (entry > last)) {
1725 if (fReadBasket < 0) {
1726 fNextBasketEntry = -1;
1727 Error("In the branch %s, no basket contains the entry %d\n", GetName(), entry);
1728 return -1;
1729 }
1730 if (fReadBasket == fWriteBasket) {
1732 } else {
1734 }
1736 }
1737
1738 // We have found the basket containing this entry.
1739 // Make sure basket buffers are in memory.
1740 TBasket* basket = GetBasketImpl(fReadBasket, nullptr);
1741 fCurrentBasket = basket;
1742 if (!basket) {
1743 fFirstBasketEntry = -1;
1744 fNextBasketEntry = -1;
1745 return 0;
1746 }
1747 TBuffer* buf = basket->GetBufferRef();
1748 // Set entry offset in buffer and read data from all leaves.
1750 buf->ResetMap();
1751 }
1752 if (R__unlikely(!buf->IsReading())) {
1753 basket->SetReadMode();
1754 }
1755 Int_t* entryOffset = basket->GetEntryOffset();
1756 Int_t bufbegin = 0;
1757 if (entryOffset) {
1758 bufbegin = entryOffset[entry-first];
1759 buf->SetBufferOffset(bufbegin);
1760 Int_t* displacement = basket->GetDisplacement();
1761 if (R__unlikely(displacement)) {
1762 buf->SetBufferDisplacement(displacement[entry-first]);
1763 }
1764 } else {
1765 bufbegin = basket->GetKeylen() + ((entry-first) * basket->GetNevBufSize());
1766 buf->SetBufferOffset(bufbegin);
1767 }
1768 TLeaf* leaf = (TLeaf*) fLeaves.UncheckedAt(0);
1769 leaf->ReadBasketExport(*buf, li, nentries);
1770 nbytes = buf->Length() - bufbegin;
1771 return nbytes;
1772}
1773
1774////////////////////////////////////////////////////////////////////////////////
1775/// Fill expectedClass and expectedType with information on the data type of the
1776/// object/values contained in this branch (and thus the type of pointers
1777/// expected to be passed to Set[Branch]Address
1778/// return 0 in case of success and > 0 in case of failure.
1779
1780Int_t TBranch::GetExpectedType(TClass *&expectedClass,EDataType &expectedType)
1781{
1782 expectedClass = 0;
1783 expectedType = kOther_t;
1784 TLeaf* l = (TLeaf*) GetListOfLeaves()->At(0);
1785 if (l) {
1786 expectedType = (EDataType) gROOT->GetType(l->GetTypeName())->GetType();
1787 return 0;
1788 } else {
1789 Error("GetExpectedType", "Did not find any leaves in %s",GetName());
1790 return 1;
1791 }
1792}
1793
1794////////////////////////////////////////////////////////////////////////////////
1795/// Return pointer to the file where branch buffers reside, returns 0
1796/// in case branch buffers reside in the same file as tree header.
1797/// If mode is 1 the branch buffer file is recreated.
1798
1800{
1801 if (fDirectory) return fDirectory->GetFile();
1802
1803 // check if a file with this name is in the list of Root files
1804 TFile *file = 0;
1805 {
1807 file = (TFile*)gROOT->GetListOfFiles()->FindObject(fFileName.Data());
1808 if (file) {
1809 fDirectory = file;
1810 return file;
1811 }
1812 }
1813
1814 if (fFileName.Length() == 0) return 0;
1815
1816 TString bFileName( GetRealFileName() );
1817
1818 // Open file (new file if mode = 1)
1819 {
1821 if (mode) file = TFile::Open(bFileName, "recreate");
1822 else file = TFile::Open(bFileName);
1823 }
1824 if (!file) return 0;
1825 if (file->IsZombie()) {delete file; return 0;}
1827 return file;
1828}
1829
1830////////////////////////////////////////////////////////////////////////////////
1831/// Return a fresh basket by either reusing an existing basket that needs
1832/// to be drop (according to TTree::MemoryFull) or create a new one.
1833///
1834/// If the user_buffer argument is non-null, then the memory in the
1835/// user-provided buffer will be utilized by the underlying basket.
1836///
1837/// The basket number is used to estimate the required buffer size
1838/// and try to optimize memory usage and number of memory allocation.
1839
1840TBasket* TBranch::GetFreshBasket(Int_t basketnumber, TBuffer* user_buffer)
1841{
1842 TBasket *basket = 0;
1843 if (user_buffer && fExtraBasket) {
1844 basket = fExtraBasket;
1845 fExtraBasket = nullptr;
1846 basket->AdoptBuffer(user_buffer);
1847 } else {
1848 if (GetTree()->MemoryFull(0)) {
1849 if (fNBaskets==1) {
1850 // Steal the existing basket
1851 Int_t oldindex = fBaskets.GetLast();
1852 basket = (TBasket*)fBaskets.UncheckedAt(oldindex);
1853 if (!basket) {
1854 fBaskets.SetLast(-2); // For recalculation of Last.
1855 oldindex = fBaskets.GetLast();
1856 if (oldindex != fBaskets.LowerBound()-1) {
1857 basket = (TBasket*)fBaskets.UncheckedAt(oldindex);
1858 }
1859 }
1860 if (basket && fBasketBytes[oldindex]!=0) {
1861 if (basket == fCurrentBasket) {
1862 fCurrentBasket = 0;
1863 fFirstBasketEntry = -1;
1864 fNextBasketEntry = -1;
1865 }
1866 fBaskets.AddAt(0,oldindex);
1867 fBaskets.SetLast(-1);
1868 fNBaskets = 0;
1869 basket->ReadResetBuffer(basketnumber);
1870#ifdef R__TRACK_BASKET_ALLOC_TIME
1871 fTree->AddAllocationTime(basket->GetResetAllocationTime());
1872#endif
1874 } else {
1875 basket = fTree->CreateBasket(this);
1876 }
1877 } else if (fNBaskets == 0) {
1878 // There is nothing to drop!
1879 basket = fTree->CreateBasket(this);
1880 } else {
1881 // Memory is full and there is more than one basket,
1882 // Let DropBaskets do it job.
1883 DropBaskets();
1884 basket = fTree->CreateBasket(this);
1885 }
1886 } else {
1887 basket = fTree->CreateBasket(this);
1888 }
1889 if (user_buffer)
1890 basket->AdoptBuffer(user_buffer);
1891 }
1892 return basket;
1893}
1894
1895////////////////////////////////////////////////////////////////////////////////
1896/// Drops the cluster two behind the current cluster and returns a fresh basket
1897/// by either reusing or creating a new one
1898
1900{
1901 TBasket *basket = 0;
1902
1903 auto CreateOrReuseBasket = [this, user_buffer]() -> TBasket* {
1904 TBasket *newbasket = nullptr;
1905 if (fExtraBasket) {
1906 newbasket = fExtraBasket;
1907 fExtraBasket = nullptr;
1908 } else {
1909 newbasket = fTree->CreateBasket(this);
1910 }
1911 if (user_buffer)
1912 newbasket->AdoptBuffer(user_buffer);
1913 return newbasket;
1914 };
1915
1916 // If GetClusterIterator is called with a negative entry then GetStartEntry will be 0
1917 // So we need to check if we reach the zero before we have gone back (1-VirtualSize) clusters
1918 // if this is the case, we want to keep everything in memory so we return a new basket
1920 if (iter.GetStartEntry() == 0) {
1921 return CreateOrReuseBasket();
1922 }
1923
1924 // Iterate backwards (1-VirtualSize) clusters to reach cluster to be unloaded from memory,
1925 // skipped if VirtualSize > 0.
1926 for (Int_t j = 0; j < -fTree->GetMaxVirtualSize(); j++) {
1927 if (iter.Previous() == 0) {
1928 return CreateOrReuseBasket();
1929 }
1930 }
1931
1932 Int_t entryToUnload = iter.Previous();
1933 // Finds the basket to unload from memory. Since the basket should be close to current
1934 // basket, just iterate backwards until the correct basket is reached. This should
1935 // be fast as long as the number of baskets per cluster is small
1936 Int_t basketToUnload = fReadBasket;
1937 while (fBasketEntry[basketToUnload] != entryToUnload) {
1938 basketToUnload--;
1939 if (basketToUnload < 0) {
1940 return CreateOrReuseBasket();
1941 }
1942 }
1943
1944 // Retrieves the basket that is going to be unloaded from memory. If the basket did not
1945 // exist, create a new one
1946 basket = (TBasket *)fBaskets.UncheckedAt(basketToUnload);
1947 if (basket) {
1948 fBaskets.AddAt(0, basketToUnload);
1949 --fNBaskets;
1950 } else {
1951 basket = CreateOrReuseBasket();
1952 }
1953 ++basketToUnload;
1954
1955 // Clear the rest of the baskets. While it would be ideal to reuse these baskets
1956 // for other baskets in the new cluster. It would require the function to go
1957 // beyond its current scope. In the ideal case when each cluster only has 1 basket
1958 // this will perform well
1959 iter.Next();
1960 while (fBasketEntry[basketToUnload] < iter.GetStartEntry()) {
1961 TBasket *oldbasket = (TBasket *)fBaskets.UncheckedAt(basketToUnload);
1962 if (oldbasket) {
1963 oldbasket->DropBuffers();
1964 delete oldbasket;
1965 fBaskets.AddAt(0, basketToUnload);
1966 --fNBaskets;
1967 }
1968 ++basketToUnload;
1969 }
1970 fBaskets.SetLast(-1);
1971 return basket;
1972}
1973
1974////////////////////////////////////////////////////////////////////////////////
1975/// Return the 'full' name of the branch. In particular prefix the mother's name
1976/// when it does not end in a trailing dot and thus is not part of the branch name
1978{
1979 TBranch* mother = GetMother();
1980 if (!mother || mother==this) {
1981 return fName;
1982 }
1983
1984 const auto motherName = mother->GetName();
1985 const auto len = strlen(motherName);
1986 if (len > 0 && (motherName[len-1] == '.')) {
1987 return fName;
1988 }
1989
1990 // Reserve the final size to avoid allocations
1991 TString result{static_cast<Ssiz_t>(len + 1 + fName.Length())};
1992 result = motherName;
1993 result += ".";
1994 result += fName;
1995 return result;
1996}
1997
1998////////////////////////////////////////////////////////////////////////////////
1999/// Return pointer to the 1st Leaf named name in thisBranch
2000
2001TLeaf* TBranch::GetLeaf(const char* name) const
2002{
2003 Int_t i;
2004 for (i=0;i<fNleaves;i++) {
2005 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(i);
2006 if (!strcmp(leaf->GetName(),name)) return leaf;
2007 }
2008 return 0;
2009}
2010
2011////////////////////////////////////////////////////////////////////////////////
2012/// Get real file name
2013
2015{
2016 if (fFileName.Length()==0) {
2017 return fFileName;
2018 }
2019 TString bFileName = fFileName;
2020
2021 // check if branch file name is absolute or a URL (e.g. root://host/...)
2022 char *bname = gSystem->ExpandPathName(fFileName.Data());
2023 if (!gSystem->IsAbsoluteFileName(bname) && !strstr(bname, ":/") && fTree && fTree->GetCurrentFile()) {
2024
2025 // if not, get filename where tree header is stored
2026 const char *tfn = fTree->GetCurrentFile()->GetName();
2027
2028 // If it is an archive file we need a special treatment
2029 TUrl arc(tfn);
2030 if (strlen(arc.GetAnchor()) > 0) {
2032 bFileName = arc.GetUrl();
2033 } else {
2034 // if this is an absolute path or a URL then prepend this path
2035 // to the branch file name
2036 char *tname = gSystem->ExpandPathName(tfn);
2037 if (gSystem->IsAbsoluteFileName(tname) || strstr(tname, ":/")) {
2038 bFileName = gSystem->GetDirName(tname);
2039 bFileName += "/";
2040 bFileName += fFileName;
2041 }
2042 delete [] tname;
2043 }
2044 }
2045 delete [] bname;
2046
2047 return bFileName;
2048}
2049
2050////////////////////////////////////////////////////////////////////////////////
2051/// Return all elements of one row unpacked in internal array fValues
2052/// [Actually just returns 1 (?)]
2053
2055{
2056 return 1;
2057}
2058
2059////////////////////////////////////////////////////////////////////////////////
2060/// Return whether this branch is in a mode where the object are decomposed
2061/// or not (Also known as MakeClass mode).
2062
2064{
2065 // Regular TBranch and TBrancObject can not be in makeClass mode
2066
2067 return kFALSE;
2068}
2069
2070////////////////////////////////////////////////////////////////////////////////
2071/// Get our top-level parent branch in the tree.
2072
2074{
2075 if (fMother) return fMother;
2076
2077 {
2078 TBranch *parent = fParent;
2079 while(parent) {
2080 if (parent->fMother) {
2081 const_cast<TBranch*>(this)->fMother = parent->fMother; // We can not yet use the 'mutable' keyword
2082 return fMother;
2083 }
2084 if (!parent->fParent) {
2085 // This is the top node
2086 const_cast<TBranch*>(this)->fMother = parent; // We can not yet use the 'mutable' keyword
2087 return fMother;
2088 }
2089 parent = parent->fParent;
2090 }
2091 }
2092
2093 const TObjArray* array = fTree->GetListOfBranches();
2094 Int_t n = array->GetEntriesFast();
2095 for (Int_t i = 0; i < n; ++i) {
2096 TBranch* branch = (TBranch*) array->UncheckedAt(i);
2097 TBranch* parent = branch->GetSubBranch(this);
2098 if (parent) {
2099 const_cast<TBranch*>(this)->fMother = branch; // We can not yet use the 'mutable' keyword
2100 return branch;
2101 }
2102 }
2103 return 0;
2104}
2105
2106////////////////////////////////////////////////////////////////////////////////
2107/// Find the parent branch of child.
2108/// Return 0 if child is not in this branch hierarchy.
2109
2111{
2112 // Handle error condition, if the parameter is us, we cannot find the parent.
2113 if (this == child) {
2114 // Note: We cast away any const-ness of "this".
2115 return (TBranch*) this;
2116 }
2117
2118 if (child->fParent) {
2119 return child->fParent;
2120 }
2121
2123 for (Int_t i = 0; i < len; ++i) {
2124 TBranch* branch = (TBranch*) fBranches.UncheckedAt(i);
2125 if (!branch) {
2126 continue;
2127 }
2128 if (branch == child) {
2129 // We are the direct parent of child.
2130 // Note: We cast away any const-ness of "this".
2131 const_cast<TBranch*>(child)->fParent = (TBranch*)this; // We can not yet use the 'mutable' keyword
2132 return (TBranch*) this;
2133 }
2134 // FIXME: This is a tail-recursion!
2135 TBranch* parent = branch->GetSubBranch(child);
2136 if (parent) {
2137 return parent;
2138 }
2139 }
2140 // We failed to find the parent.
2141 return 0;
2142}
2143
2144////////////////////////////////////////////////////////////////////////////////
2145/// Return total number of bytes in the branch (including current buffer)
2146
2148{
2150 // This intentionally only store the TBranch part and thus slightly
2151 // under-estimate the space used.
2152 // Since the TBranchElement part contains pointers to other branches (branch count),
2153 // doing regular Streaming would end up including those and thus greatly over-estimate
2154 // the size used.
2155 const_cast<TBranch *>(this)->TBranch::Streamer(b);
2156
2157 Long64_t totbytes = 0;
2158 if (fZipBytes > 0) totbytes = fTotBytes;
2159 return totbytes + b.Length();
2160}
2161
2162////////////////////////////////////////////////////////////////////////////////
2163/// Return total number of bytes in the branch (excluding current buffer)
2164/// if option ="*" includes all sub-branches of this branch too
2165
2167{
2168 Long64_t totbytes = fTotBytes;
2169 if (!option) return totbytes;
2170 if (option[0] != '*') return totbytes;
2171 //scan sub-branches
2173 for (Int_t i = 0; i < len; ++i) {
2174 TBranch* branch = (TBranch*) fBranches.UncheckedAt(i);
2175 if (branch) totbytes += branch->GetTotBytes(option);
2176 }
2177 return totbytes;
2178}
2179
2180////////////////////////////////////////////////////////////////////////////////
2181/// Return total number of zip bytes in the branch
2182/// if option ="*" includes all sub-branches of this branch too
2183
2185{
2186 Long64_t zipbytes = fZipBytes;
2187 if (!option) return zipbytes;
2188 if (option[0] != '*') return zipbytes;
2189 //scan sub-branches
2191 for (Int_t i = 0; i < len; ++i) {
2192 TBranch* branch = (TBranch*) fBranches.UncheckedAt(i);
2193 if (branch) zipbytes += branch->GetZipBytes(option);
2194 }
2195 return zipbytes;
2196}
2197
2198////////////////////////////////////////////////////////////////////////////////
2199/// Returns the IO settings currently in use for this branch.
2200
2202{
2203 return fIOFeatures;
2204}
2205
2206////////////////////////////////////////////////////////////////////////////////
2207/// Return kTRUE if an existing object in a TBranchObject must be deleted.
2208
2210{
2211 return TestBit(kAutoDelete);
2212}
2213
2214////////////////////////////////////////////////////////////////////////////////
2215/// Return kTRUE if more than one leaf or browsables, kFALSE otherwise.
2216
2218{
2219 if (fNleaves > 1) {
2220 return kTRUE;
2221 }
2222 TList* browsables = const_cast<TBranch*>(this)->GetBrowsables();
2223 return browsables && browsables->GetSize();
2224}
2225
2226////////////////////////////////////////////////////////////////////////////////
2227/// keep a maximum of fMaxEntries in memory
2228
2230{
2231 Int_t dentries = (Int_t) (fEntries - maxEntries);
2232 TBasket* basket = (TBasket*) fBaskets.UncheckedAt(0);
2233 if (basket) basket->MoveEntries(dentries);
2234 fEntries = maxEntries;
2235 fEntryNumber = maxEntries;
2236 //loop on sub branches
2238 for (Int_t i = 0; i < nb; ++i) {
2239 TBranch* branch = (TBranch*) fBranches.UncheckedAt(i);
2240 branch->KeepCircular(maxEntries);
2241 }
2242}
2243
2244////////////////////////////////////////////////////////////////////////////////
2245/// Baskets associated to this branch are forced to be in memory.
2246/// You can call TTree::SetMaxVirtualSize(maxmemory) to instruct
2247/// the system that the total size of the imported baskets does not
2248/// exceed maxmemory bytes.
2249///
2250/// The function returns the number of baskets that have been put in memory.
2251/// This method may be called to force all baskets of one or more branches
2252/// in memory when random access to entries in this branch is required.
2253/// See also TTree::LoadBaskets to load all baskets of all branches in memory.
2254
2256{
2257 Int_t nimported = 0;
2258 Int_t nbaskets = fWriteBasket;
2259 TFile *file = GetFile(0);
2260 if (!file) return 0;
2261 TBasket *basket;
2262 for (Int_t i=0;i<nbaskets;i++) {
2263 basket = (TBasket*)fBaskets.UncheckedAt(i);
2264 if (basket) continue;
2265 basket = GetFreshBasket(i, nullptr);
2266 if (fBasketBytes[i] == 0) {
2268 }
2269 Int_t badread = basket->ReadBasketBuffers(fBasketSeek[i],fBasketBytes[i],file);
2270 if (badread) {
2271 Error("Loadbaskets","Error while reading basket buffer %d of branch %s",i,GetName());
2272 return -1;
2273 }
2274 ++fNBaskets;
2275 fBaskets.AddAt(basket,i);
2276 nimported++;
2277 }
2278 return nimported;
2279}
2280
2281////////////////////////////////////////////////////////////////////////////////
2282/// Print TBranch parameters
2283///
2284/// If options contains "basketsInfo" print the entry number, location and size
2285/// of each baskets.
2286
2288{
2289 const int kLINEND = 77;
2290 Float_t cx = 1;
2291
2292 TString titleContent(GetTitle());
2293 if ( titleContent == GetName() ) {
2294 titleContent.Clear();
2295 }
2296
2297 if (fLeaves.GetEntries() == 1) {
2298 if (titleContent.Length()>=2 && titleContent[titleContent.Length()-2]=='/' && isalpha(titleContent[titleContent.Length()-1])) {
2299 // The type is already encoded. Nothing to do.
2300 } else {
2301 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(0);
2302 if (titleContent.Length()) {
2303 titleContent.Prepend(" ");
2304 }
2305 // titleContent.Append("type: ");
2306 titleContent.Prepend(leaf->GetTypeName());
2307 }
2308 }
2309 Int_t titleLength = titleContent.Length();
2310
2311 Int_t aLength = titleLength + strlen(GetName());
2312 aLength += (aLength / 54 + 1) * 80 + 100;
2313 if (aLength < 200) aLength = 200;
2314 char *bline = new char[aLength];
2315
2316 Long64_t totBytes = GetTotalSize();
2317 if (fZipBytes) cx = (fTotBytes+0.00001)/fZipBytes;
2318 if (titleLength) snprintf(bline,aLength,"*Br%5d :%-9s : %-54s *",fgCount,GetName(),titleContent.Data());
2319 else snprintf(bline,aLength,"*Br%5d :%-9s : %-54s *",fgCount,GetName()," ");
2320 if (strlen(bline) > UInt_t(kLINEND)) {
2321 char *tmp = new char[strlen(bline)+1];
2322 if (titleLength) strlcpy(tmp, titleContent.Data(),strlen(bline)+1);
2323 snprintf(bline,aLength,"*Br%5d :%-9s : ",fgCount,GetName());
2324 int pos = strlen (bline);
2325 int npos = pos;
2326 int beg=0, end;
2327 while (beg < titleLength) {
2328 for (end=beg+1; end < titleLength-1; end ++)
2329 if (tmp[end] == ':') break;
2330 if (npos + end-beg+1 >= 78) {
2331 while (npos < kLINEND) {
2332 bline[pos ++] = ' ';
2333 npos ++;
2334 }
2335 bline[pos ++] = '*';
2336 bline[pos ++] = '\n';
2337 bline[pos ++] = '*';
2338 npos = 1;
2339 for (; npos < 12; npos ++)
2340 bline[pos ++] = ' ';
2341 bline[pos-2] = '|';
2342 }
2343 for (int n = beg; n <= end; n ++)
2344 bline[pos+n-beg] = tmp[n];
2345 pos += end-beg+1;
2346 npos += end-beg+1;
2347 beg = end+1;
2348 }
2349 while (npos < kLINEND) {
2350 bline[pos ++] = ' ';
2351 npos ++;
2352 }
2353 bline[pos ++] = '*';
2354 bline[pos] = '\0';
2355 delete[] tmp;
2356 }
2357 Printf("%s", bline);
2358
2359 if (fTotBytes > 2000000000) {
2360 Printf("*Entries :%lld : Total Size=%11lld bytes File Size = %lld *",fEntries,totBytes,fZipBytes);
2361 } else {
2362 if (fZipBytes > 0) {
2363 Printf("*Entries :%9lld : Total Size=%11lld bytes File Size = %10lld *",fEntries,totBytes,fZipBytes);
2364 } else {
2365 if (fWriteBasket > 0) {
2366 Printf("*Entries :%9lld : Total Size=%11lld bytes All baskets in memory *",fEntries,totBytes);
2367 } else {
2368 Printf("*Entries :%9lld : Total Size=%11lld bytes One basket in memory *",fEntries,totBytes);
2369 }
2370 }
2371 }
2372 Printf("*Baskets :%9d : Basket Size=%11d bytes Compression= %6.2f *",fWriteBasket,fBasketSize,cx);
2373
2374 if (strncmp(option,"basketsInfo",strlen("basketsInfo"))==0) {
2375 Int_t nbaskets = fWriteBasket;
2376 for (Int_t i=0;i<nbaskets;i++) {
2377 Printf("*Basket #%4d entry=%6lld pos=%6lld size=%5d",
2378 i, fBasketEntry[i], fBasketSeek[i], fBasketBytes[i]);
2379 }
2380 }
2381
2382 Printf("*............................................................................*");
2383 delete [] bline;
2384 fgCount++;
2385}
2386
2387////////////////////////////////////////////////////////////////////////////////
2388/// Print the information we have about which basket is currently cached and
2389/// whether they have been 'used'/'read' from the cache.
2390
2392{
2394}
2395
2396////////////////////////////////////////////////////////////////////////////////
2397/// Loop on all leaves of this branch to read Basket buffer.
2398
2400{
2401 // fLeaves->ReadBasket(basket);
2402}
2403
2404////////////////////////////////////////////////////////////////////////////////
2405/// Loop on all leaves of this branch to read Basket buffer.
2406
2408{
2409 for (Int_t i = 0; i < fNleaves; ++i) {
2410 TLeaf* leaf = (TLeaf*) fLeaves.UncheckedAt(i);
2411 leaf->ReadBasket(b);
2412 }
2413}
2414
2415////////////////////////////////////////////////////////////////////////////////
2416/// Read zero leaves without the overhead of a loop.
2417
2419{
2420}
2421
2422////////////////////////////////////////////////////////////////////////////////
2423/// Read one leaf without the overhead of a loop.
2424
2426{
2428}
2429
2430////////////////////////////////////////////////////////////////////////////////
2431/// Read two leaves without the overhead of a loop.
2432
2434{
2437}
2438
2439////////////////////////////////////////////////////////////////////////////////
2440/// Loop on all leaves of this branch to fill Basket buffer.
2441
2443{
2444 for (Int_t i = 0; i < fNleaves; ++i) {
2445 TLeaf* leaf = (TLeaf*) fLeaves.UncheckedAt(i);
2446 leaf->FillBasket(b);
2447 }
2448}
2449
2450////////////////////////////////////////////////////////////////////////////////
2451/// Refresh this branch using new information in b
2452/// This function is called by TTree::Refresh
2453
2455{
2456 if (b==0) return;
2457
2458 fEntryOffsetLen = b->fEntryOffsetLen;
2459 fWriteBasket = b->fWriteBasket;
2460 fEntryNumber = b->fEntryNumber;
2461 fMaxBaskets = b->fMaxBaskets;
2462 fEntries = b->fEntries;
2463 fTotBytes = b->fTotBytes;
2464 fZipBytes = b->fZipBytes;
2465 fReadBasket = 0;
2466 fReadEntry = -1;
2467 fFirstBasketEntry = -1;
2468 fNextBasketEntry = -1;
2469 fCurrentBasket = 0;
2470 delete [] fBasketBytes;
2471 delete [] fBasketEntry;
2472 delete [] fBasketSeek;
2476 Int_t i;
2477 for (i=0;i<fMaxBaskets;i++) {
2478 fBasketBytes[i] = b->fBasketBytes[i];
2479 fBasketEntry[i] = b->fBasketEntry[i];
2480 fBasketSeek[i] = b->fBasketSeek[i];
2481 }
2482 fBaskets.Delete();
2483 Int_t nbaskets = b->fBaskets.GetSize();
2484 fBaskets.Expand(nbaskets);
2485 // If the current fWritebasket is in memory, take it (just swap)
2486 // from the Tree being read
2487 TBasket *basket = (TBasket*)b->fBaskets.UncheckedAt(fWriteBasket);
2488 fBaskets.AddAt(basket,fWriteBasket);
2489 if (basket) {
2490 fNBaskets = 1;
2491 --(b->fNBaskets);
2492 b->fBaskets.RemoveAt(fWriteBasket);
2493 basket->SetBranch(this);
2494 }
2495}
2496
2497////////////////////////////////////////////////////////////////////////////////
2498/// Reset a Branch.
2499///
2500/// - Existing buffers are deleted.
2501/// - Entries, max and min are reset.
2502
2504{
2505 fReadBasket = 0;
2506 fReadEntry = -1;
2507 fFirstBasketEntry = -1;
2508 fNextBasketEntry = -1;
2509 fCurrentBasket = 0;
2510 fWriteBasket = 0;
2511 fEntries = 0;
2512 fTotBytes = 0;
2513 fZipBytes = 0;
2514 fEntryNumber = 0;
2515
2516 if (fBasketBytes) {
2517 for (Int_t i = 0; i < fMaxBaskets; ++i) {
2518 fBasketBytes[i] = 0;
2519 }
2520 }
2521
2522 if (fBasketEntry) {
2523 for (Int_t i = 0; i < fMaxBaskets; ++i) {
2524 fBasketEntry[i] = 0;
2525 }
2526 }
2527
2528 if (fBasketSeek) {
2529 for (Int_t i = 0; i < fMaxBaskets; ++i) {
2530 fBasketSeek[i] = 0;
2531 }
2532 }
2533
2534 fBaskets.Delete();
2535 fNBaskets = 0;
2536}
2537
2538////////////////////////////////////////////////////////////////////////////////
2539/// Reset a Branch.
2540///
2541/// - Existing buffers are deleted.
2542/// - Entries, max and min are reset.
2543
2545{
2546 fReadBasket = 0;
2547 fReadEntry = -1;
2548 fFirstBasketEntry = -1;
2549 fNextBasketEntry = -1;
2550 fCurrentBasket = 0;
2551 fWriteBasket = 0;
2552 fEntries = 0;
2553 fTotBytes = 0;
2554 fZipBytes = 0;
2555 fEntryNumber = 0;
2556
2557 if (fBasketBytes) {
2558 for (Int_t i = 0; i < fMaxBaskets; ++i) {
2559 fBasketBytes[i] = 0;
2560 }
2561 }
2562
2563 if (fBasketEntry) {
2564 for (Int_t i = 0; i < fMaxBaskets; ++i) {
2565 fBasketEntry[i] = 0;
2566 }
2567 }
2568
2569 if (fBasketSeek) {
2570 for (Int_t i = 0; i < fMaxBaskets; ++i) {
2571 fBasketSeek[i] = 0;
2572 }
2573 }
2574
2575 TBasket *reusebasket = (TBasket*)fBaskets[fWriteBasket];
2576 if (reusebasket) {
2578 } else {
2579 reusebasket = (TBasket*)fBaskets[fReadBasket];
2580 if (reusebasket) {
2581 fBaskets[fReadBasket] = 0;
2582 }
2583 }
2584 fBaskets.Delete();
2585 if (reusebasket) {
2586 fNBaskets = 1;
2587 reusebasket->WriteReset();
2588 fBaskets[0] = reusebasket;
2589 } else {
2590 fNBaskets = 0;
2591 }
2592}
2593
2594////////////////////////////////////////////////////////////////////////////////
2595/// Reset the address of the branch.
2596
2598{
2599 fAddress = 0;
2600
2601 // Reset last read entry number, we have will had new user object now.
2602 fReadEntry = -1;
2603
2604 for (Int_t i = 0; i < fNleaves; ++i) {
2605 TLeaf* leaf = (TLeaf*) fLeaves.UncheckedAt(i);
2606 leaf->SetAddress(0);
2607 }
2608
2609 Int_t nbranches = fBranches.GetEntriesFast();
2610 for (Int_t i = 0; i < nbranches; ++i) {
2611 TBranch* abranch = (TBranch*) fBranches[i];
2612 // FIXME: This is a tail recursion.
2613 abranch->ResetAddress();
2614 }
2615}
2616
2617////////////////////////////////////////////////////////////////////////////////
2618/// Static function resetting fgCount
2619
2621{
2622 fgCount = 0;
2623}
2624
2625////////////////////////////////////////////////////////////////////////////////
2626/// Set address of this branch.
2627
2628void TBranch::SetAddress(void* addr)
2629{
2630 if (TestBit(kDoNotProcess)) {
2631 return;
2632 }
2633 fReadEntry = -1;
2634 fFirstBasketEntry = -1;
2635 fNextBasketEntry = -1;
2636 fAddress = (char*) addr;
2637 for (Int_t i = 0; i < fNleaves; ++i) {
2638 TLeaf* leaf = (TLeaf*) fLeaves.UncheckedAt(i);
2639 Int_t offset = leaf->GetOffset();
2640 if (TestBit(kIsClone)) {
2641 offset = 0;
2642 }
2643 if (fAddress) leaf->SetAddress(fAddress + offset);
2644 else leaf->SetAddress(0);
2645 }
2646}
2647
2648////////////////////////////////////////////////////////////////////////////////
2649/// Set the automatic delete bit.
2650///
2651/// This bit is used by TBranchObject::ReadBasket to decide if an object
2652/// referenced by a TBranchObject must be deleted or not before reading
2653/// a new entry.
2654///
2655/// If autodel is kTRUE, this existing object will be deleted, a new object
2656/// created by the default constructor, then read from disk by the streamer.
2657///
2658/// If autodel is kFALSE, the existing object is not deleted. Root assumes
2659/// that the user is taking care of deleting any internal object or array
2660/// (this can be done in the streamer).
2661
2663{
2664 if (autodel) {
2665 SetBit(kAutoDelete, 1);
2666 } else {
2667 SetBit(kAutoDelete, 0);
2668 }
2669}
2670
2671////////////////////////////////////////////////////////////////////////////////
2672/// Set the basket size
2673/// The function makes sure that the basket size is greater than fEntryOffsetlen
2674
2676{
2677 Int_t minsize = 100 + fName.Length();
2678 if (buffsize < minsize+fEntryOffsetLen) buffsize = minsize+fEntryOffsetLen;
2679 fBasketSize = buffsize;
2680 TBasket *basket = (TBasket*)fBaskets[fWriteBasket];
2681 if (basket) {
2682 basket->AdjustSize(fBasketSize);
2683 }
2684}
2685
2686////////////////////////////////////////////////////////////////////////////////
2687/// Set address of this branch directly from a TBuffer to avoid streaming.
2688///
2689/// Note: We do not take ownership of the buffer.
2690
2692{
2693 // Check this is possible
2694 if ( (fNleaves != 1)
2695 || (strcmp("TLeafObject",fLeaves.UncheckedAt(0)->ClassName())!=0) ) {
2696 Error("TBranch::SetAddress","Filling from a TBuffer can only be done with a not split object branch. Request ignored.");
2697 } else {
2698 fReadEntry = -1;
2699 fNextBasketEntry = -1;
2700 fFirstBasketEntry = -1;
2701 // Note: We do not take ownership of the buffer.
2702 fEntryBuffer = buf;
2703 }
2704}
2705
2706////////////////////////////////////////////////////////////////////////////////
2707/// Set compression algorithm.
2708
2710{
2711 if (algorithm < 0 || algorithm >= ROOT::RCompressionSetting::EAlgorithm::kUndefined) algorithm = 0;
2712 if (fCompress < 0) {
2714 } else {
2715 int level = fCompress % 100;
2716 fCompress = 100 * algorithm + level;
2717 }
2718
2720 for (Int_t i=0;i<nb;i++) {
2721 TBranch *branch = (TBranch*)fBranches.UncheckedAt(i);
2722 branch->SetCompressionAlgorithm(algorithm);
2723 }
2724}
2725
2726////////////////////////////////////////////////////////////////////////////////
2727/// Set compression level.
2728
2730{
2731 if (level < 0) level = 0;
2732 if (level > 99) level = 99;
2733 if (fCompress < 0) {
2734 fCompress = level;
2735 } else {
2736 int algorithm = fCompress / 100;
2737 if (algorithm >= ROOT::RCompressionSetting::EAlgorithm::kUndefined) algorithm = 0;
2738 fCompress = 100 * algorithm + level;
2739 }
2740
2742 for (Int_t i=0;i<nb;i++) {
2743 TBranch *branch = (TBranch*)fBranches.UncheckedAt(i);
2744 branch->SetCompressionLevel(level);
2745 }
2746}
2747
2748////////////////////////////////////////////////////////////////////////////////
2749/// Set compression settings.
2750
2752{
2753 fCompress = settings;
2754
2756 for (Int_t i=0;i<nb;i++) {
2757 TBranch *branch = (TBranch*)fBranches.UncheckedAt(i);
2758 branch->SetCompressionSettings(settings);
2759 }
2760}
2761
2762////////////////////////////////////////////////////////////////////////////////
2763/// Update the default value for the branch's fEntryOffsetLen if and only if
2764/// it was already non zero (and the new value is not zero)
2765/// If updateExisting is true, also update all the existing branches.
2766
2767void TBranch::SetEntryOffsetLen(Int_t newdefault, Bool_t updateExisting)
2768{
2769 if (fEntryOffsetLen && newdefault) {
2770 fEntryOffsetLen = newdefault;
2771 }
2772 if (updateExisting) {
2773 TIter next( GetListOfBranches() );
2774 TBranch *b;
2775 while ( ( b = (TBranch*)next() ) ) {
2776 b->SetEntryOffsetLen( newdefault, kTRUE );
2777 }
2778 }
2779}
2780
2781////////////////////////////////////////////////////////////////////////////////
2782/// Set the number of entries in this branch.
2783
2785{
2786 fEntries = entries;
2787 fEntryNumber = entries;
2788}
2789
2790////////////////////////////////////////////////////////////////////////////////
2791/// Set file where this branch writes/reads its buffers.
2792/// By default the branch buffers reside in the file where the
2793/// Tree was created.
2794/// If the file name where the tree was created is an absolute
2795/// path name or an URL (e.g. or root://host/...)
2796/// and if the fname is not an absolute path name or an URL then
2797/// the path of the tree file is prepended to fname to make the
2798/// branch file relative to the tree file. In this case one can
2799/// move the tree + all branch files to a different location in
2800/// the file system and still access the branch files.
2801/// The ROOT file will be connected only when necessary.
2802/// If called by TBranch::Fill (via TBasket::WriteFile), the file
2803/// will be created with the option "recreate".
2804/// If called by TBranch::GetEntry (via TBranch::GetBasket), the file
2805/// will be opened in read mode.
2806/// To open a file in "update" mode or with a certain compression
2807/// level, use TBranch::SetFile(TFile *file).
2808
2810{
2811 if (file == 0) file = fTree->GetCurrentFile();
2813 if (file == fTree->GetCurrentFile()) fFileName = "";
2814 else fFileName = file->GetName();
2815
2816 if (file && fCompress == -1) {
2817 fCompress = file->GetCompressionLevel();
2818 }
2819
2820 // Apply to all existing baskets.
2821 TIter nextb(GetListOfBaskets());
2822 TBasket *basket;
2823 while ((basket = (TBasket*)nextb())) {
2824 basket->SetParent(file);
2825 }
2826
2827 // Apply to sub-branches as well.
2828 TIter next(GetListOfBranches());
2829 TBranch *branch;
2830 while ((branch = (TBranch*)next())) {
2831 branch->SetFile(file);
2832 }
2833}
2834
2835////////////////////////////////////////////////////////////////////////////////
2836/// Set file where this branch writes/reads its buffers.
2837/// By default the branch buffers reside in the file where the
2838/// Tree was created.
2839/// If the file name where the tree was created is an absolute
2840/// path name or an URL (e.g. root://host/...)
2841/// and if the fname is not an absolute path name or an URL then
2842/// the path of the tree file is prepended to fname to make the
2843/// branch file relative to the tree file. In this case one can
2844/// move the tree + all branch files to a different location in
2845/// the file system and still access the branch files.
2846/// The ROOT file will be connected only when necessary.
2847/// If called by TBranch::Fill (via TBasket::WriteFile), the file
2848/// will be created with the option "recreate".
2849/// If called by TBranch::GetEntry (via TBranch::GetBasket), the file
2850/// will be opened in read mode.
2851/// To open a file in "update" mode or with a certain compression
2852/// level, use TBranch::SetFile(TFile *file).
2853
2854void TBranch::SetFile(const char* fname)
2855{
2856 fFileName = fname;
2857 fDirectory = 0;
2858
2859 //apply to sub-branches as well
2860 TIter next(GetListOfBranches());
2861 TBranch *branch;
2862 while ((branch = (TBranch*)next())) {
2863 branch->SetFile(fname);
2864 }
2865}
2866
2867////////////////////////////////////////////////////////////////////////////////
2868/// Set the branch in a mode where the object are decomposed
2869/// (Also known as MakeClass mode).
2870/// Return whether the setting was possible (it is not possible for
2871/// TBranch and TBranchObject).
2872
2874{
2875 // Regular TBranch and TBrancObject can not be in makeClass mode
2876 return kFALSE;
2877}
2878
2879////////////////////////////////////////////////////////////////////////////////
2880/// Set object this branch is pointing to.
2881
2882void TBranch::SetObject(void * /* obj */)
2883{
2884 if (TestBit(kDoNotProcess)) {
2885 return;
2886 }
2887 Warning("SetObject","is not supported in TBranch objects");
2888}
2889
2890////////////////////////////////////////////////////////////////////////////////
2891/// Set branch status to Process or DoNotProcess.
2892
2894{
2895 if (status) ResetBit(kDoNotProcess);
2896 else SetBit(kDoNotProcess);
2897}
2898
2899////////////////////////////////////////////////////////////////////////////////
2900/// Stream a class object
2901
2903{
2904 if (b.IsReading()) {
2905 UInt_t R__s, R__c;
2906 fTree = 0; // Will be set by TTree::Streamer
2907 fAddress = 0;
2908 gROOT->SetReadingObject(kTRUE);
2909
2910 // Reset transients.
2912 fCurrentBasket = 0;
2913 fFirstBasketEntry = -1;
2914 fNextBasketEntry = -1;
2915
2916 Version_t v = b.ReadVersion(&R__s, &R__c);
2917 if (v > 9) {
2918 b.ReadClassBuffer(TBranch::Class(), this, v, R__s, R__c);
2919
2920 if (fWriteBasket>=fBaskets.GetSize()) {
2922 }
2923 fDirectory = 0;
2925 for (Int_t i=0;i<fNleaves;i++) {
2926 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(i);
2927 leaf->SetBranch(this);
2928 }
2929 auto nbranches = fBranches.GetEntriesFast();
2930 for (Int_t i=0;i<nbranches;i++) {
2932 br->fParent = this;
2933 }
2934
2935 fNBaskets = 0;
2936 for (Int_t j = fWriteBasket; j>=0; --j) {
2938 if (bk) {
2939 bk->SetBranch(this);
2940 // GetTree()->IncrementTotalBuffers(bk->GetBufferSize());
2941 ++fNBaskets;
2942 }
2943 }
2944 if (fWriteBasket >= fMaxBaskets) {
2945 //old versions may need this fix
2950
2951 }
2953 gROOT->SetReadingObject(kFALSE);
2954 if (IsA() == TBranch::Class()) {
2955 if (fNleaves == 0) {
2957 } else if (fNleaves == 1) {
2959 } else if (fNleaves == 2) {
2961 } else {
2963 }
2964 }
2965 return;
2966 }
2967 //====process old versions before automatic schema evolution
2968 Int_t n,i,j,ijunk;
2969 if (v > 5) {
2970 Stat_t djunk;
2972 if (v > 7) TAttFill::Streamer(b);
2973 b >> fCompress;
2974 b >> fBasketSize;
2975 b >> fEntryOffsetLen;
2976 b >> fWriteBasket;
2977 b >> ijunk; fEntryNumber = (Long64_t)ijunk;
2978 b >> fOffset;
2979 b >> fMaxBaskets;
2980 if (v > 6) b >> fSplitLevel;
2981 b >> djunk; fEntries = (Long64_t)djunk;
2982 b >> djunk; fTotBytes = (Long64_t)djunk;
2983 b >> djunk; fZipBytes = (Long64_t)djunk;
2984
2991 Char_t isArray;
2992 b >> isArray;
2993 b.ReadFastArray(fBasketBytes,fMaxBaskets);
2994 b >> isArray;
2995 for (i=0;i<fMaxBaskets;i++) {b >> ijunk; fBasketEntry[i] = ijunk;}
2996 b >> isArray;
2997 for (i=0;i<fMaxBaskets;i++) {
2998 if (isArray == 2) b >> fBasketSeek[i];
2999 else {Int_t bsize; b >> bsize; fBasketSeek[i] = (Long64_t)bsize;};
3000 }
3002 b.CheckByteCount(R__s, R__c, TBranch::IsA());
3003 fDirectory = 0;
3005 for (i=0;i<fNleaves;i++) {
3006 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(i);
3007 leaf->SetBranch(this);
3008 }
3009 fNBaskets = 0;
3010 for (j = fWriteBasket; j >= 0; --j) {
3012 if (bk) {
3013 bk->SetBranch(this);
3014 //GetTree()->IncrementTotalBuffers(bk->GetBufferSize());
3015 ++fNBaskets;
3016 }
3017 }
3018 if (fWriteBasket >= fMaxBaskets) {
3019 //old versions may need this fix
3024
3025 }
3026 // Check Byte Count is not needed since it was done in ReadBuffer
3028 gROOT->SetReadingObject(kFALSE);
3029 b.CheckByteCount(R__s, R__c, TBranch::IsA());
3030 if (IsA() == TBranch::Class()) {
3031 if (fNleaves == 0) {
3033 } else if (fNleaves == 1) {
3035 } else if (fNleaves == 2) {
3037 } else {
3039 }
3040 }
3041 return;
3042 }
3043 //====process very old versions
3044 Stat_t djunk;
3046 b >> fCompress;
3047 b >> fBasketSize;
3048 b >> fEntryOffsetLen;
3049 b >> fMaxBaskets;
3050 b >> fWriteBasket;
3051 b >> ijunk; fEntryNumber = (Long64_t)ijunk;
3052 b >> djunk; fEntries = (Long64_t)djunk;
3053 b >> djunk; fTotBytes = (Long64_t)djunk;
3054 b >> djunk; fZipBytes = (Long64_t)djunk;
3055 b >> fOffset;
3059 for (i=0;i<fNleaves;i++) {
3060 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(i);
3061 leaf->SetBranch(this);
3062 }
3064 for (j = fWriteBasket; j > 0; --j) {
3066 if (bk) {
3067 bk->SetBranch(this);
3068 //GetTree()->IncrementTotalBuffers(bk->GetBufferSize());
3069 }
3070 }
3072 b >> n;
3073 for (i=0;i<n;i++) {b >> ijunk; fBasketEntry[i] = ijunk;}
3075 if (v > 4) {
3076 n = b.ReadArray(fBasketBytes);
3077 } else {
3078 for (n=0;n<fMaxBaskets;n++) fBasketBytes[n] = 0;
3079 }
3080 if (v < 2) {
3082 for (n=0;n<fWriteBasket;n++) {
3083 TBasket *basket = GetBasketImpl(n, nullptr);
3084 fBasketSeek[n] = basket ? basket->GetSeekKey() : 0;
3085 }
3086 } else {
3088 b >> n;
3089 for (n=0;n<fMaxBaskets;n++) {
3090 Int_t aseek;
3091 b >> aseek;
3092 fBasketSeek[n] = Long64_t(aseek);
3093 }
3094 }
3095 if (v > 2) {
3097 }
3098 fDirectory = 0;
3099 if (v < 4) SetAutoDelete(kTRUE);
3101 gROOT->SetReadingObject(kFALSE);
3102 b.CheckByteCount(R__s, R__c, TBranch::IsA());
3103 //====end of old versions
3104 if (IsA() == TBranch::Class()) {
3105 if (fNleaves == 0) {
3107 } else if (fNleaves == 1) {
3109 } else if (fNleaves == 2) {
3111 } else {
3113 }
3114 }
3115 } else {
3116 Int_t maxBaskets = fMaxBaskets;
3118 Int_t lastBasket = fMaxBaskets;
3119 if (fMaxBaskets < 10) fMaxBaskets = 10;
3120
3121 TBasket **stash = new TBasket *[lastBasket];
3122 for (Int_t i = 0; i < lastBasket; ++i) {
3123 TBasket *ba = (TBasket *)fBaskets.UncheckedAt(i);
3124 if (ba && (fBasketBytes[i] || ba->GetNevBuf()==0)) {
3125 // Already on disk or empty.
3126 stash[i] = ba;
3127 fBaskets[i] = nullptr;
3128 } else {
3129 stash[i] = nullptr;
3130 }
3131 }
3132
3133 b.WriteClassBuffer(TBranch::Class(), this);
3134
3135 for (Int_t i = 0; i < lastBasket; ++i) {
3136 if (stash[i]) fBaskets[i] = stash[i];
3137 }
3138
3139 delete[] stash;
3140 fMaxBaskets = maxBaskets;
3141 }
3142}
3143
3144////////////////////////////////////////////////////////////////////////////////
3145/// Write the current basket to disk and return the number of bytes
3146/// written to the file.
3147
3149{
3150 Int_t nevbuf = basket->GetNevBuf();
3151 if (fEntryOffsetLen > 10 && (4*nevbuf) < fEntryOffsetLen ) {
3152 // Make sure that the fEntryOffset array does not stay large unnecessarily.
3153 fEntryOffsetLen = nevbuf < 3 ? 10 : 4*nevbuf; // assume some fluctuations.
3154 } else if (fEntryOffsetLen && nevbuf > fEntryOffsetLen) {
3155 // Increase the array ...
3156 fEntryOffsetLen = 2*nevbuf; // assume some fluctuations.
3157 }
3158
3159 // Note: captures `basket`, `where`, and `this` by value; modifies the TBranch and basket,
3160 // as we make a copy of the pointer. We cannot capture `basket` by reference as the pointer
3161 // itself might be modified after `WriteBasketImpl` exits.
3162 auto doUpdates = [this, basket, where]() {
3163 Int_t nout = basket->WriteBuffer(); // Write buffer
3164 if (nout < 0)
3165 Error("WriteBasketImpl", "basket's WriteBuffer failed.");
3166 fBasketBytes[where] = basket->GetNbytes();
3167 fBasketSeek[where] = basket->GetSeekKey();
3168 Int_t addbytes = basket->GetObjlen() + basket->GetKeylen();
3169 TBasket *reusebasket = 0;
3170 if (nout>0) {
3171 // The Basket was written so we can now safely reuse it.
3172 fBaskets[where] = 0;
3173
3174 reusebasket = basket;
3175 reusebasket->WriteReset();
3176
3177 fZipBytes += nout;
3178 fTotBytes += addbytes;
3179 fTree->AddTotBytes(addbytes);
3180 fTree->AddZipBytes(nout);
3181#ifdef R__TRACK_BASKET_ALLOC_TIME
3182 fTree->AddAllocationTime(reusebasket->GetResetAllocationTime());
3183#endif
3185 }
3186
3187 if (where==fWriteBasket) {
3188 ++fWriteBasket;
3189 if (fWriteBasket >= fMaxBaskets) {
3191 }
3192 if (reusebasket && reusebasket == fCurrentBasket) {
3193 // The 'current' basket has Reset, so if we need it we will need
3194 // to reload it.
3195 fCurrentBasket = 0;
3196 fFirstBasketEntry = -1;
3197 fNextBasketEntry = -1;
3198 }
3201 } else {
3202 --fNBaskets;
3203 fBaskets[where] = 0;
3204 basket->DropBuffers();
3205 if (basket == fCurrentBasket) {
3206 fCurrentBasket = 0;
3207 fFirstBasketEntry = -1;
3208 fNextBasketEntry = -1;
3209 }
3210 delete basket;
3211 }
3212 return nout;
3213 };
3214 if (imtHelper) {
3215 imtHelper->Run(doUpdates);
3216 return 0;
3217 } else {
3218 return doUpdates();
3219 }
3220}
3221
3222////////////////////////////////////////////////////////////////////////////////
3223///set the first entry number (case of TBranchSTL)
3224
3226{
3227 fFirstEntry = entry;
3228 fEntries = 0;
3229 fEntryNumber = entry;
3230 if( fBasketEntry )
3231 fBasketEntry[0] = entry;
3232 for( Int_t i = 0; i < fBranches.GetEntriesFast(); ++i )
3233 ((TBranch*)fBranches[i])->SetFirstEntry( entry );
3234}
3235
3236////////////////////////////////////////////////////////////////////////////////
3237/// If the branch address is not set, we set all addresses starting with
3238/// the top level parent branch.
3239
3241{
3242 SetAddress(nullptr); // in some cases, this triggers setting of the address
3243}
3244
3245////////////////////////////////////////////////////////////////////////////////
3246/// Refresh the value of fDirectory (i.e. where this branch writes/reads its buffers)
3247/// with the current value of fTree->GetCurrentFile unless this branch has been
3248/// redirected to a different file. Also update the sub-branches.
3249
3251{
3253 if (fFileName.Length() == 0) {
3254 fDirectory = file;
3255
3256 // Apply to all existing baskets.
3257 TIter nextb(GetListOfBaskets());
3258 TBasket *basket;
3259 while ((basket = (TBasket*)nextb())) {
3260 basket->SetParent(file);
3261 }
3262 }
3263
3264 // Apply to sub-branches as well.
3265 TIter next(GetListOfBranches());
3266 TBranch *branch;
3267 while ((branch = (TBranch*)next())) {
3268 branch->UpdateFile();
3269 }
3270}
void tobuf(char *&buf, Bool_t x)
Definition Bytes.h:55
#define R__likely(expr)
Definition RConfig.hxx:602
#define R__unlikely(expr)
Definition RConfig.hxx:601
#define b(i)
Definition RSha256.hxx:100
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
short Version_t
Definition RtypesCore.h:65
char Char_t
Definition RtypesCore.h:37
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:124
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
const UInt_t kNewClassTag
const UInt_t kByteCountMask
EDataType
Definition TDataType.h:28
@ kOther_t
Definition TDataType.h:32
#define R__ASSERT(e)
Definition TError.h:117
#define N
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:110
int nentries
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:405
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2481
R__EXTERN TSystem * gSystem
Definition TSystem.h:560
#define R__LOCKGUARD_IMT(mutex)
#define R__LOCKGUARD(mutex)
#define gPad
#define snprintf
Definition civetweb.c:1540
void SetUsed(Int_t basketNumber)
Mark if the basket has been marked as 'used'.
void Print(const char *owner, Long64_t *entries) const
Print the info we have for the baskets.
A helper class for managing IMT work during TTree:Fill operations.
TIOFeatures provides the end-user with the ability to change the IO behavior of data written via a TT...
Fill Area Attributes class.
Definition TAttFill.h:19
virtual void Streamer(TBuffer &)
Manages buffers for branches of a Tree.
Definition TBasket.h:34
void AdoptBuffer(TBuffer *user_buffer)
Adopt a buffer from an external entity.
Definition TBasket.cxx:721
Int_t GetNevBufSize() const
Definition TBasket.h:130
Int_t * GetEntryOffset()
Definition TBasket.h:124
Int_t * GetDisplacement() const
Definition TBasket.h:123
Int_t GetNevBuf() const
Definition TBasket.h:129
void DisownBuffer()
Disown all references to the internal buffer - some other object likely now owns it.
Definition TBasket.cxx:713
void SetBranch(TBranch *branch)
Definition TBasket.h:148
Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file)
Read basket buffers in memory and cleanup.
Definition TBasket.cxx:464
virtual Int_t DropBuffers()
Drop buffers of this basket if it is not the current basket.
Definition TBasket.cxx:173
virtual void PrepareBasket(Long64_t)
Definition TBasket.h:133
virtual void MoveEntries(Int_t dentries)
Remove the first dentries of this basket, moving entries at dentries to the start of the buffer.
Definition TBasket.cxx:310
void SetNevBufSize(Int_t n)
Definition TBasket.h:149
Int_t GetBufferSize() const
Definition TBasket.h:122
virtual void AdjustSize(Int_t newsize)
Increase the size of the current fBuffer up to newsize.
Definition TBasket.cxx:127
virtual void SetReadMode()
Set read mode of basket.
Definition TBasket.cxx:925
virtual void SetWriteMode()
Set write mode of basket.
Definition TBasket.cxx:934
Bool_t GetResetAllocationCount() const
Definition TBasket.h:143
Int_t ReadBasketBytes(Long64_t pos, TFile *file)
Read basket buffers in memory and cleanup.
Definition TBasket.cxx:698
virtual void ReadResetBuffer(Int_t basketnumber)
Reset the read basket TBuffer memory allocation if needed.
Definition TBasket.cxx:733
virtual Int_t WriteBuffer()
Write buffer of this basket on the current file.
Definition TBasket.cxx:1131
virtual void Streamer(TBuffer &)
Stream a class object.
Definition TBasket.cxx:943
Int_t GetLast() const
Definition TBasket.h:131
void Update(Int_t newlast)
Definition TBasket.h:152
virtual void WriteReset()
Reset the write basket to the starting state.
Definition TBasket.cxx:806
A TTree is a list of TBranches.
Definition TBranch.h:89
virtual TLeaf * GetLeaf(const char *name) const
Return pointer to the 1st Leaf named name in thisBranch.
Definition TBranch.cxx:2001
virtual void SetupAddresses()
If the branch address is not set, we set all addresses starting with the top level parent branch.
Definition TBranch.cxx:3240
virtual void ResetAddress()
Reset the address of the branch.
Definition TBranch.cxx:2597
virtual void SetAutoDelete(Bool_t autodel=kTRUE)
Set the automatic delete bit.
Definition TBranch.cxx:2662
TString fFileName
Name of file where buffers are stored ("" if in same file as Tree header)
Definition TBranch.h:145
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any.
Definition TBranch.cxx:1324
TBasket * GetFreshBasket(Int_t basketnumber, TBuffer *user_buffer)
Return a fresh basket by either reusing an existing basket that needs to be drop (according to TTree:...
Definition TBranch.cxx:1840
TBasket * GetBasketImpl(Int_t basket, TBuffer *user_buffer)
Return pointer to basket basketnumber in this Branch.
Definition TBranch.cxx:1226
Int_t fEntryOffsetLen
Initial Length of fEntryOffset table in the basket buffers.
Definition TBranch.h:115
virtual void DeleteBaskets(Option_t *option="")
Loop on all branch baskets.
Definition TBranch.cxx:726
virtual Long64_t GetBasketSeek(Int_t basket) const
Return address of basket in the file.
Definition TBranch.cxx:1302
TBranch()
Default constructor. Used for I/O by default.
Definition TBranch.cxx:87
void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Set compression settings.
Definition TBranch.cxx:2751
const char * GetIconName() const override
Return icon name depending on type of branch.
Definition TBranch.cxx:1332
Int_t BackFill()
Loop on all leaves of this branch to back fill Basket buffer.
Definition TBranch.cxx:680
Int_t fMaxBaskets
Maximum number of Baskets so far.
Definition TBranch.h:121
Long64_t fTotBytes
Total number of bytes in all leaves before compression.
Definition TBranch.h:132
TBuffer * fTransientBuffer
! Pointer to the current transient buffer.
Definition TBranch.h:147
virtual void ReadBasket(TBuffer &b)
Loop on all leaves of this branch to read Basket buffer.
Definition TBranch.cxx:2399
TTree * GetTree() const
Definition TBranch.h:248
static TClass * Class()
FillLeaves_t fFillLeaves
! Pointer to the FillLeaves implementation to use.
Definition TBranch.h:159
virtual TString GetFullName() const
Return the 'full' name of the branch.
Definition TBranch.cxx:1977
@ kAutoDelete
Definition TBranch.h:106
@ kDoNotUseBufferMap
If set, at least one of the entry in the branch will use the buffer's map of classname and objects.
Definition TBranch.h:108
@ kIsClone
To indicate a TBranchClones.
Definition TBranch.h:102
@ kDoNotProcess
Active bit for branches.
Definition TBranch.h:101
TObjArray fLeaves
-> List of leaves of this branch
Definition TBranch.h:135
Int_t GetBasketAndFirst(TBasket *&basket, Long64_t &first, TBuffer *user_buffer)
A helper function to locate the correct basket - and its first entry.
Definition TBranch.cxx:1353
char * fAddress
! Address of 1st leaf (variable or object)
Definition TBranch.h:143
virtual void DropBaskets(Option_t *option="")
Loop on all branch baskets.
Definition TBranch.cxx:757
TObjArray * GetListOfBranches()
Definition TBranch.h:242
virtual TList * GetBrowsables()
Returns (and, if 0, creates) browsable objects for this branch See TVirtualBranchBrowsable::FillListO...
Definition TBranch.cxx:1312
TList * fBrowsables
! List of TVirtualBranchBrowsables used for Browse()
Definition TBranch.h:148
void ReadLeavesImpl(TBuffer &b)
Loop on all leaves of this branch to read Basket buffer.
Definition TBranch.cxx:2407
Int_t fOffset
Offset of this branch.
Definition TBranch.h:120
Long64_t * fBasketEntry
[fMaxBaskets] Table of first entry in each basket
Definition TBranch.h:138
Int_t GetEntriesSerialized(Long64_t N, TBuffer &user_buf)
Definition TBranch.h:181
virtual void SetEntryOffsetLen(Int_t len, Bool_t updateSubBranches=kFALSE)
Update the default value for the branch's fEntryOffsetLen if and only if it was already non zero (and...
Definition TBranch.cxx:2767
void ExpandBasketArrays()
Increase BasketEntry buffer of a minimum of 10 locations and a maximum of 50 per cent of current size...
Definition TBranch.cxx:825
void Init(const char *name, const char *leaflist, Int_t compress)
Definition TBranch.cxx:300
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all leaves of entry and return total number of bytes read.
Definition TBranch.cxx:1652
TIOFeatures GetIOFeatures() const
Returns the IO settings currently in use for this branch.
Definition TBranch.cxx:2201
TClass * IsA() const override
Definition TBranch.h:291
void FillLeavesImpl(TBuffer &b)
Loop on all leaves of this branch to fill Basket buffer.
Definition TBranch.cxx:2442
Long64_t fReadEntry
! Current entry number when reading
Definition TBranch.h:126
virtual void AddBasket(TBasket &b, Bool_t ondisk, Long64_t startEntry)
Add the basket to this branch.
Definition TBranch.cxx:545
void Print(Option_t *option="") const override
Print TBranch parameters.
Definition TBranch.cxx:2287
static void ResetCount()
Static function resetting fgCount.
Definition TBranch.cxx:2620
TBranch * GetSubBranch(const TBranch *br) const
Find the parent branch of child.
Definition TBranch.cxx:2110
ReadLeaves_t fReadLeaves
! Pointer to the ReadLeaves implementation to use.
Definition TBranch.h:157
virtual void SetObject(void *objadd)
Set object this branch is pointing to.
Definition TBranch.cxx:2882
Int_t FlushBaskets()
Flush to disk all the baskets of this branch and any of subbranches.
Definition TBranch.cxx:1136
void ReadLeaves2Impl(TBuffer &b)
Read two leaves without the overhead of a loop.
Definition TBranch.cxx:2433
virtual void SetAddress(void *add)
Set address of this branch.
Definition TBranch.cxx:2628
static Int_t fgCount
! branch counter
Definition TBranch.h:112
virtual void AddLastBasket(Long64_t startEntry)
Add the start entry of the write basket (not yet created)
Definition TBranch.cxx:618
TBasket * GetBasket(Int_t basket)
Definition TBranch.h:209
Int_t fNBaskets
! Number of baskets in memory
Definition TBranch.h:122
void ReadLeaves1Impl(TBuffer &b)
Read one leaf without the overhead of a loop.
Definition TBranch.cxx:2425
Int_t GetBulkEntries(Long64_t, TBuffer &)
Read as many events as possible into the given buffer, using zero-copy mechanisms.
Definition TBranch.cxx:1456
virtual void SetFile(TFile *file=nullptr)
Set file where this branch writes/reads its buffers.
Definition TBranch.cxx:2809
virtual Int_t GetEntryExport(Long64_t entry, Int_t getall, TClonesArray *list, Int_t n)
Read all leaves of an entry and export buffers to real objects in a TClonesArray list.
Definition TBranch.cxx:1708
Long64_t fZipBytes
Total number of bytes in all leaves after compression.
Definition TBranch.h:133
TIOFeatures fIOFeatures
IO features for newly-created baskets.
Definition TBranch.h:119
void Browse(TBrowser *b) override
Browser interface.
Definition TBranch.cxx:699
void SetCompressionAlgorithm(Int_t algorithm=ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
Set compression algorithm.
Definition TBranch.cxx:2709
Bool_t IsAutoDelete() const
Return kTRUE if an existing object in a TBranchObject must be deleted.
Definition TBranch.cxx:2209
virtual TLeaf * FindLeaf(const char *name)
Find the leaf corresponding to the name 'searchname'.
Definition TBranch.cxx:1081
CacheInfo_t fCacheInfo
! Hold info about which basket are in the cache and if they have been retrieved from the cache.
Definition TBranch.h:154
TObjArray * GetListOfBaskets()
Definition TBranch.h:241
virtual void SetBufferAddress(TBuffer *entryBuffer)
Set address of this branch directly from a TBuffer to avoid streaming.
Definition TBranch.cxx:2691
Long64_t GetEntries() const
Definition TBranch.h:247
Int_t fNleaves
! Number of leaves
Definition TBranch.h:124
Int_t fSplitLevel
Branch split level.
Definition TBranch.h:123
Int_t WriteBasketImpl(TBasket *basket, Int_t where, ROOT::Internal::TBranchIMTHelper *)
Write the current basket to disk and return the number of bytes written to the file.
Definition TBranch.cxx:3148
virtual void UpdateFile()
Refresh the value of fDirectory (i.e.
Definition TBranch.cxx:3250
Int_t * fBasketBytes
[fMaxBaskets] Length of baskets on file
Definition TBranch.h:137
Long64_t fNextBasketEntry
! Next entry that will requires us to go to the next basket
Definition TBranch.h:128
virtual ~TBranch()
Destructor.
Definition TBranch.cxx:450
Int_t FillEntryBuffer(TBasket *basket, TBuffer *buf, Int_t &lnew)
Copy the data from fEntryBuffer into the current basket.
Definition TBranch.cxx:935
virtual TFile * GetFile(Int_t mode=0)
Return pointer to the file where branch buffers reside, returns 0 in case branch buffers reside in th...
Definition TBranch.cxx:1799
TObjArray fBranches
-> List of Branches of this branch
Definition TBranch.h:134
virtual void KeepCircular(Long64_t maxEntries)
keep a maximum of fMaxEntries in memory
Definition TBranch.cxx:2229
virtual void ResetAfterMerge(TFileMergeInfo *)
Reset a Branch.
Definition TBranch.cxx:2544
void ReadLeaves0Impl(TBuffer &b)
Read zero leaves without the overhead of a loop.
Definition TBranch.cxx:2418
virtual Bool_t GetMakeClass() const
Return whether this branch is in a mode where the object are decomposed or not (Also known as MakeCla...
Definition TBranch.cxx:2063
TString GetRealFileName() const
Get real file name.
Definition TBranch.cxx:2014
virtual TBranch * FindBranch(const char *name)
Find the immediate sub-branch with passed name.
Definition TBranch.cxx:1035
TDirectory * fDirectory
! Pointer to directory where this branch buffers are stored
Definition TBranch.h:144
void PrintCacheInfo() const
Print the information we have about which basket is currently cached and whether they have been 'used...
Definition TBranch.cxx:2391
TObjArray fBaskets
-> List of baskets of this branch
Definition TBranch.h:136
virtual Int_t LoadBaskets()
Baskets associated to this branch are forced to be in memory.
Definition TBranch.cxx:2255
Bool_t fSkipZip
! After being read, the buffer will not be unzipped.
Definition TBranch.h:151
TBranch * fMother
! Pointer to top-level parent branch in the tree.
Definition TBranch.h:141
Long64_t GetTotBytes(Option_t *option="") const
Return total number of bytes in the branch (excluding current buffer) if option ="*" includes all sub...
Definition TBranch.cxx:2166
virtual Bool_t SetMakeClass(Bool_t decomposeObj=kTRUE)
Set the branch in a mode where the object are decomposed (Also known as MakeClass mode).
Definition TBranch.cxx:2873
TBranch * fParent
! Pointer to parent branch.
Definition TBranch.h:142
Int_t WriteBasket(TBasket *basket, Int_t where)
Definition TBranch.h:171
Int_t FlushOneBasket(UInt_t which)
If we have a write basket in memory and it contains some entries and has not yet been written to disk...
Definition TBranch.cxx:1182
virtual Int_t GetExpectedType(TClass *&clptr, EDataType &type)
Fill expectedClass and expectedType with information on the data type of the object/values contained ...
Definition TBranch.cxx:1780
virtual void SetFirstEntry(Long64_t entry)
set the first entry number (case of TBranchSTL)
Definition TBranch.cxx:3225
Long64_t GetTotalSize(Option_t *option="") const
Return total number of bytes in the branch (including current buffer)
Definition TBranch.cxx:2147
Long64_t GetZipBytes(Option_t *option="") const
Return total number of zip bytes in the branch if option ="*" includes all sub-branches of this branc...
Definition TBranch.cxx:2184
virtual void SetBasketSize(Int_t buffsize)
Set the basket size The function makes sure that the basket size is greater than fEntryOffsetlen.
Definition TBranch.cxx:2675
virtual void Refresh(TBranch *b)
Refresh this branch using new information in b This function is called by TTree::Refresh.
Definition TBranch.cxx:2454
Int_t fWriteBasket
Last basket number written.
Definition TBranch.h:116
Long64_t * fBasketSeek
[fMaxBaskets] Addresses of baskets on file
Definition TBranch.h:139
virtual void SetStatus(Bool_t status=1)
Set branch status to Process or DoNotProcess.
Definition TBranch.cxx:2893
TObjArray * GetListOfLeaves()
Definition TBranch.h:243
virtual void SetEntries(Long64_t entries)
Set the number of entries in this branch.
Definition TBranch.cxx:2784
Int_t fReadBasket
! Current basket number when reading
Definition TBranch.h:125
Long64_t fFirstEntry
Number of the first entry in this branch.
Definition TBranch.h:131
TBasket * fExtraBasket
! Allocated basket not currently holding any data.
Definition TBranch.h:118
virtual Int_t GetRow(Int_t row)
Return all elements of one row unpacked in internal array fValues [Actually just returns 1 (?...
Definition TBranch.cxx:2054
Int_t fBasketSize
Initial Size of Basket Buffer.
Definition TBranch.h:114
Int_t Fill()
Definition TBranch.h:201
virtual void Reset(Option_t *option="")
Reset a Branch.
Definition TBranch.cxx:2503
Long64_t fEntryNumber
Current entry number (last one filled in this branch)
Definition TBranch.h:117
TBranch * GetMother() const
Get our top-level parent branch in the tree.
Definition TBranch.cxx:2073
Int_t fCompress
Compression level and algorithm.
Definition TBranch.h:113
TBuffer * GetTransientBuffer(Int_t size)
Returns the transient buffer currently used by this TBranch for reading/writing baskets.
Definition TBranch.cxx:523
virtual Int_t FillImpl(ROOT::Internal::TBranchIMTHelper *)
Loop on all leaves of this branch to fill Basket buffer.
Definition TBranch.cxx:856
TBuffer * fEntryBuffer
! Buffer used to directly pass the content without streaming
Definition TBranch.h:146
TBasket * fCurrentBasket
! Pointer to the current basket.
Definition TBranch.h:129
Long64_t fFirstBasketEntry
! First entry in the current basket.
Definition TBranch.h:127
void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
Set compression level.
Definition TBranch.cxx:2729
void Streamer(TBuffer &) override
Stream a class object.
Definition TBranch.cxx:2902
Bool_t IsFolder() const override
Return kTRUE if more than one leaf or browsables, kFALSE otherwise.
Definition TBranch.cxx:2217
Long64_t fEntries
Number of entries.
Definition TBranch.h:130
TBasket * GetFreshCluster(TBuffer *user_buffer)
Drops the cluster two behind the current cluster and returns a fresh basket by either reusing or crea...
Definition TBranch.cxx:1899
Bool_t SupportsBulkRead() const
Returns true if this branch supports bulk IO, false otherwise.
Definition TBranch.cxx:1431
TTree * fTree
! Pointer to Tree header
Definition TBranch.h:140
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition TBufferFile.h:47
@ kNotDecompressed
Definition TBufferIO.h:66
Buffer base class used for serializing objects.
Definition TBuffer.h:43
void SetWriteMode()
Set buffer in write mode.
Definition TBuffer.cxx:315
char * GetCurrent() const
Definition TBuffer.h:97
void Expand(Int_t newsize, Bool_t copy=kTRUE)
Expand (or shrink) the I/O buffer to newsize bytes.
Definition TBuffer.cxx:223
virtual Int_t GetBufferDisplacement() const =0
Int_t BufferSize() const
Definition TBuffer.h:98
@ kIsOwner
Definition TBuffer.h:75
void SetBuffer(void *buf, UInt_t bufsiz=0, Bool_t adopt=kTRUE, ReAllocCharFun_t reallocfunc=nullptr)
Sets a new buffer in an existing TBuffer object.
Definition TBuffer.cxx:187
@ kWrite
Definition TBuffer.h:73
@ kRead
Definition TBuffer.h:73
void AutoExpand(Int_t size_needed)
Automatically calculate a new size and expand the buffer to fit at least size_needed.
Definition TBuffer.cxx:158
@ kMinimalSize
Definition TBuffer.h:78
Bool_t IsReading() const
Definition TBuffer.h:86
virtual void ResetMap()=0
void SetBufferOffset(Int_t offset=0)
Definition TBuffer.h:93
virtual Int_t GetMapCount() const =0
void SetReadMode()
Set buffer in read mode.
Definition TBuffer.cxx:302
virtual void WriteBuf(const void *buf, Int_t max)=0
TClass * IsA() const override
Definition TBuffer.h:340
virtual void SetBufferDisplacement()=0
virtual char * ReadString(char *s, Int_t max)=0
Int_t Length() const
Definition TBuffer.h:100
char * Buffer() const
Definition TBuffer.h:96
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
An array of clone (identical) objects.
virtual void RemoveAll(TCollection *col)
Remove all objects in collection col from this collection.
void Browse(TBrowser *b) override
Browse this collection (called by TBrowser).
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
TDirectory::TContext keeps track and restore the current directory.
Definition TDirectory.h:89
Describe directory structure in memory.
Definition TDirectory.h:45
virtual TFile * GetFile() const
Definition TDirectory.h:220
virtual Bool_t IsWritable() const
Definition TDirectory.h:237
A cache when reading files over the network.
virtual void SetSkipZip(Bool_t=kTRUE)
virtual Bool_t IsLearning() const
virtual Int_t LearnBranch(TBranch *, Bool_t=kFALSE)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:51
Int_t GetCompressionSettings() const
Definition TFile.h:398
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4053
virtual Long64_t GetSeekKey() const
Definition TKey.h:89
Int_t GetKeylen() const
Definition TKey.h:84
Int_t GetObjlen() const
Definition TKey.h:87
Int_t GetNbytes() const
Definition TKey.h:86
virtual void SetParent(const TObject *parent)
Set parent in key buffer.
Definition TKey.cxx:1294
TBuffer * GetBufferRef() const
Definition TKey.h:79
A TLeaf for an 8 bit Integer data type.
Definition TLeafB.h:26
A TLeaf for a variable length string.
Definition TLeafC.h:26
static TClass * Class()
A TLeaf for a 24 bit truncated floating point data type.
Definition TLeafD32.h:28
A TLeaf for a 64 bit floating point data type.
Definition TLeafD.h:26
A TLeaf for a 24 bit truncated floating point data type.
Definition TLeafF16.h:27
A TLeaf for a 32 bit floating point data type.
Definition TLeafF.h:26
A TLeaf for a 64 bit Integer data type.
Definition TLeafG.h:27
A TLeaf for an Integer data type.
Definition TLeafI.h:27
A TLeaf for a 64 bit Integer data type.
Definition TLeafL.h:27
A TLeaf for a bool data type.
Definition TLeafO.h:26
A TLeaf for a 16 bit Integer data type.
Definition TLeafS.h:26
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition TLeaf.h:57
virtual Int_t GetLenType() const
Definition TLeaf.h:133
virtual const char * GetTypeName() const
Definition TLeaf.h:139
virtual Int_t GetLen() const
Return the number of effective elements of this leaf, for the current entry.
Definition TLeaf.cxx:404
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
Definition TLeaf.h:121
virtual DeserializeType GetDeserializeType() const
Definition TLeaf.h:117
virtual void ReadBasketExport(TBuffer &, TClonesArray *, Int_t)
Definition TLeaf.h:153
virtual void SetAddress(void *add=nullptr)
Definition TLeaf.h:185
virtual Int_t GetNdata() const
Definition TLeaf.h:136
virtual void FillBasket(TBuffer &b)
Pack leaf elements in Basket output buffer.
Definition TLeaf.cxx:180
TBranch * GetBranch() const
Definition TLeaf.h:116
virtual void SetOffset(Int_t offset=0)
Definition TLeaf.h:164
virtual bool ReadBasketFast(TBuffer &, Long64_t)
Definition TLeaf.h:154
virtual void SetBranch(TBranch *branch)
Definition TLeaf.h:161
virtual void SetUnsigned()
Definition TLeaf.h:166
virtual Int_t GetOffset() const
Definition TLeaf.h:137
virtual void ReadBasket(TBuffer &)
Definition TLeaf.h:152
A doubly linked list.
Definition TList.h:38
static TClass * Class()
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
void Streamer(TBuffer &) override
Stream an object of class TObject.
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
TString fName
Definition TNamed.h:32
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
virtual void Expand(Int_t newSize)
Expand or shrink the array to newSize elements.
void AddAt(TObject *obj, Int_t idx) override
Add object at position ids.
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
void Streamer(TBuffer &) override
Stream all objects in the array to or from the I/O buffer.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:84
TObject * Remove(TObject *obj) override
Remove object from array.
void SetLast(Int_t last)
Set index of last object in array, effectively truncating the array.
TObject * RemoveAt(Int_t idx) override
Remove object at index idx.
Int_t GetLast() const override
Return index of last object in array.
Int_t LowerBound() const
Definition TObjArray.h:91
void Add(TObject *obj) override
Definition TObjArray.h:68
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:956
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:153
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:774
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:525
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:970
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:998
void MakeZombie()
Definition TObject.h:53
void ResetBit(UInt_t f)
Definition TObject.h:200
static void * ReAlloc(void *vp, size_t size)
Reallocate (i.e.
Definition TStorage.cxx:183
static Int_t * ReAllocInt(Int_t *vp, size_t size, size_t oldsize)
Reallocate (i.e.
Definition TStorage.cxx:299
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:421
void ToLower()
Change string to lower-case.
Definition TString.cxx:1170
void Clear()
Clear string without changing its capacity.
Definition TString.cxx:1221
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition TString.cxx:531
const char * Data() const
Definition TString.h:380
TString & Prepend(const char *cs)
Definition TString.h:673
TString & Remove(Ssiz_t pos)
Definition TString.h:685
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1390
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2334
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:636
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1277
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:937
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
Definition TSystem.cxx:954
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1035
Helper class to iterate over cluster of baskets.
Definition TTree.h:267
Long64_t Previous()
Move on to the previous cluster and return the starting entry of this previous cluster.
Definition TTree.cxx:693
Long64_t GetStartEntry()
Definition TTree.h:299
Long64_t Next()
Move on to the next cluster and return the starting entry of this next cluster.
Definition TTree.cxx:649
Long64_t GetNextEntry()
Definition TTree.h:304
A TTree represents a columnar dataset.
Definition TTree.h:79
virtual TVirtualPerfStats * GetPerfStats() const
Definition TTree.h:503
virtual TClusterIterator GetClusterIterator(Long64_t firstentry)
Return an iterator over the cluster of baskets starting at firstentry.
Definition TTree.cxx:5458
void AddAllocationCount(UInt_t count)
Definition TTree.h:334
virtual TObjArray * GetListOfLeaves()
Definition TTree.h:486
TFile * GetCurrentFile() const
Return pointer to the current file.
Definition TTree.cxx:5470
void Draw(Option_t *opt) override
Default Draw method for all objects.
Definition TTree.h:428
virtual void IncrementTotalBuffers(Int_t nbytes)
Definition TTree.h:543
TDirectory * GetDirectory() const
Definition TTree.h:459
TTreeCache * GetReadCache(TFile *file) const
Find and return the TTreeCache registered with the file and which may contain branches for us.
Definition TTree.cxx:6309
virtual TObjArray * GetListOfBranches()
Definition TTree.h:485
virtual void AddZipBytes(Int_t zip)
Definition TTree.h:329
virtual TBasket * CreateBasket(TBranch *)
Create a basket for this tree and given branch.
Definition TTree.cxx:3725
@ kOnlyFlushAtCluster
If set, the branch's buffers will grow until an event cluster boundary is hit, guaranteeing a basket ...
Definition TTree.h:253
@ kCircular
Definition TTree.h:249
virtual Bool_t GetClusterPrefetch() const
Definition TTree.h:454
virtual void AddTotBytes(Int_t tot)
Definition TTree.h:328
virtual Long64_t GetAutoFlush() const
Definition TTree.h:444
virtual Long64_t GetMaxVirtualSize() const
Definition TTree.h:497
This class represents a WWW compatible URL.
Definition TUrl.h:33
const char * GetAnchor() const
Definition TUrl.h:70
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition TUrl.cxx:390
void SetAnchor(const char *anchor)
Definition TUrl.h:86
static Int_t FillListOfBrowsables(TList &list, const TBranch *branch, const TVirtualBranchBrowsable *parent=nullptr)
Askes all registered generators to fill their browsables into the list.
virtual void SetUsed(TBranch *b, size_t basketNumber)=0
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Definition TMathBase.h:347
Definition file.py:1
Definition first.py:1
Definition tree.py:1
@ kUndefined
Undefined compression algorithm (must be kept the last of the list in case a new algorithm is added).
@ kUseMin
Compression level reserved when we are not sure what to use (1 is for the fastest compression)
Definition Compression.h:68
TLine l
Definition textangle.C:4