@@ -35,6 +35,15 @@ def parse_bin_label(label):
3535 return result
3636
3737
38+ def format_value_with_comment (b ):
39+ """Return Value plus optional (comment=...) suffix."""
40+ val = b .get ("Value" , "" )
41+ comment = b .get ("Comment" , "" )
42+ if comment and comment .upper () != "X" :
43+ return f"{ val } (comment={ comment } )"
44+ return val
45+
46+
3847def ask_user_selection (group ):
3948 """
4049 Prompt user to select bin(s) for this selection group.
@@ -49,49 +58,61 @@ def ask_user_selection(group):
4958
5059 selected_bins = []
5160
52- # Minimal selection
61+ # ----- Minimal selection -----
5362 if minimal_bins :
5463 if len (minimal_bins ) == 1 :
55- # autoselect minimal OPTION
5664 only = minimal_bins [0 ]
57- print (f"\n Selection: { selection_name } — only one minimal option → auto-selecting: { only .get ('Value' ,'' )} " )
65+ print (
66+ f"\n Selection: { selection_name } — only one minimal option → auto-selecting: "
67+ f"{ format_value_with_comment (only )} "
68+ )
5869 selected_bins .append (only )
5970 else :
60- # Multiple → ask user
6171 print (f"\n Selection: { selection_name } " )
6272 for idx , b in enumerate (minimal_bins ):
63- print (f" [{ idx } ] { b . get ( 'Value' , '' )} " )
73+ print (f" [{ idx } ] { format_value_with_comment ( b )} " )
6474 while True :
6575 sel_input = input ("Enter index for minimal cut (0 = loosest minimal): " )
6676 if sel_input .strip () == "" :
6777 sel_input = "0"
6878 try :
6979 sel_idx = int (sel_input )
7080 if 0 <= sel_idx < len (minimal_bins ):
71- selected_bins .append (minimal_bins [sel_idx ])
81+ choice = minimal_bins [sel_idx ]
82+ selected_bins .append (choice )
83+ print (f"Selected: { format_value_with_comment (choice )} " )
7284 break
7385 except ValueError :
7486 pass
7587 print ("Invalid input. Please enter a valid index." )
7688
77- # Optional selection (can skip with 0)
89+ # ----- Optional selection -----
7890 if optional_bins :
79- print (f"Selection : { selection_name } (optional selection, 0 to skip)" )
91+ print (f"\n Selection : { selection_name } (optional selection, 0 to skip)" )
8092 for idx , b in enumerate (optional_bins , start = 1 ):
81- print (f" [{ idx } ] { b .get ('Value' , '' )} " )
93+ print (f" [{ idx } ] { format_value_with_comment (b )} " )
94+
8295 while True :
8396 sel_input = input ("Enter indices separated by space (0 to skip): " )
8497 if not sel_input .strip () or sel_input .strip () == "0" :
98+ print ("Selected: (skipped)" )
8599 break
100+
86101 try :
87102 indices = [int (x ) for x in sel_input .split ()]
88103 if all (0 <= i <= len (optional_bins ) for i in indices ):
104+ chosen = []
89105 for i in indices :
90106 if i != 0 :
91- selected_bins .append (optional_bins [i - 1 ])
107+ b = optional_bins [i - 1 ]
108+ selected_bins .append (b )
109+ chosen .append (format_value_with_comment (b ))
110+
111+ print ("Selected: " + ", " .join (chosen ))
92112 break
93113 except ValueError :
94114 pass
115+
95116 print ("Invalid input. Please enter valid indices separated by space." )
96117
97118 return selected_bins
@@ -163,7 +184,7 @@ def main(rootfile_path, tdir_path="femto-producer"):
163184 summary = {}
164185 for b in selected_bins :
165186 sel = b .get ("SelectionName" , "unknown" )
166- summary .setdefault (sel , []).append (b . get ( "Value" , "" ))
187+ summary .setdefault (sel , []).append (format_value_with_comment ( b ))
167188
168189 for sel , values in summary .items ():
169190 print (f" { sel } : { ', ' .join (values )} " )
0 commit comments