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

Referenced by vertexPlots.VertexValidation._init__().

650  def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName=""):
651  """Constructor.
652 
653  Arguments:
654  fullsimSamples -- List of Sample objects for FullSim samples (may be empty)
655  fastsimSamples -- List of Sample objects for FastSim samples (may be empty)
656  refRelease -- String for reference CMSSW release (can be None for no reference release)
657  newRepository -- String for directory whete to put new files
658  newRelease -- CMSSW release to be validated
659  refRepository -- String for directory where reference root files are
660  newFileModifier -- If given, a function to modify the names of the new files (function takes a string and returns a string)
661  selectionName -- If given, use this string as the selection name (appended to GlobalTag for directory names)
662  """
663  try:
664  self._newRelease = os.environ["CMSSW_VERSION"]
665  except KeyError:
666  print >>sys.stderr, 'Error: CMSSW environment variables are not available.'
667  print >>sys.stderr, ' Please run cmsenv'
668  sys.exit()
669 
670  self._fullsimSamples = fullsimSamples
671  self._fastsimSamples = fastsimSamples
672  self._refRelease = refRelease
673  self._refRepository = refRepository
674  self._newRelease = newRelease
675  self._newBaseDir = os.path.join(newRepository, self._newRelease)
676  self._newFileModifier = newFileModifier
677  self._selectionName = selectionName
678 
def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName="")
Definition: validation.py:650

Member Function Documentation

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

Definition at line 777 of file validation.py.

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

777  def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport):
778  for fast in self._fastsimSamples:
779  correspondingFull = None
780  for full in self._fullsimSamples:
781  if fast.name() != full.name():
782  continue
783  if fast.pileupEnabled():
784  if not full.pileupEnabled():
785  continue
786  if fast.fastsimCorrespondingFullsimPileup() != full.pileupType():
787  continue
788  else:
789  if full.pileupEnabled():
790  continue
791 
792  if correspondingFull is None:
793  correspondingFull = full
794  else:
795  raise Exception("Got multiple compatible FullSim samples for FastSim sample %s %s" % (fast.name(), fast.pileup()))
796  if correspondingFull is None:
797  print "WARNING: Did not find compatible FullSim sample for FastSim sample %s %s, omitting FastSim vs. FullSim comparison" % (fast.name(), fast.pileup())
798  continue
799 
800  # If we reach here, the harvestedFile must exist
801  harvestedFile = fast.filename(self._newRelease)
802  plotterInstance = self._plotter.readDirs(harvestedFile)
803  htmlReport.beginSample(fast, fastVsFull=True)
804  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
805  if not _processPlotsForSample(plotterFolder, fast):
806  continue
807  plotFiles = self._doPlotsFastFull(fast, correspondingFull, plotterFolder, dqmSubFolder, htmlReport)
808  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
809 
def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:777
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:429
def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:958
def validation.Validation._doPhase2PileupPlots (   self,
  limitSubFoldersOnlyTo,
  htmlReport 
)
private

Definition at line 810 of file validation.py.

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

810  def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport):
811  def _stripScenario(name):
812  puindex = name.find("PU")
813  if puindex < 0:
814  return name
815  return name[:puindex]
816 
817  pu140samples = {}
818  for sample in self._fullsimSamples:
819  if sample.pileupNumber() == 140:
820  key = (sample.name(), _stripScenario(sample.scenario()))
821  if key in pu140samples:
822  raise Exception("Duplicate entry for sample %s in scenario %s" % (sample.name(), sample.scenar()))
823  pu140samples[key] = sample
824 
825  for sample in self._fullsimSamples:
826  if sample.pileupNumber() != 200:
827  continue
828  key = (sample.name(), _stripScenario(sample.scenario()))
829  if not key in pu140samples:
830  continue
831 
832  sample_pu140 = pu140samples[key]
833 
834  # If we reach here, the harvestedFile must exist
835  harvestedFile = sample.filename(self._newRelease)
836  plotterInstance = self._plotter.readDirs(harvestedFile)
837  htmlReport.beginSample(sample, pileupComparison="vs. PU140")
838  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
839  if not _processPlotsForSample(plotterFolder, sample):
840  continue
841  plotFiles = self._doPlotsPileup(sample_pu140, sample, plotterFolder, dqmSubFolder, htmlReport)
842  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
843 
844 
def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:1024
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:429
def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:810
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 887 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().

