CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
validation.Validation Class Reference
Inheritance diagram for validation.Validation:
vertexPlots.VertexValidation

Public Member Functions

def __init__ (self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName="")
 
def createHtmlReport (self)
 
def doPlots (self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False)
 
def download (self)
 

Private Member Functions

def _doFastsimFastVsFullPlots (self, limitSubFoldersOnlyTo, htmlReport)
 
def _doPhase2PileupPlots (self, limitSubFoldersOnlyTo, htmlReport)
 
def _doPlots (self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
 
def _doPlotsFastFull (self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport)
 
def _doPlotsPileup (self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport)
 
def _getDirectoryName (self, args, kwargs)
 
def _getRefFileAndSelection (self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
 
def _getSelectionName (self, args, kwargs)
 

Private Attributes

 _fastsimSamples
 
 _fullsimSamples
 
 _newBaseDir
 
 _newFileModifier
 
 _newRelease
 
 _plotter
 
 _plotterDrawArgs
 
 _refRelease
 
 _refRepository
 
 _selectionName
 

Detailed Description

Base class for Tracking/Vertex validation.

Definition at line 475 of file validation.py.

Constructor & Destructor Documentation

def validation.Validation.__init__ (   self,
  fullsimSamples,
  fastsimSamples,
  refRelease,
  refRepository,
  newRelease,
  newRepository,
  newFileModifier = None,
  selectionName = "" 
)
Constructor.

Arguments:
fullsimSamples -- List of Sample objects for FullSim samples (may be empty)
fastsimSamples -- List of Sample objects for FastSim samples (may be empty)
refRelease    -- String for reference CMSSW release (can be None for no reference release)
newRepository -- String for directory whete to put new files
newRelease     -- CMSSW release to be validated
refRepository  -- String for directory where reference root files are
newFileModifier -- If given, a function to modify the names of the new files (function takes a string and returns a string)
selectionName  -- If given, use this string as the selection name (appended to GlobalTag for directory names)

Definition at line 477 of file validation.py.

Referenced by vertexPlots.VertexValidation._init__().

477  def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName=""):
478  """Constructor.
479 
480  Arguments:
481  fullsimSamples -- List of Sample objects for FullSim samples (may be empty)
482  fastsimSamples -- List of Sample objects for FastSim samples (may be empty)
483  refRelease -- String for reference CMSSW release (can be None for no reference release)
484  newRepository -- String for directory whete to put new files
485  newRelease -- CMSSW release to be validated
486  refRepository -- String for directory where reference root files are
487  newFileModifier -- If given, a function to modify the names of the new files (function takes a string and returns a string)
488  selectionName -- If given, use this string as the selection name (appended to GlobalTag for directory names)
489  """
490  try:
491  self._newRelease = os.environ["CMSSW_VERSION"]
492  except KeyError:
493  print >>sys.stderr, 'Error: CMSSW environment variables are not available.'
494  print >>sys.stderr, ' Please run cmsenv'
495  sys.exit()
496 
497  self._fullsimSamples = fullsimSamples
498  self._fastsimSamples = fastsimSamples
499  self._refRelease = refRelease
500  self._refRepository = refRepository
501  self._newRelease = newRelease
502  self._newBaseDir = os.path.join(newRepository, self._newRelease)
503  self._newFileModifier = newFileModifier
504  self._selectionName = selectionName
505 
def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName="")
Definition: validation.py:477

Member Function Documentation

def validation.Validation._doFastsimFastVsFullPlots (   self,
  limitSubFoldersOnlyTo,
  htmlReport 
)
private

Definition at line 604 of file validation.py.

References validation.Validation._doPlotsFastFull(), validation.Validation._fastsimSamples, validation.Validation._fullsimSamples, validation.Validation._newRelease, and validation._processPlotsForSample().

