Skip to content

Commit

Permalink
outsource creation of 2D hists to function
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor-Schwan committed Sep 26, 2024
1 parent 00de82a commit 80d9cc4
Showing 1 changed file with 21 additions and 30 deletions.
51 changes: 21 additions & 30 deletions utils/material_plots_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
from plotstyle import FCCStyle


def create_histogram(
name_and_title: str, argument_name_space: argparse.Namespace
) -> ROOT.TH2F:
return ROOT.TH2F(
name_and_title,
name_and_title,
int(
(argument_name_space.angleMax - argument_name_space.angleMin)
/ argument_name_space.angleBinning
),
argument_name_space.angleMin,
argument_name_space.angleMax,
argument_name_space.nPhiBins,
-math.pi,
math.pi,
)


def main():
parser = argparse.ArgumentParser(description="Material Plotter")
parser.add_argument(
Expand Down Expand Up @@ -87,36 +105,9 @@ def main():

ROOT.gROOT.SetBatch(1)

h_x0 = ROOT.TH2F(
"h_x0",
"h_x0",
int((args.angleMax - args.angleMin) / args.angleBinning),
args.angleMin,
args.angleMax,
args.nPhiBins,
-math.pi,
math.pi,
)
h_lambda = ROOT.TH2F(
"h_lambda",
"h_lambda",
int((args.angleMax - args.angleMin) / args.angleBinning),
args.angleMin,
args.angleMax,
args.nPhiBins,
-math.pi,
math.pi,
)
h_depth = ROOT.TH2F(
"h_depth",
"h_depth",
int((args.angleMax - args.angleMin) / args.angleBinning),
args.angleMin,
args.angleMax,
args.nPhiBins,
-math.pi,
math.pi,
)
h_x0 = create_histogram("h_x0", args)
h_lambda = create_histogram("h_lambda", args)
h_depth = create_histogram("h_depth", args)

for angleBinning, entry in enumerate(tree):
nMat = entry.nMaterials
Expand Down

0 comments on commit 80d9cc4

Please sign in to comment.