ATLAS Offline Software
Classes | Functions | Variables
navigation2dot Namespace Reference

Classes

class  TE
 

Functions

def featureClassName (clid)
 
def teName (teid)
 
def nav2dot (nav, eventId, level)
 
def parseLog (file)
 
def parseCLIDs ()
 
def parseOpt ()
 

Variables

 teIdtoName
 
 featureCLIDtoName
 
 GraphivizPath
 
 GraphivizBinPath
 
 GraphivizLibPath
 
 options
 
 logname
 
 log
 
 conflog
 
 navlog
 

Function Documentation

◆ featureClassName()

def navigation2dot.featureClassName (   clid)
converts the CLID to ClassName in C++. If falied then CLID instead.
    The CLIDS to name is taken from CLID Svc dump.

Definition at line 46 of file navigation2dot.py.

46 def featureClassName(clid):
47  """ converts the CLID to ClassName in C++. If falied then CLID instead.
48  The CLIDS to name is taken from CLID Svc dump."""
49  if clid in featureCLIDtoName.keys():
50  return featureCLIDtoName[clid]
51  else:
52  if options['clid'] is False:
53  return str(clid)
54  else: # use CLID DB clid command to get it)
55  name = commands.getoutput( 'clid '+clid).split(' ')[1]
56  featureCLIDtoName[clid] = name
57  return name
58 

◆ nav2dot()

def navigation2dot.nav2dot (   nav,
  eventId,
  level 
)
converts

Definition at line 164 of file navigation2dot.py.

164 def nav2dot(nav, eventId, level):
165  """ converts"""
166  global options
167  inputTEs = nav.split('\n')
168  stringTEs = []
169  for te in inputTEs:
170  if te is not '':
171  stringTEs.append(te.lstrip(' |\_'))
172 
173  # unique
174  uniqueTEs = []
175  for ste in stringTEs:
176  if ste not in uniqueTEs:
177  uniqueTEs.append(ste)
178  # print "LEN :" + str(len(stringTEs)) + "-->" + str(len(uniqueTEs))
179 
180  objectTEs = map( lambda x: TE(x), uniqueTEs)
181  dot = 'digraph Menu {\n'\
182  +'\n'\
183  +'graph [ rankdir = "TR"];'\
184  +'node [ shape=polygon, fontname=Helvetica ]\n'\
185  +'edge [ fontname=Helvetica ]\n'
186  dot += reduce(lambda x,y: x+str(y), objectTEs, '')
187  dot += '\n}'
188 
189  fname = 'navigationEvent-'+level+'-'+str(eventId)
190  if options['event'] is None or str(options['event']) == str(eventId):
191  print 'writing file: '+fname+'.dot'
192  f = file('temp.dot','w')
193  f.write(dot)
194  f.close()
195  #print commands.getoutput(GraphivizBinPath+'unflatten -l4 -f -c2 -o '+ fname+ '.dot temp.dot')
196  print commands.getoutput('mv -f temp.dot '+fname+'.dot')
197  print commands.getoutput('/bin/rm -f temp.dot')
198  if options['convert']:
199  print 'converting file: '+fname+'.dot to graphics'
200  global GraphivizBinPath
201  print commands.getoutput(GraphivizBinPath+options['program']+' ' + fname +'.dot -Tpng -o '+fname+'.png')
202  # delete dot file
203  print commands.getoutput('rm -f '+fname+'.dot')
204 # nav2dot(navex)
205 

◆ parseCLIDs()

def navigation2dot.parseCLIDs ( )

Definition at line 262 of file navigation2dot.py.

262 def parseCLIDs():
263 
264  if options['clid'] is False:
265  clids = file("CLIDDBout.txt")
266  for line in clids:
267  clid = line.split(" ")[0]
268  name = line.split(" ")[1].rstrip("\n")
269  featureCLIDtoName[clid] = name
270  # print featureCLIDtoName
271 
272 
273 

◆ parseLog()

def navigation2dot.parseLog (   file)

Definition at line 206 of file navigation2dot.py.

206 def parseLog(file):
207  eventNumber = -1
208  navigationStarted=False
209  nav = ""
210  step = 0
211  stepToLevel = ["L2", "EFunpacking", "EF"]
212 
213  for line in file:
214  if line.find("- --") is not -1:
215  # print line
216  if line.find("inputTEs") is not -1: # we spoted input TE in sequence printout
217  try:
218  teId = line.split(" ")[5]
219  teId = string.strip(teId, "(), \"\n")
220  teId = rstrip(teId, ",")
221  teName = line.split(" ")[4]
222  teName = string.strip(teName, "(), \"\n")
223  teIdtoName[teId] = teName
224  except:
225  pass
226  if line.find(" outputTE : (") is not -1:
227  teId = line.split(" ")[7]
228  teId = string.strip(teId, "() \n")
229  teName = line.split(" ")[6]
230  teName = string.strip(teName, "()\",\n")
231  teIdtoName[teId] = teName
232 
233  # catch the navigation printout
234  if line.find("start processing event #") is not -1:
235  eventId = line.split("#")[1].split(",")[0]
236  step=0
237  print "scanning event: ",eventId
238 
239 
240  if line.find("Start of HLT Processing in L2") is not -1:
241  step = 0
242 
243  if line.find("Start of HLT Processing in EF") is not -1:
244  step = 1
245 
246  if line.find("TrigSteer_EF.ResultBuilder") is not -1:
247  step = 2
248 
249  # catch navigation block
250  if line.find("\\_") is not -1:
251  if navigationStarted is False:
252  navigationStarted=True
253  nav += line
254  else:
255  if navigationStarted is True:
256  navigationStarted=False
257  nav2dot(nav, eventId, stepToLevel[step] )
258 
259  nav = ""
260 
261 

