test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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__
 
def createHtmlReport
 
def doPlots
 
def download
 

Private Member Functions

def _doFastsimFastVsFullPlots
 
def _doPhase2PileupPlots
 
def _doPlots
 
def _doPlotsFastFull
 
def _doPlotsPileup
 
def _getDirectoryName
 
def _getRefFileAndSelection
 
def _getSelectionName
 

Private Attributes

 _fastsimSamples
 
 _fullsimSamples
 
 _newBaseDir
 
 _newFileModifier
 
 _newRelease
 
 _plotter
 
 _plotterDrawArgs
 
 _refRelease
 
 _refRepository
 
 _selectionName
 

Detailed Description

Base class for Tracking/Vertex validation.

Definition at line 475 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 477 of file validation.py.

Referenced by vertexPlots.VertexValidation._init__().

478  def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName=""):
479  """Constructor.
480 
481  Arguments:
482  fullsimSamples -- List of Sample objects for FullSim samples (may be empty)
483  fastsimSamples -- List of Sample objects for FastSim samples (may be empty)
484  refRelease -- String for reference CMSSW release (can be None for no reference release)
485  newRepository -- String for directory whete to put new files
486  newRelease -- CMSSW release to be validated
487  refRepository -- String for directory where reference root files are
488  newFileModifier -- If given, a function to modify the names of the new files (function takes a string and returns a string)
489  selectionName -- If given, use this string as the selection name (appended to GlobalTag for directory names)
490  """
491  try:
492  self._newRelease = os.environ["CMSSW_VERSION"]
493  except KeyError:
494  print >>sys.stderr, 'Error: CMSSW environment variables are not available.'
495  print >>sys.stderr, ' Please run cmsenv'
496  sys.exit()
498  self._fullsimSamples = fullsimSamples
499  self._fastsimSamples = fastsimSamples
500  self._refRelease = refRelease
501  self._refRepository = refRepository
502  self._newRelease = newRelease
503  self._newBaseDir = os.path.join(newRepository, self._newRelease)
504  self._newFileModifier = newFileModifier
505  self._selectionName = selectionName

Member Function Documentation

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

Definition at line 604 of file validation.py.

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

605  def _doFastsimFastVsFullPlots(self, limitSubFoldersOnlyTo, htmlReport):
606  for fast in self._fastsimSamples:
607  correspondingFull = None
608  for full in self._fullsimSamples:
609  if fast.name() != full.name():
610  continue
611  if fast.pileupEnabled():
612  if not full.pileupEnabled():
613  continue
614  if fast.fastsimCorrespondingFullsimPileup() != full.pileupType():
615  continue
616  else:
617  if full.pileupEnabled():
618  continue
619 
620  if correspondingFull is None:
621  correspondingFull = full
622  else:
623  raise Exception("Got multiple compatible FullSim samples for FastSim sample %s %s" % (fast.name(), fast.pileup()))
624  if correspondingFull is None:
625  print "WARNING: Did not find compatible FullSim sample for FastSim sample %s %s, omitting FastSim vs. FullSim comparison" % (fast.name(), fast.pileup())
626  continue
627 
628  # If we reach here, the harvestedFile must exist
629  harvestedFile = fast.filename(self._newRelease)
630  plotterInstance = self._plotter.readDirs(harvestedFile)
631  htmlReport.beginSample(fast, fastVsFull=True)
632  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
633  if not _processPlotsForSample(plotterFolder, fast):
634  continue
635  plotFiles = self._doPlotsFastFull(fast, correspondingFull, plotterFolder, dqmSubFolder, htmlReport)
636  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
def _processPlotsForSample
Definition: validation.py:266
def validation.Validation._doPhase2PileupPlots (   self,
  limitSubFoldersOnlyTo,
  htmlReport 
)
private

Definition at line 637 of file validation.py.

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

