CMS 3D CMS Logo

Functions | Variables
dqmiodatasetharvest Namespace Reference

Functions

def check_interesting (mename)
 
def dasquery (dataset)
 
def harvestfile (fname)
 
def tosqlite (x)
 

Variables

 args
 
 ctr
 
 db
 
 default
 
 description
 
 dumpmes
 
 end
 
 files
 
 help
 
 inf
 
 insertinto
 
 int
 
 interesting_mes
 
 interesting_types
 
 makeindex
 
 maketable
 
 nan
 
 parser
 
 pool
 
 processes
 
 ROOTPREFIX
 
 sqlite2tree
 
 treenames
 
 type
 

Function Documentation

◆ check_interesting()

def dqmiodatasetharvest.check_interesting (   mename)

Definition at line 41 of file dqmiodatasetharvest.py.

Referenced by harvestfile().

41 def check_interesting(mename):
42  for pattern in interesting_mes:
43  if fnmatch.fnmatch(mename,pattern):
44  return True
45  return False
46 

◆ dasquery()

def dqmiodatasetharvest.dasquery (   dataset)

Definition at line 70 of file dqmiodatasetharvest.py.

References print().

70 def dasquery(dataset):
71  if not dataset.endswith("DQMIO"):
72  raise Exception("This tool probably cannot read the dataset you specified. The name should end with DQMIO.")
73  dasquery = ["dasgoclient", "-query=file dataset=%s" % dataset]
74  print("Querying das ... %s" % dasquery)
75  files = subprocess.check_output(dasquery)
76  files = files.splitlines()
77  print("Got %d files." % len(files))
78  return files
79 
80 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ harvestfile()

def dqmiodatasetharvest.harvestfile (   fname)

Definition at line 123 of file dqmiodatasetharvest.py.

References check_interesting(), WZElectronSkims53X_cff.max, SiStripPI.min, isotrackApplyRegressor.range, str, and tosqlite().

123 def harvestfile(fname):
124  f = ROOT.TFile.Open(ROOTPREFIX + fname)
125  idxtree = getattr(f, "Indices")
126  #idxtree.GetEntry._threaded = True # now the blocking call should release the GIL...
127 
128  # we have no good way to find out which lumis where processed in a job.
129  # so we watch the per-lumi indices and assume that all mentioned lumis
130  # are covered in the end-of-job MEs. This might fail if there are no
131  # per-lumi MEs.
132  knownlumis = set()
133  mes_to_store = []
134 
135  for i in range(idxtree.GetEntries()):
136  idxtree.GetEntry(i)
137  run, lumi, metype = idxtree.Run, idxtree.Lumi, idxtree.Type
138  if lumi != 0:
139  knownlumis.add(lumi)
140 
141  if not treenames[metype] in interesting_types:
142  continue
143 
144  endrun = run # assume no multi-run files for now
145  if lumi == 0: # per-job ME
146  endlumi = max(knownlumis)
147  lumi = min(knownlumis)
148  else:
149  endlumi = lumi
150 
151  # inclusive range -- for 0 entries, row is left out
152  firstidx, lastidx = idxtree.FirstIndex, idxtree.LastIndex
153  metree = getattr(f, treenames[metype])
154  metree.GetEntry(0)
155  metree.SetBranchStatus("*",0)
156  metree.SetBranchStatus("FullName",1)
157 
158  for x in range(firstidx, lastidx+1):
159  metree.GetEntry(x)
160  mename = str(metree.FullName)
161 
162  if mename.find("AlCaReco") != -1:
163  continue
164 
165  if mename.find("Isolated") != -1:
166  continue
167 
168  if mename.find("HLT") != -1:
169  continue
170 
171  if not ((mename.find("SiStrip") >= 0) or (mename.find("OfflinePV") >= 0) or (mename.find("PixelPhase1") >= 0) or (mename.find("Tracking") >= 0 )):
172  continue
173 
174  if check_interesting(mename):
175  metree.GetEntry(x, 1)
176  value = metree.Value
177 
178  mes_to_store.append((
179  mename,
180  run, lumi, endrun, endlumi,
181  metype,
182  tosqlite(value),
183  ))
184 
185  return mes_to_store
186 
#define str(s)

