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 680 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 682 of file validation.py.

Referenced by vertexPlots.VertexValidation._init__().

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

Member Function Documentation

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

Definition at line 809 of file validation.py.

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

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

Definition at line 842 of file validation.py.

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

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

Referenced by validation.SimpleValidation._doPlotsForPlotter().

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

Referenced by validation.Validation._doFastsimFastVsFullPlots().

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

Referenced by validation.Validation._doPhase2PileupPlots().

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

Definition at line 711 of file validation.py.

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

Definition at line 877 of file validation.py.

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

Referenced by validation.Validation._doPlots().

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

Definition at line 714 of file validation.py.

References validation.Validation._selectionName.

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

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

Definition at line 717 of file validation.py.

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

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

Referenced by validation.Validation.download().

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

Definition at line 782 of file validation.py.

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

Definition at line 705 of file validation.py.

Referenced by validation.Validation._getRefFileAndSelection().

validation.Validation._selectionName
private

Definition at line 709 of file validation.py.

Referenced by validation.Validation._getSelectionName().