638  def _doPhase2PileupPlots(self, limitSubFoldersOnlyTo, htmlReport):
639  def _stripScenario(name):
640  puindex = name.find("PU")
641  if puindex < 0:
642  return name
643  return name[:puindex]
644 
645  pu140samples = {}
646  for sample in self._fullsimSamples:
647  if sample.pileupNumber() == 140:
648  key = (sample.name(), _stripScenario(sample.scenario()))
649  if key in pu140samples:
650  raise Exception("Duplicate entry for sample %s in scenario %s" % (sample.name(), sample.scenar()))
651  pu140samples[key] = sample
652 
653  for sample in self._fullsimSamples:
654  if sample.pileupNumber() != 200:
655  continue
656  key = (sample.name(), _stripScenario(sample.scenario()))
657  if not key in pu140samples:
658  continue
659 
660  sample_pu140 = pu140samples[key]
661 
662  # If we reach here, the harvestedFile must exist
663  harvestedFile = sample.filename(self._newRelease)
664  plotterInstance = self._plotter.readDirs(harvestedFile)
665  htmlReport.beginSample(sample, pileupComparison="vs. PU140")
666  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
667  if not _processPlotsForSample(plotterFolder, sample):
668  continue
669  plotFiles = self._doPlotsPileup(sample_pu140, sample, plotterFolder, dqmSubFolder, htmlReport)
670  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
671 
def _processPlotsForSample
Definition: validation.py:266
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 714 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(), and join().

Referenced by validation.SimpleValidation._doPlotsForPlotter().

715  def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport):
716  """Do the real plotting work for a given sample and DQM subfolder"""
717  # Get GlobalTags
718  newGlobalTag = _getGlobalTag(sample, self._newRelease)
719 
720  # Construct selection string
721  selectionNameBase = "_"+sample.pileup()
722  newSelection = newGlobalTag+selectionNameBase+plotterFolder.getSelectionName(dqmSubFolder)
723  if sample.pileupEnabled():
724  newPu = sample.pileupType(self._newRelease)
725  if newPu != "":
726  newSelection += "_"+newPu
727 
728  valname = "val.{sample}.root".format(sample=sample.name())
729 
730  # Construct reference file and selection string
731  (refValFile, refSelection) = self._getRefFileAndSelection(sample, plotterFolder, dqmSubFolder, selectionNameBase, valname)
732 
733  # Construct new directory name
734  tmp = []
735  if sample.fastsim():
736  tmp.extend(["fastsim", self._newRelease])
737  tmp.extend([newSelection, sample.name()])
738  newsubdir = os.path.join(*tmp)
739  newdir = os.path.join(self._newBaseDir, newsubdir)
740 
741  # Copy the relevant histograms to a new validation root file
742  # TODO: treat the case where dqmSubFolder is empty
743  newValFile = _copySubDir(harvestedFile, valname, plotterFolder.getPossibleDQMFolders(), dqmSubFolder.subfolder if dqmSubFolder is not None else None)
744  fileList = []
745 
746  # Do the plots
747  if plotting.verbose:
748  print "Comparing ref and new {sim} {sample} {translatedFolder}".format(
749  sim="FullSim" if not sample.fastsim() else "FastSim",
750  sample=sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
751  rootFiles = [refValFile, newValFile]
752  legendLabels = [
753  "%s, %s %s" % (sample.name(), _stripRelease(self._refRelease), refSelection) if self._refRelease is not None else "dummy",
754  "%s, %s %s" % (sample.name(), _stripRelease(self._newRelease), newSelection)
755  ]
756  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=sample.pileupEnabled())
757  fileList.extend(plotterFolder.draw(**self._plotterDrawArgs))
758  # Copy val file only if there were plots
759  if len(fileList) > 0:
760  fileList.append(valname)
761 
762  # For tables we just try them all, and see which ones succeed
763  for tableCreator in plotterFolder.getTableCreators():
764  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
765 
766  newValFile.Close()
767  if refValFile is not None:
768  refValFile.Close()
769 
770  if len(fileList) == 0:
771  return []
772 
773  dups = _findDuplicates(fileList)
774  if len(dups) > 0:
775  print "Plotter produced multiple files with names", ", ".join(dups)
776  print "Typically this is a naming problem in the plotter configuration"
777  sys.exit(1)
778 
779  # Move plots to new directory
780  print "Moving plots and %s to %s" % (valname, newdir)
781  if not os.path.exists(newdir):
782  os.makedirs(newdir)
783  for f in fileList:
784  shutil.move(f, os.path.join(newdir, f))
785  return map(lambda n: os.path.join(newsubdir, n), fileList)
def _copySubDir
Definition: validation.py:924
def _getGlobalTag
Definition: validation.py:197
def _stripRelease
Definition: validation.py:190
def _findDuplicates
Definition: validation.py:973
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
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 786 of file validation.py.

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