◆ tosqlite()

def dqmiodatasetharvest.tosqlite (   x)

Definition at line 47 of file dqmiodatasetharvest.py.

References edmScanValgrind.buffer, and betterConfigParser.unicode.

Referenced by harvestfile().

47 def tosqlite(x):
48  if isinstance(x, ROOT.string):
49  try:
50  return unicode(x.data())
51  except:
52  return buffer(x.data())
53  if isinstance(x, int):
54  return x
55  if isinstance(x, float):
56  return x
57  if isinstance(x, int):
58  return x
59  else:
60  try:
61  rootobj = unicode(ROOT.TBufferJSON.ConvertToJSON(x))
62  # turns out ROOT does not generate valid JSON for NaN/inf
63  clean = nan.sub('\\g<1>0\\g<2>', inf.sub('\\g<1>1e38\\g<2>', rootobj))
64  obj = json.loads(clean)
65  jsonobj = json.dumps(obj, allow_nan=False)
66  return jsonobj
67  except Exception as e:
68  return json.dumps({"root2sqlite_error": e.__repr__(), "root2sqlite_object": x.__repr__()})
69 

Variable Documentation

◆ args

dqmiodatasetharvest.args

Definition at line 21 of file dqmiodatasetharvest.py.

◆ ctr

dqmiodatasetharvest.ctr

◆ db

dqmiodatasetharvest.db

Definition at line 119 of file dqmiodatasetharvest.py.

◆ default

dqmiodatasetharvest.default

Definition at line 18 of file dqmiodatasetharvest.py.

◆ description

dqmiodatasetharvest.description

Definition at line 15 of file dqmiodatasetharvest.py.

◆ dumpmes

dqmiodatasetharvest.dumpmes

Definition at line 115 of file dqmiodatasetharvest.py.

◆ end

dqmiodatasetharvest.end

Definition at line 197 of file dqmiodatasetharvest.py.

◆ files

dqmiodatasetharvest.files

Definition at line 187 of file dqmiodatasetharvest.py.

◆ help

dqmiodatasetharvest.help

Definition at line 17 of file dqmiodatasetharvest.py.

◆ inf

dqmiodatasetharvest.inf

Definition at line 38 of file dqmiodatasetharvest.py.

◆ insertinto

dqmiodatasetharvest.insertinto

Definition at line 106 of file dqmiodatasetharvest.py.

◆ int

dqmiodatasetharvest.int

Definition at line 19 of file dqmiodatasetharvest.py.

◆ interesting_mes

dqmiodatasetharvest.interesting_mes

Definition at line 32 of file dqmiodatasetharvest.py.

◆ interesting_types

dqmiodatasetharvest.interesting_types

Definition at line 25 of file dqmiodatasetharvest.py.

◆ makeindex

dqmiodatasetharvest.makeindex

Definition at line 103 of file dqmiodatasetharvest.py.

◆ maketable

dqmiodatasetharvest.maketable

Definition at line 96 of file dqmiodatasetharvest.py.

◆ nan

dqmiodatasetharvest.nan

◆ parser

dqmiodatasetharvest.parser

Definition at line 15 of file dqmiodatasetharvest.py.

◆ pool

dqmiodatasetharvest.pool

Definition at line 190 of file dqmiodatasetharvest.py.

◆ processes

dqmiodatasetharvest.processes

◆ ROOTPREFIX

dqmiodatasetharvest.ROOTPREFIX

Definition at line 12 of file dqmiodatasetharvest.py.

◆ sqlite2tree

dqmiodatasetharvest.sqlite2tree

Definition at line 200 of file dqmiodatasetharvest.py.

◆ treenames

dqmiodatasetharvest.treenames

Definition at line 81 of file dqmiodatasetharvest.py.

◆ type

dqmiodatasetharvest.type

Definition at line 19 of file dqmiodatasetharvest.py.