ATLAS Offline Software
Functions | Variables
dq_make_web_display Namespace Reference

Functions

def recurse (rdir, dqregion, ignorepath, reffile=None)
 
def prune (dqregion)
 
def paramcount (dqregion)
 
def process (infname, confname, reffile=None)
 
def super_process (fname, options)
 

Variables

 gatherdata
 
 worst = DQAlgorithm(id='WorstCaseSummary',libname='libdqm_summaries.so')
 
 cl = ROOT.TClass.GetClass(cl)
 print [x.__class__ for x in toList(dqregion.getSubRegions()) ] More...
 
string name = rdir.GetPath().replace(ignorepath, '') + '/' + key.GetName()
 
dictionary dqpargs
 
 reference
 
 dqpar = dqregion.newDQParameter( **dqpargs)
 
 newregion = dqregion.newDQRegion( key.GetName(), algorithm=worst )
 
 parser = optparse.OptionParser(usage='usage: %prog [options] inputfile run')
 
 default
 
 help
 
 type
 
 options
 
 args
 
 fname = args[0]
 
 run = int(args[1])
 
def rv = super_process(fname, options)
 

Function Documentation

◆ paramcount()

def dq_make_web_display.paramcount (   dqregion)

Definition at line 80 of file dq_make_web_display.py.

80 def paramcount(dqregion):
81  params = dqregion.getDQParameters()
82  if params is None:
83  params = []
84  subregions = dqregion.getSubRegions()
85  if subregions is None:
86  subregions = []
87 
88  return len(params) + sum([paramcount(region) for region in subregions])
89 

◆ process()

def dq_make_web_display.process (   infname,
  confname,
  reffile = None 
)

Definition at line 90 of file dq_make_web_display.py.

90 def process(infname, confname, reffile=None):
91  f = ROOT.TFile(infname, 'READ')
92  if not f.IsOpen():
93  print('ERROR: cannot open %s' % infname)
94  return
95 
96  top_level = DQRegion(id='topRegion',algorithm=worst)
97  print('Building tree...')
98  recurse(f, top_level, f.GetPath(), reffile)
99  print('Pruning dead branches...')
100  prune(top_level)
101  pc = paramcount(top_level)
102 
103  sublevel = top_level.getSubRegions()[:]
104  for x in sublevel:
105  top_level.delRelation('DQRegions', x)
106 
107  print('Writing output')
108  writeHanConfiguration( filename = confname , roots = sublevel)
109  return pc
110 

◆ prune()

def dq_make_web_display.prune (   dqregion)
returns True if we should kill this node
False if we should not

Definition at line 53 of file dq_make_web_display.py.

53 def prune(dqregion):
54  """
55  returns True if we should kill this node
56  False if we should not
57  """
58  params = dqregion.getDQParameters()
59  if params is None:
60  params = []
61  subregions = dqregion.getSubRegions()
62  if subregions is None:
63  subregions = []
64  else:
65  subregions = subregions[:]
66  # kill subregions
67  for sr in subregions:
68  if sr is None:
69  continue
70  if prune(sr):
71  dqregion.delRelation('DQRegions', sr)
72  subregions = dqregion.getSubRegions()
73  if subregions is None:
74  subregions = []
75  if len(subregions) + len(params) == 0:
76  return True
77  else:
78  return False
79 

◆ recurse()

def dq_make_web_display.recurse (   rdir,
  dqregion,
  ignorepath,
  reffile = None 
)

Definition at line 23 of file dq_make_web_display.py.

23 def recurse(rdir, dqregion, ignorepath, reffile=None):

◆ super_process()

def dq_make_web_display.super_process (   fname,
  options 
)

Definition at line 111 of file dq_make_web_display.py.

