Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
makeimage.py
Go to the documentation of this file.
1#! /usr/bin/env python
2
3import ROOT
4import shutil
5import os
6import sys
7
8def makeimage(MacroName, ImageName, OutDir, cp, py, batch):
9 '''Generates the ImageName output of the macro MacroName'''
10
11 ROOT.gStyle.SetImageScaling(3.)
12
13 if batch:
14 ROOT.gROOT.SetBatch(1)
15
16 if py:
17 sys.argv = [MacroName]
18 globals_ = dict(globals())
19 globals_['__file__'] = MacroName
20 exec(open(MacroName).read(), globals_)
21 else:
22 ROOT.gInterpreter.ProcessLine(".x " + MacroName)
23
24 if cp:
25 MN = MacroName.split("(")[0]
26 MNBase = os.path.basename(MN)
27 shutil.copyfile("%s" %MN,"%s/macros/%s" %(OutDir,MNBase))
28
29 ImageNum = 0
30 s = open ("ImagesSizes.dat","w")
31
32 canvases = ROOT.gROOT.GetListOfCanvases()
33 for ImageNum,can in enumerate(canvases):
34 ImageNum += 1
35 can.SaveAs("%s/html/pict%d_%s" %(OutDir,ImageNum,ImageName))
36 cw = can.GetWindowWidth()
37 s.write("%d\n" %cw)
38
39 s.close()
40
41 f = open ("NumberOfImages.dat","w")
42 f.write("%d\n" %ImageNum)
43 f.close()
44
45if __name__ == "__main__":
46 from sys import argv
47 makeimage(argv[1], argv[2], argv[3], int(argv[4]), int(argv[5]), int(argv[6]))
double read()