51 ClassImp(TBranchElement);
56 void RemovePrefix(TString& str,
const char* prefix) {
58 if (str.Length() && prefix && strlen(prefix)) {
59 if (!str.Index(prefix)) {
60 str.Remove(0, strlen(prefix));
66 TVirtualArray *fOnfileObject;
68 R__PushCache(TBufferFile &b, TVirtualArray *in, UInt_t size) : fBuffer(b), fOnfileObject(in) {
70 fOnfileObject->SetSize(size);
71 fBuffer.PushDataCache( fOnfileObject );
75 if (fOnfileObject) fBuffer.PopDataCache();
83 void TBranchElement::SwitchContainer(TObjArray* branches) {
84 const Int_t nbranches = branches->GetEntriesFast();
85 for (Int_t i = 0; i < nbranches; ++i) {
86 TBranchElement* br = (TBranchElement*) branches->At(i);
87 switch (br->GetType()) {
88 case 31: br->SetType(41);
break;
95 br->SetReadLeavesPtr();
96 br->SetFillLeavesPtr();
98 SwitchContainer(br->GetListOfBranches());
105 Bool_t CanSelfReference(TClass *cl) {
107 if (cl->GetCollectionProxy()) {
108 TClass *inside = cl->GetCollectionProxy()->GetValueClass();
110 return CanSelfReference(inside);
115 const static TClassRef stringClass(
"std::string");
116 if (cl == stringClass || cl == TString::Class()) {
131 TBranchElement::TBranchElement()
143 , fSTLtype(ROOT::kNotSTL)
151 , fInInitInfo(kFALSE)
152 , fInitOffsets(kFALSE)
160 , fReadActionSequence(0)
161 , fFillActionSequence(0)
167 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesImpl;
168 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesImpl;
176 TBranchElement::TBranchElement(TTree *tree,
const char* bname, TStreamerInfo* sinfo, Int_t
id,
char* pointer, Int_t basketsize, Int_t splitlevel, Int_t btype)
178 , fClassName(sinfo->GetName())
182 , fCheckSum(sinfo->GetCheckSum())
183 , fClassVersion(sinfo->GetClass()->GetClassVersion())
188 , fSTLtype(ROOT::kNotSTL)
196 , fInInitInfo(kFALSE)
197 , fInitOffsets(kFALSE)
198 , fTargetClass(fClassName)
201 , fBranchClass(sinfo->GetClass())
205 , fReadActionSequence(0)
206 , fFillActionSequence(0)
212 ROOT::TIOFeatures features = tree->GetIOFeatures();
213 SetIOFeatures(features);
215 Init(tree, 0, bname,sinfo,
id,pointer,basketsize,splitlevel,btype);
223 TBranchElement::TBranchElement(TBranch *parent,
const char* bname, TStreamerInfo* sinfo, Int_t
id,
char* pointer, Int_t basketsize, Int_t splitlevel, Int_t btype)
225 , fClassName(sinfo->GetName())
229 , fCheckSum(sinfo->GetCheckSum())
230 , fClassVersion(sinfo->GetClass()->GetClassVersion())
235 , fSTLtype(ROOT::kNotSTL)
243 , fInInitInfo(kFALSE)
244 , fInitOffsets(kFALSE)
245 , fTargetClass( fClassName )
248 , fBranchClass(sinfo->GetClass())
252 , fReadActionSequence(0)
253 , fFillActionSequence(0)
258 ROOT::TIOFeatures features = parent->GetIOFeatures();
259 SetIOFeatures(features);
260 Init(parent ? parent->GetTree() : 0, parent, bname,sinfo,id,pointer,basketsize,splitlevel,btype);
268 void TBranchElement::Init(TTree *tree, TBranch *parent,
const char* bname, TStreamerInfo* sinfo, Int_t
id,
char* pointer, Int_t basketsize, Int_t splitlevel, Int_t btype)
277 fSplitLevel = splitlevel;
279 if (fTree == 0)
return;
280 fMother = parent ? parent->GetMother() :
this;
282 fDirectory = fTree->GetDirectory();
288 SetAutoDelete(kFALSE);
290 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesImpl;
291 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesImpl;
297 Int_t splitSTLP = splitlevel - (splitlevel%TTree::kSplitCollectionOfPointers);
298 splitlevel %= TTree::kSplitCollectionOfPointers;
301 if (fTree->GetDirectory()) {
302 TFile* bfile = fTree->GetDirectory()->GetFile();
304 fCompress = bfile->GetCompressionSettings();
314 TStreamerElement* element = sinfo->GetElement(
id);
315 fStreamerType = element->GetType();
326 if (btype || (fStreamerType <= TVirtualStreamerInfo::kBase) || (fStreamerType == TVirtualStreamerInfo::kCharStar) || (fStreamerType == TVirtualStreamerInfo::kBits) || (fStreamerType > TVirtualStreamerInfo::kFloat16)) {
327 fEntryOffsetLen = fTree->GetDefaultEntryOffsetLen();
335 if (basketsize < (100 + fEntryOffsetLen)) {
336 basketsize = 100 + fEntryOffsetLen;
338 fBasketSize = basketsize;
344 fBasketBytes =
new Int_t[fMaxBaskets];
345 fBasketEntry =
new Long64_t[fMaxBaskets];
346 fBasketSeek =
new Long64_t[fMaxBaskets];
348 for (Int_t i = 0; i < fMaxBaskets; ++i) {
357 TBranchElement* brOfCounter = 0;
361 if (fBranchClass.GetClass()) {
362 Bool_t hasCustomStreamer = kFALSE;
363 Bool_t canSelfReference = CanSelfReference(fBranchClass);
364 if (fBranchClass.GetClass()->IsTObject()) {
365 if (canSelfReference) SetBit(kBranchObject);
366 hasCustomStreamer = (!fBranchClass.GetClass()->GetCollectionProxy() && fBranchClass.GetClass()->TestBit(TClass::kHasCustomStreamerMember));
368 if (canSelfReference) SetBit(kBranchAny);
369 hasCustomStreamer = !fBranchClass.GetClass()->GetCollectionProxy() && (fBranchClass.GetClass()->GetStreamer() != 0 || fBranchClass.GetClass()->TestBit(TClass::kHasCustomStreamerMember));
371 if (hasCustomStreamer) {
377 TStreamerElement* element = sinfo->GetElement(
id);
378 if ((fStreamerType == TVirtualStreamerInfo::kObject) || (fStreamerType == TVirtualStreamerInfo::kBase) || (fStreamerType == TVirtualStreamerInfo::kTNamed) || (fStreamerType == TVirtualStreamerInfo::kTObject) || (fStreamerType == TVirtualStreamerInfo::kObjectp) || (fStreamerType == TVirtualStreamerInfo::kObjectP)) {
382 if (CanSelfReference(fBranchClass)) {
383 if (fBranchClass.GetClass()->IsTObject()) {
384 SetBit(kBranchObject);
390 if (element->IsA() == TStreamerBasicPointer::Class()) {
392 TStreamerBasicPointer *bp = (TStreamerBasicPointer *)element;
395 Ssiz_t dot = countname.Last(
'.');
397 countname.Remove(dot+1);
401 countname += bp->GetCountName();
402 brOfCounter = (TBranchElement *)fTree->GetBranch(countname);
403 countname.Form(
"%s[%s]",name.Data(),bp->GetCountName());
406 }
else if (element->IsA() == TStreamerLoop::Class()) {
408 TStreamerLoop *bp = (TStreamerLoop *)element;
411 Ssiz_t dot = countname.Last(
'.');
413 countname.Remove(dot+1);
417 countname += bp->GetCountName();
418 brOfCounter = (TBranchElement *)fTree->GetBranch(countname);
419 countname.Form(
"%s[%s]",name.Data(),bp->GetCountName());
424 if (splitlevel > 0) {
426 const char* elemType = element->GetTypeName();
427 TClass *elementClass = element->GetClassPointer();
428 fSTLtype = elementClass ? elementClass->GetCollectionType() : ROOT::kNotSTL;
429 if (element->CannotSplit()) {
431 }
else if (element->IsA() == TStreamerBase::Class()) {
438 TClass* clOfElement = element->GetClassPointer();
439 Int_t nbranches = fBranches.GetEntriesFast();
445 if (!strcmp(name, clOfElement->GetName())) {
454 Unroll(
"", fBranchClass.GetClass(), clOfElement, pointer, basketsize, splitlevel+splitSTLP, 0);
472 Unroll(name, clOfElement, clOfElement, pointer, basketsize, splitlevel+splitSTLP, 0);
473 if (strchr(bname,
'.')) {
488 if (nbranches == fBranches.GetEntriesFast()) {
491 name.Form(
"%s.%s", bname, clOfElement->GetName());
493 name.Form(
"%s", clOfElement->GetName());
501 }
else if (element->GetClassPointer() == TClonesArray::Class()) {
503 Bool_t ispointer = element->IsaPointer();
504 TClonesArray *clones;
506 char **ppointer = (
char**)(pointer);
507 clones = (TClonesArray*)(*ppointer);
509 clones = (TClonesArray*)pointer;
514 TLeaf* leaf =
new TLeafElement(
this, name, fID, fStreamerType);
517 fTree->GetListOfLeaves()->Add(leaf);
522 TClass* clOfClones = clones->GetClass();
533 fClonesName = clOfClones->GetName();
534 fClonesClass = clOfClones;
536 aname.Form(
" (%s)", clOfClones->GetName());
537 TString atitle = element->GetTitle();
538 if (!atitle.Contains(aname)) {
540 element->SetTitle(atitle.Data());
542 TString branchname( name );
544 SetTitle(branchname);
545 leaf->SetName(branchname);
546 leaf->SetTitle(branchname);
547 leaf->SetRange(kTRUE);
548 Unroll(name, clOfClones, clOfClones, pointer, basketsize, splitlevel+splitSTLP, 31);
553 }
else if (((fSTLtype >= ROOT::kSTLvector) && (fSTLtype < ROOT::kSTLend)) || ((fSTLtype > -ROOT::kSTLend) && (fSTLtype <= -ROOT::kSTLvector))) {
555 TClass* contCl = elementClass;
556 fCollProxy = contCl->GetCollectionProxy()->Generate();
557 TClass* valueClass = GetCollectionProxy()->GetValueClass();
559 Bool_t cansplit = kTRUE;
562 }
else if ((valueClass == TString::Class()) || (valueClass == TClass::GetClass(
"string"))) {
564 }
else if (GetCollectionProxy()->HasPointers() && !splitSTLP ) {
566 }
else if (!valueClass->CanSplit() && !(GetCollectionProxy()->HasPointers() && splitSTLP)) {
568 }
else if (valueClass->GetCollectionProxy()) {
578 TLeaf *leaf =
new TLeafElement(
this, name, fID, fStreamerType);
581 fTree->GetListOfLeaves()->Add(leaf);
585 fClonesName = valueClass->GetName();
586 fClonesClass = valueClass;
588 aname.Form(
" (%s)", valueClass->GetName());
589 TString atitle = element->GetTitle();
590 if (!atitle.Contains(aname)) {
592 element->SetTitle(atitle.Data());
594 TString branchname (name);
596 SetTitle(branchname);
597 leaf->SetName(branchname);
598 leaf->SetTitle(branchname);
599 leaf->SetRange(kTRUE);
601 Unroll(name, valueClass, valueClass, pointer, basketsize, splitlevel+splitSTLP, 41);
607 }
else if (!strchr(elemType,
'*') && ((fStreamerType == TVirtualStreamerInfo::kObject) || (fStreamerType == TVirtualStreamerInfo::kAny))) {
614 TClass* clm = elementClass;
615 Int_t err = Unroll(name, clm, clm, pointer, basketsize, splitlevel+splitSTLP, 0);
631 TLeaf* leaf =
new TLeafElement(
this, GetTitle(), fID, fStreamerType);
632 leaf->SetTitle(GetTitle());
635 fTree->GetListOfLeaves()->Add(leaf);
643 SetBranchCount(brOfCounter);
655 TBranchElement::TBranchElement(TTree *tree,
const char* bname, TClonesArray* clones, Int_t basketsize, Int_t splitlevel, Int_t compress)
657 , fClassName(
"TClonesArray")
659 , fInfo((TStreamerInfo*)TClonesArray::Class()->GetStreamerInfo())
661 , fInInitInfo(kFALSE)
662 , fInitOffsets(kFALSE)
663 , fTargetClass( fClassName )
666 , fBranchClass(TClonesArray::Class())
668 , fReadActionSequence(0)
669 , fFillActionSequence(0)
674 Init(tree, 0, bname, clones, basketsize, splitlevel, compress);
682 TBranchElement::TBranchElement(TBranch *parent,
const char* bname, TClonesArray* clones, Int_t basketsize, Int_t splitlevel, Int_t compress)
684 , fClassName(
"TClonesArray")
686 , fInfo((TStreamerInfo*)TClonesArray::Class()->GetStreamerInfo())
688 , fInInitInfo(kFALSE)
689 , fInitOffsets(kFALSE)
690 , fTargetClass( fClassName )
693 , fBranchClass(TClonesArray::Class())
695 , fReadActionSequence(0)
696 , fFillActionSequence(0)
701 Init(parent ? parent->GetTree() : 0, parent, bname, clones, basketsize, splitlevel, compress);
709 void TBranchElement::Init(TTree *tree, TBranch *parent,
const char* bname, TClonesArray* clones, Int_t basketsize, Int_t splitlevel, Int_t compress)
712 fSplitLevel = splitlevel;
717 fClassVersion = TClonesArray::Class()->GetClassVersion();
718 fCheckSum = fInfo->GetCheckSum();
725 fSTLtype = ROOT::kNotSTL;
726 fInitOffsets = kFALSE;
729 fMother = parent ? parent->GetMother() :
this;
731 fDirectory = fTree->GetDirectory();
735 const char* name = GetName();
738 fCompress = compress;
739 if (compress == -1 && fTree->GetDirectory()) {
740 TFile *bfile = fTree->GetDirectory()->GetFile();
741 if (bfile) fCompress = bfile->GetCompressionSettings();
744 if (basketsize < 100) basketsize = 100;
745 fBasketSize = basketsize;
746 fBasketBytes =
new Int_t[fMaxBaskets];
747 fBasketEntry =
new Long64_t[fMaxBaskets];
748 fBasketSeek =
new Long64_t[fMaxBaskets];
750 for (Int_t i=0;i<fMaxBaskets;i++) {
758 SetAutoDelete(kFALSE);
761 if (splitlevel%TTree::kSplitCollectionOfPointers > 0) {
762 TClass* clonesClass = clones->GetClass();
764 Error(
"Init",
"Missing class object of the TClonesArray %s\n",clones->GetName());
769 TLeaf* leaf =
new TLeafElement(
this, name, fID, fStreamerType);
772 fTree->GetListOfLeaves()->Add(leaf);
774 fClonesName = clonesClass->GetName();
775 fClonesClass = clonesClass;
776 std::string branchname = name + std::string(
"_");
777 SetTitle(branchname.c_str());
778 leaf->SetName(branchname.c_str());
779 leaf->SetTitle(branchname.c_str());
780 Unroll(name, clonesClass, clonesClass, 0, basketsize, splitlevel, 31);
787 if (!clones->GetClass() || CanSelfReference(clones->GetClass())) {
788 SetBit(kBranchObject);
790 TLeaf *leaf =
new TLeafElement(
this, GetTitle(), fID, fStreamerType);
791 leaf->SetTitle(GetTitle());
794 fTree->GetListOfLeaves()->Add(leaf);
805 TBranchElement::TBranchElement(TTree *tree,
const char* bname, TVirtualCollectionProxy* cont, Int_t basketsize, Int_t splitlevel, Int_t compress)
807 , fClassName(cont->GetCollectionClass()->GetName())
810 , fInInitInfo(kFALSE)
811 , fInitOffsets(kFALSE)
812 , fTargetClass( fClassName )
815 , fBranchClass(cont->GetCollectionClass())
817 , fReadActionSequence(0)
818 , fFillActionSequence(0)
823 Init(tree, 0, bname, cont, basketsize, splitlevel, compress);
831 TBranchElement::TBranchElement(TBranch *parent,
const char* bname, TVirtualCollectionProxy* cont, Int_t basketsize, Int_t splitlevel, Int_t compress)
833 , fClassName(cont->GetCollectionClass()->GetName())
836 , fInInitInfo(kFALSE)
837 , fInitOffsets(kFALSE)
838 , fTargetClass( fClassName )
841 , fBranchClass(cont->GetCollectionClass())
843 , fReadActionSequence(0)
844 , fFillActionSequence(0)
849 Init(parent ? parent->GetTree() : 0, parent, bname, cont, basketsize, splitlevel, compress);
857 void TBranchElement::Init(TTree *tree, TBranch *parent,
const char* bname, TVirtualCollectionProxy* cont, Int_t basketsize, Int_t splitlevel, Int_t compress)
859 fCollProxy = cont->Generate();
860 TString name( bname );
861 if (name[name.Length()-1]==
'.') {
862 name.Remove(name.Length()-1);
864 fInitOffsets = kFALSE;
865 fSplitLevel = splitlevel;
871 fClassVersion = cont->GetCollectionClass()->GetClassVersion();
872 fCheckSum = cont->GetCollectionClass()->GetCheckSum();
881 fSTLtype = cont->GetCollectionType();
883 fSTLtype = -fSTLtype;
887 fMother = parent ? parent->GetMother() :
this;
889 fDirectory = fTree->GetDirectory();
895 fCompress = compress;
896 if ((compress == -1) && fTree->GetDirectory()) {
897 TFile* bfile = fTree->GetDirectory()->GetFile();
899 fCompress = bfile->GetCompressionSettings();
903 if (basketsize < 100) {
906 fBasketSize = basketsize;
908 fBasketBytes =
new Int_t[fMaxBaskets];
909 fBasketEntry =
new Long64_t[fMaxBaskets];
910 fBasketSeek =
new Long64_t[fMaxBaskets];
912 for (Int_t i = 0; i < fMaxBaskets; ++i) {
920 SetAutoDelete(kFALSE);
923 if ( (splitlevel%TTree::kSplitCollectionOfPointers > 0 && fBranchClass.GetClass() && fBranchClass.GetClass()->CanSplit()) ||
924 (cont->HasPointers() && splitlevel > TTree::kSplitCollectionOfPointers && cont->GetValueClass() && cont->GetValueClass()->CanSplit() ) )
928 TLeaf* leaf =
new TLeafElement(
this, name, fID, fStreamerType);
931 fTree->GetListOfLeaves()->Add(leaf);
933 TClass* valueClass = cont->GetValueClass();
937 fClonesName = valueClass->GetName();
938 fClonesClass = valueClass;
939 TString branchname( name );
941 SetTitle(branchname);
942 leaf->SetName(branchname);
943 leaf->SetTitle(branchname);
944 Unroll(name, valueClass, valueClass, 0, basketsize, splitlevel, 41);
951 TLeaf *leaf =
new TLeafElement(
this, GetTitle(), fID, fStreamerType);
952 leaf->SetTitle(GetTitle());
955 fTree->GetListOfLeaves()->Add(leaf);
963 TBranchElement::~TBranchElement()
966 if (fOnfileObject && TestBit(kOwnOnfileObj)) {
967 delete fOnfileObject;
972 delete[] fBranchOffset;
979 if (fType == 4 || fType == 0) {
986 delete fReadActionSequence;
987 delete fFillActionSequence;
989 delete fWriteIterators;
990 delete fPtrIterators;
999 inline TStreamerInfo* TBranchElement::GetInfoImp()
const
1003 if (!fInfo || (fInfo && (!fInit || !fInfo->IsCompiled()))) {
1004 const_cast<TBranchElement*
>(
this)->InitInfo();
1012 TStreamerInfo* TBranchElement::GetInfo()
const
1014 return GetInfoImp();
1020 void TBranchElement::Browse(TBrowser* b)
1022 Int_t nbranches = fBranches.GetEntriesFast();
1023 if (nbranches > 0) {
1024 TList persistentBranches;
1026 TIter iB(&fBranches);
1027 while((branch=(TBranch*)iB())) {
1028 if (branch->IsFolder()) persistentBranches.Add(branch);
1032 if (strlen(GetClonesName()))
1037 cl=TClass::GetClass(GetClassName());
1041 TStreamerElement *element=0;
1043 if (fID>=0 && GetInfoImp()
1044 && GetInfoImp()->IsCompiled()
1045 && ((element=GetInfoImp()->GetElement(fID)))
1046 && ((clsub=element->GetClassPointer())))
1050 TString strMember=branch->GetName();
1051 Size_t mempos=strMember.Last(
'.');
1053 strMember.Remove(0, (Int_t)mempos+1);
1054 mempos=strMember.First(
'[');
1056 strMember.Remove((Int_t)mempos);
1057 TDataMember* m=cl->GetDataMember(strMember);
1058 if (!m || m->IsPersistent()) persistentBranches.Add(branch);
1059 }
else persistentBranches.Add(branch);
1062 persistentBranches.Browse(b);
1064 if (GetBrowsables() && GetBrowsables()->GetSize())
1065 GetBrowsables()->Browse(b);
1067 if (GetBrowsables() && GetBrowsables()->GetSize()) {
1068 GetBrowsables()->Browse(b);
1074 TString escapedSlash(
"\\/");
1075 TString name = GetName();
1076 Int_t pos = name.First(
'[');
1082 mothername = GetMother()->GetName();
1083 pos = mothername.First(
'[');
1085 mothername.Remove(pos);
1087 Int_t len = mothername.Length();
1089 if (mothername(len-1) !=
'.') {
1094 TString doublename = mothername;
1095 doublename.Append(
".");
1096 Int_t isthere = (name.Index(doublename) == 0);
1098 name.Prepend(doublename);
1100 if (GetMother()->FindBranch(mothername)) {
1101 doublename.Append(mothername);
1102 isthere = (name.Index(doublename) == 0);
1104 mothername.Append(
".");
1105 name.Prepend(mothername);
1115 if (name.Index(mothername) == kNPOS) {
1116 name.Prepend(mothername);
1121 name.ReplaceAll(slash, escapedSlash);
1122 GetTree()->Draw(name,
"", b ? b->GetDrawOption() :
"");
1132 void TBranchElement::BuildTitle(
const char* name)
1136 Int_t nbranches = fBranches.GetEntries();
1138 for (Int_t i = 0; i < nbranches; ++i) {
1139 TBranchElement* bre = (TBranchElement*) fBranches.At(i);
1142 }
else if (fType == 4) {
1145 Error(
"BuildTitle",
"This cannot happen, fType of parent is not 3 or 4!");
1147 bre->fCollProxy = GetCollectionProxy();
1148 bre->BuildTitle(name);
1149 const char* fin = strrchr(bre->GetTitle(),
'.');
1154 bre->SetBranchCount(
this);
1155 TLeafElement* lf = (TLeafElement*) bre->GetListOfLeaves()->At(0);
1159 Ssiz_t dim = branchname.First(
'[');
1161 branchname.Remove(dim);
1163 branchname += TString::Format(
"[%s_]",name);
1164 bre->SetTitle(branchname);
1166 lf->SetTitle(branchname);
1180 Int_t stype = bre->GetStreamerType();
1182 if ((stype > 40) && (stype < 61)) {
1183 TString name2 (bre->GetName());
1184 Ssiz_t bn = name2.Last(
'.');
1188 TStreamerBasicPointer *el = (TStreamerBasicPointer*)bre->GetInfoImp()->GetElements()->FindObject(name2.Data()+bn+1);
1190 if (el) name2 += el->GetCountName();
1191 TBranchElement *bc2 = (TBranchElement*)fBranches.FindObject(name2);
1192 bre->SetBranchCount2(bc2);
1194 bre->SetReadLeavesPtr();
1195 bre->SetFillLeavesPtr();
1209 Int_t TBranchElement::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper)
1214 Int_t nbranches = fBranches.GetEntriesFast();
1224 Error(
"Fill",
"attempt to fill branch %s while addresss is not set", GetName());
1235 if ((fType >= -1) && (fType < 10)) {
1236 TBranchRef* bref = fTree->GetBranchRef();
1238 fBranchID = bref->SetParent(
this, fBranchID);
1244 if (!TestBit(kDoNotProcess)) {
1245 nwrite = TBranch::FillImpl(imtHelper);
1247 Error(
"Fill",
"Failed filling branch:%s, nbytes=%d", GetName(), nwrite);
1255 if (fType == 3 || fType == 4) {
1257 nwrite = TBranch::FillImpl(imtHelper);
1259 Error(
"Fill",
"Failed filling branch:%s, nbytes=%d", GetName(), nwrite);
1267 for (Int_t i = 0; i < nbranches; ++i) {
1268 TBranchElement* branch = (TBranchElement*) fBranches[i];
1269 if (!branch->TestBit(kDoNotProcess)) {
1270 nwrite = branch->FillImpl(imtHelper);
1272 Error(
"Fill",
"Failed filling branch:%s.%s, nbytes=%d", GetName(), branch->GetName(), nwrite);
1281 if (fTree->Debug() > 0) {
1283 Long64_t entry = fEntries;
1284 if ((entry >= fTree->GetDebugMin()) && (entry <= fTree->GetDebugMax())) {
1285 printf(
"Fill: %lld, branch=%s, nbytes=%d\n", entry, GetName(), nbytes);
1300 void TBranchElement::FillLeavesMakeClass(TBuffer& b)
1315 TVirtualStreamerInfo* si = fClonesClass->GetStreamerInfo();
1317 Error(
"FillLeaves",
"Cannot get streamer info for branch '%s' class '%s'", GetName(), fClonesClass->GetName());
1320 b.ForceWriteInfo(si,kFALSE);
1321 Int_t* nptr = (Int_t*) fAddress;
1323 }
else if (fType == 31) {
1331 Int_t atype = fStreamerType;
1342 Int_t* nn = (Int_t*) fBranchCount->GetAddress();
1344 Error(
"FillLeaves",
"The branch counter address was zero!");
1350 Error(
"FillLeaves",
"Clonesa: %s, n=%d, sorry not supported yet", GetName(), n);
1355 TLeafElement* leaf = (TLeafElement*) fLeaves.UncheckedAt(0);
1356 n = n * leaf->GetLenStatic();
1360 case TVirtualStreamerInfo::kChar : { b.WriteFastArray((Char_t*) fAddress, n);
break; }
1361 case TVirtualStreamerInfo::kShort : { b.WriteFastArray((Short_t*) fAddress, n);
break; }
1362 case TVirtualStreamerInfo::kInt : { b.WriteFastArray((Int_t*) fAddress, n);
break; }
1363 case TVirtualStreamerInfo::kLong : { b.WriteFastArray((Long_t*) fAddress, n);
break; }
1364 case TVirtualStreamerInfo::kFloat : { b.WriteFastArray((Float_t*) fAddress, n);
break; }
1365 case TVirtualStreamerInfo::kCounter : { b.WriteFastArray((Int_t*) fAddress, n);
break; }
1367 case TVirtualStreamerInfo::kDouble : { b.WriteFastArray((Double_t*) fAddress, n);
break; }
1368 case TVirtualStreamerInfo::kDouble32 : {
1369 TVirtualStreamerInfo* si = GetInfoImp();
1371 TStreamerElement* se = si->GetElement(fID);
1372 Double_t* xx = (Double_t*) fAddress;
1373 for (Int_t ii = 0; ii < n; ++ii) {
1374 b.WriteDouble32(&(xx[ii]),se);
1378 case TVirtualStreamerInfo::kFloat16 : {
1379 TVirtualStreamerInfo* si = GetInfoImp();
1381 TStreamerElement* se = (TStreamerElement*) si->GetElement(fID);
1382 Float_t* xx = (Float_t*) fAddress;
1383 for (Int_t ii = 0; ii < n; ++ii) {
1384 b.WriteFloat16(&(xx[ii]),se);
1389 case TVirtualStreamerInfo::kUChar : { b.WriteFastArray((UChar_t*) fAddress, n);
break; }
1390 case TVirtualStreamerInfo::kUShort : { b.WriteFastArray((UShort_t*) fAddress, n);
break; }
1391 case TVirtualStreamerInfo::kUInt : { b.WriteFastArray((UInt_t*) fAddress, n);
break; }
1392 case TVirtualStreamerInfo::kULong : { b.WriteFastArray((ULong_t*) fAddress, n);
break; }
1394 case TVirtualStreamerInfo::kBits : { b.WriteFastArray((UInt_t*) fAddress, n);
break; }
1395 case TVirtualStreamerInfo::kLong64 : { b.WriteFastArray((Long64_t*) fAddress, n);
break; }
1396 case TVirtualStreamerInfo::kULong64 : { b.WriteFastArray((ULong64_t*) fAddress, n);
break; }
1397 case TVirtualStreamerInfo::kBool : { b.WriteFastArray((Bool_t*) fAddress, n);
break; }
1406 void TBranchElement::FillLeavesCollection(TBuffer& b)
1419 TVirtualCollectionProxy* proxy = GetCollectionProxy();
1422 TVirtualCollectionProxy::TPushPop helper(proxy, fObject);
1430 if(fSTLtype != ROOT::kSTLvector && proxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
1431 fPtrIterators->CreateIterators(fObject, proxy);
1436 if (proxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) {
1437 fWriteIterators->CreateIterators(fObject, proxy);
1439 fIterators->CreateIterators(fObject, proxy);
1449 void TBranchElement::FillLeavesCollectionSplitVectorPtrMember(TBuffer& b)
1462 TVirtualCollectionProxy::TPushPop helper(GetCollectionProxy(), fObject);
1464 TStreamerInfo* si = (TStreamerInfo*)GetInfoImp();
1466 Error(
"FillLeaves",
"Cannot get streamer info for branch '%s'", GetName());
1470 TVirtualCollectionIterators *iter = fBranchCount->fIterators;
1472 b.ApplySequenceVecPtr(*fFillActionSequence,iter->fBegin,iter->fEnd);
1479 void TBranchElement::FillLeavesCollectionSplitPtrMember(TBuffer& b)
1492 TVirtualCollectionProxy::TPushPop helper(GetCollectionProxy(), fObject);
1495 TStreamerInfo* si = (TStreamerInfo*)GetInfoImp();
1497 Error(
"FillLeaves",
"Cannot get streamer info for branch '%s'", GetName());
1501 TVirtualCollectionPtrIterators *iter = fBranchCount->fPtrIterators;
1502 b.ApplySequence(*fFillActionSequence,iter->fBegin,iter->fEnd);
1510 void TBranchElement::FillLeavesCollectionMember(TBuffer& b)
1523 TVirtualCollectionProxy::TPushPop helper(GetCollectionProxy(), fObject);
1525 TStreamerInfo* si = (TStreamerInfo*)GetInfoImp();
1527 Error(
"FillLeaves",
"Cannot get streamer info for branch '%s'", GetName());
1531 TVirtualCollectionIterators *iter = fBranchCount->fIterators;
1533 b.ApplySequence(*fFillActionSequence,iter->fBegin,iter->fEnd);
1541 void TBranchElement::FillLeavesAssociativeCollectionMember(TBuffer& b)
1554 TVirtualCollectionProxy::TPushPop helper(GetCollectionProxy(), fObject);
1556 TStreamerInfo* si = (TStreamerInfo*)GetInfoImp();
1558 Error(
"FillLeaves",
"Cannot get streamer info for branch '%s'", GetName());
1562 TVirtualCollectionIterators *iter = fBranchCount->fWriteIterators;
1564 b.ApplySequence(*fFillActionSequence,iter->fBegin,iter->fEnd);
1572 void TBranchElement::FillLeavesClones(TBuffer& b)
1585 TClonesArray* clones = (TClonesArray*) fObject;
1586 Int_t n = clones->GetEntriesFast();
1597 void TBranchElement::FillLeavesClonesMember(TBuffer& b)
1609 TClonesArray* clones = (TClonesArray*) fObject;
1610 Int_t n = clones->GetEntriesFast();
1611 TStreamerInfo* si = (TStreamerInfo*)GetInfoImp();
1613 Error(
"FillLeaves",
"Cannot get streamer info for branch '%s'", GetName());
1617 char **arr = (
char **)clones->GetObjectRef(0);
1618 char **end = arr + n;
1619 b.ApplySequenceVecPtr(*fFillActionSequence,arr,end);
1626 void TBranchElement::FillLeavesCustomStreamer(TBuffer& b)
1642 if (TestBit(kBranchObject)) {
1643 b.MapObject((TObject*) fObject);
1644 }
else if (TestBit(kBranchAny)) {
1645 b.MapObject(fObject, fBranchClass);
1648 fBranchClass->Streamer(fObject,b);
1656 void TBranchElement::FillLeavesMemberBranchCount(TBuffer& b)
1658 FillLeavesMember(b);
1677 void TBranchElement::FillLeavesMemberCounter(TBuffer& b)
1693 TStreamerInfo* si = GetInfoImp();
1695 Error(
"FillLeaves",
"Cannot get streamer info for branch '%s'", GetName());
1699 b.ApplySequence(*fFillActionSequence, fObject);
1702 Int_t n = *(Int_t*)(fObject + si->TStreamerInfo::GetElementOffset(fID));
1714 void TBranchElement::FillLeavesMember(TBuffer& b)
1726 if (TestBit(kBranchObject)) {
1727 b.MapObject((TObject*) fObject);
1728 }
else if (TestBit(kBranchAny)) {
1729 b.MapObject(fObject, fBranchClass);
1737 TStreamerInfo* si = GetInfoImp();
1739 Error(
"FillLeaves",
"Cannot get streamer info for branch '%s'", GetName());
1743 b.ApplySequence(*fFillActionSequence, fObject);
1751 static void R__CleanName(std::string &name)
1753 if (name[name.length()-1]==
']') {
1754 std::size_t dim = name.find_first_of(
"[");
1755 if (dim != std::string::npos) {
1759 if (name[name.size()-1] !=
'.') {
1767 TBranch* TBranchElement::FindBranch(
const char *name)
1776 TVirtualStreamerInfo* si = GetInfoImp();
1777 TStreamerElement* se = si->GetElement(fID);
1778 if (se && se->IsBase()) {
1780 UInt_t len = strlen(name);
1782 longnm.reserve(fName.Length()+len+3);
1783 longnm = fName.Data();
1784 R__CleanName(longnm);
1786 std::string longnm_parent;
1787 longnm_parent.reserve(fName.Length()+len+3);
1788 longnm_parent = (GetMother()->GetSubBranch(
this)->GetName());
1789 R__CleanName(longnm_parent);
1790 longnm_parent += name;
1792 UInt_t namelen = strlen(name);
1794 TBranch* branch = 0;
1795 Int_t nbranches = fBranches.GetEntries();
1796 for(Int_t i = 0; i < nbranches; ++i) {
1797 branch = (TBranch*) fBranches.UncheckedAt(i);
1799 const char *brname = branch->GetName();
1800 UInt_t brlen = strlen(brname);
1801 if (brname[brlen-1]==
']') {
1802 const char *dim = strchr(brname,
'[');
1804 brlen = dim - brname;
1807 if (namelen == brlen
1808 && strncmp(name,brname,brlen) == 0) {
1811 if (brlen == longnm.length()
1812 && strncmp(longnm.c_str(),brname,brlen) == 0) {
1816 if (brlen == longnm_parent.length()
1817 && strncmp(longnm_parent.c_str(),brname,brlen) == 0) {
1821 if (namelen>brlen && name[brlen]==
'.' && strncmp(name,brname,brlen)==0) {
1823 return branch->FindBranch(name+brlen+1);
1828 TBranch *result = TBranch::FindBranch(name);
1831 Int_t nbranches = fBranches.GetEntries();
1832 for(Int_t i = 0; i < nbranches; ++i) {
1833 TObject *obj = fBranches.UncheckedAt(i);
1834 if(obj->IsA() != TBranchElement :: Class() )
1836 TBranchElement *br = (TBranchElement*)obj;
1837 TVirtualStreamerInfo* si = br->GetInfoImp();
1838 if (si && br->GetID() >= 0) {
1839 TStreamerElement* se = si->GetElement(br->GetID());
1840 if (se && se->IsBase()) {
1841 result = br->FindBranch(name);
1852 TLeaf* TBranchElement::FindLeaf(
const char *name)
1854 TLeaf *leaf = TBranch::FindLeaf(name);
1856 if (leaf==0 && GetListOfLeaves()->GetEntries()==1) {
1857 TBranch *br = GetMother()->GetSubBranch(
this );
1858 if( br->IsA() != TBranchElement::Class() )
1861 TBranchElement *parent = (TBranchElement*)br;
1862 if (parent==
this || parent->GetID()<0 )
return 0;
1864 TVirtualStreamerInfo* si = parent->GetInfoImp();
1865 TStreamerElement* se = si->GetElement(parent->GetID());
1867 if (! se->IsBase() )
return 0;
1869 br = GetMother()->GetSubBranch( parent );
1870 if( br->IsA() != TBranchElement::Class() )
1873 TBranchElement *grand_parent = (TBranchElement*)br;
1875 std::string longname( grand_parent->GetName() );
1876 R__CleanName(longname);
1879 std::string leafname( GetListOfLeaves()->At(0)->GetName() );
1881 if ( longname == leafname ) {
1882 return (TLeaf*)GetListOfLeaves()->At(0);
1903 char* TBranchElement::GetAddress()
const
1914 TStreamerInfo *TBranchElement::FindOnfileInfo(TClass *valueClass,
const TObjArray &branches)
const
1916 TStreamerInfo *localInfo =
nullptr;
1919 for(
auto subbe : TRangeDynCast<TBranchElement>( branches )) {
1922 if (valueClass == subbe->fInfo->GetClass()) {
1923 localInfo = subbe->fInfo;
1929 auto file = fDirectory ? fDirectory->GetFile() :
nullptr;
1930 if (file && file->GetSeekInfo()) {
1931 localInfo = (TStreamerInfo*)file->GetStreamerInfoCache()->FindObject(valueClass->GetName());
1933 if (valueClass->IsVersioned()) {
1934 localInfo = (TStreamerInfo*)valueClass->GetStreamerInfo(localInfo->GetClassVersion());
1936 localInfo = (TStreamerInfo*)valueClass->FindStreamerInfo(localInfo->GetCheckSum());
1939 localInfo = (TStreamerInfo*)valueClass->GetStreamerInfo(localInfo->GetClassVersion());
1946 localInfo = (TStreamerInfo*)valueClass->GetStreamerInfo();
1950 TClass *targetValueClass = fInfo->GetClass()->GetCollectionProxy()
1951 ? fInfo->GetClass()->GetCollectionProxy()->GetValueClass()
1958 if (targetValueClass && localInfo->GetClass() != targetValueClass) {
1959 localInfo = (TStreamerInfo*)targetValueClass->GetConversionStreamerInfo(localInfo->GetClass(),
1960 localInfo->GetClassVersion());
1967 static void GatherArtificialElements(
const TObjArray &branches, TStreamerInfoActions::TIDs &ids, TString prefix, TStreamerInfo *info, Int_t offset) {
1968 size_t ndata = info->GetNelement();
1969 for (
size_t i =0; i < ndata; ++i) {
1970 TStreamerElement *nextel = info->GetElement(i);
1972 if (nextel->GetType() == TStreamerInfo::kCacheDelete
1973 || nextel->GetType() == TStreamerInfo::kCacheNew) {
1977 TString ename = prefix + nextel->GetName();
1983 while ((pos = ename.Last(
'[')) != TString::kNPOS) {
1984 ename = ename.Remove(pos);
1987 TBranchElement *be = (TBranchElement*)branches.FindObject(ename);
1988 if (nextel->IsA() == TStreamerArtificial::Class()
1992 ids.back().fElement = nextel;
1993 ids.back().fInfo = info;
1996 if (nextel->CannotSplit() || nextel->IsTransient() || nextel->GetOffset() == TStreamerInfo::kMissing)
1999 if (!be && nextel->IsBase()) {
2003 TString subprefix(prefix);
2004 if (subprefix.Length() && subprefix[subprefix.Length()-1] ==
'.')
2005 subprefix.Remove(subprefix.Length()-1);
2007 be = (TBranchElement*)branches.FindObject(subprefix);
2011 TClass *expectedClass =
nullptr;
2012 EDataType expectedType;
2013 if (0 != be->GetExpectedType(expectedClass,expectedType)
2014 || expectedClass != nextel->GetClassPointer())
2017 Int_t nbranches = branches.GetEntriesFast();
2018 for (Int_t bi = 0; bi < nbranches; ++bi) {
2019 TBranchElement* branch = (TBranchElement*) branches[bi];
2020 if (subprefix != branch->GetName())
2022 if (0 == branch->GetExpectedType(expectedClass,expectedType)
2023 && expectedClass == nextel->GetClassPointer())
2033 TClass *elementClass = nextel->GetClassPointer();
2034 if (elementClass && (!be || be->GetType() == -2)) {
2036 TStreamerInfo *nextinfo =
nullptr;
2039 auto search = be ? be->GetListOfBranches() : &branches;
2040 TVirtualArray *onfileObject =
nullptr;
2041 for(
auto subbe : TRangeDynCast<TBranchElement>( *search )) {
2043 if (elementClass == subbe->GetInfo()->GetClass()) {
2044 nextinfo = subbe->GetInfo();
2045 onfileObject = subbe->GetOnfileObject();
2050 nextinfo = (TStreamerInfo *)elementClass->GetStreamerInfo();
2051 if (elementClass->GetCollectionProxy() && elementClass->GetCollectionProxy()->GetValueClass()) {
2052 nextinfo = (TStreamerInfo *)elementClass->GetCollectionProxy()->GetValueClass()->GetStreamerInfo();
2055 ids.emplace_back(nextinfo, offset + nextel->GetOffset());
2056 if (!onfileObject && nextinfo && nextinfo->GetNelement() && nextinfo->GetElement(0)->GetType() == TStreamerInfo::kCacheNew) {
2057 onfileObject =
new TVirtualArray( info->GetElement(0)->GetClassPointer(), 1 );
2058 ids.back().fNestedIDs->fOwnOnfileObject = kTRUE;
2060 ids.back().fNestedIDs->fOnfileObject = onfileObject;
2062 if (prefix.Length() && nextel->IsA() == TStreamerBase::Class()) {
2067 subprefix = ename +
".";
2069 GatherArtificialElements(branches, ids.back().fNestedIDs->fIDs, subprefix, nextinfo, offset + nextel->GetOffset());
2070 if (ids.back().fNestedIDs->fIDs.empty())
2085 void TBranchElement::SetupInfo()
2088 TClass* cl = fBranchClass.GetClass();
2094 TClass* targetClass = 0;
2095 if( fTargetClass.GetClassName()[0] ) {
2096 targetClass = fTargetClass;
2097 if (!targetClass && GetCollectionProxy()) {
2102 targetClass = fTargetClass;
2104 if ( !targetClass ) {
2105 Error(
"InitInfo",
"The target class dictionary is not present!" );
2117 if ( (cl->Property() & kIsAbstract) && cl == targetClass) {
2118 TBranchElement *parent = (TBranchElement*)GetMother()->GetSubBranch(
this);
2119 if (parent && parent !=
this && !parent->GetClass()->IsLoaded() ) {
2122 TString target = cl->GetName();
2123 target +=
"@@emulated";
2124 fTargetClass.SetName(target);
2126 if (!fTargetClass) {
2127 cl->GetStreamerInfoAbstractEmulated(fClassVersion);
2129 targetClass = fTargetClass;
2132 if( targetClass != cl ) {
2133 fInfo = (TStreamerInfo*)targetClass->GetConversionStreamerInfo( cl, fClassVersion );
2135 fInfo = (TStreamerInfo*)cl->GetStreamerInfo(fClassVersion);
2142 R__LOCKGUARD(gInterpreterMutex);
2143 if (fCheckSum && (cl->IsForeign() || (!cl->IsLoaded() && (fClassVersion == 1) && cl->GetStreamerInfos()->At(1) && (fCheckSum != ((TVirtualStreamerInfo*) cl->GetStreamerInfos()->At(1))->GetCheckSum())))) {
2148 TStreamerInfo* info;
2149 if( targetClass != cl )
2150 info = (TStreamerInfo*)targetClass->GetConversionStreamerInfo( cl, fCheckSum );
2152 info = (TStreamerInfo*)cl->FindStreamerInfo( fCheckSum );
2155 info = (TStreamerInfo*)cl->GetStreamerInfo(info->GetClassVersion());
2174 void TBranchElement::InitInfo()
2186 if (!fInfo->IsCompiled()) {
2189 Error(
"InitInfo",
"StreamerInfo is not compiled.");
2194 fInInitInfo = kTRUE;
2201 auto SetOnfileObject = [
this](TStreamerInfo *info) {
2203 if (fType==31 || fType==41) {
2204 TLeaf *leaf = (TLeaf*)fLeaves.At(0);
2206 arrlen = leaf->GetMaximum();
2209 Bool_t toplevel = (fType == 3 || fType == 4 || (fType == 0 && fID == -2));
2210 Bool_t seenExisting = kFALSE;
2212 fOnfileObject =
new TVirtualArray( info->GetElement(0)->GetClassPointer(), arrlen );
2214 TObjArray *branches = toplevel ? GetListOfBranches() : GetMother()->GetSubBranch(this)->GetListOfBranches();
2215 Int_t nbranches = branches->GetEntriesFast();
2216 TBranchElement *lastbranch =
this;
2218 TClass *currentClass = fBranchClass;
2219 auto currentVersion = fClassVersion;
2222 currentClass = info->GetClass();
2223 currentVersion = info->GetClassVersion();
2226 for (Int_t i = 0; i < nbranches; ++i) {
2227 TBranchElement* subbranch = (TBranchElement*)branches->At(i);
2228 Bool_t match = kFALSE;
2229 if (
this != subbranch) {
2231 if (!subbranch->fInfo)
2232 subbranch->SetupInfo();
2234 if (subbranch->fInfo == info)
2236 else if (subbranch->fInfo ==
nullptr && subbranch->fBranchClass == currentClass) {
2238 if (subbranch->fCheckSum == fCheckSum)
2241 if (!subbranch->fBranchClass->IsForeign() && subbranch->fClassVersion == currentVersion)
2243 else if (subbranch->fCheckSum == info->GetCheckSum()) {
2250 if (subbranch->fOnfileObject && subbranch->fOnfileObject != fOnfileObject) {
2252 Error(
"SetOnfileObject (lambda)",
"2 distincts fOnfileObject are in the hierarchy of %s for type %s",
2253 toplevel ? GetName() : GetMother()->GetSubBranch(
this)->GetName(), info->GetName());
2255 delete fOnfileObject;
2256 fOnfileObject = subbranch->fOnfileObject;
2257 seenExisting = kTRUE;
2260 subbranch->fOnfileObject = fOnfileObject;
2261 lastbranch = subbranch;
2265 SetBit(kOwnOnfileObj);
2266 if (lastbranch !=
this)
2267 lastbranch->ResetBit(kOwnOnfileObj);
2269 lastbranch->SetBit(kOwnOnfileObj);
2274 std::string s(GetName());
2275 size_t pos = s.rfind(
'.');
2276 if (pos != std::string::npos) {
2277 s = s.substr(pos+1);
2279 while ((pos = s.rfind(
'[')) != std::string::npos) {
2280 s = s.substr(0, pos);
2283 TStreamerElement* elt = fInfo->GetStreamerElement(s.c_str(), offset);
2284 if (elt && offset!=TStreamerInfo::kMissing) {
2285 size_t ndata = fInfo->GetNelement();
2287 for (
size_t i = 0; i < ndata; ++i) {
2288 if (fInfo->GetElement(i) == elt) {
2289 if (elt->TestBit (TStreamerElement::kCache)
2291 && s == fInfo->GetElement(i)->GetName())
2300 if (elt->TestBit(TStreamerElement::kRepeat)) {
2301 fNewIDs.push_back(fID+1);
2302 fNewIDs.back().fElement = fInfo->GetElement(i+1);
2303 fNewIDs.back().fInfo = fInfo;
2304 }
else if (fInfo->GetElement(i+1)->TestBit(TStreamerElement::kWrite)) {
2305 fNewIDs.push_back(fID+1);
2306 fNewIDs.back().fElement = fInfo->GetElement(i+1);
2307 fNewIDs.back().fInfo = fInfo;
2313 if (elt->TestBit (TStreamerElement::kCache)) {
2314 SetBit(TBranchElement::kCache);
2319 for (
size_t i = fID+1+(fNewIDs.size()); i < ndata; ++i) {
2320 TStreamerElement *nextel = fInfo->GetElement(i);
2322 std::string ename = nextel->GetName();
2323 if (ename[0] ==
'*')
2324 ename = ename.substr(1);
2326 while ((pos = ename.rfind(
'[')) != std::string::npos) {
2327 ename = ename.substr(0, pos);
2336 if (fType==31||fType==41) {
2339 if ((nextel->GetType() == TStreamerInfo::kObject
2340 || nextel->GetType() == TStreamerInfo::kAny)
2341 && nextel->GetClassPointer()->CanSplit())
2346 if (nextel->GetOffset() == TStreamerInfo::kMissing) {
2351 if (nextel->IsA() != TStreamerArtificial::Class()
2352 || nextel->GetType() == TStreamerInfo::kCacheDelete ) {
2358 fNewIDs.push_back(i);
2359 fNewIDs.back().fElement = nextel;
2360 fNewIDs.back().fInfo = fInfo;
2362 }
else if (elt && offset==TStreamerInfo::kMissing) {
2365 size_t ndata = fInfo->GetNelement();
2366 for (
size_t i = 0; i < ndata; ++i) {
2367 if (fInfo->GetElement(i) == elt) {
2378 if (fOnfileObject==0 && (fType==31 || fType==41 || (0 <= fType && fType <=2) ) && fInfo->GetNelement()
2379 && fInfo->GetElement(0)->GetType() == TStreamerInfo::kCacheNew)
2381 SetOnfileObject(fInfo);
2384 if (fType == 3 || fType == 4 || (fType == 0 && fID == -2)) {
2386 TStreamerInfo *localInfo = fInfo;
2387 if (fType == 3 || fType == 4) {
2391 localInfo = FindOnfileInfo(fClonesClass, fBranches);
2394 TString prefix(GetName());
2395 if (prefix[prefix.Length()-1] !=
'.') {
2396 if (fType == 3 || fType == 4 || prefix.Index(
'.') != TString::kNPOS) {
2404 GatherArtificialElements(fBranches, fNewIDs, prefix, localInfo, 0);
2406 if (!fNewIDs.empty() && fOnfileObject ==
nullptr && localInfo->GetElement(0)->GetType() == TStreamerInfo::kCacheNew)
2408 SetOnfileObject(localInfo);
2415 SetReadActionSequence();
2416 SetFillActionSequence();
2417 }
else if (!fReadActionSequence) {
2419 SetReadActionSequence();
2420 SetFillActionSequence();
2424 fInInitInfo = kFALSE;
2431 TVirtualCollectionProxy* TBranchElement::GetCollectionProxy()
2436 TBranchElement* thiscast =
const_cast<TBranchElement*
>(
this);
2439 const char* className = 0;
2440 TClass* cl =
nullptr;
2443 if (fBranchClass.GetClass()) {
2444 cl = fBranchClass.GetClass();
2448 TVirtualStreamerInfo* si = thiscast->GetInfoImp();
2457 TStreamerElement* se = si->GetElement(fID);
2458 cl = se->GetClassPointer();
2466 cl =
new TClass(fBranchClass.GetClassName(), fClassVersion);
2467 cl->SetBit(TClass::kIsEmulation);
2468 className = cl->GetName();
2470 cl =
new TClass(className, fClassVersion);
2471 cl->SetBit(TClass::kIsEmulation);
2472 className = cl->GetName();
2475 TVirtualCollectionProxy* proxy = cl->GetCollectionProxy();
2480 equiv.Form(
"vector<%s>",fClonesName.Data());
2481 TClass *clequiv = TClass::GetClass(equiv);
2482 proxy = clequiv->GetCollectionProxy();
2484 Fatal(
"GetCollectionProxy",
2485 "Can not create a Collection Proxy of any kind for the class \"%s\" needed by the branch \"%s\" of the TTree \"%s\"!",
2486 className, GetName(), GetTree()->GetName());
2488 if (gDebug > 0) Info(
"GetCollectionProxy",
2489 "Fixing the collection proxy of the class \"%s\" \n"
2490 "\tneeded by the branch \"%s\" of the TTree \"%s\" to be similar to \"%s\".",
2491 className, GetName(), GetTree()->GetName(),equiv.Data());
2492 cl->CopyCollectionProxy( *proxy );
2494 fCollProxy = proxy->Generate();
2495 fSTLtype = proxy->GetCollectionType();
2496 }
else if (fType == 41) {
2498 thiscast->fCollProxy = fBranchCount->GetCollectionProxy();
2506 TClass* TBranchElement::GetCurrentClass()
2508 TClass* cl = fCurrentClass;
2513 TStreamerInfo* brInfo = (TStreamerInfo*)GetInfoImp();
2515 cl = TClass::GetClass(GetClassName());
2516 R__ASSERT(cl && cl->GetCollectionProxy());
2520 TClass* motherCl = brInfo->GetClass();
2521 if (motherCl->GetCollectionProxy()) {
2522 cl = motherCl->GetCollectionProxy()->GetCollectionClass();
2528 if (GetID() < 0 || GetID()>=brInfo->GetNelement()) {
2531 TStreamerElement* currentStreamerElement = brInfo->GetElement(GetID());
2532 TDataMember* dm = (TDataMember*) motherCl->GetListOfDataMembers()->FindObject(currentStreamerElement->GetName());
2537 if (!motherCl->IsLoaded()) {
2538 TVirtualStreamerInfo* newInfo = motherCl->GetStreamerInfo();
2539 if (newInfo != brInfo) {
2540 TStreamerElement* newElems = (TStreamerElement*) newInfo->GetElements()->FindObject(currentStreamerElement->GetName());
2542 if (newElems->GetClassPointer())
2543 newType = newElems->GetClassPointer()->GetName();
2545 newType = newElems->GetTypeName();
2548 if (newType.Length()==0) {
2549 if (currentStreamerElement->GetClassPointer())
2550 newType = currentStreamerElement->GetClassPointer()->GetName();
2552 newType = currentStreamerElement->GetTypeName();
2556 newType = dm->GetTypeName();
2558 cl = TClass::GetClass(newType);
2577 Int_t TBranchElement::GetEntry(Long64_t entry, Int_t getall)
2587 TBranchRef* bref = fTree->GetBranchRef();
2588 if (R__unlikely(bref)) {
2589 R__LOCKGUARD_IMT(gROOTMutex);
2590 fBranchID = bref->SetParent(
this, fBranchID);
2591 bref->SetRequestedEntry(entry);
2596 if (R__unlikely(IsAutoDelete())) {
2597 SetBit(kDeleteObject);
2598 SetAddress(fAddress);
2600 if (R__unlikely(!fAddress && !TestBit(kDecomposedObj))) {
2601 R__LOCKGUARD_IMT(gROOTMutex);
2602 SetupAddressesImpl();
2606 Int_t nbranches = fBranches.GetEntriesFast();
2612 if ((fType == 3) || (fType == 4)) {
2613 Int_t nb = TBranch::GetEntry(entry, getall);
2621 case ROOT::kSTLmultiset:
2622 case ROOT::kSTLunorderedset:
2623 case ROOT::kSTLunorderedmultiset:
2625 case ROOT::kSTLmultimap:
2626 case ROOT::kSTLunorderedmap:
2627 case ROOT::kSTLunorderedmultimap:
2631 for (Int_t i = 0; i < nbranches; ++i) {
2632 TBranch* branch = (TBranch*) fBranches.UncheckedAt(i);
2633 Int_t nb = branch->GetEntry(entry, getall);
2641 if (!TestBit(kDecomposedObj) && fReadActionSequence && !fReadActionSequence->fActions.empty()) {
2645 TBufferFile b(TBufferFile::kRead, 1);
2647 auto ndata = GetNdata();
2649 TClonesArray* clones = (TClonesArray*) fObject;
2650 if (clones->IsZombie()) {
2653 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,ndata);
2655 char **arr = (
char **)clones->GetObjectRef();
2656 char **end = arr + fNdata;
2658 b.ApplySequenceVecPtr(*fReadActionSequence,arr,end);
2659 }
else if (fType == 4) {
2662 TBufferFile b(TBufferFile::kRead, 1);
2664 auto ndata = GetNdata();
2666 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,ndata);
2667 TVirtualCollectionProxy *proxy = GetCollectionProxy();
2668 TVirtualCollectionProxy::TPushPop helper(proxy, fObject);
2670 TVirtualCollectionIterators *iter = fIterators;
2671 b.ApplySequence(*fReadActionSequence,iter->fBegin,iter->fEnd);
2675 TBufferFile b(TBufferFile::kRead, 1);
2676 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,fNdata);
2677 b.ApplySequence(*fReadActionSequence, fObject);
2682 if (fBranchCount && (fBranchCount->GetReadEntry() != entry)) {
2683 Int_t nb = fBranchCount->TBranch::GetEntry(entry, getall);
2689 Int_t nb = TBranch::GetEntry(entry, getall);
2696 if (R__unlikely(fTree->Debug() > 0)) {
2697 if ((entry >= fTree->GetDebugMin()) && (entry <= fTree->GetDebugMax())) {
2698 Info(
"GetEntry",
"%lld, branch=%s, nbytes=%d", entry, GetName(), nbytes);
2710 Int_t TBranchElement::GetExpectedType(TClass *&expectedClass,EDataType &expectedType)
2713 expectedType = kOther_t;
2715 Int_t type = GetStreamerType();
2716 if ((type == -1) || (fID == -1)) {
2717 expectedClass = fBranchClass;
2722 TStreamerElement* element = GetInfoImp()->GetElement(fID);
2724 expectedClass = element->GetClassPointer();
2725 if (!expectedClass) {
2726 TDataType* data = gROOT->GetType(element->GetTypeNameBasic());
2728 Error(
"GetExpectedType",
"Did not find the type number for %s", element->GetTypeNameBasic());
2731 expectedType = (EDataType) data->GetType();
2735 Error(
"GetExpectedType",
"Did not find the type for %s",GetName());
2745 const char* TBranchElement::GetIconName()
const
2748 return "TBranchElement-folder";
2750 return "TBranchElement-leaf";
2758 Bool_t TBranchElement::GetMakeClass()
const
2760 return TestBit(kDecomposedObj);
2766 Int_t TBranchElement::GetMaximum()
const
2769 return fBranchCount->GetMaximum();
2777 char* TBranchElement::GetObject()
const
2786 TClass* TBranchElement::GetParentClass()
2788 return fParentClass.GetClass();
2794 const char* TBranchElement::GetTypeName()
const
2796 if (fType == 3 || fType == 4) {
2800 if ((fStreamerType < 1) || (fStreamerType > 59)) {
2801 if (fBranchClass.GetClass()) {
2803 return GetInfoImp()->GetElement(fID)->GetTypeName();
2805 return fBranchClass.GetClass()->GetName();
2811 const char *types[20] = {
2833 Int_t itype = fStreamerType % 20;
2834 return types[itype];
2839 template Double_t TBranchElement::GetTypedValue(Int_t j, Int_t len, Bool_t subarr)
const;
2840 template Long64_t TBranchElement::GetTypedValue(Int_t j, Int_t len, Bool_t subarr)
const;
2841 template LongDouble_t TBranchElement::GetTypedValue(Int_t j, Int_t len, Bool_t subarr)
const;
2843 template <
typename T>
2844 T TBranchElement::GetTypedValue(Int_t j, Int_t len, Bool_t subarr)
const
2859 char *
object = fObject;
2860 if (TestBit(kCache)) {
2861 if (GetInfoImp()->GetElements()->At(fID)->TestBit(TStreamerElement::kRepeat)) {
2863 }
else if (fOnfileObject) {
2864 object = fOnfileObject->GetObjectAt(0);
2868 if (!j && fBranchCount) {
2869 Long64_t entry = fTree->GetReadEntry();
2872 if (entry != fBranchCount->GetReadEntry()) {
2873 fBranchCount->TBranch::GetEntry(entry);
2875 if (fBranchCount2 && entry != fBranchCount2->GetReadEntry()) {
2876 fBranchCount2->TBranch::GetEntry(entry);
2880 if (TestBit(kDecomposedObj)) {
2884 if ((fType == 3) || (fType == 4)) {
2887 }
else if ((fType == 31) || (fType == 41)) {
2889 Int_t atype = fStreamerType;
2893 return GetInfoImp()->GetTypedValue<T>(fAddress, atype, j, 1);
2894 }
else if (fType <= 2) {
2897 if ((fStreamerType > 40) && (fStreamerType < 55)) {
2898 Int_t atype = fStreamerType - 20;
2899 return GetInfoImp()->GetTypedValue<T>(fAddress, atype, j, 1);
2901 return GetInfoImp()->GetTypedValue<T>(object, prID, j, -1);
2914 TClonesArray* clones = (TClonesArray*)
object;
2916 return GetInfoImp()->GetTypedValueClones<T>(clones, prID, j, len, fOffset);
2918 return GetInfoImp()->GetTypedValueClones<T>(clones, prID, j/len, j%len, fOffset);
2919 }
else if (fType == 41) {
2920 TVirtualCollectionProxy::TPushPop helper(((TBranchElement*)
this)->GetCollectionProxy(),
object);
2921 if( fSplitLevel < TTree::kSplitCollectionOfPointers )
2924 return GetInfoImp()->GetTypedValueSTL<T>(((TBranchElement*)
this)->GetCollectionProxy(), prID, j, len, fOffset);
2926 return GetInfoImp()->GetTypedValueSTL<T>(((TBranchElement*)
this)->GetCollectionProxy(), prID, j/len, j%len, fOffset);
2931 return GetInfoImp()->GetTypedValueSTLP<T>(((TBranchElement*)
this)->GetCollectionProxy(), prID, j, len, fOffset);
2932 return GetInfoImp()->GetTypedValueSTLP<T>(((TBranchElement*)
this)->GetCollectionProxy(), prID, j/len, j%len, fOffset);
2936 return GetInfoImp()->GetTypedValue<T>(object, prID, j, -1);
2946 void* TBranchElement::GetValuePointer()
const
2951 char *
object = fObject;
2952 if (TestBit(kCache)) {
2953 if (GetInfoImp()->GetElements()->At(fID)->TestBit(TStreamerElement::kRepeat)) {
2955 }
else if (fOnfileObject) {
2956 object = fOnfileObject->GetObjectAt(0);
2961 Long64_t entry = fTree->GetReadEntry();
2962 fBranchCount->TBranch::GetEntry(entry);
2963 if (fBranchCount2) fBranchCount2->TBranch::GetEntry(entry);
2965 if (TestBit(kDecomposedObj)) {
2972 }
else if (fType == 4) {
2975 }
else if (fType == 31) {
2980 }
else if (fType == 41) {
2985 }
else if (fType <= 2) {
2987 if (fStreamerType > 40 && fStreamerType < 55) {
3000 }
else if (fType == 41) {
3002 }
else if (prID < 0) {
3006 if (!GetInfoImp() || !
object)
return 0;
3007 char **val = (
char**)(
object+GetInfoImp()->TStreamerInfo::GetElementOffset(prID));
3029 void TBranchElement::InitializeOffsets()
3031 Int_t nbranches = fBranches.GetEntriesFast();
3043 R__LOCKGUARD(gInterpreterMutex);
3047 if (CanSelfReference(fBranchClass)) {
3048 if (fBranchClass.GetClass()->IsTObject()) {
3049 SetBit(kBranchObject);
3057 delete[] fBranchOffset;
3059 fBranchOffset =
new Int_t[nbranches];
3061 if (!fBranchClass.GetClass()) {
3062 Warning(
"InitializeOffsets",
"No branch class set for branch: %s", GetName());
3063 fInitOffsets = kTRUE;
3067 if (!GetInfoImp()) {
3068 Warning(
"InitializeOffsets",
"No streamer info available for branch: %s of class: %s", GetName(), fBranchClass.GetClass()->GetName());
3069 fInitOffsets = kTRUE;
3078 TStreamerElement* branchElem = 0;
3079 Int_t localOffset = 0;
3080 TClass* branchClass = fBranchClass.GetClass();
3081 Bool_t renamed = kFALSE;
3089 TVirtualStreamerInfo* si = GetInfoImp();
3091 if (!si->IsCompiled()) {
3092 Warning(
"InitializeOffsets",
"Streamer info for branch: %s has no elements array!", GetName());
3093 fInitOffsets = kTRUE;
3097 branchElem = si->GetElement(fID);
3099 Warning(
"InitializeOffsets",
"Cannot get streamer element for branch: %s!", GetName());
3100 fInitOffsets = kTRUE;
3102 }
else if (branchElem->TestBit(TStreamerElement::kRepeat)) {
3105 if (si->GetElement(fID+1)) {
3106 branchElem = si->GetElement(fID+1);
3109 localOffset = branchElem->GetOffset();
3110 branchClass = branchElem->GetClassPointer();
3111 if (localOffset == TStreamerInfo::kMissing) {
3114 renamed = branchClass && branchElem->GetNewClass() && (branchClass != branchElem->GetNewClass());
3117 renamed = fTargetClass != fBranchClass;
3120 Error(
"InitializeOffsets",
"Could not find class for branch: %s", GetName());
3121 fInitOffsets = kTRUE;
3129 TString stlParentName;
3130 Bool_t stlParentNameUpdated = kFALSE;
3133 TBranch *br = GetMother()->GetSubBranch(
this );
3134 stlParentName = br->GetName();
3135 stlParentName.Strip( TString::kTrailing,
'.' );
3143 for (Int_t subBranchIdx = 0; subBranchIdx < nbranches; ++subBranchIdx) {
3144 bool alternateElement =
false;
3146 fBranchOffset[subBranchIdx] = 0;
3147 TBranchElement* subBranch =
dynamic_cast<TBranchElement*
> (fBranches[subBranchIdx]);
3148 if (subBranch == 0) {
3154 if (subBranch->fBranchClass == branchClass) {
3155 if (branchElem) subBranch->SetTargetClass(branchElem->GetNewClass()->GetName());
3156 else subBranch->SetTargetClass(fTargetClass->GetName());
3160 TVirtualStreamerInfo* sinfo = subBranch->GetInfoImp();
3162 Warning(
"InitializeOffsets",
"No streamer info for branch: %s subbranch: %s", GetName(), subBranch->GetName());
3163 fBranchOffset[subBranchIdx] = TStreamerInfo::kMissing;
3166 if (!sinfo->IsCompiled()) {
3167 Warning(
"InitializeOffsets",
"No elements array for branch: %s subbranch: %s", GetName(), subBranch->GetName());
3168 fBranchOffset[subBranchIdx] = TStreamerInfo::kMissing;
3172 TStreamerElement* subBranchElement = sinfo->GetElement(subBranch->fID);
3173 if (!subBranchElement) {
3174 Warning(
"InitializeOffsets",
"No streamer element for branch: %s subbranch: %s", GetName(), subBranch->GetName());
3175 fBranchOffset[subBranchIdx] = TStreamerInfo::kMissing;
3177 }
else if (subBranchElement->TestBit(TStreamerElement::kRepeat)) {
3180 if (sinfo->GetElement(subBranch->fID+1)) {
3181 subBranchElement = sinfo->GetElement(subBranch->fID+1);
3183 }
else if (subBranchElement->TestBit(TStreamerElement::kCache)) {
3187 if (subBranch->fReadActionSequence && subBranch->fReadActionSequence->fActions.size() > 1) {
3188 typedef TStreamerInfoActions::ActionContainer_t::iterator iterator;
3189 iterator end = subBranch->fReadActionSequence->fActions.end();
3190 for(iterator iter = subBranch->fReadActionSequence->fActions.begin();
3191 iter != end; ++iter) {
3192 TStreamerInfoActions::TConfiguration *config = iter->fConfiguration;
3193 UInt_t
id = config->fElemId;
3194 TStreamerElement *e = (TStreamerElement*)config->fInfo->GetElements()->At(
id);
3195 if (e && !e->TestBit(TStreamerElement::kCache)) {
3196 subBranchElement = e;
3197 alternateElement =
true;
3204 localOffset = subBranchElement->GetOffset();
3205 if (localOffset == TStreamerInfo::kMissing) {
3206 subBranch->fObject = 0;
3209 Int_t streamerType = subBranchElement->GetType();
3210 if (streamerType > TStreamerInfo::kObject
3211 && subBranch->GetListOfBranches()->GetEntries()==0
3212 && CanSelfReference(subBranchElement->GetClass()))
3214 subBranch->SetBit(kBranchAny);
3216 subBranch->ResetBit(kBranchAny);
3220 if (subBranchElement->GetNewType()<0) {
3221 subBranch->ResetBit(kBranchAny);
3222 subBranch->ResetBit(kBranchObject);
3226 TBranch* mother = GetMother();
3228 Warning(
"InitializeOffsets",
"Branch '%s' has no mother!", GetName());
3229 fBranchOffset[subBranchIdx] = TStreamerInfo::kMissing;
3232 TString motherName(mother->GetName());
3233 Bool_t motherDot = kFALSE;
3234 if (motherName.Length() && strchr(motherName.Data(),
'.')) {
3237 Bool_t motherDotAtEnd = kFALSE;
3238 if (motherName.Length() && (motherName[motherName.Length()-1] ==
'.')) {
3239 motherDotAtEnd = kTRUE;
3242 Bool_t isBaseSubBranch = kFALSE;
3243 if ((subBranch->fType == 1) || (subBranchElement && subBranchElement->IsBase())) {
3251 isBaseSubBranch = kTRUE;
3254 Bool_t isContDataMember = kFALSE;
3255 if ((subBranch->fType == 31) || (subBranch->fType == 41)) {
3257 isContDataMember = kTRUE;
3281 TString dataName(subBranch->GetName());
3282 if (motherDotAtEnd) {
3284 dataName.Remove(0, motherName.Length());
3286 if (!stlParentNameUpdated && stlParentName.Length()) {
3287 stlParentName.Remove(0, motherName.Length());
3288 stlParentNameUpdated = kTRUE;
3290 }
else if (motherDot) {
3299 if ((fID < 0) && (subBranchElement->IsA() == TStreamerBase::Class())) {
3304 if (dataName.Length() == motherName.Length()) {
3305 dataName.Remove(0, motherName.Length());
3307 if (!stlParentNameUpdated && stlParentName.Length()) {
3308 stlParentName.Remove(0, motherName.Length());
3313 if (dataName.Length() > motherName.Length()) {
3314 dataName.Remove(0, motherName.Length() + 1);
3315 if (!stlParentNameUpdated && stlParentName.Length()) {
3316 stlParentName.Remove(0, motherName.Length());
3321 stlParentNameUpdated = kTRUE;
3322 if (isBaseSubBranch) {
3325 TString pattern(subBranchElement->GetName());
3326 if (pattern.Length() <= dataName.Length()) {
3327 if (!strcmp(dataName.Data() + (dataName.Length() - pattern.Length()), pattern.Data())) {
3331 dataName.Remove(dataName.Length() - pattern.Length());
3335 if (dataName.Length()) {
3336 if (dataName[0] ==
'.') {
3337 dataName.Remove(0, 1);
3345 TString parentName(GetName());
3346 if (motherDotAtEnd) {
3348 parentName.Remove(0, motherName.Length());
3349 }
else if (motherDot) {
3358 if ((fID > -1) && (mother == mother->GetSubBranch(
this)) && (branchElem->IsA() == TStreamerBase::Class())) {
3363 if (parentName.Length() == motherName.Length()) {
3364 parentName.Remove(0, motherName.Length());
3368 if (parentName.Length() > motherName.Length()) {
3369 parentName.Remove(0, motherName.Length() + 1);
3376 if (mother != mother->GetSubBranch(
this)) {
3381 TString pattern(branchElem->GetName());
3382 if (pattern.Length() <= parentName.Length()) {
3383 if (!strcmp(parentName.Data() + (parentName.Length() - pattern.Length()), pattern.Data())) {
3387 parentName.Remove(parentName.Length() - pattern.Length());
3399 RemovePrefix(dataName, parentName);
3403 if (dataName.Length()) {
3404 if (dataName[0] ==
'.') {
3405 dataName.Remove(0, 1);
3410 if (dataName.Length()) {
3411 if (dataName[dataName.Length()-1] ==
'.') {
3412 dataName.Remove(dataName.Length() - 1, 1);
3428 if (dataName.Length()) {
3434 TStreamerInfo *subInfo = subBranch->GetInfoImp();
3436 if (subBranchElement->TestBit(TStreamerElement::kCache)) {
3437 pClass = ((TStreamerElement*)subInfo->GetElements()->At(0))->GetClassPointer();
3444 pClass = branchElem->GetClassPointer();
3445 if (pClass->Property() & kIsAbstract) {
3448 TBranchElement *parent = (TBranchElement*)GetMother()->GetSubBranch(
this);
3449 if (parent && parent !=
this && !parent->GetClass()->IsLoaded() ) {
3452 TString target = pClass->GetName();
3453 target +=
"@@emulated";
3455 pClass = TClass::GetClass(target);
3461 pClass = subBranch->GetParentClass();
3468 if (GetClonesName() && strlen(GetClonesName())) {
3469 pClass = fClonesClass;
3471 Warning(
"InitializeOffsets",
"subBranch: '%s' has no parent class, and cannot get class for clones class: '%s'!", subBranch->GetName(), GetClonesName());
3472 fBranchOffset[subBranchIdx] = TStreamerInfo::kMissing;
3475 Warning(
"InitializeOffsets",
"subBranch: '%s' has no parent class! Assuming parent class is: '%s'.", subBranch->GetName(), pClass->GetName());
3477 if (fBranchCount && fBranchCount->fCollProxy && fBranchCount->fCollProxy->GetValueClass()) {
3478 pClass = fBranchCount->fCollProxy->GetValueClass();
3479 Warning(
"InitializeOffsets",
"subBranch: '%s' has no parent class! Assuming parent class is: '%s'.", subBranch->GetName(), pClass ? pClass->GetName() :
"unknowned class");
3484 pClass = branchClass;
3489 if (renamed && pClass) {
3490 if (pClass == branchClass) {
3491 pClass = branchElem->GetNewClass();
3492 }
else if (fCollProxy && pClass == branchClass->GetCollectionProxy()->GetValueClass()) {
3493 pClass = fCollProxy->GetValueClass();
3502 if( dynamic_cast<TBranchSTL*>(fParent) && stlParentName.Length() )
3504 if( !strncmp( stlParentName.Data(), dataName.Data(), stlParentName.Length()-1 )
3505 && dataName[ stlParentName.Length() ] ==
'.' )
3506 dataName.Remove( 0, stlParentName.Length()+1 );
3513 if (alternateElement) {
3514 Ssiz_t dotpos = dataName.Last(
'.');
3515 Ssiz_t endpos = dataName.Length();
3516 if (dotpos != kNPOS) ++dotpos;
else dotpos = 0;
3517 dataName.Replace(dotpos,endpos-dotpos,subBranchElement->GetFullName());
3519 TRealData* rd = pClass->GetRealData(dataName);
3520 if (rd && (!rd->TestBit(TRealData::kTransient) || alternateElement)) {
3524 offset = rd->GetThisOffset();
3525 }
else if (subBranchElement->TestBit(TStreamerElement::kWholeObject)) {
3532 if (fEntries == 0) {
3535 if (pClass->GetListOfRealData()->GetEntries() == 0) {
3538 Error(
"InitializeOffsets",
3539 "Could not find the real data member '%s' when constructing the branch '%s' [Likely missing ShowMember].",
3540 dataName.Data(),GetName());
3541 }
else if (subInfo && subInfo->GetClassVersion()!=subInfo->GetClass()->GetClassVersion()) {
3544 Info(
"InitializeOffsets",
3545 "TTree created with an older schema, some data might not be copied in 'slow-cloning' mode; fast-cloning should have the correct result. '%s' is missing when constructing the branch '%s'. ",
3546 dataName.Data(),GetName());
3549 Fatal(
"InitializeOffsets",
3550 "Could not find the real data member '%s' when constructing the branch '%s' [Likely an internal error, please report to the developers].",
3551 dataName.Data(),GetName());
3554 localOffset = TStreamerInfo::kMissing;
3558 if (isBaseSubBranch) {
3561 Warning(
"InitializeOffsets",
"Could not find the data member name for branch '%s' with parent branch '%s', assuming offset is zero!", subBranch->GetName(), GetName());
3569 if (isContDataMember) {
3576 if (subBranch->fObject == 0 && localOffset == TStreamerInfo::kMissing) {
3577 subBranch->SetMissing();
3581 fBranchOffset[subBranchIdx] = TStreamerInfo::kMissing;
3583 if (isBaseSubBranch) {
3586 subBranch->SetOffset(offset);
3590 subBranch->SetOffset(offset - localOffset);
3595 Int_t isSplit = 0 != subBranch->GetListOfBranches()->GetEntriesFast();
3596 if (subBranch->fObject == 0 && localOffset == TStreamerInfo::kMissing) {
3598 fBranchOffset[subBranchIdx] = TStreamerInfo::kMissing;
3600 }
else if (isSplit) {
3601 if (isBaseSubBranch) {
3604 fBranchOffset[subBranchIdx] = offset + localOffset;
3609 fBranchOffset[subBranchIdx] = offset;
3612 if (isBaseSubBranch) {
3615 fBranchOffset[subBranchIdx] = offset;
3619 fBranchOffset[subBranchIdx] = offset - localOffset;
3629 if (GetOffset() == TStreamerInfo::kMissing) {
3634 const bool isSplitNode = (fType == 2 || fType == 1 || (fType == 0 && fID == -2)) && !fBranches.IsEmpty();
3635 if (fReadActionSequence && isSplitNode) {
3636 TBranchElement *parent =
dynamic_cast<TBranchElement*
>(GetMother()->GetSubBranch(
this));
3637 auto index = parent->fBranches.IndexOf(
this);
3639 fReadActionSequence->AddToOffset( - parent->fBranchOffset[index] );
3643 fInitOffsets = kTRUE;
3649 Bool_t TBranchElement::IsFolder()
const
3651 Int_t nbranches = fBranches.GetEntriesFast();
3652 if (nbranches >= 1) {
3655 TList* browsables =
const_cast<TBranchElement*
>(
this)->GetBrowsables();
3656 return browsables && browsables->GetSize();
3667 Bool_t TBranchElement::IsMissingCollection()
const
3669 Bool_t ismissing = kFALSE;
3670 TBasket* basket = (TBasket*) fBaskets.UncheckedAt(fReadBasket);
3671 if (basket && fTree) {
3672 Long64_t entry = fTree->GetReadEntry();
3673 Long64_t first = fBasketEntry[fReadBasket];
3675 if (fReadBasket == fWriteBasket) {
3676 last = fEntryNumber - 1;
3678 last = fBasketEntry[fReadBasket+1] - 1;
3680 Int_t* entryOffset = basket->GetEntryOffset();
3684 bufbegin = entryOffset[entry-first];
3687 bufnext = entryOffset[entry+1-first];
3689 bufnext = basket->GetLast();
3691 if (bufnext == bufbegin) {
3695 if (basket->GetNevBufSize() == 0) {
3707 static void PrintElements(
const TStreamerInfo *info,
const TStreamerInfoActions::TIDs &ids)
3709 for(
auto &cursor : ids) {
3710 auto id = cursor.fElemID;
3712 auto el = info->GetElement(
id);
3716 Error(
"TBranchElement::Print",
"Element for id #%d not found in StreamerInfo for %s",
3717 id, info->GetName());
3719 TClass::GetClass(
"PFTauWith")->GetStreamerInfos()->ls();
3721 }
else if (cursor.fNestedIDs) {
3722 Printf(
" Within subobject of type %s offset = %d", cursor.fNestedIDs->fInfo->GetName(), cursor.fNestedIDs->fOffset);
3723 PrintElements(cursor.fNestedIDs->fInfo, cursor.fNestedIDs->fIDs);
3728 void TBranchElement::Print(Option_t* option)
const
3730 Int_t nbranches = fBranches.GetEntriesFast();
3731 if (strncmp(option,
"debugAddress",strlen(
"debugAddress"))==0) {
3732 if (strlen(option)==strlen(
"debugAddress")) {
3733 Printf(
"%-24s %-16s %2s %4s %-16s %-16s %8s %8s %s\n",
3734 "Branch Name",
"Streamer Class",
"ID",
"Type",
"Class",
"Parent",
"pOffset",
"fOffset",
"fObject");
3736 if (strlen(GetName())>24) Printf(
"%-24s\n%-24s ", GetName(),
"");
3737 else Printf(
"%-24s ", GetName());
3739 TBranchElement *parent =
dynamic_cast<TBranchElement*
>(GetMother()->GetSubBranch(
this));
3740 Int_t ind = parent ? parent->GetListOfBranches()->IndexOf(
this) : -1;
3741 TVirtualStreamerInfo *info = ((TBranchElement*)
this)->GetInfoImp();
3743 Printf(
"%-16s %2d %4d %-16s %-16s %8x %8x %s\n",
3744 info ? info->GetName() :
"StreamerInfo unvailable", GetID(), GetType(),
3745 GetClassName(), GetParentName(),
3746 (fBranchOffset&&parent && ind>=0) ? parent->fBranchOffset[ind] : 0,
3747 GetOffset(), GetObject());
3748 for (Int_t i = 0; i < nbranches; ++i) {
3749 TBranchElement* subbranch = (TBranchElement*)fBranches.At(i);
3750 subbranch->Print(
"debugAddressSub");
3754 if (strncmp(option,
"debugInfo",strlen(
"debugInfo"))==0) {
3755 Printf(
"Branch %s uses:",GetName());
3761 TStreamerInfo *localInfo = GetInfoImp();
3762 if (fType == 3 || fType == 4) {
3764 localInfo = FindOnfileInfo(fClonesClass, fBranches);
3766 Printf(
" With elements:");
3767 if (fType != 3 && fType != 4)
3768 localInfo->GetElement(fID)->ls();
3769 PrintElements(localInfo, fNewIDs);
3770 Printf(
" with read actions:");
3771 if (fReadActionSequence) fReadActionSequence->Print(option);
3772 Printf(
" with write actions:");
3773 if (fFillActionSequence) fFillActionSequence->Print(option);
3774 }
else if (!fNewIDs.empty() && GetInfoImp()) {
3775 TStreamerInfo *localInfo = GetInfoImp();
3776 if (fType == 3 || fType == 4) {
3778 localInfo = FindOnfileInfo(fClonesClass, fBranches);
3780 PrintElements(localInfo, fNewIDs);
3781 Printf(
" with read actions:");
3782 if (fReadActionSequence) fReadActionSequence->Print(option);
3783 Printf(
" with write actions:");
3784 if (fFillActionSequence) fFillActionSequence->Print(option);
3786 TString suboption =
"debugInfoSub";
3787 suboption += (option+strlen(
"debugInfo"));
3788 for (Int_t i = 0; i < nbranches; ++i) {
3789 TBranchElement* subbranch = (TBranchElement*)fBranches.At(i);
3790 subbranch->Print(suboption);
3797 if (strcmp(GetName(),GetTitle()) == 0) {
3798 Printf(
"*Branch :%-66s *",GetName());
3800 Printf(
"*Branch :%-9s : %-54s *",GetName(),GetTitle());
3802 Printf(
"*Entries : %8d : BranchElement (see below) *",Int_t(fEntries));
3803 Printf(
"*............................................................................*");
3806 TBranch::Print(option);
3808 for (Int_t i=0;i<nbranches;i++) {
3809 TBranch *branch = (TBranch*)fBranches.At(i);
3810 branch->Print(option);
3813 TBranch::Print(option);
3820 void TBranchElement::PrintValue(Int_t lenmax)
const
3824 TStreamerInfo *info = GetInfoImp();
3826 char *
object = fObject;
3827 if (TestBit(kCache)) {
3828 if (info->GetElements()->At(fID)->TestBit(TStreamerElement::kRepeat)) {
3830 }
else if (fOnfileObject) {
3831 object = fOnfileObject->GetObjectAt(0);
3835 if (TestBit(kDecomposedObj)) {
3839 if (fType == 3 || fType == 4) {
3841 printf(
" %-15s = %d\n", GetName(), fNdata);
3843 }
else if (fType == 31 || fType == 41) {
3845 Int_t n = TMath::Min(10, fNdata);
3846 Int_t atype = fStreamerType + TVirtualStreamerInfo::kOffsetL;
3847 if (fStreamerType == TVirtualStreamerInfo::kChar) {
3851 atype = TVirtualStreamerInfo::kOffsetL + TVirtualStreamerInfo::kUChar;
3855 printf(
" %-15s = %d\n", GetName(), fNdata);
3858 if (fStreamerType > 20) {
3860 TLeafElement* leaf = (TLeafElement*) fLeaves.UncheckedAt(0);
3861 n = n * leaf->GetLenStatic();
3864 GetInfoImp()->PrintValue(GetName(), fAddress, atype, n, lenmax);
3867 }
else if (fType <= 2) {
3870 if ((fStreamerType > 40) && (fStreamerType < 55)) {
3871 Int_t atype = fStreamerType - 20;
3872 TBranchElement* counterElement = (TBranchElement*) fBranchCount;
3873 Int_t n = (Int_t) counterElement->GetValue(0, 0);
3875 GetInfoImp()->PrintValue(GetName(), fAddress, atype, n, lenmax);
3879 GetInfoImp()->PrintValue(GetName(),
object, prID, -1, lenmax);
3884 }
else if (fType == 3) {
3885 printf(
" %-15s = %d\n", GetName(), fNdata);
3886 }
else if (fType == 31) {
3887 TClonesArray* clones = (TClonesArray*)
object;
3889 GetInfoImp()->PrintValueClones(GetName(), clones, prID, fOffset, lenmax);
3891 }
else if (fType == 41) {
3892 TVirtualCollectionProxy::TPushPop helper(((TBranchElement*)
this)->GetCollectionProxy(),
object);
3894 GetInfoImp()->PrintValueSTL(GetName(), ((TBranchElement*)
this)->GetCollectionProxy(), prID, fOffset, lenmax);
3898 GetInfoImp()->PrintValue(GetName(),
object, prID, -1, lenmax);
3906 void TBranchElement::ReadLeavesImpl(TBuffer&)
3908 Fatal(
"ReadLeaves",
"The ReadLeaves function has not been configured for %s",GetName());
3915 void TBranchElement::ReadLeavesMakeClass(TBuffer& b)
3919 if (fType == 3 || fType == 4) {
3921 Int_t *n = (Int_t*) fAddress;
3923 if ((n[0] < 0) || (n[0] > fMaximum)) {
3924 if (IsMissingCollection()) {
3926 b.SetBufferOffset(b.Length() -
sizeof(n));
3928 Error(
"ReadLeaves",
"Incorrect size read for the container in %s\nThe size read is %d when the maximum is %d\nThe size is reset to 0 for this entry (%lld)", GetName(), n[0], fMaximum, GetReadEntry());
3934 Int_t nbranches = fBranches.GetEntriesFast();
3937 case ROOT::kSTLmultiset:
3939 case ROOT::kSTLmultimap:
3940 for (Int_t i=0; i<nbranches; i++) {
3941 TBranch *branch = (TBranch*)fBranches[i];
3942 Int_t nb = branch->GetEntry(GetReadEntry(), 1);
3953 }
else if (fType == 31 || fType == 41) {
3954 fNdata = fBranchCount->GetNdata();
3955 Int_t atype = fStreamerType;
3957 if (atype > 54)
return;
3964 if (!fBranchCount2)
return;
3965 const char *len_where = (
char*)fBranchCount2->fAddress;
3966 if (!len_where)
return;
3967 Int_t len_atype = fBranchCount2->fStreamerType;
3971 for( k=0; k<n; k++) {
3972 char **where = &(((
char**)fAddress)[k]);
3976 case 1: {length = ((Char_t*) len_where)[k];
break;}
3977 case 2: {length = ((Short_t*) len_where)[k];
break;}
3978 case 3: {length = ((Int_t*) len_where)[k];
break;}
3979 case 4: {length = ((Long_t*) len_where)[k];
break;}
3981 case 6: {length = ((Int_t*) len_where)[k];
break;}
3983 case 11: {length = ((UChar_t*) len_where)[k];
break;}
3984 case 12: {length = ((UShort_t*) len_where)[k];
break;}
3985 case 13: {length = ((UInt_t*) len_where)[k];
break;}
3986 case 14: {length = ((ULong_t*) len_where)[k];
break;}
3987 case 15: {length = ((UInt_t*) len_where)[k];
break;}
3988 case 16: {length = ((Long64_t*) len_where)[k];
break;}
3989 case 17: {length = ((ULong64_t*)len_where)[k];
break;}
3990 case 18: {length = ((Bool_t*) len_where)[k];
break;}
3994 if (length <= 0)
continue;
3995 if (isArray == 0)
continue;
3997 case 1: {*where=
new char[
sizeof(Char_t)*length]; b.ReadFastArray((Char_t*) *where, length);
break;}
3998 case 2: {*where=
new char[
sizeof(Short_t)*length]; b.ReadFastArray((Short_t*) *where, length);
break;}
3999 case 3: {*where=
new char[
sizeof(Int_t)*length]; b.ReadFastArray((Int_t*) *where, length);
break;}
4000 case 4: {*where=
new char[
sizeof(Long_t)*length]; b.ReadFastArray((Long_t*) *where, length);
break;}
4001 case 5: {*where=
new char[
sizeof(Float_t)*length]; b.ReadFastArray((Float_t*) *where, length);
break;}
4002 case 6: {*where=
new char[
sizeof(Int_t)*length]; b.ReadFastArray((Int_t*) *where, length);
break;}
4003 case 8: {*where=
new char[
sizeof(Double_t)*length]; b.ReadFastArray((Double_t*)*where, length);
break;}
4004 case 11: {*where=
new char[
sizeof(UChar_t)*length]; b.ReadFastArray((UChar_t*) *where, length);
break;}
4005 case 12: {*where=
new char[
sizeof(UShort_t)*length]; b.ReadFastArray((UShort_t*)*where, length);
break;}
4006 case 13: {*where=
new char[
sizeof(UInt_t)*length]; b.ReadFastArray((UInt_t*) *where, length);
break;}
4007 case 14: {*where=
new char[
sizeof(ULong_t)*length]; b.ReadFastArray((ULong_t*) *where, length);
break;}
4008 case 15: {*where=
new char[
sizeof(UInt_t)*length]; b.ReadFastArray((UInt_t*) *where, length);
break;}
4009 case 16: {*where=
new char[
sizeof(Long64_t)*length]; b.ReadFastArray((Long64_t*) *where, length);
break;}
4010 case 17: {*where=
new char[
sizeof(ULong64_t)*length]; b.ReadFastArray((ULong64_t*)*where, length);
break;}
4011 case 18: {*where=
new char[
sizeof(Bool_t)*length]; b.ReadFastArray((Bool_t*) *where, length);
break;}
4018 TLeafElement *leaf = (TLeafElement*)fLeaves.UncheckedAt(0);
4019 n *= leaf->GetLenStatic();
4022 case 1: {b.ReadFastArray((Char_t*) fAddress, n);
break;}
4023 case 2: {b.ReadFastArray((Short_t*) fAddress, n);
break;}
4024 case 3: {b.ReadFastArray((Int_t*) fAddress, n);
break;}
4025 case 4: {b.ReadFastArray((Long_t*) fAddress, n);
break;}
4026 case 5: {b.ReadFastArray((Float_t*) fAddress, n);
break;}
4027 case 6: {b.ReadFastArray((Int_t*) fAddress, n);
break;}
4028 case 8: {b.ReadFastArray((Double_t*)fAddress, n);
break;}
4029 case 11: {b.ReadFastArray((UChar_t*) fAddress, n);
break;}
4030 case 12: {b.ReadFastArray((UShort_t*)fAddress, n);
break;}
4031 case 13: {b.ReadFastArray((UInt_t*) fAddress, n);
break;}
4032 case 14: {b.ReadFastArray((ULong_t*) fAddress, n);
break;}
4033 case 15: {b.ReadFastArray((UInt_t*) fAddress, n);
break;}
4034 case 16: {b.ReadFastArray((Long64_t*)fAddress, n);
break;}
4035 case 17: {b.ReadFastArray((ULong64_t*)fAddress, n);
break;}
4036 case 18: {b.ReadFastArray((Bool_t*) fAddress, n);
break;}
4038 TVirtualStreamerInfo* si = GetInfoImp();
4039 TStreamerElement* se = (TStreamerElement*) si->GetElement(fID);
4040 Double_t *xx = (Double_t*) fAddress;
4041 for (Int_t ii=0;ii<n;ii++) {
4042 b.ReadDouble32(&(xx[ii]),se);
4047 TVirtualStreamerInfo* si = GetInfoImp();
4048 TStreamerElement* se = (TStreamerElement*) si->GetElement(fID);
4049 Float_t *xx = (Float_t*) fAddress;
4050 for (Int_t ii=0;ii<n;ii++) {
4051 b.ReadFloat16(&(xx[ii]),se);
4057 }
else if (fType <= 2) {
4059 if (fStreamerType > 40 && fStreamerType < 55) {
4060 Int_t atype = fStreamerType - 40;
4062 if (fBranchCount==0) {
4065 TString countname( GetName() );
4066 Ssiz_t dot = countname.Last(
'.');
4068 countname.Remove(dot+1);
4072 TString counter( GetTitle() );
4073 Ssiz_t loc = counter.Last(
'[');
4075 counter.Remove(0,loc+1);
4077 loc = counter.Last(
']');
4079 counter.Remove(loc);
4081 countname += counter;
4082 SetBranchCount((TBranchElement *)fTree->GetBranch(countname));
4085 n = (Int_t)fBranchCount->GetValue(0,0);
4087 Warning(
"ReadLeaves",
"Missing fBranchCount for %s. Data will not be read correctly by the MakeClass mode.",GetName());
4094 case 1: {b.ReadFastArray((Char_t*) fAddress, n);
break;}
4095 case 2: {b.ReadFastArray((Short_t*) fAddress, n);
break;}
4096 case 3: {b.ReadFastArray((Int_t*) fAddress, n);
break;}
4097 case 4: {b.ReadFastArray((Long_t*) fAddress, n);
break;}
4098 case 5: {b.ReadFastArray((Float_t*) fAddress, n);
break;}
4099 case 6: {b.ReadFastArray((Int_t*) fAddress, n);
break;}
4100 case 8: {b.ReadFastArray((Double_t*)fAddress, n);
break;}
4101 case 11: {b.ReadFastArray((UChar_t*) fAddress, n);
break;}
4102 case 12: {b.ReadFastArray((UShort_t*)fAddress, n);
break;}
4103 case 13: {b.ReadFastArray((UInt_t*) fAddress, n);
break;}
4104 case 14: {b.ReadFastArray((ULong_t*) fAddress, n);
break;}
4105 case 15: {b.ReadFastArray((UInt_t*) fAddress, n);
break;}
4106 case 16: {b.ReadFastArray((Long64_t*) fAddress, n);
break;}
4107 case 17: {b.ReadFastArray((ULong64_t*)fAddress, n);
break;}
4108 case 18: {b.ReadFastArray((Bool_t*) fAddress, n);
break;}
4110 TVirtualStreamerInfo* si = GetInfoImp();
4111 TStreamerElement* se = (TStreamerElement*) si->GetElement(fID);
4112 Double_t *xx = (Double_t*) fAddress;
4113 for (Int_t ii=0;ii<n;ii++) {
4114 b.ReadDouble32(&(xx[ii]),se);
4119 TVirtualStreamerInfo* si = GetInfoImp();
4120 TStreamerElement* se = (TStreamerElement*) si->GetElement(fID);
4121 Float_t *xx = (Float_t*) fAddress;
4122 for (Int_t ii=0;ii<n;ii++) {
4123 b.ReadFloat16(&(xx[ii]),se);
4135 fBranchClass->Streamer(fObject,b);
4137 TStreamerInfo *info = GetInfoImp();
4142 b.ApplySequence(*fReadActionSequence, fObject);
4144 if (fStreamerType == TVirtualStreamerInfo::kCounter) {
4145 fNdata = (Int_t) GetValue(0, 0);
4159 void TBranchElement::ReadLeavesCollection(TBuffer& b)
4172 if ((n < 0) || (n > fMaximum)) {
4173 if (IsMissingCollection()) {
4175 b.SetBufferOffset(b.Length()-
sizeof(n));
4177 Error(
"ReadLeaves",
"Incorrect size read for the container in %s\n\tThe size read is %d while the maximum is %d\n\tThe size is reset to 0 for this entry (%lld)", GetName(), n, fMaximum, GetReadEntry());
4183 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,1);
4192 TVirtualCollectionProxy* proxy = GetCollectionProxy();
4193 TVirtualCollectionProxy::TPushPop helper(proxy, fObject);
4194 void* alternate = proxy->Allocate(fNdata,
true);
4195 if(fSTLtype != ROOT::kSTLvector && proxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
4196 fPtrIterators->CreateIterators(alternate, proxy);
4198 fIterators->CreateIterators(alternate, proxy);
4201 Int_t nbranches = fBranches.GetEntriesFast();
4204 case ROOT::kSTLunorderedset:
4205 case ROOT::kSTLunorderedmultiset:
4206 case ROOT::kSTLmultiset:
4208 case ROOT::kSTLmultimap:
4209 case ROOT::kSTLunorderedmap:
4210 case ROOT::kSTLunorderedmultimap:
4211 for (Int_t i = 0; i < nbranches; ++i) {
4212 TBranch *branch = (TBranch*) fBranches[i];
4213 Int_t nb = branch->GetEntry(GetReadEntry(), 1);
4228 if( proxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers )
4230 TClass *elClass = proxy->GetValueClass();
4239 if( !fNdata || *(
void**)proxy->At( 0 ) != 0 )
4242 for( ; i < fNdata; ++i )
4244 void **el = (
void**)proxy->At( i );
4246 *el = elClass->New();
4250 proxy->Commit(alternate);
4257 void TBranchElement::ReadLeavesCollectionSplitPtrMember(TBuffer& b)
4268 fNdata = fBranchCount->GetNdata();
4273 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,fNdata);
4275 TStreamerInfo *info = GetInfoImp();
4276 if (info == 0)
return;
4278 TVirtualCollectionProxy *proxy = GetCollectionProxy();
4279 TVirtualCollectionProxy::TPushPop helper(proxy, fObject);
4282 TVirtualCollectionPtrIterators *iter = fBranchCount->fPtrIterators;
4283 b.ApplySequence(*fReadActionSequence,iter->fBegin,iter->fEnd);
4290 void TBranchElement::ReadLeavesCollectionSplitVectorPtrMember(TBuffer& b)
4301 fNdata = fBranchCount->GetNdata();
4305 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,fNdata);
4307 TStreamerInfo *info = GetInfoImp();
4308 if (info == 0)
return;
4310 TVirtualCollectionProxy *proxy = GetCollectionProxy();
4311 TVirtualCollectionProxy::TPushPop helper(proxy, fObject);
4313 TVirtualCollectionIterators *iter = fBranchCount->fIterators;
4314 b.ApplySequenceVecPtr(*fReadActionSequence,iter->fBegin,iter->fEnd);
4321 void TBranchElement::ReadLeavesCollectionMember(TBuffer& b)
4332 fNdata = fBranchCount->GetNdata();
4336 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,fNdata);
4338 TStreamerInfo *info = GetInfoImp();
4339 if (info == 0)
return;
4343 TVirtualCollectionProxy *proxy = GetCollectionProxy();
4344 TVirtualCollectionProxy::TPushPop helper(proxy, fObject);
4346 TVirtualCollectionIterators *iter = fBranchCount->fIterators;
4347 b.ApplySequence(*fReadActionSequence,iter->fBegin,iter->fEnd);
4354 void TBranchElement::ReadLeavesClones(TBuffer& b)
4367 if ((n < 0) || (n > fMaximum)) {
4368 if (IsMissingCollection()) {
4370 b.SetBufferOffset(b.Length()-
sizeof(n));
4372 Error(
"ReadLeaves",
"Incorrect size read for the container in %s\n\tThe size read is %d while the maximum is %d\n\tThe size is reset to 0 for this entry (%lld)", GetName(), n, fMaximum, GetReadEntry());
4377 TClonesArray* clones = (TClonesArray*) fObject;
4378 if (clones->IsZombie()) {
4384 clones->ExpandCreateFast(fNdata);
4391 void TBranchElement::ReadLeavesClonesMember(TBuffer& b)
4405 fNdata = fBranchCount->GetNdata();
4406 TClonesArray* clones = (TClonesArray*) fObject;
4407 if (clones->IsZombie()) {
4410 TStreamerInfo *info = GetInfoImp();
4411 if (info==0)
return;
4416 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,fNdata);
4418 char **arr = (
char **)clones->GetObjectRef();
4419 char **end = arr + fNdata;
4420 b.ApplySequenceVecPtr(*fReadActionSequence,arr,end);
4428 void TBranchElement::ReadLeavesMember(TBuffer& b)
4430 R__ASSERT(fBranchCount==0);
4431 R__ASSERT(fStreamerType != TVirtualStreamerInfo::kCounter);
4441 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,1);
4446 if (TestBit(kBranchObject)) {
4447 b.MapObject((TObject*) fObject);
4448 }
else if (TestBit(kBranchAny)) {
4449 b.MapObject(fObject, fBranchClass);
4453 TStreamerInfo *info = GetInfoImp();
4458 b.ApplySequence(*fReadActionSequence, fObject);
4466 void TBranchElement::ReadLeavesMemberBranchCount(TBuffer& b)
4468 R__ASSERT(fStreamerType != TVirtualStreamerInfo::kCounter);
4482 if (TestBit(kBranchObject)) {
4483 b.MapObject((TObject*) fObject);
4484 }
else if (TestBit(kBranchAny)) {
4485 b.MapObject(fObject, fBranchClass);
4488 fNdata = (Int_t) fBranchCount->GetValue(0, 0);
4489 TStreamerInfo *info = GetInfoImp();
4493 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,1);
4495 b.ApplySequence(*fReadActionSequence, fObject);
4503 void TBranchElement::ReadLeavesMemberCounter(TBuffer& b)
4517 if (TestBit(kBranchObject)) {
4518 b.MapObject((TObject*) fObject);
4519 }
else if (TestBit(kBranchAny)) {
4520 b.MapObject(fObject, fBranchClass);
4523 TStreamerInfo *info = GetInfoImp();
4528 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,1);
4531 b.ApplySequence(*fReadActionSequence, fObject);
4532 fNdata = (Int_t) GetValue(0, 0);
4539 void TBranchElement::ReadLeavesCustomStreamer(TBuffer& b)
4549 R__PushCache onfileObject(((TBufferFile&)b),fOnfileObject,1);
4550 fBranchClass->Streamer(fObject,b);
4556 void TBranchElement::FillLeavesImpl(TBuffer&)
4558 Fatal(
"FillLeaves",
"The FillLeaves function has not been configured for %s",GetName());
4564 void TBranchElement::ReleaseObject()
4566 if (fObject && TestBit(kDeleteObject)) {
4567 if (IsAutoDelete() && fAddress != (
char*)&fObject) {
4568 *((
char**) fAddress) = 0;
4570 ResetBit(kDeleteObject);
4573 TClonesArray::Class()->Destructor(fObject);
4575 if ((fStreamerType == TVirtualStreamerInfo::kObjectp) ||
4576 (fStreamerType == TVirtualStreamerInfo::kObjectP)) {
4579 *((
char**) fAddress) = 0;
4581 }
else if (fType == 4) {
4583 TVirtualCollectionProxy* proxy = GetCollectionProxy();
4586 Warning(
"ReleaseObject",
"Cannot delete allocated STL container because I do not have a proxy! branch: %s", GetName());
4589 Bool_t needDelete = proxy->GetProperties()&TVirtualCollectionProxy::kNeedDelete;
4590 if (needDelete && fID >= 0) {
4591 TVirtualStreamerInfo* si = GetInfoImp();
4592 TStreamerElement* se = (TStreamerElement*) si->GetElement(fID);
4593 needDelete = !se->TestBit(TStreamerElement::kDoNotDelete);
4596 TVirtualCollectionProxy::TPushPop helper(proxy,fObject);
4597 proxy->Clear(
"force");
4599 proxy->Destructor(fObject);
4602 if (fStreamerType == TVirtualStreamerInfo::kSTLp) {
4605 *((
char**) fAddress) = 0;
4609 TClass* cl = fBranchClass.GetClass();
4611 Warning(
"ReleaseObject",
"Cannot delete allocated object because I cannot instantiate a TClass object for its class! branch: '%s' class: '%s'", GetName(), fBranchClass.GetClassName());
4614 TVirtualCollectionProxy* proxy = cl->GetCollectionProxy();
4618 TVirtualStreamerInfo* si = GetInfoImp();
4619 TStreamerElement* se = si->GetElement(fID);
4620 if (!se->TestBit(TStreamerElement::kDoNotDelete) && proxy->GetProperties()&TVirtualCollectionProxy::kNeedDelete) {
4621 TVirtualCollectionProxy::TPushPop helper(proxy,fObject);
4622 proxy->Clear(
"force");
4624 }
else if (proxy->GetProperties()&TVirtualCollectionProxy::kNeedDelete) {
4625 TVirtualCollectionProxy::TPushPop helper(proxy,fObject);
4626 proxy->Clear(
"force");
4630 cl->Destructor(fObject);
4644 void TBranchElement::Reset(Option_t* option)
4646 Int_t nbranches = fBranches.GetEntriesFast();
4647 for (Int_t i = 0; i < nbranches; ++i) {
4648 TBranch* branch = (TBranch*) fBranches[i];
4649 branch->Reset(option);
4652 TBranch::Reset(option);
4659 void TBranchElement::ResetAfterMerge(TFileMergeInfo *info)
4661 Int_t nbranches = fBranches.GetEntriesFast();
4662 for (Int_t i = 0; i < nbranches; ++i) {
4663 TBranch* branch = (TBranch*) fBranches[i];
4664 branch->ResetAfterMerge(info);
4666 TBranch::ResetAfterMerge(info);
4672 void TBranchElement::ResetAddress()
4674 for (Int_t i = 0; i < fNleaves; ++i) {
4675 TLeaf* leaf = (TLeaf*) fLeaves.UncheckedAt(i);
4677 leaf->SetAddress(0);
4683 Int_t nbranches = fBranches.GetEntriesFast();
4684 for (Int_t i = 0; i < nbranches; ++i) {
4685 TBranch* br = (TBranch*) fBranches[i];
4686 if (br) br->ResetAddress();
4695 ResetBit(kAddressSet);
4706 void TBranchElement::ResetDeleteObject()
4708 ResetBit(kDeleteObject);
4709 Int_t nb = fBranches.GetEntriesFast();
4710 for (Int_t i = 0; i < nb; ++i) {
4711 TBranch* br = (TBranch*) fBranches[i];
4712 if (br->InheritsFrom(TBranchElement::Class())) {
4713 ((TBranchElement*) br)->ResetDeleteObject();
4723 void TBranchElement::ResetInitInfo(Bool_t recurse)
4727 fInitOffsets = kFALSE;
4728 fCurrentClass =
nullptr;
4729 delete fReadActionSequence;
4730 fReadActionSequence =
nullptr;
4731 delete fFillActionSequence;
4732 fFillActionSequence =
nullptr;
4735 Int_t nbranches = fBranches.GetEntriesFast();
4736 for (Int_t i = 0; i < nbranches; ++i) {
4737 TBranchElement *sub = (TBranchElement*) fBranches[i];
4738 sub->ResetInitInfo(kTRUE);
4854 void TBranchElement::SetAddress(
void* addr)
4860 if (TestBit(kDoNotProcess)) {
4876 if (Long_t(addr) == -1) {
4879 fAddress = (
char*) -1;
4880 fObject = (
char*) -1;
4881 ResetBit(kDeleteObject);
4894 TClass* clOfBranch = fBranchClass.GetClass();
4895 if( fTargetClass.GetClassName()[0] ) {
4896 clOfBranch = fTargetClass;
4903 TStreamerInfo *info = GetInfoImp();
4911 if (fObject && TestBit(kDeleteObject)){
4919 fAddress = (
char*) addr;
4920 if (fAddress != (
char*)(&fObject)) {
4923 ResetBit(kDeleteObject);
4930 if (TestBit(kDecomposedObj)) {
4940 fObject = fAddress - info->TStreamerInfo::GetElementOffset(fID);
4954 TClass* clm = fClonesClass;
4957 clm->BuildRealData();
4958 clm->GetStreamerInfo();
4960 TClass* newType = GetCurrentClass();
4961 if (newType && (newType != TClonesArray::Class())) {
4965 Bool_t matched = kFALSE;
4966 if (newType->GetCollectionProxy()) {
4967 TClass *content = newType->GetCollectionProxy()->GetValueClass();
4968 if (clm == content) {
4971 Warning(
"SetAddress",
"The type of %s was changed from TClonesArray to %s but the content do not match (was %s)!", GetName(), newType->GetName(), GetClonesName());
4974 Warning(
"SetAddress",
"The type of the %s was changed from TClonesArray to %s but we do not have a TVirtualCollectionProxy for that container type!", GetName(), newType->GetName());
4980 fSTLtype = newType->GetCollectionType();
4981 fCollProxy = newType->GetCollectionProxy()->Generate();
4983 SwitchContainer(GetListOfBranches());
4987 if(fSTLtype != ROOT::kSTLvector && fCollProxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
4988 fPtrIterators =
new TVirtualCollectionPtrIterators(fCollProxy);
4989 }
else if (fCollProxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) {
4990 fWriteIterators =
new TVirtualCollectionIterators(fCollProxy,kFALSE);
4991 fIterators =
new TVirtualCollectionIterators(fCollProxy);
4993 fIterators =
new TVirtualCollectionIterators(fCollProxy);
5000 }
else if (fType == 4) {
5002 TClass* newType = GetCurrentClass();
5003 if (newType && (newType != GetCollectionProxy()->GetCollectionClass())) {
5005 TVirtualCollectionProxy* newProxy = newType->GetCollectionProxy();
5006 TVirtualCollectionProxy* oldProxy = GetCollectionProxy();
5007 if (newProxy && (oldProxy->GetValueClass() == newProxy->GetValueClass()) && ((!oldProxy->GetValueClass() && (oldProxy->GetType() == newProxy->GetType())) || (oldProxy->GetValueClass() && (oldProxy->HasPointers() == newProxy->HasPointers())))) {
5009 Int_t nbranches = GetListOfBranches()->GetEntries();
5010 fCollProxy = newType->GetCollectionProxy()->Generate();
5011 fSTLtype = fCollProxy->GetCollectionType();
5012 for (Int_t i = 0; i < nbranches; ++i) {
5013 TBranchElement* br = (TBranchElement*) GetListOfBranches()->UncheckedAt(i);
5015 if (br->fReadActionSequence) {
5016 br->SetReadActionSequence();
5018 if (br->fFillActionSequence) {
5019 br->SetFillActionSequence();
5022 SetReadActionSequence();
5023 SetFillActionSequence();
5027 delete fPtrIterators;
5028 if(fSTLtype != ROOT::kSTLvector && fCollProxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
5029 fPtrIterators =
new TVirtualCollectionPtrIterators(fCollProxy);
5030 }
else if (fCollProxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) {
5031 fWriteIterators =
new TVirtualCollectionIterators(fCollProxy,kFALSE);
5032 fIterators =
new TVirtualCollectionIterators(fCollProxy);
5034 fIterators =
new TVirtualCollectionIterators(fCollProxy);
5037 else if (newProxy && (oldProxy->HasPointers() == newProxy->HasPointers()) && (oldProxy->GetValueClass()!=0) && (newProxy->GetValueClass()!=0)) {
5039 if (newType->GetSchemaRules()->HasRuleWithSourceClass( oldProxy->GetCollectionClass()->GetName())) {
5040 TClass *oldValueClass = oldProxy->GetValueClass();
5042 Int_t nbranches = GetListOfBranches()->GetEntries();
5043 fCollProxy = newType->GetCollectionProxy()->Generate();
5044 fSTLtype = fCollProxy->GetCollectionType();
5045 for (Int_t i = 0; i < nbranches; ++i) {
5046 TBranchElement* br = (TBranchElement*) GetListOfBranches()->UncheckedAt(i);
5048 if (br->fBranchClass == oldValueClass) {
5049 br->SetTargetClass(fCollProxy->GetValueClass()->GetName());
5051 if (br->fReadActionSequence) {
5052 br->SetReadActionSequence();
5054 if (br->fFillActionSequence) {
5055 br->SetFillActionSequence();
5058 SetReadActionSequence();
5059 SetFillActionSequence();
5063 delete fPtrIterators;
5064 if(fSTLtype != ROOT::kSTLvector && fCollProxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
5065 fPtrIterators =
new TVirtualCollectionPtrIterators(fCollProxy);
5066 }
else if (fCollProxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) {
5067 fWriteIterators =
new TVirtualCollectionIterators(fCollProxy,kFALSE);
5068 fIterators =
new TVirtualCollectionIterators(fCollProxy);
5070 fIterators =
new TVirtualCollectionIterators(fCollProxy);
5073 Error(
"SetAddress",
"For %s, we can not convert %s into %s\n",
5074 GetName(),oldProxy->GetCollectionClass()->GetName(),newType->GetName());
5080 else if ((newType == TClonesArray::Class()) && (oldProxy->GetValueClass() && !oldProxy->HasPointers() && oldProxy->GetValueClass()->IsTObject()))
5095 switch(fStreamerType) {
5096 case TVirtualStreamerInfo::kAny:
5097 case TVirtualStreamerInfo::kSTL:
5098 fStreamerType = TVirtualStreamerInfo::kObject;
5100 case TVirtualStreamerInfo::kAnyp:
5101 case TVirtualStreamerInfo::kSTLp:
5102 fStreamerType = TVirtualStreamerInfo::kObjectp;
5104 case TVirtualStreamerInfo::kAnyP:
5105 fStreamerType = TVirtualStreamerInfo::kObjectP;
5108 fClonesClass = oldProxy->GetValueClass();
5109 fClonesName = fClonesClass->GetName();
5112 TClass* clm = fClonesClass;
5114 clm->BuildRealData();
5115 clm->GetStreamerInfo();
5117 SwitchContainer(GetListOfBranches());
5122 delete fPtrIterators;
5126 Error(
"SetAddress",
"For %s can not convert %s into %s\n",GetName(),GetCurrentClass()->GetName(),newType->GetName());
5131 if (!fIterators && !fPtrIterators) {
5132 if(fSTLtype != ROOT::kSTLvector && GetCollectionProxy()->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) {
5133 fPtrIterators =
new TVirtualCollectionPtrIterators(GetCollectionProxy());
5134 }
else if (fCollProxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) {
5135 fWriteIterators =
new TVirtualCollectionIterators(fCollProxy,kFALSE);
5136 fIterators =
new TVirtualCollectionIterators(fCollProxy);
5138 fIterators =
new TVirtualCollectionIterators(GetCollectionProxy());
5165 if (fStreamerType == TVirtualStreamerInfo::kObject) {
5170 TClonesArray* clones = (TClonesArray*) fObject;
5171 if (!clones->GetClass()) {
5172 new(fObject) TClonesArray(fClonesClass);
5177 if ((fStreamerType != -1) &&
5178 (fStreamerType != TVirtualStreamerInfo::kObjectp) &&
5179 (fStreamerType != TVirtualStreamerInfo::kObjectP)) {
5180 Error(
"SetAddress",
"TClonesArray with fStreamerType: %d", fStreamerType);
5181 }
else if (fStreamerType == -1) {
5183 TClonesArray** pp = (TClonesArray**) fAddress;
5186 *pp =
new TClonesArray(fClonesClass);
5188 fObject = (
char*) *pp;
5193 TClonesArray** pp = (TClonesArray**) fAddress;
5196 *pp =
new TClonesArray(fClonesClass);
5198 fObject = (
char*) *pp;
5203 if (fStreamerType == TVirtualStreamerInfo::kObject) {
5206 Error(
"SetAddress",
"Embedded TClonesArray given a zero address for branch '%s'", GetName());
5210 if ((fStreamerType != -1) &&
5211 (fStreamerType != TVirtualStreamerInfo::kObjectp) &&
5212 (fStreamerType != TVirtualStreamerInfo::kObjectP)) {
5213 Error(
"SetAddress",
"TClonesArray with fStreamerType: %d", fStreamerType);
5214 }
else if (fStreamerType == -1) {
5217 SetBit(kDeleteObject);
5218 fObject = (
char*)
new TClonesArray(fClonesClass);
5219 fAddress = (
char*) &fObject;
5222 Error(
"SetAddress",
"Embedded pointer to a TClonesArray given a zero address for branch '%s'", GetName());
5226 }
else if (fType == 4) {
5230 TVirtualCollectionProxy* proxy = GetCollectionProxy();
5233 if ((fStreamerType == TVirtualStreamerInfo::kObject) ||
5234 (fStreamerType == TVirtualStreamerInfo::kAny) ||
5235 (fStreamerType == TVirtualStreamerInfo::kSTL)) {
5244 if ((fStreamerType != -1) && (fStreamerType != TVirtualStreamerInfo::kSTLp)) {
5245 Error(
"SetAddress",
"STL container with fStreamerType: %d", fStreamerType);
5246 }
else if (fStreamerType == -1) {
5248 void** pp = (
void**) fAddress;
5253 Error(
"SetAddress",
"Failed to allocate STL container for branch '%s'", GetName());
5260 fObject = (
char*) *pp;
5265 void** pp = (
void**) fAddress;
5270 Error(
"SetAddress",
"Failed to allocate STL container for branch '%s'", GetName());
5277 fObject = (
char*) *pp;
5282 if ((fStreamerType == TVirtualStreamerInfo::kObject) ||
5283 (fStreamerType == TVirtualStreamerInfo::kAny) ||
5284 (fStreamerType == TVirtualStreamerInfo::kSTL)) {
5289 Error(
"SetAddress",
"Embedded STL container given a zero address for branch '%s'", GetName());
5293 if ((fStreamerType != -1) && (fStreamerType != TVirtualStreamerInfo::kSTLp)) {
5294 Error(
"SetAddress",
"STL container with fStreamerType: %d", fStreamerType);
5295 }
else if (fStreamerType == -1) {
5297 SetBit(kDeleteObject);
5298 fObject = (
char*) proxy->New();
5300 fAddress = (
char*) &fObject;
5302 Error(
"SetAddress",
"Failed to allocate STL container for branch '%s'", GetName());
5310 Error(
"SetAddress",
"Embedded pointer to an STL container given a zero address for branch '%s'", GetName());
5314 }
else if (fType == 41) {
5317 GetCollectionProxy();
5320 }
else if (fID < 0) {
5322 char** pp = (
char**) fAddress;
5331 SetBit(kDeleteObject);
5333 fObject = (
char*) clOfBranch->New();
5337 fAddress = (
char*) &fObject;
5340 Error(
"SetAddress",
"I have no TClass for branch %s, so I cannot allocate an I/O buffer!", GetName());
5359 if (!fInitOffsets) {
5360 InitializeOffsets();
5366 Int_t nbranches = fBranches.GetEntriesFast();
5367 for (Int_t i = 0; i < nbranches; ++i) {
5368 TBranch* abranch = (TBranch*) fBranches.UncheckedAt(i);
5370 if (fBranchOffset[i] != TStreamerInfo::kMissing) {
5371 abranch->SetAddress(fObject + fBranchOffset[i]);
5372 abranch->SetBit(kAddressSet);
5378 abranch->SetBit(kAddressSet);
5386 void TBranchElement::SetBasketSize(Int_t buffsize)
5388 TBranch::SetBasketSize(buffsize);
5389 Int_t nbranches = fBranches.GetEntriesFast();
5390 for (Int_t i = 0; i < nbranches; ++i) {
5391 TBranch* branch = (TBranch*) fBranches[i];
5392 branch->SetBasketSize(fBasketSize);
5399 void TBranchElement::SetBranchCount(TBranchElement* brOfCounter)
5401 fBranchCount = brOfCounter;
5402 if (fBranchCount==0)
return;
5404 TLeafElement* leafOfCounter = (TLeafElement*) brOfCounter->GetListOfLeaves()->At(0);
5405 TLeafElement* leaf = (TLeafElement*) GetListOfLeaves()->At(0);
5406 if (leafOfCounter && leaf) {
5407 leaf->SetLeafCount(leafOfCounter);
5409 if (!leafOfCounter) {
5410 Warning(
"SetBranchCount",
"Counter branch %s for branch %s has no leaves!", brOfCounter->GetName(), GetName());
5413 Warning(
"SetBranchCount",
"Branch %s has no leaves!", GetName());
5424 Bool_t TBranchElement::SetMakeClass(Bool_t decomposeObj)
5427 SetBit(kDecomposedObj);
5429 ResetBit(kDecomposedObj);
5431 Int_t nbranches = fBranches.GetEntriesFast();
5432 for (Int_t i = 0; i < nbranches; ++i) {
5433 TBranchElement* branch = (TBranchElement*) fBranches[i];
5434 branch->SetMakeClass(decomposeObj);
5445 void TBranchElement::SetObject(
void* obj)
5447 if (TestBit(kDoNotProcess)) {
5450 fObject = (
char*)obj;
5451 SetAddress( &fObject );
5458 void TBranchElement::SetOffset(Int_t offset)
5463 if (offset == TVirtualStreamerInfo::kMissing) {
5468 if (fReadActionSequence) {
5469 fReadActionSequence->AddToOffset(offset - fOffset);
5471 if (fFillActionSequence) {
5472 fFillActionSequence->AddToOffset(offset - fOffset);
5481 void TBranchElement::SetMissing()
5486 if (fReadActionSequence) {
5487 fReadActionSequence->SetMissing();
5489 if (fFillActionSequence) {
5490 fFillActionSequence->SetMissing();
5492 fOffset = TVirtualStreamerInfo::kMissing;
5498 void TBranchElement::SetActionSequence(TClass *originalClass, TStreamerInfo *localInfo, TStreamerInfoActions::TActionSequence::SequenceGetter_t create, TStreamerInfoActions::TActionSequence *&actionSequence)
5501 const bool isSplitNode = (fType == 3 || fType == 4 || fType == 2 || fType == 1 || (fType == 0 && fID == -2)) && !fBranches.IsEmpty();
5504 fNewIDs.insert(fNewIDs.begin(),fID);
5507 if (actionSequence)
delete actionSequence;
5508 auto original = create(localInfo, GetCollectionProxy(), originalClass);
5510 actionSequence = original->CreateSubSequence(fNewIDs, fOffset, create);
5513 fNewIDs.erase(fNewIDs.begin());
5515 else if (fInitOffsets && fType != 3 && fType != 4) {
5522 TBranchElement *parent =
dynamic_cast<TBranchElement*
>(GetMother()->GetSubBranch(
this));
5524 auto index = parent->fBranches.IndexOf(
this);
5526 actionSequence->AddToOffset( - parent->fBranchOffset[index] );
5533 void TBranchElement::SetReadActionSequence()
5540 TStreamerInfoActions::TActionSequence::SequenceGetter_t create =
nullptr;
5541 TClass *originalClass =
nullptr;
5542 TStreamerInfo *localInfo = fInfo;
5544 if( fSplitLevel >= TTree::kSplitCollectionOfPointers && fBranchCount->fSTLtype == ROOT::kSTLvector) {
5545 create = TStreamerInfoActions::TActionSequence::ReadMemberWiseActionsCollectionGetter;
5547 TVirtualStreamerInfo *info = GetInfoImp();
5548 if (GetParentClass() == info->GetClass()) {
5549 if( fTargetClass.GetClassName()[0] && fBranchClass != fTargetClass ) {
5550 originalClass = fBranchClass;
5551 create = TStreamerInfoActions::TActionSequence::ConversionReadMemberWiseActionsViaProxyGetter;
5553 create = TStreamerInfoActions::TActionSequence::ReadMemberWiseActionsViaProxyGetter;
5555 }
else if (GetCollectionProxy()) {
5557 create = TStreamerInfoActions::TActionSequence::ReadMemberWiseActionsCollectionCreator;
5560 }
else if (fType == 31) {
5561 create = TStreamerInfoActions::TActionSequence::ReadMemberWiseActionsCollectionGetter;
5562 }
else if (0<=fType && fType<=2) {
5564 create = TStreamerInfoActions::TActionSequence::ReadMemberWiseActionsGetter;
5565 }
else if ( fType == 4 && !fNewIDs.empty()) {
5566 localInfo = FindOnfileInfo(fClonesClass, fBranches);
5567 create = TStreamerInfoActions::TActionSequence::ReadMemberWiseActionsCollectionCreator;
5568 }
else if ( fType == 3 && !fNewIDs.empty()) {
5569 localInfo = FindOnfileInfo(fClonesClass, fBranches);
5570 create = TStreamerInfoActions::TActionSequence::ReadMemberWiseActionsCollectionGetter;
5574 SetActionSequence(originalClass, localInfo, create, fReadActionSequence);
5581 void TBranchElement::SetReadLeavesPtr()
5583 if (TestBit(kDecomposedObj)) {
5584 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesMakeClass;
5585 }
else if (fType == 4) {
5586 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesCollection;
5587 }
else if (fType == 41) {
5588 if( fSplitLevel >= TTree::kSplitCollectionOfPointers ) {
5589 if (fBranchCount->fSTLtype == ROOT::kSTLvector) {
5590 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesCollectionSplitVectorPtrMember;
5592 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesCollectionSplitPtrMember;
5595 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesCollectionMember;
5597 }
else if (fType == 3) {
5598 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesClones;
5599 }
else if (fType == 31) {
5600 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesClonesMember;
5601 }
else if (fType < 0) {
5602 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesCustomStreamer;
5603 }
else if (fType == 0 && fID == -1) {
5605 Bool_t hasCustomStreamer = !fBranchClass.GetClass()->GetCollectionProxy() && (fBranchClass.GetClass()->GetStreamer() != 0 || fBranchClass.GetClass()->TestBit(TClass::kHasCustomStreamerMember));
5606 if (hasCustomStreamer) {
5610 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesCustomStreamer;
5612 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesMember;
5614 }
else if (fType <= 2) {
5617 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesMemberBranchCount;
5618 }
else if (fStreamerType == TVirtualStreamerInfo::kCounter) {
5619 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesMemberCounter;
5621 fReadLeaves = (ReadLeaves_t)&TBranchElement::ReadLeavesMember;
5624 Fatal(
"SetReadLeavePtr",
"Unexpected branch type %d for %s",fType,GetName());
5627 SetReadActionSequence();
5633 void TBranchElement::SetFillActionSequence()
5640 TStreamerInfoActions::TActionSequence::SequenceGetter_t create =
nullptr;
5641 TClass *originalClass =
nullptr;
5642 TStreamerInfo *localInfo = fInfo;
5644 if( fSplitLevel >= TTree::kSplitCollectionOfPointers && fBranchCount->fSTLtype == ROOT::kSTLvector) {
5645 create = TStreamerInfoActions::TActionSequence::WriteMemberWiseActionsCollectionGetter;
5647 TVirtualStreamerInfo *info = GetInfoImp();
5648 if (GetParentClass() == info->GetClass()) {
5653 create = TStreamerInfoActions::TActionSequence::WriteMemberWiseActionsViaProxyGetter;
5655 }
else if (GetCollectionProxy()) {
5657 create = TStreamerInfoActions::TActionSequence::WriteMemberWiseActionsCollectionCreator;
5660 }
else if (fType == 31) {
5661 create = TStreamerInfoActions::TActionSequence::WriteMemberWiseActionsCollectionGetter;
5662 }
else if (0<=fType && fType<=2) {
5664 create = TStreamerInfoActions::TActionSequence::WriteMemberWiseActionsGetter;
5665 }
else if ( fType == 4 && !fNewIDs.empty()) {
5666 localInfo = FindOnfileInfo(fClonesClass, fBranches);
5667 create = TStreamerInfoActions::TActionSequence::WriteMemberWiseActionsCollectionCreator;
5668 }
else if ( fType == 3 && !fNewIDs.empty()) {
5669 localInfo = FindOnfileInfo(fClonesClass, fBranches);
5670 create = TStreamerInfoActions::TActionSequence::WriteMemberWiseActionsCollectionGetter;
5674 SetActionSequence(originalClass, localInfo, create, fFillActionSequence);
5681 void TBranchElement::SetFillLeavesPtr()
5683 if (TestBit(kDecomposedObj) && ((fType==3)||(fType==31))) {
5684 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesMakeClass;
5685 }
else if (fType == 4) {
5686 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollection;
5687 }
else if (fType == 41) {
5688 if( fSplitLevel >= TTree::kSplitCollectionOfPointers ) {
5689 if (fBranchCount->fSTLtype == ROOT::kSTLvector) {
5690 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollectionSplitVectorPtrMember;
5692 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollectionSplitPtrMember;
5694 }
else if (GetCollectionProxy()->GetProperties() & TVirtualCollectionProxy::kIsAssociative) {
5695 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesAssociativeCollectionMember;
5697 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollectionMember;
5699 }
else if (fType == 3) {
5700 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesClones;
5701 }
else if (fType == 31) {
5702 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesClonesMember;
5703 }
else if (fType < 0) {
5704 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCustomStreamer;
5705 }
else if (fType <=2) {
5708 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesMemberBranchCount;
5709 }
else if (fStreamerType == TVirtualStreamerInfo::kCounter) {
5710 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesMemberCounter;
5712 fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesMember;
5715 Fatal(
"SetFillLeavePtr",
"Unexpected branch type %d for %s",fType,GetName());
5718 SetFillActionSequence();
5725 void TBranchElement::SetTargetClass(
const char *name)
5727 if (name == 0)
return;
5729 if (strcmp(fTargetClass.GetClassName(),name) != 0 )
5734 ResetInitInfo( kFALSE);
5736 Int_t nbranches = fBranches.GetEntriesFast();
5737 for (Int_t i = 0; i < nbranches; ++i) {
5738 TBranchElement *sub = (TBranchElement*) fBranches[i];
5740 if (sub->fTargetClass == fTargetClass ) {
5741 sub->SetTargetClass(name);
5746 sub->ResetInitInfo(kTRUE);
5748 if (sub->fParentClass == fTargetClass ) {
5749 sub->SetParentClass(TClass::GetClass(name));
5752 fTargetClass = name;
5762 void TBranchElement::SetupAddresses()
5767 if (fAddress || TestBit(kDecomposedObj)) {
5771 SetupAddressesImpl();
5779 void TBranchElement::SetupAddressesImpl()
5781 if (TestBit(kDoNotProcess|kAddressSet)) {
5792 if( fType == 41 && fSplitLevel >= TTree::kSplitCollectionOfPointers )
5794 TBranchElement *parent = (TBranchElement *)GetMother()->GetSubBranch(
this );
5799 if( !parent->GetAddress() )
5800 parent->SetAddress( 0 );
5808 TBranchElement* mother = (TBranchElement*) GetMother();
5812 TClass* cl = TClass::GetClass(mother->GetClassName());
5821 if (!mother->GetAddress()) {
5823 Bool_t motherStatus = mother->TestBit(kDoNotProcess);
5824 mother->ResetBit(kDoNotProcess);
5826 mother->SetAddress(0);
5827 mother->SetBit(kDoNotProcess, motherStatus);
5834 void TBranchElement::Streamer(TBuffer& R__b)
5836 if (R__b.IsReading()) {
5837 R__b.ReadClassBuffer(TBranchElement::Class(),
this);
5838 fParentClass.SetName(fParentName);
5839 fBranchClass.SetName(fClassName);
5840 fTargetClass.SetName(fClassName);
5841 fClonesClass.SetName(fClonesName);
5845 ResetBit(kDeleteObject|kCache|kOwnOnfileObj|kAddressSet|kDecomposedObj);
5847 if ((fType == 0) && (fLeaves.GetEntriesFast() == 0)) {
5848 TLeaf* leaf =
new TLeafElement(
this, GetTitle(), fID, fStreamerType);
5849 leaf->SetTitle(GetTitle());
5852 fTree->GetListOfLeaves()->Add(leaf);
5858 TDirectory* dirsav = fDirectory;
5862 Int_t classVersion = fClassVersion;
5864 if (fClassVersion < 0) {
5865 fClassVersion = -fClassVersion;
5871 R__b.WriteClassBuffer(TBranchElement::Class(),
this);
5873 fClassVersion = classVersion;
5880 R__b.ForceWriteInfo(GetInfoImp(), kTRUE);
5894 TClass* cl = fClonesClass;
5896 R__b.ForceWriteInfo(cl->GetStreamerInfo(), kTRUE);
5899 else if (fType == 4) {
5905 TVirtualCollectionProxy* cp = GetCollectionProxy();
5907 TClass* cl = cp->GetValueClass();
5909 R__b.ForceWriteInfo(cl->GetStreamerInfo(), kTRUE);
5919 if (!dirsav->IsWritable()) {
5920 fDirectory = dirsav;
5923 TDirectory* pdirectory = fTree->GetDirectory();
5925 fDirectory = dirsav;
5928 const char* treeFileName = pdirectory->GetFile()->GetName();
5929 TBranch* mother = GetMother();
5930 const char* motherFileName = treeFileName;
5931 if (mother && (mother !=
this)) {
5932 motherFileName = mother->GetFileName();
5934 if ((fFileName.Length() > 0) && strcmp(motherFileName, fFileName.Data())) {
5935 dirsav->WriteTObject(
this);
5937 fDirectory = dirsav;
5948 void TBranchElement::Unroll(
const char *name, TClass *cl, TStreamerInfo *sinfo,
char* objptr, Int_t bufsize, Int_t splitlevel)
5957 char* dot = (
char*) strchr(name,
'.');
5958 Int_t nch = strlen(name);
5959 Bool_t dotlast = kFALSE;
5960 if (nch && (name[nch-1] ==
'.')) {
5965 TObjArray* blist = this->GetListOfBranches();
5966 TIter next(sinfo->GetElements());
5967 TStreamerElement* element = 0;
5969 for (Int_t
id = 0; (element = (TStreamerElement*) next()); ++id) {
5970 if (element->IsA() == TStreamerArtificial::Class()) {
5973 if (element->TestBit(TStreamerElement::kRepeat)) {
5976 if (element->TestBit(TStreamerElement::kCache) && !element->TestBit(TStreamerElement::kWrite)) {
5979 char* pointer = (
char*) (objptr + element->GetOffset());
5984 Bool_t isBase = (element->IsA() == TStreamerBase::Class());
5986 TClass* clbase = element->GetClassPointer();
5987 if ((clbase == TObject::Class()) && cl->CanIgnoreTObjectStreamer()) {
5996 if (clbase->GetListOfRealData()->GetSize() == 0) {
6003 bname.Form(
"%s%s", name, element->GetFullName());
6020 bname.Form(
"%s.%s", name, element->GetFullName());
6026 bname.Form(
"%s", element->GetFullName());
6029 if( splitlevel > TTree::kSplitCollectionOfPointers && element->GetClass() &&
6030 element->GetClass()->GetCollectionProxy() &&
6031 element->GetClass()->GetCollectionProxy()->HasPointers() )
6033 TBranchSTL* brSTL =
new TBranchSTL(
this, bname, element->GetClass()->GetCollectionProxy(), bufsize, splitlevel-1, sinfo, id );
6038 TBranchElement* bre =
new TBranchElement(
this, bname, sinfo,
id, pointer, bufsize, splitlevel - 1);
6039 bre->SetParentClass(cl);
6044 SetReadActionSequence();
6045 SetFillActionSequence();
6082 Int_t TBranchElement::Unroll(
const char* name, TClass* clParent, TClass* cl,
char* ptr, Int_t basketsize, Int_t splitlevel, Int_t btype)
6088 Int_t splitSTLP = splitlevel - (splitlevel%TTree::kSplitCollectionOfPointers);
6089 splitlevel %= TTree::kSplitCollectionOfPointers;
6093 if ((cl == TObject::Class()) && clParent->CanIgnoreTObjectStreamer()) {
6097 TStreamerInfo* sinfo = fTree->BuildStreamerInfo(cl);
6107 Int_t ndata = sinfo->GetNelement();
6109 if ((ndata == 1) && cl->GetCollectionProxy() && !strcmp(sinfo->GetElement(0)->GetName(),
"This")) {
6116 for (Int_t elemID = 0; elemID < ndata; ++elemID) {
6118 TStreamerElement* elem = sinfo->GetElement(elemID);
6119 if (elem->IsA() == TStreamerArtificial::Class()) {
6122 if (elem->TestBit(TStreamerElement::kRepeat)) {
6125 if (elem->TestBit(TStreamerElement::kCache) && !elem->TestBit(TStreamerElement::kWrite)) {
6128 Int_t offset = elem->GetOffset();
6131 if (elem->IsA() == TStreamerBase::Class()) {
6133 TClass* clOfBase = elem->GetClassPointer();
6134 if (!clOfBase || ((clOfBase->Property() & kIsAbstract) && cl->InheritsFrom(TCollection::Class()))) {
6138 if ((btype == 31) || (btype == 41)) {
6149 if (!elem->CannotSplit() || clOfBase == TObject::Class()) {
6150 unroll = Unroll(name, clParent, clOfBase, ptr + offset, basketsize, splitlevel+splitSTLP, btype);
6155 branchname.Form(
"%s.%s", name, elem->GetFullName());
6157 branchname.Form(
"%s", elem->GetFullName());
6159 TBranchElement* branch =
new TBranchElement(
this, branchname, sinfo, elemID, 0, basketsize, 0, btype);
6160 branch->SetParentClass(clParent);
6161 fBranches.Add(branch);
6163 }
else if (clOfBase->GetListOfRealData()->GetSize()) {
6166 branchname.Form(
"%s.%s", name, elem->GetFullName());
6172 TBranchElement* branch =
new TBranchElement(
this, name, sinfo, elemID, ptr + offset, basketsize, splitlevel+splitSTLP, btype);
6174 branch->SetName(branchname);
6175 branch->SetTitle(branchname);
6176 branch->SetParentClass(clParent);
6177 fBranches.Add(branch);
6179 branchname.Form(
"%s", elem->GetFullName());
6180 TBranchElement* branch =
new TBranchElement(
this, branchname, sinfo, elemID, ptr + offset, basketsize, splitlevel+splitSTLP, btype);
6181 branch->SetParentClass(clParent);
6182 fBranches.Add(branch);
6188 branchname.Form(
"%s.%s", name, elem->GetFullName());
6190 branchname.Form(
"%s", elem->GetFullName());
6192 if ((splitlevel > 1) && ((elem->IsA() == TStreamerObject::Class()) || (elem->IsA() == TStreamerObjectAny::Class()))) {
6198 TClass* elemClass = elem->GetClassPointer();
6199 if (!elemClass || elemClass->Property() & kIsAbstract) {
6202 if (elem->CannotSplit()) {
6204 TBranchElement* branch =
new TBranchElement(
this, branchname, sinfo, elemID, ptr + offset, basketsize, 0, btype);
6205 branch->SetParentClass(clParent);
6206 fBranches.Add(branch);
6207 }
else if (elemClass->InheritsFrom(TClonesArray::Class())) {
6209 Int_t subSplitlevel = splitlevel-1;
6210 if (btype == 31 || btype == 41 || elem->CannotSplit()) {
6214 TBranchElement* branch =
new TBranchElement(
this, branchname, sinfo, elemID, ptr + offset, basketsize, subSplitlevel, btype);
6215 branch->SetParentClass(clParent);
6216 fBranches.Add(branch);
6225 Int_t unroll = Unroll(branchname, clParent, elemClass, ptr + offset, basketsize, splitlevel-1+splitSTLP, btype);
6228 TBranchElement* branch =
new TBranchElement(
this, branchname, sinfo, elemID, ptr + offset, basketsize, 0, btype);
6229 branch->SetParentClass(clParent);
6230 fBranches.Add(branch);
6234 else if( elem->GetClassPointer() &&
6235 elem->GetClassPointer()->GetCollectionProxy() &&
6236 elem->GetClassPointer()->GetCollectionProxy()->HasPointers() &&
6237 splitSTLP && fType != 4 )
6240 TBranchSTL* branch =
new TBranchSTL(
this, branchname,
6241 elem->GetClassPointer()->GetCollectionProxy(),
6242 basketsize, splitlevel - 1+splitSTLP, sinfo, elemID );
6243 branch->SetAddress( ptr+offset );
6244 fBranches.Add( branch );
6246 else if ((elem->IsA() == TStreamerSTL::Class()) && !elem->IsaPointer()) {
6250 Int_t subSplitlevel = splitlevel - 1;
6251 if ((btype == 31) || (btype == 41) || elem->CannotSplit()) {
6255 TBranchElement* branch =
new TBranchElement(
this, branchname, sinfo, elemID, ptr + offset, basketsize, subSplitlevel+splitSTLP, btype);
6256 branch->SetParentClass(clParent);
6257 fBranches.Add(branch);
6258 }
else if (((btype != 31) && (btype != 41)) && ptr && ((elem->GetClassPointer() == TClonesArray::Class()) || ((elem->IsA() == TStreamerSTL::Class()) && !elem->CannotSplit()))) {
6265 TBranchElement* branch =
new TBranchElement(
this, branchname, sinfo, elemID, ptr + offset, basketsize, splitlevel-1+splitSTLP, btype);
6266 branch->SetParentClass(clParent);
6267 fBranches.Add(branch);
6270 TBranchElement* branch =
new TBranchElement(
this, branchname, sinfo, elemID, 0, basketsize, splitSTLP, btype);
6271 branch->SetType(btype);
6272 branch->SetParentClass(clParent);
6273 fBranches.Add(branch);
6278 if (!fBranches.IsEmpty()) {
6280 SetReadActionSequence();
6281 SetFillActionSequence();
6291 void TBranchElement::UpdateFile()
6297 TBranch::UpdateFile();