Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
3d695ecb
Commit
3d695ecb
authored
6 years ago
by
Enrico Guiraud
Browse files
Options
Downloads
Patches
Plain Diff
[TREEPROCMT][NFC] Refactor TreeView::GetTreeReader
parent
9c1a7698
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tree/treeplayer/inc/ROOT/TTreeProcessorMT.hxx
+29
-17
29 additions, 17 deletions
tree/treeplayer/inc/ROOT/TTreeProcessorMT.hxx
with
29 additions
and
17 deletions
tree/treeplayer/inc/ROOT/TTreeProcessorMT.hxx
+
29
−
17
View file @
3d695ecb
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include
"TError.h"
#include
"TError.h"
#include
"TEntryList.h"
#include
"TEntryList.h"
#include
"TFriendElement.h"
#include
"TFriendElement.h"
#include
"ROOT/RMakeUnique.hxx"
#include
"ROOT/TThreadedObject.hxx"
#include
"ROOT/TThreadedObject.hxx"
#include
<string.h>
#include
<string.h>
...
@@ -55,6 +56,8 @@ namespace ROOT {
...
@@ -55,6 +56,8 @@ namespace ROOT {
class
TTreeView
{
class
TTreeView
{
private:
private:
using
TreeReaderEntryListPair
=
std
::
pair
<
std
::
unique_ptr
<
TTreeReader
>
,
std
::
unique_ptr
<
TEntryList
>>
;
typedef
std
::
pair
<
std
::
string
,
std
::
string
>
NameAlias
;
typedef
std
::
pair
<
std
::
string
,
std
::
string
>
NameAlias
;
// NOTE: fFriends must come before fChain to be deleted after it, see ROOT-9281 for more details
// NOTE: fFriends must come before fChain to be deleted after it, see ROOT-9281 for more details
...
@@ -62,7 +65,7 @@ namespace ROOT {
...
@@ -62,7 +65,7 @@ namespace ROOT {
std
::
unique_ptr
<
TChain
>
fChain
;
///< Chain on which to operate
std
::
unique_ptr
<
TChain
>
fChain
;
///< Chain on which to operate
std
::
vector
<
std
::
string
>
fFileNames
;
///< Names of the files
std
::
vector
<
std
::
string
>
fFileNames
;
///< Names of the files
std
::
string
fTreeName
;
///< Name of the tree
std
::
string
fTreeName
;
///< Name of the tree
TEntryList
fEntryList
;
///< Entry numbers to be process
ed
TEntryList
fEntryList
;
///< User-defined selection of entry numbers to be processed, empty if none was provid
ed
std
::
vector
<
Long64_t
>
fLoadedEntries
;
///<! Per-task loaded entries (for task interleaving)
std
::
vector
<
Long64_t
>
fLoadedEntries
;
///<! Per-task loaded entries (for task interleaving)
std
::
vector
<
NameAlias
>
fFriendNames
;
///< <name,alias> pairs of the friends of the tree/chain
std
::
vector
<
NameAlias
>
fFriendNames
;
///< <name,alias> pairs of the friends of the tree/chain
std
::
vector
<
std
::
vector
<
std
::
string
>>
fFriendFileNames
;
///< Names of the files where friends are stored
std
::
vector
<
std
::
vector
<
std
::
string
>>
fFriendFileNames
;
///< Names of the files where friends are stored
...
@@ -149,6 +152,29 @@ namespace ROOT {
...
@@ -149,6 +152,29 @@ namespace ROOT {
}
}
}
}
TreeReaderEntryListPair
MakeReaderWithEntryList
(
Long64_t
start
,
Long64_t
end
)
{
// TEntryList and SetEntriesRange do not work together (the former has precedence).
// We need to construct a TEntryList that contains only those entry numbers in our desired range.
auto
elist
=
std
::
make_unique
<
TEntryList
>
();
Long64_t
entry
=
fEntryList
.
GetEntry
(
0
);
do
{
if
(
entry
>=
start
&&
entry
<
end
)
// TODO can quit this loop early when entry >= end
elist
->
Enter
(
entry
);
}
while
((
entry
=
fEntryList
.
Next
())
>=
0
);
auto
reader
=
std
::
make_unique
<
TTreeReader
>
(
fChain
.
get
(),
elist
.
get
());
return
std
::
make_pair
(
std
::
move
(
reader
),
std
::
move
(
elist
));
}
std
::
unique_ptr
<
TTreeReader
>
MakeReader
(
Long64_t
start
,
Long64_t
end
)
{
auto
reader
=
std
::
make_unique
<
TTreeReader
>
(
fChain
.
get
());
fChain
->
LoadTree
(
start
-
1
);
reader
->
SetEntriesRange
(
start
,
end
);
return
reader
;
}
public
:
public
:
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/// Constructor based on a file name.
/// Constructor based on a file name.
...
@@ -250,28 +276,14 @@ namespace ROOT {
...
@@ -250,28 +276,14 @@ namespace ROOT {
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/// Get a TTreeReader for the current tree of this view.
/// Get a TTreeReader for the current tree of this view.
using
TreeReaderEntryListPair
=
std
::
pair
<
std
::
unique_ptr
<
TTreeReader
>
,
std
::
unique_ptr
<
TEntryList
>>
;
TreeReaderEntryListPair
GetTreeReader
(
Long64_t
start
,
Long64_t
end
)
TreeReaderEntryListPair
GetTreeReader
(
Long64_t
start
,
Long64_t
end
)
{
{
std
::
unique_ptr
<
TTreeReader
>
reader
;
std
::
unique_ptr
<
TTreeReader
>
reader
;
std
::
unique_ptr
<
TEntryList
>
elist
;
std
::
unique_ptr
<
TEntryList
>
elist
;
if
(
fEntryList
.
GetN
()
>
0
)
{
if
(
fEntryList
.
GetN
()
>
0
)
{
// TEntryList and SetEntriesRange do not work together (the former has precedence).
std
::
tie
(
reader
,
elist
)
=
MakeReaderWithEntryList
(
start
,
end
);
// We need to construct a TEntryList that contains only those entry numbers
// in our desired range.
elist
.
reset
(
new
TEntryList
);
Long64_t
entry
=
fEntryList
.
GetEntry
(
0
);
do
{
if
(
entry
>=
start
&&
entry
<
end
)
// TODO can quit this loop early when entry >= end
elist
->
Enter
(
entry
);
}
while
((
entry
=
fEntryList
.
Next
())
>=
0
);
reader
.
reset
(
new
TTreeReader
(
fChain
.
get
(),
elist
.
get
()));
}
else
{
}
else
{
// If no TEntryList is involved we can safely set the range in the reader
reader
=
MakeReader
(
start
,
end
);
reader
.
reset
(
new
TTreeReader
(
fChain
.
get
()));
fChain
->
LoadTree
(
start
-
1
);
reader
->
SetEntriesRange
(
start
,
end
);
}
}
// we need to return the entry list too, as it needs to be in scope as long as the reader is
// we need to return the entry list too, as it needs to be in scope as long as the reader is
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment