ROOT  6.06/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,
74  };
75 
76  class CompareSeek {
78  public:
79  CompareSeek(TTreeCloner *obj) : fObject(obj) {}
81  };
82 
83  class CompareEntry {
85  public:
86  CompareEntry(TTreeCloner *obj) : fObject(obj) {}
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,
108  };
109 
110  TTreeCloner(TTree *from, TTree *to, Option_t *method, UInt_t options = kNone);
111  virtual ~TTreeCloner();
112 
113  void CloseOutWriteBaskets();
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; }
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
TTreeCloner(const TTreeCloner &)=delete
UInt_t * fBasketIndex
Definition: TTreeCloner.h:58
An array of TObjects.
Definition: TObjArray.h:39
void ImportClusterRanges()
Set the entries and import the cluster range of the.
void RestoreCache()
Restore the TFileCacheRead to its previous value.
Long64_t * fBasketEntry
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
void WriteBaskets()
Transfer the basket from the input file to the output file.
unsigned short UShort_t
Definition: RtypesCore.h:36
#define BIT(n)
Definition: Rtypes.h:120
Long64_t fToStartEntries
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
TTreeCloner & operator=(const TTreeCloner &)=delete
ClassDef(TTreeCloner, 0)
UInt_t fMaxBaskets
Definition: TTreeCloner.h:52
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
Definition: TTreeCloner.h:67
Bool_t IsValid()
Definition: TTreeCloner.h:123
TTree * fFromTree
Definition: TTreeCloner.h:46
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.
unsigned int UInt_t
Definition: RtypesCore.h:42
TObjArray fToBranches
Definition: TTreeCloner.h:50
TTreeCloner * fObject
Definition: TTreeCloner.h:77
Bool_t operator()(UInt_t i1, UInt_t i2)
Definition: TTreeCloner.cxx:53
void CreateCache()
Create a TFileCacheRead if it was requested.
UInt_t CollectBranches()
Fill the array of branches, matching the branches of the 'from' and 'to' TTrees Returns the total num...
Bool_t Exec()
Execute the cloning.
UInt_t * fBasketNum
Definition: TTreeCloner.h:54
Bool_t operator()(UInt_t i1, UInt_t i2)
Definition: TTreeCloner.cxx:40
UInt_t fOptions
Definition: TTreeCloner.h:45
UInt_t FillCache(UInt_t from)
Fill the file cache with the next set of basket.
const char * GetWarning() const
Definition: TTreeCloner.h:121
UShort_t fPidOffset
Definition: TTreeCloner.h:60
TFileCacheRead * fFileCache
Definition: TTreeCloner.h:66
UInt_t fCloneMethod
Definition: TTreeCloner.h:62
void SetCacheSize(Int_t size)
Set the TFile cache size to be used.
UInt_t * fBasketBranchNum
Definition: TTreeCloner.h:53
Class implementing or helping the various TTree cloning method.
Definition: TTreeCloner.h:40
Bool_t fNeedConversion
Definition: TTreeCloner.h:44
A TTree object has a header with a name and a title.
Definition: TTree.h:94
TString fWarningMsg
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
Definition: TTreeCloner.h:56
Option_t * fMethod
Definition: TTreeCloner.h:48
TObject * obj
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
Definition: TTreeCloner.h:65
TObjArray fFromBranches
Definition: TTreeCloner.h:49
Bool_t fIsValid
Definition: TTreeCloner.h:43