This module provides a WHIZARD Python interface using the C API of WHIZARD.
Warning
-------
Do not instantiate several Whizard instances.
See also
--------
Manual : API section
api.nw
Note
----
We implement the different WHIZARD handles, i.e. handling WHIZARD or event samples, as class variables.
Therefore, different instances of WhizardSample or Whizard share a common handle object.
Furthermore, the Python interface makes heavy use of UTF-8 encoded strings and goes all the way to ensure that these strings are converted to binary strings (including to append a null character), i.e. ASCII-based, before handing them to the C API.
Example
-------
>>> import whizard
>>> wz = whizard.Whizard()
>>> wz.options('--model', 'sm')
"""
fromcpythoncimportarray
cimportcwhizard
importarray
cdefclassWhizardSample:
"""
WHIZARD event stream sampler.
Provides access to WHIZARD's internal stream of event samples.
Access to the event stream is granted either indirectly as Python iterator
or directly using the WHIZARD API.
Attributes
----------
_c_sample : cwhizard.sample_handle_t
WHIZARD Sample Handler.
_begin : int
Start of event stream iterator.
_end : int
End of event stream iterator.
_it : int
Current status of event stream iterator.
Methods
-------
__iter__
Returns itself as an iterator object.
__next__
Implement iterator and return current iterator index.
open
Open event stream.
next_event
Iterate and access next event.
close
Close event stream and destroy object.
get_event_index
Returns the current event index with regard to WHIZARD.
get_process_index
Returns the current process index with regard to WHIZARD.
get_process_id
Returns the process id as defined by the process command.
get_fac_scale
Returns the factorization scale.
get_alpha_s
Returns alpha_s.
get_weight
Returns the event weight, among others, includes flux factor and phasespace weight.
get_sqme
Returns the squared matrix element of the event.
Examples
--------
The sample class provides itself as an iterator:
>>> sample = wz.new_sample("process_name_1")
>>> for it in sample:
>>> idx = sample.get_event_index()
>>> # [...]
The direct approach using the WHIZARD API looks like: