482 case kchar:
return 0;
487 case kBits:
return 0;
523 fMethodBit(tfl.fMethodBit),
524 fPrevious(tfl.fPrevious)
548 fTree->fFriendLockStatus &= ~(fMethodBit &
kBitMask);
575 entryInRange = firstEntry;
578 entryInRange = firstEntry - pedestal;
586 if (autoflush <= 0) {
589 fStartEntry = pedestal + entryInRange - entryInRange%autoflush;
614 auto autoFlush = fTree->GetAutoFlush();
615 if (autoFlush > 0)
return autoFlush;
616 if (fEstimatedSize > 0)
return fEstimatedSize;
618 Long64_t zipBytes = fTree->GetZipBytes();
620 fEstimatedSize = fTree->GetEntries() - 1;
621 if (fEstimatedSize <= 0)
625 Long64_t cacheSize = fTree->GetCacheSize();
626 if (cacheSize == 0) {
628 TFile *file = fTree->GetCurrentFile();
637 if (cacheSize <= 0) {
638 cacheSize = 30000000;
640 clusterEstimate = fTree->GetEntries() * cacheSize / zipBytes;
642 fEstimatedSize = clusterEstimate ? clusterEstimate : 1;
644 return fEstimatedSize;
653 fStartEntry = fNextEntry;
654 if (fTree->fNClusterRange || fTree->GetAutoFlush() > 0) {
655 if (fClusterRange == fTree->fNClusterRange) {
658 fNextEntry += GetEstimatedClusterSize();
660 if (fStartEntry > fTree->fClusterRangeEnd[fClusterRange]) {
663 if (fClusterRange == fTree->fNClusterRange) {
666 fNextEntry += GetEstimatedClusterSize();
668 Long64_t clusterSize = fTree->fClusterSize[fClusterRange];
669 if (clusterSize == 0) {
670 clusterSize = GetEstimatedClusterSize();
672 fNextEntry += clusterSize;
673 if (fNextEntry > fTree->fClusterRangeEnd[fClusterRange]) {
677 fNextEntry = fTree->fClusterRangeEnd[fClusterRange] + 1;
683 fNextEntry = fStartEntry + GetEstimatedClusterSize();
685 if (fNextEntry > fTree->GetEntries()) {
686 fNextEntry = fTree->GetEntries();
697 fNextEntry = fStartEntry;
698 if (fTree->fNClusterRange || fTree->GetAutoFlush() > 0) {
699 if (fClusterRange == 0 || fTree->fNClusterRange == 0) {
702 fStartEntry -= GetEstimatedClusterSize();
707 if (fClusterRange == 0) {
711 Long64_t clusterSize = fTree->fClusterSize[fClusterRange];
712 if (clusterSize == 0) {
713 clusterSize = GetEstimatedClusterSize();
715 fStartEntry -= clusterSize;
720 fStartEntry = fNextEntry - GetEstimatedClusterSize();
722 if (fStartEntry < 0) {
833, fDefaultEntryOffsetLen(1000)
839, fAutoSave( -300000000)
840, fAutoFlush(-30000000)
842, fClusterRangeEnd(nullptr)
843, fClusterSize(nullptr)
866, fExternalFriends(nullptr)
872, fFriendLockStatus(0)
873, fTransientBuffer(nullptr)
874, fCacheDoAutoInit(true)
875, fCacheDoClusterPrefetch(false)
876, fCacheUserSet(false)
877, fIMTEnabled(
ROOT::IsImplicitMTEnabled())
878, fNEntriesSinceSorting(0)
911 if (strlen(title) > 2) {
912 if (title[0] ==
'/') {
913 Branch(title+1,32000,splitlevel);
928#ifdef R__TRACK_BASKET_ALLOC_TIME
929 Info(
"TTree::~TTree",
"For tree %s, allocation time is %lluus.",
GetName(), fAllocationTime.load());
1064 Error(
"AddBranchToCache",
"Could not load a tree");
1073 Error(
"AddBranchToCache",
"No tree is available. Branch was not added to the cache");
1079 Error(
"AddBranchToCache",
"No file is available. Branch was not added to the cache");
1084 Error(
"AddBranchToCache",
"No cache is available, branch not added");
1087 return tc->
AddBranch(bname,subbranches);
1103 Error(
"AddBranchToCache",
"Could not load a tree");
1111 Error(
"AddBranchToCache",
"Error adding branch");
1116 Error(
"AddBranchToCache",
"No tree is available. Branch was not added to the cache");
1122 Error(
"AddBranchToCache",
"No file is available. Branch was not added to the cache");
1127 Error(
"AddBranchToCache",
"No cache is available, branch not added");
1147 Error(
"DropBranchFromCache",
"Could not load a tree");
1156 Error(
"DropBranchFromCache",
"No tree is available. Branch was not dropped from the cache");
1162 Error(
"DropBranchFromCache",
"No file is available. Branch was not dropped from the cache");
1167 Error(
"DropBranchFromCache",
"No cache is available, branch not dropped");
1186 Error(
"DropBranchFromCache",
"Could not load a tree");
1194 Error(
"DropBranchFromCache",
"Error dropping branch");
1199 Error(
"DropBranchFromCache",
"No tree is available. Branch was not dropped from the cache");
1205 Error(
"DropBranchFromCache",
"No file is available. Branch was not dropped from the cache");
1210 Error(
"DropBranchFromCache",
"No cache is available, branch not dropped");
1245 const auto friendHasValidIndex = [&] {
1247 return idx ? idx->
IsValidFor(&mainTree) :
false;
1250 if ((isMainReshuffled || isFriendReshuffled) && !friendHasValidIndex) {
1251 const auto reshuffledTreeName = isMainReshuffled ? mainTree.
GetName() : friendTree.
GetName();
1253 "Tree '%s' has the kEntriesReshuffled bit set and cannot have friends nor can be added as a friend unless the "
1254 "main tree has a TTreeIndex on the friend tree '%s'. You can also unset the bit manually if you know what you "
1255 "are doing; note that you risk associating wrong TTree entries of the friend with those of the main TTree!";
1256 Error(
"AddFriend", msg, reshuffledTreeName, friendTree.
GetName());
1341 bool canAddFriend =
true;
1345 Warning(
"AddFriend",
"FriendElement %s in file %s has less entries %lld than its parent Tree: %lld", treename,
1349 Error(
"AddFriend",
"Cannot find tree '%s' in file '%s', friend not added", treename,
filename);
1350 canAddFriend =
false;
1375 bool canAddFriend =
true;
1379 Warning(
"AddFriend",
"FriendElement %s in file %s has less entries %lld than its parent tree: %lld", treename,
1383 Error(
"AddFriend",
"Cannot find tree '%s' in file '%s', friend not added", treename, file->
GetName());
1384 canAddFriend =
false;
1410 Warning(
"AddFriend",
"FriendElement '%s' in file '%s' has less entries %lld than its parent tree: %lld",
1417 tree->RemoveExternalFriend(fe);
1510 if (opt.
Contains(
"flushbaskets")) {
1511 if (
gDebug > 0)
Info(
"AutoSave",
"calling FlushBaskets \n");
1544 const char* writeStlWithoutProxyMsg =
"The class requested (%s) for the branch \"%s\""
1545 " is an instance of an stl collection and does not have a compiled CollectionProxy."
1546 " Please generate the dictionary for this collection (%s) to avoid to write corrupted data.";
1560 Error(
"Branch", writeStlWithoutProxyMsg,
1564 return Branch(branchname, classname, (
void*) addobj, bufsize, splitlevel);
1566 TClass* actualClass =
nullptr;
1567 void** addr = (
void**) addobj;
1571 if (ptrClass && claim) {
1578 Error(
"Branch",
"The class requested (%s) for \"%s\" is different from the type of the pointer passed (%s)",
1581 }
else if (actualClass && (claim != actualClass) && !actualClass->
InheritsFrom(claim)) {
1586 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s",
1592 Error(
"Branch", writeStlWithoutProxyMsg,
1596 return Branch(branchname, classname, (
void*) addobj, bufsize, splitlevel);
1606 Error(
"Branch",
"The pointer specified for %s is not of a class known to ROOT", branchname);
1609 TClass* actualClass =
nullptr;
1610 void** addr = (
void**) addobj;
1611 if (addr && *addr) {
1614 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",
1615 branchname, ptrClass->
GetName());
1616 actualClass = ptrClass;
1617 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1618 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());
1622 actualClass = ptrClass;
1625 Error(
"Branch", writeStlWithoutProxyMsg,
1629 return Branch(branchname, actualClass->
GetName(), (
void*) addobj, bufsize, splitlevel);
1641 Error(
"Branch", writeStlWithoutProxyMsg,
1644 }
else if (claim ==
nullptr) {
1645 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 TClass* actualClass =
nullptr;
1652 Error(
"Branch",
"Reference interface requires a valid object (for branch: %s)!", branchname);
1656 if (ptrClass && claim) {
1663 Error(
"Branch",
"The class requested (%s) for \"%s\" is different from the type of the object passed (%s)",
1666 }
else if (actualClass && (claim != actualClass) && !actualClass->
InheritsFrom(claim)) {
1671 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s",
1677 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",
1678 branchname, ptrClass->
GetName());
1679 actualClass = ptrClass;
1680 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1681 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());
1685 Error(
"Branch", writeStlWithoutProxyMsg,
1689 return BronchExec(branchname, actualClass->
GetName(), (
void*) addobj,
false, bufsize, splitlevel);
1700 Error(
"Branch",
"The pointer specified for %s is not of a class or type known to ROOT", branchname);
1703 return Branch(branchname,addobj,varname.
Data(),bufsize);
1707 TClass* actualClass =
nullptr;
1709 Error(
"Branch",
"Reference interface requires a valid object (for branch: %s)!", branchname);
1714 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",
1715 branchname, ptrClass->
GetName());
1716 actualClass = ptrClass;
1717 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1718 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());
1722 Error(
"Branch", writeStlWithoutProxyMsg,
1726 return BronchExec(branchname, actualClass->
GetName(), (
void*) addobj,
false, bufsize, splitlevel);
1737 "The inner type of the std::array passed specified for %s is not of a class or type known to ROOT",
1742 return Branch(branchname, addobj, varname.
Data(), bufsize);
1843 Error(
"Branch",
"Cannot call this constructor for a TClonesArray");
1849 while ((obj = next())) {
1857 Branch(col, bufsize, splitlevel - 1, branchname);
1859 if (nch && (
name[nch-1] ==
'_')) {
1868 if (splitlevel > 99) {
1894 char* curname =
new char[1000];
1896 while ((obj = next())) {
1899 Branch(curname, bufsize, splitlevel - 1);
1902 for (
Int_t i = 0; i < 1000; ++i) {
1903 if (curname[i] == 0) {
1906 if (curname[i] ==
'/') {
1913 strlcat(curname, occur,1000);
2025 return Bronch(
name, classname, addobj, bufsize, splitlevel);
2027 if (splitlevel < 0) {
2030 return BranchOld(
name, classname, addobj, bufsize, splitlevel);
2079 Error(
"BranchOld",
"Cannot find class: '%s'", classname);
2084 Fatal(
"BranchOld",
"The requested class ('%s') does not inherit from TObject.\n"
2085 "\tfgBranchStyle is set to zero requesting by default to use BranchOld.\n"
2086 "\tIf this is intentional use Bronch instead of Branch or BranchOld.", classname);
2088 Fatal(
"BranchOld",
"The requested class ('%s') does not inherit from TObject.\n"
2089 "\tYou can not use BranchOld to store objects of this type.",classname);
2100 const char* rdname =
nullptr;
2101 const char* dname =
nullptr;
2103 char** apointer = (
char**) addobj;
2105 bool delobj =
false;
2115 if (
name[lenName-1] ==
'.') {
2154 if (!strcmp(dname,
"fBits")) {
2157 if (!strcmp(dname,
"fUniqueID")) {
2167 branchname = rdname;
2171 branchname.
Form(
"%s%s",
name, &rdname[1]);
2173 branchname.
Form(
"%s%s",
name, &rdname[0]);
2179 char* pointer = ((
char*) obj) +
offset;
2188 char* cpointer = (
char*) pointer;
2189 char** ppointer = (
char**) cpointer;
2191 if (splitlevel != 2) {
2193 branch1 =
new TBranchClones(branch,branchname, pointer, bufsize);
2198 blist->
Add(branch1);
2206 blist->
Add(branch1);
2223 blist->
Add(branch1);
2247 if (!strcmp(rdi->
GetName(), aindex)) {
2259 leaflist.
Form(
"%s[%s]/%c", &rdname[0],
index, vcode);
2261 Error(
"BranchOld",
"Cannot create branch for rdname: %s code: %d", branchname.
Data(), code);
2268 leaflist.
Form(
"%s/%s", dname,
"C");
2281 branch1 =
new TBranch(branch, bname, *((
void**) pointer), leaflist, bufsize);
2285 blist->
Add(branch1);
2292 leaflist.
Form(
"%s/%c", rdname, vcode);
2294 Error(
"BranchOld",
"Cannot create branch for rdname: %s code: %d", branchname.
Data(), code);
2297 branch1 =
new TBranch(branch, branchname, pointer, leaflist, bufsize);
2299 blist->
Add(branch1);
2308 Warning(
"BranchOld",
"Cannot process member: '%s'", rdname);
2407 return BronchExec(
name, classname, addr,
true, bufsize, splitlevel);
2417 Error(
"Bronch",
"Cannot find class:%s", classname);
2426 char* objptr =
nullptr;
2428 objptr = (
char*)addr;
2430 objptr = *((
char**) addr);
2436 Error(
"Bronch",
"Pointer to TClonesArray is null");
2440 Error(
"Bronch",
"TClonesArray with no class defined in branch: %s",
name);
2444 Error(
"Bronch",
"TClonesArray with no dictionary defined in branch: %s",
name);
2448 if (splitlevel > 0) {
2449 if (hasCustomStreamer)
2450 Warning(
"Bronch",
"Using split mode on a class: %s with a custom Streamer", clones->
GetClass()->
GetName());
2465 if (!inklass && (collProxy->
GetType() == 0)) {
2466 Error(
"Bronch",
"%s with no class defined in branch: %s", classname,
name);
2473 Error(
"Bronch",
"Container with no dictionary defined in branch: %s",
name);
2477 Warning(
"Bronch",
"Using split mode on a class: %s with a custom Streamer", inklass->
GetName());
2488 branch =
new TBranchSTL(
this,
name, collProxy, bufsize, splitlevel );
2500 bool hasCustomStreamer =
false;
2502 Error(
"Bronch",
"Cannot find dictionary for class: %s", classname);
2508 hasCustomStreamer =
true;
2511 if (splitlevel < 0 || ((splitlevel == 0) && hasCustomStreamer && cl->
IsTObject())) {
2539 bool delobj =
false;
2542 objptr = (
char*) cl->
New();
2550 if ((splitlevel > 0) && !cl->
CanSplit()) {
2551 if (splitlevel != 99) {
2552 Warning(
"Bronch",
"%s cannot be split, resetting splitlevel to 0", cl->
GetName());
2566 Error(
"Bronch",
"Cannot build the StreamerInfo for class: %s", cl->
GetName());
2575 if (splitlevel > 0) {
2586 branch->
Unroll(
name, cl, sinfo, objptr, bufsize, splitlevel);
2755 constexpr auto kBufSize = 2000;
2756 char* fname =
new char[kBufSize];
2759 for (
Int_t i = 0; i < 10; ++i) {
2767 strlcpy(fname, file->
GetName(), kBufSize);
2770 char* cunder = strrchr(fname,
'_');
2773 const char* cdot = strrchr(file->
GetName(),
'.');
2775 strlcat(fname, cdot, kBufSize);
2780 strlcat(fname, fcount, kBufSize);
2783 char* cdot = strrchr(fname,
'.');
2786 strlcat(fname, strrchr(file->
GetName(),
'.'), kBufSize);
2790 strlcat(fname, fcount, kBufSize);
2797 Warning(
"ChangeFile",
"file %s already exist, trying with %d underscores", fname, nus+1);
2801 if (newfile ==
nullptr) {
2802 Error(
"Fill",
"Failed to open new file %s, continuing as a memory tree.",fname);
2804 Printf(
"Fill: Switching to new file: %s", fname);
2827 while ((branch = (
TBranch*)nextb())) {
2836 if (newfile) newfile->
Append(obj);
2839 file->TObject::Delete();
2876 TClass* expectedClass =
nullptr;
2883 if (expectedClass && datatype ==
kOther_t && ptrClass ==
nullptr) {
2884 if (isBranchElement) {
2889 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2890 "The class expected (%s) refers to an stl collection and do not have a compiled CollectionProxy. "
2891 "Please generate the dictionary for this class (%s)",
2898 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2899 "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."
2900 "Please generate the dictionary for this class (%s)",
2903 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2904 "This is probably due to a missing dictionary, the original data class for this branch is %s.", branch->
GetName(), expectedClass->
GetName());
2908 if (expectedClass && ptrClass && (branch->
GetMother() == branch)) {
2911 Error(
"SetBranchAddress",
"The address for \"%s\" should be the address of a pointer!", branch->
GetName());
2931 if( expectedClass && ptrClass &&
2932 expectedClass != ptrClass &&
2940 Info(
"SetBranchAddress",
"Matching STL collection (at least according to the SchemaRuleSet when "
2941 "reading a %s into a %s",expectedClass->
GetName(),ptrClass->
GetName());
2948 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());
2959 }
else if (expectedClass && ptrClass && !expectedClass->
InheritsFrom(ptrClass)) {
2981 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());
2982 if (isBranchElement) {
2991 Error(
"SetBranchAddress",
"The pointer type given \"%s\" (%d) does not correspond to the type needed \"%s\" (%d) by the branch: %s",
2998 if (expectedClass) {
2999 Error(
"SetBranchAddress",
"The pointer type given \"%s\" (%d) does not correspond to the type needed \"%s\" by the branch: %s",
3001 if (isBranchElement) {
3017 if (etype == expectedType) {
3032 if (etype == expectedType) {
3044 if (len <= ptrClass->Size()) {
3048 Error(
"SetBranchAddress",
"The pointer type given \"%s\" does not correspond to the type needed \"%s\" (%d) by the branch: %s",
3054 Error(
"SetBranchAddress", writeStlWithoutProxyMsg,
3056 if (isBranchElement) {
3062 if (isBranchElement) {
3063 if (expectedClass) {
3143 bool fastClone =
false;
3175 for (
Int_t i = 0; i < nb; ++i) {
3185 if (thistree !=
this) {
3194 TFile* nfile =
nullptr;
3210 for (
Int_t lndx = 0; lndx < nleaves; ++lndx) {
3216 if (branch && (newcomp > -1)) {
3225 for (
Long64_t i = 0; i < nb; ++i) {
3236 for (
Int_t j = 0; j < nb1; ++j) {
3250 for (
Int_t k = 0; k < nb2; ++k) {
3282 Error(
"CloneTTree",
"TTree has not been cloned\n");
3305 for (
Int_t i = 0; i < nbranches; ++i) {
3312 tree->ResetBranchAddress(br);
3341 Warning(
"CopyAddresses",
"Could not find branch named '%s' in tree named '%s'", branch->
GetName(), tree->GetName());
3347 TObjArray* tleaves = tree->GetListOfLeaves();
3349 std::set<TLeaf*> updatedLeafCount;
3350 for (
Int_t i = 0; i < ntleaves; ++i) {
3366 tree->ResetBranchAddress(tbranch);
3369 bool needAddressReset =
false;
3377 needAddressReset =
true;
3379 needAddressReset = (updatedLeafCount.find(leaf->
GetLeafCount()) != updatedLeafCount.end());
3402 if (br->
IsA() != branch->
IsA()) {
3405 "Branch kind mismatch between input tree '%s' and output tree '%s' for branch '%s': '%s' vs '%s'",
3415 Warning(
"CopyAddresses",
"Could not find branch named '%s' in tree named '%s'", branch->
GetName(), tree->GetName());
3424 ( tree->IsA()->InheritsFrom(
"TNtuple") || tree->IsA()->InheritsFrom(
"TNtupleD") )
3426 tree->ResetBranchAddresses();
3432 enum EOnIndexError { kDrop, kKeep, kBuild };
3434 bool R__HandleIndex(EOnIndexError onIndexError,
TTree *newtree,
TTree *oldtree)
3438 bool withIndex =
true;
3442 switch (onIndexError) {
3466 switch (onIndexError) {
3472 index->SetTree(newtree);
3480 index->SetTree(newtree);
3490 }
else if ( onIndexError == kDrop ) {
3543 bool fastClone = opt.
Contains(
"fast");
3544 bool withIndex = !opt.
Contains(
"noindex");
3545 EOnIndexError onIndexError;
3547 onIndexError = kKeep;
3548 }
else if (opt.
Contains(
"buildindex")) {
3549 onIndexError = kBuild;
3550 }
else if (opt.
Contains(
"dropindex")) {
3551 onIndexError = kDrop;
3553 onIndexError = kBuild;
3559 Ssiz_t cacheSizeEnd = opt.
Index(
" ",cacheSizeLoc+10) - (cacheSizeLoc+10);
3560 TSubString cacheSizeStr( opt(cacheSizeLoc+10,cacheSizeEnd) );
3563 Warning(
"CopyEntries",
"The cachesize option can not be parsed: %s. The default size will be used.",cacheSizeStr.
String().
Data());
3566 const char *munit =
nullptr;
3569 Warning(
"CopyEntries",
"The cachesize option is too large: %s (%g%s max). The default size will be used.",cacheSizeStr.
String().
Data(),
m,munit);
3572 if (
gDebug > 0 && cacheSize != -1)
Info(
"CopyEntries",
"Using Cache size: %lld\n",cacheSize);
3575 Long64_t treeEntries = tree->GetEntriesFast();
3578 }
else if (
nentries > treeEntries) {
3582 if (fastClone && (nentries < 0 || nentries == tree->
GetEntriesFast())) {
3586 if (tree->LoadTree(i) < 0) {
3590 withIndex = R__HandleIndex( onIndexError,
this, tree );
3613 TTree *localtree = tree->GetTree();
3615 if (needCopyAddresses) {
3621 for (
Long64_t ii = 0; ii < tentries; ii++) {
3622 if (localtree->
GetEntry(ii) <= 0) {
3627 if (needCopyAddresses)
3628 tree->ResetBranchAddresses();
3634 if (tree->GetDirectory() && tree->GetDirectory()->GetFile()) {
3635 Warning(
"CopyEntries",
"Skipped file %s\n", tree->GetDirectory()->GetFile()->GetName());
3637 Warning(
"CopyEntries",
"Skipped file number %d\n", tree->GetTreeNumber());
3651 }
else if (
nentries > treeEntries) {
3654 if (needCopyAddresses) {
3660 Int_t treenumber = -1;
3662 if (tree->LoadTree(i) < 0) {
3665 if (treenumber != tree->GetTreeNumber()) {
3667 withIndex = R__HandleIndex( onIndexError,
this, tree );
3669 treenumber = tree->GetTreeNumber();
3671 if (tree->GetEntry(i) <= 0) {
3674 nbytes += this->
Fill();
3676 if (needCopyAddresses)
3677 tree->ResetBranchAddresses();
3755 Error(
"Delete",
"File : %s is not writable, cannot delete Tree:%s", file->
GetName(),
GetName());
3772 Int_t nbytes,objlen,keylen;
3773 while ((leaf = (
TLeaf*)next())) {
3776 for (
Int_t i=0;i<nbaskets;i++) {
3780 if (!branchFile)
continue;
3782 if (nbytes <= 0)
continue;
3783 branchFile->
MakeFree(pos,pos+nbytes-1);
3797 if (dirsav) dirsav->
cd();
3798 if (
gDebug)
Info(
"TTree::Delete",
"Deleting Tree: %s: %d baskets deleted. Total space freed = %d bytes\n",
GetName(),nbask,ntot);
4523 for (
Int_t i = 0; i < nb; ++i) {
4536 for (
Int_t i = 0; i < nleaves; ++i) {
4540 for (
Int_t j = 0; j < nbaskets - 1; ++j) {
4629 for (
Int_t i = 0; i < nbranches; ++i) {
4637 nwrite = branch->
FillImpl(
nullptr);
4639 nwrite = branch->
FillImpl(useIMT ? &imtHelper :
nullptr);
4643 Error(
"Fill",
"Failed filling branch:%s.%s, nbytes=%d, entry=%lld\n"
4644 " This error is symptomatic of a Tree created as a memory-resident Tree\n"
4645 " Instead of doing:\n"
4646 " TTree *T = new TTree(...)\n"
4647 " TFile *f = new TFile(...)\n"
4649 " TFile *f = new TFile(...)\n"
4650 " TTree *T = new TTree(...)\n\n",
4653 Error(
"Fill",
"Failed filling branch:%s.%s, nbytes=%d, entry=%lld",
GetName(), branch->
GetName(), nwrite,
4685 bool autoFlush =
false;
4686 bool autoSave =
false;
4704 if (autoFlush || autoSave) {
4715 Info(
"TTree::Fill",
"OptimizeBaskets called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",
4727 if (zipBytes != 0) {
4729 }
else if (totBytes != 0) {
4764 Info(
"TTree::Fill",
"FlushBaskets() called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",
fEntries,
4772 Info(
"TTree::Fill",
"AutoSave called at entry %lld, fZipBytes=%lld, fSavedBytes=%lld\n",
fEntries,
4784 if (!(
dynamic_cast<TMemFile *
>(file)))
4787 return nerror == 0 ? nbytes : -1;
4795 if (list==
nullptr || branchname ==
nullptr || branchname[0] ==
'\0')
return nullptr;
4799 UInt_t brlen = strlen(branchname);
4807 const char *dim = strchr(
name,
'[');
4812 if (brlen ==
len && strncmp(branchname,
name,
len)==0) {
4816 if ((brlen >=
len) && (branchname[
len] ==
'.')
4817 && strncmp(
name, branchname,
len) == 0) {
4824 if (next)
return next;
4826 const char *dot = strchr((
char*)branchname,
'.');
4828 if (
len==(
size_t)(dot-branchname) &&
4829 strncmp(branchname,
name,dot-branchname)==0 ) {
4860 if (branch)
return branch;
4864 if (branch)
return branch;
4868 while ((branch = (
TBranch*) next())) {
4871 return nestedbranch;
4888 const char *subbranch = strstr(branchname, fe->
GetName());
4889 if (subbranch != branchname) {
4890 subbranch =
nullptr;
4893 subbranch += strlen(fe->
GetName());
4894 if (*subbranch !=
'.') {
4895 subbranch =
nullptr;
4900 std::ostringstream
name;
4930 const char* subsearchname = strstr(searchname,
GetName());
4931 if (subsearchname != searchname) {
4932 subsearchname =
nullptr;
4934 if (subsearchname) {
4935 subsearchname += strlen(
GetName());
4936 if (*subsearchname !=
'.') {
4937 subsearchname =
nullptr;
4940 if (subsearchname[0] == 0) {
4941 subsearchname =
nullptr;
4951 const bool searchnameHasDot = strchr(searchname,
'.') !=
nullptr;
4955 TLeaf* leaf =
nullptr;
4956 while ((leaf = (
TLeaf*) next())) {
4959 if (dim >= 0) leafname.
Remove(dim);
4961 if (leafname == searchname) {
4964 if (subsearchname && leafname == subsearchname) {
4970 dim = leaftitle.
First(
'[');
4971 if (dim >= 0) leaftitle.
Remove(dim);
4973 if (leaftitle == searchname) {
4976 if (subsearchname && leaftitle == subsearchname) {
4979 if (!searchnameHasDot)
4984 dim = longname.
First(
'[');
4985 if (dim>=0) longname.
Remove(dim);
4986 if (longname == searchname) {
4989 if (subsearchname && longname == subsearchname) {
4993 dim = longtitle.
First(
'[');
4994 if (dim>=0) longtitle.
Remove(dim);
4995 if (longtitle == searchname) {
4998 if (subsearchname && longtitle == subsearchname) {
5006 if (strstr(searchname,
".") && !strcmp(searchname, branch->
GetName())) {
5009 if (subsearchname && strstr(subsearchname,
".") && !strcmp(subsearchname, branch->
GetName())) {
5027 subsearchname = strstr(searchname, fe->
GetName());
5028 if (subsearchname != searchname) {
5029 subsearchname =
nullptr;
5031 if (subsearchname) {
5032 subsearchname += strlen(fe->
GetName());
5033 if (*subsearchname !=
'.') {
5034 subsearchname =
nullptr;
5039 if (subsearchname) {
5040 leafname.
Form(
"%s.%s",t->
GetName(),subsearchname);
5042 leafname = searchname;
5090struct BoolRAIIToggle {
5093 BoolRAIIToggle(
bool &val) : m_val(val) { m_val =
true; }
5094 ~BoolRAIIToggle() { m_val =
false; }
5133 if (retval == -1)
return retval;
5168 std::atomic<Int_t> nerrpar(0);
5169 std::atomic<Int_t> nbpar(0);
5170 std::atomic<Int_t> pos(0);
5172 auto mapFunction = [&]() {
5178 Int_t j = pos.fetch_add(1);
5184 std::stringstream ss;
5185 ss << std::this_thread::get_id();
5186 Info(
"FlushBaskets",
"[IMT] Thread %s", ss.str().c_str());
5187 Info(
"FlushBaskets",
"[IMT] Running task for branch #%d: %s", j, branch->GetName());
5190 Int_t nbtask = branch->FlushBaskets();
5192 if (nbtask < 0) { nerrpar++; }
5193 else { nbpar += nbtask; }
5197 pool.
Foreach(mapFunction, nb);
5203 return nerrpar ? -1 : nbpar.load();
5206 for (
Int_t j = 0; j < nb; j++) {
5249 const char* alias = t->
GetAlias(aliasName);
5253 const char* subAliasName = strstr(aliasName, fe->
GetName());
5254 if (subAliasName && (subAliasName[strlen(fe->
GetName())] ==
'.')) {
5274 for (
Int_t i = 0; i < nb; i++) {
5278 if (!strcmp(
b->GetName(),
name)) {
5281 if (!strcmp(
b->GetFullName(),
name)) {
5285 result = R__GetBranch(*(
b->GetListOfBranches()),
name);
5320 for (
Int_t i = 0; i < nleaves; i++) {