Logo ROOT   6.07/09
Reference Guide
TTreeCloner.h
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Philippe Canal 07/11/2005
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 #ifndef ROOT_TTreeCloner
13 #define ROOT_TTreeCloner
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TTreeCloner //
18 // //
19 // Class implementing or helping the various TTree cloning method //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #ifndef ROOT_TObjArray
24 #include "TObjArray.h"
25 #endif
26 
27 #include <vector>
28 
29 #ifdef R__OLDHPACC
30 namespace std {
31  using ::string;
32  using ::vector;
33 }
34 #endif
35 
36 class TBranch;
37 class TTree;
38 class TFileCacheRead;
39 
40 class TTreeCloner {
41  TString fWarningMsg; ///< Text of the error message lead to an 'invalid' state
42 
44  Bool_t fNeedConversion; ///< True if the fast merge is not possible but a slow merge might possible.
51 
53  UInt_t *fBasketBranchNum; ///<[fMaxBaskets] Index of the branch(es) of the basket.
54  UInt_t *fBasketNum; ///<[fMaxBaskets] index of the basket within the branch.
55 
56  Long64_t *fBasketSeek; ///<[fMaxBaskets] list of basket position to be read.
57  Long64_t *fBasketEntry; ///<[fMaxBaskets] list of basket start entries.
58  UInt_t *fBasketIndex; ///<[fMaxBaskets] ordered list of basket indices to be written.
59 
60  UShort_t fPidOffset; ///< Offset to be added to the copied key/basket.
61 
62  UInt_t fCloneMethod; ///< Indicates which cloning method was selected.
63  Long64_t fToStartEntries; ///< Number of entries in the target tree before any addition.
64 
65  Int_t fCacheSize; ///< Requested size of the file cache
66  TFileCacheRead *fFileCache; ///< File Cache used to reduce the number of individual reads
67  TFileCacheRead *fPrevCache; ///< Cache that set before the TTreeCloner ctor for the 'from' TTree if any.
68 
69  enum ECloneMethod {
70  kDefault = 0,
71  kSortBasketsByBranch = 1,
72  kSortBasketsByOffset = 2,
73  kSortBasketsByEntry = 3
74  };
75 
76  class CompareSeek {
78  public:
79  CompareSeek(TTreeCloner *obj) : fObject(obj) {}
80  Bool_t operator()(UInt_t i1, UInt_t i2);
81  };
82 
83  class CompareEntry {
85  public:
86  CompareEntry(TTreeCloner *obj) : fObject(obj) {}
87  Bool_t operator()(UInt_t i1, UInt_t i2);
88  };
89 
90  friend class CompareSeek;
91  friend class CompareEntry;
92 
93  void ImportClusterRanges();
94  void CreateCache();
95  UInt_t FillCache(UInt_t from);
96  void RestoreCache();
97 
98 private:
99  TTreeCloner(const TTreeCloner&) = delete;
100  TTreeCloner &operator=(const TTreeCloner&) = delete;
101 
102 public:
104  kNone = 0,
105  kNoWarnings = BIT(1),
106  kIgnoreMissingTopLevel = BIT(2),
107  kNoFileCache = BIT(3)
108  };
109 
110  TTreeCloner(TTree *from, TTree *to, Option_t *method, UInt_t options = kNone);
111  virtual ~TTreeCloner();
112 
113  void CloseOutWriteBaskets();
114  UInt_t CollectBranches(TBranch *from, TBranch *to);
115  UInt_t CollectBranches(TObjArray *from, TObjArray *to);
116  UInt_t CollectBranches();
117  void CollectBaskets();
118  void CopyMemoryBaskets();
119  void CopyStreamerInfos();
120  void CopyProcessIds();
121  const char *GetWarning() const { return fWarningMsg; }
122  Bool_t Exec();
123  Bool_t IsValid() { return fIsValid; }
124  Bool_t NeedConversion() { return fNeedConversion; }
125  void SetCacheSize(Int_t size);
126  void SortBaskets();
127  void WriteBaskets();
128 
129  ClassDef(TTreeCloner,0); // helper used for the fast cloning of TTrees.
130 };
131 
132 #endif
UInt_t * fBasketIndex
[fMaxBaskets] ordered list of basket indices to be written.
Definition: TTreeCloner.h:58
An array of TObjects.
Definition: TObjArray.h:39
Long64_t * fBasketEntry
[fMaxBaskets] list of basket start entries.
Definition: TTreeCloner.h:57
long long Long64_t
Definition: RtypesCore.h:69
A cache when reading files over the network.
const char Option_t
Definition: RtypesCore.h:62
unsigned short UShort_t
Definition: RtypesCore.h:36
Long64_t fToStartEntries
Number of entries in the target tree before any addition.
Definition: TTreeCloner.h:63
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
STL namespace.
Bool_t NeedConversion()
Definition: TTreeCloner.h:124
CompareEntry(TTreeCloner *obj)
Definition: TTreeCloner.h:86
UInt_t fMaxBaskets
Definition: TTreeCloner.h:52
#define ClassDef(name, id)
Definition: Rtypes.h:254
TFileCacheRead * fPrevCache
Cache that set before the TTreeCloner ctor for the &#39;from&#39; TTree if any.
Definition: TTreeCloner.h:67
Bool_t IsValid()
Definition: TTreeCloner.h:123
TTree * fFromTree
Definition: TTreeCloner.h:46
unsigned int UInt_t
Definition: RtypesCore.h:42
const Handle_t kNone
Definition: GuiTypes.h:89
TObjArray fToBranches
Definition: TTreeCloner.h:50
TTreeCloner * fObject
Definition: TTreeCloner.h:77
UInt_t * fBasketNum
[fMaxBaskets] index of the basket within the branch.
Definition: TTreeCloner.h:54
UInt_t fOptions
Definition: TTreeCloner.h:45
const char * GetWarning() const
Definition: TTreeCloner.h:121
UShort_t fPidOffset
Offset to be added to the copied key/basket.
Definition: TTreeCloner.h:60
TFileCacheRead * fFileCache
File Cache used to reduce the number of individual reads.
Definition: TTreeCloner.h:66
#define BIT(n)
Definition: Rtypes.h:120
UInt_t fCloneMethod
Indicates which cloning method was selected.
Definition: TTreeCloner.h:62
UInt_t * fBasketBranchNum
[fMaxBaskets] Index of the branch(es) of the basket.
Definition: TTreeCloner.h:53
Class implementing or helping the various TTree cloning method.
Definition: TTreeCloner.h:40
Bool_t fNeedConversion
True if the fast merge is not possible but a slow merge might possible.
Definition: TTreeCloner.h:44
A TTree object has a header with a name and a title.
Definition: TTree.h:98
TString fWarningMsg
Text of the error message lead to an &#39;invalid&#39; state.
Definition: TTreeCloner.h:41
TTree * fToTree
Definition: TTreeCloner.h:47
A TTree is a list of TBranches.
Definition: TBranch.h:58
CompareSeek(TTreeCloner *obj)
Definition: TTreeCloner.h:79
Long64_t * fBasketSeek
[fMaxBaskets] list of basket position to be read.
Definition: TTreeCloner.h:56
Option_t * fMethod
Definition: TTreeCloner.h:48
Int_t fCacheSize
Requested size of the file cache.
Definition: TTreeCloner.h:65
TObjArray fFromBranches
Definition: TTreeCloner.h:49
Bool_t fIsValid
Definition: TTreeCloner.h:43