Proper(?) modification to avoid cppyy.ll.SegmentationViolation in angel2root.py - #16
Open
furutaka wants to merge 10 commits into
Open
Proper(?) modification to avoid cppyy.ll.SegmentationViolation in angel2root.py#16furutaka wants to merge 10 commits into
furutaka wants to merge 10 commits into
Conversation
added 7 commits
July 10, 2026 14:32
…Write()" The "fix" in PR#14 was completely wrong; it didn't work for multiple plots in a file. We had to take the modification described in kbat#14 (comment)
There may be multiple plots in a page.
In the 1st page, there're lines which should be processed as a group, e.g. "mesh = reg" and "multiplier = " and so on. To process groups of lines, `for` loop is not convenient, because one has to advance the line pointer the fixed amount according to the kind of group the lines belong. Therefore, the type of loop for use to scan the 1st header page was changed from `for` to `while`. To check the working, many debug-prints were added, and multiple DEBUG levels were introduced (more verbose with larger DEBUG).
To differentiate multiple TH1 histograms. Added more debug-prints.
For unknown reasons (to K.F), in order for TGraphErrors to avoid cppyy.ll.SegmentationViolation, you need one more effort to release the ownership. For this, now we don't import ROOT from ROOT, because ROOT is regarded as an object when the import is done. Similarly as histograms, now the names of graphs (may) depend on the page numbers as well as the comments.
There are cases in which the string between a pair of parentheses
in a "h:" line, "y(...)", includes whitespaces.
e.g. "h: n x y(zmin 0.000E+00),hh0l n ..."
in PHITS/recommendation/ParticleTherapy/y-distribution.out
In those cases, the subtitle of a histogram would become an empty
string, and mulitple histograms have all the same name, and a
warning is issued such as:
TFile::Append:0: RuntimeWarning: Replacing existing TH1: ... \
(Potential memory leak).
The cause of the problem is the splitting of "h:" line by whitespaces.
To properly split the line, splitHline() was added for use
in GetNhist().
To do so, the corresponding regular expression has been changed from "^h[2dc]:" to "^h([2d]|c2?):" (although the plot type, "hc2:", seems NOT to be mentioned in the manuals of PHITS v.3.36 or v4.53). Do NOT `continue` processing the page after returning from Read2DHist(); `break` to proceed to the next plot page: we don't have to read color-palette data etc.
Collaborator
Author
|
Well... I noticed my terribly bad language in the commit message of my last commit. Tomorrow I will fix it at work, so please wait for the fix.... Thanks. |
added 3 commits
July 17, 2026 14:15
PHITS manual reads "There are 8 kinds of mesh definition..." https://phits.jaea.go.jp/manual/PHITS-en/chapters/tally-format.html#mesh-definition but 'l' definition (for LET?) was overlooked. This modification enables the conversion of the following angel files: PHITS/lecture/old-lecture/ex023/let.out PHITS/lecture/old-lecture/ex023/letr.out PHITS/recommendation/ParticleTherapy/let-distribution.out
To do this, a Boolean argument, `tet` is added to
Read1DGraphErrors(). If tet = True, the column to start
reading the data is shifted right by 2 ("tetra" and "volume"
columns are skipped):
"# num tetra volume all r.err ..."
There seems to be only one "mesh = tet" angel file included
with phits v.3.36: utility/FLUENT/PHITS/Tetra_test1_deposit.out
…ns added by "sangel = ..." In that case, the tally data is preceded by the additiona angel instruction (which may be other plot(s) of data).
|
Collaborator
Author
|
FYI: I'm not sure whether we need this or not... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Hi.
I must apologize that the previous PR I made was wrong; the script still SEGVs in case there are multiple plots in an angel file. We must use the way I described in this comment.
Further, the modification which can avoid SEGV for
TH1is not enough forTGraphErros; we have to explicitly release the ownership by usingROOT.SetOwnership().In addition to the above, I changed the loop to scan the 1st page from
forto `while, to process some lines as a group.The present modifications also include
numPlotstonumPlotPages,I have checked the function of the script by converting many angel files coming with PHITS v.3.36.
Many of them could be successfully converted, some failed (later I'll investigate the reasons).
I'd like to ask you to carefully review the modification: I have one criminal record!
TODOs:
h:andn/x.# gshow.