111 def super_process(fname, options):
112  import shutil, os, sys, contextlib
113  import ROOT
114  han_is_found = (ROOT.gSystem.Load('libDataQualityInterfaces') == 0)
115  if not han_is_found:
116  print('ERROR: unable to load offline DQMF; unable to proceed')
117  sys.exit(1)
118  bname = os.path.basename(fname)
119 
120  run = options.run
121  hanconfig = None
122  hanhcfg = None
123  hanoutput = None
124 
125  failed = False
126  prebuilt_hcfg = False
127 
128  @contextlib.contextmanager
129  def tmpdir():
130  import tempfile
131  td = tempfile.mkdtemp()
132  yield td
133  shutil.rmtree(td)
134 
135  with tmpdir() as hantmpdir:
136  try:
137  print('====> Processing file %s' % (fname))
138  print('====> Generating han configuration file')
139  hantmpinput = os.path.join(hantmpdir, bname)
140  shutil.copyfile(fname, hantmpinput)
141  haninput = hantmpinput
142  hanconfig = os.path.join(hantmpdir, 'han.config')
143  rv = process(hantmpinput, hanconfig, options.reffile)
144  # bad hack. rv = number of histogram nodes
145  if rv == 0:
146  print('No histograms to display; exiting with code 0')
147  sys.exit(0)
148 
149  print('====> Compiling han configuration')
150  hanhcfg = os.path.join(hantmpdir, 'han.hcfg')
151 
152  ROOT.dqi.HanConfig().AssembleAndSave( hanconfig, hanhcfg )
153 
154  print('====> Executing han')
155  import resource
156  memlimit = resource.getrlimit(resource.RLIMIT_AS)
157  resource.setrlimit(resource.RLIMIT_AS, (memlimit[1], memlimit[1]))
158  hanoutput = haninput.rpartition('.')[0] + '_han.root'
159 
160  rv = ROOT.dqi.HanApp().Analyze( hanhcfg, haninput, hanoutput, '' )
161 
162  if rv != 0:
163  raise Exception('failure in han')
164  hantargetdir = os.path.join(options.webdir, str(options.iteration),
165  options.dispname, 'run_%s' % run)
166  print('====> Copying to', hantargetdir)
167  hantargetfile = os.path.join(hantargetdir, 'run_%s_han.root' % run)
168  if not os.access(hantargetdir, os.W_OK):
169  try:
170  os.makedirs(hantargetdir)
171  except Exception as e:
172  print('Unable to create %s for some reason: %s' % (hantargetdir, e))
173  raise Exception('Error during execute')
174  shutil.copy2(hanoutput, hantargetfile)
175  print('====> Cleaning up')
176  except Exception as e:
177  print(e)
178  if 'canonical format' not in str(e):
179  failed = True
180  finally:
181  try:
182  if not prebuilt_hcfg:
183  os.unlink(hantmpinput)
184  os.unlink(hanconfig)
185  os.unlink(hanhcfg)
186  os.unlink(hanoutput)
187  except Exception:
188  pass
189 
190  return not failed
191 
192 

Variable Documentation

◆ args

dq_make_web_display.args

Definition at line 205 of file dq_make_web_display.py.

◆ cl

dq_make_web_display.cl = ROOT.TClass.GetClass(cl)

print [x.__class__ for x in toList(dqregion.getSubRegions()) ]

Definition at line 26 of file dq_make_web_display.py.

◆ default

dq_make_web_display.default

Definition at line 196 of file dq_make_web_display.py.

◆ dqpar

dq_make_web_display.dqpar = dqregion.newDQParameter( **dqpargs)

Definition at line 45 of file dq_make_web_display.py.

◆ dqpargs

dictionary dq_make_web_display.dqpargs
Initial value:
1 = { 'id' :name,
2  'algorithm': gatherdata,
3  'inputdatasource': name,
4  }

Definition at line 39 of file dq_make_web_display.py.

◆ fname

dq_make_web_display.fname = args[0]

Definition at line 210 of file dq_make_web_display.py.

◆ gatherdata

dq_make_web_display.gatherdata
Initial value:
1 = DQAlgorithm(id='GatherData',
2  libname='libdqm_algorithms.so')

Definition at line 19 of file dq_make_web_display.py.

◆ help

dq_make_web_display.help

Definition at line 197 of file dq_make_web_display.py.

◆ name

string dq_make_web_display.name = rdir.GetPath().replace(ignorepath, '') + '/' + key.GetName()

Definition at line 38 of file dq_make_web_display.py.

◆ newregion

dq_make_web_display.newregion = dqregion.newDQRegion( key.GetName(), algorithm=worst )

Definition at line 50 of file dq_make_web_display.py.

◆ options

dq_make_web_display.options

Definition at line 205 of file dq_make_web_display.py.

◆ parser

dq_make_web_display.parser = optparse.OptionParser(usage='usage: %prog [options] inputfile run')

Definition at line 195 of file dq_make_web_display.py.

◆ reference

dq_make_web_display.reference

Definition at line 44 of file dq_make_web_display.py.

◆ run

dq_make_web_display.run = int(args[1])

Definition at line 212 of file dq_make_web_display.py.

◆ rv

def dq_make_web_display.rv = super_process(fname, options)

Definition at line 219 of file dq_make_web_display.py.

◆ type

dq_make_web_display.type

Definition at line 200 of file dq_make_web_display.py.

◆ worst

dq_make_web_display.worst = DQAlgorithm(id='WorstCaseSummary',libname='libdqm_summaries.so')

Definition at line 21 of file dq_make_web_display.py.

dq_make_web_display.paramcount
def paramcount(dqregion)
Definition: dq_make_web_display.py:80
dq_make_web_display.super_process
def super_process(fname, options)
Definition: dq_make_web_display.py:111
dq_make_web_display.recurse
def recurse(rdir, dqregion, ignorepath, reffile=None)
Definition: dq_make_web_display.py:23
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
dq_make_web_display.prune
def prune(dqregion)
Definition: dq_make_web_display.py:53
dq_make_web_display.process
def process(infname, confname, reffile=None)
Definition: dq_make_web_display.py:90
beamspotman.tmpdir
string tmpdir
Definition: beamspotman.py:412
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
str
Definition: BTagTrackIpAccessor.cxx:11
python.hanwriter.writeHanConfiguration
def writeHanConfiguration(filename='dq.han.config', roots=[])
Definition: hanwriter.py:724