Referenced by validation.Validation._doFastsimFastVsFullPlots().

787  def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, htmlReport):
788  """Do the real plotting work for FastSim vs. FullSim for a given algorithm, quality flag, and sample."""
789  # Get GlobalTags
790  fastGlobalTag = _getGlobalTag(fastSample, self._newRelease)
791  fullGlobalTag = _getGlobalTag(fullSample, self._newRelease)
792 
793  # Construct selection string
794  tmp = plotterFolder.getSelectionName(dqmSubFolder)
795  fastSelection = fastGlobalTag+"_"+fastSample.pileup()+tmp
796  fullSelection = fullGlobalTag+"_"+fullSample.pileup()+tmp
797  if fullSample.pileupEnabled():
798  fullSelection += "_"+fullSample.pileupType(self._newRelease)
799  fastSelection += "_"+fastSample.pileupType(self._newRelease)
800 
801  # Construct directories for FastSim, FullSim, and for the results
802  fastdir = os.path.join(self._newBaseDir, "fastsim", self._newRelease, fastSelection, fastSample.name())
803  fulldir = os.path.join(self._newBaseDir, fullSelection, fullSample.name())
804  newsubdir = os.path.join("fastfull", self._newRelease, fastSelection, fastSample.name())
805  newdir = os.path.join(self._newBaseDir, newsubdir)
806 
807  # Open input root files
808  valname = "val.{sample}.root".format(sample=fastSample.name())
809  fastValFilePath = os.path.join(fastdir, valname)
810  if not os.path.exists(fastValFilePath) and plotting.verbose:
811  print "FastSim file %s not found" % fastValFilePath
812  fullValFilePath = os.path.join(fulldir, valname)
813  if not os.path.exists(fullValFilePath) and plotting.verbose:
814  print "FullSim file %s not found" % fullValFilePath
815 
816  fastValFile = ROOT.TFile.Open(fastValFilePath)
817  fullValFile = ROOT.TFile.Open(fullValFilePath)
818 
819  # Do plots
820  if plotting.verbose:
821  print "Comparing FullSim and FastSim {sample} {translatedFolder}".format(
822  sample=fastSample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
823  rootFiles = [fullValFile, fastValFile]
824  legendLabels = [
825  "FullSim %s, %s %s" % (fullSample.name(), _stripRelease(self._newRelease), fullSelection),
826  "FastSim %s, %s %s" % (fastSample.name(), _stripRelease(self._newRelease), fastSelection),
827  ]
828  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=fastSample.pileupEnabled(), requireAllHistograms=True)
829  fileList = plotterFolder.draw(**self._plotterDrawArgs)
830 
831  # For tables we just try them all, and see which ones succeed
832  for tableCreator in plotterFolder.getTableCreators():
833  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
834 
835  fullValFile.Close()
836  fastValFile.Close()
837 
838  if len(fileList) == 0:
839  return []
840 
841  dups = _findDuplicates(fileList)
842  if len(dups) > 0:
843  print "Plotter produced multiple files with names", ", ".join(dups)
844  print "Typically this is a naming problem in the plotter configuration"
845  sys.exit(1)
846 
847  # Move plots to new directory
848  print "Moving plots to %s" % (newdir)
849  if not os.path.exists(newdir):
850  os.makedirs(newdir)
851  for f in fileList:
852  shutil.move(f, os.path.join(newdir, f))
853  return map(lambda n: os.path.join(newsubdir, n), fileList)
def _getGlobalTag
Definition: validation.py:197
def _stripRelease
Definition: validation.py:190
def _findDuplicates
Definition: validation.py:973
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
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 854 of file validation.py.

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

Referenced by validation.Validation._doPhase2PileupPlots().

