Logo ROOT   master
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 class TBranch;
26 class TTree;
27 class TFileCacheRead;
28 
29 class TTreeCloner {
30  TString fWarningMsg; ///< Text of the error message lead to an 'invalid' state
31 
33  Bool_t fNeedConversion; ///< True if the fast merge is not possible but a slow merge might possible.
40 
42  UInt_t *fBasketBranchNum; ///<[fMaxBaskets] Index of the branch(es) of the basket.
43  UInt_t *fBasketNum; ///<[fMaxBaskets] index of the basket within the branch.
44 
45  Long64_t *fBasketSeek; ///<[fMaxBaskets] list of basket position to be read.
46  Long64_t *fBasketEntry; ///<[fMaxBaskets] list of basket start entries.
47  UInt_t *fBasketIndex; ///<[fMaxBaskets] ordered list of basket indices to be written.
48 
49  UShort_t fPidOffset; ///< Offset to be added to the copied key/basket.
50 
51  UInt_t fCloneMethod; ///< Indicates which cloning method was selected.
52  Long64_t fToStartEntries; ///< Number of entries in the target tree before any addition.
53 
54  Int_t fCacheSize; ///< Requested size of the file cache
55  TFileCacheRead *fFileCache; ///< File Cache used to reduce the number of individual reads
56  TFileCacheRead *fPrevCache; ///< Cache that set before the TTreeCloner ctor for the 'from' TTree if any.
57 
58  enum ECloneMethod {
59  kDefault = 0,
63  };
64 
65  class CompareSeek {
67  public:
70  };
71 
72  class CompareEntry {
74  public:
77  };
78 
79  friend class CompareSeek;
80  friend class CompareEntry;
81 
82  void ImportClusterRanges();
83  void CreateCache();
84  UInt_t FillCache(UInt_t from);
85  void RestoreCache();
86 
87 private:
88  TTreeCloner(const TTreeCloner&) = delete;
89  TTreeCloner &operator=(const TTreeCloner&) = delete;
90 
91 public:
93  kNone = 0,
97  };
98 
99  TTreeCloner(TTree *from, TTree *to, Option_t *method, UInt_t options = kNone);
100  virtual ~TTreeCloner();
101 
102  void CloseOutWriteBaskets();
106  void CollectBaskets();
107  void CopyMemoryBaskets();
108  void CopyStreamerInfos();
109  void CopyProcessIds();
110  const char *GetWarning() const { return fWarningMsg; }
111  Bool_t Exec();
112  Bool_t IsValid() { return fIsValid; }
114  void SetCacheSize(Int_t size);
115  void SortBaskets();
116  void WriteBaskets();
117 
118  ClassDef(TTreeCloner,0); // helper used for the fast cloning of TTrees.
119 };
120 
121 #endif
TTreeCloner(const TTreeCloner &)=delete
UInt_t * fBasketIndex
[fMaxBaskets] ordered list of basket indices to be written.
Definition: TTreeCloner.h:47
An array of TObjects.
Definition: TObjArray.h:37
void ImportClusterRanges()
Set the entries and import the cluster range of the.
const char * GetWarning() const
Definition: TTreeCloner.h:110
void RestoreCache()
Restore the TFileCacheRead to its previous value.
Long64_t * fBasketEntry
[fMaxBaskets] list of basket start entries.
Definition: TTreeCloner.h:46
unsigned int UInt_t
Definition: CPyCppyy.h:44
A cache when reading files over the network.
const char Option_t
Definition: RtypesCore.h:64
void WriteBaskets()
Transfer the basket from the input file to the output file.
unsigned short UShort_t
Definition: RtypesCore.h:38
#define BIT(n)
Definition: Rtypes.h:83
int Int_t
Definition: CPyCppyy.h:43
Long64_t fToStartEntries
Number of entries in the target tree before any addition.
Definition: TTreeCloner.h:52
Basic string class.
Definition: TString.h:131
bool Bool_t
Definition: RtypesCore.h:61
Bool_t NeedConversion()
Definition: TTreeCloner.h:113
CompareEntry(TTreeCloner *obj)
Definition: TTreeCloner.h:75
TTreeCloner & operator=(const TTreeCloner &)=delete
UInt_t fMaxBaskets
Definition: TTreeCloner.h:41
#define ClassDef(name, id)
Definition: Rtypes.h:322
void CloseOutWriteBaskets()
Before we can start adding new basket, we need to flush to disk the partially filled baskets (the Wri...
void SortBaskets()
Sort the basket according to the user request.
TFileCacheRead * fPrevCache
Cache that set before the TTreeCloner ctor for the &#39;from&#39; TTree if any.
Definition: TTreeCloner.h:56
Bool_t IsValid()
Definition: TTreeCloner.h:112
TTree * fFromTree
Definition: TTreeCloner.h:35
void CopyProcessIds()
Make sure that all the needed TStreamerInfo are present in the output file.
void CopyStreamerInfos()
Make sure that all the needed TStreamerInfo are present in the output file.
TObjArray fToBranches
Definition: TTreeCloner.h:39
TTreeCloner * fObject
Definition: TTreeCloner.h:66
Bool_t operator()(UInt_t i1, UInt_t i2)
Definition: TTreeCloner.cxx:55
void CreateCache()
Create a TFileCacheRead if it was requested.
UInt_t CollectBranches()
Fill the array of branches, matching the branches of the &#39;from&#39; and &#39;to&#39; TTrees Returns the total num...
Bool_t Exec()
Execute the cloning.
UInt_t * fBasketNum
[fMaxBaskets] index of the basket within the branch.
Definition: TTreeCloner.h:43
Bool_t operator()(UInt_t i1, UInt_t i2)
Definition: TTreeCloner.cxx:42
UInt_t fOptions
Definition: TTreeCloner.h:34
UInt_t FillCache(UInt_t from)
Fill the file cache with the next set of basket.
UShort_t fPidOffset
Offset to be added to the copied key/basket.
Definition: TTreeCloner.h:49
TFileCacheRead * fFileCache
File Cache used to reduce the number of individual reads.
Definition: TTreeCloner.h:55
UInt_t fCloneMethod
Indicates which cloning method was selected.
Definition: TTreeCloner.h:51
void SetCacheSize(Int_t size)
Set the TFile cache size to be used.
UInt_t * fBasketBranchNum
[fMaxBaskets] Index of the branch(es) of the basket.
Definition: TTreeCloner.h:42
Class implementing or helping the various TTree cloning method.
Definition: TTreeCloner.h:29
Bool_t fNeedConversion
True if the fast merge is not possible but a slow merge might possible.
Definition: TTreeCloner.h:33
A TTree represents a columnar dataset.
Definition: TTree.h:78
TString fWarningMsg
Text of the error message lead to an &#39;invalid&#39; state.
Definition: TTreeCloner.h:30
TTree * fToTree
Definition: TTreeCloner.h:36
A TTree is a list of TBranches.
Definition: TBranch.h:88
CompareSeek(TTreeCloner *obj)
Definition: TTreeCloner.h:68
Long64_t * fBasketSeek
[fMaxBaskets] list of basket position to be read.
Definition: TTreeCloner.h:45
Option_t * fMethod
Definition: TTreeCloner.h:37
virtual ~TTreeCloner()
TTreeCloner destructor.
void CopyMemoryBaskets()
Transfer the basket from the input file to the output file.
void CollectBaskets()
Collect the information about the on-file basket that need to be copied.
Int_t fCacheSize
Requested size of the file cache.
Definition: TTreeCloner.h:54
TObjArray fFromBranches
Definition: TTreeCloner.h:38
Bool_t fIsValid
Definition: TTreeCloner.h:32
long long Long64_t
Definition: cpp_cppyy.h:13