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

Referenced by vertexPlots.VertexValidation._init__().

620  def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName=""):
621  """Constructor.
622 
623  Arguments:
624  fullsimSamples -- List of Sample objects for FullSim samples (may be empty)
625  fastsimSamples -- List of Sample objects for FastSim samples (may be empty)
626  refRelease -- String for reference CMSSW release (can be None for no reference release)
627  newRepository -- String for directory whete to put new files
628  newRelease -- CMSSW release to be validated
629  refRepository -- String for directory where reference root files are
630  newFileModifier -- If given, a function to modify the names of the new files (function takes a string and returns a string)
631  selectionName -- If given, use this string as the selection name (appended to GlobalTag for directory names)
632  """
633  try:
634  self._newRelease = os.environ["CMSSW_VERSION"]
635  except KeyError:
636  print >>sys.stderr, 'Error: CMSSW environment variables are not available.'
637  print >>sys.stderr, ' Please run cmsenv'
638  sys.exit()
639 
640  self._fullsimSamples = fullsimSamples
641  self._fastsimSamples = fastsimSamples
642  self._refRelease = refRelease
643  self._refRepository = refRepository
644  self._newRelease = newRelease
645  self._newBaseDir = os.path.join(newRepository, self._newRelease)
646  self._newFileModifier = newFileModifier
647  self._selectionName = selectionName
648 
def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName="")
Definition: validation.py:620

Member Function Documentation

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

Definition at line 747 of file validation.py.

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

747  def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport):
748  for fast in self._fastsimSamples:
749  correspondingFull = None
750  for full in self._fullsimSamples:
751  if fast.name() != full.name():
752  continue
753  if fast.pileupEnabled():
754  if not full.pileupEnabled():
755  continue
756  if fast.fastsimCorrespondingFullsimPileup() != full.pileupType():
757  continue
758  else:
759  if full.pileupEnabled():
760  continue
761 
762  if correspondingFull is None:
763  correspondingFull = full
764  else:
765  raise Exception("Got multiple compatible FullSim samples for FastSim sample %s %s" % (fast.name(), fast.pileup()))
766  if correspondingFull is None:
767  print "WARNING: Did not find compatible FullSim sample for FastSim sample %s %s, omitting FastSim vs. FullSim comparison" % (fast.name(), fast.pileup())
768  continue
769 
770  # If we reach here, the harvestedFile must exist
771  harvestedFile = fast.filename(self._newRelease)
772  plotterInstance = self._plotter.readDirs(harvestedFile)
773  htmlReport.beginSample(fast, fastVsFull=True)
774  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
775  if not _processPlotsForSample(plotterFolder, fast):
776  continue
777  plotFiles = self._doPlotsFastFull(fast, correspondingFull, plotterFolder, dqmSubFolder, htmlReport)
778  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
779 
def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:747
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:399
def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:928
def validation.Validation._doPhase2PileupPlots (   self,
  limitSubFoldersOnlyTo,
  htmlReport 
)
private

Definition at line 780 of file validation.py.

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

780  def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport):
781  def _stripScenario(name):
782  puindex = name.find("PU")
783  if puindex < 0:
784  return name
785  return name[:puindex]
786 
787  pu140samples = {}
788  for sample in self._fullsimSamples:
789  if sample.pileupNumber() == 140:
790  key = (sample.name(), _stripScenario(sample.scenario()))
791  if key in pu140samples:
792  raise Exception("Duplicate entry for sample %s in scenario %s" % (sample.name(), sample.scenar()))
793  pu140samples[key] = sample
794 
795  for sample in self._fullsimSamples:
796  if sample.pileupNumber() != 200:
797  continue
798  key = (sample.name(), _stripScenario(sample.scenario()))
799  if not key in pu140samples:
800  continue
801 
802  sample_pu140 = pu140samples[key]
803 
804  # If we reach here, the harvestedFile must exist
805  harvestedFile = sample.filename(self._newRelease)
806  plotterInstance = self._plotter.readDirs(harvestedFile)
807  htmlReport.beginSample(sample, pileupComparison="vs. PU140")
808  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
809  if not _processPlotsForSample(plotterFolder, sample):
810  continue
811  plotFiles = self._doPlotsPileup(sample_pu140, sample, plotterFolder, dqmSubFolder, htmlReport)
812  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
813 
814 
def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:994
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:399
def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:780
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 857 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().

