lhcb-ntuple-wizard-test 1.3.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +1 -2
  2. package/package.json +42 -21
  3. package/dist/components/App.js +0 -99
  4. package/dist/components/ConfigDict.js +0 -103
  5. package/dist/components/ConfigList.js +0 -94
  6. package/dist/components/ConfigNode.js +0 -320
  7. package/dist/components/ConfigValue.js +0 -86
  8. package/dist/components/Dataset.js +0 -67
  9. package/dist/components/Decay.js +0 -50
  10. package/dist/components/DecayItem.js +0 -101
  11. package/dist/components/DecayTag.js +0 -52
  12. package/dist/components/DecayTree.js +0 -451
  13. package/dist/components/DecaysList.js +0 -107
  14. package/dist/components/DeleteButton.js +0 -56
  15. package/dist/components/DescriptorsSearch.js +0 -352
  16. package/dist/components/EventTypeBadge.js +0 -45
  17. package/dist/components/ItemSearch.js +0 -120
  18. package/dist/components/LinesTable.js +0 -1105
  19. package/dist/components/NtupleWizard.js +0 -142
  20. package/dist/components/ParticleTag.js +0 -54
  21. package/dist/components/PolarityBadge.js +0 -35
  22. package/dist/components/SearchItem.js +0 -99
  23. package/dist/components/SelectParticle.js +0 -61
  24. package/dist/components/SelectTag.js +0 -66
  25. package/dist/components/SelectTool.js +0 -59
  26. package/dist/components/SelectVariables.js +0 -106
  27. package/dist/components/StrippingBadge.js +0 -64
  28. package/dist/components/StrippingLine.js +0 -50
  29. package/dist/components/TupleTool.js +0 -46
  30. package/dist/components/VariablesSearch.js +0 -128
  31. package/dist/components/YearBadge.js +0 -35
  32. package/dist/config.json +0 -72
  33. package/dist/contexts/MetadataContext.js +0 -135
  34. package/dist/index.js +0 -20
  35. package/dist/lib/BKPath.js +0 -58
  36. package/dist/lib/DTTConfig.js +0 -178
  37. package/dist/lib/mathjax.js +0 -35
  38. package/dist/lib/utils.js +0 -191
  39. package/dist/style/DecaysList.css +0 -15
