diff --git a/python-scripts/read_defined_branch.py b/python-scripts/read_defined_branch.py index d78c259cfa18cb0e23fb831e8c7096834ea759cc..67a15b79b49f801a9a4a93a8391c9cad25a67d14 100644 --- a/python-scripts/read_defined_branch.py +++ b/python-scripts/read_defined_branch.py @@ -97,12 +97,19 @@ class defined_branch : return " tree->SetBranchAddress(\"" + self.name + "\", &" + self.name + ", &b" + self.name + ");\n" + def get_statement3(self, in_used) : + if in_used : + return " tree->SetBranchStatus(\"" + self.name + "\", 1);\n" + else : + return " tree->SetBranchStatus(\"" + self.name + "\", 0);\n" + def debug(self) : self.print() print(" # statement1") print(self.get_statement1()) print(" # statement2") print(self.get_statement2()) + print(self.get_statement3(1)) @@ -121,14 +128,17 @@ def config_file_to_branch_information_array(path) : def get_branch_statements_1(branches) : line = [] for branch in branches : - branch.debug() line.append(branch.get_statement1()) return line def get_branch_statements_2(branches) : line = [] for branch in branches : - branch.debug() line.append(branch.get_statement2()) - print(line) + return line + +def get_branch_statements_3(branches, counts) : + line = [] + for i, branch in enumerate(branches) : + line.append(branch.get_statement3(bool(counts[i] > 0))) return line diff --git a/python-scripts/setup.py b/python-scripts/setup.py index 7045c3cc031b39beb6ab4af19c5f4a18c629f143..f4fa393b9090587868dbc03d1670b4e0f28cb8fe 100644 --- a/python-scripts/setup.py +++ b/python-scripts/setup.py @@ -72,11 +72,10 @@ if debug_mode : print("class list") print(classes) -raw = [] -raw.extend(utils.extract_file(tree_dat)) +#raw = [] +#raw.extend(utils.extract_file(tree_dat)) -branch = utils.extract_branch(raw) -branch_names = branch[0] +#branch = utils.extract_branch(raw) definition = [] @@ -156,13 +155,6 @@ with open(info_dir+"/variables_next.txt", "w") as f : import numpy as np -counts = np.zeros(len(branch_names)) - -for l in definition : - for i in range(len(branch_names)) : - c = l.count(branch_names[i]) - counts[i] += c - #setBranchAddress = [] # #for i in range(len(branch[0])): @@ -179,11 +171,22 @@ for l in definition : +## SetAddress of Original Branches +## + 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_2(original_branches), chick, "/*-* INSERT POINT OF SETBRANCHADRESS *-*/") +counts = np.zeros(len(original_branches)) +for l in definition : + for i in range(len(original_branches)) : + c = l.count(original_branches[i].name) + counts[i] += c +chick = utils.insert_line(read_defined_branch.get_branch_statements_3(original_branches, counts), chick, "/*-* INSERT POINT OF SETBRANCHADRESS *-*/") + +## bird = []