Skip to content

Commit

Permalink
deactivate different limits for platforms
Browse files Browse the repository at this point in the history
as it gives problems with the Error output of GetIndex when comparing with the .ref

clarify wording

and restore platform-dependency

no need for minor/major limits
  • Loading branch information
ferdymercury committed Nov 28, 2024
1 parent e499c1a commit 1ca9966
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
45 changes: 29 additions & 16 deletions root/tree/index/index64.ref
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@

Processing runindex64.C...
******************************************************************************
* Row * run * event *
******************************************************************************
* 0 * 8 * 0 *
* 1 * 5 * 1 *
* 2 * 5 * 3 *
* 3 * 5 * 2 *
* 4 * 5 * 1.15292150460684698e+18 *
* 5 * 5 * 1.84467440737095516e+19 *
* 6 * 0 * 5 *
* 7 * 4 * 1.15292150460684698e+18 *
* 8 * 6 * 3 *
* 9 * 1.84467440737095516e+19 * 1.15292150460684698e+18 *
* 10 * 1.15292150460684698e+18 * 1.84467440737095516e+19 *
* 11 * 1.15292150460684698e+18 * 1.15292150460684698e+18 *
* 12 * 1.84467440737095516e+19 * 1.84467440737095516e+19 *
******************************************************************************
Tree BuildIndex returns 13
0: Run 8, Event 0 found at entry number: 0
1: Run 5, Event 1 found at entry number: 1
2: Run 5, Event 3 found at entry number: 2
3: Run 5, Event 2 found at entry number: 3
4: Run 0, Event 281474976710655 found at entry number: 4
5: Run 0, Event 4503599627370480 found at entry number: 5
6: Run 5, Event 5 found at entry number: 6
Error in <TTreeIndex::TreeIndex>: Wrong major (4) minor (281474976710655) combination
7: Run 4, Event 281474976710655 found at entry number: -1
4: Run 5, Event 1152921504606846975 found at entry number: 4
5: Run 5, Event 18446744073709551600 found at entry number: -1
6: Run 0, Event 5 found at entry number: 6
7: Run 4, Event 1152921504606846975 found at entry number: 7
8: Run 6, Event 3 found at entry number: 8
Error in <TTreeIndex::TreeIndex>: Wrong major (4503599627370480) minor (281474976710655) combination
9: Run 4503599627370480, Event 281474976710655 found at entry number: -1
Error in <TTreeIndex::TreeIndex>: Wrong major (1) minor (2147483648) combination
10: Run 1, Event 2147483648 found at entry number: -1
11: Run 8589934591, Event 2147483647 found at entry number: 11
Error in <TTreeIndex::TreeIndex>: Wrong major (8589934592) minor (0) combination
12: Run 8589934592, Event 0 found at entry number: -1
9: Run 18446744073709551600, Event 1152921504606846975 found at entry number: -1
10: Run 1152921504606846975, Event 18446744073709551600 found at entry number: -1
11: Run 1152921504606846975, Event 1152921504606846975 found at entry number: 11
12: Run 18446744073709551600, Event 18446744073709551600 found at entry number: -1
Entries in chain: 13
BuildIndex returns 13
Try to get value that is not in the chain, this should return a -1:
Try to find the position of run=0, event=500 in the chain, as it does not exist, this should return a -1:
-1
Try to get value that is in the chain, this should return a 4:
Try to find the position of run=5, event=bigval in the chain, which was inserted in position 4:
4
Entries in chain: 13
BuildIndex returns 1
Try to get value that is not in the chain, this should return a -1:
Try to find the position of run=0, event=500 in the chain, as it does not exist, this should return a -1:
-1
Try to get value that is in the chain, this should return a 4:
Try to find the position of run=5, event=bigval in the chain, which was inserted in position 4:
4
(int) 0
34 changes: 12 additions & 22 deletions root/tree/index/runindex64.C
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ const char* fname = "index64.root";
// Apple M1 has long double == double; these values exceed its range
// and cannot be represented as (even temporary) expression results.
// There would be a warning if you'd try.
// More info: https://github.com/root-project/roottest/commit/f3c97809c9064feccaed3844007de9e7c6a5980d and https://github.com/root-project/roottest/commit/9e3843d4bf50bc34e6e15dfe7c027f029417d6c0
static constexpr bool shortlongdouble = sizeof(long double) < 16; // was true for __APPLE__ and __arm64__
const Long64_t bigval = shortlongdouble ? 0xFFFFFFFFFFFF : 0xFFFFFFFFFFFFFFF; // still positive number
const Long64_t bigval = shortlongdouble ? 0xFFFFFFFFFFFF : 0xFFFFFFFFFFFFFFF; // still positive number
const ULong64_t biguval = shortlongdouble ? 0xFFFFFFFFFFFF0 : 0xFFFFFFFFFFFFFFF0; // "negative" number
const Long64_t maxMajor = 0x1ffffffff;
const Long64_t maxMinor = 0x7fffffff; // unless major = 0

