Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 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 Long64_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:
73 bool operator()(UInt_t i1, UInt_t i2);
74 };
75
78 public:
80 bool operator()(UInt_t i1, UInt_t i2);
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 IsInPlace() const { return fFromTree == fToTree; }
119 bool Exec();
120 bool IsValid() { return fIsValid; }
123 void SortBaskets();
124 void WriteBaskets();
125
126 ClassDef(TTreeCloner,0); // helper used for the fast cloning of TTrees.
127};
128
129#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned short UShort_t
Definition RtypesCore.h:40
unsigned int UInt_t
Definition RtypesCore.h:46
long long Long64_t
Definition RtypesCore.h:69
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:90
A TTree is a list of TBranches.
Definition TBranch.h:93
Describe directory structure in memory.
Definition TDirectory.h:45
A cache when reading files over the network.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
An array of TObjects.
Definition TObjArray.h:31
Basic string class.
Definition TString.h:139
CompareEntry(TTreeCloner *obj)
Definition TTreeCloner.h:79
bool operator()(UInt_t i1, UInt_t i2)
bool operator()(UInt_t i1, UInt_t i2)
CompareSeek(TTreeCloner *obj)
Definition TTreeCloner.h:72
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.
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.
Long64_t fCacheSize
Requested size of the file cache.
Definition TTreeCloner.h:58
@ kIgnoreMissingTopLevel
const char * GetWarning() const
@ kSortBasketsByOffset
Definition TTreeCloner.h:65
@ kSortBasketsByEntry
Definition TTreeCloner.h:66
@ kSortBasketsByBranch
Definition TTreeCloner.h:64
bool Exec()
Execute the cloning.
Option_t * fMethod
Definition TTreeCloner.h:41
Long64_t * fBasketSeek
[fMaxBaskets] list of basket position to be read.
Definition TTreeCloner.h:49
void CopyMemoryBaskets()
Transfer the basket from the input file to the output file.
bool fNeedConversion
True if the fast merge is not possible but a slow merge might possible.
Definition TTreeCloner.h:35
UShort_t fPidOffset
Offset to be added to the copied key/basket.
Definition TTreeCloner.h:53
Long64_t * fBasketEntry
[fMaxBaskets] list of basket start entries.
Definition TTreeCloner.h:50
void CreateCache()
Create a TFileCacheRead if it was requested.
ClassDef(TTreeCloner, 0)
TFileCacheRead * fFileCache
File Cache used to reduce the number of individual reads.
Definition TTreeCloner.h:59
bool IsInPlace() const
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:60
TTree * fFromTree
Definition TTreeCloner.h:37
UInt_t fCloneMethod
Indicates which cloning method was selected.
Definition TTreeCloner.h:55
void RestoreCache()
Restore the TFileCacheRead to its previous value.
bool NeedConversion()
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 IsValid()
UInt_t * fBasketNum
[fMaxBaskets] index of the basket within the branch.
Definition TTreeCloner.h:47
void SetCacheSize(Long64_t size)
Set the cache size used by the matching TFile.
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:79