Skip to content

Commit b89a6dc

Browse files
committed
[test] test treeindex with array index in formula
1 parent 850537e commit b89a6dc

File tree

3 files changed

+73
-8
lines changed

3 files changed

+73
-8
lines changed

roottest/root/tree/index/Makefile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ CLEAN_TARGETS += $(ALL_LIBRARIES) *.log *.clog newTestFile.root index64.root ind
77
# only target added. If the name of the target is changed in the rules then
88
# the name should be changed accordingly in this list.
99

10-
TEST_TARGETS += chain mytest index64 indexl64
10+
TEST_TARGETS += chain mytest index64 indexl64 varsizearr
1111

1212
# Search for Rules.mk in roottest/scripts
1313
# Algorithm: Find the current working directory and remove everything after
14-
# '*roottest/'. Append the path for Rules.mk from within roottest, which
14+
# '*roottest/'. Append the path for Rules.mk from within roottest, which
1515
# should be 'scripts/Rules.mk'. The roottest path is saved in the
16-
# ROOTTEST_HOME variable for use by the SUBDIRECTORIES variable and is
17-
# exported to eliminate the overhead of findding the path again during
16+
# ROOTTEST_HOME variable for use by the SUBDIRECTORIES variable and is
17+
# exported to eliminate the overhead of findding the path again during
1818
# recursive calls of gmake.
1919
# Since all makefiles should be under roottest or one of its
20-
# subdirectories and all recursions of gmake are called by
20+
# subdirectories and all recursions of gmake are called by
2121
# 'cd [DIR]; gmake ...'
2222
# this algorithm should not fail in finding /roottest/ in the
23-
# current working directory.
24-
# Issues: This algorithm will fail if a makefile is called from outside the
25-
# roottest folder, as in executing 'gmake -f ~/roottest/Makefile' from
23+
# current working directory.
24+
# Issues: This algorithm will fail if a makefile is called from outside the
25+
# roottest folder, as in executing 'gmake -f ~/roottest/Makefile' from
2626
# the home directory.
2727

2828
ifeq ($(strip $(ROOTTEST_HOME)),)
@@ -75,4 +75,9 @@ chain: chain.log
7575
index64: index64.log
7676
$(TestDiff)
7777

78+
indexl64: indexl64.log
79+
$(TestDiff)
80+
81+
varsizearr: varsizearr.log
82+
$(TestDiff)
7883

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "TTree.h"
2+
#include "TTreeIndex.h"
3+
#include <vector>
4+
#include <iostream>
5+
6+
int runvarsizearr()
7+
{
8+
const Long64_t nEvents = 2;
9+
const size_t nElements = 3;
10+
std::vector<int> otherNumbers(nElements);
11+
Long64_t eventNumber;
12+
TTree t("tree", "tree");
13+
t.Branch("eventNumber", &eventNumber);
14+
t.Branch("otherNumbers", &otherNumbers);
15+
for (Long64_t i = 0; i < nEvents; i++) {
16+
eventNumber = i;
17+
for (size_t j = 0; j < nElements; ++j)
18+
otherNumbers[j] = -2. * eventNumber + 3500 * j;
19+
t.Fill();
20+
}
21+
std::cout << t.GetEntries() << std::endl;
22+
// use Scan to show what otherNumbers[2] contains
23+
t.Scan("eventNumber:otherNumbers", "", "", nEvents);
24+
25+
TTreeIndex firstIndex(&t, "otherNumbers[2]", "eventNumber");
26+
firstIndex.Print("2"); // wasn't working before: major was always a garbage value
27+
TTreeIndex secondIndex(&t, "otherNumbers", "eventNumber");
28+
secondIndex.Print("2"); // major is always otherNumbers[0] since index not specified (before and after fix)
29+
return 0;
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
Processing runvarsizearr.C...
3+
2
4+
***********************************************
5+
* Row * Instance * eventNumb * otherNumb *
6+
***********************************************
7+
* 0 * 0 * 0 * 0 *
8+
* 0 * 1 * 0 * 3500 *
9+
* 0 * 2 * 0 * 7000 *
10+
* 1 * 0 * 1 * -2 *
11+
* 1 * 1 * 1 * 3498 *
12+
* 1 * 2 * 1 * 6998 *
13+
***********************************************
14+
15+
**********************************************
16+
* Index of Tree: tree/tree
17+
**********************************************
18+
serial : otherNumbers[2] : eventNumber
19+
**********************************************
20+
0 : 6998 : 1
21+
1 : 7000 : 0
22+
23+
**********************************************
24+
* Index of Tree: tree/tree
25+
**********************************************
26+
serial : otherNumbers : eventNumber
27+
**********************************************
28+
0 : -2 : 1
29+
1 : 0 : 0
30+
(int) 0

0 commit comments

Comments
 (0)