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