420 #include "snprintf.h"
472 case kchar:
return 0;
477 case kBits:
return 0;
513 fMethodBit(tfl.fMethodBit),
514 fPrevious(tfl.fPrevious)
538 fTree->fFriendLockStatus &= ~(fMethodBit &
kBitMask);
565 entryInRange = firstEntry;
568 entryInRange = firstEntry - pedestal;
576 if (autoflush <= 0) {
579 fStartEntry = pedestal + entryInRange - entryInRange%autoflush;
604 auto autoFlush = fTree->GetAutoFlush();
605 if (autoFlush > 0)
return autoFlush;
606 if (fEstimatedSize > 0)
return fEstimatedSize;
608 Long64_t zipBytes = fTree->GetZipBytes();
610 fEstimatedSize = fTree->GetEntries() - 1;
611 if (fEstimatedSize <= 0)
615 Long64_t cacheSize = fTree->GetCacheSize();
616 if (cacheSize == 0) {
627 if (cacheSize <= 0) {
628 cacheSize = 30000000;
630 clusterEstimate = fTree->GetEntries() * cacheSize / zipBytes;
632 fEstimatedSize = clusterEstimate ? clusterEstimate : 1;
634 return fEstimatedSize;
643 fStartEntry = fNextEntry;
644 if (fTree->fNClusterRange || fTree->GetAutoFlush() > 0) {
645 if (fClusterRange == fTree->fNClusterRange) {
648 fNextEntry += GetEstimatedClusterSize();
650 if (fStartEntry > fTree->fClusterRangeEnd[fClusterRange]) {
653 if (fClusterRange == fTree->fNClusterRange) {
656 fNextEntry += GetEstimatedClusterSize();
658 Long64_t clusterSize = fTree->fClusterSize[fClusterRange];
659 if (clusterSize == 0) {
660 clusterSize = GetEstimatedClusterSize();
662 fNextEntry += clusterSize;
663 if (fNextEntry > fTree->fClusterRangeEnd[fClusterRange]) {
667 fNextEntry = fTree->fClusterRangeEnd[fClusterRange] + 1;
673 fNextEntry = fStartEntry + GetEstimatedClusterSize();
675 if (fNextEntry > fTree->GetEntries()) {
676 fNextEntry = fTree->GetEntries();
687 fNextEntry = fStartEntry;
688 if (fTree->fNClusterRange || fTree->GetAutoFlush() > 0) {
689 if (fClusterRange == 0 || fTree->fNClusterRange == 0) {
692 fStartEntry -= GetEstimatedClusterSize();
697 if (fClusterRange == 0) {
701 Long64_t clusterSize = fTree->fClusterSize[fClusterRange];
702 if (clusterSize == 0) {
703 clusterSize = GetEstimatedClusterSize();
705 fStartEntry -= clusterSize;
710 fStartEntry = fNextEntry - GetEstimatedClusterSize();
712 if (fStartEntry < 0) {
823 , fDefaultEntryOffsetLen(1000)
825 , fMaxClusterRange(0)
829 , fAutoSave( -300000000)
830 , fAutoFlush(-30000000)
832 , fClusterRangeEnd(0)
856 , fExternalFriends(0)
862 , fFriendLockStatus(0)
863 , fTransientBuffer(0)
864 , fCacheDoAutoInit(
kTRUE)
865 , fCacheDoClusterPrefetch(
kFALSE)
868 , fNEntriesSinceSorting(0)
901 if (strlen(title) > 2) {
902 if (title[0] ==
'/') {
903 Branch(title+1,32000,splitlevel);
918 #ifdef R__TRACK_BASKET_ALLOC_TIME
919 Info(
"TTree::~TTree",
"For tree %s, allocation time is %lluus.",
GetName(), fAllocationTime.load());
1046 Error(
"AddBranchToCache",
"Could not load a tree");
1055 Error(
"AddBranchToCache",
"No tree is available. Branch was not added to the cache");
1061 Error(
"AddBranchToCache",
"No file is available. Branch was not added to the cache");
1066 Error(
"AddBranchToCache",
"No cache is available, branch not added");
1069 return tc->
AddBranch(bname,subbranches);
1085 Error(
"AddBranchToCache",
"Could not load a tree");
1093 Error(
"AddBranchToCache",
"Error adding branch");
1098 Error(
"AddBranchToCache",
"No tree is available. Branch was not added to the cache");
1104 Error(
"AddBranchToCache",
"No file is available. Branch was not added to the cache");
1109 Error(
"AddBranchToCache",
"No cache is available, branch not added");
1129 Error(
"DropBranchFromCache",
"Could not load a tree");
1138 Error(
"DropBranchFromCache",
"No tree is available. Branch was not dropped from the cache");
1144 Error(
"DropBranchFromCache",
"No file is available. Branch was not dropped from the cache");
1149 Error(
"DropBranchFromCache",
"No cache is available, branch not dropped");
1168 Error(
"DropBranchFromCache",
"Could not load a tree");
1176 Error(
"DropBranchFromCache",
"Error dropping branch");
1181 Error(
"DropBranchFromCache",
"No tree is available. Branch was not dropped from the cache");
1187 Error(
"DropBranchFromCache",
"No file is available. Branch was not dropped from the cache");
1192 Error(
"DropBranchFromCache",
"No cache is available, branch not dropped");
1227 const auto friendHasValidIndex = [&] {
1232 if ((isMainReshuffled || isFriendReshuffled) && !friendHasValidIndex) {
1233 const auto reshuffledTreeName = isMainReshuffled ? mainTree.
GetName() : friendTree.
GetName();
1234 const auto msg =
"Tree '%s' has the kEntriesReshuffled bit set, and cannot be used as friend nor can be added as "
1235 "a friend unless the main tree has a TTreeIndex on the friend tree '%s'. You can also unset the "
1236 "bit manually if you know what you are doing.";
1237 Error(
"AddFriend", msg, reshuffledTreeName, friendTree.
GetName());
1322 bool canAddFriend =
true;
1326 Warning(
"AddFriend",
"FriendElement %s in file %s has less entries %lld than its parent Tree: %lld", treename,
1330 Error(
"AddFriend",
"Cannot find tree '%s' in file '%s', friend not added", treename, filename);
1331 canAddFriend =
false;
1356 bool canAddFriend =
true;
1360 Warning(
"AddFriend",
"FriendElement %s in file %s has less entries %lld than its parent tree: %lld", treename,
1364 Error(
"AddFriend",
"Cannot find tree '%s' in file '%s', friend not added", treename,
file->GetName());
1365 canAddFriend =
false;
1391 Warning(
"AddFriend",
"FriendElement '%s' in file '%s' has less entries %lld than its parent tree: %lld",
1397 tree->RegisterExternalFriend(fe);
1491 if (opt.
Contains(
"flushbaskets")) {
1492 if (
gDebug > 0)
Info(
"AutoSave",
"calling FlushBaskets \n");
1511 if (
file)
file->WriteStreamerInfo();
1525 const char* writeStlWithoutProxyMsg =
"The class requested (%s) for the branch \"%s\""
1526 " is an instance of an stl collection and does not have a compiled CollectionProxy."
1527 " Please generate the dictionary for this collection (%s) to avoid to write corrupted data.";
1541 Error(
"Branch", writeStlWithoutProxyMsg,
1545 return Branch(branchname, classname, (
void*) addobj, bufsize, splitlevel);
1548 void** addr = (
void**) addobj;
1552 if (ptrClass && claim) {
1559 Error(
"Branch",
"The class requested (%s) for \"%s\" is different from the type of the pointer passed (%s)",
1562 }
else if (actualClass && (claim != actualClass) && !actualClass->
InheritsFrom(claim)) {
1567 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s",
1573 Error(
"Branch", writeStlWithoutProxyMsg,
1577 return Branch(branchname, classname, (
void*) addobj, bufsize, splitlevel);
1587 Error(
"Branch",
"The pointer specified for %s is not of a class known to ROOT", branchname);
1591 void** addr = (
void**) addobj;
1592 if (addr && *addr) {
1595 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",
1596 branchname, ptrClass->
GetName());
1597 actualClass = ptrClass;
1598 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1599 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());
1603 actualClass = ptrClass;
1606 Error(
"Branch", writeStlWithoutProxyMsg,
1610 return Branch(branchname, actualClass->
GetName(), (
void*) addobj, bufsize, splitlevel);
1622 Error(
"Branch", writeStlWithoutProxyMsg,
1625 }
else if (claim == 0) {
1626 Error(
"Branch",
"The pointer specified for %s is not of a class known to ROOT and %s is not a known class", branchname, classname);
1633 Error(
"Branch",
"Reference interface requires a valid object (for branch: %s)!", branchname);
1637 if (ptrClass && claim) {
1644 Error(
"Branch",
"The class requested (%s) for \"%s\" is different from the type of the object passed (%s)",
1647 }
else if (actualClass && (claim != actualClass) && !actualClass->
InheritsFrom(claim)) {
1652 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s",
1658 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",
1659 branchname, ptrClass->
GetName());
1660 actualClass = ptrClass;
1661 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1662 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());
1666 Error(
"Branch", writeStlWithoutProxyMsg,
1681 Error(
"Branch",
"The pointer specified for %s is not of a class or type known to ROOT", branchname);
1684 return Branch(branchname,addobj,varname.
Data(),bufsize);
1690 Error(
"Branch",
"Reference interface requires a valid object (for branch: %s)!", branchname);
1695 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",
1696 branchname, ptrClass->
GetName());
1697 actualClass = ptrClass;
1698 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1699 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());
1703 Error(
"Branch", writeStlWithoutProxyMsg,
1718 "The inner type of the std::array passed specified for %s is not of a class or type known to ROOT",
1723 return Branch(branchname, addobj, varname.
Data(), bufsize);
1824 Error(
"Branch",
"Cannot call this constructor for a TClonesArray");
1830 while ((obj = next())) {
1838 Branch(col, bufsize, splitlevel - 1, branchname);
1840 if (nch && (
name[nch-1] ==
'_')) {
1849 if (splitlevel > 99) {
1875 char* curname =
new char[1000];
1877 while ((obj = next())) {
1880 Branch(curname, bufsize, splitlevel - 1);
1883 for (
Int_t i = 0; i < 1000; ++i) {
1884 if (curname[i] == 0) {
1887 if (curname[i] ==
'/') {
1894 strlcat(curname, occur,1000);
2005 return Bronch(
name, classname, addobj, bufsize, splitlevel);
2007 if (splitlevel < 0) {
2010 return BranchOld(
name, classname, addobj, bufsize, splitlevel);
2059 Error(
"BranchOld",
"Cannot find class: '%s'", classname);
2064 Fatal(
"BranchOld",
"The requested class ('%s') does not inherit from TObject.\n"
2065 "\tfgBranchStyle is set to zero requesting by default to use BranchOld.\n"
2066 "\tIf this is intentional use Bronch instead of Branch or BranchOld.", classname);
2068 Fatal(
"BranchOld",
"The requested class ('%s') does not inherit from TObject.\n"
2069 "\tYou can not use BranchOld to store objects of this type.",classname);
2080 const char* rdname = 0;
2081 const char* dname = 0;
2083 char** apointer = (
char**) addobj;
2095 if (
name[lenName-1] ==
'.') {
2134 if (!strcmp(dname,
"fBits")) {
2137 if (!strcmp(dname,
"fUniqueID")) {
2147 branchname = rdname;
2151 branchname.
Form(
"%s%s",
name, &rdname[1]);
2153 branchname.
Form(
"%s%s",
name, &rdname[0]);
2159 char* pointer = ((
char*) obj) + offset;
2168 char* cpointer = (
char*) pointer;
2169 char** ppointer = (
char**) cpointer;
2171 if (splitlevel != 2) {
2173 branch1 =
new TBranchClones(branch,branchname, pointer, bufsize);
2178 blist->
Add(branch1);
2186 blist->
Add(branch1);
2203 blist->
Add(branch1);
2224 if (!strcmp(rdi->
GetName(), index)) {
2227 if (!strcmp(rdi->
GetName(), aindex)) {
2239 leaflist.
Form(
"%s[%s]/%c", &rdname[0], index, vcode);
2241 Error(
"BranchOld",
"Cannot create branch for rdname: %s code: %d", branchname.
Data(), code);
2248 leaflist.
Form(
"%s/%s", dname,
"C");
2261 branch1 =
new TBranch(branch, bname, *((
void**) pointer), leaflist, bufsize);
2265 blist->
Add(branch1);
2272 leaflist.
Form(
"%s/%c", rdname, vcode);
2274 Error(
"BranchOld",
"Cannot create branch for rdname: %s code: %d", branchname.
Data(), code);
2277 branch1 =
new TBranch(branch, branchname, pointer, leaflist, bufsize);
2279 blist->
Add(branch1);
2288 Warning(
"BranchOld",
"Cannot process member: '%s'", rdname);
2397 Error(
"Bronch",
"Cannot find class:%s", classname);
2408 objptr = (
char*)addr;
2410 objptr = *((
char**) addr);
2416 Error(
"Bronch",
"Pointer to TClonesArray is null");
2420 Error(
"Bronch",
"TClonesArray with no class defined in branch: %s",
name);
2424 Error(
"Bronch",
"TClonesArray with no dictionary defined in branch: %s",
name);
2428 if (splitlevel > 0) {
2429 if (hasCustomStreamer)
2430 Warning(
"Bronch",
"Using split mode on a class: %s with a custom Streamer", clones->
GetClass()->
GetName());
2445 if (!inklass && (collProxy->
GetType() == 0)) {
2446 Error(
"Bronch",
"%s with no class defined in branch: %s", classname,
name);
2453 Error(
"Bronch",
"Container with no dictionary defined in branch: %s",
name);
2457 Warning(
"Bronch",
"Using split mode on a class: %s with a custom Streamer", inklass->
GetName());
2468 branch =
new TBranchSTL(
this,
name, collProxy, bufsize, splitlevel );
2482 Error(
"Bronch",
"Cannot find dictionary for class: %s", classname);
2488 hasCustomStreamer =
kTRUE;
2491 if (splitlevel < 0 || ((splitlevel == 0) && hasCustomStreamer && cl->
IsTObject())) {
2522 objptr = (
char*) cl->
New();
2530 if ((splitlevel > 0) && !cl->
CanSplit()) {
2531 if (splitlevel != 99) {
2532 Warning(
"Bronch",
"%s cannot be split, resetting splitlevel to 0", cl->
GetName());
2546 Error(
"Bronch",
"Cannot build the StreamerInfo for class: %s", cl->
GetName());
2555 if (splitlevel > 0) {
2566 branch->
Unroll(
name, cl, sinfo, objptr, bufsize, splitlevel);
2712 constexpr
auto kBufSize = 2000;
2713 char* fname =
new char[kBufSize];
2716 for (
Int_t i = 0; i < 10; ++i) {
2724 strlcpy(fname,
file->GetName(), kBufSize);
2727 char* cunder = strrchr(fname,
'_');
2730 const char* cdot = strrchr(
file->GetName(),
'.');
2732 strlcat(fname, cdot, kBufSize);
2737 strlcat(fname, fcount, kBufSize);
2740 char* cdot = strrchr(fname,
'.');
2743 strlcat(fname, strrchr(
file->GetName(),
'.'), kBufSize);
2747 strlcat(fname, fcount, kBufSize);
2754 Warning(
"ChangeFile",
"file %s already exist, trying with %d underscores", fname, nus+1);
2756 Int_t compress =
file->GetCompressionSettings();
2759 Error(
"Fill",
"Failed to open new file %s, continuing as a memory tree.",fname);
2761 Printf(
"Fill: Switching to new file: %s", fname);
2767 while ((obj =
file->GetList()->First())) {
2784 while ((branch = (
TBranch*)nextb())) {
2793 if (newfile) newfile->
Append(obj);
2796 file->TObject::Delete();
2833 TClass* expectedClass = 0;
2840 if (expectedClass && datatype ==
kOther_t && ptrClass == 0) {
2841 if (isBranchElement) {
2846 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2847 "The class expected (%s) refers to an stl collection and do not have a compiled CollectionProxy. "
2848 "Please generate the dictionary for this class (%s)",
2855 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2856 "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."
2857 "Please generate the dictionary for this class (%s)",
2860 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2861 "This is probably due to a missing dictionary, the original data class for this branch is %s.", branch->
GetName(), expectedClass->
GetName());
2865 if (expectedClass && ptrClass && (branch->
GetMother() == branch)) {
2868 Error(
"SetBranchAddress",
"The address for \"%s\" should be the address of a pointer!", branch->
GetName());
2888 if( expectedClass && ptrClass &&
2889 expectedClass != ptrClass &&
2897 Info(
"SetBranchAddress",
"Matching STL collection (at least according to the SchemaRuleSet when "
2898 "reading a %s into a %s",expectedClass->
GetName(),ptrClass->
GetName());
2905 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());
2916 }
else if (expectedClass && ptrClass && !expectedClass->
InheritsFrom(ptrClass)) {
2938 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());
2939 if (isBranchElement) {
2948 Error(
"SetBranchAddress",
"The pointer type given \"%s\" (%d) does not correspond to the type needed \"%s\" (%d) by the branch: %s",
2955 if (expectedClass) {
2956 Error(
"SetBranchAddress",
"The pointer type given \"%s\" (%d) does not correspond to the type needed \"%s\" by the branch: %s",
2958 if (isBranchElement) {
2974 if (etype == expectedType) {
2989 if (etype == expectedType) {
3001 if (len <= ptrClass->
Size()) {
3005 Error(
"SetBranchAddress",
"The pointer type given \"%s\" does not correspond to the type needed \"%s\" (%d) by the branch: %s",
3011 Error(
"SetBranchAddress", writeStlWithoutProxyMsg,
3013 if (isBranchElement) {
3019 if (isBranchElement) {
3020 if (expectedClass) {
3129 for (
Int_t i = 0; i < nb; ++i) {
3139 if (thistree !=
this) {
3164 for (
Int_t lndx = 0; lndx < nleaves; ++lndx) {
3170 if (branch && (newcomp > -1)) {
3179 for (
Long64_t i = 0; i < nb; ++i) {
3190 for (
Int_t j = 0; j < nb1; ++j) {
3204 for (
Int_t k = 0; k < nb2; ++k) {
3234 if ( newtree->
CopyEntries(
this, -1, option ) < 0 ) {
3236 Error(
"CloneTTree",
"TTree has not been cloned\n");
3259 for (
Int_t i = 0; i < nbranches; ++i) {
3266 tree->ResetBranchAddress(br);
3295 Warning(
"CopyAddresses",
"Could not find branch named '%s' in tree named '%s'", branch->
GetName(),
tree->GetName());
3303 std::set<TLeaf*> updatedLeafCount;
3304 for (
Int_t i = 0; i < ntleaves; ++i) {
3320 tree->ResetBranchAddress(tbranch);
3323 bool needAddressReset =
false;
3331 needAddressReset =
true;
3333 needAddressReset = (updatedLeafCount.find(leaf->
GetLeafCount()) != updatedLeafCount.end());
3362 Warning(
"CopyAddresses",
"Could not find branch named '%s' in tree named '%s'", branch->
GetName(),
tree->GetName());
3371 (
tree->IsA()->InheritsFrom(
"TNtuple") ||
tree->IsA()->InheritsFrom(
"TNtupleD") )
3373 tree->ResetBranchAddresses();
3379 enum EOnIndexError { kDrop, kKeep, kBuild };
3381 static Bool_t R__HandleIndex(EOnIndexError onIndexError,
TTree *newtree,
TTree *oldtree)
3389 switch (onIndexError) {
3413 switch (onIndexError) {
3437 }
else if ( onIndexError == kDrop ) {
3492 EOnIndexError onIndexError;
3494 onIndexError = kKeep;
3495 }
else if (opt.
Contains(
"buildindex")) {
3496 onIndexError = kBuild;
3497 }
else if (opt.
Contains(
"dropindex")) {
3498 onIndexError = kDrop;
3500 onIndexError = kBuild;
3503 Int_t cacheSize = -1;
3506 Ssiz_t cacheSizeEnd = opt.
Index(
" ",cacheSizeLoc+10) - (cacheSizeLoc+10);
3507 TSubString cacheSizeStr( opt(cacheSizeLoc+10,cacheSizeEnd) );
3510 Warning(
"CopyEntries",
"The cachesize option can not be parsed: %s. The default size will be used.",cacheSizeStr.
String().
Data());
3513 const char *munit =
nullptr;
3516 Warning(
"CopyEntries",
"The cachesize option is too large: %s (%g%s max). The default size will be used.",cacheSizeStr.
String().
Data(),
m,munit);
3519 if (
gDebug > 0 && cacheSize != -1)
Info(
"CopyEntries",
"Using Cache size: %d\n",cacheSize);
3525 }
else if (
nentries > treeEntries) {
3529 if (fastClone && (nentries < 0 || nentries == tree->
GetEntriesFast())) {
3533 if (
tree->LoadTree(i) < 0) {
3537 withIndex = R__HandleIndex( onIndexError,
this,
tree );
3562 for (
Long64_t ii = 0; ii < tentries; ii++) {
3563 if (localtree->
GetEntry(ii) <= 0) {
3573 if (
tree->GetDirectory() &&
tree->GetDirectory()->GetFile()) {
3574 Warning(
"CopyEntries",
"Skipped file %s\n",
tree->GetDirectory()->GetFile()->GetName());
3576 Warning(
"CopyEntries",
"Skipped file number %d\n",
tree->GetTreeNumber());
3590 }
else if (
nentries > treeEntries) {
3593 Int_t treenumber = -1;
3595 if (
tree->LoadTree(i) < 0) {
3598 if (treenumber !=
tree->GetTreeNumber()) {
3600 withIndex = R__HandleIndex( onIndexError,
this,
tree );
3602 treenumber =
tree->GetTreeNumber();
3604 if (
tree->GetEntry(i) <= 0) {
3607 nbytes += this->
Fill();
3684 if (
file && !strcmp(option,
"all")) {
3685 if (!
file->IsWritable()) {
3686 Error(
"Delete",
"File : %s is not writable, cannot delete Tree:%s",
file->GetName(),
GetName());
3703 Int_t nbytes,objlen,keylen;
3704 while ((leaf = (
TLeaf*)next())) {
3707 for (
Int_t i=0;i<nbaskets;i++) {
3711 if (!branchFile)
continue;
3713 if (nbytes <= 0)
continue;
3714 branchFile->
MakeFree(pos,pos+nbytes-1);
3728 if (dirsav) dirsav->
cd();
3729 if (
gDebug)
Info(
"TTree::Delete",
"Deleting Tree: %s: %d baskets deleted. Total space freed = %d bytes\n",
GetName(),nbask,ntot);
4455 for (
Int_t i = 0; i < nb; ++i) {
4469 for (
Int_t i = 0; i < nleaves; ++i) {
4473 for (
Int_t j = 0; j < nbaskets - 1; ++j) {
4562 for (
Int_t i = 0; i < nbranches; ++i) {
4570 nwrite = branch->
FillImpl(
nullptr);
4572 nwrite = branch->
FillImpl(useIMT ? &imtHelper :
nullptr);
4576 Error(
"Fill",
"Failed filling branch:%s.%s, nbytes=%d, entry=%lld\n"
4577 " This error is symptomatic of a Tree created as a memory-resident Tree\n"
4578 " Instead of doing:\n"
4579 " TTree *T = new TTree(...)\n"
4580 " TFile *f = new TFile(...)\n"
4582 " TFile *f = new TFile(...)\n"
4583 " TTree *T = new TTree(...)\n\n",
4586 Error(
"Fill",
"Failed filling branch:%s.%s, nbytes=%d, entry=%lld",
GetName(), branch->
GetName(), nwrite,
4618 bool autoFlush =
false;
4619 bool autoSave =
false;
4637 if (autoFlush || autoSave) {
4648 Info(
"TTree::Fill",
"OptimizeBaskets called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",
4660 if (zipBytes != 0) {
4662 }
else if (totBytes != 0) {
4697 Info(
"TTree::Fill",
"FlushBaskets() called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",
fEntries,
4705 Info(
"TTree::Fill",
"AutoSave called at entry %lld, fZipBytes=%lld, fSavedBytes=%lld\n",
fEntries,
4720 return nerror == 0 ? nbytes : -1;
4728 if (list==0 || branchname == 0 || branchname[0] ==
'\0')
return 0;
4732 UInt_t brlen = strlen(branchname);
4734 for(
Int_t index = 0; index < nbranches; ++index) {
4739 if (len &&
name[len-1]==
']') {
4740 const char *dim = strchr(
name,
'[');
4745 if (brlen == len && strncmp(branchname,
name,len)==0) {
4749 if ((brlen >= len) && (branchname[len] ==
'.')
4750 && strncmp(
name, branchname, len) == 0) {
4757 if (next)
return next;
4759 const char *dot = strchr((
char*)branchname,
'.');
4761 if (len==(
size_t)(dot-branchname) &&
4762 strncmp(branchname,
name,dot-branchname)==0 ) {
4790 if (branch)
return branch;
4794 if (branch)
return branch;
4798 while ((branch = (
TBranch*) next())) {
4801 return nestedbranch;
4818 const char *subbranch = strstr(branchname, fe->
GetName());
4819 if (subbranch != branchname) {
4823 subbranch += strlen(fe->
GetName());
4824 if (*subbranch !=
'.') {
4830 std::ostringstream
name;
4857 char* subsearchname = (
char*) strstr(searchname,
GetName());
4858 if (subsearchname != searchname) {
4861 if (subsearchname) {
4862 subsearchname += strlen(
GetName());
4863 if (*subsearchname !=
'.') {
4867 if (subsearchname[0]==0) {
4878 const bool searchnameHasDot = strchr(searchname,
'.') !=
nullptr;
4883 while ((leaf = (
TLeaf*) next())) {
4886 if (dim >= 0) leafname.
Remove(dim);
4888 if (leafname == searchname) {
4891 if (subsearchname && leafname == subsearchname) {
4897 dim = leaftitle.
First(
'[');
4898 if (dim >= 0) leaftitle.
Remove(dim);
4900 if (leaftitle == searchname) {
4903 if (subsearchname && leaftitle == subsearchname) {
4906 if (!searchnameHasDot)
4911 dim = longname.
First(
'[');
4912 if (dim>=0) longname.
Remove(dim);
4913 if (longname == searchname) {
4916 if (subsearchname && longname == subsearchname) {
4920 dim = longtitle.
First(
'[');
4921 if (dim>=0) longtitle.
Remove(dim);
4922 if (longtitle == searchname) {
4925 if (subsearchname && longtitle == subsearchname) {
4933 if (strstr(searchname,
".") && !strcmp(searchname, branch->
GetName())) {
4936 if (subsearchname && strstr(subsearchname,
".") && !strcmp(subsearchname, branch->
GetName())) {
4954 subsearchname = (
char*) strstr(searchname, fe->
GetName());
4955 if (subsearchname != searchname) {
4958 if (subsearchname) {
4959 subsearchname += strlen(fe->
GetName());
4960 if (*subsearchname !=
'.') {
4966 if (subsearchname) {
4967 leafname.
Form(
"%s.%s",t->
GetName(),subsearchname);
4969 leafname = searchname;
5011 return fPlayer->
Fit(funcname, varexp, selection, option, goption,
nentries, firstentry);
5017 struct BoolRAIIToggle {
5020 BoolRAIIToggle(
Bool_t &val) : m_val(val) { m_val =
true; }
5021 ~BoolRAIIToggle() { m_val =
false; }
5060 if (retval == -1)
return retval;
5095 std::atomic<Int_t> nerrpar(0);
5096 std::atomic<Int_t> nbpar(0);
5097 std::atomic<Int_t> pos(0);
5099 auto mapFunction = [&]() {
5105 Int_t j = pos.fetch_add(1);
5111 std::stringstream ss;
5112 ss << std::this_thread::get_id();
5113 Info(
"FlushBaskets",
"[IMT] Thread %s", ss.str().c_str());
5114 Info(
"FlushBaskets",
"[IMT] Running task for branch #%d: %s", j, branch->GetName());
5117 Int_t nbtask = branch->FlushBaskets();
5119 if (nbtask < 0) { nerrpar++; }
5120 else { nbpar += nbtask; }
5124 pool.
Foreach(mapFunction, nb);
5130 return nerrpar ? -1 : nbpar.load();
5133 for (
Int_t j = 0; j < nb; j++) {
5176 const char* alias = t->
GetAlias(aliasName);
5180 const char* subAliasName = strstr(aliasName, fe->
GetName());
5181 if (subAliasName && (subAliasName[strlen(fe->
GetName())] ==
'.')) {
5201 for (
Int_t i = 0; i < nb; i++) {
5205 if (!strcmp(
b->GetName(),
name)) {
5208 if (!strcmp(
b->GetFullName(),
name)) {
5212 result = R__GetBranch(*(
b->GetListOfBranches()),
name);
5224 if (
name == 0)
return 0;
5246 for (
Int_t i = 0; i < nleaves; i++) {
5283 char* subname = (
char*) strstr(
name, fe->
GetName());
5284 if (subname !=
name) {
5289 if (*subname !=
'.') {
5338 if (!(stcs =
gSystem->
Getenv(
"ROOT_TTREECACHE_SIZE")) || !*stcs) {
5344 if (cacheFactor < 0.0) {
5355 if (cacheSize >= (INT_MAX / 4)) {
5356 cacheSize = INT_MAX / 4;
5359 if (cacheSize < 0) {
5363 if (cacheSize == 0 && withDefault) {
5562 if (entry < 0 || entry >=
fEntries)
return 0;
5574 auto seqprocessing = [&]() {
5576 for (i=0;i<nbranches;i++) {
5578 nb = branch->
GetEntry(entry, getall);
5591 nb = branch->GetEntry(entry, getall);
5595 if (nb < 0)
return nb;
5601 std::atomic<Int_t> pos(0);
5602 std::atomic<Int_t> nbpar(0);
5604 auto mapFunction = [&]() {
5610 Int_t j = pos.fetch_add(1);
5616 std::stringstream ss;
5617 ss << std::this_thread::get_id();
5618 Info(
"GetEntry",
"[IMT] Thread %s", ss.str().c_str());
5619 Info(
"GetEntry",
"[IMT] Running task for branch #%d: %s", j, branch->GetName());
5622 std::chrono::time_point<std::chrono::system_clock> start, end;
5624 start = std::chrono::system_clock::now();
5625 nbtask = branch->GetEntry(entry, getall);
5626 end = std::chrono::system_clock::now();
5628 Long64_t tasktime = (
Long64_t)std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
5631 if (nbtask < 0) errnb = nbtask;
5632 else nbpar += nbtask;
5658 if (nb < 0)
return nb;
5675 if (nb < 0)
return nb;
5710 if (checkLeafCount) {
5711 for (
Int_t i = 0; i < nbranches; i++) {
5715 auto countBranch = leafCount->GetBranch();
5725 if (!checkLeafCount) {
5728 for (
Int_t i = 0; i < nbranches; i++) {