Skip to content

Commit

Permalink
Minor modifs to energy correction script
Browse files Browse the repository at this point in the history
  • Loading branch information
BrieucF authored and vvolkl committed Jul 14, 2021
1 parent 7f6033a commit 895db73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Detector/DetStudies/scripts/cec_derive1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import argparse
import json
import os


def main():
Expand All @@ -17,6 +18,8 @@ def main():
help='additional note to be displayed in the plots')
parser.add_argument('--theta-slice', type=float, default=90.,
help='select theta slice for the correction derivation')
parser.add_argument('--plot-file-format', type=str, default='pdf', help='plot output file format')
parser.add_argument('--plot-directory', type=str, default='./', help='Directory of the output plots')

required_arguments = parser.add_argument_group('required arguments')
required_arguments.add_argument('-i', '--input-file', type=str, required=True, help='Input file path')
Expand All @@ -35,6 +38,9 @@ def main():
args.notes.append('#theta = %i deg' % (args.theta_slice))
print('WARNING: Using default plot legend notes.')

if not os.path.isdir(args.plot_directory):
os.mkdir(args.plot_directory)

from ROOT import gROOT
gROOT.SetBatch(True)

Expand Down Expand Up @@ -216,8 +222,7 @@ def plot(obj, plotname, args=None):
obj.Draw('APEL')
legend.Draw()
plotname += '_%ideg' % (args.theta_slice)
canvas.Print(plotname + '.pdf')

canvas.Print(os.path.join(args.plot_directory, plotname + '.' + args.plot_file_format))

if __name__ == '__main__':
main()
6 changes: 5 additions & 1 deletion Detector/DetStudies/scripts/cec_process_events
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def main():
help='additional note to be displayed in the plots')
parser.add_argument('-o', '--output', type=str, default='fit_results.json', help='output JSON file name')
parser.add_argument('--plot-file-format', type=str, default='pdf', help='plot output file format')
parser.add_argument('--plot-directory', type=str, default='./', help='Directory of the output plots')

required_arguments = parser.add_argument_group('required arguments')
required_arguments.add_argument('-i', '--input-file', type=str, required=True, help='input file path')
Expand Down Expand Up @@ -85,6 +86,9 @@ def main():
print(' ' + args.input_file)
exit(1)

if not os.path.isdir(args.plot_directory):
os.mkdir(args.plot_directory)

from ROOT import gROOT, TFile, TH2D, TF1
gROOT.SetBatch(True)

Expand Down Expand Up @@ -251,7 +255,7 @@ def plot(obj, plotname, args):

obj.Draw(draw_options)
legend.Draw()
canvas.Print(plotname + '.' + args.plot_file_format)
canvas.Print(os.path.join(args.plot_directory, plotname + '.' + args.plot_file_format))


def count_bins_with_error(hist):
Expand Down

0 comments on commit 895db73

Please sign in to comment.