After setting up this TDAQ release the event Viewer can be
started by using the following simple command:
> event_viewer.py
There are 3 simple steps to follow in order to provide a custom
representation of a ROD data:
A plugin is a simple Python function which has one argument - a sequnce of 4-byte integer values and must return an HTML string which contain representation of the input data. This function must be preceded by special annotation which defines what data it will be applied to. For example the following function implements a plugin which will be used for displaying both status and data values of all ROD fragments whose names are starting with "LAR_":
The plugin formats input sequence into multiple rows with 10 hexadecimal integer values in each row. Each value is printed using mono-spaced font of blue color.import EventViewer
@EventViewer.Plugin("data", "LAR_.*")@EventViewer.Plugin("status", "LAR_.*")def lar_converter(data):lines = [data[i:i+10] for i in range(0,len(data),10)]
out = '<br />'.join('<b><i>%03d</i></b> : %s' % (10*n,' '.join('0x%08x' % word for word in line))for n,line in enumerate(lines))
return '<font face="courier" color="blue">' + out + '</font>'
One can as well provide different functions for the "status" and "data" tags as well as have more specific formatting for a subset of RODs. For example in addition to the previous function a valid plugin may contain the following one in which case all RODs which start with "LAR_EM_" will be displayed differently to the ones which have only "LAR_" in their names:
Those ones will be shown in a similar way but using red color for the data values.@EventViewer.Plugin("data", "LAR_EM_.*")@EventViewer.Plugin("status", "LAR_EM.*")def lar_converter(data):lines = [data[i:i+10] for i in range(0,len(data),10)]
out = '<br />'.join('<b><i>%03d</i></b> : %s' % (10*n,' '.join('0x%08x' % word for word in line))for n,line in enumerate(lines))
return '<font face="courier" color="red">' + out + '</font>'
> export PYTHONPATH=<location of the plugin file>:$PYTHONPATH
Finally if the plugin code is packed to the file called for example LArEventViewerPlugin.py one can put it into play by executing the following command:One can also simplify the usage of the plugins providing to the end users a simple python script which contains custom plugins code and starts the Event Viewer. Such script will look like:
> event_viewer.py LArEventViewerPlugin
#!/usr/bin/env tdaq_python import EventViewer # Put your plugins code here if __name__ == '__main__': w = EventViewer.EventViewer() w.run()