muonic package software reference

main package: muonic

The muonic package

muonic.daq muonic.gui muonic.analysis

daq i/o with muonic.daq

Provide a connection to the QNet DAQ cards via python-serial. For software testing and development, (very) dumb DAQ card simulator is available.

muonic.daq.DAQProvider

Control the two I/O threads which communicate with the DAQ. If the simulated DAQ is used, there is only one thread.

Provides the public interfaces to read from and send to a DAQ card

class muonic.daq.provider.BaseDAQProvider(logger=None)[source]

Base class defining the public API and helpers for the DAQ provider implementations

Parameters:logger (logging.Logger) – logger object
LINE_PATTERN = <_sre.SRE_Pattern object at 0x32223a0>
_abc_cache = <_weakrefset.WeakSet object at 0x3224650>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x3224690>
_abc_negative_cache_version = 27
_abc_registry = <_weakrefset.WeakSet object at 0x3224610>
_validate_line(line)[source]

Validate line against pattern. Returns None it the provided line is invalid or the line if it is valid.

Parameters:line (str) – line to validate
Returns:str or None
data_available()[source]

Tests if data is available from the DAQ.

Returns:int or bool
get(*args)[source]

Get something from the DAQ.

Parameters:args (list) – queue arguments
Returns:str or None
put(*args)[source]

Send information to the DAQ.

Parameters:args (list) – queue arguments
Returns:None
class muonic.daq.provider.DAQClient(address='127.0.0.1', port=5556, logger=None)[source]

DAQClient

Raises DAQMissingDependencyError if zmq is not installed.

Parameters:
  • address (str) – address to connect to
  • port (int) – TCP port to connect to
  • logger (logging.Logger) – logger object
Raises:

DAQMissingDependencyError

_abc_cache = <_weakrefset.WeakSet object at 0x3224950>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x32249d0>
_abc_negative_cache_version = 27
_abc_registry = <_weakrefset.WeakSet object at 0x3224890>
data_available()[source]

Tests if data is available from the DAQ.

Returns:int or bool
get(*args)[source]

Get something from the DAQ.

Raises DAQIOError if the queue is empty.

Parameters:args (list) – queue arguments
Returns:str or None – next line read from socket
Raises:DAQIOError
put(*args)[source]

Send information to the DAQ.

Parameters:args (list) – queue arguments
Returns:None
class muonic.daq.provider.DAQProvider(logger=None, sim=False)[source]

DAQProvider

Parameters:
  • logger (logging.Logger) – logger object
  • sim (bool) – enables DAQ simulation if set to True
_abc_cache = <_weakrefset.WeakSet object at 0x3224790>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x3224810>
_abc_negative_cache_version = 27
_abc_registry = <_weakrefset.WeakSet object at 0x3224710>
data_available()[source]

Tests if data is available from the DAQ.

Returns:int or bool
get(*args)[source]

Get something from the DAQ.

Raises DAQIOError if the queue is empty.

Parameters:args (list) – queue arguments
Returns:str or None – next item from the queue
Raises:DAQIOError
put(*args)[source]

Send information to the DAQ.

Parameters:args (list) – queue arguments
Returns:None

muonic.daq.DAQConnection

The module provides a class which uses python-serial to open a connection over the usb ports to the daq card. Since on LINUX systems the used usb device ( which is usually /dev/tty0 ) might change during runtime, this is catched automatically by DaqConnection. Therefore a shell script is invoked.

Provides DAQ server and connection classes to interface with the serial port.

class muonic.daq.connection.BaseDAQConnection(logger=None)[source]

Base DAQ Connection class.

Raises SystemError if serial connection cannot be established.

Parameters:logger (logging.Logger) – logger object
Raises:SystemError
_abc_cache = <_weakrefset.WeakSet object at 0x3218250>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x3224390>
_abc_negative_cache_version = 27
_abc_registry = <_weakrefset.WeakSet object at 0x32118d0>
get_serial_port()[source]

Check out which device (/dev/tty) is used for DAQ communication.

Raises OSError if binary ‘which_tty_daq’ cannot be found.

Returns:serial.Serial – serial connection port
Raises:OSError
read()[source]

Get data from the DAQ. Read it from the provided Queue.

Returns:None
write()[source]