604  def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport):
605  for fast in self._fastsimSamples:
606  correspondingFull = None
607  for full in self._fullsimSamples:
608  if fast.name() != full.name():
609  continue
610  if fast.pileupEnabled():
611  if not full.pileupEnabled():
612  continue
613  if fast.fastsimCorrespondingFullsimPileup() != full.pileupType():
614  continue
615  else:
616  if full.pileupEnabled():
617  continue
618 
619  if correspondingFull is None:
620  correspondingFull = full
621  else:
622  raise Exception("Got multiple compatible FullSim samples for FastSim sample %s %s" % (fast.name(), fast.pileup()))
623  if correspondingFull is None:
624  print "WARNING: Did not find compatible FullSim sample for FastSim sample %s %s, omitting FastSim vs. FullSim comparison" % (fast.name(), fast.pileup())
625  continue
626 
627  # If we reach here, the harvestedFile must exist
628  harvestedFile = fast.filename(self._newRelease)
629  plotterInstance = self._plotter.readDirs(harvestedFile)
630  htmlReport.beginSample(fast, fastVsFull=True)
631  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
632  if not _processPlotsForSample(plotterFolder, fast):
633  continue
634  plotFiles = self._doPlotsFastFull(fast, correspondingFull, plotterFolder, dqmSubFolder, htmlReport)
635  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
636 
def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:604
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:266
def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:786
def validation.Validation._doPhase2PileupPlots (   self,
  limitSubFoldersOnlyTo,
  htmlReport 
)
private

Definition at line 637 of file validation.py.

References validation.Validation._doPlotsPileup(), validation.Validation._fullsimSamples, validation.Validation._newRelease, and validation._processPlotsForSample().

637  def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport):
638  def _stripScenario(name):
639  puindex = name.find("PU")
640  if puindex < 0:
641  return name
642  return name[:puindex]
643 
644  pu140samples = {}
645  for sample in self._fullsimSamples:
646  if sample.pileupNumber() == 140:
647  key = (sample.name(), _stripScenario(sample.scenario()))
648  if key in pu140samples:
649  raise Exception("Duplicate entry for sample %s in scenario %s" % (sample.name(), sample.scenar()))
650  pu140samples[key] = sample
651 
652  for sample in self._fullsimSamples:
653  if sample.pileupNumber() != 200:
654  continue
655  key = (sample.name(), _stripScenario(sample.scenario()))
656  if not key in pu140samples:
657  continue
658 
659  sample_pu140 = pu140samples[key]
660 
661  # If we reach here, the harvestedFile must exist
662  harvestedFile = sample.filename(self._newRelease)
663  plotterInstance = self._plotter.readDirs(harvestedFile)
664  htmlReport.beginSample(sample, pileupComparison="vs. PU140")
665  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
666  if not _processPlotsForSample(plotterFolder, sample):
667  continue
668  plotFiles = self._doPlotsPileup(sample_pu140, sample, plotterFolder, dqmSubFolder, htmlReport)
669  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
670 
671 
def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:854
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:266
def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:637
def validation.Validation._doPlots (   self,
  sample,
  harvestedFile,
  plotterFolder,
  dqmSubFolder,
  htmlReport 
)
private
Do the real plotting work for a given sample and DQM subfolder

Definition at line 714 of file validation.py.

References validation._copySubDir(), validation._findDuplicates(), validation._getGlobalTag(), validation.Validation._getRefFileAndSelection(), validation.Validation._newBaseDir, html.HtmlReport._newBaseDir, validation.Validation._newRelease, validation.Validation._plotterDrawArgs, validation.Validation._refRelease, validation._stripRelease(), join(), genParticles_cff.map, and harvestTrackValidationPlots.str.

Referenced by validation.SimpleValidation._doPlotsForPlotter().

