ATLAS Offline Software
Loading...
Searching...
No Matches
navigation2dot Namespace Reference

Classes

class  TE

Functions

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

Variables

dict teIdtoName = {'0':'0'}
dict featureCLIDtoName = {}
str GraphivizPath = os.environ['CMTROOT']+'/../Grafviz/2.2'
str GraphivizBinPath = GraphivizPath+'/bin/'
str GraphivizLibPath = GraphivizPath+'/lib/graphviz'
dict options
 logname = sys.argv[-1]
 log = file(logname)
 conflog = file(options['configdump'])
 navlog = file(options['navigationdump'])

Function Documentation

◆ featureClassName()

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.

46def 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
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ nav2dot()

navigation2dot.nav2dot ( nav,
eventId,
level )
converts

Definition at line 164 of file navigation2dot.py.

164def 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
static void reduce(HepMC::GenEvent *ge, HepMC::GenParticle *gp)
Remove an unwanted particle from the event, collapsing the graph structure consistently.
Definition FixHepMC.cxx:39
STL class.
TFile * file

◆ parseCLIDs()

navigation2dot.parseCLIDs ( )

Definition at line 262 of file navigation2dot.py.

262def 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()

navigation2dot.parseLog ( file)

Definition at line 206 of file navigation2dot.py.

206def 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()

navigation2dot.parseOpt ( )

Definition at line 274 of file navigation2dot.py.

274def 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()

navigation2dot.teName ( teid)

Definition at line 59 of file navigation2dot.py.

59def 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 = file(options['configdump'])

Definition at line 334 of file navigation2dot.py.

◆ featureCLIDtoName

dict navigation2dot.featureCLIDtoName = {}

Definition at line 12 of file navigation2dot.py.

◆ GraphivizBinPath

str navigation2dot.GraphivizBinPath = GraphivizPath+'/bin/'

Definition at line 26 of file navigation2dot.py.

◆ GraphivizLibPath

str navigation2dot.GraphivizLibPath = GraphivizPath+'/lib/graphviz'

Definition at line 27 of file navigation2dot.py.

◆ GraphivizPath

str navigation2dot.GraphivizPath = os.environ['CMTROOT']+'/../Grafviz/2.2'

Definition at line 25 of file navigation2dot.py.

◆ log

navigation2dot.log = file(logname)

Definition at line 330 of file navigation2dot.py.

◆ logname

navigation2dot.logname = sys.argv[-1]

Definition at line 329 of file navigation2dot.py.

◆ navlog

navigation2dot.navlog = file(options['navigationdump'])

Definition at line 336 of file navigation2dot.py.

◆ options

dict navigation2dot.options
Initial value:
1= {'drawFeatures': False,
2 'clid': True,
3 'convert': False,
4 'program': 'dot',
5 'event': None,
6 'raw': False,
7 'regex': re.compile('.*')}

Definition at line 37 of file navigation2dot.py.

◆ teIdtoName

dict navigation2dot.teIdtoName = {'0':'0'}

Definition at line 11 of file navigation2dot.py.