CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
validation Namespace Reference

Classes

class  Sample
 
class  SeparateValidation
 
class  SimpleSample
 
class  SimpleValidation
 
class  Validation
 

Functions

def _copyDir
 
def _copySubDir
 
def _doPlotsForPlotter
 
def _findDuplicates
 
def _getGlobalTag
 
def _getRelValUrl
 
def _processPlotsForSample
 
def _stripRelease
 

Variables

list _doBHadronSamples
 
list _doConversionSamples
 
list _doElectronSamples
 
dictionary _globalTags
 
list _releasePostfixes
 
dictionary _relvalUrls
 

Function Documentation

def validation._copyDir (   src,
  dst 
)
private
Copy non-TTree objects from src TDirectory to dst TDirectory.

Definition at line 1165 of file validation.py.

Referenced by _copySubDir().

1166 def _copyDir(src, dst):
1167  """Copy non-TTree objects from src TDirectory to dst TDirectory."""
1168  keys = src.GetListOfKeys()
1169  for key in keys:
1170  classname = key.GetClassName()
1171  cl = ROOT.TClass.GetClass(classname)
1172  if not cl:
1173  continue
1174  if not (cl.InheritsFrom("TTree") and cl.InheritsFrom("TDirectory")):
1175  dst.cd()
1176  obj = key.ReadObj()
1177  obj.Write()
1178  obj.Delete()
def validation._copySubDir (   oldfile,
  newfile,
  basenames,
  dirname 
)
private
Copy a subdirectory from oldfile to newfile.

Arguments:
oldfile   -- String for source TFile
newfile   -- String for destination TFile
basenames -- List of strings for base directories, first existing one is picked
dirname   -- String for directory name under the base directory

Definition at line 1130 of file validation.py.

References _copyDir(), join(), and submitPVValidationJobs.split().

Referenced by validation.Validation._doPlots().

1131 def _copySubDir(oldfile, newfile, basenames, dirname):
1132  """Copy a subdirectory from oldfile to newfile.
1133 
1134  Arguments:
1135  oldfile -- String for source TFile
1136  newfile -- String for destination TFile
1137  basenames -- List of strings for base directories, first existing one is picked
1138  dirname -- String for directory name under the base directory
1139  """
1140  oldf = ROOT.TFile.Open(oldfile)
1141 
1142  dirold = None
1143  for basename in basenames:
1144  dirold = oldf.GetDirectory(basename)
1145  if dirold:
1146  break
1147  if not dirold:
1148  raise Exception("Did not find any of %s directories from file %s" % (",".join(basenames), oldfile))
1149  if dirname:
1150  d = dirold.Get(dirname)
1151  if not d:
1152  raise Exception("Did not find directory %s under %s" % (dirname, dirold.GetPath()))
1153  dirold = d
1154 
1155  newf = ROOT.TFile.Open(newfile, "RECREATE")
1156  dirnew = newf
1157  for d in basenames[0].split("/"):
1158  dirnew = dirnew.mkdir(d)
1159  if dirname:
1160  dirnew = dirnew.mkdir(dirname)
1161  _copyDir(dirold, dirnew)
1162 
1163  oldf.Close()
1164  return newf
def _copySubDir
Definition: validation.py:1130
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def validation._doPlotsForPlotter (   self,
  plotter,
  sample,
  limitSubFoldersOnlyTo = None 
)
private

Definition at line 1189 of file validation.py.

References _processPlotsForSample(), join(), and sistrip::SpyUtilities.range().