714  def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport):
715  """Do the real plotting work for a given sample and DQM subfolder"""
716  # Get GlobalTags
717  newGlobalTag = _getGlobalTag(sample, self._newRelease)
718 
719  # Construct selection string
720  selectionNameBase = "_"+sample.pileup()
721  newSelection = newGlobalTag+selectionNameBase+plotterFolder.getSelectionName(dqmSubFolder)
722  if sample.pileupEnabled():
723  newPu = sample.pileupType(self._newRelease)
724  if newPu != "":
725  newSelection += "_"+newPu
726 
727  valname = "val.{sample}.root".format(sample=sample.name())
728 
729  # Construct reference file and selection string
730  (refValFile, refSelection) = self._getRefFileAndSelection(sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
731 
732  # Construct new directory name
733  tmp = []
734  if sample.fastsim():
735  tmp.extend(["fastsim", self._newRelease])
736  tmp.extend([newSelection, sample.name()])
737  newsubdir = os.path.join(*tmp)
738  newdir = os.path.join(self._newBaseDir, newsubdir)
739 
740  # Copy the relevant histograms to a new validation root file
741  # TODO: treat the case where dqmSubFolder is empty
742  newValFile = _copySubDir(harvestedFile, valname, plotterFolder.getPossibleDQMFolders(), dqmSubFolder.subfolder if dqmSubFolder is not None else None)
743  fileList = []
744 
745  # Do the plots
746  if plotting.verbose:
747  print "Comparing ref and new {sim} {sample} {translatedFolder}".format(
748  sim="FullSim" if not sample.fastsim() else "FastSim",
749  sample=sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
750  rootFiles = [refValFile, newValFile]
751  legendLabels = [
752  "%s, %s %s" % (sample.name(), _stripRelease(self._refRelease), refSelection) if self._refRelease is not None else "dummy",
753  "%s, %s %s" % (sample.name(), _stripRelease(self._newRelease), newSelection)
754  ]
755  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=sample.pileupEnabled())
756  fileList.extend(plotterFolder.draw(**self._plotterDrawArgs))
757  # Copy val file only if there were plots
758  if len(fileList) > 0:
759  fileList.append(valname)
760 
761  # For tables we just try them all, and see which ones succeed
762  for tableCreator in plotterFolder.getTableCreators():
763  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
764 
765  newValFile.Close()
766  if refValFile is not None:
767  refValFile.Close()
768 
769  if len(fileList) == 0:
770  return []
771 
772  dups = _findDuplicates(fileList)
773  if len(dups) > 0:
774  print "Plotter produced multiple files with names", ", ".join(dups)
775  print "Typically this is a naming problem in the plotter configuration"
776  sys.exit(1)
777 
778  # Move plots to new directory
779  print "Moving plots and %s to %s" % (valname, newdir)
780  if not os.path.exists(newdir):
781  os.makedirs(newdir)
782  for f in fileList:
783  shutil.move(f, os.path.join(newdir, f))
784  return map(lambda n: os.path.join(newsubdir, n), fileList)
785 
def _getGlobalTag(sample, release)
Definition: validation.py:197
def _stripRelease(release)
Definition: validation.py:190
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:973
def _copySubDir(oldfile, newfile, basenames, dirname)
Definition: validation.py:924
def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
Definition: validation.py:672
def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:714
def validation.Validation._doPlotsFastFull (   self,
  fastSample,
  fullSample,
  plotterFolder,
  dqmSubFolder,
  htmlReport 
)
private
Do the real plotting work for FastSim vs. FullSim for a given algorithm, quality flag, and sample.

Definition at line 786 of file validation.py.

References validation._findDuplicates(), validation._getGlobalTag(), validation.Validation._newBaseDir, html.HtmlReport._newBaseDir, validation.Validation._newRelease, validation.Validation._plotterDrawArgs, validation._stripRelease(), join(), genParticles_cff.map, and harvestTrackValidationPlots.str.

Referenced by validation.Validation._doFastsimFastVsFullPlots().

786  def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport):
787  """Do the real plotting work for FastSim vs. FullSim for a given algorithm, quality flag, and sample."""
788  # Get GlobalTags
789  fastGlobalTag = _getGlobalTag(fastSample, self._newRelease)
790  fullGlobalTag = _getGlobalTag(fullSample, self._newRelease)
791 
792  # Construct selection string
793  tmp = plotterFolder.getSelectionName(dqmSubFolder)
794  fastSelection = fastGlobalTag+"_"+fastSample.pileup()+tmp
795  fullSelection = fullGlobalTag+"_"+fullSample.pileup()+tmp
796  if fullSample.pileupEnabled():
797  fullSelection += "_"+fullSample.pileupType(self._newRelease)
798  fastSelection += "_"+fastSample.pileupType(self._newRelease)
799 
800  # Construct directories for FastSim, FullSim, and for the results
801  fastdir = os.path.join(self._newBaseDir, "fastsim", self._newRelease, fastSelection, fastSample.name())
802  fulldir = os.path.join(self._newBaseDir, fullSelection, fullSample.name())
803  newsubdir = os.path.join("fastfull", self._newRelease, fastSelection, fastSample.name())
804  newdir = os.path.join(self._newBaseDir, newsubdir)
805 
806  # Open input root files
807  valname = "val.{sample}.root".format(sample=fastSample.name())
808  fastValFilePath = os.path.join(fastdir, valname)
809  if not os.path.exists(fastValFilePath) and plotting.verbose:
810  print "FastSim file %s not found" % fastValFilePath
811  fullValFilePath = os.path.join(fulldir, valname)
812  if not os.path.exists(fullValFilePath) and plotting.verbose:
813  print "FullSim file %s not found" % fullValFilePath
814 
815  fastValFile = ROOT.TFile.Open(fastValFilePath)
816  fullValFile = ROOT.TFile.Open(fullValFilePath)
817 
818  # Do plots
819  if plotting.verbose:
820  print "Comparing FullSim and FastSim {sample} {translatedFolder}".format(
821  sample=fastSample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
822  rootFiles = [fullValFile, fastValFile]
823  legendLabels = [
824  "FullSim %s, %s %s" % (fullSample.name(), _stripRelease(self._newRelease), fullSelection),
825  "FastSim %s, %s %s" % (fastSample.name(), _stripRelease(self._newRelease), fastSelection),
826  ]
827  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=fastSample.pileupEnabled(), requireAllHistograms=True)
828  fileList = plotterFolder.draw(**self._plotterDrawArgs)
829 
830  # For tables we just try them all, and see which ones succeed
831  for tableCreator in plotterFolder.getTableCreators():
832  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
833 
834  fullValFile.Close()
835  fastValFile.Close()
836 
837  if len(fileList) == 0:
838  return []
839 
840  dups = _findDuplicates(fileList)
841  if len(dups) > 0:
842  print "Plotter produced multiple files with names", ", ".join(dups)
843  print "Typically this is a naming problem in the plotter configuration"
844  sys.exit(1)
845 
846  # Move plots to new directory
847  print "Moving plots to %s" % (newdir)
848  if not os.path.exists(newdir):
849  os.makedirs(newdir)
850  for f in fileList:
851  shutil.move(f, os.path.join(newdir, f))
852  return map(lambda n: os.path.join(newsubdir, n), fileList)
853 
def _getGlobalTag(sample, release)
Definition: validation.py:197
def _stripRelease(release)
Definition: validation.py:190
def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:786
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:973
def validation.Validation._doPlotsPileup (   self,
  pu140Sample,
  pu200Sample,
  plotterFolder,
  dqmSubFolder,
  htmlReport 
)
private
Do the real plotting work for two pileup scenarios for a given algorithm, quality flag, and sample.