857  def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport):
858  """Do the real plotting work for a given sample and DQM subfolder"""
859  # Get GlobalTags
860  newGlobalTag = _getGlobalTag(sample, self._newRelease)
861 
862  # Construct selection string
863  selectionNameBase = "_"+sample.pileup()
864  newSelection = newGlobalTag+selectionNameBase+plotterFolder.getSelectionName(dqmSubFolder)
865  if sample.pileupEnabled():
866  newPu = sample.pileupType(self._newRelease)
867  if newPu != "":
868  newSelection += "_"+newPu
869 
870  valname = "val.{sample}.root".format(sample=sample.name())
871 
872  # Construct reference file and selection string
873  (refValFile, refSelection) = self._getRefFileAndSelection(sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
874 
875  # Construct new directory name
876  tmp = []
877  if sample.fastsim():
878  tmp.extend(["fastsim", self._newRelease])
879  tmp.extend([newSelection, sample.name()])
880  newsubdir = os.path.join(*tmp)
881  newdir = os.path.join(self._newBaseDir, newsubdir)
882  if not os.path.exists(newdir):
883  os.makedirs(newdir)
884  valnameFullPath = os.path.join(newdir, valname)
885 
886  # Copy the relevant histograms to a new validation root file
887  # TODO: treat the case where dqmSubFolder is empty
888  newValFile = _copySubDir(harvestedFile, valnameFullPath, plotterFolder.getPossibleDQMFolders(), dqmSubFolder.subfolder if dqmSubFolder is not None else None)
889  fileList = []
890 
891  # Do the plots
892  if plotting.verbose:
893  print "Comparing ref and new {sim} {sample} {translatedFolder}".format(
894  sim="FullSim" if not sample.fastsim() else "FastSim",
895  sample=sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
896  rootFiles = [refValFile, newValFile]
897  legendLabels = [
898  "%s, %s %s" % (sample.name(), _stripRelease(self._refRelease), refSelection) if self._refRelease is not None else "dummy",
899  "%s, %s %s" % (sample.name(), _stripRelease(self._newRelease), newSelection)
900  ]
901  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=sample.pileupEnabled())
902  fileList.extend(plotterFolder.draw(directory=newdir, **self._plotterDrawArgs))
903  # Copy val file only if there were plots
904  if len(fileList) > 0:
905  fileList.append(valnameFullPath)
906 
907  # For tables we just try them all, and see which ones succeed
908  for tableCreator in plotterFolder.getTableCreators():
909  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
910 
911  newValFile.Close()
912  if refValFile is not None:
913  refValFile.Close()
914 
915  if len(fileList) == 0:
916  return []
917 
918  dups = _findDuplicates(fileList)
919  if len(dups) > 0:
920  print "Plotter produced multiple files with names", ", ".join(dups)
921  print "Typically this is a naming problem in the plotter configuration"
922  sys.exit(1)
923 
924  # Move plots to new directory
925  print "Created plots and %s in %s" % (valname, newdir)
926  return map(lambda n: n.replace(newdir, newsubdir), fileList)
927 
def _getGlobalTag(sample, release)
Definition: validation.py:297
def _stripRelease(release)
Definition: validation.py:290
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:1111
def _copySubDir(oldfile, newfile, basenames, dirname)
Definition: validation.py:1062
def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
Definition: validation.py:815
def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:857
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 928 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().

928  def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport):
929  """Do the real plotting work for FastSim vs. FullSim for a given algorithm, quality flag, and sample."""
930  # Get GlobalTags
931  fastGlobalTag = _getGlobalTag(fastSample, self._newRelease)
932  fullGlobalTag = _getGlobalTag(fullSample, self._newRelease)
933 
934  # Construct selection string
935  tmp = plotterFolder.getSelectionName(dqmSubFolder)
936  fastSelection = fastGlobalTag+"_"+fastSample.pileup()+tmp
937  fullSelection = fullGlobalTag+"_"+fullSample.pileup()+tmp
938  if fullSample.pileupEnabled():
939  fullSelection += "_"+fullSample.pileupType(self._newRelease)
940  fastSelection += "_"+fastSample.pileupType(self._newRelease)
941 
942  # Construct directories for FastSim, FullSim, and for the results
943  fastdir = os.path.join(self._newBaseDir, "fastsim", self._newRelease, fastSelection, fastSample.name())
944  fulldir = os.path.join(self._newBaseDir, fullSelection, fullSample.name())
945  newsubdir = os.path.join("fastfull", self._newRelease, fastSelection, fastSample.name())
946  newdir = os.path.join(self._newBaseDir, newsubdir)
947  if not os.path.exists(newdir):
948  os.makedirs(newdir)
949 
950  # Open input root files
951  valname = "val.{sample}.root".format(sample=fastSample.name())
952  fastValFilePath = os.path.join(fastdir, valname)
953  if not os.path.exists(fastValFilePath) and plotting.verbose:
954  print "FastSim file %s not found" % fastValFilePath
955  fullValFilePath = os.path.join(fulldir, valname)
956  if not os.path.exists(fullValFilePath) and plotting.verbose:
957  print "FullSim file %s not found" % fullValFilePath
958 
959  fastValFile = ROOT.TFile.Open(fastValFilePath)
960  fullValFile = ROOT.TFile.Open(fullValFilePath)
961 
962  # Do plots
963  if plotting.verbose:
964  print "Comparing FullSim and FastSim {sample} {translatedFolder}".format(
965  sample=fastSample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
966  rootFiles = [fullValFile, fastValFile]
967  legendLabels = [
968  "FullSim %s, %s %s" % (fullSample.name(), _stripRelease(self._newRelease), fullSelection),
969  "FastSim %s, %s %s" % (fastSample.name(), _stripRelease(self._newRelease), fastSelection),
970  ]
971  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=fastSample.pileupEnabled(), requireAllHistograms=True)
972  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
973 
974  # For tables we just try them all, and see which ones succeed
975  for tableCreator in plotterFolder.getTableCreators():
976  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
977 
978  fullValFile.Close()
979  fastValFile.Close()
980 
981  if len(fileList) == 0:
982  return []
983 
984  dups = _findDuplicates(fileList)
985  if len(dups) > 0:
986  print "Plotter produced multiple files with names", ", ".join(dups)
987  print "Typically this is a naming problem in the plotter configuration"
988  sys.exit(1)
989 
990  # Move plots to new directory
991  print "Created plots in %s" % (newdir)
992  return map(lambda n: n.replace(newdir, newsubdir), fileList)
993 
def _getGlobalTag(sample, release)
Definition: validation.py:297
def _stripRelease(release)
Definition: validation.py:290
def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:928
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:1111
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 994 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().

