@@ -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
6262for 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