Definition at line 854 of file validation.py.

References validation._findDuplicates(), validation._getGlobalTag(), validation.Validation._newBaseDir, html.HtmlReport._newBaseDir, validation.Validation._newRelease, validation.Validation._plotterDrawArgs, validation._stripRelease(), join(), genParticles_cff.map, and harvestTrackValidationPlots.str.

Referenced by validation.Validation._doPhase2PileupPlots().

854  def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport):
855  """Do the real plotting work for two pileup scenarios for a given algorithm, quality flag, and sample."""
856  # Get GlobalTags
857  pu140GlobalTag = _getGlobalTag(pu140Sample, self._newRelease)
858  pu200GlobalTag = _getGlobalTag(pu200Sample, self._newRelease)
859 
860  # Construct selection string
861  tmp = plotterFolder.getSelectionName(dqmSubFolder)
862  pu140Selection = pu140GlobalTag+"_"+pu140Sample.pileup()+tmp+"_"+pu140Sample.pileupType(self._newRelease)
863  pu200Selection = pu200GlobalTag+"_"+pu200Sample.pileup()+tmp+"_"+pu200Sample.pileupType(self._newRelease)
864 
865  # Construct directories for
866  pu140dir = os.path.join(self._newBaseDir, pu140Selection, pu140Sample.name())
867  pu200dir = os.path.join(self._newBaseDir, pu200Selection, pu200Sample.name())
868  newsubdir = os.path.join("pileup", self._newRelease, pu200Selection, pu200Sample.name())
869  newdir = os.path.join(self._newBaseDir, newsubdir)
870 
871  # Open input root files
872  valname = "val.{sample}.root".format(sample=pu140Sample.name())
873  pu140ValFilePath = os.path.join(pu140dir, valname)
874  if not os.path.exists(pu140ValFilePath):
875  if plotting.verbose:
876  print "PU140 file %s not found" % pu140ValFilePath
877  return []
878  pu200ValFilePath = os.path.join(pu200dir, valname)
879  if not os.path.exists(pu200ValFilePath):
880  if plotting.verbose:
881  print "PU200 file %s not found" % pu200ValFilePath
882  return []
883 
884  pu140ValFile = ROOT.TFile.Open(pu140ValFilePath)
885  pu200ValFile = ROOT.TFile.Open(pu200ValFilePath)
886 
887  # Do plots
888  if plotting.verbose:
889  print "Comparing PU140 and PU200 {sample} {translatedFolder}".format(
890  sample=pu200Sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
891  rootFiles = [pu140ValFile, pu200ValFile]
892  legendLabels = [
893  "%s, %s %s" % (pu140Sample.name(), _stripRelease(self._newRelease), pu140Selection),
894  "%s, %s %s" % (pu200Sample.name(), _stripRelease(self._newRelease), pu200Selection),
895  ]
896  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=pu140Sample.pileupEnabled(), requireAllHistograms=True)
897  fileList = plotterFolder.draw(**self._plotterDrawArgs)
898 
899  # For tables we just try them all, and see which ones succeed
900  for tableCreator in plotterFolder.getTableCreators():
901  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
902 
903  pu200ValFile.Close()
904  pu140ValFile.Close()
905 
906  if len(fileList) == 0:
907  return []
908 
909  dups = _findDuplicates(fileList)
910  if len(dups) > 0:
911  print "Plotter produced multiple files with names", ", ".join(dups)
912  print "Typically this is a naming problem in the plotter configuration"
913  sys.exit(1)
914 
915  # Move plots to new directory
916  print "Moving plots to %s" % (newdir)
917  if not os.path.exists(newdir):
918  os.makedirs(newdir)
919  for f in fileList:
920  shutil.move(f, os.path.join(newdir, f))
921  return map(lambda n: os.path.join(newsubdir, n), fileList)
922 
923 
def _getGlobalTag(sample, release)
Definition: validation.py:197
def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:854
def _stripRelease(release)
Definition: validation.py:190
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:973
def validation.Validation._getDirectoryName (   self,
  args,
  kwargs 
)
private

