I’m encountering a very odd thing while using a TTreeReader to read a TTree. On one computer, things work completely as expected, however using the same code on a server results in TTreeReader::Next() not returning, and instead stalling the program whilst using slowly more and more memory.
The source code is
#include <TROOT.h>
#include <TTreeReader.h>
#include <TTreeReaderValue.h>
#include <TH1.h>
#include <TFile.h>
int main(int argc, char **argv) {
std::string filename(argv[1]);
std::cout << filename << std::endl;
TFile *file = TFile::Open(filename.c_str());
TTree *tree = (TTree*)file->Get("RawTree");
file->ls();
tree->Print();
TTreeReader reader("RawTree", file);
TTreeReaderValue<UInt_t> energy(reader, "0.2.0.eventEnergy");
std::cout << "entering loop" << std::endl;
while (reader.Next()) {
std::cout << "here" << std::endl;
}
std::cout << "sorted" << std::endl;
file->Close();
std::cout << std::endl;
}
Which I am compiling with g++, however I’ve also tried running it as a macro and it makes no difference.
The results are
test.root
TFile** test.root
TFile* test.root
OBJ: TTree RawTree RawTree : 0 at: 0x33f15c0
KEY: TTree RawTree;1 RawTree
******************************************************************************
*Tree :RawTree : RawTree *
*Entries : 17096 : Total = 967587 bytes File Size = 119977 *
* : : Tree compression factor = 8.10 *
******************************************************************************
*Br 0 :0.2.0.eventTime : 0.2.0.eventTime/l *
*Entries : 17096 : Total Size= 137726 bytes File Size = 77490 *
*Baskets : 5 : Basket Size= 32000 bytes Compression= 1.77 *
*............................................................................*
*Br 1 :0.2.0.eventRelTime : 0.2.0.eventRelTime/i *
*Entries : 17096 : Total Size= 69185 bytes File Size = 713 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 96.28 *
*............................................................................*
*Br 2 :0.2.0.finishCode : 0.2.0.finishCode/i *
*Entries : 17096 : Total Size= 69171 bytes File Size = 994 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 69.06 *
*............................................................................*
*Br 3 :0.2.0.CFDForce : 0.2.0.CFDForce/i *
*Entries : 17096 : Total Size= 69157 bytes File Size = 726 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 94.54 *
*............................................................................*
*Br 4 :0.2.0.eventEnergy : 0.2.0.eventEnergy/i *
*Entries : 17096 : Total Size= 69178 bytes File Size = 33529 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 2.05 *
*............................................................................*
*Br 5 :0.2.0.outOfRange : 0.2.0.outOfRange/i *
*Entries : 17096 : Total Size= 69171 bytes File Size = 652 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 105.28 *
*............................................................................*
*Br 6 :0.2.1.eventTime : 0.2.1.eventTime/l *
*Entries : 17096 : Total Size= 137726 bytes File Size = 1185 *
*Baskets : 5 : Basket Size= 32000 bytes Compression= 115.77 *
*............................................................................*
*Br 7 :0.2.1.eventRelTime : 0.2.1.eventRelTime/i *
*Entries : 17096 : Total Size= 69185 bytes File Size = 658 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 104.33 *
*............................................................................*
*Br 8 :0.2.1.finishCode : 0.2.1.finishCode/i *
*Entries : 17096 : Total Size= 69171 bytes File Size = 652 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 105.28 *
*............................................................................*
*Br 9 :0.2.1.CFDForce : 0.2.1.CFDForce/i *
*Entries : 17096 : Total Size= 69157 bytes File Size = 646 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 106.25 *
*............................................................................*
*Br 10 :0.2.1.eventEnergy : 0.2.1.eventEnergy/i *
*Entries : 17096 : Total Size= 69178 bytes File Size = 655 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 104.80 *
*............................................................................*
*Br 11 :0.2.1.outOfRange : 0.2.1.outOfRange/i *
*Entries : 17096 : Total Size= 69171 bytes File Size = 652 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 105.28 *
*............................................................................*
entering loop
So it’s clear that the relevant branch exists, and that reader.Next() is called but does not return.
As I mentioned, if I use htop I can see that the memory being used is slowly increasing.
Does anyone know what may be going on here/how to diagnose it/whether there’s a workaround?
ROOT Version: 6.14
Platform: Ubuntu 16.04
Compiler: Not Provided