CMS 3D CMS Logo

Classes | Functions | Variables
preskimming Namespace Reference

Classes

class  JSONFilter
 

Functions

def preSkim (tree, jsonInput=None, cutstring=None, maxEntries=None, firstEntry=0)
 

Variables

 IgnoreCommandLineOptions
 

Function Documentation

◆ preSkim()

def preskimming.preSkim (   tree,
  jsonInput = None,
  cutstring = None,
  maxEntries = None,
  firstEntry = 0 
)

Definition at line 59 of file preskimming.py.

Referenced by postprocessor.PostProcessor.run().

59 def preSkim(tree, jsonInput=None, cutstring=None, maxEntries=None, firstEntry=0):
60  if jsonInput == None and cutstring == None:
61  return None, None
62  cut = None
63  jsonFilter = None
64  if jsonInput != None:
65  if type(jsonInput) is dict:
66  jsonFilter = JSONFilter(runsAndLumis=jsonInput)
67  else:
68  jsonFilter = JSONFilter(jsonInput)
69  cut = jsonFilter.runCut()
70  if cutstring != None:
71  cut = "(%s) && (%s)" % (cutstring, cut) if cut else cutstring
72  if maxEntries is None:
73  maxEntries = ROOT.TVirtualTreePlayer.kMaxEntries
74  while "AltBranch$" in cut:
75  m = re.search(r"AltBranch\$\(\s*(\w+)\s*,\s*(\w+)\s*\)", cut)
76  if not m:
77  raise RuntimeError(
78  "Error, found AltBranch$ in cut string, but it doesn't comply with the syntax this code can support. The cut is %r" % cut)
79  cut = cut.replace(m.group(0), m.group(
80  1) if tree.GetBranch(m.group(1)) else m.group(2))
81  tree.Draw('>>elist', cut, "entrylist", maxEntries, firstEntry)
82  elist = ROOT.gDirectory.Get('elist')
83  if jsonInput:
84  elist = jsonFilter.filterEList(tree, elist)
85  return elist, jsonFilter
86 
def preSkim(tree, jsonInput=None, cutstring=None, maxEntries=None, firstEntry=0)
Definition: preskimming.py:59

Variable Documentation

◆ IgnoreCommandLineOptions

preskimming.IgnoreCommandLineOptions

Definition at line 4 of file preskimming.py.