12 from root_numpy
import hist2array
13 from matplotlib
import pyplot
as pl
14 from basf2
import logging, LogLevel, create_path, process
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)
79 data = np.append(data, 0)
81 pl.plot(edges[0], data, drawstyle=
"steps-post", **argk)
86 all_data, mat_edges = plot_hist(
"All_Regions", label=
"All regions", c=
"k")
89 for region
in [
"BeamPipe",
"PXD",
"SVD",
"CDC",
"ARICH",
"TOP",
"ECL",
"EKLM",
"BKLM",
"STR",
"COIL"]:
90 plot_hist(region, label=region)
95 pl.xlim(xmin=mat_edges[0], xmax=mat_edges[-1] + 1)
96 pl.xlabel(
"Flight length [cm]")
97 pl.ylabel(
"Radiation length [$X_0 / %.3g$ cm]" % (mat_edges[1] - mat_edges[0]))
100 pl.savefig(
"MaterialRay.pdf")