Logo ROOT   6.14/05
Reference Guide
List of all members | Public Member Functions | Private Attributes | List of all members
ROOT::TTreeProcessorMT Class Reference

A class to process the entries of a TTree in parallel.

By means of its Process method, ROOT::TTreeProcessorMT provides a way to process the entries of a TTree in parallel. When invoking TTreeProcessor::Process, the user passes a function whose only parameter is a TTreeReader. The function iterates on a subrange of entries by using that TTreeReader.

The implementation of ROOT::TTreeProcessorMT parallelizes the processing of the subranges, each corresponding to a cluster in the TTree. This is possible thanks to the use of a ROOT::TThreadedObject, so that each thread works with its own TFile and TTree objects.

Definition at line 316 of file TTreeProcessorMT.hxx.

Public Member Functions

 TTreeProcessorMT (std::string_view filename, std::string_view treename="")
 Constructor based on a file name. More...
 
 TTreeProcessorMT (const std::vector< std::string_view > &filenames, std::string_view treename="")
 Constructor based on a collection of file names. More...
 
 TTreeProcessorMT (TTree &tree)
 Constructor based on a TTree. More...
 
 TTreeProcessorMT (TTree &tree, TEntryList &entries)
 Constructor based on a TTree and a TEntryList. More...
 
void Process (std::function< void(TTreeReader &)> func)
 Process the entries of a TTree in parallel. More...
 

Private Attributes

ROOT::TThreadedObject< ROOT::Internal::TTreeViewtreeView
 ! Thread-local TreeViews More...
 

#include <ROOT/TTreeProcessorMT.hxx>

Constructor & Destructor Documentation

◆ TTreeProcessorMT() [1/4]

TTreeProcessorMT::TTreeProcessorMT ( std::string_view  filename,
std::string_view  treename = "" 
)

Constructor based on a file name.

Parameters
[in]filenameName of the file containing the tree to process.
[in]treenameName of the tree to process. If not provided, the implementation will automatically search for a tree in the file.

Definition at line 152 of file TTreeProcessorMT.cxx.

◆ TTreeProcessorMT() [2/4]

TTreeProcessorMT::TTreeProcessorMT ( const std::vector< std::string_view > &  filenames,
std::string_view  treename = "" 
)

Constructor based on a collection of file names.

Parameters
[in]filenamesCollection of the names of the files containing the tree to process.
[in]treenameName of the tree to process. If not provided, the implementation will automatically search for a tree in the collection of files.

Definition at line 160 of file TTreeProcessorMT.cxx.

◆ TTreeProcessorMT() [3/4]

TTreeProcessorMT::TTreeProcessorMT ( TTree tree)

Constructor based on a TTree.

Parameters
[in]treeTree or chain of files containing the tree to process.

Definition at line 165 of file TTreeProcessorMT.cxx.

◆ TTreeProcessorMT() [4/4]

TTreeProcessorMT::TTreeProcessorMT ( TTree tree,
TEntryList entries 
)

Constructor based on a TTree and a TEntryList.

Parameters
[in]treeTree or chain of files containing the tree to process.
[in]entriesList of entry numbers to process.

Definition at line 171 of file TTreeProcessorMT.cxx.

Member Function Documentation

◆ Process()

void TTreeProcessorMT::Process ( std::function< void(TTreeReader &)>  func)

Process the entries of a TTree in parallel.

The user-provided function receives a TTreeReader which can be used to iterate on a subrange of entries

// Select branches to read
while (readerSubRange.next()) {
// Use content of current entry
}
});

The user needs to be aware that each of the subranges can potentially be processed in parallel. This means that the code of the user function should be thread safe.

Parameters
[in]funcUser-defined function that processes a subrange of entries

Definition at line 190 of file TTreeProcessorMT.cxx.

Member Data Documentation

◆ treeView

ROOT::TThreadedObject<ROOT::Internal::TTreeView> ROOT::TTreeProcessorMT::treeView
private

! Thread-local TreeViews

Definition at line 318 of file TTreeProcessorMT.hxx.

Libraries for ROOT::TTreeProcessorMT:
[legend]

The documentation for this class was generated from the following files: