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