-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeamtype.py
99 lines (90 loc) · 2.76 KB
/
beamtype.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
from container import *
from distribution import *
from correlation import *
class BeamType(Container):
"""
A BeamType is a:
(1) PARTNUM (I) particle number
(2) BMTYPE (I) beam type {magnitude = mass code; sign = charge}
1: e
2: μ
3: π
4: K
5: p
6: d
7: He3
8: Li7
(3) FRACBT (R) fraction of beam of this type {0-1} The sum of all fracbt(i) should =1.0
(4) Distribution
(5) NBCORR # of beam correlations {0-10}
(6) From 0-10 enclosed Correlation objects as specified by NBCORR (5)
"""
allowed_enclosed_commands = ['Correlation']
command_params = {
'partnum': {
'desc': 'Particle number',
'doc': '',
'type': 'Integer',
'req': True,
'default': None},
'bmtype': {
'desc': 'beam type {magnitude = mass code; sign = charge}: 1: e, 2: μ, 3: π, 4: K, 5: p. '
'6: d, 7: He3, 8: Li7',
'doc': '',
'out_dict': {
'e': 1,
'mu': 2,
'pi': 3,
'k': 4,
'p': 5,
'd': 6,
'he3': 7,
'li7': 8},
'type': 'Integer',
'req': True,
'default': None},
'fractbt': {
'desc': 'Fraction of beam of this type {0-1} The sum of all fracbt(i) should =1.0',
'doc': '',
'type': 'Real',
'req': True,
'default': None},
'distribution': {
'desc': 'Beam distribution object',
'doc': '',
'type': 'Distribution',
'req': True,
'default': None},
'nbcorr': {
'desc': '# of beam correlations {0-10}',
'doc': '',
'type': 'Integer',
'req': True,
'default': 0,
'min': 0,
'max': 10}}
def __init__(self, **kwargs):
if self.check_command_params_init(kwargs) is False:
sys.exit(0)
ICoolObject.__init__(self, kwargs)
Container.__init__(self)
def __setattr__(self, name, value):
Container.__setattr__(self, name, value)
def __str__(self):
return 'BeamType: \n'
def __repr__(self):
return '[BeamType: ]'
def gen_for001(self, file):
file.write(str(self.partnum))
file.write(' ')
file.write(str(self.bmtype))
file.write(' ')
file.write(str(self.fractbt))
file.write('\n')
self.distribution.gen_for001(file)
file.write('\n')
file.write(str(self.nbcorr))
file.write('\n')
for c in self.enclosed_commands:
c.gen_for001(file)