File indexing completed on 2025-01-18 10:12:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TTreeCloner
0013 #define ROOT_TTreeCloner
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include "TObjArray.h"
0024
0025 class TBranch;
0026 class TTree;
0027 class TFile;
0028 class TFileCacheRead;
0029 class TDirectory;
0030
0031 class TTreeCloner {
0032 TString fWarningMsg;
0033
0034 bool fIsValid;
0035 bool fNeedConversion;
0036 UInt_t fOptions;
0037 TTree *fFromTree;
0038 TTree *fToTree;
0039 TDirectory*fToDirectory;
0040 TFile *fToFile;
0041 Option_t *fMethod;
0042 TObjArray fFromBranches;
0043 TObjArray fToBranches;
0044
0045 UInt_t fMaxBaskets;
0046 UInt_t *fBasketBranchNum;
0047 UInt_t *fBasketNum;
0048
0049 Long64_t *fBasketSeek;
0050 Long64_t *fBasketEntry;
0051 UInt_t *fBasketIndex;
0052
0053 UShort_t fPidOffset;
0054
0055 UInt_t fCloneMethod;
0056 Long64_t fToStartEntries;
0057
0058 Int_t fCacheSize;
0059 TFileCacheRead *fFileCache;
0060 TFileCacheRead *fPrevCache;
0061
0062 enum ECloneMethod {
0063 kDefault = 0,
0064 kSortBasketsByBranch = 1,
0065 kSortBasketsByOffset = 2,
0066 kSortBasketsByEntry = 3
0067 };
0068
0069 class CompareSeek {
0070 TTreeCloner *fObject;
0071 public:
0072 CompareSeek(TTreeCloner *obj) : fObject(obj) {}
0073 bool operator()(UInt_t i1, UInt_t i2);
0074 };
0075
0076 class CompareEntry {
0077 TTreeCloner *fObject;
0078 public:
0079 CompareEntry(TTreeCloner *obj) : fObject(obj) {}
0080 bool operator()(UInt_t i1, UInt_t i2);
0081 };
0082
0083 friend class CompareSeek;
0084 friend class CompareEntry;
0085
0086 void ImportClusterRanges();
0087 void CreateCache();
0088 UInt_t FillCache(UInt_t from);
0089 void RestoreCache();
0090
0091 private:
0092 TTreeCloner(const TTreeCloner&) = delete;
0093 TTreeCloner &operator=(const TTreeCloner&) = delete;
0094
0095 TTreeCloner(TTree *from, TTree *to, TDirectory *newdirectory, Option_t *method, UInt_t options = kNone);
0096
0097 public:
0098 enum EClonerOptions {
0099 kNone = 0,
0100 kNoWarnings = BIT(1),
0101 kIgnoreMissingTopLevel = BIT(2),
0102 kNoFileCache = BIT(3)
0103 };
0104
0105 TTreeCloner(TTree *from, TTree *to, Option_t *method, UInt_t options = kNone);
0106 TTreeCloner(TTree *from, TDirectory *newdirectory, Option_t *method, UInt_t options = kNone);
0107 virtual ~TTreeCloner();
0108
0109 void CloseOutWriteBaskets();
0110 UInt_t CollectBranches(TBranch *from, TBranch *to);
0111 UInt_t CollectBranches(TObjArray *from, TObjArray *to);
0112 UInt_t CollectBranches();
0113 void CollectBaskets();
0114 void CopyMemoryBaskets();
0115 void CopyStreamerInfos();
0116 void CopyProcessIds();
0117 const char *GetWarning() const { return fWarningMsg; }
0118 bool IsInPlace() const { return fFromTree == fToTree; }
0119 bool Exec();
0120 bool IsValid() { return fIsValid; }
0121 bool NeedConversion() { return fNeedConversion; }
0122 void SetCacheSize(Int_t size);
0123 void SortBaskets();
0124 void WriteBaskets();
0125
0126 ClassDef(TTreeCloner,0);
0127 };
0128
0129 #endif