Reweight card output
@@ -158,6 +158,37 @@ class MadMiner():
with open(mg_process_directory + '/Cards/param_card.dat') as file:
file.write(param_card)
- # Write reweight_card.dat
+ # Open reweight_card template
+ with open(reweight_card_template_file) as file:
+ reweight_card = file.read()
+
+ # Put in parameter values
+ block_end = reweight_card.search('# Manual')
+ assert block_end >= 0, 'Cannot find "# Manual" string in reweight_card template'
+
+ insert_pos = reweight_card.rsearch('\n\n')
+ assert insert_pos >= 0, 'Cannot find empty line in reweight_card template'
+
+ lines = []
+ for benchmark_name, benchmark in self.benchmarks:
+ if benchmark_name == sample_benchmark:
+ continue
+
+ lines.append('')
+ lines.append('# MadMiner benchmark ' + benchmark_name)
+ lines.append('launch')
+
+ for parameter_name, parameter_value in benchmark.keys():
+ parameter_lha_block = self.parameters[parameter_name][0]
+ parameter_lha_id = self.parameters[parameter_name][1]
+
+ lines.append(' set {0} {1} {2}')
+
+ lines.append('')
+
+ reweight_card = reweight_card[:insert_pos] + '\n'.join(lines) + reweight_card[insert_pos:]
+
+ # Save param_card.dat
+ with open(mg_process_directory + '/Cards/reweight_card.dat') as file:
+ file.write(reweight_card)
- # TODO
