Accessing the NuWa Object from a Job Module

From Daya Bay
Jump to navigation Jump to search
Offline Documentation: [Offline Category] [FAQ] [Howto] [Reference] [Manual]

Offline Documentation
This article is part
of the Offline Documentation
Other pages...

Offline Category
How Tos
Getting Started
Software Installation

See also...

General Help on this Wiki

You can access the main object that is at the heart of from a Job Option Module (JOM).


The program is actually very trivial. It imports a single main() function from DybPython.Control and calls it. This function is also very short as it delegates everything to an instance of the DybPython.Control.NuWa class. This instance is available to any Job Module via

from DybPython.Control import nuwa

Most things in this object should not be changed, but it is a way to read and modify the overall configuration.

Context of Use

Technically A Job Option Module can import the nuwa object at any place in its code. However, the module should be written with an understanding of how the nuwa object interact with the module itself. What the JOM wants to do depends on where it is best to access the nuwa object.

At top level

The top-level code of a JOM is executed when the module is imported by the nuwa object. This is after command line flags have been parsed but before any down-stream JOMs are imported and before input files are determined.

In configure()

The optional configure() method of a JOM is called just after all JOMs have been imported.

In run()

The optional run() method of a JOM is called after all JOMs are configured and Gaudi has moved from the Configuration state to the running state, but just before any algorithms are executed.


Some examples of how the nuwa object might be used.

Template:Fixme:Note, these examples may not be tested, so take them with a grain of salt

Rudimentary example script

A meta-configuration module

It is possible to bundle command line arguments into a JOM. For example one might do: -m "MetaConfig 42"

where the "MetaConfig" module will interpret "42" to mean some configuration.

Adding modules

One example would be to add some modules that would otherwise be on the command line. They can only be added after our "MetaConfig" module and must be done at top-level. Something like the following:

from DybPython.Control import nuwa
nuwa.opts.module.insert(nuwa.opts.module.index("MetaConfig 42"),"SomeOtherModule -and its args")

Getting the number of requested executions

It should be possible to do this in any context.

nexecs = nuwa.opts.executions

Setting the run number or number of executions

The run number and the number of execution cycles can be specified in a JOM

       nuwa.opts.executions = nexec = runnum 

Setting the output

An output file can be specified as

       nuwa.opts.output_streams['default'] = rootfn

Note: This only works if the -o or -O option is specified in the original command line (i.e., -o some.file ). This is because there is no default output file.

Determine if AES will be used

if nuwa.use_AES: ...

Check for non-default detector

if nuwa.opts.detector:
   print 'Non-standard detector is',nuwa.opts.detector

Setting the detector geometry

You can only do this on the original command line. Not in a JOM.

Offline Software Documentation: [Offline Categories] [FAQ] [Offline Manual Category]