Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rntuple-enum-debug
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arthur Charles Kraus
rntuple-enum-debug
Commits
1f8bc2be
Commit
1f8bc2be
authored
1 year ago
by
Alaettin Serhan Mete
🦅
Browse files
Options
Downloads
Patches
Plain Diff
Refine the example and add a TTree version
parent
73de1c55
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/MyPersClass.h
+9
-0
9 additions, 0 deletions
src/MyPersClass.h
src/WriteReadEnum.cxx
+36
-9
36 additions, 9 deletions
src/WriteReadEnum.cxx
src/selection.xml
+3
-0
3 additions, 0 deletions
src/selection.xml
with
48 additions
and
9 deletions
src/MyPersClass.h
+
9
−
0
View file @
1f8bc2be
...
...
@@ -2,6 +2,8 @@
* Author: Alaettin Serhan Mete <amete@anl.gov>
*/
#include
<vector>
// Dummy Class to define the Enum
class
MyEnumClass
{
public:
...
...
@@ -21,3 +23,10 @@ class MyPersClass {
float
m_float
;
MyEnumClass
::
MyEnum
m_enum
;
};
// Instantiate all necessary types for the dictionary
namespace
{
struct
GCCXML_DUMMY_INSTANTIATION
{
std
::
vector
<
MyPersClass
>
dummy
;
};
}
This diff is collapsed.
Click to expand it.
src/WriteReadEnum.cxx
+
36
−
9
View file @
1f8bc2be
...
...
@@ -2,8 +2,12 @@
* Author: Alaettin Serhan Mete <amete@anl.gov>
*/
#define VERSION 0 // 0: RNTuple, 1: TTree
#include
<ROOT/RNTuple.hxx>
#include
<ROOT/RNTupleModel.hxx>
#include
<TFile.h>
#include
<TTree.h>
#include
"MyPersClass.h"
...
...
@@ -26,21 +30,44 @@ int main(int argc, char *argv[]) {
// Write Here
{
auto
model
=
RNTupleModel
::
Create
();
auto
field
=
model
->
MakeField
<
std
::
vector
<
MyPersClass
>>
(
"foo"
);
auto
ntuple
=
RNTupleWriter
::
Recreate
(
std
::
move
(
model
),
ntupleName
,
outputName
);
for
(
unsigned
i
=
0
;
i
<
10
;
++
i
)
{
for
(
unsigned
j
=
0
;
j
<
10
;
++
j
)
{
field
->
emplace_back
(
i
*
j
,
j
<
5
?
MyEnumClass
::
ZERO
:
MyEnumClass
::
ONE
);
if
(
VERSION
==
0
)
{
// RNTuple version
auto
model
=
RNTupleModel
::
Create
();
auto
field
=
model
->
MakeField
<
std
::
vector
<
MyPersClass
>>
(
"foo"
);
auto
ntuple
=
RNTupleWriter
::
Recreate
(
std
::
move
(
model
),
ntupleName
,
outputName
);
for
(
unsigned
i
=
0
;
i
<
10
;
++
i
)
{
field
->
clear
();
for
(
unsigned
j
=
0
;
j
<
10
;
++
j
)
{
field
->
emplace_back
(
i
*
j
,
j
<
5
?
MyEnumClass
::
ZERO
:
MyEnumClass
::
ONE
);
}
ntuple
->
Fill
();
}
}
else
if
(
VERSION
==
1
)
{
// TTree version
TFile
*
f
=
TFile
::
Open
(
outputName
.
c_str
(),
"RECREATE"
);
TTree
*
t
=
new
TTree
(
ntupleName
.
c_str
(),
""
);
std
::
vector
<
MyPersClass
>
result
;
t
->
Branch
(
"foo"
,
&
result
);
for
(
unsigned
i
=
0
;
i
<
10
;
++
i
)
{
result
.
clear
();
for
(
unsigned
j
=
0
;
j
<
10
;
++
j
)
{
result
.
emplace_back
(
i
*
j
,
j
<
5
?
MyEnumClass
::
ZERO
:
MyEnumClass
::
ONE
);
}
t
->
Fill
();
}
ntuple
->
Fill
();
f
->
Write
();
f
->
Close
();
}
}
// Read Here
{
auto
ntuple
=
RNTupleReader
::
Open
(
ntupleName
,
outputName
);
ntuple
->
Show
(
0
);
if
(
VERSION
==
0
)
{
// RNTuple version
auto
ntuple
=
RNTupleReader
::
Open
(
ntupleName
,
outputName
);
ntuple
->
Show
(
9
);
}
else
if
(
VERSION
==
1
)
{
// TTree version
TFile
*
f
=
TFile
::
Open
(
outputName
.
c_str
(),
"OPEN"
);
TTree
*
t
=
f
->
Get
<
TTree
>
(
ntupleName
.
c_str
());
t
->
Show
(
9
);
}
}
return
0
;
...
...
This diff is collapsed.
Click to expand it.
src/selection.xml
+
3
−
0
View file @
1f8bc2be
<lcgdict>
<!-- These two are probably redundant in this context -->
<class
name=
"MyEnumClass"
/>
<enum
name=
"MyEnumClass::MyEnum"
/>
<!-- These are the important ones for this example -->
<class
name=
"MyPersClass"
/>
<class
name=
"std::vector<MyPersClass>"
/>
</lcgdict>
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