125 fDidBooleanOptimization(
kFALSE), fDimensionSetup(0)
159 fDidBooleanOptimization(
kFALSE), fDimensionSetup(0)
168 const std::vector<std::string>& aliases)
170 fDidBooleanOptimization(
kFALSE), fDimensionSetup(0), fAliasesUsed(aliases)
210 if(savedir) savedir->
cd();
215 Warning(
"TTreeFormula",
"Too many items in expression:%s",expression);
225 if (!leafc)
continue;
268 for(k0 = 0; k0 <
fNcodes; k0++) {
273 Error(
"TTreeFormula",
274 "Index %d for dimension #%d in %s is too high (max is %d)",
277 if(savedir) savedir->
cd();
306 if (readentry >= 0) {
311 if (readentry >= 0) {
318 if(savedir) savedir->
cd();
340 for (
int j=0; j<
fNcodes; j++) {
368 bool scalarindex =
false;
374 switch (index_multiplicity) {
405 const char * current;
414 if (current[0] !=
'[') current--;
417 scanindex = sscanf(current,
"%d",&
size);
421 if (scanindex==0)
size = -1;
430 current = (
char*)strstr( current,
"[" );
444 return (
size==-1) ? 1 : 0;
452 Bool_t useCollectionObject) {
485 if (maininfo==0 || maininfo==leafinfo || 1) {
491 delete currentinfo->
fNext;
516 }
else if (
c &&
c->GetReferenceProxy() &&
c->GetReferenceProxy()->HasCounter() ) {
547 }
while (current<ndim);
584 Int_t numberOfVarDim = 0;
589 const char *tname = leaf->
GetTitle();
590 char *leaf_dim = (
char*)strstr( tname,
"[" );
593 char *branch_dim = (
char*)strstr(bname,
"[");
594 if (branch_dim) branch_dim++;
606 if (!branch_dim || strncmp(branch_dim,leaf_dim,strlen(branch_dim))) {
609 }
else if (branch_dim && strncmp(branch_dim,leaf_dim,strlen(branch_dim))==0
610 && strlen(leaf_dim)>strlen(branch_dim)
611 && (leaf_dim+strlen(branch_dim))[0]==
'[') {
630 "Noticed an incorrect in-memory TBranchElement object (%s).\nIt has a BranchCount2 but no BranchCount!\nThe result might be incorrect!",
632 return numberOfVarDim;
638 "Already in kDataMember mode when handling multiple variable dimensions");
646 return numberOfVarDim;
659 static const char *altfunc =
"Alt$(";
660 static const char *minfunc =
"MinIf$(";
661 static const char *maxfunc =
"MaxIf$(";
665 if ( strncmp(expression,altfunc,strlen(altfunc))==0
666 && expression[strlen(expression)-1]==
')' ) {
668 start = strlen(altfunc);
670 if ( strncmp(expression,maxfunc,strlen(maxfunc))==0
671 && expression[strlen(expression)-1]==
')' ) {
673 start = strlen(maxfunc);
675 if ( strncmp(expression,minfunc,strlen(minfunc))==0
676 && expression[strlen(expression)-1]==
')' ) {
678 start = strlen(minfunc);
688 for(
unsigned int i=start;i<strlen(expression);++i) {
689 switch (expression[i]) {
690 case '(': paran++;
break;
691 case ')': paran--;
break;
692 case '"': instr = instr ? 0 : 1;
break;
693 case '[': brack++;
break;
694 case ']': brack--;
break;
696 if (expression[i]==
',' && paran==0 && instr==0 && brack==0) {
697 part1 = full( start, i-start );
698 part2 = full( i+1, full.Length() -1 - (i+1) );
710 Error(
"DefinedVariable",
"The 2nd arguments in %s can not be an array (%s,%d)!",
719 Error(
"DefinedVariable",
720 "The 2nd arguments in %s has to return the same type as the 1st argument (string)!",
726 Error(
"DefinedVariable",
727 "The 2nd arguments in %s has to return the same type as the 1st argument (numerical type)!",
736 Error(
"DefinedVariable",
737 "The arguments of %s can not be strings!",
768 Int_t numberOfVarDim = 0;
771 char scratch[
kMaxLen]; scratch[0] =
'\0';
772 char work[
kMaxLen]; work[0] =
'\0';
774 const char *right = subExpression;
779 if (readentry < 0) readentry=0;
781 Bool_t useLeafReferenceObject =
false;
792 Error(
"DefinedVariable",
"Missing StreamerInfo for %s. We will be unable to read!",
804 Error(
"DefinedVariable",
"Missing StreamerInfo for %s."
805 " We will be unable to read!",
810 Error(
"DefinedVariable",
"Address not set when the type of the branch is negative for for %s. We will be unable to read!", mom->
GetName());
823 const char* alias = 0;
826 if (!alias && realtree!=
fTree) {
834 TTree *tleaf = realtree;
841 if (mother_name[strlen(mother_name)-1]!=
'.') {
842 br_extended_name = mother_name;
843 br_extended_name.
Append(
'.');
848 if (dim >= 0) br_extended_name.
Remove(dim);
936 "Missing TStreamerElement in object in TClonesArray section");
947 maininfo = clonesinfo;
966 maininfo->
fNext = previnfo;
967 unwindCollection =
kTRUE;
969 }
else if (branchEl->
GetType()==41) {
974 Warning(
"DefinedVariable",
"Missing TStreamerElement in object in Collection section");
980 if ( count->
GetID() >= 0 ) {
999 maininfo = collectioninfo;
1018 maininfo->
fNext = previnfo;
1019 unwindCollection =
kTRUE;
1021 }
else if ( branchEl->
GetType()==3) {
1023 if (useLeafCollectionObject) {
1028 numberOfVarDim +=
RegisterDimensions(code,clonesinfo,maininfo,useLeafCollectionObject);
1031 maininfo = clonesinfo;
1032 previnfo = maininfo;
1034 }
else if (!useLeafCollectionObject && branchEl->
GetType()==4) {
1037 if (useLeafCollectionObject) {
1042 numberOfVarDim +=
RegisterDimensions(code,collectioninfo,maininfo,useLeafCollectionObject);
1045 maininfo = collectioninfo;
1046 previnfo = maininfo;
1050 if (useLeafCollectionObject) {
1053 maininfo = collectioninfo;
1054 previnfo = collectioninfo;
1061 maininfo = collectioninfo;
1062 previnfo = collectioninfo;
1072 previnfo->
fNext = multi;
1075 previnfo = multi->
fNext;
1083 previnfo = previnfo->
fNext;
1089 }
else if (strlen(right)==0 && cl && element &&
final) {
1092 if (!useLeafCollectionObject
1103 maininfo = collectioninfo;
1104 previnfo = collectioninfo;
1113 previnfo->
fNext = multi;
1116 previnfo = multi->
fNext;
1123 previnfo = previnfo->
fNext;
1126 }
else if (!useLeafCollectionObject
1142 collectioninfo->
fNext =
1145 maininfo = collectioninfo;
1146 previnfo = maininfo->
fNext;
1148 }
else if (!useLeafCollectionObject
1159 previnfo = maininfo;
1164 if ( useLeafCollectionObject || fullExpression[0] ==
'@' || fullExpression[strlen(scratch)] ==
'@' ) {
1165 useLeafReferenceObject =
true;
1182 Error(
"DefinedVariable",
"Failed to access class type of reference target (%s)",element->
GetName());
1189 if (subExpression && subExpression[0]) {
1190 Error(
"ParseWithLeaf",
"Found a numerical leaf but the name has trailing characters: \"%s\"", subExpression);
1199 if (unwindCollection) {
1202 R__ASSERT(numberOfVarDim==1 && maininfo);
1209 previnfo->
fNext = multi;
1212 previnfo = multi->
fNext;
1219 previnfo = previnfo->
fNext;
1227 previnfo->
fNext = multi;
1230 previnfo = multi->
fNext;
1239 Int_t nchname = strlen(right);
1254 Error(
"DefinedVariable",
"%s does not inherit from %s. Casting not possible!",
1261 maininfo = leafinfo;
1264 previnfo = leafinfo;
1266 previnfo->
fNext = leafinfo;
1267 previnfo = leafinfo;
1272 castqueue.
AddAt(0,paran_level);
1276 Bool_t prevUseCollectionObject = useLeafCollectionObject;
1277 Bool_t useCollectionObject = useLeafCollectionObject;
1278 Bool_t useReferenceObject = useLeafReferenceObject;
1279 Bool_t prevUseReferenceObject = useLeafReferenceObject;
1280 for (i=0, current = &(work[0]); i<=nchname;i++ ) {
1282 if (right[i] ==
'(') {
1285 *current++ = right[i++];
1286 }
while(right[i]!=
')' && right[i]);
1287 *current++ = right[i];
1289 char *params = strchr(work,
'(');
1291 *params = 0; params++;
1292 }
else params = (
char *)
")";
1294 Error(
"DefinedVariable",
"Can not call '%s' with a class",work);
1298 Error(
"DefinedVariable",
"Class probably unavailable:%s",cl->
GetName());
1325 previnfo = clonesinfo;
1326 maininfo = clonesinfo;
1358 previnfo = collectioninfo;
1359 maininfo = collectioninfo;
1364 if (inside_cl) cl = inside_cl;
1366 Warning(
"DefinedVariable",
"Can not call method on content of %s in %s\n",
1373 Error(
"DefinedVariable",
1374 "Could not discover the TClass corresponding to (%s)!",
1378 method =
new TMethodCall(cl,
"GetEntriesFast",
"");
1382 if (useLeafCollectionObject) {
1388 maininfo=previnfo=collectioninfo;
1394 Error(
"DefinedVariable",
1395 "Can not call method %s on class without dictionary (%s)!",
1403 Error(
"DefinedVariable",
"Unknown method:%s in %s",right,cl->
GetName());
1428 Error(
"DefineVariable",
"Method %s from %s has an impossible return type %d",
1434 maininfo = leafinfo;
1437 previnfo = leafinfo;
1439 previnfo->
fNext = leafinfo;
1440 previnfo = leafinfo;
1443 current = &(work[0]);
1445 prevUseCollectionObject =
kFALSE;
1446 prevUseReferenceObject =
kFALSE;
1447 useCollectionObject =
kFALSE;
1450 if (numberOfVarDim>1) {
1451 Warning(
"DefinedVariable",
"TTreeFormula support only 2 level of variables size collections. Assuming '@' notation for the collection %s.",
1454 useCollectionObject =
kTRUE;
1455 }
else if (numberOfVarDim==0) {
1459 }
else if (numberOfVarDim==1) {
1464 previnfo->
fNext = leafinfo;
1465 previnfo = leafinfo;
1471 previnfo->
fNext = leafinfo;
1472 previnfo = leafinfo;
1476 }
else if (right[i] ==
')') {
1479 TClass * casted = (
TClass*) ((
int(--paran_level)>=0) ? castqueue.
At(paran_level) : 0);
1485 maininfo = leafinfo;
1488 previnfo = leafinfo;
1490 previnfo->
fNext = leafinfo;
1491 previnfo = leafinfo;
1494 current = &(work[0]);
1501 }
else if (i > 0 && (right[i] ==
'.' || right[i] ==
'[' || right[i] ==
'\0') ) {
1508 if (strlen(work)==0)
continue;
1510 prevUseCollectionObject = useCollectionObject;
1511 prevUseReferenceObject = useReferenceObject;
1513 useReferenceObject =
kTRUE;
1514 useCollectionObject =
kTRUE;
1516 for(
l=0;work[
l+1]!=0;++
l) work[
l] = work[
l+1];
1518 }
else if (work[strlen(work)-1]==
'@') {
1519 useReferenceObject =
kTRUE;
1520 useCollectionObject =
kTRUE;
1521 work[strlen(work)-1] =
'\0';
1523 useReferenceObject =
kFALSE;
1524 useCollectionObject =
kFALSE;
1535 prevUseReferenceObject =
kFALSE;
1538 previnfo = previnfo->
fNext;
1542 for(
Long64_t entry=0; entry<leaf->
GetBranch()->GetEntries()-readentry; ++entry) {
1580 previnfo = clonesinfo;
1581 maininfo = clonesinfo;
1585 Error(
"DefinedVariable",
"Unimplemented usage of ClonesArray");
1596 "TClonesArray object was not retrievable for %s!",
1605 if (1 || inside_cl) cl = inside_cl;
1607 if (0 && strlen(work)==0) {
1641 previnfo = collectioninfo;
1642 maininfo = collectioninfo;
1651 Error(
"DefinedVariable",
"Could you not find the inner class for %s with coll type = %d",
1655 Warning(
"DefinedVariable",
"No data member in content of %s in %s\n",
1664 Warning(
"DefinedVariable",
"Missing class for %s!",
name.Data());
1669 if (!element && !prevUseCollectionObject) {
1676 Int_t clones_offset = 0;
1684 previnfo->
fNext = clonesinfo;
1686 previnfo->
fNext = 0;
1698 if (maininfo==0) maininfo = leafinfo;
1699 if (previnfo==0) previnfo = leafinfo;
1701 previnfo->
fNext = leafinfo;
1702 previnfo = leafinfo;
1710 Int_t coll_offset = 0;
1719 if (numberOfVarDim>1) {
1720 Warning(
"DefinedVariable",
"TTreeFormula support only 2 level of variables size collections. Assuming '@' notation for the collection %s.",
1723 useCollectionObject =
kTRUE;
1724 }
else if (numberOfVarDim==1) {
1736 if (maininfo==0) maininfo = leafinfo;
1737 if (previnfo==0) previnfo = leafinfo;
1739 previnfo->
fNext = leafinfo;
1740 previnfo = leafinfo;
1742 if (leafinfo->
fNext) {
1743 previnfo = leafinfo->
fNext;
1758 if (numberOfVarDim>=1 &&
type>40) {
1763 if (leafinfo &&
type<=40 ) {
1803 Error(
"DefinedVariable",
1804 "%s is a datamember of %s BUT is not yet of a supported type (%d)",
1809 Error(
"DefinedVariable",
1810 "%s is a datamember of %s BUT is not of a unknown type (%d)",
1815 if (
object && !useCollectionObject &&
1821 if (
object && leafinfo) {
1823 }
else if (objarr) {
1838 if (numberOfVarDim>1) {
1839 Warning(
"DefinedVariable",
"TTreeFormula support only 2 level of variables size collections. Assuming '@' notation for the collection %s.",
1842 useCollectionObject =
kTRUE;
1843 }
else if (numberOfVarDim==1) {
1863 else leafinfo->
fNext = info;
1870 if (!maininfo) maininfo = leafinfo;
1875 if (previnfo==0) previnfo = leafinfo;
1877 previnfo->
fNext = leafinfo;
1878 previnfo = leafinfo;
1893 else leafinfo->
fNext = info;
1909 prevUseReferenceObject =
kFALSE;
1912 }
else if (pointer) {
1924 if (cl)
Error(
"DefinedVariable",
"%s is not a datamember of %s",work,cl->
GetName());
1931 maininfo = leafinfo;
1934 previnfo = leafinfo;
1935 }
else if (previnfo!=leafinfo) {
1936 previnfo->
fNext = leafinfo;
1937 previnfo = leafinfo;
1939 while (previnfo->
fNext) previnfo = previnfo->
fNext;
1941 if ( right[i] !=
'\0' ) {
1942 if ( !needClass && mustderef ) {
1948 if ( inf->IsReference() ) {
1959 Error(
"DefinedVariable",
"Failed to access class type of reference target (%s)",element->
GetName());
1965 Error(
"DefinedVariable",
"Failed to access class type of reference target (%s)",element->
GetName());
1969 else if ( needClass ) {
1973 if (mustderef) leafinfo = 0;
1974 current = &(work[0]);
1983 nchname = strlen(right);
1987 *current++ = right[i];
1996 if (strlen(work)!=0) {
2008 if (!last)
return action;
2012 if (last && last->
GetClass() != objClass) {
2024 last->
fNext = collectioninfo;
2036 if (!last)
return action;
2040 const char *funcname = 0;
2044 }
else if (objClass == stdStringClass) {
2087 method =
new TMethodCall(objClass,
"AsString",
"");
2140 const char *funcname = 0;
2143 }
else if (objClass == stdStringClass) {
2183 if (readentry < 0) readentry=0;
2184 const char *
cname = expression;
2186 char second[
kMaxLen*2]; second[0] =
'\0';
2187 char right[
kMaxLen*2]; right[0] =
'\0';
2188 char work[
kMaxLen]; work[0] =
'\0';
2189 char left[
kMaxLen]; left[0] =
'\0';
2192 std::string currentname;
2193 Int_t previousdot = 0;
2196 TBranch *branch=0, *tmp_branch=0;
2202 for (i=0, current = &(work[0]); i<=nchname && !
final;i++ ) {
2204 *current++ =
cname[i];
2206 if (
cname[i] ==
'(') {
2209 if (current==work+1) {
2212 startWithParan =
kTRUE;
2224 if (
cname[i] ==
')') {
2225 if (paran_level==0) {
2226 Error(
"DefinedVariable",
"Unmatched parenthesis in %s",fullExpression);
2231 if (startWithParan) {
2241 current = &(work[0]);
2245 }
else if (
gROOT->GetType(cast_name)) {
2247 current = &(work[0]);
2250 "Casting to primary types like \"%s\" is not supported yet",cast_name.
Data());
2257 char *params = strchr(work,
'(');
2259 *params = 0; params++;
2261 if (branch && !leaf) {
2273 while (!leaf && (leafcur = (
TLeaf*) next())) {
2283 if (strlen(left) && left[strlen(left)-1]==
'.') left[strlen(left)-1]=0;
2285 if (aliasValue && strcspn(aliasValue,
"+*/-%&!=<>|")==strlen(aliasValue)) {
2288 if (find(aliasUsed.begin(),
2290 left) != aliasUsed.end()) {
2291 Error(
"DefinedVariable",
2292 "The substitution of the branch alias \"%s\" by \"%s\" in \"%s\" failed\n"\
2293 "\tbecause \"%s\" is used [recursively] in its own definition!",
2294 left,aliasValue,fullExpression,left);
2297 aliasUsed.push_back(left);
2298 TString newExpression = aliasValue;
2299 newExpression += (
cname+strlen(left));
2301 castqueue, aliasUsed, useLeafCollectionObject, fullExpression);
2303 Error(
"DefinedVariable",
2304 "The substitution of the alias \"%s\" by \"%s\" failed.",left,aliasValue);
2321 strlcpy(right,work,2*
kMaxLen);
2322 strncat(right,
"(",2*
kMaxLen-1-strlen(right));
2323 strncat(right,params,2*
kMaxLen-1-strlen(right));
2327 i += strlen(params);
2330 current = &(work[0]);
2342 foundAtSign =
kTRUE;
2344 for(
l=0;work[
l+1]!=0;++
l) work[
l] = work[
l+1];
2347 }
else if (
len>=2 && work[
len-2]==
'@') {
2348 foundAtSign =
kTRUE;
2356 if (left[0]==0) strlcpy(left,work,
kMaxLen);
2357 if (!leaf && !branch) {
2361 std::string treename(
first);
2362 if (treename.size() && treename[treename.size()-1]==
'.') {
2363 treename.erase(treename.size()-1);
2365 if (treename==
"This" ) {
2416 useLeafCollectionObject = foundAtSign;
2418 current = &(work[0]);
2421 else if (branch && (foundAtSign ||
cname[i] != 0) ) {
2435 useLeafCollectionObject = foundAtSign;
2437 current = &(work[0]);
2447 useLeafCollectionObject = foundAtSign;
2449 current = &(work[0]);
2451 }
else if (leaf || branch) {
2452 if (leaf && branch) {
2466 current = &(work[0]);
2479 if (foundAtSign) strncat(right,
"@",2*
kMaxLen-1-strlen(right));
2480 if (
cname[i]==
'.') strncat(right,
".",2*
kMaxLen-1-strlen(right));
2483 current = &(work[0]);
2486 }
else if (
cname[i] ==
'.') {
2493 while(!branch && (branchcur=(
TBranch*)next()) ) {
2498 current = &(work[0]);
2505 Error(
"DefinedVariable",
"Unexpected control flow!");
2511 if (
cname[i]) work[strlen(work)-1] =
'\0';
2513 snprintf(scratch2,
sizeof(scratch2),
"%s.%s.%s",
first,second,work);
2516 currentname = &(work[previousdot+1]);
2523 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch);
2524 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch2);
2525 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(currentname.c_str());
2535 if (!tmp_branch) tmp_branch = branch->
FindBranch(scratch);
2536 if (!tmp_branch) tmp_branch = branch->
FindBranch(scratch2);
2537 if (!tmp_branch) tmp_branch = branch->
FindBranch(currentname.c_str());
2545 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch);
2546 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(scratch2);
2547 if (!tmp_leaf) tmp_leaf = branch->
FindLeaf(currentname.c_str());
2558 if (second[0]) strncat(second,
".",2*
kMaxLen-1-strlen(second));
2559 strncat(second,work,2*
kMaxLen-1-strlen(second));
2561 useLeafCollectionObject = foundAtSign;
2565 current = &(work[0]);
2571 Int_t where = strlen(work);
2573 work[where+1] =
cname[i];
2575 previousdot = where+1;
2577 previousdot = strlen(work);
2578 work[strlen(work)] =
cname[i];
2588 strncat(right,work,2*
kMaxLen-1-strlen(right));
2592 if (strlen(right) && right[strlen(right)-1]!=
'.' &&
cname[i]!=
'.') {
2596 strncat(right,
".",2*
kMaxLen-1-strlen(right));
2601 if (!
final && branch) {
2604 if (!leaf)
return -1;
2610 if (strlen(right)==0) strlcpy(right,work,2*
kMaxLen);
2613 if (leaf==0 && left[0]!=0) {
2614 if (left[strlen(left)-1]==
'.') left[strlen(left)-1]=0;
2618 if (aliasValue && strcspn(aliasValue,
"()[]+*/-%&!=<>|")==strlen(aliasValue)) {
2621 if (find(aliasUsed.begin(),
2623 left) != aliasUsed.end()) {
2624 Error(
"DefinedVariable",
2625 "The substitution of the branch alias \"%s\" by \"%s\" in \"%s\" failed\n"\
2626 "\tbecause \"%s\" is used [recursively] in its own definition!",
2627 left,aliasValue,fullExpression,left);
2630 aliasUsed.push_back(left);
2631 TString newExpression = aliasValue;
2632 newExpression += (
cname+strlen(left));
2634 castqueue, aliasUsed, useLeafCollectionObject, fullExpression);
2636 Error(
"DefinedVariable",
2637 "The substitution of the alias \"%s\" by \"%s\" failed.",left,aliasValue);
2688 if (!
fTree)
return -1;
2694 if (
name ==
"Entry$") {
2700 if (
name ==
"LocalEntry$") {
2706 if (
name ==
"Entries$") {
2714 if (
name ==
"LocalEntries$") {
2722 if (
name ==
"Iteration$") {
2728 if (
name ==
"Length$") {
2734 static const char *
lenfunc =
"Length$(";
2735 if (strncmp(
name.Data(),
"Length$(",strlen(
lenfunc))==0
2747 static const char *minfunc =
"Min$(";
2748 if (strncmp(
name.Data(),
"Min$(",strlen(minfunc))==0
2760 static const char *maxfunc =
"Max$(";
2761 if (strncmp(
name.Data(),
"Max$(",strlen(maxfunc))==0
2773 static const char *sumfunc =
"Sum$(";
2774 if (strncmp(
name.Data(),
"Sum$(",strlen(sumfunc))==0
2793 if (res<0)
return res;
2801 char dims[
kMaxLen]; dims[0] =
'\0';
2810 for(i=0,k=0; i<cnamelen; ++i, ++k) {
2811 if (
cname[i] ==
'[') {
2813 int bracket_level = 1;
2815 for (j=++i; j<cnamelen && (bracket_level>0 ||
cname[j]==
'['); j++, i++) {
2816 if (
cname[j]==
'[') bracket_level++;
2817 else if (
cname[j]==
']') bracket_level--;
2819 if (bracket_level != 0) {
2823 strncat(dims,&
cname[bracket],j-bracket);
2837 if (res<0)
return res;
2839 if (!leaf && res!=2) {
2848 Error(
"DefinedVariable",
2849 "The substitution of the alias \"%s\" by \"%s\" failed\n"\
2850 "\tbecause \"%s\" is recursively used in its own definition!",
2856 if (strcspn(aliasValue,
"()+*/-%&!=<>|")!=strlen(aliasValue)) {
2862 aliasSofar.push_back(
cname );
2864 TString subValue( aliasValue );
2873 Error(
"DefinedVariable",
2874 "The substitution of the alias \"%s\" by \"%s\" failed.",
cname,aliasValue);
2889 TString thisAlias( aliasValue );
2897 Error(
"Compile",
" Bad numerical expression : \"%s\"",thisAlias.
Data());
2898 }
else if (aliasRes==-2) {
2899 Error(
"Compile",
" Part of the Variable \"%s\" exists but some of it is not accessible or useable",thisAlias.
Data());
2902 Error(
"DefinedVariable",
2903 "The substitution of the alias \"%s\" by \"%s\" failed.",
cname,aliasValue);
2912 if (leaf || res==2) {
2915 Error(
"DefinedVariable",
"the branch \"%s\" has to be enabled to be used",leaf->
GetBranch()->
GetName());
2924 char *current = &( dims[0] );
2931 if (current[0] ==
']') {
2934 scanindex = sscanf(current,
"%d",&
index);
2940 char *end = (
char*)(varindex.
Data());
2941 for(
char bracket_level = 0;*end!=0;end++) {
2942 if (*end==
'[') bracket_level++;
2943 if (bracket_level==0 && *end==
']')
break;
2944 if (*end==
']') bracket_level--;
2954 current += strlen(varindex)+1;
2962 current = (
char*)strstr( current,
"[" );
2969 res =
ParseWithLeaf(leaf,leftover,
final,paran_level,castqueue,useLeafCollectionObject,
name);
2970 if (res<0)
return res;
2971 if (res>0) action = res;
2999 }
else if (strlen(gcut->
GetVarX())) {
3008 for(
Int_t i2 = 1; i2<
n; i2++) {
3009 if (
x[i2] < min) min =
x[i2];
3010 if (
x[i2] > max) max =
x[i2];
3029 Error(
"DefinedVariable",
"Found a TCutG without leaf information (%s)",
3066 while ((leafcur = (
TLeaf*)nextleaf())) {
3094 if (clonesinfo) {
delete clonesinfo; clonesinfo = 0; }
3118 if (clones) cl = clones->
GetClass();
3160 leafinfo = clonesinfo;
3172 Int_t clones_offset = 0;
3177 else leafinfo->
fNext = sub_clonesinfo;
3178 else leafinfo = sub_clonesinfo;
3184 delete leafinfo; clonesinfo = 0;
3189 if (!clones)
continue;
3250 }
else if (
type > 60) {
3309 Error(
"BranchHasMethod",
"A TClonesArray was stored in a branch type no yet support (i.e. neither TBranchObject nor TBranchElement): %s",branch->
IsA()->
GetName());
3312 cl = clones ? clones->
GetClass() : 0;
3346 Int_t real_instance = 0;
3381 if (local_index<0) {
3382 Error(
"EvalInstance",
"Index %s is out of bound (%d) in formula %s",
3389 real_instance = local_index *
fCumulSizes[codeindex][1];
3414 if (local_index<0) {
3415 Error(
"EvalInstance",
"Index %s is out of bound (%d) in formula %s",
3435 if (check)
return fNdata[0]+1;
3440 }
while( instance >= virt_accum && local_index<maxloop);
3446 if (local_index==(maxloop-1) && (instance >= virt_accum)) {
3448 if (check)
return fNdata[0]+1;
3454 if (check)
return fNdata[0]+1;
3462 local_index =
fIndexes[codeindex][0];
3489 if (
fIndexes[codeindex][vdim]>=0) {
3492 if (isize!=1 &&
fIndexes[codeindex][vdim]>isize) {
3497 for(
Int_t k=vdim -1; k>0; --k) {
3501 real_instance = local_index *
fCumulSizes[codeindex][1];
3505 for (
Int_t dim = 1; dim < max_dim; dim++) {
3516 if (
fIndexes[codeindex][dim]==-2) {
3523 if (local_index<0 ||
3525 Error(
"EvalInstance",
"Index %s is out of bound (%d/%d) in formula %s",
3533 real_instance += local_index *
fCumulSizes[codeindex][dim+1];
3537 if (
fIndexes[codeindex][max_dim]>=0) {
3538 if (!info) real_instance +=
fIndexes[codeindex][max_dim];
3544 local_index = instance;
3546 if (info && local_index>=
fCumulSizes[codeindex][max_dim]) {
3550 if (
fIndexes[codeindex][max_dim]==-2) {
3556 if (local_index<0 ||
3558 Error(
"EvalInstance",
"Index %s is of out bound (%d/%d) in formula %s",
3566 real_instance += local_index;
3571 return real_instance;
3669 else if (real_instance>=
fNdata[0])
return 0;
3675 if (real_instance) {
3676 Warning(
"EvalObject",
"Not yet implement for kDirect and arrays (for %s).\nPlease contact the developers",
GetName());
3695 const Int_t kMAXSTRINGFOUND = 10;
3696 const char *stringStack[kMAXSTRINGFOUND];
3707 }
else if (real_instance>=
fNdata[0]) {
3720 return stringStack[0];
3723#define TT_EVAL_INIT \
3724 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(0); \
3726 const Int_t real_instance = GetRealInstance(instance,0); \
3728 if (instance==0) fNeedLoading = kTRUE; \
3729 if (real_instance>=fNdata[0]) return 0; \
3735 if (fNeedLoading) { \
3736 fNeedLoading = kFALSE; \
3737 TBranch *br = leaf->GetBranch(); \
3738 Long64_t tentry = br->GetTree()->GetReadEntry(); \
3739 R__LoadBranch(br,tentry,fQuickLoad); \
3746 if (fLookupType[0]==kDirect) { \
3747 label = (char*)leaf->GetValuePointer(); \
3749 label = (char*)GetLeafInfo(0)->GetValuePointer(leaf,instance); \
3751 Int_t bin = fAxis->FindBin(label); \
3755#define TREE_EVAL_INIT \
3756 const Int_t real_instance = GetRealInstance(instance,0); \
3758 if (real_instance>=fNdata[0]) return 0; \
3764 label = (char*)GetLeafInfo(0)->GetValuePointer((TLeaf*)0x0,instance); \
3765 Int_t bin = fAxis->FindBin(label); \
3769#define TT_EVAL_INIT_LOOP \
3770 TLeaf *leaf = (TLeaf*)fLeaves.UncheckedAt(code); \
3773 const Int_t real_instance = GetRealInstance(instance,code); \
3776 TBranch *branch = (TBranch*)fBranches.UncheckedAt(code); \
3778 Long64_t treeEntry = branch->GetTree()->GetReadEntry(); \
3779 R__LoadBranch(branch,treeEntry,fQuickLoad); \
3780 } else if (fDidBooleanOptimization) { \
3781 branch = leaf->GetBranch(); \
3782 Long64_t treeEntry = branch->GetTree()->GetReadEntry(); \
3783 if (branch->GetReadEntry() != treeEntry) branch->GetEntry( treeEntry ); \
3789 if (fDidBooleanOptimization) { \
3790 TBranch *br = leaf->GetBranch(); \
3791 Long64_t treeEntry = br->GetTree()->GetReadEntry(); \
3792 if (br->GetReadEntry() != treeEntry) br->GetEntry( treeEntry ); \
3795 if (real_instance>=fNdata[code]) return 0;
3797#define TREE_EVAL_INIT_LOOP \
3799 const Int_t real_instance = GetRealInstance(instance,code); \
3801 if (real_instance>=fNdata[code]) return 0;
3807 for (
int i=0; i<
len; ++i) res +=
sum->EvalInstance<T>(i);
3816 for (
int i=1; i<
len; ++i) {
3831 for (
int i=1; i<
len; ++i) {
3850 }
while (!condval && i<
len);
3851 if (!condval && i==
len) {
3860 for (; i<
len; ++i) {
3882 }
while (!condval && i<
len);
3883 if (!condval && i==
len) {
3892 for (; i<
len; ++i) {
3907template <
typename T>
T fmod_local(T
x, T
y) {
return fmod(
x,
y); }
3924 if( !strncmp(
fExpr[op],
"0x", 2) || !strncmp(
fExpr[op],
"0X", 2) ) {
3926 sscanf(
fExpr[op],
"%llx", &val );
3952 return leaf->GetTypedValue<T>(real_instance);
4010 const Int_t kMAXSTRINGFOUND = 10;
4011 const char *stringStackLocal[kMAXSTRINGFOUND];
4012 const char **stringStack = stringStackArg?stringStackArg:stringStackLocal;
4028 if (newaction==
kConstant) { pos++; tab[pos-1] = GetConstant<T>(oper &
kTFOperMask);
continue; }
4032 case kEnd :
return tab[0];
4033 case kAdd : pos--; tab[pos-1] += tab[pos];
continue;
4034 case kSubstract : pos--; tab[pos-1] -= tab[pos];
continue;
4035 case kMultiply : pos--; tab[pos-1] *= tab[pos];
continue;
4036 case kDivide : pos--;
if (tab[pos] == 0) tab[pos-1] = 0;
4037 else tab[pos-1] /= tab[pos];
4042 tab[pos-1] =
T(int1 % int2);
4062 case kacosh:
if (tab[pos-1] < 1) {tab[pos-1] = 0;}
4071 case kfmod : pos--; tab[pos-1] = fmod_local(tab[pos-1],tab[pos]);
continue;
4072 case kpow : pos--; tab[pos-1] =
TMath::Power(tab[pos-1],tab[pos]);
continue;
4073 case ksq : tab[pos-1] = tab[pos-1]*tab[pos-1];
continue;
4076 case kstrstr : pos2 -= 2; pos++;
if (strstr(stringStack[pos2],stringStack[pos2+1])) tab[pos-1]=1;
4080 case kmin : pos--; tab[pos-1] = std::min(tab[pos-1],tab[pos]);
continue;
4081 case kmax : pos--; tab[pos-1] = std::max(tab[pos-1],tab[pos]);
continue;
4083 case klog :
if (tab[pos-1] > 0) tab[pos-1] =
TMath::Log(tab[pos-1]);
4084 else {tab[pos-1] = 0;}
4087 if (dexp < -700) {tab[pos-1] = 0;
continue;}
4088 if (dexp > 700) {tab[pos-1] =
TMath::Exp(700);
continue;}
4092 else {tab[pos-1] = 0;}
4098 case ksign :
if (tab[pos-1] < 0) tab[pos-1] = -1;
else tab[pos-1] = 1;
4101 case kSignInv: tab[pos-1] = -1 * tab[pos-1];
continue;
4104 case kAnd : pos--;
if (tab[pos-1]!=0 && tab[pos]!=0) tab[pos-1]=1;
4107 case kOr : pos--;
if (tab[pos-1]!=0 || tab[pos]!=0) tab[pos-1]=1;
4111 case kEqual : pos--; tab[pos-1] = (tab[pos-1] == tab[pos]) ? 1 : 0;
continue;
4112 case kNotEqual : pos--; tab[pos-1] = (tab[pos-1] != tab[pos]) ? 1 : 0;
continue;
4113 case kLess : pos--; tab[pos-1] = (tab[pos-1] < tab[pos]) ? 1 : 0;
continue;
4114 case kGreater : pos--; tab[pos-1] = (tab[pos-1] > tab[pos]) ? 1 : 0;
continue;
4115 case kLessThan : pos--; tab[pos-1] = (tab[pos-1] <= tab[pos]) ? 1 : 0;
continue;
4116 case kGreaterThan: pos--; tab[pos-1] = (tab[pos-1] >= tab[pos]) ? 1 : 0;
continue;
4117 case kNot : tab[pos-1] = (tab[pos-1] != 0) ? 0 : 1;
continue;
4119 case kStringEqual : pos2 -= 2; pos++;
if (!strcmp(stringStack[pos2+1],stringStack[pos2])) tab[pos-1]=1;
4122 case kStringNotEqual: pos2 -= 2; pos++;
if (strcmp(stringStack[pos2+1],stringStack[pos2])) tab[pos-1]=1;
4147 pos2++; stringStack[pos2-1] = (
char*)
fExpr[i].Data();
4161 int op = param % 10;
4163 if (op == 1 && (!tab[pos-1]) ) {
4172 }
else if (op == 2 && tab[pos-1] ) {
4183 int toskip = param / 10;
4194 int fno = param / 1000;
4195 int nargs = param % 1000;
4203 UInt_t argloc = pos-nargs;
4204 for(
Int_t j=0;j<nargs;j++,argloc++,pos--) {
4205 SetMethodParam(method, tab[argloc]);
4228 switch (lookupType) {
4235 case kIteration: tab[pos++] = instance;
continue;
4243 GetTypedValue<T>(leaf,real_instance);
continue; }
4245 GetTypedValue<T>((
TLeaf*)0x0,real_instance);
continue; }
4250 default: tab[pos++] = 0;
continue;
4263 tab[pos++] = gcut->
IsInside(xcut,ycut);
4292 tab[pos] = param; pos++;
4310 T param = FindMin<T>(primary,condition);
4312 tab[pos] = param; pos++;
4319 T param = FindMax<T>(primary,condition);
4321 tab[pos] = param; pos++;
4331 if (instance < primary->
GetNdata()) {
4337 tab[pos] = param; pos++;
4351 if (instance < primary->
GetNdata()) {
4389 if (real_instance>=
fNdata[string_code])
return 0;
4411template double TTreeFormula::EvalInstance<double> (
int,
char const**);
4412template long double TTreeFormula::EvalInstance<long double> (
int,
char const**);
4413template long long TTreeFormula::EvalInstance<long long> (
int,
char const**);
4479 Warning(
"GetValueFromMethod",
"No streamer info for branch %s.", branch->
GetName());
4489 thisobj = *((
char**) (address +
offset));
4539 Warning(
"GetValuePointerFromMethod",
"No streamer info for branch %s.", branch->
GetName());
4549 thisobj = *((
char**) (address +
offset));