Definition at line 506 of file validation.py.

506  def _getDirectoryName(self, *args, **kwargs):
507  return None
508 
def _getDirectoryName(self, args, kwargs)
Definition: validation.py:506
def validation.Validation._getRefFileAndSelection (   self,
  sample,
  plotterFolder,
  dqmSubFolder,
  selectionNameBase,
  valname 
)
private

Definition at line 672 of file validation.py.

References validation._getGlobalTag(), validation.Validation._refRelease, validation.Validation._refRepository, and join().

Referenced by validation.Validation._doPlots().

672  def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname):
673  if self._refRelease is None:
674  return (None, "")
675 
676  refGlobalTag = _getGlobalTag(sample, self._refRelease)
677  def _createRefSelection(selectionName):
678  sel = refGlobalTag+selectionNameBase+selectionName
679  if sample.pileupEnabled():
680  refPu = sample.pileupType(self._refRelease)
681  if refPu != "":
682  sel += "_"+refPu
683  return sel
684  refSelection = _createRefSelection(plotterFolder.getSelectionName(dqmSubFolder))
685 
686  # Construct reference directory name, and open reference file it it exists
687  refValFile = None
688  triedRefValFiles = []
689  tmp = [self._refRepository, self._refRelease]
690  if sample.fastsim():
691  tmp.extend(["fastsim", self._refRelease])
692  for selName in plotterFolder.getSelectionNameIterator(dqmSubFolder):
693  refSel = _createRefSelection(selName)
694  refdir = os.path.join(*(tmp+[refSel, sample.name()]))
695 
696  # Open reference file if it exists
697  refValFilePath = os.path.join(refdir, valname)
698  if os.path.exists(refValFilePath):
699  refSelection = refSel
700  refValFile = ROOT.TFile.Open(refValFilePath)
701  break
702  else:
703  triedRefValFiles.append(refValFilePath)
704  if refValFile is None:
705  if len(triedRefValFiles) == 1:
706  if plotting.verbose:
707  print "Reference file %s not found" % triedRefValFiles[0]
708  else:
709  if plotting.verbose:
710  print "None of the possible reference files %s not found" % ",".join(triedRefValFiles)
711 
712  return (refValFile, refSelection)
713 
def _getGlobalTag(sample, release)
Definition: validation.py:197
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
Definition: validation.py:672
def validation.Validation._getSelectionName (   self,
  args,
  kwargs 
)
private

