TTreeProcessorMT using a subset of tree entries

Hello, I’m trying to parallelize a program I wrote with ROOT. I’m following from here: https://root.cern.ch/doc/v612/imt101__parTreeProcessing_8C.html

I’m trying to run over only a subset of the tree using TTreeReader tr, then setting its range. I believe it should be an argument to the function myFunction, using the syntax

tp.Process(myFunction(tr));

but this syntax doesn’t work. I’m not familiar with this part of C++, and am probably reading this incorrectly, but don’t know how to properly google this. What would be the correct way to do this?
Thanks.


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


I’ve also tried setting the range within the function itself with

myReader.SetEntriesRange(start, end);

but it seems to loop indefinitely on the entry range in tp.Process(func)

@BrownPants, can you provide us your code example?
Perhaps, the author of example @etejedor can help you here?

Thank you,
Oksana.

Here is a simplified version of the code, it’s really no different than the example.

int PatternFinder(string inputfile, string outputfile, int start=0, int end=-1) {

	unsigned int nthreads = std::thread::hardware_concurrency();
	ROOT::EnableImplicitMT(nthreads);
	ROOT::EnableThreadSafety();
	ROOT::TTreeProcessorMT tp(inputfile.c_str(), "CSCDigiTree");

	auto processPatternFinder = [&](TTreeReader &r) {
		cout << "start: " << start << " end: " << end << endl;
		r.SetEntriesRange(start, end);


		while(r.Next()){
			cout << "r.Entry: " << r.GetCurrentEntry() << endl;
		}
	};

	try {
		tp.Process(processPatternFinder);
	} catch( const char* msg) {
		cerr << "ERROR: " << msg << endl;
		return -1;
	}
	return 0;
}

When printing things out, it still appears to try to loop through the entire file, or at least, when trying to run on one event (start = 0, end = 1) will print out many many lines, likely the size of the tree. Here a portion of the output

start: 0 end: 1 end: 
r.Entry: 0
start: 0 end: 11


r.Entry: 0
r.Entry: 0
start: 0 end: 1
r.Entry: 0
r.Entry: start: 0 end: 1
r.Entry: 0
0start: 0 end: 1
r.Entry: 0

start: start: 0 end: 1
r.Entry: 0
0 end: 1
r.Entry: 0
r.Entry: 0

Of course it is out of sequence from the multithreading, which appears to be working.

Anyone have any suggestions here?

Hi,

TTreeProcessorMT wraps your processing function and sets the ranges behind the scenes to prepare the chunks of work to feed the runtime with.
The solution one may try out if you are interested in a particular set of entries, contiguous or not, is to use a TEntryList

Cheers,
D

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.