1190 def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None):
1191  plotterInstance = plotter.readDirs(*self._openFiles)
1192  manager = multiprocessing.Manager()
1193  return_dict = manager.dict()
1194  proc = []
1195  iProc = 0
1196 
1197  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
1198  if sample is not None and not _processPlotsForSample(plotterFolder, sample):
1199  continue
1200  newsubdir = self._subdirprefix+plotterFolder.getSelectionName(dqmSubFolder)
1201  newdir = os.path.join(self._newdir, newsubdir)
1202  if not os.path.exists(newdir):
1203  os.makedirs(newdir, exist_ok=True)
1204 
1205  plotterFolder.create(self._openFiles, self._labels, dqmSubFolder)
1206  p = multiprocessing.Process(target=self._doPlots, args=(plotterFolder, dqmSubFolder, newsubdir, newdir, iProc, return_dict))
1207  proc.append((plotterFolder, dqmSubFolder, p))
1208  p.start()
1209  iProc += 1
1210 
1211  for i in range(iProc):
1212  proc[i][2].join()
1213  if len(return_dict[i]) > 0:
1214  self._htmlReport.addPlots(proc[i][0], proc[i][1], return_dict[i])
const uint16_t range(const Frame &aFrame)
def _processPlotsForSample
Definition: validation.py:464
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def _doPlotsForPlotter
Definition: validation.py:1189
def validation._findDuplicates (   lst)
private

Definition at line 1179 of file validation.py.

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

1180 def _findDuplicates(lst):
1181  found = set()
1182  found2 = set()
1183  for x in lst:
1184  if x in found:
1185  found2.add(x)
1186  else:
1187  found.add(x)
1188  return list(found2)
def _findDuplicates
Definition: validation.py:1179
def validation._getGlobalTag (   sample,
  release 
)
private
Get a GlobalTag.

Arguments:
sample  -- Sample object
release -- CMSSW release string

Definition at line 360 of file validation.py.

References print().

Referenced by validation.Validation._doPlots(), validation.Validation._doPlotsFastFull(), validation.Validation._doPlotsPileup(), validation.Validation._getRefFileAndSelection(), validation.Sample.datasetpattern(), and validation.Sample.filename().

361 def _getGlobalTag(sample, release):
362  """Get a GlobalTag.
363 
364  Arguments:
365  sample -- Sample object
366  release -- CMSSW release string
367  """
368  if not release in _globalTags:
369  print("Release %s not found from globaltag map in validation.py" % release)
370  sys.exit(1)
371  gtmap = _globalTags[release]
372  selectedGT = None
373  if sample.hasOverrideGlobalTag():
374  ogt = sample.overrideGlobalTag()
375  if release in ogt:
376  gtmap = _globalTags[ogt[release]]
377  scenario = ""
378  if sample.hasScenario():
379  scenario = sample.scenario()
380  sims = []
381  if sample.fullsim():
382  if sample.pileupEnabled():
383  sim = "fullsim_"+sample.pileupType()
384  sims.extend([
385  sim+"_PU%d"%sample.pileupNumber(),
386  sim
387  ])
388  elif sample.fastsim():
389  sim = "fastsim"
390  if sample.pileupEnabled():
391  sim += "_"+sample.pileupType()
392  sims.append(sim+"_PU%d"%sample.pileupNumber())
393  sims.append(sim)
394 
395  selectedGT = None
396  # First try with scenario+simulation
397  if scenario != "":
398  for sim in sims:
399  selectedGT = gtmap.get(scenario+"_"+sim, None)
400  if selectedGT is not None:
401  break
402  # Then with scenario (but only if sample specifies a scenario)
403  if selectedGT is None:
404  selectedGT = gtmap.get(scenario, None)
405  # Then with simulation
406  if selectedGT is None:
407  for sim in sims:
408  selectedGT = gtmap.get(sim, None)
409  if selectedGT is not None:
410  break
411  # Finally default
412  if selectedGT is None:
413  selectedGT = gtmap["default"]
414 
415  if isinstance(selectedGT, dict):
416  return selectedGT.get(sample.name(), selectedGT["default"])
417  else:
418  return selectedGT
419 
# Mapping from release series to RelVal download URLs
def _getGlobalTag
Definition: validation.py:360
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def validation._getRelValUrl (   release)
private
Get RelVal download URL for a given release.

Definition at line 452 of file validation.py.

References print().

Referenced by validation.Validation.download().

