Skip to content

Commit

Permalink
adding counters
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger committed Sep 10, 2024
1 parent 2cbc111 commit 9227d4b
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class RootPropagationSummaryWriter : public WriterT<PropagationSummaries> {

/// Propagation summary statstics
int m_nSensitives = 0;
int m_nMaterials = 0;
int m_nMaterials = 0;
int m_nPortals = 0;

// steper statistics
Expand Down
16 changes: 8 additions & 8 deletions Examples/Io/Root/src/RootPropagationSummaryWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ ProcessCode RootPropagationSummaryWriter::writeT(

// Loop over the steps & count for the statistics
std::ranges::for_each(summary.steps, [&](const auto& step) {
// Check if the step is a sensitive step
if (step.geoID.sensitive() > 0) {
m_nSensitives++;
}
// Check if the step is a portal step
if (step.geoID.boundary() > 0) {
m_nPortals++;
}
// Check if the step is a sensitive step
if (step.geoID.sensitive() > 0) {
m_nSensitives++;
}
// Check if the step is a portal step
if (step.geoID.boundary() > 0) {
m_nPortals++;
}

if (step.surface != nullptr) {
// Check if the step is a material step
Expand Down
132 changes: 79 additions & 53 deletions Examples/Scripts/Propagation/propagation_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,76 @@
p = argparse.ArgumentParser()

p.add_argument(
"-i",
"--input",
nargs="+",
type=str,
default="",
help="Input file(s) with propagation summary",
)
"-i",
"--input",
nargs="+",
type=str,
default="",
help="Input file(s) with propagation summary",
)

p.add_argument(
"-l",
"--label",
nargs="+",
type=str,
default="",
help="Input label(s) for the propagation summary",
)
"-l",
"--label",
nargs="+",
type=str,
default="",
help="Input label(s) for the propagation summary",
)

p.add_argument(
"-c",
"--color",
nargs="+",
type=str,
default="",
help="Input label(s) for the propagation summary",
)
"-c",
"--color",
nargs="+",
type=str,
default="",
help="Input label(s) for the propagation summary",
)

p.add_argument(
"-m",
"--marker",
nargs="+",
type=str,
default=["o"],
choices=["o", "s", "D", "v", "^", "<", ">", "p", "P", "*", "h", "H", "+", "x", "X", "d"],
help="Input label(s) for the propagation summary",
)
"-m",
"--marker",
nargs="+",
type=str,
default=["o"],
choices=[
"o",
"s",
"D",
"v",
"^",
"<",
">",
"p",
"P",
"*",
"h",
"H",
"+",
"x",
"X",
"d",
],
help="Input label(s) for the propagation summary",
)

p.add_argument(
"-o",
"--output",
type=str,
default="",
help="Output file base name",
)
"-o",
"--output",
type=str,
default="",
help="Output file base name",
)

args = p.parse_args()

try :
try:

fig, ax = plt.subplots(1, 1, figsize=(11, 10))

eta_bins = np.linspace(-4, 4, 100)
eta_centers = 0.5 * (eta_bins[:-1] + eta_bins[1:])
eta_width = 8./100
eta_width = 8.0 / 100

for ir, irfile in enumerate(args.input):
# load the tree
Expand All @@ -72,31 +89,40 @@
portals = tree["nPortals"].array(library="np")
materials = tree["nMaterials"].array(library="np")

df = pd.DataFrame({'eta': eta, 'phi': phi, 'sens': sens, 'portals': portals, 'materials': materials})
df = pd.DataFrame(
{
"eta": eta,
"phi": phi,
"sens": sens,
"portals": portals,
"materials": materials,
}
)

df['eta_bin'] = np.digitize(eta, bins=eta_bins)
df["eta_bin"] = np.digitize(eta, bins=eta_bins)

# grouby bin, so we can calculate stuff
eta_binned = df.groupby('eta_bin')
sens_result = eta_binned['sens'].agg(['mean', 'sem'])
sens_result['eta'] = eta_centers
sens_result['xerr'] = eta_width / 2
eta_binned = df.groupby("eta_bin")
sens_result = eta_binned["sens"].agg(["mean", "sem"])
sens_result["eta"] = eta_centers
sens_result["xerr"] = eta_width / 2

sens_result.plot(
x='eta',
y='mean',
xerr='xerr',
yerr='sem',
linestyle='none',
x="eta",
y="mean",
xerr="xerr",
yerr="sem",
linestyle="none",
capsize=1,
marker=args.marker[ir],
label=args.label[ir],
ax=ax)
ax.set_xlabel(r'$\eta$')
ax.set_ylabel('Avg. Number of sensitive modules / track')
ax=ax,
)
ax.set_xlabel(r"$\eta$")
ax.set_ylabel("Avg. Number of sensitive modules / track")

fig.show()

except:
print("The number of input files and labels must match")
exit()

0 comments on commit 9227d4b

Please sign in to comment.