def doPlots(self, plotter, subdirprefix, plotterDrawArgs={}, htmlReport=html.HtmlReportDummy()): self._subdirprefix = subdirprefix self._plotterDrawArgs = plotterDrawArgs self._openFiles = [] for f in self._files: if not os.path.exists(f): print "File %s not found" % f sys.exit(1) self._openFiles.append(ROOT.TFile.Open(f)) plotterInstance = plotter.readDirs(*self._openFiles) for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(): plotFiles = self._doPlots(plotterFolder, dqmSubFolder) htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles) for tf in self._openFiles: tf.Close() self._openFiles = []
def doPlots(self, plotter, subdirprefix=None, sample=None, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy()): if subdirprefix is None and sample is None: raise Exception("Need either 'subdirprefix' or 'sample'") if subdirprefix is not None and sample is not None: raise Exception( "May give only one of 'subdirprefix' or 'sample', got both") self._subdirprefix = sample.label( ) if sample is not None else subdirprefix self._plotterDrawArgs = plotterDrawArgs self._openFiles = [] for f in self._files: if not os.path.exists(f): print "File %s not found" % f sys.exit(1) self._openFiles.append(ROOT.TFile.Open(f)) plotterInstance = plotter.readDirs(*self._openFiles) for plotterFolder, dqmSubFolder in plotterInstance.iterFolders( limitSubFoldersOnlyTo=limitSubFoldersOnlyTo): if sample is not None and plotterFolder.onlyForPileup( ) and not sample.hasPileup(): continue plotFiles = self._doPlots(plotterFolder, dqmSubFolder, htmlReport) if len(plotFiles) > 0: htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles) for tf in self._openFiles: tf.Close() self._openFiles = []
def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True): """Create validation plots. Arguments: plotter -- plotting.Plotter object that does the plotting Keyword arguments: plotterDrawArgs -- Dictionary for additional arguments to Plotter.draw() (default: {}) limitSubFoldersOnlyTo -- If not None, should be a dictionary from string to an object. The string is the name of a PlotFolder, and the object is PlotFolder-type specific to limit the subfolders to be processed. In general case the object is a list of strings, but e.g. for track iteration plots it is a function taking the algo and quality as parameters. htmlReport -- Object returned by createHtmlReport(), in case HTML report generation is desired doFastVsFull -- Do FastSim vs. FullSim comparison? (default: True) """ self._plotter = plotter self._plotterDrawArgs = plotterDrawArgs # New vs. Ref for sample in self._fullsimSamples+self._fastsimSamples: # Check that the new DQM file exists harvestedFile = sample.filename(self._newRelease) if not os.path.exists(harvestedFile): print "Harvested file %s does not exist!" % harvestedFile sys.exit(1) plotterInstance = plotter.readDirs(harvestedFile) htmlReport.beginSample(sample) for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo): if not _processPlotsForSample(plotterFolder, sample): continue plotFiles = self._doPlots(sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport) htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles) # TODO: the pileup case is still to be migrated # if s.fullsim() and s.hasPileup(): # self._doPlotsPileup(a, q, s) # Fast vs. Full if not doFastVsFull: return for fast in self._fastsimSamples: correspondingFull = None for full in self._fullsimSamples: if fast.name() != full.name(): continue if fast.hasPileup(): if not full.hasPileup(): continue if fast.fastsimCorrespondingFullsimPileup() != full.pileupType(): continue else: if full.hasPileup(): continue if correspondingFull is None: correspondingFull = full else: raise Exception("Got multiple compatible FullSim samples for FastSim sample %s %s" % (fast.name(), fast.pileup())) if correspondingFull is None: print "WARNING: Did not find compatible FullSim sample for FastSim sample %s %s, omitting FastSim vs. FullSim comparison" % (fast.name(), fast.pileup()) continue # If we reach here, the harvestedFile must exist harvestedFile = fast.filename(self._newRelease) plotterInstance = plotter.readDirs(harvestedFile) htmlReport.beginSample(fast, fastVsFull=True) for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo): if not _processPlotsForSample(plotterFolder, fast): continue plotFiles = self._doPlotsFastFull(fast, correspondingFull, plotterFolder, dqmSubFolder, htmlReport) htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)