00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "TBranchRef.h"
00036 #include "TTree.h"
00037 #include "TBasket.h"
00038 #include "TFile.h"
00039 #include "TFriendElement.h"
00040
00041 ClassImp(TBranchRef)
00042
00043
00044 TBranchRef::TBranchRef(): TBranch()
00045 {
00046
00047
00048 fRefTable = 0;
00049 fReadLeaves = (ReadLeaves_t)&TBranchRef::ReadLeavesImpl;
00050 }
00051
00052
00053
00054 TBranchRef::TBranchRef(TTree *tree)
00055 :TBranch()
00056 {
00057
00058
00059 if (!tree) return;
00060 SetName("TRefTable");
00061 SetTitle("List of branch numbers with referenced objects");
00062 fRefTable = new TRefTable(this,100);
00063
00064 fCompress = 1;
00065 fBasketSize = 32000;
00066 fAddress = 0;
00067 fBasketBytes = new Int_t[fMaxBaskets];
00068 fBasketEntry = new Long64_t[fMaxBaskets];
00069 fBasketSeek = new Long64_t[fMaxBaskets];
00070
00071 for (Int_t i=0;i<fMaxBaskets;i++) {
00072 fBasketBytes[i] = 0;
00073 fBasketEntry[i] = 0;
00074 fBasketSeek[i] = 0;
00075 }
00076
00077 fTree = tree;
00078 fMother = this;
00079 fDirectory = fTree->GetDirectory();
00080 fFileName = "";
00081 fReadLeaves = (ReadLeaves_t)&TBranchRef::ReadLeavesImpl;
00082 }
00083
00084
00085
00086 TBranchRef::~TBranchRef()
00087 {
00088
00089
00090 delete fRefTable;
00091 }
00092
00093
00094 void TBranchRef::Clear(Option_t *option)
00095 {
00096
00097
00098 if (fRefTable) fRefTable->Clear(option);
00099 }
00100
00101
00102 Int_t TBranchRef::Fill()
00103 {
00104
00105
00106 Int_t nbytes = TBranch::Fill();
00107 return nbytes;
00108 }
00109
00110
00111 void TBranchRef::FillLeaves(TBuffer &b)
00112 {
00113
00114
00115 if (!fRefTable) fRefTable = new TRefTable(this,100);
00116 fRefTable->FillBuffer(b);
00117 }
00118
00119
00120 Bool_t TBranchRef::Notify()
00121 {
00122
00123
00124
00125
00126
00127 if (!fRefTable) fRefTable = new TRefTable(this,100);
00128 UInt_t uid = fRefTable->GetUID();
00129 TProcessID* context = fRefTable->GetUIDContext();
00130 GetEntry(fReadEntry);
00131 TBranch *branch = (TBranch*)fRefTable->GetParent(uid, context);
00132 if (branch) {
00133
00134 if (branch->GetReadEntry() != fReadEntry)
00135 branch->GetEntry(fReadEntry);
00136 } else {
00137
00138 TList *friends = fTree->GetListOfFriends();
00139 if (!friends) return kTRUE;
00140 TObjLink *lnk = friends->FirstLink();
00141 while (lnk) {
00142 TFriendElement* elem = (TFriendElement*)lnk->GetObject();
00143 TTree *tree = elem->GetTree();
00144 TBranchRef *bref = tree->GetBranchRef();
00145 if (bref) {
00146 bref->GetEntry(fReadEntry);
00147 branch = (TBranch*)bref->GetRefTable()->GetParent(uid, context);
00148 if (branch) {
00149
00150 if (branch->GetReadEntry() != fReadEntry)
00151 branch->GetEntry(fReadEntry);
00152 return kTRUE;
00153 }
00154 }
00155 lnk = lnk->Next();
00156 }
00157 }
00158 return kTRUE;
00159 }
00160
00161
00162 void TBranchRef::Print(Option_t *option) const
00163 {
00164
00165
00166 TBranch::Print(option);
00167 }
00168
00169
00170 void TBranchRef::ReadLeavesImpl(TBuffer &b)
00171 {
00172
00173
00174 if (!fRefTable) fRefTable = new TRefTable(this,100);
00175 fRefTable->ReadBuffer(b);
00176 }
00177
00178
00179 void TBranchRef::Reset(Option_t *option)
00180 {
00181
00182
00183
00184
00185 TBranch::Reset(option);
00186 if (!fRefTable) fRefTable = new TRefTable(this,100);
00187 fRefTable->Reset();
00188 }
00189
00190
00191 Int_t TBranchRef::SetParent(const TObject* object, Int_t branchID)
00192 {
00193
00194
00195
00196
00197
00198
00199 if (!fRefTable) {
00200 fRefTable = new TRefTable(this, 100);
00201 }
00202 TRefTable::SetRefTable(fRefTable);
00203 return fRefTable->SetParent(object, branchID);
00204 }
00205