453 def _getRelValUrl(release):
454  """Get RelVal download URL for a given release."""
455  version_re = re.compile("CMSSW_(?P<X>\d+)_(?P<Y>\d+)")
456  m = version_re.search(release)
457  if not m:
458  raise Exception("Regex %s does not match to release version %s" % (version_re.pattern, release))
459  version = "%s_%s_X" % (m.group("X"), m.group("Y"))
460  if not version in _relvalUrls:
461  print("No RelVal URL for version %s, please update _relvalUrls" % version)
462  sys.exit(1)
463  return _relvalUrls[version]
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def _getRelValUrl
Definition: validation.py:452
def validation._processPlotsForSample (   plotterFolder,
  sample 
)
private

Definition at line 464 of file validation.py.

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

465 def _processPlotsForSample(plotterFolder, sample):
466  if plotterFolder.onlyForPileup() and not sample.pileupEnabled():
467  return False
468  if plotterFolder.onlyForElectron() and not sample.doElectron():
469  return False
470  if plotterFolder.onlyForConversion() and not sample.doConversion():
471  return False
472  if plotterFolder.onlyForBHadron() and not sample.doBHadron():
473  return False
474  return True
def _processPlotsForSample
Definition: validation.py:464
def validation._stripRelease (   release)
private

Definition at line 353 of file validation.py.

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

354 def _stripRelease(release):
355  for pf in _releasePostfixes:
356  if pf in release:
357  return _stripRelease(release.replace(pf, ""))
358  return release
359 
def _stripRelease
Definition: validation.py:353

Variable Documentation

list validation._doBHadronSamples
Initial value:
1 = [
2  "RelValTTbar"
3 ]

Definition at line 448 of file validation.py.

list validation._doConversionSamples
Initial value:
1 = [
2  "RelValTTbar",
3  "RelValH125GGgluonfusion",
4 ]

Definition at line 444 of file validation.py.

list validation._doElectronSamples
Initial value:
1 = [
2  "RelValTTbar",
3  "RelValSingleElectronPt35",
4  "RelValSingleElectronPt10",
5 ]

Definition at line 439 of file validation.py.

dictionary validation._globalTags

Definition at line 19 of file validation.py.

list validation._releasePostfixes
Initial value:
1 = ["_AlcaCSA14", "_PHYS14", "_TEST", "_v2", "_v3", "_pmx", "_Fall14DR", "_FIXGT", "_PU", "_PXbest", "_PXworst", "_hcal", "_tec", "_71XGENSIM", "_73XGENSIM", "_BS", "_GenSim_7113", "_extended",
2  "_25ns_asymptotic", "_50ns_startup", "_50ns_asympref", "_50ns_asymptotic", "_minimal", "_0T", "_unsch", "_noCCC", "_MT", "_GS", "_rereco", "_pythia8", "_13TeV", "_realGT", "_newGT2", "_newGT", "_phase1", "_phase2", "_2017", "_2018", "_ecal15fb", "_ecal30fb", "_ecalsrb5", "_ecalsrc1", "_ecalsrd7", "_pixDynIneff", "_PXmap", "_gcc530", "_gcc630", "_cc7", "_Tranche4GT", "_newBPixFPixHCAL", "_newBPixFPix", "_newBPixHCAL", "_newBPix", "_newHCAL", "_HIP", "_run1", "_mahi"]

Definition at line 351 of file validation.py.

dictionary validation._relvalUrls
Initial value:
1 = {
2  "6_2_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_6_2_x/",
3  "7_0_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_7_0_x/",
4  "7_1_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_7_1_x/",
5  "7_2_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_7_2_x/",
6  "7_3_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_7_3_x/",
7  "7_4_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_7_4_x/",
8  "7_5_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_7_5_x/",
9  "7_6_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_7_6_x/",
10  "8_0_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_8_0_x/",
11  "8_1_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_8_1_x/",
12  "9_0_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_9_0_x/",
13  "9_1_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_9_1_x/",
14  "9_2_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_9_2_x/",
15  "9_3_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_9_3_x/",
16  "9_4_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_9_4_x/",
17  "10_0_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_10_0_x/",
18 }

Definition at line 420 of file validation.py.