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 679 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 681 of file validation.py.

Referenced by vertexPlots.VertexValidation._init__().

681  def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName=""):
682  """Constructor.
683 
684  Arguments:
685  fullsimSamples -- List of Sample objects for FullSim samples (may be empty)
686  fastsimSamples -- List of Sample objects for FastSim samples (may be empty)
687  refRelease -- String for reference CMSSW release (can be None for no reference release)
688  newRepository -- String for directory whete to put new files
689  newRelease -- CMSSW release to be validated
690  refRepository -- String for directory where reference root files are
691  newFileModifier -- If given, a function to modify the names of the new files (function takes a string and returns a string)
692  selectionName -- If given, use this string as the selection name (appended to GlobalTag for directory names)
693  """
694  try:
695  self._newRelease = os.environ["CMSSW_VERSION"]
696  except KeyError:
697  print >>sys.stderr, 'Error: CMSSW environment variables are not available.'
698  print >>sys.stderr, ' Please run cmsenv'
699  sys.exit()
700 
701  self._fullsimSamples = fullsimSamples
702  self._fastsimSamples = fastsimSamples
703  self._refRelease = refRelease
704  self._refRepository = refRepository
705  self._newRelease = newRelease
706  self._newBaseDir = os.path.join(newRepository, self._newRelease)
707  self._newFileModifier = newFileModifier
708  self._selectionName = selectionName
709 
def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName="")
Definition: validation.py:681

Member Function Documentation

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

Definition at line 808 of file validation.py.

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

808  def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport):
809  for fast in self._fastsimSamples:
810  correspondingFull = None
811  for full in self._fullsimSamples:
812  if fast.name() != full.name():
813  continue
814  if fast.pileupEnabled():
815  if not full.pileupEnabled():
816  continue
817  if fast.fastsimCorrespondingFullsimPileup() != full.pileupType():
818  continue
819  else:
820  if full.pileupEnabled():
821  continue
822 
823  if correspondingFull is None:
824  correspondingFull = full
825  else:
826  raise Exception("Got multiple compatible FullSim samples for FastSim sample %s %s" % (fast.name(), fast.pileup()))
827  if correspondingFull is None:
828  print "WARNING: Did not find compatible FullSim sample for FastSim sample %s %s, omitting FastSim vs. FullSim comparison" % (fast.name(), fast.pileup())
829  continue
830 
831  # If we reach here, the harvestedFile must exist
832  harvestedFile = fast.filename(self._newRelease)
833  plotterInstance = self._plotter.readDirs(harvestedFile)
834  htmlReport.beginSample(fast, fastVsFull=True)
835  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
836  if not _processPlotsForSample(plotterFolder, fast):
837  continue
838  plotFiles = self._doPlotsFastFull(fast, correspondingFull, plotterFolder, dqmSubFolder, htmlReport)
839  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
840 
def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:808
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:460
def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:989
def validation.Validation._doPhase2PileupPlots (   self,
  limitSubFoldersOnlyTo,
  htmlReport 
)
private

Definition at line 841 of file validation.py.

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

841  def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport):
842  def _stripScenario(name):
843  puindex = name.find("PU")
844  if puindex < 0:
845  return name
846  return name[:puindex]
847 
848  pu140samples = {}
849  for sample in self._fullsimSamples:
850  if sample.pileupNumber() == 140:
851  key = (sample.name(), _stripScenario(sample.scenario()))
852  if key in pu140samples:
853  raise Exception("Duplicate entry for sample %s in scenario %s" % (sample.name(), sample.scenar()))
854  pu140samples[key] = sample
855 
856  for sample in self._fullsimSamples:
857  if sample.pileupNumber() != 200:
858  continue
859  key = (sample.name(), _stripScenario(sample.scenario()))
860  if not key in pu140samples:
861  continue
862 
863  sample_pu140 = pu140samples[key]
864 
865  # If we reach here, the harvestedFile must exist
866  harvestedFile = sample.filename(self._newRelease)
867  plotterInstance = self._plotter.readDirs(harvestedFile)
868  htmlReport.beginSample(sample, pileupComparison="vs. PU140")
869  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
870  if not _processPlotsForSample(plotterFolder, sample):
871  continue
872  plotFiles = self._doPlotsPileup(sample_pu140, sample, plotterFolder, dqmSubFolder, htmlReport)
873  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
874 
875 
def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:1055
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:460
def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:841
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 918 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().

