From 8e4e4513057b2568a8f26cb4e194328de81b417a Mon Sep 17 00:00:00 2001 From: Hideki Shimizu Date: Fri, 11 Dec 2020 04:25:29 +0900 Subject: [PATCH] apply changes in setup.py --- python-scripts/read_defined_branch.py | 11 ++++++++ python-scripts/setup.py | 38 ++++++++++++++++----------- python-scripts/utils.py | 10 +++++-- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/python-scripts/read_defined_branch.py b/python-scripts/read_defined_branch.py index 7c05e20..6fe8e12 100644 --- a/python-scripts/read_defined_branch.py +++ b/python-scripts/read_defined_branch.py @@ -118,3 +118,14 @@ def config_file_to_branch_information_array(path) : b.debug() branches.append(b) +def get_branch_statements_1(branches) : + line = [] + for branch in branches : + line.append(branch.get_statement1()) + return line + +def get_branch_statements_2(branches) : + line = [] + for branch in branches : + line.append(branch.get_statement2()) + return line diff --git a/python-scripts/setup.py b/python-scripts/setup.py index 6908b6d..c02ae2d 100644 --- a/python-scripts/setup.py +++ b/python-scripts/setup.py @@ -7,10 +7,12 @@ # ############################## -import utils import os import sys +import utils +import read_defined_branch + if len(sys.argv) > 1 : option = sys.argv[1] else : @@ -70,7 +72,6 @@ if debug_mode : print("class list") print(classes) - raw = [] raw.extend(utils.extract_file(tree_dat)) @@ -112,7 +113,6 @@ for var in variables : chick = utils.insert_line(bra ,chick, "/*-* INSERT POINT VARIABLES *-*/") - for var in variables : if var.Number > 1 : definition.append("for(Int_t i=0; i<"+str(var.Number)+";i++){") @@ -163,19 +163,27 @@ for l in definition : c = l.count(branch_names[i]) counts[i] += c -setBranchAddress = [] +#setBranchAddress = [] +# +#for i in range(len(branch[0])): +# if branch[1][i] == 0 and branch[2][i] == 0 : +# setBranchAddress.append(" tree->SetBranchAddress(\""+str(branch[0][i])+"\", &"+str(branch[0][i])+");") +# if (counts[i] == 0) : +# setBranchAddress.append(" tree->SetBranchStatus(\""+str(branch[0][i])+"\", 0);") +# else : +# setBranchAddress.append(" tree->SetBranchAddress(\""+str(branch[0][i])+"\", "+str(branch[0][i])+");") +# if (counts[i] == 0) : +# setBranchAddress.append(" tree->SetBranchStatus(\""+str(branch[0][i])+"\", 0);") +#chick = utils.insert_line(raw , chick, "/*-* INSERT POINT FROM TREE *-*/") +#chick = utils.insert_line(setBranchAddress , chick, "/*-* INSERT POINT OF SETBRANCHADRESS *-*/") + + + +original_branches = read_defined_branch.config_file_to_branch_information_array(tree_dat) + +chick = utils.insert_line(read_defined_branch.get_branch_statements_1(original_branches), chick, "/*-* INSERT POINT FROM TREE *-*/") +chick = utils.insert_line(read_defined_branch.get_branch_statements_1(original_branches), chick,, "/*-* INSERT POINT OF SETBRANCHADRESS *-*/") -for i in range(len(branch[0])): - if branch[1][i] == 0 and branch[2][i] == 0 : - setBranchAddress.append(" tree->SetBranchAddress(\""+str(branch[0][i])+"\", &"+str(branch[0][i])+");") - if (counts[i] == 0) : - setBranchAddress.append(" tree->SetBranchStatus(\""+str(branch[0][i])+"\", 0);") - else : - setBranchAddress.append(" tree->SetBranchAddress(\""+str(branch[0][i])+"\", "+str(branch[0][i])+");") - if (counts[i] == 0) : - setBranchAddress.append(" tree->SetBranchStatus(\""+str(branch[0][i])+"\", 0);") -chick = utils.insert_line(raw , chick, "/*-* INSERT POINT FROM TREE *-*/") -chick = utils.insert_line(setBranchAddress , chick, "/*-* INSERT POINT OF SETBRANCHADRESS *-*/") bird = [] diff --git a/python-scripts/utils.py b/python-scripts/utils.py index 1af14ae..2bbb11c 100644 --- a/python-scripts/utils.py +++ b/python-scripts/utils.py @@ -25,6 +25,7 @@ _type.append(["ULong_t", "unsigned long", "l"]) _type.append(["ULong64_t", "unsigned long long", "l"]) + def isExt(path, ext) : r, e = os.path.splitext(path) return e == ext @@ -86,8 +87,13 @@ def insertLine(inputLine, targetFile, symbol, outputFile = open("output.text","w ''' -# new -def extract_branch(lines) : +### +### input : list of txt of tree.dat +### output : [ [name1, name2, ...], [number1, number2, ...], [channel1, channel2, ...]] +### +### + +def extract_branch(lines) : _types = [] for t in _type : _types.append(t[0]) -- GitLab