CMS 3D CMS Logo

Functions | Variables
heppy_report Namespace Reference

Functions

def root2map (dir, ana, treename)
 

Variables

 args
 
 default
 
 description
 
 dest
 
 help
 
 jmap
 
 lumis
 
 oname
 
 options
 
 parser
 
 runs
 
 summary
 
 usage
 

Function Documentation

◆ root2map()

def heppy_report.root2map (   dir,
  ana,
  treename 
)

Definition at line 7 of file heppy_report.py.

References mps_setup.append, print(), and isotrackApplyRegressor.range.

7 def root2map(dir,ana,treename):
8  import ROOT
9  tfile = ROOT.TFile.Open("%s/%s/%s.root"%(dir,ana,treename))
10  if not tfile:
11  print("Error: dir %s does not contain %s/%s.root" % (dir,ana,treename))
12  return None
13  tree = tfile.Get(treename)
14  if not tree:
15  print("Error: rootfile %s/%s/%s.root does not contain a TTree %s" % (dir,ana,treename,treename))
16  return None
17  jsonind = {}
18  for e in range(tree.GetEntries()):
19  tree.GetEntry(e)
20  run,lumi = tree.run, tree.lumi
21  if run not in jsonind:
22  jsonind[run] = [lumi]
23  else:
24  jsonind[run].append(lumi)
25  # remove duplicates
26  for run in jsonind:
27  jsonind[run] = list(set(jsonind[run]))
28 
29  nruns = len(jsonind)
30  nlumis = sum(len(v) for v in jsonind.values())
31  jsonmap = {}
32  for r,lumis in jsonind.items():
33  if len(lumis) == 0: continue # shouldn't happen
34  lumis.sort()
35  ranges = [ [ lumis[0], lumis[0] ] ]
36  for lumi in lumis[1:]:
37  if lumi == ranges[-1][1] + 1:
38  ranges[-1][1] = lumi
39  else:
40  ranges.append([lumi,lumi])
41  jsonmap[r] = ranges
42  return (jsonmap, nruns, nlumis)
43 
def root2map(dir, ana, treename)
Definition: heppy_report.py:7
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Variable Documentation

◆ args

heppy_report.args

Definition at line 50 of file heppy_report.py.

◆ default

heppy_report.default

Definition at line 47 of file heppy_report.py.

◆ description

heppy_report.description

Definition at line 46 of file heppy_report.py.

◆ dest

heppy_report.dest

Definition at line 47 of file heppy_report.py.

◆ help

heppy_report.help

Definition at line 47 of file heppy_report.py.

◆ jmap

heppy_report.jmap

Definition at line 58 of file heppy_report.py.

◆ lumis

heppy_report.lumis

Definition at line 58 of file heppy_report.py.

◆ oname

heppy_report.oname

◆ options

heppy_report.options

Definition at line 50 of file heppy_report.py.

◆ parser

heppy_report.parser

Definition at line 45 of file heppy_report.py.

◆ runs

heppy_report.runs

Definition at line 58 of file heppy_report.py.

◆ summary

heppy_report.summary

Definition at line 55 of file heppy_report.py.

◆ usage

heppy_report.usage

Definition at line 45 of file heppy_report.py.