Skip to content

Commit 562e0f9

Browse files
committed
added trees for JES & JER to add control regions
1 parent 47cee7f commit 562e0f9

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

experimental/add_control_region.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def create_new_trees(input_file, suffix = ''):
2222
cr1 = 'TTbar_plus_X_analysis/MuPlusJets/QCD 0.12 < iso <= 0.3'
2323
cr2 = 'TTbar_plus_X_analysis/MuPlusJets/QCD iso > 0.3'
2424

25-
with root_open(input_file) as f:
26-
t1 = f.Get(tree1_name)
27-
t2 = f.Get(tree2_name)
25+
with root_open(input_file) as file:
26+
t1 = file.Get(tree1_name)
27+
t2 = file.Get(tree2_name)
2828
t1.AddFriend(t2)
2929

3030
# h1 = t1.Draw('MET', 'relIso_04_deltaBeta > 0.3')
@@ -60,10 +60,22 @@ def create_new_trees(input_file, suffix = ''):
6060
new_tree2 = f_in.Get(cr2 + '/FitVariables' + suffix).CloneTree()
6161

6262
for f in input_files:
63-
shutil.copy(input_folder + f, f)
6463
for suffix in ['', '_JERDown', '_JERUp', '_JESDown', '_JESUp']:
64+
fileToUse = f
6565
if 'data' in f and not suffix == '':
6666
continue
67-
create_new_trees(f, suffix=suffix)
68-
subprocess.call(['hadoop', 'fs', '-rm', output_folder + f])
69-
subprocess.call(['hadoop', 'fs', '-copyFromLocal', f, output_folder + f])
67+
68+
if suffix == '_JERDown':
69+
fileToUse = f.replace('tree','minusJER_tree')
70+
elif suffix == '_JERUp':
71+
fileToUse = f.replace('tree','plusJER_tree')
72+
elif suffix == '_JESDown':
73+
fileToUse = f.replace('tree','minusJES_tree')
74+
elif suffix == '_JESUp':
75+
fileToUse = f.replace('tree','plusJES_tree')
76+
77+
shutil.copy(input_folder + fileToUse, fileToUse)
78+
79+
create_new_trees(fileToUse, suffix=suffix)
80+
subprocess.call(['hadoop', 'fs', '-rm', output_folder + fileToUse])
81+
subprocess.call(['hadoop', 'fs', '-copyFromLocal', fileToUse, output_folder + fileToUse])

0 commit comments

Comments
 (0)