Definition at line 509 of file validation.py.

References validation.Validation._selectionName.

509  def _getSelectionName(self, *args, **kwargs):
510  return self._selectionName
511 
def _getSelectionName(self, args, kwargs)
Definition: validation.py:509
def validation.Validation.createHtmlReport (   self)
def validation.Validation.doPlots (   self,
  plotter,
  plotterDrawArgs = {},
  limitSubFoldersOnlyTo = None,
  htmlReport = html.HtmlReportDummy(),
  doFastVsFull = True,
  doPhase2PU = False 
)
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)
doPhase2PU      -- Do Phase2 PU 200 vs. 140 comparison (default: False)

Definition at line 564 of file validation.py.

564  def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False):
565  """Create validation plots.
566 
567  Arguments:
568  plotter -- plotting.Plotter object that does the plotting
569 
570  Keyword arguments:
571  plotterDrawArgs -- Dictionary for additional arguments to Plotter.draw() (default: {})
572  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.
573  htmlReport -- Object returned by createHtmlReport(), in case HTML report generation is desired
574  doFastVsFull -- Do FastSim vs. FullSim comparison? (default: True)
575  doPhase2PU -- Do Phase2 PU 200 vs. 140 comparison (default: False)
576  """
577  self._plotter = plotter
578  self._plotterDrawArgs = plotterDrawArgs
579 
580  # New vs. Ref
581  for sample in self._fullsimSamples+self._fastsimSamples:
582  # Check that the new DQM file exists
583  harvestedFile = sample.filename(self._newRelease)
584  if not os.path.exists(harvestedFile):
585  print "Harvested file %s does not exist!" % harvestedFile
586  sys.exit(1)
587 
588  plotterInstance = plotter.readDirs(harvestedFile)
589  htmlReport.beginSample(sample)
590  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
591  if not _processPlotsForSample(plotterFolder, sample):
592  continue
593  plotFiles = self._doPlots(sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
594  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
595 
596  # Fast vs. Full
597  if doFastVsFull:
598  self._doFastsimFastVsFullPlots(limitSubFoldersOnlyTo, htmlReport)
599 
600  # Phase2 PU200 vs. PU 140
601  if doPhase2PU:
602  self._doPhase2PileupPlots(limitSubFoldersOnlyTo, htmlReport)
603 
def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:604
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:266
def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:637
def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False)
Definition: validation.py:564
def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:714
def validation.Validation.download (   self)
Download DQM files. Requires grid certificate and asks your password for it.