887  def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport):
888  """Do the real plotting work for a given sample and DQM subfolder"""
889  # Get GlobalTags
890  newGlobalTag = _getGlobalTag(sample, self._newRelease)
891 
892  # Construct selection string
893  selectionNameBase = "_"+sample.pileup()
894  newSelection = newGlobalTag+selectionNameBase+plotterFolder.getSelectionName(dqmSubFolder)
895  if sample.pileupEnabled():
896  newPu = sample.pileupType(self._newRelease)
897  if newPu != "":
898  newSelection += "_"+newPu
899 
900  valname = "val.{sample}.root".format(sample=sample.name())
901 
902  # Construct reference file and selection string
903  (refValFile, refSelection) = self._getRefFileAndSelection(sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
904 
905  # Construct new directory name
906  tmp = []
907  if sample.fastsim():
908  tmp.extend(["fastsim", self._newRelease])
909  tmp.extend([newSelection, sample.name()])
910  newsubdir = os.path.join(*tmp)
911  newdir = os.path.join(self._newBaseDir, newsubdir)
912  if not os.path.exists(newdir):
913  os.makedirs(newdir)
914  valnameFullPath = os.path.join(newdir, valname)
915 
916  # Copy the relevant histograms to a new validation root file
917  # TODO: treat the case where dqmSubFolder is empty
918  newValFile = _copySubDir(harvestedFile, valnameFullPath, plotterFolder.getPossibleDQMFolders(), dqmSubFolder.subfolder if dqmSubFolder is not None else None)
919  fileList = []
920 
921  # Do the plots
922  if plotting.verbose:
923  print "Comparing ref and new {sim} {sample} {translatedFolder}".format(
924  sim="FullSim" if not sample.fastsim() else "FastSim",
925  sample=sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
926  rootFiles = [refValFile, newValFile]
927  legendLabels = [
928  "%s, %s %s" % (sample.name(), _stripRelease(self._refRelease), refSelection) if self._refRelease is not None else "dummy",
929  "%s, %s %s" % (sample.name(), _stripRelease(self._newRelease), newSelection)
930  ]
931  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=sample.pileupEnabled())
932  fileList.extend(plotterFolder.draw(directory=newdir, **self._plotterDrawArgs))
933  # Copy val file only if there were plots
934  if len(fileList) > 0:
935  fileList.append(valnameFullPath)
936 
937  # For tables we just try them all, and see which ones succeed
938  for tableCreator in plotterFolder.getTableCreators():
939  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
940 
941  newValFile.Close()
942  if refValFile is not None:
943  refValFile.Close()
944 
945  if len(fileList) == 0:
946  return []
947 
948  dups = _findDuplicates(fileList)
949  if len(dups) > 0:
950  print "Plotter produced multiple files with names", ", ".join(dups)
951  print "Typically this is a naming problem in the plotter configuration"
952  sys.exit(1)
953 
954  # Move plots to new directory
955  print "Created plots and %s in %s" % (valname, newdir)
956  return map(lambda n: n.replace(newdir, newsubdir), fileList)
957 
def _getGlobalTag(sample, release)
Definition: validation.py:326
def _stripRelease(release)
Definition: validation.py:319
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:1141
def _copySubDir(oldfile, newfile, basenames, dirname)
Definition: validation.py:1092
def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
Definition: validation.py:845
def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:887
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 958 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().

958  def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport):
959  """Do the real plotting work for FastSim vs. FullSim for a given algorithm, quality flag, and sample."""
960  # Get GlobalTags
961  fastGlobalTag = _getGlobalTag(fastSample, self._newRelease)
962  fullGlobalTag = _getGlobalTag(fullSample, self._newRelease)
963 
964  # Construct selection string
965  tmp = plotterFolder.getSelectionName(dqmSubFolder)
966  fastSelection = fastGlobalTag+"_"+fastSample.pileup()+tmp
967  fullSelection = fullGlobalTag+"_"+fullSample.pileup()+tmp
968  if fullSample.pileupEnabled():
969  fullSelection += "_"+fullSample.pileupType(self._newRelease)
970  fastSelection += "_"+fastSample.pileupType(self._newRelease)
971 
972  # Construct directories for FastSim, FullSim, and for the results
973  fastdir = os.path.join(self._newBaseDir, "fastsim", self._newRelease, fastSelection, fastSample.name())
974  fulldir = os.path.join(self._newBaseDir, fullSelection, fullSample.name())
975  newsubdir = os.path.join("fastfull", self._newRelease, fastSelection, fastSample.name())
976  newdir = os.path.join(self._newBaseDir, newsubdir)
977  if not os.path.exists(newdir):
978  os.makedirs(newdir)
979 
980  # Open input root files
981  valname = "val.{sample}.root".format(sample=fastSample.name())
982  fastValFilePath = os.path.join(fastdir, valname)
983  if not os.path.exists(fastValFilePath) and plotting.verbose:
984  print "FastSim file %s not found" % fastValFilePath
985  fullValFilePath = os.path.join(fulldir, valname)
986  if not os.path.exists(fullValFilePath) and plotting.verbose:
987  print "FullSim file %s not found" % fullValFilePath
988 
989  fastValFile = ROOT.TFile.Open(fastValFilePath)
990  fullValFile = ROOT.TFile.Open(fullValFilePath)
991 
992  # Do plots
993  if plotting.verbose:
994  print "Comparing FullSim and FastSim {sample} {translatedFolder}".format(
995  sample=fastSample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
996  rootFiles = [fullValFile, fastValFile]
997  legendLabels = [
998  "FullSim %s, %s %s" % (fullSample.name(), _stripRelease(self._newRelease), fullSelection),
999  "FastSim %s, %s %s" % (fastSample.name(), _stripRelease(self._newRelease), fastSelection),
1000  ]
1001  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=fastSample.pileupEnabled(), requireAllHistograms=True)
1002  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
1003 
1004  # For tables we just try them all, and see which ones succeed
1005  for tableCreator in plotterFolder.getTableCreators():
1006  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
1007 
1008  fullValFile.Close()
1009  fastValFile.Close()
1010 
1011  if len(fileList) == 0:
1012  return []
1013 
1014  dups = _findDuplicates(fileList)
1015  if len(dups) > 0:
1016  print "Plotter produced multiple files with names", ", ".join(dups)
1017  print "Typically this is a naming problem in the plotter configuration"
1018  sys.exit(1)
1019 
1020  # Move plots to new directory
1021  print "Created plots in %s" % (newdir)
1022  return map(lambda n: n.replace(newdir, newsubdir), fileList)
1023 
def _getGlobalTag(sample, release)
Definition: validation.py:326
def _stripRelease(release)
Definition: validation.py:319
def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:958
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:1141
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 1024 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().

