From 6f41d5da5e985ecc2539e4c71737946411f0b3fc Mon Sep 17 00:00:00 2001 From: "Kazuyoshi Furutaka (work)" Date: Thu, 28 May 2026 14:54:56 +0900 Subject: [PATCH 1/2] To avoid cppyy.ll.SegmentationViolation in doing self.histos.Write() --- mctools/phits/angel2root.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mctools/phits/angel2root.py b/mctools/phits/angel2root.py index 26bf99b..b2a0ffa 100755 --- a/mctools/phits/angel2root.py +++ b/mctools/phits/angel2root.py @@ -251,7 +251,7 @@ def __init__(self, fname_in, fname_out, **kwargs): if self.histos.GetEntries(): fout = TFile(self.fname_out, "recreate") - self.histos.Write() + fout.Write() fout.Close() self.return_value = 0 else: From ef9e033c1f491744f2874f07d8e74aff0d8024e0 Mon Sep 17 00:00:00 2001 From: "Kazuyoshi Furutaka (work)" Date: Wed, 3 Jun 2026 13:29:39 +0900 Subject: [PATCH 2/2] angel2root.py: ugly but works without cppyy.ll.SegmentationViolation With the previous modification, it did not spit SEGV but NO histograms were saved in the output file. The present one works, although looks a bit ugly... --- mctools/phits/angel2root.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mctools/phits/angel2root.py b/mctools/phits/angel2root.py index b2a0ffa..f3fdc3d 100755 --- a/mctools/phits/angel2root.py +++ b/mctools/phits/angel2root.py @@ -225,17 +225,20 @@ def __init__(self, fname_in, fname_out, **kwargs): if re.search("^h", line): if re.search("^h: [nx]", line): # !!! We are looking for 'h: n' instead of 'h' due to rz-plots. if DEBUG: print("one dimentional graph section") - self.Read1DHist(igline) + tmp_h = self.Read1DHist(igline) + self.histos.Add(tmp_h) continue elif re.search("h: x", line): - self.Read1DGraphErrors(igline) + tmp_g = self.Read1DGraphErrors(igline) + self.histos.Add(tmp_g) continue elif re.search("^h[2dc]:", line): if DEBUG: if re.search("^h2", line): print("h2: two dimentional contour plot section") if re.search("^hd", line): print("hd: two dimentional cluster plot section") if re.search("^hc", line): print("hc: two dimentional colour cluster plot section") - self.Read2DHist(igline) + tmp_h = self.Read2DHist(igline) + self.histos.Add(tmp_h) continue elif 'reg' in self.axis: # line starts with 'h' and axis is 'reg' => 1D histo in region mesh. For instance, this is whe case with [t-deposit] tally and mesh = reg. self.Read1DHist(igline) @@ -246,12 +249,13 @@ def __init__(self, fname_in, fname_out, **kwargs): if DEBUG: print("1D") else: if DEBUG: print("2D") -# self.Make2Dfrom1D() +# tmp_h2 = self.Make2Dfrom1D() +# self.histos.Add(tmp_h2) if self.histos.GetEntries(): fout = TFile(self.fname_out, "recreate") - fout.Write() + self.histos.Write() fout.Close() self.return_value = 0 else: @@ -405,7 +409,7 @@ def Read1DHist(self, iline): h.GetXaxis().SetBinLabel(i+1, bin_labels[i]) h.GetXaxis().SetTitle("Region number") - self.histos.Add(h) + return h del self.subtitles[:] def Read1DGraphErrors(self, iline): @@ -448,7 +452,7 @@ def Read1DGraphErrors(self, iline): g.SetPoint(i, x, y) g.SetPointError(i, 0, ey*y) - self.histos.Add(g) + return g del self.subtitles[:] @@ -600,7 +604,7 @@ def Make2Dfrom1D(self): h2.SetBinError(binx+1, biny+1, h1.GetBinError(binx+1)) - self.histos.Add(h2) + return h2