AuroraMaster

From Charm-Tau Detector
(Difference between revisions)
Jump to: navigation, search
 
(5 intermediate revisions by one user not shown)
Line 1: Line 1:
 
= Introduction =
 
= 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:
+
The AuroraMaster package contains python classes providing high level interfaces to the Aurora algorithms and tools. The following tools are implemented in AuroraMaster at the moment:
  
from AuroraMaster.auroramaster import AuroraMaster
+
* Read/write SCT EDM data
am = AuroraMaster(purpose='parsim', olvl='info')
+
* Primary event generators
 +
** Particle gun
 +
** [https://evtgen.hepforge.org/ EvtGen]
 +
* Parametric simulation
 +
** Main SCT parametric simulation
 +
** [[Simple_SCT_parametric_simulation|Simple parametric simulation]]
 +
* Full simulation with DD4Hep and Geant4
 +
* [[Use_Analysis_package|Event analysis and selection with the Analysis package]]
 +
** Access to reconstructed final-state-particles
 +
** Reconstruction of particle decay trees
 +
** Saving flat n-tuples for further physics analysis
  
The first argument specifies purpose of the job option. Possible values are:
+
= The AuroraMaster class =
  
* <code>'parsim'</code>
+
Each job option employing AuroraMaster must contain one instance of the AuroraMaster class:
* <code>'fullsim'</code>
+
 
* <code>'evtgen'</code>
+
from AuroraMaster.auroramaster import AuroraMaster
* <code>'analysis'</code>
+
am = AuroraMaster(olvl='info')
  
An AuroraMaster object initializes Aurora services corresponding to the job option purpose. The second argument specifies general output level:
+
The <code>olvl</code> argument specifies the default output level: 'debug' or 'info', where the latter is used as the default.
  
* <code>'debug'</code>
+
The job option logic is formed by invoking methods of the AuroraMaster instance. Each method has the 'cfg' parameter that takes an AuroraConfig object.
* <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:
+
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
Line 28: Line 37:
 
     'dec': './dkpi.dec'
 
     'dec': './dkpi.dec'
 
  })
 
  })
  am.add_evtgen(cfg=evtgenCfg)
