80 Int_t uc =
gEnv->GetValue(
"MultiProc.UseTreeCache", 1);
105 if (fp ==
nullptr || fp->
IsZombie()) {
106 std::stringstream ss;
107 ss <<
"could not open file " << fileName;
108 std::string errmsg = ss.str();
123 TTree *tree =
nullptr;
137 if (tree ==
nullptr) {
138 std::stringstream ss;
139 ss <<
"cannot find tree with name " <<
fTreeName <<
" in file " << fp->
GetName();
140 std::string errmsg = ss.str();
169 Warning(
"SetupTreeCache",
"default tree does not have a file attached: corruption? Tree cache untouched");
218 std::string reply =
"S" + std::to_string(
GetNWorker());
219 reply +=
": unknown code received: " + std::to_string(code);
288 bool setupcache =
true;
290 std::string mgroot =
"[S" + std::to_string(
GetNWorker()) +
"]: ";
292 TTree *tree =
nullptr;
295 mgroot +=
"MPCode::kProcTree: ";
298 if(
fTree ==
nullptr) {
299 errmsg = mgroot + std::string(
"tree undefined!");
312 start = rangeN * nBunch;
313 if (
start >= nEntries) {
314 start = finish = nEntries;
317 finish = (rangeN+1)*nBunch;
326 if (
fTree->GetCurrentFile()) {
330 errmsg = mgroot + std::string(
"unable to retrieve tree from open file ") +
331 std::string(
fTree->GetCurrentFile()->GetName());
338 errmsg = mgroot + std::string(
"unable to open file ") + std::string(
fTree->GetCurrentFile()->GetName());
347 mgroot +=
"MPCode::kProcRange: ";
353 mgroot +=
"MPCode::kProcFile: ";
357 errmsg +=
"MPCode undefined!";
365 if (
fFile ==
nullptr) {
367 errmsg = mgroot + std::string(
"unable to open file ") +
fFileNames[fileN];
375 if (tree ==
nullptr) {
377 errmsg = mgroot + std::string(
"unable to retrieve tree from open file ") +
fFileNames[fileN];
382 setupcache = (tree !=
fTree) ?
true :
false;
395 start = rangeN * nBunch;
396 if (
start >= nEntries)
397 start = finish = nEntries;
399 finish = (rangeN+1)*nBunch;
422 start = rangeN * nBunch;
423 if (
start >= nEntries) {
424 start = finish = nEntries;
426 finish = (rangeN + 1) * nBunch;
431 finish = (*enl)->GetN();
445 Info(
"LoadTree",
"%s %d %d file: %s %lld %lld", mgroot.c_str(), nProcessed, fileN,
fFile->GetName(),
start,
int MPSend(TSocket *s, unsigned code)
Send a message with the specified code on the specified socket.
T ReadBuffer(TBufferFile *buf)
One of the template functions used to read objects from messages.
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 Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
TList * GetListOfKeys() const override
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
virtual Long64_t GetEntry(Long64_t index)
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=nullptr, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
Return a pointer to the current read cache.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual const char * GetClassName() const
void SendResult() override
Selector processing SendResult and Process overload.
TSelector & fSelector
pointer to the selector to be used to process the tree. It is null if we are not using a TSelector.
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.
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.
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.
void SendError(const std::string &errmsg, unsigned int code=MPCode::kError)
Error sender.
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
virtual void Init(int fd, unsigned workerN)
This method is called by children processes right after forking.
unsigned fNWorkers
the number of workers spawned
const char * GetName() const override
Returns name of object.
A cache to speed-up the reading of ROOT datasets.
A TTree represents a columnar dataset.
TFile * GetCurrentFile() const
Return pointer to the current file.
virtual Long64_t GetEntries() const
virtual Long64_t GetCacheSize() const
virtual Int_t SetCacheSize(Long64_t cachesize=-1)
Set maximum size of the file cache (TTreeCache) in bytes.
This class represents a WWW compatible URL.
const char * GetFile() const
@ kSendResult
Ask for a kFuncResult/kProcResult.
@ kProcFile
Tell a TMPWorkerTree which tree to process. The object sent is a TreeInfo.
@ kIdling
We are ready for the next task.
@ kProcRange
Tell a TMPWorkerTree which tree and entries range to process. The object sent is a TreeRangeInfo.
@ kProcTree
Tell a TMPWorkerTree to process the tree that was passed to it at construction time.
@ kProcError
Tell the client there was an error while processing.
@ kProcResult
The message contains the result of the processing of a TTree.