855  def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, htmlReport):
856  """Do the real plotting work for two pileup scenarios for a given algorithm, quality flag, and sample."""
857  # Get GlobalTags
858  pu140GlobalTag = _getGlobalTag(pu140Sample, self._newRelease)
859  pu200GlobalTag = _getGlobalTag(pu200Sample, self._newRelease)
860 
861  # Construct selection string
862  tmp = plotterFolder.getSelectionName(dqmSubFolder)
863  pu140Selection = pu140GlobalTag+"_"+pu140Sample.pileup()+tmp+"_"+pu140Sample.pileupType(self._newRelease)
864  pu200Selection = pu200GlobalTag+"_"+pu200Sample.pileup()+tmp+"_"+pu200Sample.pileupType(self._newRelease)
865 
866  # Construct directories for
867  pu140dir = os.path.join(self._newBaseDir, pu140Selection, pu140Sample.name())
868  pu200dir = os.path.join(self._newBaseDir, pu200Selection, pu200Sample.name())
869  newsubdir = os.path.join("pileup", self._newRelease, pu200Selection, pu200Sample.name())
870  newdir = os.path.join(self._newBaseDir, newsubdir)
871 
872  # Open input root files
873  valname = "val.{sample}.root".format(sample=pu140Sample.name())
874  pu140ValFilePath = os.path.join(pu140dir, valname)
875  if not os.path.exists(pu140ValFilePath):
876  if plotting.verbose:
877  print "PU140 file %s not found" % pu140ValFilePath
878  return []
879  pu200ValFilePath = os.path.join(pu200dir, valname)
880  if not os.path.exists(pu200ValFilePath):
881  if plotting.verbose:
882  print "PU200 file %s not found" % pu200ValFilePath
883  return []
884 
885  pu140ValFile = ROOT.TFile.Open(pu140ValFilePath)
886  pu200ValFile = ROOT.TFile.Open(pu200ValFilePath)
887 
888  # Do plots
889  if plotting.verbose:
890  print "Comparing PU140 and PU200 {sample} {translatedFolder}".format(
891  sample=pu200Sample.name(), translatedFolder=str(dqmSubFolder.translated) if dqmSubFolder is not None else "")
892  rootFiles = [pu140ValFile, pu200ValFile]
893  legendLabels = [
894  "%s, %s %s" % (pu140Sample.name(), _stripRelease(self._newRelease), pu140Selection),
895  "%s, %s %s" % (pu200Sample.name(), _stripRelease(self._newRelease), pu200Selection),
896  ]
897  plotterFolder.create(rootFiles, legendLabels, dqmSubFolder, isPileupSample=pu140Sample.pileupEnabled(), requireAllHistograms=True)
898  fileList = plotterFolder.draw(**self._plotterDrawArgs)
899 
900  # For tables we just try them all, and see which ones succeed
901  for tableCreator in plotterFolder.getTableCreators():
902  htmlReport.addTable(tableCreator.create(rootFiles, legendLabels, dqmSubFolder))
903 
904  pu200ValFile.Close()
905  pu140ValFile.Close()
906 
907  if len(fileList) == 0:
908  return []
909 
910  dups = _findDuplicates(fileList)
911  if len(dups) > 0:
912  print "Plotter produced multiple files with names", ", ".join(dups)
913  print "Typically this is a naming problem in the plotter configuration"
914  sys.exit(1)
915 
916  # Move plots to new directory
917  print "Moving plots to %s" % (newdir)
918  if not os.path.exists(newdir):
919  os.makedirs(newdir)
920  for f in fileList:
921  shutil.move(f, os.path.join(newdir, f))
922  return map(lambda n: os.path.join(newsubdir, n), fileList)
923 
def _getGlobalTag
Definition: validation.py:197
def _stripRelease
Definition: validation.py:190
def _findDuplicates
Definition: validation.py:973
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def validation.Validation._getDirectoryName (   self,
  args,
  kwargs 
)
private

Definition at line 506 of file validation.py.

507  def _getDirectoryName(self, *args, **kwargs):
508  return None
def validation.Validation._getRefFileAndSelection (   self,
  sample,
  plotterFolder,
  dqmSubFolder,
  selectionNameBase,
  valname 
)
private

Definition at line 672 of file validation.py.

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

Referenced by validation.Validation._doPlots().