Definition at line 512 of file validation.py.

References validation.Validation._fastsimSamples, validation.Validation._fullsimSamples, validation._getRelValUrl(), validation.Validation._newFileModifier, validation.Validation._newRelease, ALCARECOTkAlBeamHalo_cff.filter, join(), and genParticles_cff.map.

512  def download(self):
513  """Download DQM files. Requires grid certificate and asks your password for it."""
514  filenames = [s.filename(self._newRelease) for s in self._fullsimSamples+self._fastsimSamples]
515  if self._newFileModifier is not None:
516  filenames = map(self._newFileModifier, filenames)
517  filenames = filter(lambda f: not os.path.exists(f), filenames)
518  if len(filenames) == 0:
519  print "All files already downloaded"
520  return
521 
522  relvalUrl = _getRelValUrl(self._newRelease)
523  urls = [relvalUrl+f for f in filenames]
524  certfile = os.path.join(os.environ["HOME"], ".globus", "usercert.pem")
525  if not os.path.exists(certfile):
526  print "Certificate file {certfile} does not exist, unable to download RelVal files from {url}".format(certfile=certfile, url=relvalUrl)
527  sys.exit(1)
528  keyfile = os.path.join(os.environ["HOME"], ".globus", "userkey.pem")
529  if not os.path.exists(certfile):
530  print "Private key file {keyfile} does not exist, unable to download RelVal files from {url}".format(keyfile=keyfile, url=relvalUrl)
531  sys.exit(1)
532 
533  # curl --cert-type PEM --cert $HOME/.globus/usercert.pem --key $HOME/.globus/userkye.pem -k -O <url> -O <url>
534  cmd = ["curl", "--cert-type", "PEM", "--cert", certfile, "--key", keyfile, "-k"]
535  for u in urls:
536  cmd.extend(["-O", u])
537  print "Downloading %d files from RelVal URL %s:" % (len(filenames), relvalUrl)
538  print " "+"\n ".join(filenames)
539  print "Please provide your private key pass phrase when curl asks it"
540  ret = subprocess.call(cmd)
541  if ret != 0:
542  print "Downloading failed with exit code %d" % ret
543  sys.exit(1)
544 
545  # verify
546  allFine = True
547  for f in filenames:
548  p = subprocess.Popen(["file", f], stdout=subprocess.PIPE)
549  stdout = p.communicate()[0]
550  if p.returncode != 0:
551  print "file command failed with exit code %d" % p.returncode
552  sys.exit(1)
553  if not "ROOT" in stdout:
554  print "File {f} is not ROOT, please check the correct version, GlobalTag etc. from {url}".format(f=f, url=relvalUrl)
555  allFine = False
556  if os.path.exists(f):
557  os.remove(f)
558  if not allFine:
559  sys.exit(1)
560 
def _getRelValUrl(release)
Definition: validation.py:254
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Member Data Documentation

validation.Validation._fastsimSamples
private
validation.Validation._fullsimSamples
private
validation.Validation._newBaseDir
private
validation.Validation._newFileModifier
private

Definition at line 503 of file validation.py.

Referenced by validation.Validation.download().

validation.Validation._newRelease
private
validation.Validation._plotter
private

Definition at line 577 of file validation.py.

validation.Validation._plotterDrawArgs
private
validation.Validation._refRelease
private
validation.Validation._refRepository
private

Definition at line 500 of file validation.py.

Referenced by validation.Validation._getRefFileAndSelection().

validation.Validation._selectionName
private

Definition at line 504 of file validation.py.

Referenced by validation.Validation._getSelectionName().