def plotDefault(argv, outputDir, name, type, plots, addArgv=[]): tmpArgv = argv[:] tmpArgv.append('-o') tmpArgv.append(outputDir+'/'+name+type) tmpArgv.extend(addArgv) tmpArgv.extend(plots) MultipleCompare.main(tmpArgv)
def plotOneByOne(argv, outputDir, histoList, histoSubNames, paths): for hist, name, path in zip(histoList, histoSubNames, paths): CreateSubDirectory(outputDir, path) #now give modified arguments to MultipleCompare tmpArgv = argv[:] tmpArgv.append('-o') tmpArgv.append(outputDir+'/'+path+'/'+name+'.png') tmpArgv.append(hist) MultipleCompare.main(tmpArgv)
def main(argv=None): if argv is None: argv = sys.argv options, toPlot = MultipleCompare.LoadCommandlineOptions(argv) gROOT.SetBatch() testFile = TFile(options.test) refFile = None if options.ref != '': refFile = TFile(options.ref) plotList = [] MultipleCompare.MapDirStructure(testFile, '', plotList) if len(plotList) < 1: print( '\tError: Please specify at least one histogram. The following ones are available in the root file.' ) print(plotList) sys.exit() histoList = [] histoSubNames = [] paths = [] massiveMode = False for plot in toPlot: #clean the arguments. toPlot contains the list of positional arguments leftover after parsing options argv.remove(plot) for path in plotList: if MultipleCompare.Match(plot.lower(), path.lower()): histoList.append(path) strippedPath, strippedPlot = StripPath(path) paths.append(strippedPath) histoSubNames.append(strippedPlot) #print histoSubNames[-1] elif plot.find('massiveMode') != -1: massiveMode = True CleanArguments(argv, '--output') CleanArguments(argv, '-o') outputDir = CreateBaseDirectory(options) if massiveMode: print( "Massive mode: scan all subdirs and make plots comparing each histogram one by one." ) plotOneByOne(argv, outputDir, histoList, histoSubNames, paths) else: print("Default mode: Make default plot combinations.") plotDefaults(argv, options, outputDir)