@@ -49,12 +49,20 @@ def ask_user_selection(group):
4949 Prompt user to select bin(s) for this selection group.
5050 - If minimal selections contain exactly 1 entry → auto-select it.
5151 - Optional selections remain user-selectable.
52+ - Neither minimal nor optional selections are shown with a warning — useful for rejection masks.
5253 """
5354 selection_name = group [0 ].get ("SelectionName" , "unknown" )
5455
55- # Separate minimal and optional bins
56+ # Separate bins by type
5657 minimal_bins = [b for b in group if b .get ("MinimalCut" , "0" ) == "1" and b .get ("OptionalCut" , "0" ) == "0" ]
5758 optional_bins = [b for b in group if b .get ("OptionalCut" , "0" ) == "1" ]
59+ neutral_bins = [
60+ b
61+ for b in group
62+ if b .get ("MinimalCut" , "0" ) == "0"
63+ and b .get ("OptionalCut" , "0" ) == "0"
64+ and b .get ("BitPosition" , "X" ).upper () != "X"
65+ ]
5866
5967 selected_bins = []
6068
@@ -107,7 +115,34 @@ def ask_user_selection(group):
107115 b = optional_bins [i - 1 ]
108116 selected_bins .append (b )
109117 chosen .append (format_value_with_comment (b ))
118+ print ("Selected: " + ", " .join (chosen ))
119+ break
120+ except ValueError :
121+ pass
122+
123+ print ("Invalid input. Please enter valid indices separated by space." )
110124
125+ # ----- Neither minimal nor optional-----
126+ if neutral_bins :
127+ print (f"\n Selection: { selection_name } (Neither minimal nor optional, 0 to skip)" )
128+ for idx , b in enumerate (neutral_bins , start = 1 ):
129+ print (f" [{ idx } ] { format_value_with_comment (b )} " )
130+
131+ while True :
132+ sel_input = input ("Enter indices separated by space (0 to skip): " )
133+ if not sel_input .strip () or sel_input .strip () == "0" :
134+ print ("Selected: (skipped)" )
135+ break
136+
137+ try :
138+ indices = [int (x ) for x in sel_input .split ()]
139+ if all (0 <= i <= len (neutral_bins ) for i in indices ):
140+ chosen = []
141+ for i in indices :
142+ if i != 0 :
143+ b = neutral_bins [i - 1 ]
144+ selected_bins .append (b )
145+ chosen .append (format_value_with_comment (b ))
111146 print ("Selected: " + ", " .join (chosen ))
112147 break
113148 except ValueError :
0 commit comments