1024  def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport):
1025  """Do the real plotting work for two pileup scenarios for a given algorithm, quality flag, and sample."""
1026  # Get GlobalTags
1027  pu140GlobalTag = _getGlobalTag(pu140Sample, self._newRelease)
1028  pu200GlobalTag = _getGlobalTag(pu200Sample, self._newRelease)
1029 
1030  # Construct selection string
1031  tmp = plotterFolder.getSelectionName(dqmSubFolder)
1032  pu140Selection = pu140GlobalTag+"_"+pu140Sample.pileup()+tmp+"_"+pu140Sample.pileupType(self._newRelease)
1033  pu200Selection = pu200GlobalTag+"_"+pu200Sample.pileup()+tmp+"_"+pu200Sample.pileupType(self._newRelease)
1034 
1035  # Construct directories for
1036  pu140dir = os.path.join(self._newBaseDir, pu140Selection, pu140Sample.name())
1037  pu200dir = os.path.join(self._newBaseDir, pu200Selection, pu200Sample.name())
1038  newsubdir = os.path.join("pileup", self._newRelease, pu200Selection, pu200Sample.name())
1039  newdir = os.path.join(self._newBaseDir, newsubdir)
1040  if not os.path.exists(newdir):
1041  os.makedirs(newdir)
1042 
1043  # Open input root files
1044  valname = "val.{sample}.root".format(sample=pu140Sample.name())
1045  pu140ValFilePath = os.path.join(pu140dir, valname)
1046  if not os.path.exists(pu140ValFilePath):
1047  if plotting.verbose:
1048  print "PU140 file %s not found" % pu140ValFilePath
1049  return []
1050  pu200ValFilePath = os.path.join(pu200dir, valname)
1051  if not os.path.exists(pu200ValFilePath):
1052  if plotting.verbose:
1053  print "PU200 file %s not found" % pu200ValFilePath
1054  return []
1055 
1056  pu140ValFile = ROOT.TFile.Open(pu140ValFilePath)
1057  pu200ValFile = ROOT.TFile.Open(pu200ValFilePath)
1058 
1059  # Do plots
1060  if plotting.verbose:
1061  print "Comparing PU140 and PU200 {sample} {translatedFolder}".format(
1062  sample=pu200Sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
1063  rootFiles = [pu140ValFile, pu200ValFile]
1064  legendLabels = [
1065  "%s, %s %s" % (pu140Sample.name(), _stripRelease(self._newRelease), pu140Selection),
1066  "%s, %s %s" % (pu200Sample.name(), _stripRelease(self._newRelease), pu200Selection),
1067  ]
1068  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=pu140Sample.pileupEnabled(), requireAllHistograms=True)
1069  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
1070 
1071  # For tables we just try them all, and see which ones succeed
1072  for tableCreator in plotterFolder.getTableCreators():
1073  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
1074 
1075  pu200ValFile.Close()
1076  pu140ValFile.Close()
1077 
1078  if len(fileList) == 0:
1079  return []
1080 
1081  dups = _findDuplicates(fileList)
1082  if len(dups) > 0:
1083  print "Plotter produced multiple files with names", ", ".join(dups)
1084  print "Typically this is a naming problem in the plotter configuration"
1085  sys.exit(1)
1086 
1087  # Move plots to new directory
1088  print "Created plots in %s" % (newdir)
1089  return map(lambda n: n.replace(newdir, newsubdir), fileList)
1090 
1091 
def _getGlobalTag(sample, release)
Definition: validation.py:326
def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:1024
def _stripRelease(release)
Definition: validation.py:319
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:1141
def validation.Validation._getDirectoryName (   self,
  args,
  kwargs 
)
private

