Logo ROOT  
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
25class TBranch;
26class TTree;
27class TFile;
28class TFileCacheRead;
29class TDirectory;
30
32 TString fWarningMsg; ///< Text of the error message lead to an 'invalid' state
33
35 Bool_t fNeedConversion; ///< True if the fast merge is not possible but a slow merge might possible.
44
46 UInt_t *fBasketBranchNum; ///<[fMaxBaskets] Index of the branch(es) of the basket.
47 UInt_t *fBasketNum; ///<[fMaxBaskets] index of the basket within the branch.
48
49 Long64_t *fBasketSeek; ///<[fMaxBaskets] list of basket position to be read.
50 Long64_t *fBasketEntry; ///<[fMaxBaskets] list of basket start entries.
51 UInt_t *fBasketIndex; ///<[fMaxBaskets] ordered list of basket indices to be written.
52
53 UShort_t fPidOffset; ///< Offset to be added to the copied key/basket.
54
55 UInt_t fCloneMethod; ///< Indicates which cloning method was selected.
56 Long64_t fToStartEntries; ///< Number of entries in the target tree before any addition.
57
58 Int_t fCacheSize; ///< Requested size of the file cache
59 TFileCacheRead *fFileCache; ///< File Cache used to reduce the number of individual reads
60 TFileCacheRead *fPrevCache; ///< Cache that set before the TTreeCloner ctor for the 'from' TTree if any.
61
67 };
68
71 public:
74 };
75
78 public:
81 };
82
83 friend class CompareSeek;
84 friend class CompareEntry;
85
87 void CreateCache();
89 void RestoreCache();
90
91private:
92 TTreeCloner(const TTreeCloner&) = delete;
94
95 TTreeCloner(TTree *from, TTree *to, TDirectory *newdirectory, Option_t *method, UInt_t options = kNone);
96
97public:
99 kNone = 0,
102 kNoFileCache = BIT(3)
103 };
104
105 TTreeCloner(TTree *from, TTree *to, Option_t *method, UInt_t options = kNone);
106 TTreeCloner(TTree *from, TDirectory *newdirectory, Option_t *method, UInt_t options = kNone);
107 virtual ~TTreeCloner();
108
113 void CollectBaskets();
114 void CopyMemoryBaskets();
115 void CopyStreamerInfos();
116 void CopyProcessIds();
117 const char *GetWarning() const { return fWarningMsg; }
118 Bool_t IsInPlace() const { return fFromTree == fToTree; }
119 Bool_t Exec();
120 Bool_t IsValid() { return fIsValid; }
122 void SetCacheSize(Int_t size);
123 void SortBaskets();
124 void WriteBaskets();
125
126 ClassDef(TTreeCloner,0); // helper used for the fast cloning of TTrees.
127};
128
129#endif
unsigned short UShort_t
Definition: RtypesCore.h:38
int Int_t
Definition: RtypesCore.h:43
unsigned int UInt_t
Definition: RtypesCore.h:44
bool Bool_t
Definition: RtypesCore.h:61
long long Long64_t
Definition: RtypesCore.h:71
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
#define BIT(n)
Definition: Rtypes.h:83
A TTree is a list of TBranches.
Definition: TBranch.h:91
Describe directory structure in memory.
Definition: TDirectory.h:40
A cache when reading files over the network.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:53
An array of TObjects.
Definition: TObjArray.h:37
Basic string class.
Definition: TString.h:131
CompareEntry(TTreeCloner *obj)
Definition: TTreeCloner.h:79
Bool_t operator()(UInt_t i1, UInt_t i2)
Definition: TTreeCloner.cxx:56
CompareSeek(TTreeCloner *obj)
Definition: TTreeCloner.h:72
Bool_t operator()(UInt_t i1, UInt_t i2)
Definition: TTreeCloner.cxx:43
TTreeCloner * fObject
Definition: TTreeCloner.h:70
Class implementing or helping the various TTree cloning method.
Definition: TTreeCloner.h:31
UInt_t * fBasketBranchNum
[fMaxBaskets] Index of the branch(es) of the basket.
Definition: TTreeCloner.h:46
TObjArray fToBranches
Definition: TTreeCloner.h:43
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:38
UInt_t fOptions
Definition: TTreeCloner.h:36
void CollectBaskets()
Collect the information about the on-file basket that need to be copied.
TObjArray fFromBranches
Definition: TTreeCloner.h:42
TTreeCloner & operator=(const TTreeCloner &)=delete
UInt_t * fBasketIndex
[fMaxBaskets] ordered list of basket indices to be written.
Definition: TTreeCloner.h:51
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:101
Bool_t IsValid()
Definition: TTreeCloner.h:120
const char * GetWarning() const
Definition: TTreeCloner.h:117
@ kSortBasketsByOffset
Definition: TTreeCloner.h:65
@ kSortBasketsByEntry
Definition: TTreeCloner.h:66
@ kSortBasketsByBranch
Definition: TTreeCloner.h:64
Option_t * fMethod
Definition: TTreeCloner.h:41
Long64_t * fBasketSeek
[fMaxBaskets] list of basket position to be read.
Definition: TTreeCloner.h:49
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:53
Bool_t fIsValid
Definition: TTreeCloner.h:34
Long64_t * fBasketEntry
[fMaxBaskets] list of basket start entries.
Definition: TTreeCloner.h:50
void CreateCache()
Create a TFileCacheRead if it was requested.
TFileCacheRead * fFileCache
File Cache used to reduce the number of individual reads.
Definition: TTreeCloner.h:59
void CopyProcessIds()
Make sure that all the needed TStreamerInfo are present in the output file.
Bool_t IsInPlace() const
Definition: TTreeCloner.h:118
TTreeCloner(const TTreeCloner &)=delete
TFileCacheRead * fPrevCache
Cache that set before the TTreeCloner ctor for the 'from' TTree if any.
Definition: TTreeCloner.h:60
TTree * fFromTree
Definition: TTreeCloner.h:37
Bool_t fNeedConversion
True if the fast merge is not possible but a slow merge might possible.
Definition: TTreeCloner.h:35
UInt_t fCloneMethod
Indicates which cloning method was selected.
Definition: TTreeCloner.h:55
void RestoreCache()
Restore the TFileCacheRead to its previous value.
TString fWarningMsg
Text of the error message lead to an 'invalid' state.
Definition: TTreeCloner.h:32
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:56
virtual ~TTreeCloner()
TTreeCloner destructor.
UInt_t fMaxBaskets
Definition: TTreeCloner.h:45
TFile * fToFile
Definition: TTreeCloner.h:40
Bool_t NeedConversion()
Definition: TTreeCloner.h:121
Int_t fCacheSize
Requested size of the file cache.
Definition: TTreeCloner.h:58
UInt_t * fBasketNum
[fMaxBaskets] index of the basket within the branch.
Definition: TTreeCloner.h:47
TDirectory * fToDirectory
Definition: TTreeCloner.h:39
void SortBaskets()
Sort the basket according to the user request.
A TTree represents a columnar dataset.
Definition: TTree.h:78