Logo ROOT   6.08/07
Reference Guide
TPoolPlayer.h
Go to the documentation of this file.
1 /* @(#)root/multiproc:$Id$ */
2 // Author: Enrico Guiraud September 2015
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TPoolPlayer
13 #define ROOT_TPoolPlayer
14 
15 #include "TMPWorker.h"
16 #include "TTree.h"
17 #include "TSelector.h"
18 #include "MPSendRecv.h"
19 
20 class TPoolPlayer : public TMPWorker {
21  public:
22  TPoolPlayer(TSelector &selector, TTree *tree, unsigned nWorkers, ULong64_t maxEntries) :
23  TMPWorker(), fSelector(selector), fFileNames(), fTreeName(), fTree(tree),
24  fNWorkers(nWorkers), fMaxNEntries(maxEntries),
26  {}
27  TPoolPlayer(TSelector &selector, const std::vector<std::string>& fileNames,
28  const std::string& treeName, unsigned nWorkers, ULong64_t maxEntries) :
29  TMPWorker(), fSelector(selector), fFileNames(fileNames), fTreeName(treeName), fTree(nullptr),
30  fNWorkers(nWorkers), fMaxNEntries(maxEntries),
32  {}
33 
35 
36  void HandleInput(MPCodeBufPair& msg); ///< Execute instructions received from a TPool client
37  void Init(int fd, unsigned nWorkers);
38 
39  private:
40  void ProcTree(MPCodeBufPair& msg); ///< Run fSelector->Process over the tree entries, send back result
41  void ProcDataSet(unsigned int code, MPCodeBufPair& msg); ///< Run fSelector->Process over a data set
42 
43  TSelector &fSelector; ///< pointer to the selector to be used to process the tree. It is null if we are not using a TSelector.
44  std::vector<std::string> fFileNames; ///< the files to be processed by all workers
45  std::string fTreeName; ///< the name of the tree to be processed
46  TTree *fTree; ///< tree to be processed. It is only used if the tree is directly passed to TProcessExecutor::Process as argument
47  unsigned fNWorkers; ///< the number of workers spawned
48  ULong64_t fMaxNEntries; ///< the maximum number of entries to be processed by this worker
49  ULong64_t fProcessedEntries; ///< the number of entries processed by this worker so far
50  bool fFirstEntry = true;
51 };
52 
53 #endif
This class works in conjuction with TMPClient, reacting to messages received from it as specified by ...
Definition: TMPWorker.h:30
ULong64_t fMaxNEntries
the maximum number of entries to be processed by this worker
Definition: TPoolPlayer.h:48
TPoolPlayer(TSelector &selector, TTree *tree, unsigned nWorkers, ULong64_t maxEntries)
Definition: TPoolPlayer.h:22
void Init(int fd, unsigned nWorkers)
This method is called by children processes right after forking.
Definition: TPoolPlayer.cxx:9
unsigned fNWorkers
the number of workers spawned
Definition: TPoolPlayer.h:47
std::pair< unsigned, std::unique_ptr< TBufferFile > > MPCodeBufPair
An std::pair that wraps the code and optional object contained in a message.
Definition: MPSendRecv.h:31
void HandleInput(MPCodeBufPair &msg)
Execute instructions received from a TPool client.
Definition: TPoolPlayer.cxx:13
bool fFirstEntry
Definition: TPoolPlayer.h:50
TTree * fTree
tree to be processed. It is only used if the tree is directly passed to TProcessExecutor::Process as ...
Definition: TPoolPlayer.h:46
TPoolPlayer(TSelector &selector, const std::vector< std::string > &fileNames, const std::string &treeName, unsigned nWorkers, ULong64_t maxEntries)
Definition: TPoolPlayer.h:27
std::vector< std::string > fFileNames
the files to be processed by all workers
Definition: TPoolPlayer.h:44
unsigned long long ULong64_t
Definition: RtypesCore.h:70
std::string fTreeName
the name of the tree to be processed
Definition: TPoolPlayer.h:45
#define nullptr
Definition: Rtypes.h:87
void ProcDataSet(unsigned int code, MPCodeBufPair &msg)
Run fSelector->Process over a data set.
Definition: TPoolPlayer.cxx:31
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:98
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:39
ULong64_t fProcessedEntries
the number of entries processed by this worker so far
Definition: TPoolPlayer.h:49
void ProcTree(MPCodeBufPair &msg)
Run fSelector->Process over the tree entries, send back result.
TSelector & fSelector
pointer to the selector to be used to process the tree. It is null if we are not using a TSelector...
Definition: TPoolPlayer.h:43