◆ parseOpt()

def navigation2dot.parseOpt ( )

Definition at line 274 of file navigation2dot.py.

274 def parseOpt():
275  global options
276  stat = True
277 
278  if '-f' in sys.argv:
279  options['drawFeatures'] = True
280  print "OPTION: will draw features"
281 
282  if '-d' in sys.argv:
283  options['clid'] = True
284  print "OPTION: will use clid command to get class names (slower)"
285  if '-x' in sys.argv:
286  options['regex'] = re.compile(sys.argv[sys.argv.index('-x')+1])
287  print "OPTION: will use only TEs accepted by regex", sys.argv[sys.argv.index('-x')+1]
288  if '-e' in sys.argv:
289  import string
290  options['event'] = string.atoi(sys.argv[sys.argv.index('-e')+1])
291  print "OPTION: will only draw event: ", options["event"]
292 
293  if '-c' in sys.argv:
294  options['convert'] = True;
295  print "OPTION: will convert to graphics on the fly"
296 
297  if '-p' in sys.argv:
298  options['program'] = sys.argv[sys.argv.index('-p')+1]
299  print "OPTION: will convert to graphics on the fly using ", options['program']
300 
301  if '-r' in sys.argv:
302  options['raw'] = True
303  options['configdump'] = sys.argv[sys.argv.index('-r')+2]
304  options['navigationdump'] = sys.argv[sys.argv.index('-r')+1]
305 
306 
307  if '-h' in sys.argv:
308  print "OPTION: Help needed? Here it is:"
309  print """
310  Files generated by this utility can be viewed by programs like 'dotty'.
311  Thay can be converted to graphics using probram 'dot':
312  dot nav_event_123.dot -o nav123.png -Tpng
313 
314  -h -- this help
315  -f -- draw freatures atteched to TE (with lables)
316  -d -- use clid command instead of CLIDDBout.txt to get human class names rather than CLIDs
317  -e X -- writeout only event (X)
318  -x regex -- use the regex to select only wanted TEs
319  -c -- convert graphs to png on the fly using dot program
320  -p prog -- use other program(neato, twopi, circo, fdp)
321  -r navigationfile configfile -- take files with the navigation dump and the configuration dump (rather than plain log)
322  """
323  stat = False
324  return stat
325 # main script
326 

◆ teName()

def navigation2dot.teName (   teid)

Definition at line 59 of file navigation2dot.py.

59 def teName(teid):
60  if teid in teIdtoName.keys():
61  return teIdtoName[teid]
62  else:
63  print "TE id: ", teid, " unknown"
64  return teid
65 

Variable Documentation

◆ conflog

navigation2dot.conflog

Definition at line 334 of file navigation2dot.py.

◆ featureCLIDtoName

navigation2dot.featureCLIDtoName

Definition at line 12 of file navigation2dot.py.

◆ GraphivizBinPath

navigation2dot.GraphivizBinPath

Definition at line 26 of file navigation2dot.py.

◆ GraphivizLibPath

navigation2dot.GraphivizLibPath

Definition at line 27 of file navigation2dot.py.

◆ GraphivizPath

navigation2dot.GraphivizPath

Definition at line 25 of file navigation2dot.py.

◆ log

navigation2dot.log

Definition at line 330 of file navigation2dot.py.

◆ logname

navigation2dot.logname

Definition at line 329 of file navigation2dot.py.

◆ navlog

navigation2dot.navlog

Definition at line 336 of file navigation2dot.py.

◆ options

navigation2dot.options

Definition at line 37 of file navigation2dot.py.

◆ teIdtoName

navigation2dot.teIdtoName

Definition at line 11 of file navigation2dot.py.

navigation2dot.parseOpt
def parseOpt()
Definition: navigation2dot.py:274
navigation2dot.teName
def teName(teid)
Definition: navigation2dot.py:59
reduce
void reduce(HepMC::GenEvent *ge, std::vector< HepMC::GenParticlePtr > toremove)
Remove unwanted particles from the event, collapsing the graph structure consistently.
Definition: FixHepMC.cxx:81
navigation2dot.parseCLIDs
def parseCLIDs()
Definition: navigation2dot.py:262
file
TFile * file
Definition: tile_monitor.h:29
navigation2dot.parseLog
def parseLog(file)
Definition: navigation2dot.py:206
navigation2dot.featureClassName
def featureClassName(clid)
Definition: navigation2dot.py:46
navigation2dot.nav2dot
def nav2dot(nav, eventId, level)
Definition: navigation2dot.py:164
str
Definition: BTagTrackIpAccessor.cxx:11
Trk::split
@ split
Definition: LayerMaterialProperties.h:38