673  def _getRefFileAndSelection(self, sample, plotterFolder, dqmSubFolder, selectionNameBase, valname):
674  if self._refRelease is None:
675  return (None, "")
676 
677  refGlobalTag = _getGlobalTag(sample, self._refRelease)
678  def _createRefSelection(selectionName):
679  sel = refGlobalTag+selectionNameBase+selectionName
680  if sample.pileupEnabled():
681  refPu = sample.pileupType(self._refRelease)
682  if refPu != "":
683  sel += "_"+refPu
684  return sel
685  refSelection = _createRefSelection(plotterFolder.getSelectionName(dqmSubFolder))
686 
687  # Construct reference directory name, and open reference file it it exists
688  refValFile = None
689  triedRefValFiles = []
690  tmp = [self._refRepository, self._refRelease]
691  if sample.fastsim():
692  tmp.extend(["fastsim", self._refRelease])
693  for selName in plotterFolder.getSelectionNameIterator(dqmSubFolder):
694  refSel = _createRefSelection(selName)
695  refdir = os.path.join(*(tmp+[refSel, sample.name()]))
696 
697  # Open reference file if it exists
698  refValFilePath = os.path.join(refdir, valname)
699  if os.path.exists(refValFilePath):
700  refSelection = refSel
701  refValFile = ROOT.TFile.Open(refValFilePath)
702  break
703  else:
704  triedRefValFiles.append(refValFilePath)
705  if refValFile is None:
706  if len(triedRefValFiles) == 1:
707  if plotting.verbose:
708  print "Reference file %s not found" % triedRefValFiles[0]
709  else:
710  if plotting.verbose:
711  print "None of the possible reference files %s not found" % ",".join(triedRefValFiles)
712 
713  return (refValFile, refSelection)
def _getGlobalTag
Definition: validation.py:197
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def validation.Validation._getSelectionName (   self,
  args,
  kwargs 
)
private

Definition at line 509 of file validation.py.

References validation.Validation._selectionName.

510  def _getSelectionName(self, *args, **kwargs):
511  return self._selectionName
def validation.Validation.createHtmlReport (   self)

Definition at line 561 of file validation.py.

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

562  def createHtmlReport(self):
563  return html.HtmlReport(self._newRelease, self._newBaseDir)
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 564 of file validation.py.

565  def doPlots(self, plotter, plotterDrawArgs={}, limitSubFoldersOnlyTo=None, htmlReport=html.HtmlReportDummy(), doFastVsFull=True, doPhase2PU=False):
566  """Create validation plots.
567 
568  Arguments:
569  plotter -- plotting.Plotter object that does the plotting
570 
571  Keyword arguments:
572  plotterDrawArgs -- Dictionary for additional arguments to Plotter.draw() (default: {})
573  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.
574  htmlReport -- Object returned by createHtmlReport(), in case HTML report generation is desired
575  doFastVsFull -- Do FastSim vs. FullSim comparison? (default: True)
576  doPhase2PU -- Do Phase2 PU 200 vs. 140 comparison (default: False)
577  """
578  self._plotter = plotter
579  self._plotterDrawArgs = plotterDrawArgs
580 
581  # New vs. Ref
582  for sample in self._fullsimSamples+self._fastsimSamples:
583  # Check that the new DQM file exists
584  harvestedFile = sample.filename(self._newRelease)
585  if not os.path.exists(harvestedFile):
586  print "Harvested file %s does not exist!" % harvestedFile
587  sys.exit(1)
588 
589  plotterInstance = plotter.readDirs(harvestedFile)
590  htmlReport.beginSample(sample)
591  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
592  if not _processPlotsForSample(plotterFolder, sample):
593  continue
594  plotFiles = self._doPlots(sample, harvestedFile, plotterFolder, dqmSubFolder, htmlReport)
595  htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
596 
597  # Fast vs. Full
598  if doFastVsFull:
599  self._doFastsimFastVsFullPlots(limitSubFoldersOnlyTo, htmlReport)
600 
601  # Phase2 PU200 vs. PU 140
602  if doPhase2PU:
603  self._doPhase2PileupPlots(limitSubFoldersOnlyTo, htmlReport)
def _processPlotsForSample
Definition: validation.py:266
def validation.Validation.download (   self)
Download DQM files. Requires grid certificate and asks your password for it.

Definition at line 512 of file validation.py.

References validation.Validation._fastsimSamples, validation.Validation._fullsimSamples, validation._getRelValUrl(), validation.Validation._newFileModifier, validation.Validation._newRelease, alcazmumu_cfi.filter, and join().