994  def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport):
995  """Do the real plotting work for two pileup scenarios for a given algorithm, quality flag, and sample."""
996  # Get GlobalTags
997  pu140GlobalTag = _getGlobalTag(pu140Sample, self._newRelease)
998  pu200GlobalTag = _getGlobalTag(pu200Sample, self._newRelease)
999 
1000  # Construct selection string
1001  tmp = plotterFolder.getSelectionName(dqmSubFolder)
1002  pu140Selection = pu140GlobalTag+"_"+pu140Sample.pileup()+tmp+"_"+pu140Sample.pileupType(self._newRelease)
1003  pu200Selection = pu200GlobalTag+"_"+pu200Sample.pileup()+tmp+"_"+pu200Sample.pileupType(self._newRelease)
1004 
1005  # Construct directories for
1006  pu140dir = os.path.join(self._newBaseDir, pu140Selection, pu140Sample.name())
1007  pu200dir = os.path.join(self._newBaseDir, pu200Selection, pu200Sample.name())
1008  newsubdir = os.path.join("pileup", self._newRelease, pu200Selection, pu200Sample.name())
1009  newdir = os.path.join(self._newBaseDir, newsubdir)
1010  if not os.path.exists(newdir):
1011  os.makedirs(newdir)
1012 
1013  # Open input root files
1014  valname = "val.{sample}.root".format(sample=pu140Sample.name())
1015  pu140ValFilePath = os.path.join(pu140dir, valname)
1016  if not os.path.exists(pu140ValFilePath):
1017  if plotting.verbose:
1018  print "PU140 file %s not found" % pu140ValFilePath
1019  return []
1020  pu200ValFilePath = os.path.join(pu200dir, valname)
1021  if not os.path.exists(pu200ValFilePath):
1022  if plotting.verbose:
1023  print "PU200 file %s not found" % pu200ValFilePath
1024  return []
1025 
1026  pu140ValFile = ROOT.TFile.Open(pu140ValFilePath)
1027  pu200ValFile = ROOT.TFile.Open(pu200ValFilePath)
1028 
1029  # Do plots
1030  if plotting.verbose:
1031  print "Comparing PU140 and PU200 {sample} {translatedFolder}".format(
1032  sample=pu200Sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
1033  rootFiles = [pu140ValFile, pu200ValFile]
1034  legendLabels = [
1035  "%s, %s %s" % (pu140Sample.name(), _stripRelease(self._newRelease), pu140Selection),
1036  "%s, %s %s" % (pu200Sample.name(), _stripRelease(self._newRelease), pu200Selection),
1037  ]
1038  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=pu140Sample.pileupEnabled(), requireAllHistograms=True)
1039  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
1040 
1041  # For tables we just try them all, and see which ones succeed
1042  for tableCreator in plotterFolder.getTableCreators():
1043  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
1044 
1045  pu200ValFile.Close()
1046  pu140ValFile.Close()
1047 
1048  if len(fileList) == 0:
1049  return []
1050 
1051  dups = _findDuplicates(fileList)
1052  if len(dups) > 0:
1053  print "Plotter produced multiple files with names", ", ".join(dups)
1054  print "Typically this is a naming problem in the plotter configuration"
1055  sys.exit(1)
1056 
1057  # Move plots to new directory
1058  print "Created plots in %s" % (newdir)
1059  return map(lambda n: n.replace(newdir, newsubdir), fileList)
1060 
1061 
def _getGlobalTag(sample, release)
Definition: validation.py:297
def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:994
def _stripRelease(release)
Definition: validation.py:290
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _findDuplicates(lst)
Definition: validation.py:1111
def validation.Validation._getDirectoryName (   self,
  args,
  kwargs 
)
private

