12 from matplotlib
import pyplot
as pl
13 from basf2
import logging, LogLevel, create_path, process
14 from hist_utils
import hist2array
17 import matplotlib
as mpl
21 logging.log_level = LogLevel.ERROR
26 main.add_module(
"EventInfoSetter", evtNumList=[1])
28 main.add_module(
"Gearbox")
31 geometry = main.add_module(
33 logLevel=LogLevel.INFO,
37 main.add_module(
'FullSim')
39 materialscan = main.add_module(
"MaterialScan", logLevel=LogLevel.INFO)
42 'Filename':
'MaterialRay.root',
54 'ray.sampleDepth': 0.1,
67 rmaterial_file = root.TFile(
"MaterialRay.root")
70 def plot_hist(region, **argk):
71 """Get the histogram for a given region from the file and plot it. Return the histogram data and edges"""
72 h = rmaterial_file.Get(
"Ray/%s_x0" % region)
75 data, edges = hist2array(h, return_edges=
True)
76 data = np.append(data, 0)
77 edges[-1][-1] = h.GetXaxis().GetXmax()
79 pl.plot(edges[0], data, drawstyle=
"steps-post", **argk)
84 all_data, mat_edges = plot_hist(
"All_Regions", label=
"All regions", c=
"k")
87 for region
in [
"BeamPipe",
"PXD",
"SVD",
"CDC",
"ARICH",
"TOP",
"ECL",
"EKLM",
"BKLM",
"STR",
"COIL"]:
88 plot_hist(region, label=region)
93 pl.xlim(xmin=mat_edges[0], xmax=mat_edges[-1] + 1)
94 pl.xlabel(
"Flight length [cm]")
95 pl.ylabel(
"Radiation length [$X_0 / %.3g$ cm]" % (mat_edges[1] - mat_edges[0]))
98 pl.savefig(
"MaterialRay.pdf")