110class TDimensionInfo :
public TObject {
117 : fCode(code), fOper(oper),
fSize(size), fMultiDim(multiDim) {};
118 ~TDimensionInfo() {};
124 fDidBooleanOptimization(
kFALSE), fDimensionSetup(0)
158 fDidBooleanOptimization(
kFALSE), fDimensionSetup(0)
167 const std::vector<std::string>& aliases)
169 fDidBooleanOptimization(
kFALSE), fDimensionSetup(0), fAliasesUsed(aliases)
209 if(savedir) savedir->
cd();
214 Warning(
"TTreeFormula",
"Too many items in expression:%s",expression);
224 if (!leafc)
continue;
267 for(k0 = 0; k0 <
fNcodes; k0++) {
272 Error(
"TTreeFormula",
273 "Index %d for dimension #%d in %s is too high (max is %d)",
276 if(savedir) savedir->
cd();
305 if (readentry >= 0) {
310 if (readentry >= 0) {
317 if(savedir) savedir->
cd();
339 for (
int j=0; j<
fNcodes; j++) {
367 bool scalarindex =
false;
373 switch (index_multiplicity) {
404 const char * current;
405 Int_t size, scanindex, vardim;
413 if (current[0] !=
'[') current--;
416 scanindex = sscanf(current,
"%d",&size);
420 if (scanindex==0) size = -1;
429 current = (
char*)strstr( current,
"[" );
439 TDimensionInfo * info =
new TDimensionInfo(code,
fNoper,size,multidim);
443 return (size==-1) ? 1 : 0;
451 Bool_t useCollectionObject) {
452 Int_t ndim, size, current, vardim;
484 if (maininfo==0 || maininfo==leafinfo || 1) {
490 delete currentinfo->
fNext;
515 }
else if (
c &&
c->GetReferenceProxy() &&
c->GetReferenceProxy()->HasCounter() ) {
546 }
while (current<ndim);
583 Int_t numberOfVarDim = 0;
588 const char *tname = leaf->
GetTitle();
589 char *leaf_dim = (
char*)strstr( tname,
"[" );
592 char *branch_dim = (
char*)strstr(bname,
"[");
593 if (branch_dim) branch_dim++;
605 if (!branch_dim || strncmp(branch_dim,leaf_dim,strlen(branch_dim))) {
608 }
else if (branch_dim && strncmp(branch_dim,leaf_dim,strlen(branch_dim))==0
609 && strlen(leaf_dim)>strlen(branch_dim)
610 && (leaf_dim+strlen(branch_dim))[0]==
'[') {
629 "Noticed an incorrect in-memory TBranchElement object (%s).\nIt has a BranchCount2 but no BranchCount!\nThe result might be incorrect!",
631 return numberOfVarDim;
637 "Already in kDataMember mode when handling multiple variable dimensions");
645 return numberOfVarDim;
658 static const char *altfunc =
"Alt$(";
659 static const char *minfunc =
"MinIf$(";
660 static const char *maxfunc =
"MaxIf$(";
664 if ( strncmp(expression,altfunc,strlen(altfunc))==0
665 && expression[strlen(expression)-1]==
')' ) {
667 start = strlen(altfunc);
669 if ( strncmp(expression,maxfunc,strlen(maxfunc))==0
670 && expression[strlen(expression)-1]==
')' ) {
672 start = strlen(maxfunc);
674 if ( strncmp(expression,minfunc,strlen(minfunc))==0
675 && expression[strlen(expression)-1]==
')' ) {
677 start = strlen(minfunc);
687 for(
unsigned int i=start;i<strlen(expression);++i) {
688 switch (expression[i]) {
689 case '(': paran++;
break;
690 case ')': paran--;
break;
691 case '"': instr = instr ? 0 : 1;
break;
692 case '[': brack++;
break;
693 case ']': brack--;
break;
695 if (expression[i]==
',' && paran==0 && instr==0 && brack==0) {
696 part1 = full( start, i-start );
697 part2 = full( i+1, full.
Length() -1 - (i+1) );
709 Error(
"DefinedVariable",
"The 2nd arguments in %s can not be an array (%s,%d)!",
718 Error(
"DefinedVariable",
719 "The 2nd arguments in %s has to return the same type as the 1st argument (string)!",
725 Error(
"DefinedVariable",
726 "The 2nd arguments in %s has to return the same type as the 1st argument (numerical type)!",
735 Error(
"DefinedVariable",
736 "The arguments of %s can not be strings!",
767 Int_t numberOfVarDim = 0;
770 char scratch[
kMaxLen]; scratch[0] =
'\0';
771 char work[
kMaxLen]; work[0] =
'\0';
773 const char *right = subExpression;
778 if (readentry < 0) readentry=0;
780 Bool_t useLeafReferenceObject =
false;
791 Error(
"DefinedVariable",
"Missing StreamerInfo for %s. We will be unable to read!",
803 Error(
"DefinedVariable",
"Missing StreamerInfo for %s."
804 " We will be unable to read!",
809 Error(
"DefinedVariable",
"Address not set when the type of the branch is negative for for %s. We will be unable to read!", mom->
GetName());
822 const char* alias = 0;
825 if (!alias && realtree!=
fTree) {
833 TTree *tleaf = realtree;
840 if (mother_name[strlen(mother_name)-1]!=
'.') {
841 br_extended_name = mother_name;
842 br_extended_name.
Append(
'.');
847 if (dim >= 0) br_extended_name.
Remove(dim);
935 "Missing TStreamerElement in object in TClonesArray section");
946 maininfo = clonesinfo;
965 maininfo->
fNext = previnfo;
966 unwindCollection =
kTRUE;
968 }
else if (branchEl->
GetType()==41) {
973 Warning(
"DefinedVariable",
"Missing TStreamerElement in object in Collection section");
979 if ( count->
GetID() >= 0 ) {
998 maininfo = collectioninfo;
1017 maininfo->
fNext = previnfo;
1018 unwindCollection =
kTRUE;
1020 }
else if ( branchEl->
GetType()==3) {
1022 if (useLeafCollectionObject) {
1027 numberOfVarDim +=
RegisterDimensions(code,clonesinfo,maininfo,useLeafCollectionObject);
1030 maininfo = clonesinfo;
1031 previnfo = maininfo;
1033 }
else if (!useLeafCollectionObject && branchEl->
GetType()==4) {
1036 if (useLeafCollectionObject) {
1041 numberOfVarDim +=
RegisterDimensions(code,collectioninfo,maininfo,useLeafCollectionObject);
1044 maininfo = collectioninfo;
1045 previnfo = maininfo;
1049 if (useLeafCollectionObject) {
1052 maininfo = collectioninfo;
1053 previnfo = collectioninfo;
1060 maininfo = collectioninfo;
1061 previnfo = collectioninfo;
1071 previnfo->
fNext = multi;
1074 previnfo = multi->
fNext;
1082 previnfo = previnfo->
fNext;
1088 }
else if (strlen(right)==0 && cl && element &&
final) {
1091 if (!useLeafCollectionObject
1102 maininfo = collectioninfo;
1103 previnfo = collectioninfo;
1112 previnfo->
fNext = multi;
1115 previnfo = multi->
fNext;
1122 previnfo = previnfo->
fNext;
1125 }
else if (!useLeafCollectionObject
1141 collectioninfo->
fNext =
1144 maininfo = collectioninfo;
1145 previnfo = maininfo->
fNext;
1147 }
else if (!useLeafCollectionObject
1158 previnfo = maininfo;
1163 if ( useLeafCollectionObject || fullExpression[0] ==
'@' || fullExpression[strlen(scratch)] ==
'@' ) {
1164 useLeafReferenceObject =
true;
1181 Error(
"DefinedVariable",
"Failed to access class type of reference target (%s)",element->
GetName());
1192 if (unwindCollection) {
1195 R__ASSERT(numberOfVarDim==1 && maininfo);
1202 previnfo->
fNext = multi;
1205 previnfo = multi->
fNext;
1212 previnfo = previnfo->
fNext;
1220 previnfo->
fNext = multi;
1223 previnfo = multi->
fNext;
1232 Int_t nchname = strlen(right);
1247 Error(
"DefinedVariable",
"%s does not inherit from %s. Casting not possible!",
1254 maininfo = leafinfo;
1257 previnfo = leafinfo;
1259 previnfo->
fNext = leafinfo;
1260 previnfo = leafinfo;
1265 castqueue.
AddAt(0,paran_level);
1269 Bool_t prevUseCollectionObject = useLeafCollectionObject;
1270 Bool_t useCollectionObject = useLeafCollectionObject;
1271 Bool_t useReferenceObject = useLeafReferenceObject;
1272 Bool_t prevUseReferenceObject = useLeafReferenceObject;
1273 for (i=0, current = &(work[0]); i<=nchname;i++ ) {
1275 if (right[i] ==
'(') {
1278 *current++ = right[i++];
1279 }
while(right[i]!=
')' && right[i]);
1280 *current++ = right[i];
1282 char *params = strchr(work,
'(');
1284 *params = 0; params++;
1285 }
else params = (
char *)
")";
1287 Error(
"DefinedVariable",
"Can not call '%s' with a class",work);
1291 Error(
"DefinedVariable",
"Class probably unavailable:%s",cl->
GetName());
1318 previnfo = clonesinfo;
1319 maininfo = clonesinfo;
1351 previnfo = collectioninfo;
1352 maininfo = collectioninfo;
1357 if (inside_cl) cl = inside_cl;
1359 Warning(
"DefinedVariable",
"Can not call method on content of %s in %s\n",
1366 Error(
"DefinedVariable",
1367 "Could not discover the TClass corresponding to (%s)!",
1371 method =
new TMethodCall(cl,
"GetEntriesFast",
"");
1375 if (useLeafCollectionObject) {
1381 maininfo=previnfo=collectioninfo;
1387 Error(
"DefinedVariable",
1388 "Can not call method %s on class without dictionary (%s)!",
1396 Error(
"DefinedVariable",
"Unknown method:%s in %s",right,cl->
GetName());
1421 Error(
"DefineVariable",
"Method %s from %s has an impossible return type %d",
1427 maininfo = leafinfo;
1430 previnfo = leafinfo;
1432 previnfo->
fNext = leafinfo;
1433 previnfo = leafinfo;
1436 current = &(work[0]);
1438 prevUseCollectionObject =
kFALSE;
1439 prevUseReferenceObject =
kFALSE;
1440 useCollectionObject =
kFALSE;
1443 if (numberOfVarDim>1) {
1444 Warning(
"DefinedVariable",
"TTreeFormula support only 2 level of variables size collections. Assuming '@' notation for the collection %s.",
1447 useCollectionObject =
kTRUE;
1448 }
else if (numberOfVarDim==0) {
1452 }
else if (numberOfVarDim==1) {
1457 previnfo->
fNext = leafinfo;
1458 previnfo = leafinfo;
1464 previnfo->
fNext = leafinfo;
1465 previnfo = leafinfo;
1469 }
else if (right[i] ==
')') {
1472 TClass * casted = (
TClass*) ((
int(--paran_level)>=0) ? castqueue.
At(paran_level) : 0);
1478 maininfo = leafinfo;
1481 previnfo = leafinfo;
1483 previnfo->
fNext = leafinfo;
1484 previnfo = leafinfo;
1487 current = &(work[0]);
1494 }
else if (i > 0 && (right[i] ==
'.' || right[i] ==
'[' || right[i] ==
'\0') ) {
1501 if (strlen(work)==0)
continue;
1503 prevUseCollectionObject = useCollectionObject;
1504 prevUseReferenceObject = useReferenceObject;
1506 useReferenceObject =
kTRUE;
1507 useCollectionObject =
kTRUE;
1509 for(
l=0;work[
l+1]!=0;++
l) work[
l] = work[
l+1];
1511 }
else if (work[strlen(work)-1]==
'@') {
1512 useReferenceObject =
kTRUE;
1513 useCollectionObject =
kTRUE;
1514 work[strlen(work)-1] =
'\0';
1516 useReferenceObject =
kFALSE;
1517 useCollectionObject =
kFALSE;
1528 prevUseReferenceObject =
kFALSE;
1531 previnfo = previnfo->
fNext;
1535 for(
Long64_t entry=0; entry<leaf->
GetBranch()->GetEntries()-readentry; ++entry) {
1573 previnfo = clonesinfo;
1574 maininfo = clonesinfo;
1578 Error(
"DefinedVariable",
"Unimplemented usage of ClonesArray");
1589 "TClonesArray object was not retrievable for %s!",
1598 if (1 || inside_cl) cl = inside_cl;
1600 if (0 && strlen(work)==0) {
1634 previnfo = collectioninfo;
1635 maininfo = collectioninfo;
1644 Error(
"DefinedVariable",
"Could you not find the inner class for %s with coll type = %d",
1648 Warning(
"DefinedVariable",
"No data member in content of %s in %s\n",
1657 Warning(
"DefinedVariable",
"Missing class for %s!",
name.Data());
1662 if (!element && !prevUseCollectionObject) {
1669 Int_t clones_offset = 0;
1677 previnfo->
fNext = clonesinfo;
1679 previnfo->
fNext = 0;
1691 if (maininfo==0) maininfo = leafinfo;
1692 if (previnfo==0) previnfo = leafinfo;
1694 previnfo->
fNext = leafinfo;
1695 previnfo = leafinfo;
1703 Int_t coll_offset = 0;
1712 if (numberOfVarDim>1) {
1713 Warning(
"DefinedVariable",
"TTreeFormula support only 2 level of variables size collections. Assuming '@' notation for the collection %s.",
1716 useCollectionObject =
kTRUE;
1717 }
else if (numberOfVarDim==1) {
1729 if (maininfo==0) maininfo = leafinfo;
1730 if (previnfo==0) previnfo = leafinfo;
1732 previnfo->
fNext = leafinfo;
1733 previnfo = leafinfo;
1735 if (leafinfo->
fNext) {
1736 previnfo = leafinfo->
fNext;
1751 if (numberOfVarDim>=1 &&
type>40) {
1756 if (leafinfo &&
type<=40 ) {
1796 Error(
"DefinedVariable",
1797 "%s is a datamember of %s BUT is not yet of a supported type (%d)",
1802 Error(
"DefinedVariable",
1803 "%s is a datamember of %s BUT is not of a unknown type (%d)",
1808 if (
object && !useCollectionObject &&
1814 if (
object && leafinfo) {
1816 }
else if (objarr) {
1831 if (numberOfVarDim>1) {
1832 Warning(
"DefinedVariable",
"TTreeFormula support only 2 level of variables size collections. Assuming '@' notation for the collection %s.",
1835 useCollectionObject =
kTRUE;
1836 }
else if (numberOfVarDim==1) {
1856 else leafinfo->
fNext = info;
1863 if (!maininfo) maininfo = leafinfo;
1868 if (previnfo==0) previnfo = leafinfo;
1870 previnfo->
fNext = leafinfo;
1871 previnfo = leafinfo;
1886 else leafinfo->
fNext = info;
1902 prevUseReferenceObject =
kFALSE;
1905 }
else if (pointer) {
1917 if (cl)
Error(
"DefinedVariable",
"%s is not a datamember of %s",work,cl->
GetName());
1924 maininfo = leafinfo;
1927 previnfo = leafinfo;
1928 }
else if (previnfo!=leafinfo) {
1929 previnfo->
fNext = leafinfo;
1930 previnfo = leafinfo;
1932 while (previnfo->
fNext) previnfo = previnfo->
fNext;
1934 if ( right[i] !=
'\0' ) {
1935 if ( !needClass && mustderef ) {
1941 if ( inf->IsReference() ) {
1952 Error(
"DefinedVariable",
"Failed to access class type of reference target (%s)",element->
GetName());
1958 Error(
"DefinedVariable",
"Failed to access class type of reference target (%s)",element->
GetName());
1962 else if ( needClass ) {
1966 if (mustderef) leafinfo = 0;
1967 current = &(work[0]);
1976 nchname = strlen(right);
1980 *current++ = right[i];
1989 if (strlen(work)!=0) {
2001 if (!last)
return action;
2005 if (last && last->
GetClass() != objClass) {
2017 last->
fNext = collectioninfo;
2029 if (!last)
return action;
2033 const char *funcname = 0;
2037 }
else if (objClass == stdStringClass) {
2080 method =
new TMethodCall(objClass,
"AsString",
"");
2133 const char *funcname = 0;
2136 }
else if (objClass == stdStringClass) {
2176 if (readentry < 0) readentry=0;
2177 const char *cname = expression;
2180 char right[
kMaxLen*2]; right[0] =
'\0';
2181 char work[
kMaxLen]; work[0] =
'\0';
2182 char left[
kMaxLen]; left[0] =
'\0';
2185 std::string currentname;
2186 Int_t previousdot = 0;
2189 TBranch *branch=0, *tmp_branch=0;
2190 Int_t nchname = strlen(cname);
2195 for (i=0, current = &(work[0]); i<=nchname && !
final;i++ ) {
2197 *current++ = cname[i];
2199 if (cname[i] ==
'(') {
2202 if (current==work+1) {
2205 startWithParan =
kTRUE;
2217 if (cname[i] ==
')') {
2218 if (paran_level==0) {
2219 Error(
"DefinedVariable",
"Unmatched paranthesis in %s",fullExpression);
2224 if (startWithParan) {
2234 current = &(work[0]);
2238 }
else if (
gROOT->GetType(cast_name)) {
2240 current = &(work[0]);
2243 "Casting to primary types like \"%s\" is not supported yet",cast_name.
Data());
2250 char *params = strchr(work,
'(');
2252 *params = 0; params++;
2254 if (branch && !leaf) {
2266 while (!leaf && (leafcur = (
TLeaf*) next())) {
2276 if (strlen(left) && left[strlen(left)-1]==
'.') left[strlen(left)-1]=0;
2278 if (aliasValue && strcspn(aliasValue,
"+*/-%&!=<>|")==strlen(aliasValue)) {
2281 if (find(aliasUsed.begin(),
2283 left) != aliasUsed.end()) {
2284 Error(
"DefinedVariable",
2285 "The substitution of the branch alias \"%s\" by \"%s\" in \"%s\" failed\n"\
2286 "\tbecause \"%s\" is used [recursively] in its own definition!",
2287 left,aliasValue,fullExpression,left);
2290 aliasUsed.push_back(left);
2291 TString newExpression = aliasValue;
2292 newExpression += (cname+strlen(left));
2294 castqueue, aliasUsed, useLeafCollectionObject, fullExpression);
2296 Error(
"DefinedVariable",
2297 "The substitution of the alias \"%s\" by \"%s\" failed.",left,aliasValue);
2314 strlcpy(right,work,2*
kMaxLen);
2315 strncat(right,
"(",2*
kMaxLen-1-strlen(right));
2316 strncat(right,params,2*
kMaxLen-1-strlen(right));
2320 i += strlen(params);
2323 current = &(work[0]);
2328 if (cname[i] ==
'.' || cname[i] ==
'\0' || cname[i] ==
')') {
2333 Int_t len = strlen(work);
2335 foundAtSign =
kTRUE;
2337 for(
l=0;work[
l+1]!=0;++
l) work[
l] = work[
l+1];
2340 }
else if (len>=2 && work[len-2]==
'@') {
2341 foundAtSign =
kTRUE;
2342 work[len-2] = cname[i];
2349 if (left[0]==0) strlcpy(left,work,
kMaxLen);
2350 if (!leaf && !branch) {
2354 std::string treename(
first);
2355 if (treename.size() && treename[treename.size()-1]==
'.') {
2356 treename.erase(treename.size()-1);
2358 if (treename==
"This" ) {
2363 if (cname[i]) leftover = &(cname[i+1]);
2409 useLeafCollectionObject = foundAtSign;
2411 current = &(work[0]);
2414 else if (branch && (foundAtSign || cname[i] != 0) ) {
2428 useLeafCollectionObject = foundAtSign;
2430 current = &(work[0]);
2440 useLeafCollectionObject = foundAtSign;
2442 current = &(work[0]);
2444 }
else if (leaf || branch) {
2445 if (leaf && branch) {
2459 current = &(work[0]);
2472 if (foundAtSign) strncat(right,
"@",2*
kMaxLen-1-strlen(right));
2473 if (cname[i]==
'.') strncat(right,
".",2*
kMaxLen-1-strlen(right));
2476 current = &(work[0]);
2479 }
else if (cname[i] ==
'.') {
2486 while(!branch && (branchcur=(
TBranch*)next()) ) {
2491 current = &(work[0]);
2498 Error(
"DefinedVariable",
"Unexpected control flow!");
2504 if (cname[i]) work[strlen(work)-1] =
'\0';
2509 currentname = &(work[previousdot+1]);
2516 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch);
2517 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch2);
2518 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(currentname.c_str());
2528 if (!tmp_branch) tmp_branch = branch->
FindBranch(scratch);
2529 if (!tmp_branch) tmp_branch = branch->
FindBranch(scratch2);
2530 if (!tmp_branch) tmp_branch = branch->
FindBranch(currentname.c_str());
2538 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch);
2539 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch2);
2540 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(currentname.c_str());
2554 useLeafCollectionObject = foundAtSign;
2558 current = &(work[0]);
2564 Int_t where = strlen(work);
2566 work[where+1] = cname[i];
2568 previousdot = where+1;
2570 previousdot = strlen(work);
2571 work[strlen(work)] = cname[i];
2581 strncat(right,work,2*
kMaxLen-1-strlen(right));
2585 if (strlen(right) && right[strlen(right)-1]!=
'.' && cname[i]!=
'.') {
2589 strncat(right,
".",2*
kMaxLen-1-strlen(right));
2591 strncat(right,&cname[i],2*
kMaxLen-1-strlen(right));
2594 if (!
final && branch) {
2597 if (!leaf)
return -1;
2603 if (strlen(right)==0) strlcpy(right,work,2*
kMaxLen);
2606 if (leaf==0 && left[0]!=0) {
2607 if (left[strlen(left)-1]==
'.') left[strlen(left)-1]=0;
2611 if (aliasValue && strcspn(aliasValue,
"()[]+*/-%&!=<>|")==strlen(aliasValue)) {
2614 if (find(aliasUsed.begin(),
2616 left) != aliasUsed.end()) {
2617 Error(
"DefinedVariable",
2618 "The substitution of the branch alias \"%s\" by \"%s\" in \"%s\" failed\n"\
2619 "\tbecause \"%s\" is used [recursively] in its own definition!",
2620 left,aliasValue,fullExpression,left);
2623 aliasUsed.push_back(left);
2624 TString newExpression = aliasValue;
2625 newExpression += (cname+strlen(left));
2627 castqueue, aliasUsed, useLeafCollectionObject, fullExpression);
2629 Error(
"DefinedVariable",
2630 "The substitution of the alias \"%s\" by \"%s\" failed.",left,aliasValue);
2681 if (!
fTree)
return -1;
2687 if (
name ==
"Entry$") {
2693 if (
name ==
"LocalEntry$") {
2699 if (
name ==
"Entries$") {
2707 if (
name ==
"LocalEntries$") {
2715 if (
name ==
"Iteration$") {
2721 if (
name ==
"Length$") {
2727 static const char *
lenfunc =
"Length$(";
2728 if (strncmp(
name.Data(),
"Length$(",strlen(
lenfunc))==0
2740 static const char *minfunc =
"Min$(";
2741 if (strncmp(
name.Data(),
"Min$(",strlen(minfunc))==0
2753 static const char *maxfunc =
"Max$(";
2754 if (strncmp(
name.Data(),
"Max$(",strlen(maxfunc))==0
2766 static const char *sumfunc =
"Sum$(";
2767 if (strncmp(
name.Data(),
"Sum$(",strlen(sumfunc))==0
2786 if (res<0)
return res;
2794 char dims[
kMaxLen]; dims[0] =
'\0';
2802 Int_t cnamelen = strlen(cname);
2803 for(i=0,k=0; i<cnamelen; ++i, ++k) {
2804 if (cname[i] ==
'[') {
2806 int bracket_level = 1;
2808 for (j=++i; j<cnamelen && (bracket_level>0 || cname[j]==
'['); j++, i++) {
2809 if (cname[j]==
'[') bracket_level++;
2810 else if (cname[j]==
']') bracket_level--;
2812 if (bracket_level != 0) {
2816 strncat(dims,&cname[bracket],j-bracket);
2819 if (i!=k) cname[k] = cname[i];
2828 res =
FindLeafForExpression(cname, leaf, leftover,
final, paran_level, castqueue, aliasSofar, useLeafCollectionObject,
name);
2830 if (res<0)
return res;
2832 if (!leaf && res!=2) {
2841 Error(
"DefinedVariable",
2842 "The substitution of the alias \"%s\" by \"%s\" failed\n"\
2843 "\tbecause \"%s\" is recursively used in its own definition!",
2844 cname,aliasValue,cname);
2849 if (strcspn(aliasValue,
"()+*/-%&!=<>|")!=strlen(aliasValue)) {
2855 aliasSofar.push_back( cname );
2857 TString subValue( aliasValue );
2866 Error(
"DefinedVariable",
2867 "The substitution of the alias \"%s\" by \"%s\" failed.",cname,aliasValue);
2882 TString thisAlias( aliasValue );
2890 Error(
"Compile",
" Bad numerical expression : \"%s\"",thisAlias.
Data());
2891 }
else if (aliasRes==-2) {
2892 Error(
"Compile",
" Part of the Variable \"%s\" exists but some of it is not accessible or useable",thisAlias.
Data());
2895 Error(
"DefinedVariable",
2896 "The substitution of the alias \"%s\" by \"%s\" failed.",cname,aliasValue);
2905 if (leaf || res==2) {
2908 Error(
"DefinedVariable",
"the branch \"%s\" has to be enabled to be used",leaf->
GetBranch()->
GetName());
2917 char *current = &( dims[0] );
2924 if (current[0] ==
']') {
2927 scanindex = sscanf(current,
"%d",&index);
2933 char *end = (
char*)(varindex.
Data());
2934 for(
char bracket_level = 0;*end!=0;end++) {
2935 if (*end==
'[') bracket_level++;
2936 if (bracket_level==0 && *end==
']')
break;
2937 if (*end==
']') bracket_level--;
2947 current += strlen(varindex)+1;
2955 current = (
char*)strstr( current,
"[" );
2962 res =
ParseWithLeaf(leaf,leftover,
final,paran_level,castqueue,useLeafCollectionObject,
name);
2963 if (res<0)
return res;
2964 if (res>0) action = res;
2992 }
else if (strlen(gcut->
GetVarX())) {
3001 for(
Int_t i2 = 1; i2<
n; i2++) {
3002 if (
x[i2] < min) min =
x[i2];
3003 if (
x[i2] > max) max =
x[i2];
3022 Error(
"DefinedVariable",
"Found a TCutG without leaf information (%s)",
3059 while ((leafcur = (
TLeaf*)nextleaf())) {
3087 if (clonesinfo) {
delete clonesinfo; clonesinfo = 0; }
3111 if (clones) cl = clones->
GetClass();
3153 leafinfo = clonesinfo;
3165 Int_t clones_offset = 0;
3170 else leafinfo->
fNext = sub_clonesinfo;
3171 else leafinfo = sub_clonesinfo;
3177 delete leafinfo; clonesinfo = 0;
3182 if (!clones)
continue;
3243 }
else if (
type > 60) {
3302 Error(
"BranchHasMethod",
"A TClonesArray was stored in a branch type no yet support (i.e. neither TBranchObject nor TBranchElement): %s",branch->IsA()->
GetName());
3305 cl = clones ? clones->
GetClass() : 0;
3339 Int_t real_instance = 0;
3374 if (local_index<0) {
3375 Error(
"EvalInstance",
"Index %s is out of bound (%d) in formula %s",
3382 real_instance = local_index *
fCumulSizes[codeindex][1];
3407 if (local_index<0) {
3408 Error(
"EvalInstance",
"Index %s is out of bound (%d) in formula %s",
3428 if (check)
return fNdata[0]+1;
3433 }
while(
instance >= virt_accum && local_index<maxloop);
3439 if (local_index==(maxloop-1) && (
instance >= virt_accum)) {
3441 if (check)
return fNdata[0]+1;
3447 if (check)
return fNdata[0]+1;
3455 local_index =
fIndexes[codeindex][0];
3482 if (
fIndexes[codeindex][vdim]>=0) {
3485 if (isize!=1 &&
fIndexes[codeindex][vdim]>isize) {
3490 for(
Int_t k=vdim -1; k>0; --k) {
3494 real_instance = local_index *
fCumulSizes[codeindex][1];
3498 for (
Int_t dim = 1; dim < max_dim; dim++) {
3509 if (
fIndexes[codeindex][dim]==-2) {
3516 if (local_index<0 ||
3518 Error(
"EvalInstance",
"Index %s is out of bound (%d/%d) in formula %s",
3526 real_instance += local_index *
fCumulSizes[codeindex][dim+1];
3530 if (
fIndexes[codeindex][max_dim]>=0) {
3531 if (!info) real_instance +=
fIndexes[codeindex][max_dim];
3539 if (info && local_index>=
fCumulSizes[codeindex][max_dim]) {
3543 if (
fIndexes[codeindex][max_dim]==-2) {
3549 if (local_index<0 ||
3551 Error(
"EvalInstance",
"Index %s is of out bound (%d/%d) in formula %s",
3559 real_instance += local_index;
3564 return real_instance;
3662 else if (real_instance>=
fNdata[0])
return 0;
3668 if (real_instance) {
3669 Warning(
"EvalObject",
"Not yet implement for kDirect and arrays (for %s).\nPlease contact the developers",
GetName());
3688 const Int_t kMAXSTRINGFOUND = 10;
3689 const char *stringStack[kMAXSTRINGFOUND];
3700 }
else if (real_instance>=
fNdata[0]) {
3713 return stringStack[0];
3716#define TT_EVAL_INIT \
3717 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(0); \
3719 const Int_t real_instance = GetRealInstance(instance,0); \
3721 if (instance==0) fNeedLoading = kTRUE; \
3722 if (real_instance>=fNdata[0]) return 0; \
3728 if (fNeedLoading) { \
3729 fNeedLoading = kFALSE; \
3730 TBranch *br = leaf->GetBranch(); \
3731 Long64_t tentry = br->GetTree()->GetReadEntry(); \
3732 R__LoadBranch(br,tentry,fQuickLoad); \
3739 if (fLookupType[0]==kDirect) { \
3740 label = (char*)leaf->GetValuePointer(); \
3742 label = (char*)GetLeafInfo(0)->GetValuePointer(leaf,instance); \
3744 Int_t bin = fAxis->FindBin(label); \
3748#define TREE_EVAL_INIT \
3749 const Int_t real_instance = GetRealInstance(instance,0); \
3751 if (real_instance>=fNdata[0]) return 0; \
3757 label = (char*)GetLeafInfo(0)->GetValuePointer((TLeaf*)0x0,instance); \
3758 Int_t bin = fAxis->FindBin(label); \
3762#define TT_EVAL_INIT_LOOP \
3763 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(code); \
3766 const Int_t real_instance = GetRealInstance(instance,code); \
3769 TBranch *branch = (TBranch*)fBranches.UncheckedAt(code); \
3771 Long64_t treeEntry = branch->GetTree()->GetReadEntry(); \
3772 R__LoadBranch(branch,treeEntry,fQuickLoad); \
3773 } else if (fDidBooleanOptimization) { \
3774 branch = leaf->GetBranch(); \
3775 Long64_t treeEntry = branch->GetTree()->GetReadEntry(); \
3776 if (branch->GetReadEntry() != treeEntry) branch->GetEntry( treeEntry ); \
3782 if (fDidBooleanOptimization) { \
3783 TBranch *br = leaf->GetBranch(); \
3784 Long64_t treeEntry = br->GetTree()->GetReadEntry(); \
3785 if (br->GetReadEntry() != treeEntry) br->GetEntry( treeEntry ); \
3788 if (real_instance>=fNdata[code]) return 0;
3790#define TREE_EVAL_INIT_LOOP \
3792 const Int_t real_instance = GetRealInstance(instance,code); \
3794 if (real_instance>=fNdata[code]) return 0;
3800 for (
int i=0; i<len; ++i) res +=
sum->EvalInstance<
T>(i);
3809 for (
int i=1; i<len; ++i) {
3824 for (
int i=1; i<len; ++i) {
3843 }
while (!condval && i<len);
3844 if (!condval && i==len) {
3853 for (; i<len; ++i) {
3875 }
while (!condval && i<len);
3876 if (!condval && i==len) {
3885 for (; i<len; ++i) {
3900template <
typename T>
T fmod_local(
T x,
T y) {
return fmod(
x,
y); }
3917 if( !strncmp(
fExpr[op],
"0x", 2) || !strncmp(
fExpr[op],
"0X", 2) ) {
3919 sscanf(
fExpr[op],
"%llx", &val );
3945 return leaf->GetTypedValue<
T>(real_instance);
4003 const Int_t kMAXSTRINGFOUND = 10;
4004 const char *stringStackLocal[kMAXSTRINGFOUND];
4005 const char **stringStack = stringStackArg?stringStackArg:stringStackLocal;
4021 if (newaction==
kConstant) { pos++; tab[pos-1] = GetConstant<T>(oper &
kTFOperMask);
continue; }
4025 case kEnd :
return tab[0];
4026 case kAdd : pos--; tab[pos-1] += tab[pos];
continue;
4027 case kSubstract : pos--; tab[pos-1] -= tab[pos];
continue;
4028 case kMultiply : pos--; tab[pos-1] *= tab[pos];
continue;
4029 case kDivide : pos--;
if (tab[pos] == 0) tab[pos-1] = 0;
4030 else tab[pos-1] /= tab[pos];
4035 tab[pos-1] =
T(int1 % int2);
4055 case kacosh:
if (tab[pos-1] < 1) {tab[pos-1] = 0;}
4064 case kfmod : pos--; tab[pos-1] = fmod_local(tab[pos-1],tab[pos]);
continue;
4065 case kpow : pos--; tab[pos-1] =
TMath::Power(tab[pos-1],tab[pos]);
continue;
4066 case ksq : tab[pos-1] = tab[pos-1]*tab[pos-1];
continue;
4069 case kstrstr : pos2 -= 2; pos++;
if (strstr(stringStack[pos2],stringStack[pos2+1])) tab[pos-1]=1;
4073 case kmin : pos--; tab[pos-1] = std::min(tab[pos-1],tab[pos]);
continue;
4074 case kmax : pos--; tab[pos-1] = std::max(tab[pos-1],tab[pos]);
continue;
4076 case klog :
if (tab[pos-1] > 0) tab[pos-1] =
TMath::Log(tab[pos-1]);
4077 else {tab[pos-1] = 0;}
4080 if (dexp < -700) {tab[pos-1] = 0;
continue;}
4081 if (dexp > 700) {tab[pos-1] =
TMath::Exp(700);
continue;}
4085 else {tab[pos-1] = 0;}
4091 case ksign :
if (tab[pos-1] < 0) tab[pos-1] = -1;
else tab[pos-1] = 1;
4094 case kSignInv: tab[pos-1] = -1 * tab[pos-1];
continue;
4097 case kAnd : pos--;
if (tab[pos-1]!=0 && tab[pos]!=0) tab[pos-1]=1;
4100 case kOr : pos--;
if (tab[pos-1]!=0 || tab[pos]!=0) tab[pos-1]=1;
4104 case kEqual : pos--; tab[pos-1] = (tab[pos-1] == tab[pos]) ? 1 : 0;
continue;
4105 case kNotEqual : pos--; tab[pos-1] = (tab[pos-1] != tab[pos]) ? 1 : 0;
continue;
4106 case kLess : pos--; tab[pos-1] = (tab[pos-1] < tab[pos]) ? 1 : 0;
continue;
4107 case kGreater : pos--; tab[pos-1] = (tab[pos-1] > tab[pos]) ? 1 : 0;
continue;
4108 case kLessThan : pos--; tab[pos-1] = (tab[pos-1] <= tab[pos]) ? 1 : 0;
continue;
4109 case kGreaterThan: pos--; tab[pos-1] = (tab[pos-1] >= tab[pos]) ? 1 : 0;
continue;
4110 case kNot : tab[pos-1] = (tab[pos-1] != 0) ? 0 : 1;
continue;
4112 case kStringEqual : pos2 -= 2; pos++;
if (!strcmp(stringStack[pos2+1],stringStack[pos2])) tab[pos-1]=1;
4115 case kStringNotEqual: pos2 -= 2; pos++;
if (strcmp(stringStack[pos2+1],stringStack[pos2])) tab[pos-1]=1;
4140 pos2++; stringStack[pos2-1] = (
char*)
fExpr[i].Data();
4154 int op = param % 10;
4156 if (op == 1 && (!tab[pos-1]) ) {
4165 }
else if (op == 2 && tab[pos-1] ) {
4176 int toskip = param / 10;
4187 int fno = param / 1000;
4188 int nargs = param % 1000;
4196 UInt_t argloc = pos-nargs;
4197 for(
Int_t j=0;j<nargs;j++,argloc++,pos--) {
4198 SetMethodParam(method, tab[argloc]);
4221 switch (lookupType) {
4236 GetTypedValue<T>(leaf,real_instance);
continue; }
4238 GetTypedValue<T>((
TLeaf*)0x0,real_instance);
continue; }
4243 default: tab[pos++] = 0;
continue;
4256 tab[pos++] = gcut->
IsInside(xcut,ycut);
4285 tab[pos] = param; pos++;
4303 T param = FindMin<T>(primary,condition);
4305 tab[pos] = param; pos++;
4312 T param = FindMax<T>(primary,condition);
4314 tab[pos] = param; pos++;
4324 if (instance < primary->
GetNdata()) {
4330 tab[pos] = param; pos++;
4344 if (instance < primary->
GetNdata()) {
4382 if (real_instance>=
fNdata[string_code])
return 0;
4404template double TTreeFormula::EvalInstance<double> (
int,
char const**);
4405template long double TTreeFormula::EvalInstance<long double> (
int,
char const**);
4406template long long TTreeFormula::EvalInstance<long long> (
int,
char const**);
4472 Warning(
"GetValueFromMethod",
"No streamer info for branch %s.", branch->
GetName());
4482 thisobj = *((
char**) (address + offset));
4494 m->Execute(thisobj,
l);
4500 m->Execute(thisobj,
d);
4504 m->Execute(thisobj);
4532 Warning(
"GetValuePointerFromMethod",
"No streamer info for branch %s.", branch->
GetName());
4542 thisobj = *((
char**) (address + offset));
4554 m->Execute(thisobj,
l);
4560 m->Execute(thisobj,
d);
4566 m->Execute(thisobj, &
c);
4570 m->Execute(thisobj);
4725 if (indexname[strlen(indexname)-1] ==
'_' ) {
4737 if (bid < 0)
return kFALSE;