Definition at line 649 of file validation.py.

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

Definition at line 815 of file validation.py.

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

Referenced by validation.Validation._doPlots().

815  def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname):
816  if self._refRelease is None:
817  return (None, "")
818 
819  refGlobalTag = _getGlobalTag(sample, self._refRelease)
820  def _createRefSelection(selectionName):
821  sel = refGlobalTag+selectionNameBase+selectionName
822  if sample.pileupEnabled():
823  refPu = sample.pileupType(self._refRelease)
824  if refPu != "":
825  sel += "_"+refPu
826  return sel
827  refSelection = _createRefSelection(plotterFolder.getSelectionName(dqmSubFolder))
828 
829  # Construct reference directory name, and open reference file it it exists
830  refValFile = None
831  triedRefValFiles = []
832  tmp = [self._refRepository, self._refRelease]
833  if sample.fastsim():
834  tmp.extend(["fastsim", self._refRelease])
835  for selName in plotterFolder.getSelectionNameIterator(dqmSubFolder):
836  refSel = _createRefSelection(selName)
837  refdir = os.path.join(*(tmp+[refSel, sample.name()]))
838 
839  # Open reference file if it exists
840  refValFilePath = os.path.join(refdir, valname)
841  if os.path.exists(refValFilePath):
842  refSelection = refSel
843  refValFile = ROOT.TFile.Open(refValFilePath)
844  break
845  else:
846  triedRefValFiles.append(refValFilePath)
847  if refValFile is None:
848  if len(triedRefValFiles) == 1:
849  if plotting.verbose:
850  print "Reference file %s not found" % triedRefValFiles[0]
851  else:
852  if plotting.verbose:
853  print "None of the possible reference files %s not found" % ",".join(triedRefValFiles)
854 
855  return (refValFile, refSelection)
856 
def _getGlobalTag(sample, release)
Definition: validation.py:297
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
Definition: validation.py:815
def validation.Validation._getSelectionName (   self,
  args,
  kwargs 
)
private

Definition at line 652 of file validation.py.

References validation.Validation._selectionName.

652  def _getSelectionName(self, *args, **kwargs):
653  return self._selectionName
654 
def _getSelectionName(self, args, kwargs)
Definition: validation.py:652
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 707 of file validation.py.

