-
88.37%
Rate
-
38
Hits
-
5
Missed
- 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
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
-
-
-
-
-
- 1x
- 1x
- 1x
-
- 1x
-
-
-
-
-
- 1x
- 6x
- 4x
-
- 2x
-
-
-
-
-
-
-
- 2x
- 2x
-
- 2x
- 2x
-
-
-
-
-
-
-
-
-
-
-
- 1x
- 2x
- 1x
- 1x
- 1x
-
-
-
-
-
-
-
-
- 5x
-
- 1x
- 16x
- 4x
- 4x
-
-
-
-
-
-
-
-
- 1x
-
-
- 2x
- 38x
- 38x
-
-
-
- 2x
- 2x
-
-
- 3x
-
-
-
-
-
-
- 1x
- 2x
- 10x
- 8x
- 8x
- 4x
- 4x
-
-
- 2x
-
-
-
-
-
-
- 1x
- -------------------------------------------------------------------------------
- -- Utilities for PUMAS Physics
- -- Author: Valentin Niess
- -- License: GNU LGPL-3.0
- -------------------------------------------------------------------------------
- local lfs = require('lfs')
- local clib = require('pumas.clib')
- local os = require('pumas.os')
-
- local utils = {}
-
-
- -------------------------------------------------------------------------------
- -- Conversion between particles C type and strings
- -------------------------------------------------------------------------------
- function utils.particle_ctype (name, raise_error)
- if name == nil then
- return clib.PUMAS_PARTICLE_MUON
- else
- if type(name) ~= 'string' then
- raise_error{
- argname = 'particle',
- expected = 'a string',
- got = 'a '..type(name)
- }
- end
-
- local tmp = name:lower()
- if tmp == 'muon' then
- return clib.PUMAS_PARTICLE_MUON
- elseif tmp == "tau" then
- return clib.PUMAS_PARTICLE_TAU
- else
- raise_error{
- argname = 'particle',
- expected = "'muon' or 'tau'",
- got = "'"..name.."'"
- }
- end
- end
- end
-
-
- function utils.particle_string (ctype)
- if ctype == clib.PUMAS_PARTICLE_MUON then
- return 'muon'
- elseif ctype == clib.PUMAS_PARTICLE_TAU then
- return 'tau'
- end
- end
-
-
- -------------------------------------------------------------------------------
- -- Convert a Camel like name to a snaky one
- -------------------------------------------------------------------------------
- do
- local function f (w) return '_'..w:lower() end
-
- function utils.snakify (camel)
- camel = camel:sub(1,1):lower()..camel:sub(2)
- return camel:gsub('%u', f)
- :gsub('%d+', f)
- end
- end
-
-
- -------------------------------------------------------------------------------
- -- Text buffer used for building up multi-lines text contents
- -------------------------------------------------------------------------------
- do
- local Text = {__index={}}
-
- -- Add a line of text
- function Text.__index:push (s,...)
- table.insert(self, string.format(s,...))
- return self
- end
-
- -- Pop the full text with OS specific line seps
- function Text.__index:pop ()
- return table.concat(self, os.LINESEP)
- end
-
- function utils.Text () return setmetatable({}, Text) end
- end
-
-
- -------------------------------------------------------------------------------
- -- Recursively create a new directory if it does not already exist
- -------------------------------------------------------------------------------
- function utils.makedirs (path)
- local dir = ''
- for s in path:gmatch(os.PATHSEP..'?[^'..os.PATHSEP..']+') do
- dir = dir..s
- if lfs.attributes(dir, 'mode') == nil then
- local ok, err = lfs.mkdir(dir)
- if not ok then return nil, err end
- end
- end
- return true
- end
-
-
- -------------------------------------------------------------------------------
- -- Return the sub-package
- -------------------------------------------------------------------------------
- return utils