Put messages from the inqueue which is filled by the DAQ

Returns:None
class muonic.daq.connection.DAQConnection(in_queue, out_queue, logger=None)[source]

Client connection with DAQ card

Parameters:
  • in_queue (multiprocessing.Queue) – queue for incoming data
  • out_queue (multiprocessing.Queue) – queue for outgoing data
  • logger (logging.Logger) – logger object
_abc_cache = <_weakrefset.WeakSet object at 0x3224410>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x3224450>
_abc_negative_cache_version = 27
_abc_registry = <_weakrefset.WeakSet object at 0x32243d0>
read()[source]

Get data from the DAQ. Read it from the provided Queue.

Returns:None
write()[source]

Put messages from the inqueue which is filled by the DAQ

Returns:None
class muonic.daq.connection.DAQServer(address='127.0.0.1', port=5556, logger=None)[source]

DAQ server

Raises DAQMissingDependencyError if zmq is not installed.

Parameters:
  • address (str) – address to listen on
  • port (int) – TCP port to listen on
  • logger (logging.Logger) – logger object
Raises:

DAQMissingDependencyError

_abc_cache = <_weakrefset.WeakSet object at 0x32244d0>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x3224510>
_abc_negative_cache_version = 27
_abc_registry = <_weakrefset.WeakSet object at 0x3224490>
read()[source]

Get data from the DAQ. Read it from the provided Queue.

Returns:None
serve()[source]

Runs the server

Returns:None
write()[source]

Put messages from the inqueue which is filled by the DAQ

Returns:None

muonic.daq.DAQSimulationConnection

This module provides a dummy class which simulates DAQ I/O which is read from the file “simdaq.txt”. The simulation is only useful if the software-gui should be tested, but no DAQ card is available

Provides a simple DAQ card simulation, so that software can be tested.

class muonic.daq.simulation.BaseDAQSimulationConnection(logger=None)[source]

Base class for a simulated connection to DAQ card.

Parameters:logger (logging.Logger) – logger object
_abc_cache = <_weakrefset.WeakSet object at 0x3205fd0>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x3211050>
_abc_negative_cache_version = 27
_abc_registry = <_weakrefset.WeakSet object at 0x3205ed0>
read()[source]

Simulate DAQ I/O.

Returns:None
class muonic.daq.simulation.DAQSimulation(logger, simulation_file=None)[source]

Simulates reading from and writing to DAQ card.

Parameters:
  • logger (logging.Logger) – logger object
  • simulation_file (str) – path to the simulation data file
DEFAULT_SIMULATION_FILE = '/afs/ifh.de/user/h/hpbretz/scripts/muonic_dev/muonic/muonic/daq/simdaq.txt'
LINES_TO_PUSH = 10
_physics()[source]

This routine will increase the scalars variables using predefined rates. Rates are drawn from Poisson distributions.

Returns:None
in_waiting()[source]

Simulate a busy DAQ.

Returns:bool
readline()[source]

Read dummy pulses from the simdaq file till the configured value is reached.

Returns:str – next simulated DAQ output
write(command)[source]

Trigger a simulated daq response with command.

Parameters:command (str) – Command to send (simulated) to the DAQ card
Returns:None
class muonic.daq.simulation.DAQSimulationConnection(in_queue, out_queue, logger=None)[source]

Simulated client connection to DAQ card.

Parameters:
  • in_queue (multiprocessing.Queue) – queue for incoming data
  • out_queue (multiprocessing.Queue) – queue for outgoing data
  • logger (logging.Logger) – logger object
_abc_cache = <_weakrefset.WeakSet object at 0x3211150>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x32111d0>
_abc_negative_cache_version = 27
_abc_registry = <_weakrefset.WeakSet object at 0x3211090>
read()[source]

Simulate DAQ I/O.

Returns:None
class muonic.daq.simulation.DAQSimulationServer(address='127.0.0.1', port=5556, logger=None)[source]

Simulated DAQ server.

Raises DAQMissingDependencyError if zmq is not installed.

Parameters:
  • address (str) – address to listen on
  • port (int) – TCP port to listen on
  • logger (logging.Logger) – logger object
Raises:

DAQMissingDependencyError

