12#ifndef ROOT_TMPWorkerTree
13#define ROOT_TMPWorkerTree
101 ROOT::TypeTraits::InvokeResult_t<F, std::reference_wrapper<TTreeReader>>
fReducedResult;
137template <class T, std::enable_if_t<std::is_pointer<T>::value && std::is_constructible<TObject *, T>::value &&
138 !std::is_constructible<TCollection *, T>::value> * =
nullptr>
141 auto th1p =
dynamic_cast<TH1*
>(res);
142 if(th1p !=
nullptr) {
143 th1p->SetDirectory(
nullptr);
146 auto ttreep =
dynamic_cast<TTree*
>(res);
147 if(ttreep !=
nullptr) {
148 ttreep->SetDirectory(
nullptr);
151 auto tentrylist =
dynamic_cast<TEntryList*
>(res);
152 if(tentrylist !=
nullptr) {
153 tentrylist->SetDirectory(
nullptr);
156 auto teventlist =
dynamic_cast<TEventList*
>(res);
157 if(teventlist !=
nullptr) {
158 teventlist->SetDirectory(
nullptr);
166 std::enable_if_t<std::is_pointer<T>::value && std::is_constructible<TCollection *, T>::value> * =
nullptr>
172 while ((obj = nxo())) {
195 std::string reply, errmsg, sn =
"[S" + std::to_string(
GetNWorker()) +
"]: ";
209 reply = sn +
"could not set TTreeReader to range " + std::to_string(
start) +
" " + std::to_string(finish - 1);
int MPSend(TSocket *s, unsigned code)
Send a message with the specified code on the specified socket.
std::pair< unsigned, std::unique_ptr< TBufferFile > > MPCodeBufPair
An std::pair that wraps the code and optional object contained in a message.
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
long long Long64_t
Portable signed long integer 8 bytes.
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
void DetachRes(T res)
Auxiliary templated functions If the user lambda returns a TH1F*, TTree*, TEventList*,...
Merge collection of TObjects.
<div class="legacybox"><h2>Legacy Code</h2> TEventList is a legacy interface: there will be no bug fi...
TH1 is the base class of all histogram classes in ROOT.
TMPWorkerTreeFunc(F procFunc, TTree *tree, TEntryList *entries, UInt_t nWorkers, ULong64_t maxEntries, ULong64_t firstEntry)
bool fCanReduce
true if fReducedResult can be reduced with a new result, false until we have produced one result
void SendResult() override
Generic function processing SendResult and Process overload.
ROOT::TypeTraits::InvokeResult_t< F, std::reference_wrapper< TTreeReader > > fReducedResult
the results of the executions of fProcFunc merged together
~TMPWorkerTreeFunc() override
void Process(UInt_t code, MPCodeBufPair &msg) override
TMPWorkerTreeFunc(F procFunc, const std::vector< std::string > &fileNames, TEntryList *entries, const std::string &treeName, UInt_t nWorkers, ULong64_t maxEntries, ULong64_t firstEntry)
F fProcFunc
copy the function to be executed
void SendResult() override
Selector processing SendResult and Process overload.
~TMPWorkerTreeSel() override
TSelector & fSelector
pointer to the selector to be used to process the tree. It is null if we are not using a TSelector.
TMPWorkerTreeSel(TSelector &selector, TTree *tree, TEntryList *entries, UInt_t nWorkers, ULong64_t maxEntries, ULong64_t firstEntry)
TMPWorkerTreeSel(TSelector &selector, const std::vector< std::string > &fileNames, TEntryList *entries, const std::string &treeName, UInt_t nWorkers, ULong64_t maxEntries, ULong64_t firstEntry)
void Process(UInt_t code, MPCodeBufPair &msg) override
Selector specialization.
Int_t LoadTree(UInt_t code, MPCodeBufPair &msg, Long64_t &start, Long64_t &finish, TEntryList **enl, std::string &errmsg)
Load the required tree and evaluate the processing range.
TMPWorkerTree(const TMPWorkerTree &)=delete
TTree * fTree
pointer to the tree to be processed. It is only used if the tree is directly passed to TProcessExecut...
TFile * fFile
last open file
~TMPWorkerTree() override
void Init(int fd, UInt_t workerN) override
Init overload defining max entries.
void HandleInput(MPCodeBufPair &msg) override
Execute instructions received from a MP client.
void Setup()
Auxiliary method for common initialization.
ULong64_t fFirstEntry
first entry to br processed
ULong64_t EvalMaxEntries(ULong64_t maxEntries)
Max entries evaluation.
TTree * RetrieveTree(TFile *fp)
Retrieve a tree from an open file.
TEntryList * fEntryList
entrylist
TMPWorkerTree()
Class constructors.
TMPWorkerTree & operator=(const TMPWorkerTree &)=delete
bool fUseTreeCache
Control usage of the tree cache.
std::vector< std::string > fFileNames
the files to be processed by all workers
TFile * OpenFile(const std::string &fileName)
Handle file opening.
virtual void SendResult()
virtual void Process(UInt_t, MPCodeBufPair &)
Long64_t fCacheSize
Cache size.
std::string fTreeName
the name of the tree to be processed
void CloseFile()
Handle file closing.
void SetupTreeCache(TTree *tree)
Tree cache handling.
TTreeCache * fTreeCache
instance of the tree cache for the tree
bool fTreeCacheIsLearning
Whether cache is in learning phase.
unsigned GetNWorker() const
ULong64_t fMaxNEntries
the maximum number of entries to be processed by this worker
ULong64_t fProcessedEntries
the number of entries processed by this worker so far
Mother of all ROOT objects.
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
A cache to speed-up the reading of ROOT datasets.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
@ kEntryValid
data read okay
EEntryStatus SetEntriesRange(Long64_t beginEntry, Long64_t endEntry)
Set the range of entries to be loaded by Next(); end will not be loaded.
A TTree represents a columnar dataset.
@ kIdling
We are ready for the next task.
@ kProcError
Tell the client there was an error while processing.
@ kProcResult
The message contains the result of the processing of a TTree.