AuroraMaster

From Charm-Tau Detector
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
= Introduction =
 
= Introduction =
  
The AuroraMaster package contains python classes providing high level interfaces to the Aurora algorithms and tools. To begin working with AuroraMaster you need to instantiate the AuroraMaster class:
+
The AuroraMaster package contains python classes providing high level interfaces to the Aurora algorithms and tools. First thing you need to do is instantiate an AuroraMaster object:
  
 
  from AuroraMaster.auroramaster import AuroraMaster
 
  from AuroraMaster.auroramaster import AuroraMaster
 
  am = AuroraMaster(purpose='parsim', olvl='info')
 
  am = AuroraMaster(purpose='parsim', olvl='info')
  
The first argument specifies purpose of the job option. Possible values are: <code>'parsim'</code>, <code>'fullsim'</code>, <code>'evtgen'</code>, and <code>'analysis'</code>. AuroraMaster initializes
+
The first argument specifies purpose of the job option. Possible values are:
Aurora services corresponding to the job option purpose. The second argument specifies general output level (<code>'debug'</code> or <code>'info'</code>).
+
  
A job option is formed by a stack of predefined components. Each component has corresponding method in the AuroraMaster class. Let's begin with an example. The following code snippet is a complete job option for event generation and saving them to ROOT file:
+
* <code>'parsim'</code>
 +
* <code>'fullsim'</code>
 +
* <code>'evtgen'</code>
 +
* <code>'analysis'</code>
 +
 
 +
An AuroraMaster object initializes Aurora services corresponding to the job option purpose. The second argument specifies general output level:
 +
 
 +
* <code>'debug'</code>
 +
* <code>'info'</code>
 +
 
 +
A job option must contain only one AuroraMaster object. A job option logic is formed by stacking the predefined components. Each component has corresponding method in the AuroraMaster class. The following example shows a ready-to-use job option for event generation with [https://evtgen.hepforge.org/ EvtGen] and saving them to file in SCT EDM format:
  
 
  from AuroraMaster.auroramaster import AuroraMaster, AuroraConfig
 
  from AuroraMaster.auroramaster import AuroraMaster, AuroraConfig
 
  # Instantiate AuroraMaster
 
  # Instantiate AuroraMaster
 
  am = AuroraMaster('evtgen', 'info')
 
  am = AuroraMaster('evtgen', 'info')
  # Plug EvtGen generator with specified root particle and user's decay file
+
  # Plug in component for EvtGen
  evtgenCfg = {
+
  evtgenCfg = AuroraConfig({
 
     'root' : 'psi(3770)',
 
     'root' : 'psi(3770)',
 
     'dec': './dkpi.dec'
 
     'dec': './dkpi.dec'
  }
+
  })
 
  am.add_evtgen(cfg=evtgenCfg)
 
  am.add_evtgen(cfg=evtgenCfg)
  # Plug  
+
  # Plug in component for SCT EDM output
  edmoutputCfg = {
+
  edmoutputCfg = AuroraConfig{
 
     'filename': 'parsim.root',
 
     'filename': 'parsim.root',
 
     'commands': ['keep *'],
 
     'commands': ['keep *'],
  }
+
  })
 
  am.add_edmo(cfg=edmoutputCfg)
 
  am.add_edmo(cfg=edmoutputCfg)
 
  am.run(evtmax=10**4)
 
  am.run(evtmax=10**4)
 +
 +
 +
The <code>run</code> method should be invoked at the end.
 +
 +
= Components =
 +
 +
An AuroraMaster class method <code>add_{component}</code> receives two parameters:
 +
 +
* <code>cfg</code> - an object of the <code>AuroraConfig</code> class. Default value it None
 +
* <code>json</code> - string path to a json file with configuration. Default value it None
 +
 +
A component set up is dome with three steps:
 +
 +
# Default configuration
 +
# Configuration with passed json file. It overwrites any subset of default parameters. Parameters not specified in json keep the default values
 +
# Configuration with <code>AuroraConfig</code> object. It overrides values of the specified parameters leaving other parameters unchanged
 +
 +
If some parameter is specified in both json file and <code>AuroraConfig</code> object, the final value is taken from the <code>AuroraConfig</code> object.
 +
 +
= AuroraConfig =
 +
 +
The AuroraConfig is a data structure very similar to python dict. It can contain nested lists, dicts and other AuroraConfig objects. An example below shows configuration of simple parametric simulation:
 +
 +