Definition at line 679 of file validation.py.

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

Definition at line 845 of file validation.py.

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

Referenced by validation.Validation._doPlots().

845  def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname):
846  if self._refRelease is None:
847  return (None, "")
848 
849  refGlobalTag = _getGlobalTag(sample, self._refRelease)
850  def _createRefSelection(selectionName):
851  sel = refGlobalTag+selectionNameBase+selectionName
852  if sample.pileupEnabled():
853  refPu = sample.pileupType(self._refRelease)
854  if refPu != "":
855  sel += "_"+refPu
856  return sel
857  refSelection = _createRefSelection(plotterFolder.getSelectionName(dqmSubFolder))
858 
859  # Construct reference directory name, and open reference file it it exists
860  refValFile = None
861  triedRefValFiles = []
862  tmp = [self._refRepository, self._refRelease]
863  if sample.fastsim():
864  tmp.extend(["fastsim", self._refRelease])
865  for selName in plotterFolder.getSelectionNameIterator(dqmSubFolder):
866  refSel = _createRefSelection(selName)
867  refdir = os.path.join(*(tmp+[refSel, sample.name()]))
868 
869  # Open reference file if it exists
870  refValFilePath = os.path.join(refdir, valname)
871  if os.path.exists(refValFilePath):
872  refSelection = refSel
873  refValFile = ROOT.TFile.Open(refValFilePath)
874  break
875  else:
876  triedRefValFiles.append(refValFilePath)
877  if refValFile is None:
878  if len(triedRefValFiles) == 1:
879  if plotting.verbose:
880  print "Reference file %s not found" % triedRefValFiles[0]
881  else:
882  if plotting.verbose:
883  print "None of the possible reference files %s not found" % ",".join(triedRefValFiles)
884 
885  return (refValFile, refSelection)
886 
def _getGlobalTag(sample, release)
Definition: validation.py:326
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
Definition: validation.py:845
def validation.Validation._getSelectionName (   self,
  args,
  kwargs 
)
private

Definition at line 682 of file validation.py.

References validation.Validation._selectionName.

682  def _getSelectionName(self, *args, **kwargs):
683  return self._selectionName
684 
def _getSelectionName(self, args, kwargs)
Definition: validation.py:682
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 737 of file validation.py.

