Skip to content

Commit 64daa1b

Browse files
committed
add option to save figures as pngs
1 parent ea938cd commit 64daa1b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Configuration/python/processingUtilities.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ def set_commandline_arguments(parser):
108108
help="Include the yield of each source in the legend")
109109
parser.add_option("-p", "--pdfs", action="store_true", dest="savePDFs", default=False,
110110
help="Save pdfs files for all plots made")
111+
parser.add_option("--pngs", action="store_true", dest="savePNGs", default=False,
112+
help="Save pngs files for all plots made")
111113

112114
return parser
113115

Configuration/scripts/makePlots.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,9 @@ def MakeOneDHist(pathToDir,histogramName,integrateDir):
12251225
if arguments.savePDFs:
12261226
pathToDirString = plainTextString(pathToDir)
12271227
Canvas.SaveAs(condor_dir+"/stacked_histograms_pdfs/"+pathToDirString+"/"+histogramName+".pdf")
1228+
if arguments.savePNGs:
1229+
pathToDirString = plainTextString(pathToDir)
1230+
Canvas.SaveAs(condor_dir+"/stacked_histograms_pngs/"+pathToDirString+"/"+histogramName+".png")
12281231

12291232

12301233
##########################################################################################################################################
@@ -1518,6 +1521,9 @@ def MakeTwoDHist(pathToDir,histogramName):
15181521
if arguments.savePDFs:
15191522
pathToDirString = plainTextString(pathToDir)
15201523
Canvas.SaveAs(condor_dir+"/stacked_histograms_pdfs/"+pathToDirString+"/"+histogramName+".pdf")
1524+
if arguments.savePNGs:
1525+
pathToDirString = plainTextString(pathToDir)
1526+
Canvas.SaveAs(condor_dir+"/stacked_histograms_pngs/"+pathToDirString+"/"+histogramName+".png")
15211527

15221528

15231529

@@ -1581,6 +1587,13 @@ def MakeTwoDHist(pathToDir,histogramName):
15811587
pass
15821588
os.mkdir ("%s/stacked_histograms_pdfs" % (condor_dir))
15831589

1590+
if arguments.savePNGs:
1591+
try:
1592+
shutil.rmtree ("%s/stacked_histograms_pngs" % (condor_dir))
1593+
except OSError:
1594+
pass
1595+
os.mkdir ("%s/stacked_histograms_pngs" % (condor_dir))
1596+
15841597
#### make output file
15851598
outputFileString = ''
15861599
if arguments.rebinFactor:
@@ -1613,6 +1626,8 @@ def MakeTwoDHist(pathToDir,histogramName):
16131626
outputFile.mkdir(rootDirectory)
16141627
if arguments.savePDFs:
16151628
os.mkdir ("%s/stacked_histograms_pdfs/%s" % (condor_dir,plainTextString(rootDirectory)))
1629+
if arguments.savePNGs:
1630+
os.mkdir ("%s/stacked_histograms_pngs/%s" % (condor_dir,plainTextString(rootDirectory)))
16161631

16171632
#cd to root directory and look for histograms
16181633
inputFile.cd(rootDirectory)
@@ -1635,6 +1650,8 @@ def MakeTwoDHist(pathToDir,histogramName):
16351650
gDirectory.mkdir(key2.GetName())
16361651
if arguments.savePDFs:
16371652
os.mkdir ("%s/stacked_histograms_pdfs/%s" % (condor_dir,plainTextString(level2Directory)))
1653+
if arguments.savePNGs:
1654+
os.mkdir ("%s/stacked_histograms_pngs/%s" % (condor_dir,plainTextString(level2Directory)))
16381655

16391656
#####################################################
16401657
### This layer is typically the "channels" layer ###
@@ -1662,6 +1679,8 @@ def MakeTwoDHist(pathToDir,histogramName):
16621679
gDirectory.mkdir(key3.GetName())
16631680
if arguments.savePDFs:
16641681
os.mkdir ("%s/stacked_histograms_pdfs/%s" % (condor_dir,plainTextString(level3Directory)))
1682+
if arguments.savePNGs:
1683+
os.mkdir ("%s/stacked_histograms_pngs/%s" % (condor_dir,plainTextString(level3Directory)))
16651684

16661685
#################################################
16671686
### This layer is typically the "cuts" layer ###

0 commit comments

Comments
 (0)