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

Constructor & Destructor Documentation

◆ __init__()

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

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

Referenced by vertexPlots.VertexValidation._init__().

Member Function Documentation

◆ _doFastsimFastVsFullPlots()

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

Definition at line 811 of file validation.py.

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

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

◆ _doPhase2PileupPlots()

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

Definition at line 844 of file validation.py.

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

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

◆ _doPlots()

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

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

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, print(), and str.

Referenced by validation.SimpleValidation._doPlotsForPlotter(), and validation.SeparateValidation._doPlotsForPlotter().

◆ _doPlotsFastFull()

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

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

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

Referenced by validation.Validation._doFastsimFastVsFullPlots().

◆ _doPlotsPileup()

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

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

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

Referenced by validation.Validation._doPhase2PileupPlots().

◆ _getDirectoryName()

def validation.Validation._getDirectoryName (   self,
args,
**  kwargs 
)
private

Definition at line 713 of file validation.py.

713  def _getDirectoryName(self, *args, **kwargs):
714  return None
715 

◆ _getRefFileAndSelection()

def validation.Validation._getRefFileAndSelection (   self,
  sample,
  plotterFolder,
  dqmSubFolder,
  selectionNameBase,
  valname 
)
private

Definition at line 879 of file validation.py.

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

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

Referenced by validation.Validation._doPlots().

◆ _getSelectionName()

def validation.Validation._getSelectionName (   self,
args,
**  kwargs 
)
private

Definition at line 716 of file validation.py.

716  def _getSelectionName(self, *args, **kwargs):
717  return self._selectionName
718 

References validation.Validation._selectionName.

◆ createHtmlReport()

def validation.Validation.createHtmlReport (   self)

Definition at line 768 of file validation.py.

768  def createHtmlReport(self):
769  return html.HtmlReport(self._newRelease, self._newBaseDir)
770 

References validation.Validation._newBaseDir, html.HtmlReport._newBaseDir, and validation.Validation._newRelease.

◆ doPlots()

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

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

◆ download()

def validation.Validation.download (   self)
Download DQM files. Requires grid certificate and asks your password for it.

Definition at line 719 of file validation.py.

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

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

Member Data Documentation

◆ _fastsimSamples

validation.Validation._fastsimSamples
private

◆ _fullsimSamples

validation.Validation._fullsimSamples
private

◆ _newBaseDir

validation.Validation._newBaseDir
private

◆ _newFileModifier

validation.Validation._newFileModifier
private

Definition at line 710 of file validation.py.

Referenced by validation.Validation.download().

◆ _newRelease

validation.Validation._newRelease
private

◆ _plotter

validation.Validation._plotter
private

◆ _plotterDrawArgs

validation.Validation._plotterDrawArgs
private

◆ _refRelease

validation.Validation._refRelease
private

◆ _refRepository

validation.Validation._refRepository
private

Definition at line 707 of file validation.py.

Referenced by validation.Validation._getRefFileAndSelection().

◆ _selectionName

validation.Validation._selectionName
private

Definition at line 711 of file validation.py.

Referenced by validation.Validation._getSelectionName().

validation._findDuplicates
def _findDuplicates(lst)
Definition: validation.py:1175
validation._stripRelease
def _stripRelease(release)
Definition: validation.py:352
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
str
#define str(s)
Definition: TestProcessor.cc:51
validation._copySubDir
def _copySubDir(oldfile, newfile, basenames, dirname)
Definition: validation.py:1126
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
Exception
validation._getRelValUrl
def _getRelValUrl(release)
Definition: validation.py:451
validation._processPlotsForSample
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:463
validation._getGlobalTag
def _getGlobalTag(sample, release)
Definition: validation.py:359
format
genParticles_cff.map
map
Definition: genParticles_cff.py:11
html.HtmlReport
Definition: html.py:739