From 895db73bd73c3e7964e9b6900a54423431ccdf0f Mon Sep 17 00:00:00 2001 From: Brieuc Francois Date: Tue, 13 Jul 2021 12:55:25 +0200 Subject: [PATCH] Minor modifs to energy correction script --- Detector/DetStudies/scripts/cec_derive1 | 9 +++++++-- Detector/DetStudies/scripts/cec_process_events | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Detector/DetStudies/scripts/cec_derive1 b/Detector/DetStudies/scripts/cec_derive1 index a9b2fb6..adb1a20 100755 --- a/Detector/DetStudies/scripts/cec_derive1 +++ b/Detector/DetStudies/scripts/cec_derive1 @@ -1,6 +1,7 @@ #!/usr/bin/env python import argparse import json +import os def main(): @@ -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') @@ -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) @@ -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() diff --git a/Detector/DetStudies/scripts/cec_process_events b/Detector/DetStudies/scripts/cec_process_events index 6a9c2a4..86c98cf 100755 --- a/Detector/DetStudies/scripts/cec_process_events +++ b/Detector/DetStudies/scripts/cec_process_events @@ -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') @@ -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) @@ -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):