513  def download(self):
514  """Download DQM files. Requires grid certificate and asks your password for it."""
515  filenames = [s.filename(self._newRelease) for s in self._fullsimSamples+self._fastsimSamples]
516  if self._newFileModifier is not None:
517  filenames = map(self._newFileModifier, filenames)
518  filenames = filter(lambda f: not os.path.exists(f), filenames)
519  if len(filenames) == 0:
520  print "All files already downloaded"
521  return
522 
523  relvalUrl = _getRelValUrl(self._newRelease)
524  urls = [relvalUrl+f for f in filenames]
525  certfile = os.path.join(os.environ["HOME"], ".globus", "usercert.pem")
526  if not os.path.exists(certfile):
527  print "Certificate file {certfile} does not exist, unable to download RelVal files from {url}".format(certfile=certfile, url=relvalUrl)
528  sys.exit(1)
529  keyfile = os.path.join(os.environ["HOME"], ".globus", "userkey.pem")
530  if not os.path.exists(certfile):
531  print "Private key file {keyfile} does not exist, unable to download RelVal files from {url}".format(keyfile=keyfile, url=relvalUrl)
532  sys.exit(1)
533 
534  # curl --cert-type PEM --cert $HOME/.globus/usercert.pem --key $HOME/.globus/userkye.pem -k -O <url> -O <url>
535  cmd = ["curl", "--cert-type", "PEM", "--cert", certfile, "--key", keyfile, "-k"]
536  for u in urls:
537  cmd.extend(["-O", u])
538  print "Downloading %d files from RelVal URL %s:" % (len(filenames), relvalUrl)
539  print " "+"\n ".join(filenames)
540  print "Please provide your private key pass phrase when curl asks it"
541  ret = subprocess.call(cmd)
542  if ret != 0:
543  print "Downloading failed with exit code %d" % ret
544  sys.exit(1)
545 
546  # verify
547  allFine = True
548  for f in filenames:
549  p = subprocess.Popen(["file", f], stdout=subprocess.PIPE)
550  stdout = p.communicate()[0]
551  if p.returncode != 0:
552  print "file command failed with exit code %d" % p.returncode
553  sys.exit(1)
554  if not "ROOT" in stdout:
555  print "File {f} is not ROOT, please check the correct version, GlobalTag etc. from {url}".format(f=f, url=relvalUrl)
556  allFine = False
557  if os.path.exists(f):
558  os.remove(f)
559  if not allFine:
560  sys.exit(1)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _getRelValUrl
Definition: validation.py:254

Member Data Documentation

validation.Validation._fastsimSamples
private

Definition at line 498 of file validation.py.

Referenced by validation.Validation._doFastsimFastVsFullPlots(), and validation.Validation.download().

validation.Validation._fullsimSamples
private

Definition at line 497 of file validation.py.

Referenced by validation.Validation._doFastsimFastVsFullPlots(), validation.Validation._doPhase2PileupPlots(), and validation.Validation.download().

validation.Validation._newBaseDir
private

Definition at line 502 of file validation.py.

Referenced by validation.Validation._doPlots(), validation.Validation._doPlotsFastFull(), validation.Validation._doPlotsPileup(), and validation.Validation.createHtmlReport().

validation.Validation._newFileModifier
private

Definition at line 503 of file validation.py.

Referenced by validation.Validation.download().

validation.Validation._newRelease
private

Definition at line 491 of file validation.py.

Referenced by validation.Validation._doFastsimFastVsFullPlots(), validation.Validation._doPhase2PileupPlots(), validation.Validation._doPlots(), validation.Validation._doPlotsFastFull(), validation.Validation._doPlotsPileup(), validation.Validation.createHtmlReport(), and validation.Validation.download().

validation.Validation._plotter
private

Definition at line 577 of file validation.py.

validation.Validation._plotterDrawArgs
private

Definition at line 578 of file validation.py.

Referenced by validation.Validation._doPlots(), validation.SimpleValidation._doPlots(), validation.Validation._doPlotsFastFull(), and validation.Validation._doPlotsPileup().

validation.Validation._refRelease
private

Definition at line 499 of file validation.py.

Referenced by validation.Validation._doPlots(), and validation.Validation._getRefFileAndSelection().

validation.Validation._refRepository
private

Definition at line 500 of file validation.py.

Referenced by validation.Validation._getRefFileAndSelection().

validation.Validation._selectionName
private

Definition at line 504 of file validation.py.

Referenced by validation.Validation._getSelectionName().