481 case kchar:
return 0;
486 case kBits:
return 0;
522 fMethodBit(tfl.fMethodBit),
523 fPrevious(tfl.fPrevious)
547 fTree->fFriendLockStatus &= ~(fMethodBit &
kBitMask);
574 entryInRange = firstEntry;
577 entryInRange = firstEntry - pedestal;
585 if (autoflush <= 0) {
588 fStartEntry = pedestal + entryInRange - entryInRange%autoflush;
613 auto autoFlush = fTree->GetAutoFlush();
614 if (autoFlush > 0)
return autoFlush;
615 if (fEstimatedSize > 0)
return fEstimatedSize;
617 Long64_t zipBytes = fTree->GetZipBytes();
619 fEstimatedSize = fTree->GetEntries() - 1;
620 if (fEstimatedSize <= 0)
624 Long64_t cacheSize = fTree->GetCacheSize();
625 if (cacheSize == 0) {
636 if (cacheSize <= 0) {
637 cacheSize = 30000000;
639 clusterEstimate = fTree->GetEntries() * cacheSize / zipBytes;
641 fEstimatedSize = clusterEstimate ? clusterEstimate : 1;
643 return fEstimatedSize;
652 fStartEntry = fNextEntry;
653 if (fTree->fNClusterRange || fTree->GetAutoFlush() > 0) {
654 if (fClusterRange == fTree->fNClusterRange) {
657 fNextEntry += GetEstimatedClusterSize();
659 if (fStartEntry > fTree->fClusterRangeEnd[fClusterRange]) {
662 if (fClusterRange == fTree->fNClusterRange) {
665 fNextEntry += GetEstimatedClusterSize();
667 Long64_t clusterSize = fTree->fClusterSize[fClusterRange];
668 if (clusterSize == 0) {
669 clusterSize = GetEstimatedClusterSize();
671 fNextEntry += clusterSize;
672 if (fNextEntry > fTree->fClusterRangeEnd[fClusterRange]) {
676 fNextEntry = fTree->fClusterRangeEnd[fClusterRange] + 1;
682 fNextEntry = fStartEntry + GetEstimatedClusterSize();
684 if (fNextEntry > fTree->GetEntries()) {
685 fNextEntry = fTree->GetEntries();
696 fNextEntry = fStartEntry;
697 if (fTree->fNClusterRange || fTree->GetAutoFlush() > 0) {
698 if (fClusterRange == 0 || fTree->fNClusterRange == 0) {
701 fStartEntry -= GetEstimatedClusterSize();
706 if (fClusterRange == 0) {
710 Long64_t clusterSize = fTree->fClusterSize[fClusterRange];
711 if (clusterSize == 0) {
712 clusterSize = GetEstimatedClusterSize();
714 fStartEntry -= clusterSize;
719 fStartEntry = fNextEntry - GetEstimatedClusterSize();
721 if (fStartEntry < 0) {
832, fDefaultEntryOffsetLen(1000)
838, fAutoSave( -300000000)
839, fAutoFlush(-30000000)
871, fFriendLockStatus(0)
873, fCacheDoAutoInit(
kTRUE)
874, fCacheDoClusterPrefetch(
kFALSE)
877, fNEntriesSinceSorting(0)
910 if (strlen(title) > 2) {
911 if (title[0] ==
'/') {
912 Branch(title+1,32000,splitlevel);
927#ifdef R__TRACK_BASKET_ALLOC_TIME
928 Info(
"TTree::~TTree",
"For tree %s, allocation time is %lluus.",
GetName(), fAllocationTime.load());
1063 Error(
"AddBranchToCache",
"Could not load a tree");
1072 Error(
"AddBranchToCache",
"No tree is available. Branch was not added to the cache");
1078 Error(
"AddBranchToCache",
"No file is available. Branch was not added to the cache");
1083 Error(
"AddBranchToCache",
"No cache is available, branch not added");
1086 return tc->
AddBranch(bname,subbranches);
1102 Error(
"AddBranchToCache",
"Could not load a tree");
1110 Error(
"AddBranchToCache",
"Error adding branch");
1115 Error(
"AddBranchToCache",
"No tree is available. Branch was not added to the cache");
1121 Error(
"AddBranchToCache",
"No file is available. Branch was not added to the cache");
1126 Error(
"AddBranchToCache",
"No cache is available, branch not added");
1146 Error(
"DropBranchFromCache",
"Could not load a tree");
1155 Error(
"DropBranchFromCache",
"No tree is available. Branch was not dropped from the cache");
1161 Error(
"DropBranchFromCache",
"No file is available. Branch was not dropped from the cache");
1166 Error(
"DropBranchFromCache",
"No cache is available, branch not dropped");
1185 Error(
"DropBranchFromCache",
"Could not load a tree");
1193 Error(
"DropBranchFromCache",
"Error dropping branch");
1198 Error(
"DropBranchFromCache",
"No tree is available. Branch was not dropped from the cache");
1204 Error(
"DropBranchFromCache",
"No file is available. Branch was not dropped from the cache");
1209 Error(
"DropBranchFromCache",
"No cache is available, branch not dropped");
1244 const auto friendHasValidIndex = [&] {
1249 if ((isMainReshuffled || isFriendReshuffled) && !friendHasValidIndex) {
1250 const auto reshuffledTreeName = isMainReshuffled ? mainTree.
GetName() : friendTree.
GetName();
1251 const auto msg =
"Tree '%s' has the kEntriesReshuffled bit set, and cannot be used as friend nor can be added as "
1252 "a friend unless the main tree has a TTreeIndex on the friend tree '%s'. You can also unset the "
1253 "bit manually if you know what you are doing.";
1254 Error(
"AddFriend", msg, reshuffledTreeName, friendTree.
GetName());
1339 bool canAddFriend =
true;
1343 Warning(
"AddFriend",
"FriendElement %s in file %s has less entries %lld than its parent Tree: %lld", treename,
1347 Error(
"AddFriend",
"Cannot find tree '%s' in file '%s', friend not added", treename,
filename);
1348 canAddFriend =
false;
1373 bool canAddFriend =
true;
1377 Warning(
"AddFriend",
"FriendElement %s in file %s has less entries %lld than its parent tree: %lld", treename,
1381 Error(
"AddFriend",
"Cannot find tree '%s' in file '%s', friend not added", treename,
file->GetName());
1382 canAddFriend =
false;
1408 Warning(
"AddFriend",
"FriendElement '%s' in file '%s' has less entries %lld than its parent tree: %lld",
1415 tree->RemoveExternalFriend(fe);
1508 if (opt.
Contains(
"flushbaskets")) {
1509 if (
gDebug > 0)
Info(
"AutoSave",
"calling FlushBaskets \n");
1528 if (
file)
file->WriteStreamerInfo();
1542 const char* writeStlWithoutProxyMsg =
"The class requested (%s) for the branch \"%s\""
1543 " is an instance of an stl collection and does not have a compiled CollectionProxy."
1544 " Please generate the dictionary for this collection (%s) to avoid to write corrupted data.";
1558 Error(
"Branch", writeStlWithoutProxyMsg,
1562 return Branch(branchname, classname, (
void*) addobj, bufsize, splitlevel);
1565 void** addr = (
void**) addobj;
1569 if (ptrClass && claim) {
1576 Error(
"Branch",
"The class requested (%s) for \"%s\" is different from the type of the pointer passed (%s)",
1579 }
else if (actualClass && (claim != actualClass) && !actualClass->
InheritsFrom(claim)) {
1584 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s",
1590 Error(
"Branch", writeStlWithoutProxyMsg,
1594 return Branch(branchname, classname, (
void*) addobj, bufsize, splitlevel);
1604 Error(
"Branch",
"The pointer specified for %s is not of a class known to ROOT", branchname);
1608 void** addr = (
void**) addobj;
1609 if (addr && *addr) {
1612 Warning(
"Branch",
"The actual TClass corresponding to the object provided for the definition of the branch \"%s\" is missing.\n\tThe object will be truncated down to its %s part",
1613 branchname, ptrClass->
GetName());
1614 actualClass = ptrClass;
1615 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1616 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s", actualClass->
GetName(), branchname, ptrClass->
GetName());
1620 actualClass = ptrClass;
1623 Error(
"Branch", writeStlWithoutProxyMsg,
1627 return Branch(branchname, actualClass->
GetName(), (
void*) addobj, bufsize, splitlevel);
1639 Error(
"Branch", writeStlWithoutProxyMsg,
1642 }
else if (claim == 0) {
1643 Error(
"Branch",
"The pointer specified for %s is not of a class known to ROOT and %s is not a known class", branchname, classname);
1650 Error(
"Branch",
"Reference interface requires a valid object (for branch: %s)!", branchname);
1654 if (ptrClass && claim) {
1661 Error(
"Branch",
"The class requested (%s) for \"%s\" is different from the type of the object passed (%s)",
1664 }
else if (actualClass && (claim != actualClass) && !actualClass->
InheritsFrom(claim)) {
1669 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s",
1675 Warning(
"Branch",
"The actual TClass corresponding to the object provided for the definition of the branch \"%s\" is missing.\n\tThe object will be truncated down to its %s part",
1676 branchname, ptrClass->
GetName());
1677 actualClass = ptrClass;
1678 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1679 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s", actualClass->
GetName(), branchname, ptrClass->
GetName());
1683 Error(
"Branch", writeStlWithoutProxyMsg,
1698 Error(
"Branch",
"The pointer specified for %s is not of a class or type known to ROOT", branchname);
1701 return Branch(branchname,addobj,varname.
Data(),bufsize);
1707 Error(
"Branch",
"Reference interface requires a valid object (for branch: %s)!", branchname);
1712 Warning(
"Branch",
"The actual TClass corresponding to the object provided for the definition of the branch \"%s\" is missing.\n\tThe object will be truncated down to its %s part",
1713 branchname, ptrClass->
GetName());
1714 actualClass = ptrClass;
1715 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1716 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s", actualClass->
GetName(), branchname, ptrClass->
GetName());
1720 Error(
"Branch", writeStlWithoutProxyMsg,
1735 "The inner type of the std::array passed specified for %s is not of a class or type known to ROOT",
1740 return Branch(branchname, addobj, varname.
Data(), bufsize);
1841 Error(
"Branch",
"Cannot call this constructor for a TClonesArray");
1847 while ((obj = next())) {
1855 Branch(col, bufsize, splitlevel - 1, branchname);
1857 if (nch && (
name[nch-1] ==
'_')) {
1866 if (splitlevel > 99) {
1892 char* curname =
new char[1000];
1894 while ((obj = next())) {
1897 Branch(curname, bufsize, splitlevel - 1);
1900 for (
Int_t i = 0; i < 1000; ++i) {
1901 if (curname[i] == 0) {
1904 if (curname[i] ==
'/') {
1911 strlcat(curname, occur,1000);
2022 return Bronch(
name, classname, addobj, bufsize, splitlevel);
2024 if (splitlevel < 0) {
2027 return BranchOld(
name, classname, addobj, bufsize, splitlevel);
2076 Error(
"BranchOld",
"Cannot find class: '%s'", classname);
2081 Fatal(
"BranchOld",
"The requested class ('%s') does not inherit from TObject.\n"
2082 "\tfgBranchStyle is set to zero requesting by default to use BranchOld.\n"
2083 "\tIf this is intentional use Bronch instead of Branch or BranchOld.", classname);
2085 Fatal(
"BranchOld",
"The requested class ('%s') does not inherit from TObject.\n"
2086 "\tYou can not use BranchOld to store objects of this type.",classname);
2097 const char* rdname = 0;
2098 const char* dname = 0;
2100 char** apointer = (
char**) addobj;
2112 if (
name[lenName-1] ==
'.') {
2151 if (!strcmp(dname,
"fBits")) {
2154 if (!strcmp(dname,
"fUniqueID")) {
2164 branchname = rdname;
2168 branchname.
Form(
"%s%s",
name, &rdname[1]);
2170 branchname.
Form(
"%s%s",
name, &rdname[0]);
2176 char* pointer = ((
char*) obj) +
offset;
2185 char* cpointer = (
char*) pointer;
2186 char** ppointer = (
char**) cpointer;
2188 if (splitlevel != 2) {
2190 branch1 =
new TBranchClones(branch,branchname, pointer, bufsize);
2195 blist->
Add(branch1);
2203 blist->
Add(branch1);
2220 blist->
Add(branch1);
2244 if (!strcmp(rdi->
GetName(), aindex)) {
2256 leaflist.
Form(
"%s[%s]/%c", &rdname[0],
index, vcode);
2258 Error(
"BranchOld",
"Cannot create branch for rdname: %s code: %d", branchname.
Data(), code);
2265 leaflist.
Form(
"%s/%s", dname,
"C");
2278 branch1 =
new TBranch(branch, bname, *((
void**) pointer), leaflist, bufsize);
2282 blist->
Add(branch1);
2289 leaflist.
Form(
"%s/%c", rdname, vcode);
2291 Error(
"BranchOld",
"Cannot create branch for rdname: %s code: %d", branchname.
Data(), code);
2294 branch1 =
new TBranch(branch, branchname, pointer, leaflist, bufsize);
2296 blist->
Add(branch1);
2305 Warning(
"BranchOld",
"Cannot process member: '%s'", rdname);
2414 Error(
"Bronch",
"Cannot find class:%s", classname);
2425 objptr = (
char*)addr;
2427 objptr = *((
char**) addr);
2433 Error(
"Bronch",
"Pointer to TClonesArray is null");
2437 Error(
"Bronch",
"TClonesArray with no class defined in branch: %s",
name);
2441 Error(
"Bronch",
"TClonesArray with no dictionary defined in branch: %s",
name);
2445 if (splitlevel > 0) {
2446 if (hasCustomStreamer)
2447 Warning(
"Bronch",
"Using split mode on a class: %s with a custom Streamer", clones->
GetClass()->
GetName());
2462 if (!inklass && (collProxy->
GetType() == 0)) {
2463 Error(
"Bronch",
"%s with no class defined in branch: %s", classname,
name);
2470 Error(
"Bronch",
"Container with no dictionary defined in branch: %s",
name);
2474 Warning(
"Bronch",
"Using split mode on a class: %s with a custom Streamer", inklass->
GetName());
2485 branch =
new TBranchSTL(
this,
name, collProxy, bufsize, splitlevel );
2499 Error(
"Bronch",
"Cannot find dictionary for class: %s", classname);
2505 hasCustomStreamer =
kTRUE;
2508 if (splitlevel < 0 || ((splitlevel == 0) && hasCustomStreamer && cl->
IsTObject())) {
2539 objptr = (
char*) cl->
New();
2547 if ((splitlevel > 0) && !cl->
CanSplit()) {
2548 if (splitlevel != 99) {
2549 Warning(
"Bronch",
"%s cannot be split, resetting splitlevel to 0", cl->
GetName());
2563 Error(
"Bronch",
"Cannot build the StreamerInfo for class: %s", cl->
GetName());
2572 if (splitlevel > 0) {
2583 branch->
Unroll(
name, cl, sinfo, objptr, bufsize, splitlevel);
2729 constexpr auto kBufSize = 2000;
2730 char* fname =
new char[kBufSize];
2733 for (
Int_t i = 0; i < 10; ++i) {
2741 strlcpy(fname,
file->GetName(), kBufSize);
2744 char* cunder = strrchr(fname,
'_');
2747 const char* cdot = strrchr(
file->GetName(),
'.');
2749 strlcat(fname, cdot, kBufSize);
2754 strlcat(fname, fcount, kBufSize);
2757 char* cdot = strrchr(fname,
'.');
2760 strlcat(fname, strrchr(
file->GetName(),
'.'), kBufSize);
2764 strlcat(fname, fcount, kBufSize);
2771 Warning(
"ChangeFile",
"file %s already exist, trying with %d underscores", fname, nus+1);
2773 Int_t compress =
file->GetCompressionSettings();
2776 Error(
"Fill",
"Failed to open new file %s, continuing as a memory tree.",fname);
2778 Printf(
"Fill: Switching to new file: %s", fname);
2784 while ((obj =
file->GetList()->First())) {
2801 while ((branch = (
TBranch*)nextb())) {
2810 if (newfile) newfile->
Append(obj);
2813 file->TObject::Delete();
2850 TClass* expectedClass = 0;
2857 if (expectedClass && datatype ==
kOther_t && ptrClass == 0) {
2858 if (isBranchElement) {
2863 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2864 "The class expected (%s) refers to an stl collection and do not have a compiled CollectionProxy. "
2865 "Please generate the dictionary for this class (%s)",
2872 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2873 "The class expected (%s) does not have a dictionary and needs to be emulated for I/O purposes but is being passed a compiled object."
2874 "Please generate the dictionary for this class (%s)",
2877 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2878 "This is probably due to a missing dictionary, the original data class for this branch is %s.", branch->
GetName(), expectedClass->
GetName());
2882 if (expectedClass && ptrClass && (branch->
GetMother() == branch)) {
2885 Error(
"SetBranchAddress",
"The address for \"%s\" should be the address of a pointer!", branch->
GetName());
2905 if( expectedClass && ptrClass &&
2906 expectedClass != ptrClass &&
2914 Info(
"SetBranchAddress",
"Matching STL collection (at least according to the SchemaRuleSet when "
2915 "reading a %s into a %s",expectedClass->
GetName(),ptrClass->
GetName());
2922 Error(
"SetBranchAddress",
"The pointer type given \"%s\" does not correspond to the type needed \"%s\" by the branch: %s", ptrClass->
GetName(), bEl->
GetClassName(), branch->
GetName());
2933 }
else if (expectedClass && ptrClass && !expectedClass->
InheritsFrom(ptrClass)) {
2955 Error(
"SetBranchAddress",
"The pointer type given (%s) does not correspond to the class needed (%s) by the branch: %s", ptrClass->
GetName(), expectedClass->
GetName(), branch->
GetName());
2956 if (isBranchElement) {
2965 Error(
"SetBranchAddress",
"The pointer type given \"%s\" (%d) does not correspond to the type needed \"%s\" (%d) by the branch: %s",
2972 if (expectedClass) {
2973 Error(
"SetBranchAddress",
"The pointer type given \"%s\" (%d) does not correspond to the type needed \"%s\" by the branch: %s",
2975 if (isBranchElement) {
2991 if (etype == expectedType) {
3006 if (etype == expectedType) {
3018 if (len <= ptrClass->
Size()) {
3022 Error(
"SetBranchAddress",
"The pointer type given \"%s\" does not correspond to the type needed \"%s\" (%d) by the branch: %s",
3028 Error(
"SetBranchAddress", writeStlWithoutProxyMsg,
3030 if (isBranchElement) {
3036 if (isBranchElement) {
3037 if (expectedClass) {
3146 for (
Int_t i = 0; i < nb; ++i) {
3156 if (thistree !=
this) {
3181 for (
Int_t lndx = 0; lndx < nleaves; ++lndx) {
3187 if (branch && (newcomp > -1)) {
3196 for (
Long64_t i = 0; i < nb; ++i) {
3207 for (
Int_t j = 0; j < nb1; ++j) {
3221 for (
Int_t k = 0; k < nb2; ++k) {
3253 Error(
"CloneTTree",
"TTree has not been cloned\n");
3276 for (
Int_t i = 0; i < nbranches; ++i) {
3283 tree->ResetBranchAddress(br);
3312 Warning(
"CopyAddresses",
"Could not find branch named '%s' in tree named '%s'", branch->
GetName(),
tree->GetName());
3320 std::set<TLeaf*> updatedLeafCount;
3321 for (
Int_t i = 0; i < ntleaves; ++i) {
3337 tree->ResetBranchAddress(tbranch);
3340 bool needAddressReset =
false;
3348 needAddressReset =
true;
3350 needAddressReset = (updatedLeafCount.find(leaf->
GetLeafCount()) != updatedLeafCount.end());
3373 if (br->
IsA() != branch->
IsA()) {
3376 "Branch kind mismatch between input tree '%s' and output tree '%s' for branch '%s': '%s' vs '%s'",
3386 Warning(
"CopyAddresses",
"Could not find branch named '%s' in tree named '%s'", branch->
GetName(),
tree->GetName());
3395 (
tree->IsA()->InheritsFrom(
"TNtuple") ||
tree->IsA()->InheritsFrom(
"TNtupleD") )
3397 tree->ResetBranchAddresses();
3403 enum EOnIndexError { kDrop, kKeep, kBuild };
3405 static Bool_t R__HandleIndex(EOnIndexError onIndexError,
TTree *newtree,
TTree *oldtree)
3413 switch (onIndexError) {
3437 switch (onIndexError) {
3443 index->SetTree(newtree);
3451 index->SetTree(newtree);
3461 }
else if ( onIndexError == kDrop ) {
3516 EOnIndexError onIndexError;
3518 onIndexError = kKeep;
3519 }
else if (opt.
Contains(
"buildindex")) {
3520 onIndexError = kBuild;
3521 }
else if (opt.
Contains(
"dropindex")) {
3522 onIndexError = kDrop;
3524 onIndexError = kBuild;
3527 Int_t cacheSize = -1;
3530 Ssiz_t cacheSizeEnd = opt.
Index(
" ",cacheSizeLoc+10) - (cacheSizeLoc+10);
3531 TSubString cacheSizeStr( opt(cacheSizeLoc+10,cacheSizeEnd) );
3534 Warning(
"CopyEntries",
"The cachesize option can not be parsed: %s. The default size will be used.",cacheSizeStr.
String().
Data());
3537 const char *munit =
nullptr;
3540 Warning(
"CopyEntries",
"The cachesize option is too large: %s (%g%s max). The default size will be used.",cacheSizeStr.
String().
Data(),
m,munit);
3543 if (
gDebug > 0 && cacheSize != -1)
Info(
"CopyEntries",
"Using Cache size: %d\n",cacheSize);
3549 }
else if (
nentries > treeEntries) {
3553 if (fastClone && (nentries < 0 || nentries == tree->
GetEntriesFast())) {
3557 if (
tree->LoadTree(i) < 0) {
3561 withIndex = R__HandleIndex( onIndexError,
this,
tree );
3586 if (needCopyAddresses) {
3592 for (
Long64_t ii = 0; ii < tentries; ii++) {
3593 if (localtree->
GetEntry(ii) <= 0) {
3598 if (needCopyAddresses)
3599 tree->ResetBranchAddresses();
3605 if (
tree->GetDirectory() &&
tree->GetDirectory()->GetFile()) {
3606 Warning(
"CopyEntries",
"Skipped file %s\n",
tree->GetDirectory()->GetFile()->GetName());
3608 Warning(
"CopyEntries",
"Skipped file number %d\n",
tree->GetTreeNumber());
3622 }
else if (
nentries > treeEntries) {
3625 if (needCopyAddresses) {
3631 Int_t treenumber = -1;
3633 if (
tree->LoadTree(i) < 0) {
3636 if (treenumber !=
tree->GetTreeNumber()) {
3638 withIndex = R__HandleIndex( onIndexError,
this,
tree );
3640 treenumber =
tree->GetTreeNumber();
3642 if (
tree->GetEntry(i) <= 0) {
3645 nbytes += this->
Fill();
3647 if (needCopyAddresses)
3648 tree->ResetBranchAddresses();
3725 if (!
file->IsWritable()) {
3726 Error(
"Delete",
"File : %s is not writable, cannot delete Tree:%s",
file->GetName(),
GetName());
3743 Int_t nbytes,objlen,keylen;
3744 while ((leaf = (
TLeaf*)next())) {
3747 for (
Int_t i=0;i<nbaskets;i++) {
3751 if (!branchFile)
continue;
3753 if (nbytes <= 0)
continue;
3754 branchFile->
MakeFree(pos,pos+nbytes-1);
3768 if (dirsav) dirsav->
cd();
3769 if (
gDebug)
Info(
"TTree::Delete",
"Deleting Tree: %s: %d baskets deleted. Total space freed = %d bytes\n",
GetName(),nbask,ntot);
4491 for (
Int_t i = 0; i < nb; ++i) {
4504 for (
Int_t i = 0; i < nleaves; ++i) {
4508 for (
Int_t j = 0; j < nbaskets - 1; ++j) {
4597 for (
Int_t i = 0; i < nbranches; ++i) {
4605 nwrite = branch->
FillImpl(
nullptr);
4607 nwrite = branch->
FillImpl(useIMT ? &imtHelper :
nullptr);
4611 Error(
"Fill",
"Failed filling branch:%s.%s, nbytes=%d, entry=%lld\n"
4612 " This error is symptomatic of a Tree created as a memory-resident Tree\n"
4613 " Instead of doing:\n"
4614 " TTree *T = new TTree(...)\n"
4615 " TFile *f = new TFile(...)\n"
4617 " TFile *f = new TFile(...)\n"
4618 " TTree *T = new TTree(...)\n\n",
4621 Error(
"Fill",
"Failed filling branch:%s.%s, nbytes=%d, entry=%lld",
GetName(), branch->
GetName(), nwrite,
4653 bool autoFlush =
false;
4654 bool autoSave =
false;
4672 if (autoFlush || autoSave) {
4683 Info(
"TTree::Fill",
"OptimizeBaskets called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",
4695 if (zipBytes != 0) {
4697 }
else if (totBytes != 0) {
4732 Info(
"TTree::Fill",
"FlushBaskets() called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",
fEntries,
4740 Info(
"TTree::Fill",
"AutoSave called at entry %lld, fZipBytes=%lld, fSavedBytes=%lld\n",
fEntries,
4755 return nerror == 0 ? nbytes : -1;
4763 if (list==0 || branchname == 0 || branchname[0] ==
'\0')
return 0;
4767 UInt_t brlen = strlen(branchname);
4775 const char *dim = strchr(
name,
'[');
4780 if (brlen ==
len && strncmp(branchname,
name,
len)==0) {
4784 if ((brlen >=
len) && (branchname[
len] ==
'.')
4785 && strncmp(
name, branchname,
len) == 0) {
4792 if (next)
return next;
4794 const char *dot = strchr((
char*)branchname,
'.');
4796 if (
len==(
size_t)(dot-branchname) &&
4797 strncmp(branchname,
name,dot-branchname)==0 ) {
4828 if (branch)
return branch;
4832 if (branch)
return branch;
4836 while ((branch = (
TBranch*) next())) {
4839 return nestedbranch;
4856 const char *subbranch = strstr(branchname, fe->
GetName());
4857 if (subbranch != branchname) {
4858 subbranch =
nullptr;
4861 subbranch += strlen(fe->
GetName());
4862 if (*subbranch !=
'.') {
4863 subbranch =
nullptr;
4868 std::ostringstream
name;
4898 const char* subsearchname = strstr(searchname,
GetName());
4899 if (subsearchname != searchname) {
4900 subsearchname =
nullptr;
4902 if (subsearchname) {
4903 subsearchname += strlen(
GetName());
4904 if (*subsearchname !=
'.') {
4905 subsearchname =
nullptr;
4908 if (subsearchname[0] == 0) {
4909 subsearchname =
nullptr;
4919 const bool searchnameHasDot = strchr(searchname,
'.') !=
nullptr;
4923 TLeaf* leaf =
nullptr;
4924 while ((leaf = (
TLeaf*) next())) {
4927 if (dim >= 0) leafname.
Remove(dim);
4929 if (leafname == searchname) {
4932 if (subsearchname && leafname == subsearchname) {
4938 dim = leaftitle.
First(
'[');
4939 if (dim >= 0) leaftitle.
Remove(dim);
4941 if (leaftitle == searchname) {
4944 if (subsearchname && leaftitle == subsearchname) {
4947 if (!searchnameHasDot)
4952 dim = longname.
First(
'[');
4953 if (dim>=0) longname.
Remove(dim);
4954 if (longname == searchname) {
4957 if (subsearchname && longname == subsearchname) {
4961 dim = longtitle.
First(
'[');
4962 if (dim>=0) longtitle.
Remove(dim);
4963 if (longtitle == searchname) {
4966 if (subsearchname && longtitle == subsearchname) {
4974 if (strstr(searchname,
".") && !strcmp(searchname, branch->
GetName())) {
4977 if (subsearchname && strstr(subsearchname,
".") && !strcmp(subsearchname, branch->
GetName())) {
4995 subsearchname = strstr(searchname, fe->
GetName());
4996 if (subsearchname != searchname) {
4997 subsearchname =
nullptr;
4999 if (subsearchname) {
5000 subsearchname += strlen(fe->
GetName());
5001 if (*subsearchname !=
'.') {
5002 subsearchname =
nullptr;
5007 if (subsearchname) {
5008 leafname.
Form(
"%s.%s",t->
GetName(),subsearchname);
5010 leafname = searchname;
5058struct BoolRAIIToggle {
5061 BoolRAIIToggle(
Bool_t &val) : m_val(val) { m_val =
true; }
5062 ~BoolRAIIToggle() { m_val =
false; }
5101 if (retval == -1)
return retval;
5136 std::atomic<Int_t> nerrpar(0);
5137 std::atomic<Int_t> nbpar(0);
5138 std::atomic<Int_t> pos(0);
5140 auto mapFunction = [&]() {
5146 Int_t j = pos.fetch_add(1);
5152 std::stringstream ss;
5153 ss << std::this_thread::get_id();
5154 Info(
"FlushBaskets",
"[IMT] Thread %s", ss.str().c_str());
5155 Info(
"FlushBaskets",
"[IMT] Running task for branch #%d: %s", j, branch->GetName());
5158 Int_t nbtask = branch->FlushBaskets();
5160 if (nbtask < 0) { nerrpar++; }
5161 else { nbpar += nbtask; }
5165 pool.
Foreach(mapFunction, nb);
5171 return nerrpar ? -1 : nbpar.load();
5174 for (
Int_t j = 0; j < nb; j++) {
5217 const char* alias = t->
GetAlias(aliasName);
5221 const char* subAliasName = strstr(aliasName, fe->
GetName());
5222 if (subAliasName && (subAliasName[strlen(fe->
GetName())] ==
'.')) {
5242 for (
Int_t i = 0; i < nb; i++) {
5246 if (!strcmp(
b->GetName(),
name)) {
5249 if (!strcmp(
b->GetFullName(),
name)) {
5253 result = R__GetBranch(*(
b->GetListOfBranches()),
name);
5288 for (
Int_t i = 0; i < nleaves; i++) {