737  def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False):
738  """Create validation plots.
739 
740  Arguments:
741  plotter -- plotting.Plotter object that does the plotting
742 
743  Keyword arguments:
744  plotterDrawArgs -- Dictionary for additional arguments to Plotter.draw() (default: {})
745  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.
746  htmlReport -- Object returned by createHtmlReport(), in case HTML report generation is desired
747  doFastVsFull -- Do FastSim vs. FullSim comparison? (default: True)
748  doPhase2PU -- Do Phase2 PU 200 vs. 140 comparison (default: False)
749  """
750  self._plotter = plotter
751  self._plotterDrawArgs = plotterDrawArgs
752 
753  # New vs. Ref
754  for sample in self._fullsimSamples+self._fastsimSamples:
755  # Check that the new DQM file exists
756  harvestedFile = sample.filename(self._newRelease)
757  if not os.path.exists(harvestedFile):
758  print "Harvested file %s does not exist!" % harvestedFile
759  sys.exit(1)
760 
761  plotterInstance = plotter.readDirs(harvestedFile)
762  htmlReport.beginSample(sample)
763  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
764  if not _processPlotsForSample(plotterFolder, sample):
765  continue
766  plotFiles = self._doPlots(sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
767  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
768 
769  # Fast vs. Full
770  if doFastVsFull:
771  self._doFastsimFastVsFullPlots(limitSubFoldersOnlyTo, htmlReport)
772 
773  # Phase2 PU200 vs. PU 140
774  if doPhase2PU:
775  self._doPhase2PileupPlots(limitSubFoldersOnlyTo, htmlReport)
776 
def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:777
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:429
def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:810
def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False)
Definition: validation.py:737
def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:887
def validation.Validation.download (   self)
Download DQM files. Requires grid certificate and asks your password for it.

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

685  def download(self):
686  """Download DQM files. Requires grid certificate and asks your password for it."""
687  filenames = [s.filename(self._newRelease) for s in self._fullsimSamples+self._fastsimSamples]
688  if self._newFileModifier is not None:
689  filenames = map(self._newFileModifier, filenames)
690  filenames = filter(lambda f: not os.path.exists(f), filenames)
691  if len(filenames) == 0:
692  print "All files already downloaded"
693  return
694 
695  relvalUrl = _getRelValUrl(self._newRelease)
696  urls = [relvalUrl+f for f in filenames]
697  certfile = os.path.join(os.environ["HOME"], ".globus", "usercert.pem")
698  if not os.path.exists(certfile):
699  print "Certificate file {certfile} does not exist, unable to download RelVal files from {url}".format(certfile=certfile, url=relvalUrl)
700  sys.exit(1)
701  keyfile = os.path.join(os.environ["HOME"], ".globus", "userkey.pem")
702  if not os.path.exists(certfile):
703  print "Private key file {keyfile} does not exist, unable to download RelVal files from {url}".format(keyfile=keyfile, url=relvalUrl)
704  sys.exit(1)
705 
706  # curl --cert-type PEM --cert $HOME/.globus/usercert.pem --key $HOME/.globus/userkye.pem -k -O <url> -O <url>
707  cmd = ["curl", "--cert-type", "PEM", "--cert", certfile, "--key", keyfile, "-k"]
708  for u in urls:
709  cmd.extend(["-O", u])
710  print "Downloading %d files from RelVal URL %s:" % (len(filenames), relvalUrl)
711  print " "+"\n ".join(filenames)
712  print "Please provide your private key pass phrase when curl asks it"
713  ret = subprocess.call(cmd)
714  if ret != 0:
715  print "Downloading failed with exit code %d" % ret
716  sys.exit(1)
717 
718  # verify
719  allFine = True
720  for f in filenames:
721  p = subprocess.Popen(["file", f], stdout=subprocess.PIPE)
722  stdout = p.communicate()[0]
723  if p.returncode != 0:
724  print "file command failed with exit code %d" % p.returncode
725  sys.exit(1)
726  if not "ROOT" in stdout:
727  print "File {f} is not ROOT, please check the correct version, GlobalTag etc. from {url}".format(f=f, url=relvalUrl)
728  allFine = False
729  if os.path.exists(f):
730  os.remove(f)
731  if not allFine:
732  sys.exit(1)
733 
def _getRelValUrl(release)
Definition: validation.py:417
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 676 of file validation.py.

Referenced by validation.Validation.download().

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

Definition at line 750 of file validation.py.

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

Definition at line 673 of file validation.py.

Referenced by validation.Validation._getRefFileAndSelection().

validation.Validation._selectionName
private

Definition at line 677 of file validation.py.

Referenced by validation.Validation._getSelectionName().