Beispiel #1
0
        canvas.Modified()
        canvas.Update()

        # make file_name and directories if needed
        file_name = "{0:s}/{1:s}".format(args.output_path, h.path)
        print("Saving {0:s}... \r".format(file_name), end='\r')
        plot_tag = plots_path.get('plot tag', plots_config.get('plot tag', None))
        if plot_tag is not None:
          file_name += '_'+plot_tag
        ensure_dir(file_name)
        for file_ext in args.file_ext:
          canvas.SaveAs("{0:s}.{1:s}".format(file_name, file_ext))
        sys.stdout.flush()
        print("Saved {0:s} successfully.".format(file_name))

        canvas.Close()
        del canvas

      if not args.debug:
        ROOT.gROOT.ProcessLine("gSystem->RedirectOutput(0);")

  except Exception, e:
    # stop redirecting if we crash as well
    if not args.debug:
      ROOT.gROOT.ProcessLine("gSystem->RedirectOutput(0);")

    logger.exception("{0}\nAn exception was caught!".format("-"*20))

  # here we close it all
  map(lambda hgroup: map(lambda hist: hist.get_file().close(), hgroup), hall)