@@ -1,178 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _lodash = _interopRequireDefault(require("lodash"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- /*****************************************************************************\
10
- * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
11
- * *
12
- * This software is distributed under the terms of the GNU General Public *
13
- * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
14
- * *
15
- * In applying this licence, CERN does not waive the privileges and immunities *
16
- * granted to it by virtue of its status as an Intergovernmental Organization *
17
- * or submit itself to any jurisdiction. *
18
- \*****************************************************************************/
19
-
20
- class DTTConfig {
21
- /* Class for customising the configuration of a DecayTreeTuple algorithm.
22
- * The output will be parsed by a custom parser in the AnalysisHelpers data-package.
23
- */
24
- constructor(config, toolMetadata) {
25
- this.metadata = toolMetadata;
26
- this.config = config;
27
- }
28
- static createDTT(descriptorTemplate, branchMap, inputs, name, toolMetadata) {
29
- let branchDict = {};
30
- branchMap.forEach(bmap => {
31
- const branch = bmap.branch;
32
- const particle = bmap.particle;
33
- branchDict[branch] = {
34
- particle: particle,
35
- tools: []
36
- };
37
- });
38
- /* Dict to store the DecayTreeTuple options.
39
- * This is what should be written to the output JSON file, with a bit of cleaning up.
40
- */
41
- const config = {
42
- inputs: inputs,
43
- descriptorTemplate: descriptorTemplate,
44
- tools: [],
45
- branches: branchDict,
46
- groups: {}
47
- };
48
- let dtt = new DTTConfig(config, toolMetadata);
49
- const defaultTools = [
50
- // default tool list in DaVinci v45r7
51
- // TODO: load this from a file generated on deployment
52
- "TupleToolKinematic", "TupleToolPid", "TupleToolANNPID", "TupleToolGeometry", "TupleToolEventInfo"];
53
- defaultTools.forEach(tool => {
54
- dtt.addTool("", tool);
55
- });
56
- dtt.setName(name);
57
- return dtt;
58
- }
59
-
60
- // Set the input location (TES location)
61
- setInputs(inputs) {
62
- this.config.inputs = inputs;
63
- }
64
- // Set the class+name combination
65
- setName(name) {
66
- const safeName = name.replace(/\W/g, "");
67
- this.config.name = "DecayTreeTuple/".concat(safeName);
68
- }
69
-
70
- // Return the name of the DecayTreeTuple algorithm
71
- getName() {
72
- return this.config.name.split("/")[1];
73
- }
74
-
75
- // Return the name of the DecayTreeTuple algorithm, or default value "" if empty
76
- getSafeName() {
77
- const name = this.getName();
78
- return name ? name : "";
79
- }
80
-
81
- // Delete all groups with an empty tool list
82
- pruneGroups() {
83
- const empty = Object.keys(this.config.groups).filter(group => this.config.groups[group].tools.length === 0);
84
- empty.forEach(key => delete this.config.groups[key]);
85
- }
86
-
87
- // Find the appropriate object which has a "tools" list
88
- getTarget(branch) {
89
- this.pruneGroups();
90
- if (branch.length === 0) {
91
- return this.config;
92
- } else if ("".concat(branch) in this.config.branches) {
93
- return this.config.branches[branch];
94
- } else {
95
- if (!("".concat(branch) in this.config.groups)) {
96
- this.config.groups["".concat(branch)] = {
97
- particles: branch.map(element => this.config.branches[element].particle),
98
- tools: []
99
- };
100
- }
101
- return this.config.groups["".concat(branch)];
102
- }
103
- }
104
-
105
- // Return the list index of a tool
106
- findTool(target, toolString) {
107
- const index = target.tools.findIndex(tool => toolString in tool);
108
- if (index < 0) {
109
- throw new Error("".concat(toolString, " not found in ").concat(target));
110
- }
111
- return index;
112
- }
113
-
114
- // Add a TupleTool. Return boolean denoting success
115
- addTool(branch, toolClass) {
116
- let toolName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
117
- let target = this.getTarget(branch);
118
- // The toolString identifies the tool in the target's tool list
119
- // If the tool is given a name (recommended), append it following a slash
120
- const toolString = toolName.length ? "".concat(toolClass, "/").concat(toolName) : toolClass;
121
- // Add the tool to the list if not already there
122
- try {
123
- this.findTool(target, toolString);
124
- } catch (e) {
125
- const toolConfig = {
126
- [toolString]: this.getDefaultConfig(toolClass)
127
- };
128
- target.tools.push(toolConfig);
129
- return true;
130
- }
131
- throw new Error("".concat(toolString, " already exists in ").concat(target));
132
- }
133
-
134
- // Return a dict containing the default configuration of a TupleTool
135
- getDefaultConfig(toolClass) {
136
- if (toolClass in this.metadata) {
137
- let params = {};
138
- this.metadata[toolClass].interface.forEach(parameter => {
139
- params[parameter.name] = _lodash.default.cloneDeep(parameter["default"]); // Deep copy
140
- });
141
- // Removing the option to configure the Preambulo for tools where it exists -- this is to prevent arbitrary Python code injection
142
- if (Object.keys(params).includes("Preambulo")) {
143
- delete params.Preambulo;
144
- }
145
- return params;
146
- } else {
147
- return {};
148
- }
149
- }
150
-
151
- // Configure a TupleTool by passing a dict (ideally a modified version of the one returned by getToolConfig)
152
- configureTool(branch, toolString, parameters) {
153
- let target = this.getTarget(branch);
154
- const index = this.findTool(target, toolString);
155
- target.tools[index][toolString] = parameters;
156
- }
157
-
158
- // Return the current config dict of a tool, so it can be modified by the user
159
- getToolConfig(branch, toolString) {
160
- const target = this.getTarget(branch);
161
- const index = this.findTool(target, toolString);
162
- return target.tools[index][toolString];
163
- }
164
-
165
- // Delete a tool
166
- removeTool(branch, toolString) {
167
- let target = this.getTarget(branch);
168
- const index = this.findTool(target, toolString);
169
- target.tools.splice(index, 1);
170
- }
171
-
172
- // Return a list of strings corresponding to the target's tool list
173
- listTools(branch) {
174
- const target = this.getTarget(branch);
175
- return target.tools.map(tool => Object.keys(tool)[0]).sort();
176
- }
177
- }
178
- var _default = exports.default = DTTConfig;
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.tex2svg = tex2svg;
8
- var _mathjax = require("mathjax-full/js/mathjax");
9
- var _tex = require("mathjax-full/js/input/tex");
10
- var _svg = require("mathjax-full/js/output/svg");
11
- /*****************************************************************************\
12
- * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
13
- * *
14
- * This software is distributed under the terms of the GNU General Public *
15
- * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
16
- * *
17
- * In applying this licence, CERN does not waive the privileges and immunities *
18
- * granted to it by virtue of its status as an Intergovernmental Organization *
19
- * or submit itself to any jurisdiction. *
20
- \*****************************************************************************/
21
-
22
- function tex2svg(inputTeX) {
23
- const tex = new _tex.TeX({
24
- packages: ["base", "ams"]
25
- });
26
- const svg = new _svg.SVG({
27
- fontCache: "none"
28
- });
29
- const tex_html = _mathjax.mathjax.document("", {
30
- InputJax: tex,
31
- OutputJax: svg
32
- });
33
- return tex_html.convert(inputTeX);
34
- }
35
- var _default = exports.default = tex2svg;
package/dist/lib/utils.js DELETED
@@ -1,191 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.dec_to_options = dec_to_options;
7
- exports.download = download;
8
- exports.downloadBlob = downloadBlob;
9
- exports.downloadConfig_old = downloadConfig_old;
10
- exports.downloadZip = downloadZip;
11
- exports.getDTreeName = getDTreeName;
12
- exports.get_tupleTool_config = get_tupleTool_config;
13
- exports.get_tupleTool_description = get_tupleTool_description;
14
- exports.list_to_options = list_to_options;
15
- exports.loadDict = loadDict;
16
- exports.parse_searchitem_descriptions = parse_searchitem_descriptions;
17
- exports.parse_tupleTools = parse_tupleTools;
18
- exports.tupletools_to_option = tupletools_to_option;
19
- var _mathjaxReact = require("mathjax-react");
20
- var _pako = _interopRequireDefault(require("pako"));
21
- var _config = _interopRequireDefault(require("../config"));
22
- var _jszip = _interopRequireDefault(require("jszip"));
23
- var _jsxRuntime = require("react/jsx-runtime");
24
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
25
- /*****************************************************************************\
26
- * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
27
- * *
28
- * This software is distributed under the terms of the GNU General Public *
29
- * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
30
- * *
31
- * In applying this licence, CERN does not waive the privileges and immunities *
32
- * granted to it by virtue of its status as an Intergovernmental Organization *
33
- * or submit itself to any jurisdiction. *
34
- \*****************************************************************************/
35
-
36
- async function loadDict(path) {
37
- const url = _config.default["metadata_baseurl"] + path + ".json.gz";
38
- const response = await fetch(url);
39
- if (!response.ok) {
40
- console.error(response);
41
- return null;
42
- }
43
- const data = await response.arrayBuffer();
44
- const unzipped = await _pako.default.inflate(new Uint8Array(data));
45
- const decoded = new TextDecoder("utf-8").decode(unzipped);
46
- const content = JSON.parse(decoded);
47
- return content;
48
- }
49
- function dec_to_options(decays) {
50
- const arr = decays.map(decay => Object({
51
- value: decay.list.plain,
52
- label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_mathjaxReact.MathComponent, {
53
- tex: decay.descriptors.latex,
54
- display: false
55
- })
56
- }));
57
- return arr;
58
- }
59
- function tupletools_to_option(toolDict) {
60
- let arr = [];
61
- Object.keys(toolDict).forEach(tool => {
62
- arr.push({
63
- value: toolDict[tool]["description"],
64
- label: tool
65
- });
66
- });
67
- return arr;
68
- }
69
- function list_to_options(lines) {
70
- let arr = [];
71
- lines.forEach(line => {
72
- arr.push({
73
- value: line,
74
- label: line
75
- });
76
- });
77
- return arr;
78
- }
79
- function parse_searchitem_descriptions(data) {
80
- let arr = [];
81
- Object.keys(data).forEach(name => {
82
- arr.push({
83
- [name]: data[name]["description"]
84
- });
85
- });
86
- return arr;
87
- }
88
- function parse_tupleTools(data) {
89
- let tupleTools = {};
90
- Object.keys(data).forEach(item => {
91
- tupleTools[item] = data[item]["description"];
92
- });
93
- return tupleTools;
94
- }
95
- function get_tupleTool_description(tool_name, data) {
96
- let key_arr = Object.keys(data).filter(item => item === tool_name);
97
- if (key_arr.length > 0) {
98
- return data[key_arr[0]]["description"];
99
- }
100
- return "";
101
- }
102
- function get_tupleTool_config(tool_name, data) {
103
- let key_arr = Object.keys(data).filter(item => item === tool_name);
104
- if (key_arr.length > 0) {
105
- return data[key_arr[0]]["description"];
106
- }
107
- return "";
108
- }
109
- function downloadConfig_old(output) {
110
- let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "file.txt";
111
- const blob = new Blob([output], {
112
- type: "text/plain"
113
- });
114
- //if (
115
- // window.navigator &&
116
- // window.navigator.msSaveOrOpenBlob
117
- //) return window.navigator.msSaveOrOpenBlob(blob);
118
-
119
- // For other browsers:
120
- // Create a link pointing to the ObjectURL containing the blob.
121
- const data = window.URL.createObjectURL(blob);
122
- const link = document.createElement("a");
123
- link.href = data;
124
- link.download = name;
125
-
126
- // this is necessary as link.click() does not work on the latest firefox
127
- link.dispatchEvent(new MouseEvent("click", {
128
- bubbles: true,
129
- cancelable: true,
130
- view: window
131
- }));
132
- setTimeout(() => {
133
- // For Firefox it is necessary to delay revoking the ObjectURL
134
- window.URL.revokeObjectURL(data);
135
- link.remove();
136
- }, 100);
137
- }
138
- function downloadBlob(blob, name) {
139
- // Convert your blob into a Blob URL (a special url that points to an object in the browser's memory)
140
- const blobUrl = URL.createObjectURL(blob);
141
-
142
- // Create a link element
143
- const link = document.createElement("a");
144
-
145
- // Set link's href to point to the Blob URL
146
- link.href = blobUrl;
147
- link.download = name;
148
-
149
- // Append link to the body
150
- document.body.appendChild(link);
151
-
152
- // Dispatch click event on the link
153
- // This is necessary as link.click() does not work on the latest firefox
154
- link.dispatchEvent(new MouseEvent("click", {
155
- bubbles: true,
156
- cancelable: true,
157
- view: window
158
- }));
159
- // Remove link from body
160
- document.body.removeChild(link);
161
- }
162
- function download(output) {
163
- let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "file.txt";
164
- let type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "text/plain";
165
- const blob = new Blob([output], {
166
- type: type
167
- });
168
- downloadBlob(blob, name);
169
- }
170
- function downloadZip(files) {
171
- let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "archive.zip";
172
- const zip = (0, _jszip.default)();
173
- files.forEach(_ref => {
174
- let [name, output] = _ref;
175
- const blob = new Blob([output], {
176
- type: "text/plain"
177
- });
178
- zip.file(name, blob);
179
- });
180
- zip.generateAsync({
181
- type: "blob"
182
- }).then(blob => downloadBlob(blob, name));
183
- }
184
- function getDTreeName(mappedList) {
185
- let name = "";
186
- mappedList.forEach(part => {
187
- name += part["particle"];
188
- });
189
- //let name = descriptor.split(' ').join('');
190
- return name;
191
- }
@@ -1,15 +0,0 @@
1
- /*****************************************************************************\
2
- * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
3
- * *
4
- * This software is distributed under the terms of the GNU General Public *
5
- * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
6
- * *
7
- * In applying this licence, CERN does not waive the privileges and immunities *
8
- * granted to it by virtue of its status as an Intergovernmental Organization *
9
- * or submit itself to any jurisdiction. *
10
- \*****************************************************************************/
11
-
12
- .decaysListClass {
13
- height: 540px;
14
- overflow-y: scroll;
15
- }