4 from basf2
import logging, LogLevel, create_path, process
7 import matplotlib
as mpl
9 from matplotlib
import pyplot
as pl
10 from root_numpy
import hist2array
13 logging.log_level = LogLevel.ERROR
18 main.add_module(
"EventInfoSetter", evtNumList=[1])
20 main.add_module(
"Gearbox")
23 geometry = main.add_module(
"Geometry", logLevel=LogLevel.INFO, assignRegions=
True)
26 main.add_module(
'FullSim')
28 materialscan = main.add_module(
"MaterialScan", logLevel=LogLevel.INFO)
31 'Filename':
'MaterialRay.root',
43 'ray.sampleDepth': 0.1,
56 rmaterial_file = root.TFile(
"MaterialRay.root")
59 def plot_hist(region, **argk):
60 """Get the histogram for a given region from the file and plot it. Return the histogram data and edges"""
61 h = rmaterial_file.Get(
"Ray/%s_x0" % region)
64 data, edges = hist2array(h, return_edges=
True)
68 data = np.append(data, 0)
70 pl.plot(edges[0], data, drawstyle=
"steps-post", **argk)
75 all_data, mat_edges = plot_hist(
"All_Regions", label=
"All regions", c=
"k")
78 for region
in [
"BeamPipe",
"PXD",
"SVD",
"CDC",
"ARICH",
"TOP",
"ECL",
"EKLM",
"BKLM",
"STR",
"COIL"]:
79 plot_hist(region, label=region)
84 pl.xlim(xmin=mat_edges[0], xmax=mat_edges[-1]+1)
85 pl.xlabel(
"Flight length [cm]")
86 pl.ylabel(
"Radiation length [$X_0 / %.3g$ cm]" % (mat_edges[1] - mat_edges[0]))
89 pl.savefig(
"MaterialRay.pdf")