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 
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,
96  kNoFileCache = BIT(3)
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::NeedConversion
Bool_t NeedConversion()
Definition: TTreeCloner.h:113
TTreeCloner::CompareEntry::operator()
Bool_t operator()(UInt_t i1, UInt_t i2)
Definition: TTreeCloner.cxx:56
TTreeCloner::fBasketBranchNum
UInt_t * fBasketBranchNum
[fMaxBaskets] Index of the branch(es) of the basket.
Definition: TTreeCloner.h:42
TTreeCloner::CompareEntry::CompareEntry
CompareEntry(TTreeCloner *obj)
Definition: TTreeCloner.h:75
TTreeCloner::fToTree
TTree * fToTree
Definition: TTreeCloner.h:36
TTreeCloner::CompareSeek::fObject
TTreeCloner * fObject
Definition: TTreeCloner.h:66
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
TTreeCloner::~TTreeCloner
virtual ~TTreeCloner()
TTreeCloner destructor.
Definition: TTreeCloner.cxx:217
TTreeCloner::fMaxBaskets
UInt_t fMaxBaskets
Definition: TTreeCloner.h:41
Option_t
const char Option_t
Definition: RtypesCore.h:66
TTreeCloner::CollectBaskets
void CollectBaskets()
Collect the information about the on-file basket that need to be copied.
Definition: TTreeCloner.cxx:419
UShort_t
unsigned short UShort_t
Definition: RtypesCore.h:40
TTreeCloner::fNeedConversion
Bool_t fNeedConversion
True if the fast merge is not possible but a slow merge might possible.
Definition: TTreeCloner.h:33
TTreeCloner::TTreeCloner
TTreeCloner(const TTreeCloner &)=delete
TTreeCloner::operator=
TTreeCloner & operator=(const TTreeCloner &)=delete
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TTreeCloner::CopyMemoryBaskets
void CopyMemoryBaskets()
Transfer the basket from the input file to the output file.
Definition: TTreeCloner.cxx:481
TTreeCloner::GetWarning
const char * GetWarning() const
Definition: TTreeCloner.h:110
TTree
A TTree represents a columnar dataset.
Definition: TTree.h:79
TTreeCloner::RestoreCache
void RestoreCache()
Restore the TFileCacheRead to its previous value.
Definition: TTreeCloner.cxx:580
Int_t
int Int_t
Definition: RtypesCore.h:45
TTreeCloner::fBasketIndex
UInt_t * fBasketIndex
[fMaxBaskets] ordered list of basket indices to be written.
Definition: TTreeCloner.h:47
TTreeCloner::ImportClusterRanges
void ImportClusterRanges()
Set the entries and import the cluster range of the.
Definition: TTreeCloner.cxx:591
TTreeCloner::fPrevCache
TFileCacheRead * fPrevCache
Cache that set before the TTreeCloner ctor for the 'from' TTree if any.
Definition: TTreeCloner.h:56
TTreeCloner::fBasketEntry
Long64_t * fBasketEntry
[fMaxBaskets] list of basket start entries.
Definition: TTreeCloner.h:46
TTreeCloner::EClonerOptions
EClonerOptions
Definition: TTreeCloner.h:92
TTreeCloner::fFromTree
TTree * fFromTree
Definition: TTreeCloner.h:35
TString
Basic string class.
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
bool
TTreeCloner::CreateCache
void CreateCache()
Create a TFileCacheRead if it was requested.
Definition: TTreeCloner.cxx:561
TTreeCloner::kDefault
@ kDefault
Definition: TTreeCloner.h:59
TTreeCloner::kSortBasketsByEntry
@ kSortBasketsByEntry
Definition: TTreeCloner.h:62
TTreeCloner::fToStartEntries
Long64_t fToStartEntries
Number of entries in the target tree before any addition.
Definition: TTreeCloner.h:52
TBranch
A TTree is a list of TBranches.
Definition: TBranch.h:89
TTreeCloner::CompareSeek::operator()
Bool_t operator()(UInt_t i1, UInt_t i2)
Definition: TTreeCloner.cxx:43
TTreeCloner::fFileCache
TFileCacheRead * fFileCache
File Cache used to reduce the number of individual reads.
Definition: TTreeCloner.h:55
TTreeCloner
Class implementing or helping the various TTree cloning method.
Definition: TTreeCloner.h:29
TTreeCloner::SortBaskets
void SortBaskets()
Sort the basket according to the user request.
Definition: TTreeCloner.cxx:632
TTreeCloner::FillCache
UInt_t FillCache(UInt_t from)
Fill the file cache with the next set of basket.
Definition: TTreeCloner.cxx:660
BIT
#define BIT(n)
Definition: Rtypes.h:85
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TTreeCloner::IsValid
Bool_t IsValid()
Definition: TTreeCloner.h:112
TTreeCloner::fCloneMethod
UInt_t fCloneMethod
Indicates which cloning method was selected.
Definition: TTreeCloner.h:51
TTreeCloner::CloseOutWriteBaskets
void CloseOutWriteBaskets()
Before we can start adding new basket, we need to flush to disk the partially filled baskets (the Wri...
Definition: TTreeCloner.cxx:233
TTreeCloner::fMethod
Option_t * fMethod
Definition: TTreeCloner.h:37
unsigned int
TFileCacheRead
A cache when reading files over the network.
Definition: TFileCacheRead.h:22
TTreeCloner::kSortBasketsByBranch
@ kSortBasketsByBranch
Definition: TTreeCloner.h:60
TTreeCloner::CopyStreamerInfos
void CopyStreamerInfos()
Make sure that all the needed TStreamerInfo are present in the output file.
Definition: TTreeCloner.cxx:440
TTreeCloner::fFromBranches
TObjArray fFromBranches
Definition: TTreeCloner.h:38
TTreeCloner::fIsValid
Bool_t fIsValid
Definition: TTreeCloner.h:32
TTreeCloner::fWarningMsg
TString fWarningMsg
Text of the error message lead to an 'invalid' state.
Definition: TTreeCloner.h:30
TTreeCloner::ECloneMethod
ECloneMethod
Definition: TTreeCloner.h:58
TTreeCloner::kNone
@ kNone
Definition: TTreeCloner.h:93
TObjArray.h
TTreeCloner::fBasketSeek
Long64_t * fBasketSeek
[fMaxBaskets] list of basket position to be read.
Definition: TTreeCloner.h:45
TTreeCloner::CompareSeek::CompareSeek
CompareSeek(TTreeCloner *obj)
Definition: TTreeCloner.h:68
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TTreeCloner::CopyProcessIds
void CopyProcessIds()
Make sure that all the needed TStreamerInfo are present in the output file.
Definition: TTreeCloner.cxx:508
TTreeCloner::fCacheSize
Int_t fCacheSize
Requested size of the file cache.
Definition: TTreeCloner.h:54
TTreeCloner::CompareSeek
Definition: TTreeCloner.h:65
TTreeCloner::kIgnoreMissingTopLevel
@ kIgnoreMissingTopLevel
Definition: TTreeCloner.h:95
TTreeCloner::kNoFileCache
@ kNoFileCache
Definition: TTreeCloner.h:96
TTreeCloner::fToBranches
TObjArray fToBranches
Definition: TTreeCloner.h:39
TTreeCloner::WriteBaskets
void WriteBaskets()
Transfer the basket from the input file to the output file.
Definition: TTreeCloner.cxx:687
TTreeCloner::kSortBasketsByOffset
@ kSortBasketsByOffset
Definition: TTreeCloner.h:61
TTreeCloner::fPidOffset
UShort_t fPidOffset
Offset to be added to the copied key/basket.
Definition: TTreeCloner.h:49
TTreeCloner::CompareEntry::fObject
TTreeCloner * fObject
Definition: TTreeCloner.h:73
TTreeCloner::CollectBranches
UInt_t CollectBranches()
Fill the array of branches, matching the branches of the 'from' and 'to' TTrees Returns the total num...
Definition: TTreeCloner.cxx:398
TTreeCloner::Exec
Bool_t Exec()
Execute the cloning.
Definition: TTreeCloner.cxx:195
TTreeCloner::SetCacheSize
void SetCacheSize(Int_t size)
Set the TFile cache size to be used.
Definition: TTreeCloner.cxx:614
TTreeCloner::fBasketNum
UInt_t * fBasketNum
[fMaxBaskets] index of the basket within the branch.
Definition: TTreeCloner.h:43
TTreeCloner::kNoWarnings
@ kNoWarnings
Definition: TTreeCloner.h:94
int
TTreeCloner::fOptions
UInt_t fOptions
Definition: TTreeCloner.h:34
TTreeCloner::CompareEntry
Definition: TTreeCloner.h:72