Skip to content

Commit

Permalink
histogram name is set to the file name value; index is only added for…
Browse files Browse the repository at this point in the history
… > 1 pages
  • Loading branch information
kbat committed Nov 29, 2024
1 parent d5741f6 commit 2cfea81
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mctools/phits/angel2root.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Usage: angel2root.py file.dat
#

import sys, re, argparse
import sys, re, argparse, os
from array import array
from mctools.phits.phits import TallyOutputParser
import ROOT
Expand Down Expand Up @@ -66,6 +66,7 @@ class Angel:
output_title = None # commented part of output line - for z-title
unit = None
unit_title = None # commented part of the unit line - for z-title
file = None # file name as defined in the PHITS tally
part = [] # list of particles
lines = []
return_value = 0
Expand Down Expand Up @@ -176,6 +177,9 @@ def __init__(self, fname_in, fname_out, **kwargs):
self.unit_title = ' '.join(words[6:])
if self.output_title != None: self.ztitle = self.output_title + " " + self.unit_title
continue
if re.search("file = ", line):
words = line.split()
self.file, ext = os.path.splitext(words[2])

##################################################
# scan the remaining data pages one by one
Expand Down Expand Up @@ -380,7 +384,8 @@ def Read1DHist(self, iline):
else: subtitle = ''
self.FixTitles()
# self.ihist+1 - start from ONE as in Angel - easy to compare
h = TH1F("h%d" % (self.ihist+1), "%s%s;%s;%s" % (self.title, subtitle, self.xtitle, self.ytitle), nbins, array('f', xarray))
hname=self.file if nhist == 1 else "%s%d" % (self.file, self.ihist+1)
h = TH1F(hname, "%s%s;%s;%s" % (self.title, subtitle, self.xtitle, self.ytitle), nbins, array('f', xarray))
if self.avBitSet:
h.SetBit(TH1F.kIsAverage)
self.ihist += 1
Expand Down

0 comments on commit 2cfea81

Please sign in to comment.