707  def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False):
708  """Create validation plots.
709 
710  Arguments:
711  plotter -- plotting.Plotter object that does the plotting
712 
713  Keyword arguments:
714  plotterDrawArgs -- Dictionary for additional arguments to Plotter.draw() (default: {})
715  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.
716  htmlReport -- Object returned by createHtmlReport(), in case HTML report generation is desired
717  doFastVsFull -- Do FastSim vs. FullSim comparison? (default: True)
718  doPhase2PU -- Do Phase2 PU 200 vs. 140 comparison (default: False)
719  """
720  self._plotter = plotter
721  self._plotterDrawArgs = plotterDrawArgs
722 
723  # New vs. Ref
724  for sample in self._fullsimSamples+self._fastsimSamples:
725  # Check that the new DQM file exists
726  harvestedFile = sample.filename(self._newRelease)
727  if not os.path.exists(harvestedFile):
728  print "Harvested file %s does not exist!" % harvestedFile
729  sys.exit(1)
730 
731  plotterInstance = plotter.readDirs(harvestedFile)
732  htmlReport.beginSample(sample)
733  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
734  if not _processPlotsForSample(plotterFolder, sample):
735  continue
736  plotFiles = self._doPlots(sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
737  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
738 
739  # Fast vs. Full
740  if doFastVsFull:
741  self._doFastsimFastVsFullPlots(limitSubFoldersOnlyTo, htmlReport)
742 
743  # Phase2 PU200 vs. PU 140
744  if doPhase2PU:
745  self._doPhase2PileupPlots(limitSubFoldersOnlyTo, htmlReport)
746 
def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:747
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:399
def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport)
Definition: validation.py:780
def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False)
Definition: validation.py:707
def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
Definition: validation.py:857
def validation.Validation.download (   self)
Download DQM files. Requires grid certificate and asks your password for it.

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

655  def download(self):
656  """Download DQM files. Requires grid certificate and asks your password for it."""
657  filenames = [s.filename(self._newRelease) for s in self._fullsimSamples+self._fastsimSamples]
658  if self._newFileModifier is not None:
659  filenames = map(self._newFileModifier, filenames)
660  filenames = filter(lambda f: not os.path.exists(f), filenames)
661  if len(filenames) == 0:
662  print "All files already downloaded"
663  return
664 
665  relvalUrl = _getRelValUrl(self._newRelease)
666  urls = [relvalUrl+f for f in filenames]
667  certfile = os.path.join(os.environ["HOME"], ".globus", "usercert.pem")
668  if not os.path.exists(certfile):
669  print "Certificate file {certfile} does not exist, unable to download RelVal files from {url}".format(certfile=certfile, url=relvalUrl)
670  sys.exit(1)
671  keyfile = os.path.join(os.environ["HOME"], ".globus", "userkey.pem")
672  if not os.path.exists(certfile):
673  print "Private key file {keyfile} does not exist, unable to download RelVal files from {url}".format(keyfile=keyfile, url=relvalUrl)
674  sys.exit(1)
675 
676  # curl --cert-type PEM --cert $HOME/.globus/usercert.pem --key $HOME/.globus/userkye.pem -k -O <url> -O <url>
677  cmd = ["curl", "--cert-type", "PEM", "--cert", certfile, "--key", keyfile, "-k"]
678  for u in urls:
679  cmd.extend(["-O", u])
680  print "Downloading %d files from RelVal URL %s:" % (len(filenames), relvalUrl)
681  print " "+"\n ".join(filenames)
682  print "Please provide your private key pass phrase when curl asks it"
683  ret = subprocess.call(cmd)
684  if ret != 0:
685  print "Downloading failed with exit code %d" % ret
686  sys.exit(1)
687 
688  # verify
689  allFine = True
690  for f in filenames:
691  p = subprocess.Popen(["file", f], stdout=subprocess.PIPE)
692  stdout = p.communicate()[0]
693  if p.returncode != 0:
694  print "file command failed with exit code %d" % p.returncode
695  sys.exit(1)
696  if not "ROOT" in stdout:
697  print "File {f} is not ROOT, please check the correct version, GlobalTag etc. from {url}".format(f=f, url=relvalUrl)
698  allFine = False
699  if os.path.exists(f):
700  os.remove(f)
701  if not allFine:
702  sys.exit(1)
703 
def _getRelValUrl(release)
Definition: validation.py:387
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 646 of file validation.py.

Referenced by validation.Validation.download().

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

Definition at line 720 of file validation.py.

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

Definition at line 643 of file validation.py.

Referenced by validation.Validation._getRefFileAndSelection().

validation.Validation._selectionName
private

Definition at line 647 of file validation.py.

Referenced by validation.Validation._getSelectionName().