+
  am.add_signal_provider('evtgen', evtgenCfg)
 
  # Plug in component for SCT EDM output
 
  # Plug in component for SCT EDM output
 
  edmoutputCfg = AuroraConfig{
 
  edmoutputCfg = AuroraConfig{
Line 37: Line 46:
 
  am.run(evtmax=10**4)
 
  am.run(evtmax=10**4)
  
 +
The <code>run</code> method must be invoked at the end.
  
The <code>run</code> method should be invoked at the end.
+
= 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.
  
= Components =
+
= AuroraMaster components =
  
An AuroraMaster class method <code>add_{component}</code> receives two parameters:
+
All AuroraMaster class methods of the <code>add_{component}</code> format has two parameters:
  
 
* <code>cfg</code> - an object of the <code>AuroraConfig</code> class. Default value it None
 
* <code>cfg</code> - an object of the <code>AuroraConfig</code> class. Default value it None
Line 55: Line 102:
 
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.
 
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 =
+
== add_edmi() ==
  
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:
+
The AuroraMaster.add_edmi() method initialized ScTauDataSvc, instantiates a PodioInput class and has the following default configuration:
  
  parsimCfg = AuroraConfig({
+
  edminputCfg = AuroraConfig({
 +
    'name' : 'EDMReader',
 +
    'olevel' : 'info',
 +
    'filename': 'input.root',
 +
    'collections': ['Particles'],
 +
})
 +
 
 +
== add_edmo() ==
 +
 
 +
The AuroraMaster.add_edmo() method initialized ScTauDataSvc, instantiates a PodioOutput class and has the following default configuration:
 +
 
 +
edmoutputCfg = AuroraConfig({
 +
    'filename': 'output.root',
 +
    'commands': ['keep *'],
 +
    'olevel' : 'info',
 +
})
 +
 
 +
== add_parsim() ==
 +
 
 +
The AuroraMaster.add_parsim() method initializes tools for parametric simulation and instantiates the required algorithm. Selection of specific implementation of the parametric simulation is done by the parameter `which`. The code snipped below shows how to plug in simple parametric simulation:
 +
 
 +
simplepartimCfg = AuroraConfig({
 +
    'olevel': 'info',
 
     'Tracker' : {
 
     'Tracker' : {
 
         'deteff': 0.99,
 
         'deteff': 0.99,
Line 87: Line 156:
 
         'sampler' : {
 
         'sampler' : {
 
             'mean' : np.zeros(3),
 
             'mean' : np.zeros(3),
             'covar': (np.diag(np.ones(3)) * 1.e-2**2).ravel()
+
             'covar': np.diag(np.ones(3)) * 1.e-2**2
 
         }
 
         }
 
     }
 
     }
 
  })
 
  })
 +
am.add_parsim(which='simple', cfg=parsimCfg)
  
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.
+
See [[Simple SCT parametric simulation|the detailed description]] of the simple SCT parametric simulation.
 +
 
 +
== add_fullsim() ==
 +
 
 +
fullsimCfg = AuroraConfig({
 +
    'detector': 'SimG4DD4hepDetector',
 +
    'subsystems': ['ALL'],
 +
    'physicslist': 'SimG4FtfpBert',
 +
    'energyCut': 0.1 * units.GeV,
 +
    'field' : {
 +
        'Bz' : 1.0 * units.tesla,
 +
        'rmax' : 100.0 * units.m,
 +
        'zmax' : 100.0 * units.m
 +
    },
 +
    'olevel': 'info',
 +
})
 +
 
 +
== add_signal_provider() ==
 +
 
 +
eventgenCfg = AuroraConfig({
 +
    'root' : 'vpho',
 +
    'dec' : '',
 +
    'ecms' : 0.,
 +
    'olevel': 'info',
 +
})
 +
am.add_signal_provider('evtgen', evtgenCfg)
 +
 
 +
or
 +
 
 +
particlegunCfg = AuroraConfig({
 +
    'momentum' : np.array([0.1, 1.5]) * units.GeV,
 +
    'phi': [0., 2*np.pi],
 +
    'theta': np.array([10, 170]) * units.rad,
 +
    'particles': [11, 13, 211],
 +
    'olevel': 'info',
 +
})
 +
am.add_signal_provider('gun', gunCfg)

Latest revision as of 18:25, 4 August 2021

Contents

[edit] Introduction

The AuroraMaster package contains python classes providing high level interfaces to the Aurora algorithms and tools. The following tools are implemented in AuroraMaster at the moment:

[edit] The AuroraMaster class

Each job option employing AuroraMaster must contain one instance of the AuroraMaster class:

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

The olvl argument specifies the default output level: 'debug' or 'info', where the latter is used as the default.

The job option logic is formed by invoking methods of the AuroraMaster instance. Each method has the 'cfg' parameter that takes an AuroraConfig object.

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_signal_provider('evtgen', 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 must be invoked at the end.

[edit] 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.

[edit] AuroraMaster components

All AuroraMaster class methods of the add_{component} format has 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.

[edit] add_edmi()

The AuroraMaster.add_edmi() method initialized ScTauDataSvc, instantiates a PodioInput class and has the following default configuration:

edminputCfg = AuroraConfig({
   'name' : 'EDMReader',
   'olevel' : 'info',
   'filename': 'input.root',
   'collections': ['Particles'],
})

[edit] add_edmo()

The AuroraMaster.add_edmo() method initialized ScTauDataSvc, instantiates a PodioOutput class and has the following default configuration:

edmoutputCfg = AuroraConfig({
   'filename': 'output.root',
   'commands': ['keep *'],
   'olevel' : 'info',
})

[edit] add_parsim()

The AuroraMaster.add_parsim() method initializes tools for parametric simulation and instantiates the required algorithm. Selection of specific implementation of the parametric simulation is done by the parameter `which`. The code snipped below shows how to plug in simple parametric simulation:

simplepartimCfg = AuroraConfig({
   'olevel': 'info',
   '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
       }
   }
})
am.add_parsim(which='simple', cfg=parsimCfg)

See the detailed description of the simple SCT parametric simulation.

[edit] add_fullsim()

fullsimCfg = AuroraConfig({
   'detector': 'SimG4DD4hepDetector',
   'subsystems': ['ALL'],
   'physicslist': 'SimG4FtfpBert',
   'energyCut': 0.1 * units.GeV,
   'field' : {
       'Bz' : 1.0 * units.tesla,
       'rmax' : 100.0 * units.m,
       'zmax' : 100.0 * units.m
   },
   'olevel': 'info',
})

[edit] add_signal_provider()

eventgenCfg = AuroraConfig({
   'root' : 'vpho',
   'dec' : ,
   'ecms' : 0.,
   'olevel': 'info',
})
am.add_signal_provider('evtgen', evtgenCfg)

or

particlegunCfg = AuroraConfig({
   'momentum' : np.array([0.1, 1.5]) * units.GeV,
   'phi': [0., 2*np.pi],
   'theta': np.array([10, 170]) * units.rad,
   'particles': [11, 13, 211],
   'olevel': 'info',
}) 
am.add_signal_provider('gun', gunCfg)
Personal tools