int runindex64(){

Expand All @@ -27,30 +26,21 @@ int runindex64(){
tree->Branch("run", &run, "run/l");
tree->Branch("event", &event, "event/l");

ULong64_t runs[] = { 8,5,5,5, 0, 0, 5, 4, 6, biguval, 1, maxMajor, maxMajor+1};
ULong64_t events[] = { 0,1,3,2, bigval, biguval, 5, bigval, 3, bigval, maxMinor+1, maxMinor, 0};
for(int i=0; i<sizeof(events)/sizeof(*events); i++){
ULong64_t runs[] = { 8,5,5,5, 5, 5, 0, 4, 6, biguval, bigval, bigval, biguval};
ULong64_t events[] = { 0,1,3,2, bigval, biguval, 5, bigval, 3, bigval, biguval, bigval, biguval};
for(size_t i=0; i<sizeof(events)/sizeof(*events); i++){
run = runs[i];
event = events[i];
tree->Fill();
}
tree->Write();
//tree->Scan("run:event","","colsize=30");
tree->Scan("run:event","","colsize=30");

cout<<"Tree BuildIndex returns "<<tree->BuildIndex("run", "event")<<endl;
for (int i=0; i<sizeof(events)/sizeof(*events); i++) {
for (size_t i=0; i<sizeof(events)/sizeof(*events); i++) {
run = runs[i];
event = events[i];
// in the cout, artificially convert to short longdouble for comparing with just one .ref instead of two based on the platforms
ULong64_t run2 = run;
ULong64_t event2 = event;
if (!shortlongdouble) {
if (run == bigval) run2 = 0xFFFFFFFFFFFF;
else if(run == biguval) run2 = 0xFFFFFFFFFFFF0;
if(event == bigval) event2 = 0xFFFFFFFFFFFF;
else if(event == biguval) event2 = 0xFFFFFFFFFFFF0;
}
cout << i << ": Run " << run2 << ", Event " << event2 << " found at entry number: " << tree->GetEntryNumberWithIndex(run, event) << endl;
cout << i << ": Run " << run << ", Event " << event << " found at entry number: " << tree->GetEntryNumberWithIndex(run, event) << endl;
}

test(tree);
Expand All @@ -73,9 +63,9 @@ bool test(TTree *chain)
{
cout<<"Entries in chain: "<<chain->GetEntries()<<endl;
cout<<"BuildIndex returns "<<chain->BuildIndex("run", "event")<<endl;
cout<<"Try to get value that is not in the chain, this should return a -1:"<<endl;
cout<<"Try to find the position of run=0, event=500 in the chain, as it does not exist, this should return a -1:"<<endl;
cout<<chain->GetEntryWithIndex(500)<<endl;
cout<<"Try to get value that is in the chain, this should return a 4:"<<endl;
cout<<(int)chain->GetEntryNumberWithIndex(0, bigval)<<endl;
return (chain->GetEntryNumberWithIndex(500)==-1);
cout<<"Try to find the position of run=5, event=bigval in the chain, which was inserted in position 4:"<<endl;
cout<<chain->GetEntryNumberWithIndex(5, bigval)<<endl;
return (chain->GetEntryNumberWithIndex(500)==-1) && (chain->GetEntryNumberWithIndex(5, bigval) == 4);
}

0 comments on commit 1ca9966

Please sign in to comment.