119 std::istringstream iss(str);
121 return iss >> std::noskipws >> number && iss.eof();
185 const std::vector<std::string>& aliases)
227 if(savedir) savedir->
cd();
232 Warning(
"TTreeFormula",
"Too many items in expression:%s",expression);
242 if (!leafc)
continue;
285 for(k0 = 0; k0 <
fNcodes; k0++) {
290 Error(
"TTreeFormula",
291 "Index %d for dimension #%d in %s is too high (max is %d)",
294 if(savedir) savedir->
cd();
306 if (
fBranches.FindObject(branch)) branch =
nullptr;
322 if (treenumber !=
fTree->GetTreeNumber()) {
323 if (readentry >= 0) {
324 fTree->LoadTree(readentry);
328 if (readentry >= 0) {
329 fTree->LoadTree(readentry);
335 if(savedir) savedir->
cd();
345 if (
fManager->fFormulas.GetLast()<0) {
357 for (
int j=0; j<
fNcodes; j++) {
385 bool scalarindex =
false;
391 switch (index_multiplicity) {
409 fManager->UpdateUsedSize(virt_dim, vsize);
422 const char * current;
431 if (current[0] !=
'[') current--;
434 scanindex = sscanf(current,
"%d",&
size);
438 if (scanindex==0)
size = -1;
447 current = (
char*)strstr( current,
"[" );
461 return (
size==-1) ? 1 : 0;
469 bool useCollectionObject) {
502 if (maininfo==0 || maininfo==leafinfo || 1) {
508 delete currentinfo->
fNext;
533 }
else if (
c &&
c->GetReferenceProxy() &&
c->GetReferenceProxy()->HasCounter() ) {
564 }
while (current<ndim);
601 Int_t numberOfVarDim = 0;
609 const char *tname = sname.
Data();
610 char *leaf_dim = (
char*)strstr( tname,
"[" );
613 char *branch_dim = (
char*)strstr(bname,
"[");
614 if (branch_dim) branch_dim++;
616 bool isString =
false;
626 if (!branch_dim || strncmp(branch_dim,leaf_dim,strlen(branch_dim))) {
629 }
else if (branch_dim && strncmp(branch_dim,leaf_dim,strlen(branch_dim))==0
630 && strlen(leaf_dim)>strlen(branch_dim)
631 && (leaf_dim+strlen(branch_dim))[0]==
'[') {
650 "Noticed an incorrect in-memory TBranchElement object (%s).\nIt has a BranchCount2 but no BranchCount!\nThe result might be incorrect!",
652 return numberOfVarDim;
658 "Already in kDataMember mode when handling multiple variable dimensions");
666 return numberOfVarDim;
679 static const char *altfunc =
"Alt$(";
680 static const char *minfunc =
"MinIf$(";
681 static const char *maxfunc =
"MaxIf$(";
685 if ( strncmp(expression,altfunc,strlen(altfunc))==0
686 && expression[strlen(expression)-1]==
')' ) {
688 start = strlen(altfunc);
690 if ( strncmp(expression,maxfunc,strlen(maxfunc))==0
691 && expression[strlen(expression)-1]==
')' ) {
693 start = strlen(maxfunc);
695 if ( strncmp(expression,minfunc,strlen(minfunc))==0
696 && expression[strlen(expression)-1]==
')' ) {
698 start = strlen(minfunc);
708 for(
unsigned int i=
start;i<strlen(expression);++i) {
709 switch (expression[i]) {
710 case '(': paran++;
break;
711 case ')': paran--;
break;
712 case '"': instr = instr ? 0 : 1;
break;
713 case '[': brack++;
break;
714 case ']': brack--;
break;
716 if (expression[i]==
',' && paran==0 && instr==0 && brack==0) {
718 part2 = full( i+1, full.Length() -1 - (i+1) );
730 Error(
"DefineAlternate",
"The 2nd arguments in %s can not be an array (%s,%d)!",
739 Error(
"DefineAlternate",
740 "The 2nd arguments in %s has to return the same type as the 1st argument (string)!",
746 Error(
"DefineAlternate",
747 "The 2nd arguments in %s has to return the same type as the 1st argument (numerical type)!",
756 Error(
"DefineAlternate",
757 "The arguments of %s can not be strings!",
788 Int_t numberOfVarDim = 0;
791 char scratch[
kMaxLen]; scratch[0] =
'\0';
792 char work[
kMaxLen]; work[0] =
'\0';
794 const char *right = subExpression;
799 if (readentry < 0) readentry=0;
801 bool useLeafReferenceObject =
false;
811 if ( br->
GetInfo() ==
nullptr ) {
812 Error(
"ParseWithLeaf",
"Missing StreamerInfo for %s. We will be unable to read!",
824 Error(
"ParseWithLeaf",
"Missing StreamerInfo for %s."
825 " We will be unable to read!",
830 Error(
"ParseWithLeaf",
"Address not set when the type of the branch is negative for for %s. We will be unable to read!", mom->
GetName());
843 const char* alias =
nullptr;
846 if (!alias && realtree!=
fTree) {
851 Int_t leafname_len = 0;
853 leafname_len = strlen(alias) + strlen(leaf->
GetName()) + 1;
857 leafname_len = strlen(leaf->
GetName());
860 if (leafname_len >
kMaxLen - 1) {
861 Error(
"TTreeFormula",
862 "Length of leafname (%d) exceeds maximum allowed by the buffer (%d), formula will be truncated.",
868 TTree *tleaf = realtree;
875 if (mother_name[strlen(mother_name)-1]!=
'.') {
876 br_extended_name = mother_name;
877 br_extended_name.
Append(
'.');
882 if (dim >= 0) br_extended_name.
Remove(dim);
886 fLeaves.AddAtAndExpand(leaf,code);
902 bool unwindCollection =
false;
970 "Missing TStreamerElement in object in TClonesArray section");
981 maininfo = clonesinfo;
1000 maininfo->
fNext = previnfo;
1001 unwindCollection =
true;
1003 }
else if (branchEl->
GetType()==41) {
1008 Warning(
"ParseWithLeaf",
"Missing TStreamerElement in object in Collection section");
1014 if ( count->
GetID() >= 0 ) {
1033 maininfo = collectioninfo;
1052 maininfo->
fNext = previnfo;
1053 unwindCollection =
true;
1055 }
else if ( branchEl->
GetType()==3) {
1057 if (useLeafCollectionObject) {
1062 numberOfVarDim +=
RegisterDimensions(code,clonesinfo,maininfo,useLeafCollectionObject);
1065 maininfo = clonesinfo;
1066 previnfo = maininfo;
1068 }
else if (!useLeafCollectionObject && branchEl->
GetType()==4) {
1071 if (useLeafCollectionObject) {
1076 numberOfVarDim +=
RegisterDimensions(code,collectioninfo,maininfo,useLeafCollectionObject);
1079 maininfo = collectioninfo;
1080 previnfo = maininfo;
1084 if (useLeafCollectionObject) {
1087 maininfo = collectioninfo;
1088 previnfo = collectioninfo;
1095 maininfo = collectioninfo;
1096 previnfo = collectioninfo;
1106 previnfo->
fNext = multi;
1109 previnfo = multi->
fNext;
1117 previnfo = previnfo->
fNext;
1123 }
else if (strlen(right)==0 && cl && element &&
final) {
1126 if (!useLeafCollectionObject
1137 maininfo = collectioninfo;
1138 previnfo = collectioninfo;
1147 previnfo->
fNext = multi;
1150 previnfo = multi->
fNext;
1157 previnfo = previnfo->
fNext;
1160 }
else if (!useLeafCollectionObject
1176 collectioninfo->
fNext =
1179 maininfo = collectioninfo;
1180 previnfo = maininfo->
fNext;
1182 }
else if (!useLeafCollectionObject
1193 previnfo = maininfo;
1198 if ( useLeafCollectionObject || fullExpression[0] ==
'@' || fullExpression[strlen(scratch)] ==
'@' ) {
1199 useLeafReferenceObject =
true;
1210 Error(
"ParseWithLeaf",
"Branch could not be loaded:%d", res);
1220 Error(
"ParseWithLeaf",
"Failed to access class type of reference target (%s)",element->
GetName());
1227 if (subExpression && subExpression[0]) {
1228 Error(
"ParseWithLeaf",
"Found a numerical leaf but the name has trailing characters: \"%s\"", subExpression);
1237 if (unwindCollection) {
1240 R__ASSERT(numberOfVarDim==1 && maininfo);
1247 previnfo->
fNext = multi;
1250 previnfo = multi->
fNext;
1257 previnfo = previnfo->
fNext;
1265 previnfo->
fNext = multi;
1268 previnfo = multi->
fNext;
1277 Int_t nchname = strlen(right);
1292 Error(
"ParseWithLeaf",
"%s does not inherit from %s. Casting not possible!",
1298 if (maininfo==
nullptr) {
1299 maininfo = leafinfo;
1301 if (previnfo==
nullptr) {
1302 previnfo = leafinfo;
1304 previnfo->
fNext = leafinfo;
1305 previnfo = leafinfo;
1310 castqueue.
AddAt(
nullptr,paran_level);
1314 bool prevUseCollectionObject = useLeafCollectionObject;
1315 bool useCollectionObject = useLeafCollectionObject;
1316 bool useReferenceObject = useLeafReferenceObject;
1317 bool prevUseReferenceObject = useLeafReferenceObject;
1318 for (i=0, current = &(work[0]); i<=nchname;i++ ) {
1320 if (right[i] ==
'(') {
1323 *current++ = right[i++];
1324 }
while(right[i]!=
')' && right[i]);
1325 *current++ = right[i];
1327 char *params = strchr(work,
'(');
1329 *params = 0; params++;
1330 }
else params = (
char *)
")";
1332 Error(
"ParseWithLeaf",
"Can not call '%s' with a class",work);
1336 Error(
"ParseWithLeaf",
"Class probably unavailable:%s",cl->
GetName());
1347 Error(
"ParseWithLeaf",
"Branch could not be loaded:%d", lres);
1367 previnfo = clonesinfo;
1368 maininfo = clonesinfo;
1382 if (previnfo==
nullptr) {
1400 previnfo = collectioninfo;
1401 maininfo = collectioninfo;
1406 if (inside_cl) cl = inside_cl;
1408 Warning(
"ParseWithLeaf",
"Can not call method on content of %s in %s\n",
1415 Error(
"ParseWithLeaf",
1416 "Could not discover the TClass corresponding to (%s)!",
1420 method =
new TMethodCall(cl,
"GetEntriesFast",
"");
1422 if (maininfo==
nullptr) {
1424 if (useLeafCollectionObject) {
1430 maininfo=previnfo=collectioninfo;
1436 Error(
"ParseWithLeaf",
1437 "Can not call method %s on class without dictionary (%s)!",
1445 Error(
"ParseWithLeaf",
"Unknown method:%s in %s",right,cl->
GetName());
1470 Error(
"DefineVariable",
"Method %s from %s has an impossible return type %d",
1475 if (maininfo==
nullptr) {
1476 maininfo = leafinfo;
1478 if (previnfo==
nullptr) {
1479 previnfo = leafinfo;
1481 previnfo->
fNext = leafinfo;
1482 previnfo = leafinfo;
1485 current = &(work[0]);
1487 prevUseCollectionObject =
false;
1488 prevUseReferenceObject =
false;
1489 useCollectionObject =
false;
1492 if (numberOfVarDim>1) {
1493 Warning(
"ParseWithLeaf",
"TTreeFormula support only 2 level of variables size collections. Assuming '@' notation for the collection %s.",
1496 useCollectionObject =
true;
1497 }
else if (numberOfVarDim==0) {
1501 }
else if (numberOfVarDim==1) {
1506 previnfo->
fNext = leafinfo;
1507 previnfo = leafinfo;
1513 previnfo->
fNext = leafinfo;
1514 previnfo = leafinfo;
1518 }
else if (right[i] ==
')') {
1521 TClass * casted = (
TClass*) ((
int(--paran_level)>=0) ? castqueue.
At(paran_level) :
nullptr);
1526 if (maininfo==
nullptr) {
1527 maininfo = leafinfo;
1529 if (previnfo==
nullptr) {
1530 previnfo = leafinfo;
1532 previnfo->
fNext = leafinfo;
1533 previnfo = leafinfo;
1536 current = &(work[0]);
1543 }
else if (i > 0 && (right[i] ==
'.' || right[i] ==
'[' || right[i] ==
'\0') ) {
1546 bool needClass =
true;
1550 if (strlen(work)==0)
continue;
1552 prevUseCollectionObject = useCollectionObject;
1553 prevUseReferenceObject = useReferenceObject;
1555 useReferenceObject =
true;
1556 useCollectionObject =
true;
1558 for(
l=0;work[
l+1]!=0;++
l) work[
l] = work[
l+1];
1560 }
else if (work[strlen(work)-1]==
'@') {
1561 useReferenceObject =
true;
1562 useCollectionObject =
true;
1563 work[strlen(work)-1] =
'\0';
1565 useReferenceObject =
false;
1566 useCollectionObject =
false;
1569 bool mustderef =
false;
1573 Error(
"ParseWithLeaf",
"Branch could not be loaded:%d", res);
1581 prevUseReferenceObject =
false;
1584 previnfo = previnfo->
fNext;
1588 for(
Long64_t entry=0; entry<leaf->
GetBranch()->GetEntries()-readentry; ++entry) {
1591 Error(
"ParseWithLeaf",
"Branch could not be loaded:%d", eres);
1611 Error(
"ParseWithLeaf",
"Branch could not be loaded:%d", res);
1634 previnfo = clonesinfo;
1635 maininfo = clonesinfo;
1639 Error(
"ParseWithLeaf",
"Unimplemented usage of ClonesArray");
1648 if (clones==
nullptr) {
1650 "TClonesArray object was not retrievable for %s!",
1659 if (1 || inside_cl) cl = inside_cl;
1661 if (0 && strlen(work)==0) {
1676 Error(
"ParseWithLeaf",
"Branch could not be loaded:%d", res);
1680 if (maininfo==
nullptr) {
1699 previnfo = collectioninfo;
1700 maininfo = collectioninfo;
1709 Error(
"ParseWithLeaf",
"Could you not find the inner class for %s with coll type = %d",
1713 Warning(
"ParseWithLeaf",
"No data member in content of %s in %s\n",
1722 Warning(
"ParseWithLeaf",
"Missing class for %s!",
name.Data());
1727 if (!element && !prevUseCollectionObject) {
1734 Int_t clones_offset = 0;
1741 Error(
"ParseWithLeaf",
"Branch could not be loaded:%d", res);
1746 previnfo->
fNext = clonesinfo;
1748 previnfo->
fNext =
nullptr;
1760 if (maininfo==
nullptr) maininfo = leafinfo;
1761 if (previnfo==
nullptr) previnfo = leafinfo;
1763 previnfo->
fNext = leafinfo;
1764 previnfo = leafinfo;
1772 Int_t coll_offset = 0;
1781 if (numberOfVarDim>1) {
1782 Warning(
"ParseWithLeaf",
"TTreeFormula support only 2 level of variables size collections. Assuming '@' notation for the collection %s.",
1785 useCollectionObject =
true;
1786 }
else if (numberOfVarDim==1) {
1798 if (maininfo==
nullptr) maininfo = leafinfo;
1799 if (previnfo==
nullptr) previnfo = leafinfo;
1801 previnfo->
fNext = leafinfo;
1802 previnfo = leafinfo;
1804 if (leafinfo->
fNext) {
1805 previnfo = leafinfo->
fNext;
1818 if (type<60 && type!=0) {
1820 if (numberOfVarDim>=1 && type>40) {
1825 if (leafinfo && type<=40 ) {
1832 bool object =
false;
1833 bool pointer =
false;
1834 bool objarr =
false;
1865 Error(
"ParseWithLeaf",
1866 "%s is a datamember of %s BUT is not yet of a supported type (%d)",
1867 right,cl ? cl->
GetName() :
"unknown class",type);
1871 Error(
"ParseWithLeaf",
1872 "%s is a datamember of %s BUT is not of a unknown type (%d)",
1873 right,cl ? cl->
GetName() :
"unknown class",type);
1877 if (
object && !useCollectionObject &&
1883 if (
object && leafinfo) {
1885 }
else if (objarr) {
1900 if (numberOfVarDim>1) {
1901 Warning(
"ParseWithLeaf",
"TTreeFormula support only 2 level of variables size collections. Assuming '@' notation for the collection %s.",
1904 useCollectionObject =
true;
1905 }
else if (numberOfVarDim==1) {
1925 else leafinfo->
fNext = info;
1932 if (!maininfo) maininfo = leafinfo;
1937 if (previnfo==
nullptr) previnfo = leafinfo;
1939 previnfo->
fNext = leafinfo;
1940 previnfo = leafinfo;
1955 else leafinfo->
fNext = info;
1962 Error(
"ParseWithLeaf",
"Branch could not be loaded:%d", res);
1975 prevUseReferenceObject =
false;
1978 }
else if (pointer) {
1990 if (cl)
Error(
"ParseWithLeaf",
"%s is not a datamember of %s",work,cl->
GetName());
1996 if (maininfo==
nullptr) {
1997 maininfo = leafinfo;
1999 if (previnfo==
nullptr) {
2000 previnfo = leafinfo;
2001 }
else if (previnfo!=leafinfo) {
2002 previnfo->
fNext = leafinfo;
2003 previnfo = leafinfo;
2005 while (previnfo->
fNext) previnfo = previnfo->
fNext;
2007 if ( right[i] !=
'\0' ) {
2008 if ( !needClass && mustderef ) {
2014 if ( inf->IsReference() ) {
2025 Error(
"ParseWithLeaf",
"Failed to access class type of reference target (%s)",element->
GetName());
2031 Error(
"ParseWithLeaf",
"Failed to access class type of reference target (%s)",element->
GetName());
2035 else if ( needClass ) {
2039 if (mustderef) leafinfo =
nullptr;
2040 current = &(work[0]);
2049 nchname = strlen(right);
2053 *current++ = right[i];
2062 if (strlen(work)!=0) {
2074 if (!last)
return action;
2078 if (last && last->
GetClass() != objClass) {
2090 last->
fNext = collectioninfo;
2102 if (!last)
return action;
2106 const char *funcname =
nullptr;
2110 }
else if (objClass == stdStringClass) {
2153 method =
new TMethodCall(objClass,
"AsString",
"");
2206 const char *funcname =
nullptr;
2209 }
else if (objClass == stdStringClass) {
2244 if (
fTree->GetTree()==
nullptr) {
2246 if (
fTree->GetTree()==
nullptr)
return -1;
2249 if (readentry < 0) readentry=0;
2250 const char *cname = expression;
2251 char first[
kMaxLen]; first[0] =
'\0';
2252 char second[
kMaxLen*2]; second[0] =
'\0';
2253 char right[
kMaxLen*2]; right[0] =
'\0';
2254 char work[
kMaxLen]; work[0] =
'\0';
2255 char left[
kMaxLen]; left[0] =
'\0';
2258 std::string currentname;
2259 Int_t previousdot = 0;
2261 TLeaf *tmp_leaf=
nullptr;
2262 TBranch *branch=
nullptr, *tmp_branch=
nullptr;
2263 Int_t nchname = strlen(cname);
2265 bool foundAtSign =
false;
2266 bool startWithParan =
false;
2268 for (i=0, current = &(work[0]); i<=nchname && !
final;i++ ) {
2270 *current++ = cname[i];
2272 if (cname[i] ==
'(') {
2275 if (current==work+1) {
2278 startWithParan =
true;
2290 if (cname[i] ==
')') {
2291 if (paran_level==0) {
2292 Error(
"FindLeafForExpression",
"Unmatched parenthesis in %s",fullExpression);
2297 if (startWithParan) {
2298 startWithParan =
false;
2307 current = &(work[0]);
2311 }
else if (
gROOT->GetType(cast_name)) {
2313 current = &(work[0]);
2315 Warning(
"FindLeafForExpression",
2316 "Casting to primary types like \"%s\" is not supported yet",cast_name.
Data());
2323 char *params = strchr(work,
'(');
2325 *params = 0; params++;
2327 if (branch && !leaf) {
2338 TLeaf* leafcur =
nullptr;
2339 while (!leaf && (leafcur = (
TLeaf*) next())) {
2349 if (strlen(left) && left[strlen(left)-1]==
'.') left[strlen(left)-1]=0;
2350 const char *aliasValue =
fTree->GetAlias(left);
2351 if (aliasValue && strcspn(aliasValue,
"()[]+*/-%&!=<>|") == strlen(aliasValue) &&
2355 if (find(aliasUsed.begin(),
2357 left) != aliasUsed.end()) {
2358 Error(
"FindLeafForExpression",
2359 "The substitution of the branch alias \"%s\" by \"%s\" in \"%s\" failed\n"\
2360 "\tbecause \"%s\" is used [recursively] in its own definition!",
2361 left,aliasValue,fullExpression,left);
2364 aliasUsed.push_back(left);
2365 TString newExpression = aliasValue;
2366 newExpression += (cname+strlen(left));
2368 castqueue, aliasUsed, useLeafCollectionObject, fullExpression);
2370 Error(
"FindLeafForExpression",
2371 "The substitution of the alias \"%s\" by \"%s\" failed.",left,aliasValue);
2388 strlcpy(right,work,2*
kMaxLen);
2389 strncat(right,
"(",2*
kMaxLen-1-strlen(right));
2390 strncat(right,params,2*
kMaxLen-1-strlen(right));
2397 current = &(work[0]);
2402 if (cname[i] ==
'.' || cname[i] ==
'\0' || cname[i] ==
')') {
2407 Int_t len = strlen(work);
2411 for(
l=0;work[
l+1]!=0;++
l) work[
l] = work[
l+1];
2414 }
else if (len>=2 && work[len-2]==
'@') {
2416 work[len-2] = cname[i];
2420 foundAtSign =
false;
2423 if (left[0]==0) strlcpy(left,work,
kMaxLen);
2424 if (!leaf && !branch) {
2428 std::string treename(first);
2429 if (!treename.empty() && treename[treename.size()-1]==
'.') {
2430 treename.erase(treename.size()-1);
2432 if (treename==
"This" ) {
2437 if (cname[i]) leftover = &(cname[i+1]);
2464 branch =
fTree->FindBranch(first);
2465 leaf =
fTree->FindLeaf(first);
2469 if (cname[i]) first[strlen(first)-1]=
'\0';
2470 if (!branch) branch =
fTree->FindBranch(first);
2471 if (!leaf) leaf =
fTree->FindLeaf(first);
2483 useLeafCollectionObject = foundAtSign;
2485 current = &(work[0]);
2488 else if (branch && (foundAtSign || cname[i] != 0) ) {
2493 if (leaf==
nullptr) {
2498 if ( type == 3 || type ==4) {
2502 useLeafCollectionObject = foundAtSign;
2503 foundAtSign =
false;
2504 current = &(work[0]);
2514 useLeafCollectionObject = foundAtSign;
2515 foundAtSign =
false;
2516 current = &(work[0]);
2518 }
else if (leaf || branch) {
2519 if (leaf && branch) {
2533 current = &(work[0]);
2546 if (foundAtSign) strncat(right,
"@",2*
kMaxLen-1-strlen(right));
2547 if (cname[i]==
'.') strncat(right,
".",2*
kMaxLen-1-strlen(right));
2550 current = &(work[0]);
2553 }
else if (cname[i] ==
'.') {
2560 while(!branch && (branchcur=(
TBranch*)next()) ) {
2565 current = &(work[0]);
2572 Error(
"FindLeafForExpression",
"Unexpected control flow!");
2578 if (cname[i]) work[strlen(work)-1] =
'\0';
2579 snprintf(scratch,
sizeof(scratch),
"%s.%s",first,work);
2580 snprintf(scratch2,
sizeof(scratch2),
"%s.%s.%s",first,second,work);
2583 currentname = &(work[previousdot+1]);
2590 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch);
2591 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch2);
2592 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(currentname.c_str());
2602 if (!tmp_branch) tmp_branch = branch->
FindBranch(scratch);
2603 if (!tmp_branch) tmp_branch = branch->
FindBranch(scratch2);
2604 if (!tmp_branch) tmp_branch = branch->
FindBranch(currentname.c_str());
2612 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch);
2613 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch2);
2614 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(currentname.c_str());
2625 if (second[0]) strncat(second,
".",2*
kMaxLen-1-strlen(second));
2626 strncat(second,work,2*
kMaxLen-1-strlen(second));
2628 useLeafCollectionObject = foundAtSign;
2629 foundAtSign =
false;
2632 current = &(work[0]);
2638 Int_t where = strlen(work);
2640 work[where+1] = cname[i];
2642 previousdot = where+1;
2644 previousdot = strlen(work);
2645 work[strlen(work)] = cname[i];
2655 strncat(right,work,2*
kMaxLen-1-strlen(right));
2659 if (strlen(right) && right[strlen(right)-1]!=
'.' && cname[i]!=
'.') {
2663 strncat(right,
".",2*
kMaxLen-1-strlen(right));
2665 strncat(right,&cname[i],2*
kMaxLen-1-strlen(right));
2668 if (!
final && branch) {
2671 if (!leaf)
return -1;
2677 if (strlen(right)==0) strlcpy(right,work,2*
kMaxLen);
2680 if (leaf==
nullptr && left[0]!=0) {
2681 if (left[strlen(left)-1]==
'.') left[strlen(left)-1]=0;
2684 const char *aliasValue =
fTree->GetAlias(left);
2685 if (aliasValue && strcspn(aliasValue,
"()[]+*/-%&!=<>|") == strlen(aliasValue) && !
IsNumberConstant(aliasValue)) {
2688 if (find(aliasUsed.begin(),
2690 left) != aliasUsed.end()) {
2691 Error(
"FindLeafForExpression",
2692 "The substitution of the branch alias \"%s\" by \"%s\" in \"%s\" failed\n"\
2693 "\tbecause \"%s\" is used [recursively] in its own definition!",
2694 left,aliasValue,fullExpression,left);
2697 aliasUsed.push_back(left);
2698 TString newExpression = aliasValue;
2699 newExpression += (cname+strlen(left));
2701 castqueue, aliasUsed, useLeafCollectionObject, fullExpression);
2703 Error(
"FindLeafForExpression",
2704 "The substitution of the alias \"%s\" by \"%s\" failed.",left,aliasValue);
2755 if (!
fTree)
return -1;
2759 Error(
"TTreeFormula",
"The length of the variable name (%d) exceeds the maximum allowed (%d)",
name.Length(),
kMaxLen);
2764 if (
name ==
"Entry$") {
2770 if (
name ==
"LocalEntry$") {
2776 if (
name ==
"Entries$") {
2784 if (
name ==
"LocalEntries$") {
2792 if (
name ==
"Iteration$") {
2798 if (
name ==
"Length$") {
2804 static const char *
lenfunc =
"Length$(";
2805 if (strncmp(
name.Data(),
"Length$(",strlen(
lenfunc))==0
2817 static const char *minfunc =
"Min$(";
2818 if (strncmp(
name.Data(),
"Min$(",strlen(minfunc))==0
2830 static const char *maxfunc =
"Max$(";
2831 if (strncmp(
name.Data(),
"Max$(",strlen(maxfunc))==0
2843 static const char *sumfunc =
"Sum$(";
2844 if (strncmp(
name.Data(),
"Sum$(",strlen(sumfunc))==0
2863 if (res<0)
return res;
2871 char dims[
kMaxLen]; dims[0] =
'\0';
2879 Int_t cnamelen = strlen(cname);
2880 for(i=0,k=0; i<cnamelen; ++i, ++k) {
2881 if (cname[i] ==
'[') {
2883 int bracket_level = 1;
2885 for (j=++i; j<cnamelen && (bracket_level>0 || cname[j]==
'['); j++, i++) {
2886 if (cname[j]==
'[') bracket_level++;
2887 else if (cname[j]==
']') bracket_level--;
2889 if (bracket_level != 0) {
2893 strncat(dims,&cname[bracket],j-bracket);
2896 if (i!=k) cname[k] = cname[i];
2900 bool useLeafCollectionObject =
false;
2902 TLeaf *leaf =
nullptr;
2905 res =
FindLeafForExpression(cname, leaf, leftover,
final, paran_level, castqueue, aliasSofar, useLeafCollectionObject,
name);
2907 if (res<0)
return res;
2909 if (!leaf && res!=2) {
2911 const char *aliasValue =
fTree->GetAlias(cname);
2918 Error(
"DefinedVariable",
2919 "The substitution of the alias \"%s\" by \"%s\" failed\n"\
2920 "\tbecause \"%s\" is recursively used in its own definition!",
2921 cname,aliasValue,cname);
2925 if (strcspn(aliasValue,
"()[]+*/-%&!=<>|") != strlen(aliasValue) ||
IsNumberConstant(aliasValue)) {
2931 aliasSofar.push_back( cname );
2933 TString subValue( aliasValue );
2942 Error(
"DefinedVariable",
2943 "The substitution of the alias \"%s\" by \"%s\" failed.",cname,aliasValue);
2958 TString thisAlias( aliasValue );
2966 Error(
"Compile",
" Bad numerical expression : \"%s\"",thisAlias.
Data());
2967 }
else if (aliasRes==-2) {
2968 Error(
"Compile",
" Part of the Variable \"%s\" exists but some of it is not accessible or useable",thisAlias.
Data());
2971 Error(
"DefinedVariable",
2972 "The substitution of the alias \"%s\" by \"%s\" failed.",cname,aliasValue);
2981 if (leaf || res==2) {
2984 Error(
"DefinedVariable",
"the branch \"%s\" has to be enabled to be used",leaf->
GetBranch()->
GetName());
2993 char *current = &( dims[0] );
3000 if (current[0] ==
']') {
3004 auto closePos = tempIndex.
First(
']');
3006 tempIndex = tempIndex(0, closePos);
3007 if (tempIndex.
IsDigit() && (scanindex = sscanf(current,
"%d", &index)) && scanindex == 1) {
3012 char *end = (
char*)(varindex.
Data());
3013 for(
char bracket_level = 0;*end!=0;end++) {
3014 if (*end==
'[') bracket_level++;
3015 if (bracket_level==0 && *end==
']')
break;
3016 if (*end==
']') bracket_level--;
3026 current += strlen(varindex)+1;
3034 current = (
char*)strstr( current,
"[" );
3041 res =
ParseWithLeaf(leaf,leftover,
final,paran_level,castqueue,useLeafCollectionObject,
name);
3042 if (res<0)
return res;
3043 if (res>0) action = res;
3071 }
else if (strlen(gcut->
GetVarX())) {
3080 for(
Int_t i2 = 1; i2<
n; i2++) {
3081 if (
x[i2] < min) min =
x[i2];
3082 if (
x[i2] > max) max =
x[i2];
3101 Error(
"DefinedVariable",
"Found a TCutG without leaf information (%s)",
3135 TIter nextleaf (
fTree->GetIteratorOnAllLeaves());
3138 while ((leafcur = (
TLeaf*)nextleaf())) {
3155 }
else if (type>60 || type==0) {
3166 if (clonesinfo) {
delete clonesinfo; clonesinfo =
nullptr; }
3173 Error(
"GetLeafWithDatamember",
"Branch could not be loaded:%d", res);
3190 bool toplevel = (branch == branch->
GetMother());
3194 if (clones) cl = clones->
GetClass();
3236 leafinfo = clonesinfo;
3248 Int_t clones_offset = 0;
3253 else leafinfo->
fNext = sub_clonesinfo;
3254 else leafinfo = sub_clonesinfo;
3258 Error(
"GetLeafWithDatamember",
"Branch could not be loaded:%d", res);
3264 delete leafinfo; clonesinfo =
nullptr;
3269 if (!clones)
continue;
3330 }
else if (type > 60) {
3358 Error(
"BranchHasMethod",
"Branch could not be loaded:%d", res);
3385 Error(
"BranchHasMethod",
"Branch could not be loaded:%d", cres);
3397 Error(
"BranchHasMethod",
"A TClonesArray was stored in a branch type no yet support (i.e. neither TBranchObject nor TBranchElement): %s",branch->
IsA()->
GetName());
3400 cl = clones ? clones->
GetClass() :
nullptr;
3434 Int_t real_instance = 0;
3458 Int_t index_real_instance =
fVarIndexes[codeindex][0]->GetRealInstance(local_index,-1);
3469 if (local_index<0) {
3470 Error(
"EvalInstance",
"Index %s is out of bound (%d) in formula %s",
3477 real_instance = local_index *
fCumulSizes[codeindex][1];
3502 if (local_index<0) {
3503 Error(
"EvalInstance",
"Index %s is out of bound (%d) in formula %s",
3523 if (check)
return fNdata[0]+1;
3526 virt_accum +=
fManager->fCumulUsedVarDims->GetArray()[local_index];
3528 }
while(
instance >= virt_accum && local_index<maxloop);
3534 if (local_index==(maxloop-1) && (
instance >= virt_accum)) {
3536 if (check)
return fNdata[0]+1;
3538 if (
fManager->fCumulUsedVarDims->At(local_index)) {
3542 if (check)
return fNdata[0]+1;
3550 local_index =
fIndexes[codeindex][0];
3577 if (
fIndexes[codeindex][vdim]>=0) {
3580 if (isize!=1 &&
fIndexes[codeindex][vdim]>isize) {
3585 for(
Int_t k=vdim -1; k>0; --k) {
3589 real_instance = local_index *
fCumulSizes[codeindex][1];
3593 for (
Int_t dim = 1; dim < max_dim; dim++) {
3598 if (virt_dim &&
fManager->fCumulUsedSizes[virt_dim]>1) {
3600 /
fManager->fCumulUsedSizes[virt_dim+1]);
3604 if (
fIndexes[codeindex][dim]==-2) {
3611 if (local_index<0 ||
3613 Error(
"EvalInstance",
"Index %s is out of bound (%d/%d) in formula %s",
3621 real_instance += local_index *
fCumulSizes[codeindex][dim+1];
3625 if (
fIndexes[codeindex][max_dim]>=0) {
3626 if (!info) real_instance +=
fIndexes[codeindex][max_dim];
3629 if (virt_dim &&
fManager->fCumulUsedSizes[virt_dim]>1) {
3634 if (info && local_index>=
fCumulSizes[codeindex][max_dim]) {
3638 if (
fIndexes[codeindex][max_dim]==-2) {
3644 if (local_index<0 ||
3646 Error(
"EvalInstance",
"Index %s is of out bound (%d/%d) in formula %s",
3654 real_instance += local_index;
3659 return real_instance;
3698 if (elem==
nullptr) {
3713 if (!obj)
return nullptr;
3717 default:
return nullptr;
3757 Error(
"EvalObject",
"Branch could not be loaded:%d", res);
3761 else if (real_instance>=
fNdata[0])
return nullptr;
3767 if (real_instance) {
3768 Warning(
"EvalObject",
"Not yet implement for kDirect and arrays (for %s).\nPlease contact the developers",
GetName());
3775 default:
return nullptr;
3787 const Int_t kMAXSTRINGFOUND = 10;
3788 const char *stringStack[kMAXSTRINGFOUND];
3800 Error(
"EvalStringInstance",
"Branch could not be loaded:%d", res);
3803 }
else if (real_instance>=
fNdata[0]) {
3816 return stringStack[0];
3819#define TT_EVAL_INIT \
3820 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(0); \
3822 const Int_t real_instance = GetRealInstance(instance,0); \
3824 if (instance==0) fNeedLoading = true; \
3825 if (real_instance>=fNdata[0]) return TMath::SignalingNaN(); \
3831 if (fNeedLoading) { \
3832 fNeedLoading = false; \
3833 TBranch *br = leaf->GetBranch(); \
3834 if (br && br->GetTree()) { \
3835 Long64_t tEntry = br->GetTree()->GetReadEntry(); \
3836 auto lres = R__LoadBranch(br, tEntry, fQuickLoad); \
3838 Error("TTreeFormula::TT_EVAL_INIT", \
3839 "Could not read entry (%lld) of leaf (%s), r=(%d).", tEntry, leaf->GetName(), lres);\
3841 Error("TTreeFormula::TT_EVAL_INIT", \
3842 "Could not init branch associated to this leaf (%s).", leaf->GetName()); \
3850 if (fLookupType[0]==kDirect) { \
3851 label = (char*)leaf->GetValuePointer(); \
3853 label = (char*)GetLeafInfo(0)->GetValuePointer(leaf,instance); \
3855 Int_t bin = fAxis->FindBin(label); \
3859#define TREE_EVAL_INIT \
3860 const Int_t real_instance = GetRealInstance(instance,0); \
3862 if (real_instance>=fNdata[0]) return TMath::SignalingNaN(); \
3868 label = (char*)GetLeafInfo(0)->GetValuePointer((TLeaf*)0x0,instance); \
3869 Int_t bin = fAxis->FindBin(label); \
3873#define TT_EVAL_INIT_LOOP \
3874 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(code); \
3877 const Int_t real_instance = GetRealInstance(instance,code); \
3880 TBranch *branch = (TBranch*)fBranches.UncheckedAt(code); \
3882 if (branch->GetTree()) { \
3883 Long64_t tEntry = branch->GetTree()->GetReadEntry(); \
3884 auto lres = R__LoadBranch(branch, tEntry, fQuickLoad); \
3886 Error("TTreeFormula::TT_EVAL_INIT_LOOP", \
3887 "Could not read entry (%lld) of leaf (%s), r=(%d).", tEntry, leaf->GetName(), lres);\
3890 Error("TTreeFormula::TT_EVAL_INIT_LOOP", \
3891 "Could not init branch associated to this leaf (%s).", leaf->GetName()); \
3893 } else if (fDidBooleanOptimization) { \
3894 branch = leaf->GetBranch(); \
3895 if (branch && branch->GetTree()) { \
3896 Long64_t tEntry = branch->GetTree()->GetReadEntry(); \
3897 if (branch->GetReadEntry() != tEntry) branch->GetEntry(tEntry); \
3899 Error("TTreeFormula::TT_EVAL_INIT_LOOP", \
3900 "Could not init branch associated to this leaf (%s).", leaf->GetName()); \
3907 if (fDidBooleanOptimization) { \
3908 TBranch *br = leaf->GetBranch(); \
3909 if (br->GetTree()) { \
3910 Long64_t tEntry = br->GetTree()->GetReadEntry(); \
3911 if (br->GetReadEntry() != tEntry) br->GetEntry(tEntry); \
3913 Error("TTreeFormula::TT_EVAL_INIT_LOOP", \
3914 "Could not init branch associated to this leaf (%s).", leaf->GetName()); \
3918 if (real_instance>=fNdata[code]) return TMath::SignalingNaN();
3920#define TREE_EVAL_INIT_LOOP \
3922 const Int_t real_instance = GetRealInstance(instance,code); \
3924 if (real_instance>=fNdata[code]) return TMath::SignalingNaN();
3930 for (
int i=0; i<len; ++i) res +=
sum->EvalInstance<T>(i);
3939 for (
int i=1; i<len; ++i) {
3954 for (
int i=1; i<len; ++i) {
3971 condval = condition->EvalInstance<T>(i);
3973 }
while (!condval && i<len);
3974 if (!condval && i==len) {
3983 for (; i<len; ++i) {
3984 condval = condition->EvalInstance<T>(i);
4003 condval = condition->EvalInstance<T>(i);
4005 }
while (!condval && i<len);
4006 if (!condval && i==len) {
4015 for (; i<len; ++i) {
4016 condval = condition->EvalInstance<T>(i);
4030template <
typename T> T fmod_local(T
x, T
y) {
return fmod(
x,
y); }
4047 if( !strncmp(
fExpr[op],
"0x", 2) || !strncmp(
fExpr[op],
"0X", 2) ) {
4049 sscanf(
fExpr[op],
"%llx", &val );
4140 return leaf->GetTypedValue<T>(real_instance);
4198 const Int_t kMAXSTRINGFOUND = 10;
4199 const char *stringStackLocal[kMAXSTRINGFOUND];
4200 const char **stringStack = stringStackArg?stringStackArg:stringStackLocal;
4220 case kEnd :
return tab[0];
4221 case kAdd : pos--; tab[pos-1] += tab[pos];
continue;
4222 case kSubstract : pos--; tab[pos-1] -= tab[pos];
continue;
4223 case kMultiply : pos--; tab[pos-1] *= tab[pos];
continue;
4224 case kDivide : pos--;
if (tab[pos] == 0) tab[pos-1] = 0;
4225 else tab[pos-1] /= tab[pos];
4230 tab[pos-1] = T(int1 % int2);
4250 case kacosh:
if (tab[pos-1] < 1) {tab[pos-1] = 0;}
4259 case kfmod : pos--; tab[pos-1] = fmod_local(tab[pos-1],tab[pos]);
continue;
4260 case kpow : pos--; tab[pos-1] =
TMath::Power(tab[pos-1],tab[pos]);
continue;
4261 case ksq : tab[pos-1] = tab[pos-1]*tab[pos-1];
continue;
4264 case kstrstr : pos2 -= 2; pos++;
if (strstr(stringStack[pos2],stringStack[pos2+1])) tab[pos-1]=1;
4268 case kmin : pos--; tab[pos-1] = std::min(tab[pos-1],tab[pos]);
continue;
4269 case kmax : pos--; tab[pos-1] = std::max(tab[pos-1],tab[pos]);
continue;
4271 case klog :
if (tab[pos-1] > 0) tab[pos-1] =
TMath::Log(tab[pos-1]);
4272 else {tab[pos-1] = 0;}
4275 if (dexp < -700) {tab[pos-1] = 0;
continue;}
4276 if (dexp > 700) {tab[pos-1] =
TMath::Exp(700);
continue;}
4280 else {tab[pos-1] = 0;}
4286 case ksign :
if (tab[pos-1] < 0) tab[pos-1] = -1;
else tab[pos-1] = 1;
4288 case kint : tab[pos-1] = T(
Long64_t(tab[pos-1]));
continue;
4289 case kSignInv: tab[pos-1] = -1 * tab[pos-1];
continue;
4290 case krndm : pos++; tab[pos-1] =
gRandom->Rndm();
continue;
4292 case kAnd : pos--;
if (tab[pos-1]!=0 && tab[pos]!=0) tab[pos-1]=1;
4295 case kOr : pos--;
if (tab[pos-1]!=0 || tab[pos]!=0) tab[pos-1]=1;
4299 case kEqual : pos--; tab[pos-1] = (tab[pos-1] == tab[pos]) ? 1 : 0;
continue;
4300 case kNotEqual : pos--; tab[pos-1] = (tab[pos-1] != tab[pos]) ? 1 : 0;
continue;
4301 case kLess : pos--; tab[pos-1] = (tab[pos-1] < tab[pos]) ? 1 : 0;
continue;
4302 case kGreater : pos--; tab[pos-1] = (tab[pos-1] > tab[pos]) ? 1 : 0;
continue;
4303 case kLessThan : pos--; tab[pos-1] = (tab[pos-1] <= tab[pos]) ? 1 : 0;
continue;
4304 case kGreaterThan: pos--; tab[pos-1] = (tab[pos-1] >= tab[pos]) ? 1 : 0;
continue;
4305 case kNot : tab[pos-1] = (tab[pos-1] != 0) ? 0 : 1;
continue;
4307 case kStringEqual : pos2 -= 2; pos++;
if (!strcmp(stringStack[pos2+1],stringStack[pos2])) tab[pos-1]=1;
4310 case kStringNotEqual: pos2 -= 2; pos++;
if (strcmp(stringStack[pos2+1],stringStack[pos2])) tab[pos-1]=1;
4335 pos2++; stringStack[pos2-1] = (
char*)
fExpr[i].Data();
4338 Int_t bin =
fAxis->FindBin(stringStack[pos2-1]);
4349 int op = param % 10;
4351 if (op == 1 && (!tab[pos-1]) ) {
4360 }
else if (op == 2 && tab[pos-1] ) {
4371 int toskip = param / 10;
4382 int fno = param / 1000;
4383 int nargs = param % 1000;
4391 UInt_t argloc = pos-nargs;
4392 for(
Int_t j=0;j<nargs;j++,argloc++,pos--) {
4393 SetMethodParam(method, tab[argloc]);
4416 switch (lookupType) {
4419 case kEntries: tab[pos++] = (T)
fTree->GetEntries();
continue;
4431 GetTypedValue<T>(leaf,real_instance);
continue; }
4433 GetTypedValue<T>((
TLeaf*)
nullptr,real_instance);
continue; }
4438 default: tab[pos++] = 0;
continue;
4451 tab[pos++] = gcut->
IsInside(xcut,ycut);
4480 tab[pos] = param; pos++;
4500 tab[pos] = param; pos++;
4509 tab[pos] = param; pos++;
4525 tab[pos] = param; pos++;
4569 Error(
"EvalInstance",
"Branch could not be loaded:%d", res);
4581 Error(
"EvalInstance",
"Branch could not be loaded:%d", res);
4662 void* thisobj =
nullptr;
4664 thisobj = ((TLeafObject*) leaf)->GetObject();
4666 TBranchElement* branch = (TBranchElement*) ((TLeafElement*) leaf)->GetBranch();
4671 TStreamerInfo* info = branch->
GetInfo();
4675 Warning(
"GetValueFromMethod",
"No streamer info for branch %s.", branch->
GetName());
4685 thisobj = *((
char**) (address + offset));
4725 thisobj = ((TLeafObject*) leaf)->GetObject();
4727 TBranchElement* branch = (TBranchElement*) ((TLeafElement*) leaf)->GetBranch();
4731 TStreamerInfo* info = branch->
GetInfo();
4735 Warning(
"GetValuePointerFromMethod",
"No streamer info for branch %s.", branch->
GetName());
4745 thisobj = *((
char**) (address + offset));
4801 if (
fNoper > 1)
return false;
4809 if (
fLeaves.GetEntries() != 1) {
4860 if (
fAxis)
return true;
4871 if (!strcmp(leaf->
GetTypeName(),
"Int_t"))
return true;
4872 if (!strcmp(leaf->
GetTypeName(),
"Short_t"))
return true;
4873 if (!strcmp(leaf->
GetTypeName(),
"UInt_t"))
return true;
4874 if (!strcmp(leaf->
GetTypeName(),
"UShort_t"))
return true;
4875 if (!strcmp(leaf->
GetTypeName(),
"Bool_t"))
return true;
4876 if (!strcmp(leaf->
GetTypeName(),
"Char_t"))
return true;
4877 if (!strcmp(leaf->
GetTypeName(),
"UChar_t"))
return true;
4878 if (!strcmp(leaf->
GetTypeName(),
"Long64_t"))
return true;
4879 if (!strcmp(leaf->
GetTypeName(),
"ULong64_t"))
return true;
4880 if (!strcmp(leaf->
GetTypeName(),
"string"))
return true;
4928 if (indexname[strlen(indexname)-1] ==
'_' ) {
4938 TBranchElement * br = (TBranchElement*)leaf->
GetBranch();
4940 if (bid < 0)
return false;
5003 const int kMAXLENGTH =
kMaxLen;
5004 static char value[kMAXLENGTH];
5007 for (
int i = 0; i < kMAXLENGTH-1; i++)
5009 value[kMAXLENGTH-1] = 0;
5010 }
else if (mode == -1) {
5012 }
else if (mode == 0) {
5015 const char * val =
nullptr;
5017 val =
fExpr[0].Data();
5028 Error(
"PrintValue",
"Branch could not be loaded:%d", res);
5042 strlcpy(value, val, kMAXLENGTH);
5046 value[kMAXLENGTH-1] = 0;
5051 if (real_instance<
fNdata[0]) {
5052 Ssiz_t len = strlen(decform);
5053 Char_t outputSizeLevel = 1;
5054 char *expo =
nullptr;
5056 switch (decform[len-2]) {
5059 outputSizeLevel = 2;
5060 if (len>3 && tolower(decform[len-3])==
'l') {
5061 outputSizeLevel = 3;
5065 case 'h': outputSizeLevel = 0;
break;
5068 switch(decform[len-1]) {
5073 switch (outputSizeLevel) {
5087 switch (outputSizeLevel) {
5102 switch (outputSizeLevel) {
5107 expo = strchr(value,
'e');
5112 expo = strchr(value,
'e');
5117 UInt_t declen = atoi(decform);
5118 if (strlen(value)>declen) {
5119 UInt_t off = strlen(value)-declen;
5120 char *
start = expo - off;
5121 UInt_t vlen = strlen(expo);
5122 for(
UInt_t z=0;z<=vlen;++z) {
5129 if (isalpha(decform[strlen(decform)-1])) {
5130 TString short_decform(decform);
5153 for(
UInt_t dim=0; dim<max_dim ;++dim) {
5163 for(
Int_t k=0; k <=
n; ++k) {
5186 if (!axis) {
fAxis =
nullptr;
return;}
5276 for (
Int_t i=0;i<nleaves;i++) {
5359 Int_t last_code = -1;
5361 for(TDimensionInfo * info; (info = (TDimensionInfo*)next()); ) {
5362 if (last_code!=info->fCode) {
5367 last_code = info->fCode;
5375 TDimensionInfo *nextinfo = (TDimensionInfo*)next();
5376 while(nextinfo && nextinfo->
fCode==info->fCode) {
5378 nextinfo = (TDimensionInfo*)next();
5380 if (!nextinfo)
break;
5384 last_code = info->fCode;
5436 if (!gcut)
continue;
5465 TLeaf *leaf = i <=
fLeaves.GetLast() ? (TLeaf*)
fLeaves.UncheckedAt(i) :
nullptr;
5466 if (!leaf)
continue;
5480 TStreamerElement * elem = leafinfo->
fElement;
5493 TTree *realtree =
fTree ?
fTree->GetTree() :
nullptr;
5495 if (tleaf && tleaf != realtree && tleaf->
GetTreeIndex()) {
5501 Int_t virt_dim2 = 0;
5507 fManager->CancelDimension(virt_dim2);
5509 if (
fIndexes[i][k] < 0 ) virt_dim2++;
5537 for (i=0; i<
fNoper ; ++i) {
5538 TLeaf *leaf = (TLeaf*)
fLeaves.UncheckedAt(i);
5539 if (leaf==
nullptr)
continue;
5545 Error(
"LoadBranches",
"Branch could not be loaded:%d", res);
5564 bool outofbounds =
false;
5567 if (
fCodes[i] < 0)
continue;
5580 TLeaf *leaf = i <=
fLeaves.GetLast() ? (TLeaf *)
fLeaves.UncheckedAt(i) :
nullptr;
5593 TTree *realtree =
fTree->GetTree();
5595 if (tleaf && tleaf != realtree && tleaf->
GetTreeIndex()) {
5604 bool hasBranchCount2 =
false;
5607 TBranch *branchcount = leafcount->
GetBranch();
5608 TFormLeafInfo * info =
nullptr;
5613 if (readentry < 0) readentry=0;
5617 Error(
"LoadCurrentDim",
"Branch could not be loaded:%d", res);
5624 branchcount->TBranch::GetEntry(readentry);
5628 size = ((TBranchElement*)branchcount)->GetNdata();
5633 TBranchElement* branch = (TBranchElement*) leaf->
GetBranch();
5647 Error(
"LoadCurrentDim",
"Branch could not be loaded:%d", res);
5655 hasBranchCount2 =
true;
5662 for(
Int_t k=vdim -1; k>=0; k--) {
5676 if (readentry < 0) readentry=0;
5679 Error(
"LoadCurrentDim",
"Branch could not be loaded:%d", res);
5684 if (hasBranchCount2) {
5699 fManager->fCumulUsedVarDims->AddAt(-1,j);
5704 fManager->fCumulUsedVarDims->AddAt(1,j);
5713 }
else if (hasBranchCount2) {
5714 TFormLeafInfo *info2;
5725 TFormLeafInfo *leafinfo = (TFormLeafInfo*)
fDataMembers.UncheckedAt(i);
5729 if (readentry < 0) readentry=0;
5732 Error(
"LoadCurrentDim",
"Branch could not be loaded:%d", res);
5758 hasBranchCount2 =
true;
5764 }
else if (
fIndexes[i][vdim] >= 0 ) {
5774 for(
Int_t k=vdim -1; k>=0; k--) {
5784 if (readentry < 0) readentry=0;
5787 Error(
"LoadCurrentDim",
"Branch could not be loaded:%d", res);
5797 TFormLeafInfo * info =
nullptr;
5807 if (
fManager->fUsedSizes[virt_dim]==1 || (index_size!=1 && index_size<fManager->fUsedSizes[virt_dim]) )
5808 fManager->fUsedSizes[virt_dim] = index_size;
5814 if (index_size==1) {
5818 if (index_size<fManager->fUsedSizes[virt_dim])
fManager->fUsedSizes[virt_dim] = index_size;
5821 }
else if (
fManager->fUsedSizes[virt_dim]==-
fManager->fVirtUsedSizes[virt_dim] ||
5822 index_size<fManager->fUsedSizes[virt_dim]) {
5823 fManager->fUsedSizes[virt_dim] = index_size;
5826 }
else if (hasBranchCount2 && info && k==info->
GetVarDim()) {
5830 if (
fManager->fUsedSizes[virt_dim]==1 || (index_size!=1 && index_size<fManager->fUsedSizes[virt_dim]) )
5831 fManager->fUsedSizes[virt_dim] = index_size;
5835 }
else if (hasBranchCount2 && info && k==info->
GetVarDim()) {
5848 return ! outofbounds;
5858 enum { kOldAlias = 100000+10000+1,
5859 kOldAliasString = kOldAlias+1,
5860 kOldAlternate = kOldAlias+2,
5861 kOldAlternateString = kOldAliasString+2
5864 for (
int k=0; k<
fNoper; k++) {
5871 case kOldAlias:
GetOper()[k] = -kOldAlias;
break;
5872 case kOldAliasString:
GetOper()[k] = -kOldAliasString;
break;
5873 case kOldAlternate:
GetOper()[k] = -kOldAlternate;
break;
5874 case kOldAlternateString:
GetOper()[k] = -kOldAlternateString;
break;
5880 for (
int i=0,offset=0; i<
fNoper; i++) {
5906 if (!leaf)
return false;
5920 last = clonesinfo->
fNext;
5924 }
else if (br->
GetType()==41) {
5929 if ( count->
GetID() >= 0 ) {
5948 last = collectioninfo->
fNext;
5952 }
else if (br->
GetID()<0) {
static Roo_reg_AGKInteg1D instance
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short).
int Int_t
Signed integer 4 bytes (int).
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
short Version_t
Class version identifier (short).
int Ssiz_t
String size (currently int).
char Char_t
Character 1 byte (char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
short Short_t
Signed Short integer 2 bytes (short).
double Double_t
Double 8 bytes.
long double LongDouble_t
Long Double (not portable).
long long Long64_t
Portable signed long integer 8 bytes.
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
const Int_t kDoNotProcess
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Class to manage histogram axis.
A Branch for the case of an object.
TBranchElement * GetBranchCount() const
const char * GetClassName() const override
Return the name of the user class whose content is stored in this branch, if any.
TStreamerInfo * GetInfo() const
Get streamer info for the branch class.
void SetupAddresses() override
If the branch address is not set, we set all addresses starting with the top level parent branch.
Int_t GetStreamerType() const
TBranchElement * GetBranchCount2() const
char * GetAddress() const override
Get the branch address.
char * GetObject() const
Return a pointer to our object.
A Branch for the case of an object.
const char * GetClassName() const override
Return the name of the user class whose content is stored in this branch, if any.
A TTree is a list of TBranches.
virtual char * GetAddress() const
TObjArray * GetListOfBranches()
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all leaves of entry and return total number of bytes read.
TClass * IsA() const override
void Print(Option_t *option="") const override
Print TBranch parameters.
virtual TLeaf * FindLeaf(const char *name)
Find the leaf corresponding to the name 'searchname'.
Long64_t GetReadEntry() const
virtual void ResetReadEntry()
virtual TBranch * FindBranch(const char *name)
Find the immediate sub-branch with passed name.
TObjArray * GetListOfLeaves()
TBranch * GetMother() const
Get our top-level parent branch in the tree.
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
TClassRef is used to implement a permanent reference to a TClass object.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Bool_t HasDataMemberInfo() const
ClassInfo_t * GetClassInfo() const
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
TVirtualRefProxy * GetReferenceProxy() const
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
TClass * GetClass() const
const char * GetVarX() const
virtual void SetObjectY(TObject *obj)
Set the Y object (and delete the previous one if any).
TObject * GetObjectY() const
virtual void SetObjectX(TObject *obj)
Set the X object (and delete the previous one if any).
TObject * GetObjectX() const
const char * GetVarY() const
A small helper class to help in keeping track of the array dimensions encountered in the analysis of ...
TDimensionInfo(Int_t code, Int_t oper, Int_t size, TFormLeafInfoMultiVarDim *multiDim)
~TDimensionInfo() override
TFormLeafInfoMultiVarDim * fMultiDim
Describe directory structure in memory.
virtual Bool_t cd()
Change current directory to "this" directory.
virtual Int_t Contains(Long64_t entry, TTree *tree=nullptr)
virtual Int_t IsInside(Double_t x, Double_t y) const
A TLeaf for the general case when using the branches created via a TStreamerInfo (i....
bool IsOnTerminalBranch() const override
Return true if this leaf is does not have any sub-branch/leaf.
A TLeaf for a general object derived from TObject.
TClass * GetClass() const
TObject * GetObject() const
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual void * GetValuePointer() const
virtual bool IsUnsigned() const
virtual const char * GetTypeName() const
virtual Int_t GetLen() const
Return the number of effective elements of this leaf, for the current entry.
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
TClass * IsA() const override
virtual bool IsOnTerminalBranch() const
TBranch * GetBranch() const
virtual Int_t GetLenStatic() const
Return the fixed length of this leaf.
Method or function calling interface.
EReturnType ReturnType()
Returns the return type of the method.
static const EReturnType kLong
static const EReturnType kString
void ResetParam()
Reset parameter list. To be used before the first call the SetParam().
static const EReturnType kOther
TFunction * GetMethod()
Returns the TMethod describing the method to be executed.
void Execute(const char *, const char *, int *=nullptr) override
Execute method on this object with the given parameter string, e.g.
TInterpreter::EReturnType EReturnType
Bool_t IsValid() const
Return true if the method call has been properly initialized and is usable.
static const EReturnType kDouble
void SetParam(Long_t l)
Add a long method parameter.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
Int_t IndexOf(const TObject *obj) const override
void AddAt(TObject *obj, Int_t idx) override
Add object at position ids.
TObject * Last() const override
Return the object in the last filled slot. Returns 0 if no entries.
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
TObject * At(Int_t idx) const override
TObject * UncheckedAt(Int_t i) const
Int_t GetLast() const override
Return index of last object in array.
friend class TClonesArray
Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Execute(const char *method, const char *params, Int_t *error=nullptr)
Execute method on this object with the given parameter string, e.g.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TObject()
TObject constructor.
const char * GetCountName() const
Describe one element (data member) to be Streamed.
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element and updates fClassObject.
Int_t GetArrayDim() const
Int_t GetMaxIndex(Int_t i) const
virtual Bool_t IsaPointer() const
TClass * GetClass() const
TClass * IsA() const override
Describes a persistent version of a class.
TStreamerElement * GetElement(Int_t id) const override
Int_t GetElementOffset(Int_t id) const override
TClass * GetClass() const override
TStreamerElement * GetStreamerElement(const char *datamember, Int_t &offset) const override
Return the StreamerElement of "datamember" inside our class or any of its base classes.
static constexpr Ssiz_t kNPOS
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
A TTree represents a columnar dataset.
virtual TObjArray * GetListOfLeaves()
virtual TVirtualIndex * GetTreeIndex() const
virtual Long64_t GetReadEntry() const
virtual const char * GetFriendAlias(TTree *) const
If the 'tree' is a friend, this method returns its alias name.
virtual EDataType GetType() const =0
If the value type is a fundamental data type, return its type (see enumeration EDataType).
virtual TClass * GetValueClass() const =0
If the value type is a user-defined class, return a pointer to the TClass representing the value type...
virtual TClass * GetValueClass(void *data) const =0
virtual Bool_t HasCounter() const =0
Bool_t IsCompiled() const
virtual TObjArray * GetElements() const =0
RVec< PromoteTypes< T0, T1 > > fmod(const T0 &x, const RVec< T1 > &v)
Double_t CosH(Double_t)
Returns the hyperbolic cosine of x.
Double_t ACos(Double_t)
Returns the principal value of the arc cosine of x, expressed in radians.
Double_t ASin(Double_t)
Returns the principal value of the arc sine of x, expressed in radians.
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Double_t ATan(Double_t)
Returns the principal value of the arc tangent of x, expressed in radians.
Double_t ASinH(Double_t)
Returns the area hyperbolic sine of x.
Double_t TanH(Double_t)
Returns the hyperbolic tangent of x.
Double_t ACosH(Double_t)
Returns the nonnegative area hyperbolic cosine of x.
Double_t ATan2(Double_t y, Double_t x)
Returns the principal value of the arc tangent of y/x, expressed in radians.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Double_t SignalingNaN()
Returns a signaling NaN as defined by IEEE 754](http://en.wikipedia.org/wiki/NaN#Signaling_NaN).
Double_t Tan(Double_t)
Returns the tangent of an angle of x radians.
Double_t ATanH(Double_t)
Returns the area hyperbolic tangent of x.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Double_t SinH(Double_t)
Returns the hyperbolic sine of `x.
static uint64_t sum(uint64_t i)