15 unsigned code = msg.first;
26 std::string errmsg =
"unknown code received: " + std::to_string(code);
36 unsigned nProcessed = 0;
40 nProcessed = ReadBuffer<unsigned>(msg.second.get());
45 fileN = ReadBuffer<unsigned>(msg.second.get());
50 if (fFile ==
nullptr) {
52 std::string errmsg =
"unable to open file " +
fFileNames[fileN];
60 if (
fTree ==
nullptr) {
62 std::string errmsg =
"unable to retrieve tree from open file " +
fFileNames[fileN];
81 start = rangeN*nBunch + 1;
82 if(rangeN < (fNWorkers-1))
83 finish = (rangeN+1)*nBunch;
104 for(
Long64_t entry = start; entry<finish; ++entry) {
109 fProcessedEntries += finish - start;
120 if(
fTree ==
nullptr) {
121 std::cout <<
"tree undefined!\n" ;
128 unsigned nProcessed = 0;
130 nProcessed = ReadBuffer<unsigned>(msg.second.get());
139 unsigned rangeN = nProcessed %
fNWorkers;
140 start = rangeN*nBunch + 1;
142 finish = (rangeN+1)*nBunch;
159 std::string errmsg =
"unable to retrieve tree from open file " +
182 for(
Long64_t entry = start; entry<finish; ++entry) {
187 fProcessedEntries += finish - start;
virtual const char * GetName() const
Returns name of object.
Tell a TPoolProcessor to process the tree that was passed to it at construction time.
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Tell a TPoolProcessor which tree and entries range to process. The object sent is a TreeRangeInfo...
TFile * OpenFile(const std::string &fileName)
Handle file opening.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
int MPSend(TSocket *s, unsigned code)
Send a message with the specified code on the specified socket.
Tell a TPoolProcessor which tree to process. The object sent is a TreeInfo.
We are ready for the next task.
void SendError(const std::string &errmsg, unsigned int code=MPCode::kError)
Error sender.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
ULong64_t fMaxNEntries
the maximum number of entries to be processed by this worker
void Init(int fd, unsigned nWorkers)
This method is called by children processes right after forking.
void SetupTreeCache(TTree *tree)
Tree cache handling.
unsigned fNWorkers
the number of workers spawned
void CloseFile()
Handle file closing.
TFile * fFile
last open file
std::pair< unsigned, std::unique_ptr< TBufferFile > > MPCodeBufPair
An std::pair that wraps the code and optional object contained in a message.
void HandleInput(MPCodeBufPair &msg)
Execute instructions received from a TPool client.
virtual void SlaveBegin(TTree *)
TFile * GetCurrentFile() const
Return pointer to the current file.
TTree * fTree
tree to be processed. It is only used if the tree is directly passed to TProcessExecutor::Process as ...
The message contains the result of the processing of a TTree.
virtual void SlaveTerminate()
std::vector< std::string > fFileNames
the files to be processed by all workers
Ask for a kFuncResult/kProcResult.
virtual Bool_t Process(Long64_t)
virtual Long64_t GetEntries() const
virtual void Init(int fd, unsigned workerN)
This method is called by children processes right after forking.
void ProcDataSet(unsigned int code, MPCodeBufPair &msg)
Run fSelector->Process over a data set.
A TTree object has a header with a name and a title.
ULong64_t fProcessedEntries
the number of entries processed by this worker so far
void ProcTree(MPCodeBufPair &msg)
Run fSelector->Process over the tree entries, send back result.
virtual TList * GetOutputList() const
TTree * RetrieveTree(TFile *fp)
Retrieve a tree from an open file.
virtual void Init(TTree *)
TSelector & fSelector
pointer to the selector to be used to process the tree. It is null if we are not using a TSelector...