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)
829, fAutoSave( -300000000)
830, fAutoFlush(-30000000)
862, fFriendLockStatus(0)
864, fCacheDoAutoInit(
kTRUE)
865, fCacheDoClusterPrefetch(
kFALSE)
867, fIMTEnabled(
ROOT::IsImplicitMTEnabled())
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());
1054 Error(
"AddBranchToCache",
"Could not load a tree");
1063 Error(
"AddBranchToCache",
"No tree is available. Branch was not added to the cache");
1069 Error(
"AddBranchToCache",
"No file is available. Branch was not added to the cache");
1074 Error(
"AddBranchToCache",
"No cache is available, branch not added");
1077 return tc->
AddBranch(bname,subbranches);
1093 Error(
"AddBranchToCache",
"Could not load a tree");
1101 Error(
"AddBranchToCache",
"Error adding branch");
1106 Error(
"AddBranchToCache",
"No tree is available. Branch was not added to the cache");
1112 Error(
"AddBranchToCache",
"No file is available. Branch was not added to the cache");
1117 Error(
"AddBranchToCache",
"No cache is available, branch not added");
1137 Error(
"DropBranchFromCache",
"Could not load a tree");
1146 Error(
"DropBranchFromCache",
"No tree is available. Branch was not dropped from the cache");
1152 Error(
"DropBranchFromCache",
"No file is available. Branch was not dropped from the cache");
1157 Error(
"DropBranchFromCache",
"No cache is available, branch not dropped");
1176 Error(
"DropBranchFromCache",
"Could not load a tree");
1184 Error(
"DropBranchFromCache",
"Error dropping branch");
1189 Error(
"DropBranchFromCache",
"No tree is available. Branch was not dropped from the cache");
1195 Error(
"DropBranchFromCache",
"No file is available. Branch was not dropped from the cache");
1200 Error(
"DropBranchFromCache",
"No cache is available, branch not dropped");
1235 const auto friendHasValidIndex = [&] {
1240 if ((isMainReshuffled || isFriendReshuffled) && !friendHasValidIndex) {
1241 const auto reshuffledTreeName = isMainReshuffled ? mainTree.
GetName() : friendTree.
GetName();
1242 const auto msg =
"Tree '%s' has the kEntriesReshuffled bit set, and cannot be used as friend nor can be added as "
1243 "a friend unless the main tree has a TTreeIndex on the friend tree '%s'. You can also unset the "
1244 "bit manually if you know what you are doing.";
1245 Error(
"AddFriend", msg, reshuffledTreeName, friendTree.
GetName());
1330 bool canAddFriend =
true;
1334 Warning(
"AddFriend",
"FriendElement %s in file %s has less entries %lld than its parent Tree: %lld", treename,
1338 Error(
"AddFriend",
"Cannot find tree '%s' in file '%s', friend not added", treename, filename);
1339 canAddFriend =
false;
1364 bool canAddFriend =
true;
1368 Warning(
"AddFriend",
"FriendElement %s in file %s has less entries %lld than its parent tree: %lld", treename,
1372 Error(
"AddFriend",
"Cannot find tree '%s' in file '%s', friend not added", treename,
file->GetName());
1373 canAddFriend =
false;
1399 Warning(
"AddFriend",
"FriendElement '%s' in file '%s' has less entries %lld than its parent tree: %lld",
1406 tree->RemoveExternalFriend(fe);
1499 if (opt.
Contains(
"flushbaskets")) {
1500 if (
gDebug > 0)
Info(
"AutoSave",
"calling FlushBaskets \n");
1519 if (
file)
file->WriteStreamerInfo();
1533 const char* writeStlWithoutProxyMsg =
"The class requested (%s) for the branch \"%s\""
1534 " is an instance of an stl collection and does not have a compiled CollectionProxy."
1535 " Please generate the dictionary for this collection (%s) to avoid to write corrupted data.";
1549 Error(
"Branch", writeStlWithoutProxyMsg,
1553 return Branch(branchname, classname, (
void*) addobj, bufsize, splitlevel);
1556 void** addr = (
void**) addobj;
1560 if (ptrClass && claim) {
1567 Error(
"Branch",
"The class requested (%s) for \"%s\" is different from the type of the pointer passed (%s)",
1570 }
else if (actualClass && (claim != actualClass) && !actualClass->
InheritsFrom(claim)) {
1575 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s",
1581 Error(
"Branch", writeStlWithoutProxyMsg,
1585 return Branch(branchname, classname, (
void*) addobj, bufsize, splitlevel);
1595 Error(
"Branch",
"The pointer specified for %s is not of a class known to ROOT", branchname);
1599 void** addr = (
void**) addobj;
1600 if (addr && *addr) {
1603 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",
1604 branchname, ptrClass->
GetName());
1605 actualClass = ptrClass;
1606 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1607 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());
1611 actualClass = ptrClass;
1614 Error(
"Branch", writeStlWithoutProxyMsg,
1618 return Branch(branchname, actualClass->
GetName(), (
void*) addobj, bufsize, splitlevel);
1630 Error(
"Branch", writeStlWithoutProxyMsg,
1633 }
else if (claim == 0) {
1634 Error(
"Branch",
"The pointer specified for %s is not of a class known to ROOT and %s is not a known class", branchname, classname);
1641 Error(
"Branch",
"Reference interface requires a valid object (for branch: %s)!", branchname);
1645 if (ptrClass && claim) {
1652 Error(
"Branch",
"The class requested (%s) for \"%s\" is different from the type of the object passed (%s)",
1655 }
else if (actualClass && (claim != actualClass) && !actualClass->
InheritsFrom(claim)) {
1660 Error(
"Branch",
"The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s",
1666 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",
1667 branchname, ptrClass->
GetName());
1668 actualClass = ptrClass;
1669 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1670 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());
1674 Error(
"Branch", writeStlWithoutProxyMsg,
1689 Error(
"Branch",
"The pointer specified for %s is not of a class or type known to ROOT", branchname);
1692 return Branch(branchname,addobj,varname.
Data(),bufsize);
1698 Error(
"Branch",
"Reference interface requires a valid object (for branch: %s)!", branchname);
1703 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",
1704 branchname, ptrClass->
GetName());
1705 actualClass = ptrClass;
1706 }
else if ((ptrClass != actualClass) && !actualClass->
InheritsFrom(ptrClass)) {
1707 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());
1711 Error(
"Branch", writeStlWithoutProxyMsg,
1726 "The inner type of the std::array passed specified for %s is not of a class or type known to ROOT",
1731 return Branch(branchname, addobj, varname.
Data(), bufsize);
1832 Error(
"Branch",
"Cannot call this constructor for a TClonesArray");
1838 while ((obj = next())) {
1846 Branch(col, bufsize, splitlevel - 1, branchname);
1848 if (nch && (
name[nch-1] ==
'_')) {
1857 if (splitlevel > 99) {
1876 if (ob->IsA() != TFolder::Class()) {
1883 char* curname =
new char[1000];
1885 while ((obj = next())) {
1887 if (obj->IsA() == TFolder::Class()) {
1888 Branch(curname, bufsize, splitlevel - 1);
1891 for (
Int_t i = 0; i < 1000; ++i) {
1892 if (curname[i] == 0) {
1895 if (curname[i] ==
'/') {
1902 strlcat(curname, occur,1000);
2013 return Bronch(
name, classname, addobj, bufsize, splitlevel);
2015 if (splitlevel < 0) {
2018 return BranchOld(
name, classname, addobj, bufsize, splitlevel);
2067 Error(
"BranchOld",
"Cannot find class: '%s'", classname);
2072 Fatal(
"BranchOld",
"The requested class ('%s') does not inherit from TObject.\n"
2073 "\tfgBranchStyle is set to zero requesting by default to use BranchOld.\n"
2074 "\tIf this is intentional use Bronch instead of Branch or BranchOld.", classname);
2076 Fatal(
"BranchOld",
"The requested class ('%s') does not inherit from TObject.\n"
2077 "\tYou can not use BranchOld to store objects of this type.",classname);
2088 const char* rdname = 0;
2089 const char* dname = 0;
2091 char** apointer = (
char**) addobj;
2103 if (
name[lenName-1] ==
'.') {
2142 if (!strcmp(dname,
"fBits")) {
2145 if (!strcmp(dname,
"fUniqueID")) {
2155 branchname = rdname;
2159 branchname.
Form(
"%s%s",
name, &rdname[1]);
2161 branchname.
Form(
"%s%s",
name, &rdname[0]);
2167 char* pointer = ((
char*) obj) + offset;
2174 if (clobj && clobj->
InheritsFrom(TClonesArray::Class())) {
2176 char* cpointer = (
char*) pointer;
2177 char** ppointer = (
char**) cpointer;
2179 if (splitlevel != 2) {
2181 branch1 =
new TBranchClones(branch,branchname, pointer, bufsize);
2186 blist->
Add(branch1);
2194 blist->
Add(branch1);
2211 blist->
Add(branch1);
2232 if (!strcmp(rdi->
GetName(), index)) {
2235 if (!strcmp(rdi->
GetName(), aindex)) {
2247 leaflist.
Form(
"%s[%s]/%c", &rdname[0], index, vcode);
2249 Error(
"BranchOld",
"Cannot create branch for rdname: %s code: %d", branchname.
Data(), code);
2256 leaflist.
Form(
"%s/%s", dname,
"C");
2269 branch1 =
new TBranch(branch, bname, *((
void**) pointer), leaflist, bufsize);
2273 blist->
Add(branch1);
2280 leaflist.
Form(
"%s/%c", rdname, vcode);
2282 Error(
"BranchOld",
"Cannot create branch for rdname: %s code: %d", branchname.
Data(), code);
2285 branch1 =
new TBranch(branch, branchname, pointer, leaflist, bufsize);
2287 blist->
Add(branch1);
2296 Warning(
"BranchOld",
"Cannot process member: '%s'", rdname);
2405 Error(
"Bronch",
"Cannot find class:%s", classname);
2416 objptr = (
char*)addr;
2418 objptr = *((
char**) addr);
2421 if (cl == TClonesArray::Class()) {
2424 Error(
"Bronch",
"Pointer to TClonesArray is null");
2428 Error(
"Bronch",
"TClonesArray with no class defined in branch: %s",
name);
2432 Error(
"Bronch",
"TClonesArray with no dictionary defined in branch: %s",
name);
2436 if (splitlevel > 0) {
2437 if (hasCustomStreamer)
2438 Warning(
"Bronch",
"Using split mode on a class: %s with a custom Streamer", clones->
GetClass()->
GetName());
2453 if (!inklass && (collProxy->
GetType() == 0)) {
2454 Error(
"Bronch",
"%s with no class defined in branch: %s", classname,
name);
2461 Error(
"Bronch",
"Container with no dictionary defined in branch: %s",
name);
2465 Warning(
"Bronch",
"Using split mode on a class: %s with a custom Streamer", inklass->
GetName());
2476 branch =
new TBranchSTL(
this,
name, collProxy, bufsize, splitlevel );
2490 Error(
"Bronch",
"Cannot find dictionary for class: %s", classname);
2496 hasCustomStreamer =
kTRUE;
2499 if (splitlevel < 0 || ((splitlevel == 0) && hasCustomStreamer && cl->
IsTObject())) {
2505 if (cl == TClonesArray::Class()) {
2530 objptr = (
char*) cl->
New();
2538 if ((splitlevel > 0) && !cl->
CanSplit()) {
2539 if (splitlevel != 99) {
2540 Warning(
"Bronch",
"%s cannot be split, resetting splitlevel to 0", cl->
GetName());
2554 Error(
"Bronch",
"Cannot build the StreamerInfo for class: %s", cl->
GetName());
2563 if (splitlevel > 0) {
2574 branch->
Unroll(
name, cl, sinfo, objptr, bufsize, splitlevel);
2743 constexpr auto kBufSize = 2000;
2744 char* fname =
new char[kBufSize];
2747 for (
Int_t i = 0; i < 10; ++i) {
2755 strlcpy(fname,
file->GetName(), kBufSize);
2758 char* cunder = strrchr(fname,
'_');
2761 const char* cdot = strrchr(
file->GetName(),
'.');
2763 strlcat(fname, cdot, kBufSize);
2768 strlcat(fname, fcount, kBufSize);
2771 char* cdot = strrchr(fname,
'.');
2774 strlcat(fname, strrchr(
file->GetName(),
'.'), kBufSize);
2778 strlcat(fname, fcount, kBufSize);
2785 Warning(
"ChangeFile",
"file %s already exist, trying with %d underscores", fname, nus+1);
2787 Int_t compress =
file->GetCompressionSettings();
2790 Error(
"Fill",
"Failed to open new file %s, continuing as a memory tree.",fname);
2792 Printf(
"Fill: Switching to new file: %s", fname);
2798 while ((obj =
file->GetList()->First())) {
2815 while ((branch = (
TBranch*)nextb())) {
2824 if (newfile) newfile->
Append(obj);
2827 file->TObject::Delete();
2864 TClass* expectedClass = 0;
2870 bool isBranchElement = branch->
InheritsFrom( TBranchElement::Class() );
2871 if (expectedClass && datatype ==
kOther_t && ptrClass == 0) {
2872 if (isBranchElement) {
2877 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2878 "The class expected (%s) refers to an stl collection and do not have a compiled CollectionProxy. "
2879 "Please generate the dictionary for this class (%s)",
2886 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2887 "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."
2888 "Please generate the dictionary for this class (%s)",
2891 Error(
"SetBranchAddress",
"Unable to determine the type given for the address for \"%s\". "
2892 "This is probably due to a missing dictionary, the original data class for this branch is %s.", branch->
GetName(), expectedClass->
GetName());
2896 if (expectedClass && ptrClass && (branch->
GetMother() == branch)) {
2899 Error(
"SetBranchAddress",
"The address for \"%s\" should be the address of a pointer!", branch->
GetName());
2919 if( expectedClass && ptrClass &&
2920 expectedClass != ptrClass &&
2928 Info(
"SetBranchAddress",
"Matching STL collection (at least according to the SchemaRuleSet when "
2929 "reading a %s into a %s",expectedClass->
GetName(),ptrClass->
GetName());
2936 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());
2947 }
else if (expectedClass && ptrClass && !expectedClass->
InheritsFrom(ptrClass)) {
2969 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());
2970 if (isBranchElement) {
2979 Error(
"SetBranchAddress",
"The pointer type given \"%s\" (%d) does not correspond to the type needed \"%s\" (%d) by the branch: %s",
2986 if (expectedClass) {
2987 Error(
"SetBranchAddress",
"The pointer type given \"%s\" (%d) does not correspond to the type needed \"%s\" by the branch: %s",
2989 if (isBranchElement) {
3005 if (etype == expectedType) {
3020 if (etype == expectedType) {
3032 if (len <= ptrClass->Size()) {
3036 Error(
"SetBranchAddress",
"The pointer type given \"%s\" does not correspond to the type needed \"%s\" (%d) by the branch: %s",
3042 Error(
"SetBranchAddress", writeStlWithoutProxyMsg,
3044 if (isBranchElement) {
3050 if (isBranchElement) {
3051 if (expectedClass) {
3160 for (
Int_t i = 0; i < nb; ++i) {
3170 if (thistree !=
this) {
3195 for (
Int_t lndx = 0; lndx < nleaves; ++lndx) {
3201 if (branch && (newcomp > -1)) {
3210 for (
Long64_t i = 0; i < nb; ++i) {
3221 for (
Int_t j = 0; j < nb1; ++j) {
3235 for (
Int_t k = 0; k < nb2; ++k) {
3267 Error(
"CloneTTree",
"TTree has not been cloned\n");
3290 for (
Int_t i = 0; i < nbranches; ++i) {
3297 tree->ResetBranchAddress(br);
3301 if (branch->IsA() == TBranch::Class()) {
3326 Warning(
"CopyAddresses",
"Could not find branch named '%s' in tree named '%s'", branch->
GetName(),
tree->GetName());
3334 std::set<TLeaf*> updatedLeafCount;
3335 for (
Int_t i = 0; i < ntleaves; ++i) {
3351 tree->ResetBranchAddress(tbranch);
3354 bool needAddressReset =
false;
3362 needAddressReset =
true;
3364 needAddressReset = (updatedLeafCount.find(leaf->
GetLeafCount()) != updatedLeafCount.end());
3368 if (leaf->IsA() == TLeafElement::Class() && mother)
3387 if (br->IsA() != branch->IsA()) {
3390 "Branch kind mismatch between input tree '%s' and output tree '%s' for branch '%s': '%s' vs '%s'",
3400 Warning(
"CopyAddresses",
"Could not find branch named '%s' in tree named '%s'", branch->
GetName(),
tree->GetName());
3409 (
tree->IsA()->InheritsFrom(
"TNtuple") ||
tree->IsA()->InheritsFrom(
"TNtupleD") )
3411 tree->ResetBranchAddresses();
3417 enum EOnIndexError { kDrop, kKeep, kBuild };
3419 static Bool_t R__HandleIndex(EOnIndexError onIndexError,
TTree *newtree,
TTree *oldtree)
3427 switch (onIndexError) {
3451 switch (onIndexError) {
3475 }
else if ( onIndexError == kDrop ) {
3530 EOnIndexError onIndexError;
3532 onIndexError = kKeep;
3533 }
else if (opt.
Contains(
"buildindex")) {
3534 onIndexError = kBuild;
3535 }
else if (opt.
Contains(
"dropindex")) {
3536 onIndexError = kDrop;
3538 onIndexError = kBuild;
3541 Int_t cacheSize = -1;
3544 Ssiz_t cacheSizeEnd = opt.
Index(
" ",cacheSizeLoc+10) - (cacheSizeLoc+10);
3545 TSubString cacheSizeStr( opt(cacheSizeLoc+10,cacheSizeEnd) );
3548 Warning(
"CopyEntries",
"The cachesize option can not be parsed: %s. The default size will be used.",cacheSizeStr.
String().
Data());
3551 const char *munit =
nullptr;
3554 Warning(
"CopyEntries",
"The cachesize option is too large: %s (%g%s max). The default size will be used.",cacheSizeStr.
String().
Data(),
m,munit);
3557 if (
gDebug > 0 && cacheSize != -1)
Info(
"CopyEntries",
"Using Cache size: %d\n",cacheSize);
3563 }
else if (
nentries > treeEntries) {
3567 if (fastClone && (nentries < 0 || nentries == tree->
GetEntriesFast())) {
3571 if (
tree->LoadTree(i) < 0) {
3575 withIndex = R__HandleIndex( onIndexError,
this,
tree );
3600 if (needCopyAddresses) {
3606 for (
Long64_t ii = 0; ii < tentries; ii++) {
3607 if (localtree->
GetEntry(ii) <= 0) {
3612 if (needCopyAddresses)
3613 tree->ResetBranchAddresses();
3619 if (
tree->GetDirectory() &&
tree->GetDirectory()->GetFile()) {
3620 Warning(
"CopyEntries",
"Skipped file %s\n",
tree->GetDirectory()->GetFile()->GetName());
3622 Warning(
"CopyEntries",
"Skipped file number %d\n",
tree->GetTreeNumber());
3636 }
else if (
nentries > treeEntries) {
3639 if (needCopyAddresses) {
3645 Int_t treenumber = -1;
3647 if (
tree->LoadTree(i) < 0) {
3650 if (treenumber !=
tree->GetTreeNumber()) {
3652 withIndex = R__HandleIndex( onIndexError,
this,
tree );
3654 treenumber =
tree->GetTreeNumber();
3656 if (
tree->GetEntry(i) <= 0) {
3659 nbytes += this->
Fill();
3661 if (needCopyAddresses)
3662 tree->ResetBranchAddresses();
3738 if (
file && !strcmp(option,
"all")) {
3739 if (!
file->IsWritable()) {
3740 Error(
"Delete",
"File : %s is not writable, cannot delete Tree:%s",
file->GetName(),
GetName());
3757 Int_t nbytes,objlen,keylen;
3758 while ((leaf = (
TLeaf*)next())) {
3761 for (
Int_t i=0;i<nbaskets;i++) {
3765 if (!branchFile)
continue;
3767 if (nbytes <= 0)
continue;
3768 branchFile->
MakeFree(pos,pos+nbytes-1);
3782 if (dirsav) dirsav->
cd();
3783 if (
gDebug)
Info(
"TTree::Delete",
"Deleting Tree: %s: %d baskets deleted. Total space freed = %d bytes\n",
GetName(),nbask,ntot);
4509 for (
Int_t i = 0; i < nb; ++i) {
4523 for (
Int_t i = 0; i < nleaves; ++i) {
4527 for (
Int_t j = 0; j < nbaskets - 1; ++j) {
4616 for (
Int_t i = 0; i < nbranches; ++i) {
4624 nwrite = branch->
FillImpl(
nullptr);
4626 nwrite = branch->
FillImpl(useIMT ? &imtHelper :
nullptr);
4630 Error(
"Fill",
"Failed filling branch:%s.%s, nbytes=%d, entry=%lld\n"
4631 " This error is symptomatic of a Tree created as a memory-resident Tree\n"
4632 " Instead of doing:\n"
4633 " TTree *T = new TTree(...)\n"
4634 " TFile *f = new TFile(...)\n"
4636 " TFile *f = new TFile(...)\n"
4637 " TTree *T = new TTree(...)\n\n",
4640 Error(
"Fill",
"Failed filling branch:%s.%s, nbytes=%d, entry=%lld",
GetName(), branch->
GetName(), nwrite,
4672 bool autoFlush =
false;
4673 bool autoSave =
false;
4691 if (autoFlush || autoSave) {
4702 Info(
"TTree::Fill",
"OptimizeBaskets called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",
4714 if (zipBytes != 0) {
4716 }
else if (totBytes != 0) {
4720 TTree::Class()->WriteBuffer(
b, (
TTree *)
this);
4751 Info(
"TTree::Fill",
"FlushBaskets() called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",
fEntries,
4759 Info(
"TTree::Fill",
"AutoSave called at entry %lld, fZipBytes=%lld, fSavedBytes=%lld\n",
fEntries,
4774 return nerror == 0 ? nbytes : -1;
4782 if (list==0 || branchname == 0 || branchname[0] ==
'\0')
return 0;
4786 UInt_t brlen = strlen(branchname);
4788 for(
Int_t index = 0; index < nbranches; ++index) {
4793 if (len &&
name[len-1]==
']') {
4794 const char *dim = strchr(
name,
'[');
4799 if (brlen == len && strncmp(branchname,
name,len)==0) {
4803 if ((brlen >= len) && (branchname[len] ==
'.')
4804 && strncmp(
name, branchname, len) == 0) {
4811 if (next)
return next;
4813 const char *dot = strchr((
char*)branchname,
'.');
4815 if (len==(
size_t)(dot-branchname) &&
4816 strncmp(branchname,
name,dot-branchname)==0 ) {
4844 if (branch)
return branch;
4848 if (branch)
return branch;
4852 while ((branch = (
TBranch*) next())) {
4855 return nestedbranch;
4872 const char *subbranch = strstr(branchname, fe->
GetName());
4873 if (subbranch != branchname) {
4877 subbranch += strlen(fe->
GetName());
4878 if (*subbranch !=
'.') {
4884 std::ostringstream
name;
4911 char* subsearchname = (
char*) strstr(searchname,
GetName());
4912 if (subsearchname != searchname) {
4915 if (subsearchname) {
4916 subsearchname += strlen(
GetName());
4917 if (*subsearchname !=
'.') {
4921 if (subsearchname[0]==0) {
4932 const bool searchnameHasDot = strchr(searchname,
'.') !=
nullptr;
4937 while ((leaf = (
TLeaf*) next())) {
4940 if (dim >= 0) leafname.
Remove(dim);
4942 if (leafname == searchname) {
4945 if (subsearchname && leafname == subsearchname) {
4951 dim = leaftitle.
First(
'[');
4952 if (dim >= 0) leaftitle.
Remove(dim);
4954 if (leaftitle == searchname) {
4957 if (subsearchname && leaftitle == subsearchname) {
4960 if (!searchnameHasDot)
4965 dim = longname.
First(
'[');
4966 if (dim>=0) longname.
Remove(dim);
4967 if (longname == searchname) {
4970 if (subsearchname && longname == subsearchname) {
4974 dim = longtitle.
First(
'[');
4975 if (dim>=0) longtitle.
Remove(dim);
4976 if (longtitle == searchname) {
4979 if (subsearchname && longtitle == subsearchname) {
4987 if (strstr(searchname,
".") && !strcmp(searchname, branch->
GetName())) {
4990 if (subsearchname && strstr(subsearchname,
".") && !strcmp(subsearchname, branch->
GetName())) {
5008 subsearchname = (
char*) strstr(searchname, fe->
GetName());
5009 if (subsearchname != searchname) {
5012 if (subsearchname) {
5013 subsearchname += strlen(fe->
GetName());
5014 if (*subsearchname !=
'.') {
5020 if (subsearchname) {
5021 leafname.
Form(
"%s.%s",t->
GetName(),subsearchname);
5023 leafname = searchname;
5065 return fPlayer->
Fit(funcname, varexp, selection, option, goption,
nentries, firstentry);
5071struct BoolRAIIToggle {
5074 BoolRAIIToggle(
Bool_t &val) : m_val(val) { m_val =
true; }
5075 ~BoolRAIIToggle() { m_val =
false; }
5114 if (retval == -1)
return retval;
5149 std::atomic<Int_t> nerrpar(0);
5150 std::atomic<Int_t> nbpar(0);
5151 std::atomic<Int_t> pos(0);
5153 auto mapFunction = [&]() {
5159 Int_t j = pos.fetch_add(1);
5165 std::stringstream ss;
5166 ss << std::this_thread::get_id();
5167 Info(
"FlushBaskets",
"[IMT] Thread %s", ss.str().c_str());
5168 Info(
"FlushBaskets",
"[IMT] Running task for branch #%d: %s", j, branch->GetName());
5171 Int_t nbtask = branch->FlushBaskets();
5173 if (nbtask < 0) { nerrpar++; }
5174 else { nbpar += nbtask; }
5178 pool.
Foreach(mapFunction, nb);
5184 return nerrpar ? -1 : nbpar.load();
5187 for (
Int_t j = 0; j < nb; j++) {
5230 const char* alias = t->
GetAlias(aliasName);
5234 const char* subAliasName = strstr(aliasName, fe->
GetName());
5235 if (subAliasName && (subAliasName[strlen(fe->
GetName())] ==
'.')) {
5255 for (
Int_t i = 0; i < nb; i++) {
5259 if (!strcmp(
b->GetName(),
name)) {
5262 if (!strcmp(
b->GetFullName(),
name)) {
5266 result = R__GetBranch(*(
b->GetListOfBranches()),
name);
5278 if (
name == 0)
return 0;
5300 for (
Int_t i = 0; i < nleaves; i++) {
5337 char* subname = (
char*) strstr(
name, fe->
GetName());
5338 if (subname !=
name) {
5343 if (*subname !=
'.') {