parsimCfg = AuroraConfig({
 +
    'Tracker' : {
 +
        'deteff': 0.99,
 +
        'ptcut': 50e-3,
 +
        'bfield': 1.5,
 +
        'maxCosth': np.cos(10./180. * np.pi),
 +
        'momentumSampler' : {
 +
            'mean' : np.zeros(3),
 +
            'covar': np.diag(np.ones(3)) * 1.e-3**2
 +
        },
 +
        'vertexSampler' : {
 +
            'mean' : np.zeros(3),
 +
            'covar': np.diag(np.ones(3)) * 1.e-3**2
 +
        }
 +
    },
 +
    'PID' : {
 +
        'eff' : 0.95,
 +
        'sigmaKpi' : 6.,
 +
        'sigmaMupi' : 4.,
 +
        'sigmaKp' : 3.,
 +
        'sigmaE' : 3.,
 +
    },
 +
    'Calorimeter' : {
 +
        'deteff': 1.0,
 +
        'energyThreshold' : 15e-3,
 +
        'maxCosth' : np.cos(10./180. * np.pi),
 +
        'sampler' : {
 +
            'mean' : np.zeros(3),
 +
            'covar': (np.diag(np.ones(3)) * 1.e-2**2).ravel()
 +
        }
 +
    }
 +
})
 +
 +
An AuroraConfig object can be serialized to and serialized from json with methods <code>to_json</code> and <code>from_json</code>. It is recommended to create json files with configuration using this interface, and not create json manualy.

Revision as of 19:50, 3 February 2021

Introduction

The AuroraMaster package contains python classes providing high level interfaces to the Aurora algorithms and tools. First thing you need to do is instantiate an AuroraMaster object:

from AuroraMaster.auroramaster import AuroraMaster
am = AuroraMaster(purpose='parsim', olvl='info')

The first argument specifies purpose of the job option. Possible values are:

  • 'parsim'
  • 'fullsim'
  • 'evtgen'
  • 'analysis'

An AuroraMaster object initializes Aurora services corresponding to the job option purpose. The second argument specifies general output level:

  • 'debug'
  • 'info'

A job option must contain only one AuroraMaster object. A job option logic is formed by stacking the predefined components. Each component has corresponding method in the AuroraMaster class. The following example shows a ready-to-use job option for event generation with EvtGen and saving them to file in SCT EDM format:

from AuroraMaster.auroramaster import AuroraMaster, AuroraConfig
# Instantiate AuroraMaster
am = AuroraMaster('evtgen', 'info')
# Plug in component for EvtGen
evtgenCfg = AuroraConfig({
   'root' : 'psi(3770)',
   'dec': './dkpi.dec'
})
am.add_evtgen(cfg=evtgenCfg)
# Plug in component for SCT EDM output
edmoutputCfg = AuroraConfig{
   'filename': 'parsim.root',
   'commands': ['keep *'],
})
am.add_edmo(cfg=edmoutputCfg)
am.run(evtmax=10**4)


The run method should be invoked at the end.

Components

An AuroraMaster class method add_{component} receives two parameters:

  • cfg - an object of the AuroraConfig class. Default value it None
  • json - string path to a json file with configuration. Default value it None

A component set up is dome with three steps:

  1. Default configuration
  2. Configuration with passed json file. It overwrites any subset of default parameters. Parameters not specified in json keep the default values
  3. Configuration with AuroraConfig object. It overrides values of the specified parameters leaving other parameters unchanged

If some parameter is specified in both json file and AuroraConfig object, the final value is taken from the AuroraConfig object.

AuroraConfig

The AuroraConfig is a data structure very similar to python dict. It can contain nested lists, dicts and other AuroraConfig objects. An example below shows configuration of simple parametric simulation:

parsimCfg = AuroraConfig({
   'Tracker' : {
       'deteff': 0.99,
       'ptcut': 50e-3,
       'bfield': 1.5,
       'maxCosth': np.cos(10./180. * np.pi),
       'momentumSampler' : {
           'mean' : np.zeros(3),
           'covar': np.diag(np.ones(3)) * 1.e-3**2
       },
       'vertexSampler' : {
           'mean' : np.zeros(3),
           'covar': np.diag(np.ones(3)) * 1.e-3**2
       }
   },
   'PID' : {
       'eff' : 0.95,
       'sigmaKpi' : 6.,
       'sigmaMupi' : 4.,
       'sigmaKp' : 3.,
       'sigmaE' : 3.,
   },
   'Calorimeter' : {
       'deteff': 1.0,
       'energyThreshold' : 15e-3,
       'maxCosth' : np.cos(10./180. * np.pi),
       'sampler' : {
           'mean' : np.zeros(3),
           'covar': (np.diag(np.ones(3)) * 1.e-2**2).ravel()
       }
   }
})

An AuroraConfig object can be serialized to and serialized from json with methods to_json and from_json. It is recommended to create json files with configuration using this interface, and not create json manualy.

Personal tools