CMS 3D CMS Logo

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

Classes

class  Sample
 
class  SimpleValidation
 
class  Validation
 

Functions

def _copyDir
 
def _copySubDir
 
def _getGlobalTag
 
def _getRelValUrl
 
def _stripRelease
 

Variables

dictionary _globalTags
 
list _releasePostfixes
 
dictionary _relvalUrls
 

Function Documentation

def validation._copyDir (   src,
  dst 
)
private
Copy recursively objects from src TDirectory to dst TDirectory.

Definition at line 628 of file validation.py.

Referenced by _copySubDir().

629 def _copyDir(src, dst):
630  """Copy recursively objects from src TDirectory to dst TDirectory."""
631  keys = src.GetListOfKeys()
632  for key in keys:
633  classname = key.GetClassName()
634  cl = ROOT.TClass.GetClass(classname)
635  if not cl:
636  continue
637  if cl.InheritsFrom("TDirectory"):
638  src2 = src.GetDirectory(key.GetName())
639  dst2 = dst.mkdir(key.GetName())
640  _copyDir(src2, dst2)
641  elif cl.InheritsFrom("TTree"):
642  t = key.ReadObj()
643  dst.cd()
644  newt = t.CloneTree(-1, "fast")
645  newt.Write()
646  newt.Delete()
647  else:
648  dst.cd()
649  obj = key.ReadObj()
650  obj.Write()
651  obj.Delete()
def _copyDir
Definition: validation.py:628
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 593 of file validation.py.

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

Referenced by validation.Validation._doPlots().

594 def _copySubDir(oldfile, newfile, basenames, dirname):
595  """Copy a subdirectory from oldfile to newfile.
596 
597  Arguments:
598  oldfile -- String for source TFile
599  newfile -- String for destination TFile
600  basenames -- List of strings for base directories, first existing one is picked
601  dirname -- String for directory name under the base directory
602  """
603  oldf = ROOT.TFile.Open(oldfile)
604 
605  dirold = None
606  for basename in basenames:
607  dirold = oldf.GetDirectory(basename)
608  if dirold:
609  break
610  if not dirold:
611  raise Exception("Did not find any of %s directories from file %s" % (",".join(basenames, oldfile)))
612  if dirname:
613  d = dirold.Get(dirname)
614  if not d:
615  raise Exception("Did not find directory %s under %s" % (dirname, dirold.GetPath()))
616  dirold = d
617 
618  newf = ROOT.TFile.Open(newfile, "RECREATE")
619  dirnew = newf
620  for d in basenames[0].split("/"):
621  dirnew = dirnew.mkdir(d)
622  if dirname:
623  dirnew = dirnew.mkdir(dirname)
624  _copyDir(dirold, dirnew)
625 
626  oldf.Close()
627  return newf
def _copySubDir
Definition: validation.py:593
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
double split
Definition: MVATrainer.cc:139
def _copyDir
Definition: validation.py:628
def validation._getGlobalTag (   sample,
  release 
)
private
Get a GlobalTag.

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

Definition at line 70 of file validation.py.

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

70 
71 def _getGlobalTag(sample, release):
72  """Get a GlobalTag.
73 
74  Arguments:
75  sample -- Sample object
76  release -- CMSSW release string
77  """
78  if not release in _globalTags:
79  print "Release %s not found from globaltag map in validation.py" % release
80  sys.exit(1)
81  gtmap = _globalTags[release]
82  if sample.hasOverrideGlobalTag():
83  ogt = sample.overrideGlobalTag()
84  if release in ogt:
85  gtmap = _globalTags[ogt[release]]
86  if sample.fullsim():
87  if sample.hasScenario():
88  return gtmap[sample.scenario()]
89  if sample.pileupType() == "50ns":
90  return gtmap.get("fullsim_50ns", gtmap["default"])
91  if sample.pileupType() == "25ns":
92  return gtmap.get("fullsim_25ns", gtmap["default"])
93  if sample.fastsim():
94  return gtmap.get("fastsim", gtmap["default"])
95  return gtmap["default"]
96 
# Mapping from release series to RelVal download URLs
def _getGlobalTag
Definition: validation.py:70
def validation._getRelValUrl (   release)
private
Get RelVal download URL for a given release.

Definition at line 106 of file validation.py.

Referenced by validation.Validation.download().

107 def _getRelValUrl(release):
108  """Get RelVal download URL for a given release."""
109  version_re = re.compile("CMSSW_(?P<X>\d+)_(?P<Y>\d+)")
110  m = version_re.search(release)
111  if not m:
112  raise Exception("Regex %s does not match to release version %s" % (version_re.pattern, release))
113  version = "%s_%s_X" % (m.group("X"), m.group("Y"))
114  if not version in _relvalUrls:
115  print "No RelVal URL for version %s, please update _relvalUrls" % version
116  sys.exit(1)
117  return _relvalUrls[version]
def _getRelValUrl
Definition: validation.py:106
def validation._stripRelease (   release)
private

Definition at line 63 of file validation.py.

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

63 
64 def _stripRelease(release):
65  for pf in _releasePostfixes:
66  if pf in release:
67  return release.replace(pf, "")
68  return release
69 
def _stripRelease
Definition: validation.py:63

Variable Documentation

dictionary validation._globalTags

Definition at line 14 of file validation.py.

list validation._releasePostfixes
Initial value:
1 = ["_AlcaCSA14", "_PHYS14", "_TEST", "_pmx_v2", "_pmx", "_Fall14DR", "_71XGENSIM_FIXGT", "_71XGENSIM", "_73XGENSIM", "_BS", "_GenSim_7113",
2  "_25ns_asymptotic", "_50ns_startup", "_50ns_asympref", "_50ns_asymptotic"]

Definition at line 61 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 }

Definition at line 97 of file validation.py.