Skip to content

Commit bed77cd

Browse files
committed
Feat: update cutculator
1 parent c30beef commit bed77cd

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

PWGCF/Femto/Core/baseSelection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ class BaseSelection
386386
}
387387
LOG(info) << "";
388388
}
389+
LOG(info) << "Number of occupied bits: " << mNSelectionBits << " / " << sizeof(BitmaskType) * CHAR_BIT;
389390
LOG(info) << "Printing done";
390391
}
391392

PWGCF/Femto/Core/selectionContainer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ class SelectionContainer
360360
std::ostringstream oss;
361361
std::string sectionDelimiter = ":::";
362362
std::string valueDelimiter = "___";
363+
std::string noValue = "X";
363364
oss << "SelectionName" << valueDelimiter << mSelectionName << sectionDelimiter
364365
<< "LimitType" << valueDelimiter << getLimitTypeAsString() << sectionDelimiter
365366
<< "MinimalCut" << valueDelimiter << (mIsMinimalCut ? "1" : "0") << sectionDelimiter
@@ -368,7 +369,8 @@ class SelectionContainer
368369
<< "Shift" << valueDelimiter << getShift() << sectionDelimiter
369370
<< "Offset" << valueDelimiter << mOffset << sectionDelimiter
370371
<< "Value" << valueDelimiter << (mSelectionFunctions.empty() ? std::to_string(mSelectionValues.at(selectionIndex)) : mSelectionFunctions.at(selectionIndex).GetExpFormula().Data()) << sectionDelimiter
371-
<< "BitPosition" << valueDelimiter << (mSkipMostPermissiveBit ? (selectionIndex == 0 ? "X" : std::to_string(mOffset + selectionIndex - 1)) : std::to_string(mOffset + selectionIndex));
372+
<< "BitPosition" << valueDelimiter << (mSkipMostPermissiveBit ? (selectionIndex == 0 ? noValue : std::to_string(mOffset + selectionIndex - 1)) : std::to_string(mOffset + selectionIndex)) << sectionDelimiter
373+
<< "Comment" << valueDelimiter << (mComments.empty() ? noValue : mComments.at(selectionIndex));
372374
return oss.str();
373375
}
374376

PWGCF/Femto/Macros/cutculator.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
3847
def 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"\nSelection: {selection_name} — only one minimal option → auto-selecting: {only.get('Value','')}")
65+
print(
66+
f"\nSelection: {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"\nSelection: {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"\nSelection: {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

Comments
 (0)