mcstasscript.instrument_diagnostics.beam_diagnostics.BeamDiagnostics

mcstasscript.instrument_diagnostics.beam_diagnostics.BeamDiagnostics

class mcstasscript.instrument_diagnostics.beam_diagnostics.BeamDiagnostics(instr)
__init__(instr)

Diagnostics instrument object with related capabilities

The diagnostics instrument takes a copy of an instrument object and can modify this version in ways relevant for diagnostics of the instrument. It can remove use of PREVIOUS and correct the use of target_index to make it safe to add additional components without altering the instrument. It carries it’s own settings and parameters that wont impact the original instrument. The diagnostics instrument can be reset to the original state, and will have settings and parameters applied again.

Parameters:

instrMcCode_instr object

Instrument which needs a diagnostics copy

Methods

__init__(instr)

Diagnostics instrument object with related capabilities

add_flag(flag)

Adds flag to be monitored in event list, maximum of 3 allowed

add_monitor(point, comp_instance)

Adds monitor_nD event monitor to diagnostics instrument for given point

add_monitors()

Adds monitors as specified by list of diagnostics points

add_point([before, after, rays])

Adds point in which the beam is investigated with given number of rays

add_view(axis1[, axis2, bins, same_scale])

Add a view with one or two axes that will be shown at all diagnostics points

clear_flags()

Clears flags

clear_points()

Remove all points

clear_views()

Clear list of views

correct_target_index()

Corrects target_index based on original instrument

plot()

Plots the generated data for all points with all views

read_data()

Reads the generated data and organizes it as event plotter instances

remove_point([before, after])

Removes a point from the list

remove_previous_use()

Replaces use of PREVIOUS with direct references

reset_instr()

Resets instrument to original state, with new pars and settings

run()

Runs diagnostics with all included points

set_parameters(**kwargs)

Set parameters as in instrument object

settings(**kwargs)

Apply settings as in an instrument object

show_flags()

Shows list of current flags

show_parameters()

Show parameters as on instrument object

show_points()

Shows current diagnostics points

show_settings()

Show settings of diagnostics instrument

show_views()

Shows views

add_flag(flag)

Adds flag to be monitored in event list, maximum of 3 allowed

The flag must be available in declared variables or user vars.

Parameters:

flag: str

str with variable name to be recorded to event dataset

add_monitor(point, comp_instance)

Adds monitor_nD event monitor to diagnostics instrument for given point

Needs point and component instance that match

Parameters:

pointDiagnosticsPoint

Point for which monitor should be added

comp_instanceComponent

Component instance relative to which the monitor should be placed

add_monitors()

Adds monitors as specified by list of diagnostics points

The method sorts the points with the component sequence so the resulting plots are in the correct order.

add_point(before=None, after=None, rays=50000)

Adds point in which the beam is investigated with given number of rays

Can be before and/or after components, this is chosen by using the appropriate keyword argument.

Parameters:

beforestr or component instance

Reference to component beam should be monitored just before

afterstr or component instance

Reference to component beam should be monitored just after

raysint or “all”

Number of rays to record, either integer or the string “all”

add_view(axis1, axis2=None, bins=100, same_scale=False, **kwargs)

Add a view with one or two axes that will be shown at all diagnostics points

Parameters: axis1: str

Name of parameter for first axis

axis2: str

Name of parameter for second axis

binsint or list of length 2

Number of bins for histogram (can be list of length 2 for 2D)

same_scalebool

Select if the same scale should be ensured for all points with this view

clear_flags()

Clears flags

clear_points()

Remove all points

clear_views()

Clear list of views

plot()

Plots the generated data for all points with all views

read_data()

Reads the generated data and organizes it as event plotter instances

remove_point(before=None, after=None)

Removes a point from the list

Specify whether the point in question is before or after the given component name or instance by using the appropriate keyword argument

Parameter:

beforestr or component instance

Name or component instance for which point before should be removed

afterstr or component instance

Name or component instance for which point after should be removed

run()

Runs diagnostics with all included points

Saves data in data attribute and the resulting instrument can be found in the instr attribute

show_flags()

Shows list of current flags

show_points()

Shows current diagnostics points

show_views()

Shows views