918  def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport):
919  """Do the real plotting work for a given sample and DQM subfolder"""
920  # Get GlobalTags
921  newGlobalTag = _getGlobalTag(sample, self._newRelease)
922 
923  # Construct selection string
924  selectionNameBase = "_"+sample.pileup()
925  newSelection = newGlobalTag+selectionNameBase+plotterFolder.getSelectionName(dqmSubFolder)
926  if sample.pileupEnabled():
927  newPu = sample.pileupType(self._newRelease)
928  if newPu != "":
929  newSelection += "_"+newPu
930 
931  valname = "val.{sample}.root".format(sample=sample.name())
932 
933  # Construct reference file and selection string
934  (refValFile, refSelection) = self._getRefFileAndSelection(sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
935 
936  # Construct new directory name
937  tmp = []
938  if sample.fastsim():
939  tmp.extend(["fastsim", self._newRelease])
940  tmp.extend([newSelection, sample.name()])
941  newsubdir = os.path.join(*tmp)
942  newdir = os.path.join(self._newBaseDir, newsubdir)
943  if not os.path.exists(newdir):
944  os.makedirs(newdir)
945  valnameFullPath = os.path.join(newdir, valname)
946 
947  # Copy the relevant histograms to a new validation root file
948  # TODO: treat the case where dqmSubFolder is empty
949  newValFile = _copySubDir(harvestedFile, valnameFullPath, plotterFolder.getPossibleDQMFolders(), dqmSubFolder.subfolder if dqmSubFolder is not None else None)
950  fileList = []
951 
952  # Do the plots
953  if plotting.verbose:
954  print "Comparing ref and new {sim} {sample} {translatedFolder}".format(
955  sim="FullSim" if not sample.fastsim() else "FastSim",
956  sample=sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
957  rootFiles = [refValFile, newValFile]
958  legendLabels = [
959  "%s, %s %s" % (sample.name(), _stripRelease(self._refRelease), refSelection) if self._refRelease is not None else "dummy",
960  "%s, %s %s" % (sample.name(), _stripRelease(self._newRelease), newSelection)
961  ]
962  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=sample.pileupEnabled())
963  fileList.extend(plotterFolder.draw(directory=newdir, **self._plotterDrawArgs))
964  # Copy val file only if there were plots
965  if len(fileList) > 0:
966  fileList.append(valnameFullPath)
967 
968  # For tables we just try them all, and see which ones succeed
969  for tableCreator in plotterFolder.getTableCreators():
970  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
971 
972  newValFile.Close()
973  if refValFile is not None:
974  refValFile.Close()
975 
976  if len(fileList) == 0:
977  return []
978 
979  dups = _findDuplicates(fileList)
980  if len(dups) > 0:
981  print "Plotter produced multiple files with names", ", ".join(dups)
982  print "Typically this is a naming problem in the plotter configuration"
983  sys.exit(1)
984 
985  # Move plots to new directory
986  print "Created plots and %s in %s" % (valname, newdir)
987  return map(lambda n: n.replace(newdir, newsubdir), fileList)
988 
def _getGlobalTag(sample, release)
Definition: validation.py:356
def _stripRelease(release)
Definition: validation.py:349
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:1172
def _copySubDir(oldfile, newfile, basenames, dirname)
Definition: validation.py:1123
def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
Definition: validation.py:876
def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:918
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 989 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().

989  def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport):
990  """Do the real plotting work for FastSim vs. FullSim for a given algorithm, quality flag, and sample."""
991  # Get GlobalTags
992  fastGlobalTag = _getGlobalTag(fastSample, self._newRelease)
993  fullGlobalTag = _getGlobalTag(fullSample, self._newRelease)
994 
995  # Construct selection string
996  tmp = plotterFolder.getSelectionName(dqmSubFolder)
997  fastSelection = fastGlobalTag+"_"+fastSample.pileup()+tmp
998  fullSelection = fullGlobalTag+"_"+fullSample.pileup()+tmp
999  if fullSample.pileupEnabled():
1000  fullSelection += "_"+fullSample.pileupType(self._newRelease)
1001  fastSelection += "_"+fastSample.pileupType(self._newRelease)
1002 
1003  # Construct directories for FastSim, FullSim, and for the results
1004  fastdir = os.path.join(self._newBaseDir, "fastsim", self._newRelease, fastSelection, fastSample.name())
1005  fulldir = os.path.join(self._newBaseDir, fullSelection, fullSample.name())
1006  newsubdir = os.path.join("fastfull", self._newRelease, fastSelection, fastSample.name())
1007  newdir = os.path.join(self._newBaseDir, newsubdir)
1008  if not os.path.exists(newdir):
1009  os.makedirs(newdir)
1010 
1011  # Open input root files
1012  valname = "val.{sample}.root".format(sample=fastSample.name())
1013  fastValFilePath = os.path.join(fastdir, valname)
1014  if not os.path.exists(fastValFilePath) and plotting.verbose:
1015  print "FastSim file %s not found" % fastValFilePath
1016  fullValFilePath = os.path.join(fulldir, valname)
1017  if not os.path.exists(fullValFilePath) and plotting.verbose:
1018  print "FullSim file %s not found" % fullValFilePath
1019 
1020  fastValFile = ROOT.TFile.Open(fastValFilePath)
1021  fullValFile = ROOT.TFile.Open(fullValFilePath)
1022 
1023  # Do plots
1024  if plotting.verbose:
1025  print "Comparing FullSim and FastSim {sample} {translatedFolder}".format(
1026  sample=fastSample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
1027  rootFiles = [fullValFile, fastValFile]
1028  legendLabels = [
1029  "FullSim %s, %s %s" % (fullSample.name(), _stripRelease(self._newRelease), fullSelection),
1030  "FastSim %s, %s %s" % (fastSample.name(), _stripRelease(self._newRelease), fastSelection),
1031  ]
1032  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=fastSample.pileupEnabled(), requireAllHistograms=True)
1033  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
1034 
1035  # For tables we just try them all, and see which ones succeed
1036  for tableCreator in plotterFolder.getTableCreators():
1037  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
1038 
1039  fullValFile.Close()
1040  fastValFile.Close()
1041 
1042  if len(fileList) == 0:
1043  return []
1044 
1045  dups = _findDuplicates(fileList)
1046  if len(dups) > 0:
1047  print "Plotter produced multiple files with names", ", ".join(dups)
1048  print "Typically this is a naming problem in the plotter configuration"
1049  sys.exit(1)
1050 
1051  # Move plots to new directory
1052  print "Created plots in %s" % (newdir)
1053  return map(lambda n: n.replace(newdir, newsubdir), fileList)
1054 
def _getGlobalTag(sample, release)
Definition: validation.py:356
def _stripRelease(release)
Definition: validation.py:349
def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:989
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:1172
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 1055 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().