_abc_cache = <_weakrefset.WeakSet object at 0x3211310>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x3211390>
_abc_negative_cache_version = 27
_abc_registry = <_weakrefset.WeakSet object at 0x3211250>
read()[source]

Simulate DAQ I/O.

Returns:None
serve()[source]

Runs the server.

Returns:None

pyqt4 gui with muonic.gui

This package contains all gui relevant classes like dialogboxes and tabwidgets. Every item in the global menu is utilizes a “Dialog” class. The “Canvas” classes contain plot routines for displaying measurements in the TabWidget.

The gui of the programm, written with PyQt4

class muonic.gui.Application(daq, logger, opts)

The main application

Parameters:
about_menu()

Show a link to the online documentation.

Returns:None
add_widget(name, label, widget)

Adds widget to the store.

Raises WidgetWithNameExistsError if a widget of that name already exists and TypeError if widget is no subclass of QtGui.QWidget.

Parameters:
  • name (str) – widget name
  • label (str) – the tab label
  • widget (object) – widget object
Returns:

None

Raises:

WidgetWithNameExistsError, TypeError

advanced_menu()

Show a config dialog for advanced options, ie. gate width, interval for the rate measurement, options for writing pulse file and the write_daq_status option.

Returns:None
calculate_pulses()

Runs the calculate function of pulse widgets if they are active and pulses are available.

Returns:None
closeEvent(ev)

Is triggered when it is attempted to close the application. Will perform some cleanup before closing.

Parameters:ev (QtGui.QCloseEvent) – event
Returns:None
config_menu()

Show the channel config dialog.

Returns:None
get_channels_from_msg(msg)

Explicitly scan message for channel information.

Return True if found, False otherwise.

DC gives:

DC C0=23 C1=71 C2=0A C3=00

Which has the meaning:

MM - 00 -> 8bits for channel enable/disable, coincidence and veto

bits
7 6 5 4 3 2 1 0
veto veto coincidence coincidence channel3 channel2 channel1 channel0
Set bits for veto
00 - ch0 is veto
01 - ch1 is veto
10 - ch2 is veto
11 - ch3 is veto
Set bits for coincidence
00 - singles
01 - twofold
10 - threefold
11 - fourfold
Parameters:msg (str) – daq message
Returns:bool
get_configuration_from_daq_card()

Get the initial threshold and channel configuration from the DAQ card.

Returns:None
get_thresholds_from_msg(msg)

Explicitly scan message for threshold information.

Return True if found, False otherwise.

Parameters:msg (str) – daq message
Returns:bool
get_widget(name)

Retrieved a widget from the store.

Parameters:name (str) – widget name
Returns:object
have_widget(name)

Returns true if widget with name exists, False otherwise.

Parameters:name (str) – widget name
Returns:bool
help_menu()

Show a simple help dialog.

Returns:None
is_widget_active(name)

Returns True if the widget exists and is active, False otherwise

Parameters:name (str) – widget name
Returns:bool
manualdoc_menu()

Show the manual that comes with muonic in a pdf viewer.

Returns:None
open_muonic_data()

Opens the folder with the data files. Usually in $HOME/muonic_data

process_incoming()

This functions gets everything out of the daq.

Handles all the messages currently in the daq and passes the results to the corresponding widgets.

Returns:None
setup_menus()

Setup the menu bar and populate menus.

Returns:None
setup_plot_style()

Setup the plot style depending on screen size.

Returns:None
setup_tab_widgets()

Creates the widgets and adds tabs

Returns:None
sphinxdoc_menu()

Show the sphinx documentation that comes with muonic in a browser.

Returns:None
threshold_menu()

Shows thresholds dialog.

Returns:None
update_dynamic()

Update dynamic widgets.

Returns:None

muonic.gui.Application

Contains the “main” gui application. It Provides the MainWindow, which initializes the different tabs and draws a menu.

Provides the main window for the gui part of muonic

class muonic.gui.application.Application(daq, logger, opts)[source]

The main application

Parameters:
about_menu()[source]

Show a link to the online documentation.

Returns:None
add_widget(name, label, widget)[source]

Adds widget to the store.

Raises WidgetWithNameExistsError if a widget of that name already exists and TypeError if widget is no subclass of QtGui.QWidget.

Parameters:
  • name (str) – widget name
  • label (str) – the tab label
  • widget (object) – widget object
Returns:

None

Raises:

WidgetWithNameExistsError, TypeError

advanced_menu()[source]

Show a config dialog for advanced options, ie. gate width, interval for the rate measurement, options for writing pulse file and the write_daq_status option.

Returns:None
calculate_pulses()[source]

Runs the calculate function of pulse widgets if they are active and pulses are available.

Returns:None
closeEvent(ev)[source]

Is triggered when it is attempted to close the application. Will perform some cleanup before closing.

Parameters:ev (QtGui.QCloseEvent) – event
Returns:None
config_menu()[source]

Show the channel config dialog.

Returns:None
get_channels_from_msg(msg)[source]

Explicitly scan message for channel information.

Return True if found, False otherwise.

DC gives:

DC C0=23 C1=71 C2=0A C3=00

Which has the meaning:

MM - 00 -> 8bits for channel enable/disable, coincidence and veto

bits
7 6 5 4 3 2 1 0
veto veto coincidence coincidence channel3 channel2 channel1 channel0
Set bits for veto
00 - ch0 is veto
01 - ch1 is veto
10 - ch2 is veto
11 - ch3 is veto
Set bits for coincidence
00 - singles
01 - twofold
10 - threefold
11 - fourfold
Parameters:msg (str) – daq message
Returns:bool
get_configuration_from_daq_card()[source]

Get the initial threshold and channel configuration from the DAQ card.

Returns:None
get_thresholds_from_msg(msg)[source]

Explicitly scan message for threshold information.

Return True if found, False otherwise.

Parameters:msg (str) – daq message
Returns:bool
get_widget(name)[source]

Retrieved a widget from the store.

Parameters:name (str) – widget name
Returns:object
have_widget(name)[source]

Returns true if widget with name exists, False otherwise.

Parameters:name (str) – widget name
Returns:bool
help_menu()[source]

Show a simple help dialog.

Returns:None
is_widget_active(name)[source]

Returns True if the widget exists and is active, False otherwise

Parameters:name (str) – widget name
Returns:bool
manualdoc_menu()[source]

Show the manual that comes with muonic in a pdf viewer.

Returns:None
open_muonic_data()[source]

Opens the folder with the data files. Usually in $HOME/muonic_data

process_incoming()[source]

This functions gets everything out of the daq.

Handles all the messages currently in the daq and passes the results to the corresponding widgets.

Returns:None
setup_menus()[source]

Setup the menu bar and populate menus.

Returns:None
setup_plot_style()[source]

Setup the plot style depending on screen size.

Returns:None
setup_tab_widgets()[source]

Creates the widgets and adds tabs

Returns:None
sphinxdoc_menu()[source]

Show the sphinx documentation that comes with muonic in a browser.

Returns:None
threshold_menu()[source]

Shows thresholds dialog.

Returns:None
update_dynamic()[source]

Update dynamic widgets.

Returns:None
exception muonic.gui.application.WidgetWithNameExistsError[source]

Exception that gets raised if it is attempted to overwrite a widget reference that already exists.

muonic.gui.widgets

The functionality of the software

Provides the different physics widgets

class muonic.gui.widgets.BaseWidget(logger, parent=None)[source]

Base widget class

Parameters:
  • logger (logging.Logger) – logger object
  • parent – parent widget
active(value=None)[source]

Getter and setter for active state.

Parameters:value (bool or None) – value for the new state
Returns:bool
calculate(*args)[source]

Calculates data related to this widget.

Parameters:args
Returns:
daq_get_last_msg()[source]

Get the last DAQ message received by the parent, if present.

Returns:str or None
daq_put(msg)[source]

Send message to DAQ cards. Reuses the connection of the parent widget if present.

Returns True if operation was successful.

Parameters:msg (str) – message to send to the DAQ card
Returns:bool
finish()[source]

Gets called upon closing application. Implement cleanup routines like closing files here.

Returns:None
start()[source]

Perform setup here like resetting variables when the widget goes into active state

Returns:None
stop()[source]

Perform actions like saving data when the widget goes into inactive state

Returns:
update(*args)[source]

Update widget contents.

Parameters:args
Returns:None
class muonic.gui.widgets.DAQWidget(logger, filename, parent=None)[source]

Shows the DAQ message log. The message log can be written to a file. This widget has a command line to issue DAQ commands.

Parameters:
  • logger (logging.Logger) – logger object
  • filename (str) – filename for the rate data file
  • parent – parent widget
_write_to_file(msg)[source]

Write the “RAW” file

Parameters:msg (str) – daq message
Returns:None
finish()[source]

Cleanup, close and rename raw file

Returns:None
on_file_clicked()[source]

Save the raw DAQ data to a automatically named file

Returns:None
on_hello_clicked()[source]

Send a message to the DAQ card

Returns:None
update()[source]

Update daq msg log

Returns:None
class muonic.gui.widgets.DecayWidget(logger, filename, pulse_extractor, parent=None)[source]

Shows the muon decay plot

Parameters:
  • logger (logging.Logger) – logger object
  • filename (str) – filename for the rate data file
  • pulse_extractor (muonic.analysis.analyzer.PulseExtractor) – pulse extractor object
  • parent – parent widget
calculate(pulses)[source]

Trigger muon decay

Parameters:pulses (list) – extracted pulses
Returns:None
finish()[source]

Cleanup, close and rename decay file

Returns:None
on_checkbox_clicked()[source]

Starts or stops the muon decay check depending on checkbox state

Returns:None
on_fit_clicked()[source]

Fit the muon decay histogram

Returns:None
on_fit_range_clicked()[source]

Adjust the fit range

Returns:None
set_previous_coincidence_times(time_03, time_02)[source]

Sets the previous coincidence times obtained from the DAQ card

Parameters:
  • time_03 (str) – time 03
  • time_02 (str) – time 03
Returns:

start()[source]

Start check for muon decay

Returns:None
stop()[source]

Stop check for muon decay

Returns:None
update()[source]

Update widget

Returns:None
class muonic.gui.widgets.GPSWidget(logger, parent=None)[source]

Shows GPS information

Parameters:
  • logger (logging.Logger) – logger object
  • parent – parent widget
GPS_DUMP_LENGTH = 13
_extract_gps_info(line, strip_string)[source]

Extract GPS info from ‘line’ and strip away ‘strip_string’.

Parameters:
  • line (int) – line number of gps output
  • strip_string (str) – string to strip away
Returns:

str

on_refresh_clicked()[source]

Display/refresh the GPS information

Returns:None
update()[source]

Readout the GPS information and display it in the tab.

Returns:bool
class muonic.gui.widgets.PulseAnalyzerWidget(logger, pulse_extractor, parent=None)[source]

Provides a widget which is able to show a plot of triggered pulses.

Parameters:
calculate(pulses)[source]

Calculates the pulse widths.

Parameters:pulses (list) – extracted pulses
Returns:None
on_checkbox_clicked()[source]

Starts or stops the pulse analyzer depending on checkbox state

Returns:None
start()[source]

Starts the pulse analyzer

Returns:None
stop()[source]

Stops the pulse analyzer

Returns:None
update()[source]

Update plot canvases

Returns:None
class muonic.gui.widgets.RateWidget(logger, filename, parent=None)[source]

Widget for displaying a rate plot

Parameters:
  • logger (logging.Logger) – logger object
  • filename (str) – filename for the rate data file
  • parent – parent widget
SCALAR_BUF_SIZE = 5
calculate()[source]

Get the rates from the observed counts by dividing by the measurement interval.

Returns True if last DAQ message was valid and could be processed.

Returns:bool
extract_scalars_from_message(msg)[source]

Extracts the scalar values for channel 0-3 and the trigger channel from daq message

Parameters:msg – DAQ message
Type:str
Returns:list of ints
finish()[source]

Cleanup, close and rename data file

Returns:None
new_scalar_buffer()[source]

Return new zeroed list of self.SCALAR_BUF_SIZE

Returns:list of int
query_daq_for_scalars()[source]

Send command to DAQ to query for scalars.

Returns:None
setup_layout()[source]

Sets up all the layout parts of the widget

Returns:None
start()[source]

Starts the rate measurement and opens the data file.

Returns:None
stop()[source]

Stops the rate measurement and closes the data file.

Returns:None
update()[source]

Display newly available data

Returns:None
update_fields(channel, enabled, disable_only=False)[source]

Update table fields for a channel, channel 4 is the trigger channel.

Parameters:
  • channel (int) – the channel index
  • enabled (bool) – enable fields
  • disable_only (bool) – do not set text if ‘enabled’ is True
Returns:

None

update_info_field(key, text=None, enable=True)[source]

Set text of info field with ‘key’ or trigger enable state if ‘text’ is None

Parameters:
  • key (str) – the key of the info field
  • text (str) – the text to set
  • enable (bool) – enable
Returns:

None

class muonic.gui.widgets.StatusWidget(logger, parent=None)[source]

Provide a widget which shows the status information of the DAQ and the software.

Parameters:
  • logger (logging.Logger) – logger object
  • parent – parent widget
TEXT_UNSET = 'not set yet - click on Refresh.'
_update_daq_stats()[source]

Gather daq status information.

Returns:None
_update_muonic_stats()[source]

Gather muonic status information.

Returns:None
on_refresh_clicked()[source]

Refresh the status information

Returns:None
update()[source]

Fill the status information in the widget.

Returns:None
class muonic.gui.widgets.VelocityWidget(logger, filename, pulse_extractor, parent=None)[source]

Shows the muon velocity plot

Parameters:
calculate(pulses)[source]

Trigger muon flight

Parameters:pulses (list) – extracted pulses
Returns:None
finish()[source]

Cleanup, close and rename decay file

Returns:None
on_checkbox_clicked()[source]

Starts or stops detecting muons depending on checkbox state

Returns:None
on_fit_clicked()[source]

Fit the muon velocity histogram

Returns:None
on_fit_range_clicked()[source]

Adjust the fit range

Returns:None
start()[source]

Start detecting muons

Returns:None
stop()[source]

Stop detecting muons

Returns:None
update()[source]

Update widget

Returns:None

muonic.gui.dialogs

Provide the dialog fields for user interaction

class muonic.gui.dialogs.AdvancedDialog(gate_width=100, time_window=5.0, write_daq_status=False)[source]

Dialog to set advanced configuration options.

Parameters:
  • gate_width (float) – the gate width of the time window
  • time_window (float) – the readout interval
  • write_daq_status (bool) – write DAQ status to raw file
class muonic.gui.dialogs.BaseDialog(window_title)[source]

Abstract base class for all dialogs

Parameters:window_title (str) – the title of the window
DEFAULT_ITEM_LABELS = ['Chan0', 'Chan1', 'Chan2', 'Chan3']
button_box(left=80, top=900)[source]

Create a custom button for cancel/apply.

Parameters:
  • left (int) – left offset
  • top (int) – top offset
choice_group(object_name='object', label='label', checkable=False, checked=False, radio=False, checked_items=None, item_labels=None, left=20)[source]

Create a group of choices.

Parameters:
  • object_name (str) – the base object name for the checkbox group. checkboxes get named ‘object_name_%d’ where %d is the checkboxes’ index
  • label (str) – the label of the checkbox group
  • checkable (bool) – determined if the group box itself is checkable
  • checked (bool) – initial state of the checkable group box
  • radio (bool) – create radio buttons instead of check boxes
  • checked_items (list of int) – items that are checked initially
  • item_labels (list) – labels of the checkboxes/radio buttons
  • left (int) – left offset
get_widget_value(object_name)[source]

Get the value of a widget by its object name.

Parameters:object_name – the object name of the widget
Type:str
Returns:mixed
class muonic.gui.dialogs.ConfigDialog(channel_states=[True, True, True, True], coincidence_states=[True, False, False, False], veto_enabled=False, channel_veto_states=[False, False, False])[source]

Dialog to set the configuration

Parameters:
  • channel_states (list of bool) – activation states of the channels
  • coincidence_states (list of bool) – coincidence states
  • veto_enabled (bool) – enable veto group
  • channel_veto_states (list of bool) – channel veto
DEFAULT_CHANNEL_STATES = [True, True, True, True]
DEFAULT_CHANNEL_VETO_STATES = [False, False, False]
DEFAULT_COINCIDENCE_STATES = [True, False, False, False]
class muonic.gui.dialogs.DecayConfigDialog[source]

Settings for the muondecay

class muonic.gui.dialogs.FitRangeConfigDialog(upper_lim=None, lower_lim=None, dimension='')[source]

Dialog to configure the fit range

Parameters:
  • upper_lim – upper limits for the fit
  • lower_lim – lower limits for the fit
  • dimension (str) – suffix
Type:

tuple of float

Type:

tuple of float

class muonic.gui.dialogs.HelpDialog[source]

Help Dialog for the DAQ commands

class muonic.gui.dialogs.ThresholdDialog(thresholds)[source]

Dialog to adjust the thresholds

Parameters:thresholds (list of int) – the threshold for the four channels
class muonic.gui.dialogs.VelocityConfigDialog[source]

Dialog to configure the muon velocity

muonic.gui.plot_canvases

Provides the canvases for plots in muonic

class muonic.gui.plot_canvases.BaseHistogramCanvas(parent, logger, binning, hist_color='b', **kwargs)[source]

A base class for all canvases with a histogram

Parameters:
  • parent – parent widget
  • logger (logging.Logger) – logger object
  • binning (list or tuple or numpy.ndarray) – the binning to use for this canvas
  • hist_color (str) – the color of the histogram
  • kwargs – additional keyword arguments
  • kwargs – dict
show_fit(bin_centers, bincontent, fitx, decay, p, covar, chisquare, nbins)[source]

Plot the fit onto the diagram

Parameters:
  • bin_centers – bin centers
  • bincontent – bincontents
  • fitx (numpy.ndarray) – the fit
  • decay (function) – decay function
  • p (list) – fit parameters
  • covar (matrix) – covariance matrix
  • chisquare (float) – chi-squared
  • nbins (int) – number of bins
Returns:

None

update_plot(data)[source]

Update the plot

Parameters:data (list of lists) – the data to plot
Returns:None
class muonic.gui.plot_canvases.BasePlotCanvas(parent, logger, ymin=0, ymax=10, xmin=0, xmax=10, xlabel='xlabel', ylabel='ylabel', grid=True, title=None, spacing=(0.1, 0.9))[source]

Base class for plot canvases

Parameters:
  • parent – the parent widget
  • logger (logging.Logger) – logger object
  • ymin (float) – minimum y-value
  • ymax (float) – maximum y-value
  • xmin (float) – minimum x-value
  • xmax (float) – maximum x-value
  • xlabel (str) – label of the x-axis
  • ylabel (str) – label of the y-axis
  • grid (bool) – draw grid
  • spacing (tuple) – left and right spacing of the subplots
update_plot(*args)[source]

Instructions to update the plot. Needs to be implemented in subclasses.

Returns:None
class muonic.gui.plot_canvases.LifetimeCanvas(parent, logger, binning=(0, 10, 21))[source]

A simple histogram for the use with mu lifetime measurement

Parameters:
  • parent – parent widget
  • logger (logging.Logger) – logger object
  • binning (list or tuple or numpy.ndarray) – the binning to use for this canvas
class muonic.gui.plot_canvases.PulseCanvas(parent, logger)[source]

Canvas to display pulses

Parameters:
  • parent – parent widget
  • logger (logging.Logger) – logger object
update_plot(pulses)[source]
class muonic.gui.plot_canvases.PulseWidthCanvas(parent, logger, hist_color='r', title=None)[source]

A simple histogram for the use with pulse width measurement

Parameters:
  • parent – parent widget
  • logger (logging.Logger) – logger object
  • hist_color (str) – the color of the histogram
update_plot(data)[source]
class muonic.gui.plot_canvases.ScalarsCanvas(parent, logger, max_length=40)[source]

A plot canvas to display scalars

Parameters:
  • parent – parent widget
  • logger (logging.Logger) – logger object
  • max_length (int) – maximum number of values to plot
CHANNEL_COLORS = ['y', 'm', 'c', 'b']
DEFAULT_CHANNEL_CONFIG = [True, True, True, True]
TRIGGER_COLOR = 'g'
reset(show_pending=False)[source]

Reset all cached plot data

Parameters:show_pending (bool) – indicate pending state
Returns:None
update_plot(data, show_trigger=True, enabled_channels=[True, True, True, True])[source]

Update plot

Parameters:
  • data (list of lists) – plot data
  • show_trigger (bool) – show trigger in plot
  • enabled_channels (list of bool) – enabled channels
Returne:

None

class muonic.gui.plot_canvases.VelocityCanvas(parent, logger, binning=(0.0, 30, 25))[source]

A simple histogram for the use with mu velocity measurement

Parameters:
  • parent – parent widget
  • logger (logging.Logger) – logger object
  • binning (list or tuple or numpy.ndarray) – the binning to use for this canvas

analyis package muonic.analysis

scripts and classes used for data analysis

muonic.analysis.analyzer

Transformation of ASCII DAQ data. Combination of Pulses to events as well as implementation of software triggers for the muon decay and the muon velocity measurement

Get the absolute timing of the pulses by use of the gps time Calculate also a non hex representation of leading and falling edges of the pulses.

class muonic.analysis.analyzer.PulseExtractor(logger, filename)[source]

Get the pulses out of a daq line. Speed is important here. If a pulse file is given, all the extracted pulses will be written into it.

Parameters:
  • logger (logging.Logger) – logger object
  • filename (str) – filename of the pulse file
_calculate_edges(line, counter_diff=0)[source]

get the leading and falling edges of the pulses Use counter diff for getting pulse times in subsequent lines of the trigger flag

Parameters:
  • line (list) – DQ message split on whitespaces
  • counter_diff (int) – counter difference
Returns:

None

_get_evt_time(time, correction, trigger_count, one_pps)[source]

Get the absolute event time in seconds since day start If gps is not available, only relative event time based on counts is returned

Parameters:
  • time – event time
  • correction
  • trigger_count
  • one_pps
Returns:

float

_order_and_clean_pulses()[source]

Remove pulses which have a leading edge later in time than a falling edge and do a bit of sorting Remove also single leading or falling edges NEW: We add virtual falling edges!

Returns:dict of lists
extract(line)[source]

Analyze subsequent lines (one per call) and check if pulses are related to triggers For each new trigger, return the set of pulses which belong to that trigger, otherwise return None

Parameters:line (str) – DAQ message
Returns:tuple
finish()[source]

Cleanup, close and rename pulse file

Returns:None
write_pulses(write_pulses)[source]

Enables or disables writing pulses to file.

Parameters:write_pulses (bool) – write pulses to file
Returns:None
class muonic.analysis.analyzer.DecayTriggerThorough(logger)[source]

Trigger on a set of extracted pulses and look for decayed muons.

We demand a second pulse in the same channel where the muon got stuck. Should operate for a 10mu sec trigger window.

Parameters:logger (logging.Logger) – logger object
trigger(trigger_pulses, single_channel=2, double_channel=3, veto_channel=4, min_decay_time=0, min_single_pulse_width=0, max_single_pulse_width=12000, min_double_pulse_width=0, max_double_pulse_width=12000)[source]

Trigger on a certain combination of single and double pulses

Parameters:
  • trigger_pulses (list) – detected pulses
  • single_channel (int) – channel index
  • double_channel (int) – channel index
  • veto_channel (int) – channel index
  • min_decay_time (int) – minimum decay time
  • min_single_pulse_width (int) – minimum single pulse width
  • max_single_pulse_width (int) – maximum single pulse width
  • min_double_pulse_width (int) – minimum double pulse width
  • max_double_pulse_width (int) – maximum double pulse width
Returns:

int or None

class muonic.analysis.analyzer.VelocityTrigger(logger)[source]

A velocity “trigger”, so that czts can be defined

Parameters:logger (logging.Logger) – logger object
trigger(pulses, upper_channel=1, lower_channel=2)[source]

Time difference will be calculated t(upper_channel) - t(lower_channel)

Parameters:
  • pulses (list) – detected pulses
  • upper_channel (int) – index of the upper channel
  • lower_channel (int) – index of the lower channel
Returns:

float or None

muonic.analysis.fit

Provide a fitting routine

Script for performing a fit to a histogramm of recorded time differences for the use with QNet

muonic.analysis.fit.fit(bincontent=None, binning=(0, 10, 21), fitrange=None)[source]

Fit function

Parameters:
  • bincontent
  • binning
  • fitrange
Returns:

muonic.analysis.fit.gaussian_fit(bincontent, binning=(0, 2, 10), fitrange=None)[source]

Guassian fit function

Parameters:
  • bincontent
  • binning
  • fitrange
Returns: