Professor is hosted by Hepforge, IPPP Durham

Changes between Version 1 and Version 2 of MiniManual


Ignore:
Timestamp:
Mar 17, 2008, 1:50:17 PM (10 years ago)
Author:
eike
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MiniManual

    v1 v2  
    11= Professor !MiniManual =
    2 This page shows you how to put the different parts of Professor together. An example program is in the SVN repository: source:trunk/useitall.py
     2This page holds links/explains which part of the code to use for single tasks.
     3Example programs are in SVN: source:trunk/examples/
    34
    45[[PageOutline]]
    56
    6 == Loading XML Files ==
    7 This is done using the getTuningData function from source:trunk/professor/rivetreader.py.
     7== Single Tasks ==
     8
     9This section describes how to get parameter estimates. The code presented is based on source:trunk/examples/usenewmin.py:177
     10
     11=== 1. Load configuration and parse command line ===
     12For more information see the CentralConfiguration page. We give the script a
     13option ''datadir'' which sets the path where the ''mc/'' and ''ref/''
     14directories lie. This option can be set on the command line with ''--datadir''.
     15{{{
     16#!python
     17from professor.tools.config import Config
     18conf = Config()
     19conf.initModule('example',
     20        {'datadir' : ('./', None, True, None)})
     21conf.parseCommandline()
     22}}}
     23
     24=== 2. Load the AIDA-XML files ===
     25We use !TuningData objects to store the MC and reference data. It's also
     26building lists with pairs of reference bin and interpolations.
     27
     28To create a !TuningData object from a directory tree, there is a factory
     29funtion getTuningData in source:trunk/professor/rivetreader.py .
     30
     31Example:
     32{{{
     33#!python
     34from professor.rivetreader import getTuningData
     35mcdir = os.path.join(conf.getOption('example', 'datadir'), 'mc')
     36refdir = os.path.join(conf.getOption('example', 'datadir'), 'ref')
     37tundat = getTuningData(refdir, mcdir)
     38}}}
     39
     40=== 3. Build a minimization object and run a minimization ===
     41To minimize in professor, we need a minimizer, i.e. a wrapper around
     42external minimization packages. Supported are Scipy.optimize.fmin_powell
     43(!ScipyMinimizer in source:trunk/professor/minimize/scipyminimizer.py) and
     44Minuit (!MinuitMinimizer  in
     45source:trunk/professor/minimize/minuitminimizer.py). By default the minimize
     46sub-package exports !MinuitMinimizer as ''Minimizer'' with
     47!ScipyMinimizer as fall back. All minimizers take a !TuningData instance for
     48creation. From this it gets the data to minimize on.
    849
    950
     51It needs a !TuningData
     52 The minimizer wraps around the !TuningData. To start
     53a minimization you'll use the ''guessMinimum'' method. It takes 4 arguments:
     54 1. A string deciding how to determine the start point for the
     55 minimization. N.B. Minuit doesn't actually use this. Possible values are:
     56 center, minmc, random .
     57 2. A list of strings with the run numbers to use for this minimization. If
     58 the list is empty or ''None'', all runs are used.
     59 3. A list of with the observable names to use in this minimizations. If
     60 the list is empty or ''None'', all runs are used.
     61 4. A list with ''selection functions''. With this functions you can exclude
     62 bins on a per-bin-level. At the moment only one selection function is
     63 implemented (see: source:trunk/professor/minimize/selectionfunctions.py)
    1064
    11 == Central Configuration ==
     65The return value is a !MinimizationResult.
     66
     67Example:
     68{{{
     69#!python
     70from professor.minimize import Minimizer
     71from professor.minimize import selectionfunctions
     72# set up data selection for the minimization
     73# use all observables
     74obs = []
     75# use all runs
     76runs = []
     77# use the only selection function we have
     78selfuncs = [selectionfunctions.OmitEmpty()]
     79
     80minim = Minimizer(tundat)
     81result = minim.guessMinimum('center', obs=obs, runs=runs, selfuncs=selfuncs)
     82}}}
     83
     84=== 4. Store a list of results ===
     85If you want to store minimization results, you can use the !ResultList from
     86source:trunk/professor/minimize/baseminimizer.py . It's a list subclass that
     87allows writing/reading xml files.
     88
     89Example:
     90{{{
     91#!python
     92# create empty list
     93results = ResultList()
     94
     95# adding a MinimizationResult:
     96results.append(minresult)
     97
     98# writing filled list to xml file:
     99results.write("path/to/results.xml")
     100
     101# loading from xml file:
     102results = ResultList.fromXML("path/to/results.xml")
     103}}}
     104
     105== Other ==
     106=== Loading AIDA XML Files ===
     107This is done using the getTuningData function from source:trunk/professor/rivetreader.py. This function returns a !TuningData object.
     108
     109=== Central Configuration ===
    12110Information how to use the central configuration and logging module can be found on the wiki page [wiki:CentralConfiguration Central Configuration]
    13111
    14 == Parameter Handling ==
     112=== Parameter Handling ===
    15113Go [wiki:ParameterHandling here] for more information.
     114