1055  def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport):
1056  """Do the real plotting work for two pileup scenarios for a given algorithm, quality flag, and sample."""
1057  # Get GlobalTags
1058  pu140GlobalTag = _getGlobalTag(pu140Sample, self._newRelease)
1059  pu200GlobalTag = _getGlobalTag(pu200Sample, self._newRelease)
1060 
1061  # Construct selection string
1062  tmp = plotterFolder.getSelectionName(dqmSubFolder)
1063  pu140Selection = pu140GlobalTag+"_"+pu140Sample.pileup()+tmp+"_"+pu140Sample.pileupType(self._newRelease)
1064  pu200Selection = pu200GlobalTag+"_"+pu200Sample.pileup()+tmp+"_"+pu200Sample.pileupType(self._newRelease)
1065 
1066  # Construct directories for
1067  pu140dir = os.path.join(self._newBaseDir, pu140Selection, pu140Sample.name())
1068  pu200dir = os.path.join(self._newBaseDir, pu200Selection, pu200Sample.name())
1069  newsubdir = os.path.join("pileup", self._newRelease, pu200Selection, pu200Sample.name())
1070  newdir = os.path.join(self._newBaseDir, newsubdir)
1071  if not os.path.exists(newdir):
1072  os.makedirs(newdir)
1073 
1074  # Open input root files
1075  valname = "val.{sample}.root".format(sample=pu140Sample.name())
1076  pu140ValFilePath = os.path.join(pu140dir, valname)
1077  if not os.path.exists(pu140ValFilePath):
1078  if plotting.verbose:
1079  print "PU140 file %s not found" % pu140ValFilePath
1080  return []
1081  pu200ValFilePath = os.path.join(pu200dir, valname)
1082  if not os.path.exists(pu200ValFilePath):
1083  if plotting.verbose:
1084  print "PU200 file %s not found" % pu200ValFilePath
1085  return []
1086 
1087  pu140ValFile = ROOT.TFile.Open(pu140ValFilePath)
1088  pu200ValFile = ROOT.TFile.Open(pu200ValFilePath)
1089 
1090  # Do plots
1091  if plotting.verbose:
1092  print "Comparing PU140 and PU200 {sample} {translatedFolder}".format(
1093  sample=pu200Sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
1094  rootFiles = [pu140ValFile, pu200ValFile]
1095  legendLabels = [
1096  "%s, %s %s" % (pu140Sample.name(), _stripRelease(self._newRelease), pu140Selection),
1097  "%s, %s %s" % (pu200Sample.name(), _stripRelease(self._newRelease), pu200Selection),
1098  ]
1099  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=pu140Sample.pileupEnabled(), requireAllHistograms=True)
1100  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
1101 
1102  # For tables we just try them all, and see which ones succeed
1103  for tableCreator in plotterFolder.getTableCreators():
1104  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
1105 
1106  pu200ValFile.Close()
1107  pu140ValFile.Close()
1108 
1109  if len(fileList) == 0:
1110  return []
1111 
1112  dups = _findDuplicates(fileList)
1113  if len(dups) > 0:
1114  print "Plotter produced multiple files with names", ", ".join(dups)
1115  print "Typically this is a naming problem in the plotter configuration"
1116  sys.exit(1)
1117 
1118  # Move plots to new directory
1119  print "Created plots in %s" % (newdir)
1120  return map(lambda n: n.replace(newdir, newsubdir), fileList)
1121 
1122 
def _getGlobalTag(sample, release)
Definition: validation.py:356
def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:1055
def _stripRelease(release)
Definition: validation.py:349
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:1172
def validation.Validation._getDirectoryName (   self,
  args,
  kwargs 
)
private

Definition at line 710 of file validation.py.

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

Definition at line 876 of file validation.py.

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

Referenced by validation.Validation._doPlots().

876  def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname):
877  if self._refRelease is None:
878  return (None, "")
879 
880  refGlobalTag = _getGlobalTag(sample, self._refRelease)
881  def _createRefSelection(selectionName):
882  sel = refGlobalTag+selectionNameBase+selectionName
883  if sample.pileupEnabled():
884  refPu = sample.pileupType(self._refRelease)
885  if refPu != "":
886  sel += "_"+refPu
887  return sel
888  refSelection = _createRefSelection(plotterFolder.getSelectionName(dqmSubFolder))
889 
890  # Construct reference directory name, and open reference file it it exists
891  refValFile = None
892  triedRefValFiles = []
893  tmp = [self._refRepository, self._refRelease]
894  if sample.fastsim():
895  tmp.extend(["fastsim", self._refRelease])
896  for selName in plotterFolder.getSelectionNameIterator(dqmSubFolder):
897  refSel = _createRefSelection(selName)
898  refdir = os.path.join(*(tmp+[refSel, sample.name()]))
899 
900  # Open reference file if it exists
901  refValFilePath = os.path.join(refdir, valname)
902  if os.path.exists(refValFilePath):
903  refSelection = refSel
904  refValFile = ROOT.TFile.Open(refValFilePath)
905  break
906  else:
907  triedRefValFiles.append(refValFilePath)
908  if refValFile is None:
909  if len(triedRefValFiles) == 1:
910  if plotting.verbose:
911  print "Reference file %s not found" % triedRefValFiles[0]
912  else:
913  if plotting.verbose:
914  print "None of the possible reference files %s not found" % ",".join(triedRefValFiles)
915 
916  return (refValFile, refSelection)
917 
def _getGlobalTag(sample, release)
Definition: validation.py:356
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
Definition: validation.py:876
def validation.Validation._getSelectionName (   self,
  args,
  kwargs 
)
private

Definition at line 713 of file validation.py.

References validation.Validation._selectionName.

713  def _getSelectionName(self, *args, **kwargs):
714  return self._selectionName
715 
def _getSelectionName(self, args, kwargs)
Definition: validation.py:713
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 768 of file validation.py.

768  def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False):
769  """Create validation plots.
770 
771  Arguments:
772  plotter -- plotting.Plotter object that does the plotting
773 
774  Keyword arguments:
775  plotterDrawArgs -- Dictionary for additional arguments to Plotter.draw() (default: {})
776  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.
777  htmlReport -- Object returned by createHtmlReport(), in case HTML report generation is desired
778  doFastVsFull -- Do FastSim vs. FullSim comparison? (default: True)
779  doPhase2PU -- Do Phase2 PU 200 vs. 140 comparison (default: False)
780  """
781  self._plotter = plotter
782  self._plotterDrawArgs = plotterDrawArgs
783 
784  # New vs. Ref
785  for sample in self._fullsimSamples+self._fastsimSamples:
786  # Check that the new DQM file exists
787  harvestedFile = sample.filename(self._newRelease)
788  if not os.path.exists(harvestedFile):
789  print "Harvested file %s does not exist!" % harvestedFile
790  sys.exit(1)
791 
792  plotterInstance = plotter.readDirs(harvestedFile)
793  htmlReport.beginSample(sample)
794  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
795  if not _processPlotsForSample(plotterFolder, sample):
796  continue
797  plotFiles = self._doPlots(sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
798  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
799 
800  # Fast vs. Full
801  if doFastVsFull:
802  self._doFastsimFastVsFullPlots(limitSubFoldersOnlyTo, htmlReport)
803 
804  # Phase2 PU200 vs. PU 140
805  if doPhase2PU:
806  self._doPhase2PileupPlots(limitSubFoldersOnlyTo, htmlReport)
807 
def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:808
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:460
def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:841
def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False)
Definition: validation.py:768
def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:918
def validation.Validation.download (   self)
Download DQM files. Requires grid certificate and asks your password for it.

Definition at line 716 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.

716  def download(self):
717  """Download DQM files. Requires grid certificate and asks your password for it."""
718  filenames = [s.filename(self._newRelease) for s in self._fullsimSamples+self._fastsimSamples]
719  if self._newFileModifier is not None:
720  filenames = map(self._newFileModifier, filenames)
721  filenames = filter(lambda f: not os.path.exists(f), filenames)
722  if len(filenames) == 0:
723  print "All files already downloaded"
724  return
725 
726  relvalUrl = _getRelValUrl(self._newRelease)
727  urls = [relvalUrl+f for f in filenames]
728  certfile = os.path.join(os.environ["HOME"], ".globus", "usercert.pem")
729  if not os.path.exists(certfile):
730  print "Certificate file {certfile} does not exist, unable to download RelVal files from {url}".format(certfile=certfile, url=relvalUrl)
731  sys.exit(1)
732  keyfile = os.path.join(os.environ["HOME"], ".globus", "userkey.pem")
733  if not os.path.exists(certfile):
734  print "Private key file {keyfile} does not exist, unable to download RelVal files from {url}".format(keyfile=keyfile, url=relvalUrl)
735  sys.exit(1)
736 
737  # curl --cert-type PEM --cert $HOME/.globus/usercert.pem --key $HOME/.globus/userkey.pem -k -O <url> -O <url>
738  cmd = ["curl", "--cert-type", "PEM", "--cert", certfile, "--key", keyfile, "-k"]
739  for u in urls:
740  cmd.extend(["-O", u])
741  print "Downloading %d files from RelVal URL %s:" % (len(filenames), relvalUrl)
742  print " "+"\n ".join(filenames)
743  print "Please provide your private key pass phrase when curl asks it"
744  ret = subprocess.call(cmd)
745  if ret != 0:
746  print "Downloading failed with exit code %d" % ret
747  sys.exit(1)
748 
749  # verify
750  allFine = True
751  for f in filenames:
752  p = subprocess.Popen(["file", f], stdout=subprocess.PIPE)
753  stdout = p.communicate()[0]
754  if p.returncode != 0:
755  print "file command failed with exit code %d" % p.returncode
756  sys.exit(1)
757  if not "ROOT" in stdout:
758  print "File {f} is not ROOT, please check the correct version, GlobalTag etc. from {url}".format(f=f, url=relvalUrl)
759  allFine = False
760  if os.path.exists(f):
761  os.remove(f)
762  if not allFine:
763  sys.exit(1)
764 
def _getRelValUrl(release)
Definition: validation.py:448
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 707 of file validation.py.

Referenced by validation.Validation.download().

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

Definition at line 781 of file validation.py.

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

Definition at line 704 of file validation.py.

Referenced by validation.Validation._getRefFileAndSelection().

validation.Validation._selectionName
private

Definition at line 708 of file validation.py.

Referenced by validation.Validation._getSelectionName().