This repository has been archived by the owner on May 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master-20180516-01-branch'
- Loading branch information
Showing
10 changed files
with
166 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
# Tai Sakuma <tai.sakuma@gmail.com> | ||
|
||
import array | ||
import ROOT | ||
|
||
##__________________________________________________________________|| | ||
def main(): | ||
|
||
file_name = 'sample_chain_01.root' | ||
content_list = [ | ||
[10, 20, 30], | ||
[24, 5] | ||
] | ||
create_file(file_name, content_list) | ||
|
||
file_name = 'sample_chain_02.root' | ||
content_list = [ | ||
[3, 10], | ||
[5, 8, 32, 15, 2], | ||
[22, 11], | ||
] | ||
create_file(file_name, content_list) | ||
|
||
file_name = 'sample_chain_03.root' | ||
content_list = [ | ||
[2, 7], | ||
[10, 100], | ||
] | ||
create_file(file_name, content_list) | ||
|
||
def create_file(name, contents): | ||
|
||
f = ROOT.TFile(name, 'recreate') | ||
t = ROOT.TTree('tree', 'sample tree') | ||
|
||
max_nvar = 128; | ||
nvar = array.array('i', [0]) | ||
var = array.array('i', max_nvar*[0]) | ||
|
||
t.Branch('nvar', nvar, 'nvar/I') | ||
t.Branch('var', var, 'var[nvar]/I') | ||
|
||
for c in contents: | ||
nvar[0] = len(c) | ||
for i, v in enumerate(c): | ||
var[i] = v | ||
t.Fill() | ||
|
||
t.Write() | ||
|
||
##__________________________________________________________________|| | ||
if __name__ == '__main__': | ||
main() | ||
|
||
##__________________________________________________________________|| |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Tai Sakuma <tai.sakuma@gmail.com> | ||
import os | ||
import sys | ||
import pytest | ||
|
||
has_no_ROOT = False | ||
try: | ||
import ROOT | ||
except ImportError: | ||
has_no_ROOT = True | ||
|
||
if not has_no_ROOT: | ||
from alphatwirl.roottree import BEvents as Events | ||
from alphatwirl.roottree import Branch | ||
|
||
##__________________________________________________________________|| | ||
pytestmark = pytest.mark.skipif(has_no_ROOT, reason="has no ROOT") | ||
|
||
##__________________________________________________________________|| | ||
@pytest.fixture() | ||
def chain(): | ||
input_file_names = [ | ||
'sample_chain_01.root', | ||
'sample_chain_02.root', | ||
'sample_chain_03.root', | ||
] | ||
input_paths = [ | ||
os.path.join(os.path.dirname(os.path.realpath(__file__)), n) | ||
for n in input_file_names | ||
] | ||
tree_name = 'tree' | ||
chain = ROOT.TChain(tree_name) | ||
for p in input_paths: | ||
chain.Add(p) | ||
yield chain | ||
|
||
@pytest.fixture() | ||
def events(chain): | ||
yield Events(chain) | ||
|
||
def test_event(events): | ||
|
||
content_list = [ | ||
# file 1 | ||
[10, 20, 30], | ||
[24, 5], | ||
|
||
# file 2 | ||
[3, 10], | ||
[5, 8, 32, 15, 2], | ||
[22, 11], | ||
|
||
# file 3 | ||
[2, 7], | ||
[10, 100], | ||
] | ||
|
||
for i, c in enumerate(content_list): | ||
event = events[i] | ||
assert len(c) == event.nvar[0] | ||
assert c == list(event.var) | ||
|
||
##__________________________________________________________________|| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters