Skip to content
Snippets Groups Projects
Commit 5746a8c6 authored by Enrico Guiraud's avatar Enrico Guiraud Committed by Danilo Piparo
Browse files

[IMT] Do not set fCurrentFile and fCurrentTree at `Init` time in TTreeView

Future commits will remove `fCurrentFile` and `fCurrentTree` altogether
in order to make TTreeView play nice with TBB tasks. Then it will make
little sense to pre-emptively open the first filename in each thread.
parent 06f26677
No related branches found
No related tags found
No related merge requests found
...@@ -63,17 +63,17 @@ namespace ROOT { ...@@ -63,17 +63,17 @@ namespace ROOT {
TEntryList fCurrentEntryList; ///< Entry numbers for the current range being processed TEntryList fCurrentEntryList; ///< Entry numbers for the current range being processed
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// Initialize the file and the tree for this view, first looking for a tree in /// Initialize TTreeView.
/// the file if necessary.
void Init() void Init()
{ {
// Here we do not use a TContext since the TThreadedObject protects // Set the current index to an "impossible" value
// the copies done for every processing slots. fCurrentIdx = std::numeric_limits<decltype(fCurrentIdx)>::max();
fCurrentFile.reset(TFile::Open(fFileNames[fCurrentIdx].data()));
// If the tree name is empty, look for a tree in the file // If the tree name is empty, look for a tree in the file
if (fTreeName.empty()) { if (fTreeName.empty()) {
TIter next(fCurrentFile->GetListOfKeys()); ::TDirectory::TContext ctxt(gDirectory);
std::unique_ptr<TFile> f(TFile::Open(fFileNames[fCurrentIdx].data()));
TIter next(f->GetListOfKeys());
while (TKey *key = (TKey*)next()) { while (TKey *key = (TKey*)next()) {
const char *className = key->GetClassName(); const char *className = key->GetClassName();
if (strcmp(className, "TTree") == 0) { if (strcmp(className, "TTree") == 0) {
...@@ -86,14 +86,6 @@ namespace ROOT { ...@@ -86,14 +86,6 @@ namespace ROOT {
throw std::runtime_error(msg); throw std::runtime_error(msg);
} }
} }
// We cannot use here the template method (TFile::GetObject) because the header will finish
// in the PCH and the specialization will be available. PyROOT will not be able to specialize
// the method for types other that TTree.
fCurrentTree = (TTree*)fCurrentFile->Get(fTreeName.data());
// Do not remove this tree from list of cleanups (thread unsafe)
fCurrentTree->ResetBit(TObject::kMustCleanup);
} }
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment