lhcb-ntuple-wizard-test 0.0.1

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 (41) hide show
  1. package/COPYING +674 -0
  2. package/README.md +79 -0
  3. package/dist/components/App.js +99 -0
  4. package/dist/components/ConfigDict.js +103 -0
  5. package/dist/components/ConfigList.js +94 -0
  6. package/dist/components/ConfigNode.js +323 -0
  7. package/dist/components/ConfigValue.js +85 -0
  8. package/dist/components/Dataset.js +67 -0
  9. package/dist/components/Decay.js +51 -0
  10. package/dist/components/DecayItem.js +101 -0
  11. package/dist/components/DecayTag.js +50 -0
  12. package/dist/components/DecayTree.js +452 -0
  13. package/dist/components/DecaysList.js +108 -0
  14. package/dist/components/DeleteButton.js +56 -0
  15. package/dist/components/DescriptorsSearch.js +351 -0
  16. package/dist/components/EventTypeBadge.js +42 -0
  17. package/dist/components/ItemSearch.js +119 -0
  18. package/dist/components/LinesTable.js +1111 -0
  19. package/dist/components/NtupleWizard.js +141 -0
  20. package/dist/components/ParticleTag.js +52 -0
  21. package/dist/components/PolarityBadge.js +35 -0
  22. package/dist/components/SearchItem.js +100 -0
  23. package/dist/components/SelectParticle.js +61 -0
  24. package/dist/components/SelectTag.js +66 -0
  25. package/dist/components/SelectTool.js +59 -0
  26. package/dist/components/SelectVariables.js +105 -0
  27. package/dist/components/StrippingBadge.js +62 -0
  28. package/dist/components/StrippingLine.js +48 -0
  29. package/dist/components/TupleTool.js +46 -0
  30. package/dist/components/VariablesSearch.js +127 -0
  31. package/dist/components/YearBadge.js +35 -0
  32. package/dist/config.json +70 -0
  33. package/dist/contexts/MetadataContext.js +134 -0
  34. package/dist/index.js +18 -0
  35. package/dist/lib/BKPath.js +58 -0
  36. package/dist/lib/DTTConfig.js +174 -0
  37. package/dist/lib/analysisHelpers.js +30 -0
  38. package/dist/lib/mathjax.js +35 -0
  39. package/dist/lib/utils.js +191 -0
  40. package/dist/style/DecaysList.css +15 -0
  41. package/package.json +66 -0
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # LHCb Ntuple Wizard
2
+
3
+ LHCb Ntuple Wizard is an application to access large-scale open data from LHCb.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Usage](#usage)
9
+ - [Npm package](#npm-package)
10
+ - [Contributing](#contributing)
11
+ - [Questions](#questions)
12
+ - [License](#license)
13
+
14
+ ## Installation
15
+
16
+ Install Node/npm: https://nodejs.org/en
17
+
18
+ Run the following command to install the dependencies:
19
+
20
+ ```bash
21
+ npm install
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ #### Run the project using `npm`:
27
+
28
+ ```bash
29
+ npm start
30
+ ```
31
+
32
+ #### Run the project using `docker`:
33
+
34
+ ```bash
35
+ docker buildx build -t ntuple-wizard .
36
+ docker run -itp 8080:8080 --rm ntuple-wizard
37
+ ```
38
+
39
+ ## Npm package
40
+
41
+ The Ntuple Wizard is also made available as a React component through an npm package ([see package here](https://www.npmjs.com/package/lhcb-ntuple-wizard)). To install it, run the following command:
42
+
43
+ ```bash
44
+ npm install lhcb-ntuple-wizard
45
+ ```
46
+
47
+ ### Usage
48
+
49
+ ```jsx
50
+ import React from "react";
51
+ import NtupleWizard from "lhcb-ntuple-wizard";
52
+
53
+ const App = () => {
54
+ return (
55
+ <NtupleWizard
56
+ basePath="/"
57
+ decaysPath="/decays"
58
+ variablesPath="/variables"
59
+ submitLocation="" // Leave empty to hide the submit button -> overrides hideDownloadButtons to false
60
+ contactEmail="" // Leave empty to let the user fill in their email address
61
+ hideDownloadButtons={true} // Can be overridden by submitLocation
62
+ />
63
+ );
64
+ };
65
+
66
+ export default App;
67
+ ```
68
+
69
+ ## Contributing
70
+
71
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
72
+
73
+ ## Questions
74
+
75
+ If you have any questions about the repo, please [open an issue](https://gitlab.cern.ch/lhcb-dpa/wp6-analysis-preservation-and-open-data/lhcb-ntuple-wizard-frontend/-/issues/new).
76
+
77
+ ## License
78
+
79
+ This project is licensed under The GNU General Public License V3.0. See [license](COPYING) for more information.
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ require("bootstrap/dist/css/bootstrap.css");
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactBootstrap = require("react-bootstrap");
10
+ var _reactBootstrapIcons = require("react-bootstrap-icons");
11
+ var _config = _interopRequireDefault(require("../config"));
12
+ var _NtupleWizard = _interopRequireDefault(require("./NtupleWizard"));
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ /*****************************************************************************\
16
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
17
+ * *
18
+ * This software is distributed under the terms of the GNU General Public *
19
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
20
+ * *
21
+ * In applying this licence, CERN does not waive the privileges and immunities *
22
+ * granted to it by virtue of its status as an Intergovernmental Organization *
23
+ * or submit itself to any jurisdiction. *
24
+ \*****************************************************************************/
25
+
26
+ class App extends _react.default.Component {
27
+ render() {
28
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
29
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Navbar, {
30
+ collapseOnSelect: true,
31
+ expand: "lg",
32
+ bg: "dark",
33
+ variant: "dark",
34
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Container, {
35
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Navbar.Brand, {
36
+ href: "/",
37
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
38
+ src: "/logo.svg",
39
+ height: "30",
40
+ className: "d-inline-block align-top",
41
+ alt: "LHCb logo"
42
+ }), " ", "LHCb NTuple Wizard"]
43
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Navbar.Toggle, {
44
+ "aria-controls": "responsive-navbar-nav"
45
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Navbar.Collapse, {
46
+ className: "justify-content-end",
47
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Nav, {
48
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.NavDropdown, {
49
+ title: "About",
50
+ id: "about-dropdown",
51
+ menuVariant: "dark",
52
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.NavDropdown.Item, {
53
+ href: "https://lhcb-dpa.web.cern.ch/lhcb-dpa/wp6/ntupling-wizard.html",
54
+ target: "_blank",
55
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.House, {}), " Project home"]
56
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.NavDropdown.Item, {
57
+ href: "https://gitlab.cern.ch/lhcb-dpa/wp6-analysis-preservation-and-open-data/lhcb-ntuple-wizard-frontend",
58
+ target: "_blank",
59
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.CodeSlash, {}), " Source code"]
60
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.NavDropdown.Item, {
61
+ href: _config.default.metadata_baseurl,
62
+ target: "_blank",
63
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.Archive, {}), " Metadata files"]
64
+ })]
65
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Nav.Link, {
66
+ href: "https://opendata.cern.ch/",
67
+ target: "_blank",
68
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
69
+ src: "/open_data_portal.png",
70
+ height: "30",
71
+ alt: "CERN Open Data Portal"
72
+ })
73
+ })]
74
+ })
75
+ })]
76
+ })
77
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Container, {
78
+ className: "mt-4",
79
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NtupleWizard.default, {
80
+ basePath: "/",
81
+ decaysPath: "/decays",
82
+ variablesPath: "/variables",
83
+ submitLocation: "" // Leave empty to hide the submit button -> overrides hideDownloadButtons to false
84
+ ,
85
+ contactEmail: "" // Leave empty to let the user fill in their email address
86
+ ,
87
+ hideDownloadButtons: false // Can be overridden by submitLocation
88
+ ,
89
+ hideUploadButtons: false,
90
+ requestReasonMessage: "Please provide a reason for your request.",
91
+ requestSubmittedMessage: /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
92
+ children: "Your request has been submitted."
93
+ })
94
+ })
95
+ })]
96
+ });
97
+ }
98
+ }
99
+ var _default = exports.default = App;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _reactBootstrap = require("react-bootstrap");
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
14
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*****************************************************************************\
15
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
16
+ * *
17
+ * This software is distributed under the terms of the GNU General Public *
18
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
19
+ * *
20
+ * In applying this licence, CERN does not waive the privileges and immunities *
21
+ * granted to it by virtue of its status as an Intergovernmental Organization *
22
+ * or submit itself to any jurisdiction. *
23
+ \*****************************************************************************/ //import ConfigValue from "./ConfigValue";
24
+ /*
25
+ * {str:str} -> <ConfigDict /> multiple rows of <input type="text" /> <input type="text" />
26
+ * {str:text} -> <ConfigDict /> multiple rows of <input type="text" /> <textarea />
27
+ */ /*
28
+ * Keys have to be unique and not empty...
29
+ * this may cause problems if the callback is executed on every keystroke
30
+ */
31
+ class ConfigDict extends _react.default.Component {
32
+ constructor() {
33
+ super(...arguments);
34
+ _defineProperty(this, "state", {
35
+ value: JSON.stringify(this.props.value, null, 2),
36
+ // Object.keys(this.props.value).map((key) => [key, this.props.value[key].valueOf()]),
37
+ edit: false,
38
+ error: ""
39
+ });
40
+ _defineProperty(this, "toggleEdit", () => {
41
+ this.setState({
42
+ edit: !this.state.edit
43
+ });
44
+ });
45
+ _defineProperty(this, "handleSave", () => {
46
+ try {
47
+ const value = JSON.parse(this.state.value);
48
+ this.props.callback(value);
49
+ this.setState({
50
+ error: ""
51
+ });
52
+ this.setState({
53
+ edit: false
54
+ });
55
+ } catch (e) {
56
+ this.setState({
57
+ error: "".concat(e)
58
+ });
59
+ }
60
+ });
61
+ _defineProperty(this, "handleUpdate", event => {
62
+ const {
63
+ value
64
+ } = event.target;
65
+ this.setState({
66
+ value: value
67
+ });
68
+ });
69
+ }
70
+ render() {
71
+ const errorMessage = this.state.error ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Alert, {
72
+ variant: "danger",
73
+ children: this.state.error
74
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
75
+ const buttonLabel = this.state.edit ? "Cancel" : "Edit";
76
+ const saveButton = this.state.edit ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
77
+ variant: "primary",
78
+ onClick: this.handleSave,
79
+ children: "Save"
80
+ }) : "";
81
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Card, {
82
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Card.Body, {
83
+ children: [errorMessage, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.FormControl, {
84
+ as: "textarea",
85
+ value: this.state.value,
86
+ onChange: this.handleUpdate,
87
+ disabled: !this.state.edit
88
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonGroup, {
89
+ children: [saveButton, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
90
+ variant: "outline-secondary",
91
+ onClick: this.toggleEdit,
92
+ children: buttonLabel
93
+ })]
94
+ })]
95
+ })
96
+ });
97
+ }
98
+ }
99
+ ConfigDict.propTypes = {
100
+ value: _propTypes.default.oneOfType([_propTypes.default.objectOf(_propTypes.default.string), _propTypes.default.objectOf(_propTypes.default.arrayOf(_propTypes.default.string))]),
101
+ callback: _propTypes.default.func
102
+ };
103
+ var _default = exports.default = ConfigDict;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _ConfigValue = _interopRequireDefault(require("./ConfigValue"));
10
+ var _reactBootstrap = require("react-bootstrap");
11
+ var _reactBootstrapIcons = require("react-bootstrap-icons");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
16
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*****************************************************************************\
17
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
18
+ * *
19
+ * This software is distributed under the terms of the GNU General Public *
20
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
21
+ * *
22
+ * In applying this licence, CERN does not waive the privileges and immunities *
23
+ * granted to it by virtue of its status as an Intergovernmental Organization *
24
+ * or submit itself to any jurisdiction. *
25
+ \*****************************************************************************/ /*
26
+ * [int] -> <ConfigList /> multiple rows of <input type="number" step=1 />
27
+ * [uint] -> <ConfigList /> multiple rows of <input type="number" step=1 min=0 />
28
+ * [float] -> <ConfigList /> multiple rows of <input type="number" />
29
+ */
30
+ class ConfigList extends _react.default.Component {
31
+ constructor() {
32
+ super(...arguments);
33
+ _defineProperty(this, "handleUpdate", index => value => {
34
+ let listValue = this.props.value;
35
+ listValue[index] = value;
36
+ this.props.callback(listValue);
37
+ });
38
+ _defineProperty(this, "handleAdd", () => {
39
+ let listValue = this.props.value;
40
+ const index = listValue.length;
41
+ if (index < this.props.defaultValue.length) {
42
+ const defaultValue = this.props.defaultValue[index].valueOf(); // Shallow copy
43
+ listValue.push(defaultValue);
44
+ } else {
45
+ listValue.push(0);
46
+ }
47
+ this.props.callback(listValue);
48
+ });
49
+ _defineProperty(this, "handleRemove", index => () => {
50
+ let listValue = this.props.value;
51
+ listValue.splice(index, 1);
52
+ this.props.callback(listValue);
53
+ });
54
+ }
55
+ render() {
56
+ const configurables = this.props.value.map((value, index) => {
57
+ const configProps = {
58
+ type: this.props.type,
59
+ value: this.props.value[index],
60
+ callback: this.handleUpdate(index)
61
+ };
62
+ if (index < this.props.defaultValue.length) {
63
+ configProps["defaultValue"] = this.props.defaultValue[index];
64
+ }
65
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
66
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.InputGroup, {
67
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ConfigValue.default, {
68
+ ...configProps
69
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.CloseButton, {
70
+ onClick: this.handleRemove(index)
71
+ })]
72
+ })
73
+ }, index);
74
+ });
75
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
76
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
77
+ variant: "flush",
78
+ children: configurables
79
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
80
+ variant: "success",
81
+ size: "sm",
82
+ onClick: this.handleAdd,
83
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.PlusLg, {})
84
+ })]
85
+ });
86
+ }
87
+ }
88
+ ConfigList.propTypes = {
89
+ type: _propTypes.default.string,
90
+ callback: _propTypes.default.func,
91
+ value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool, _propTypes.default.number, _propTypes.default.arrayOf(_propTypes.default.string)]),
92
+ defaultValue: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool, _propTypes.default.number, _propTypes.default.arrayOf(_propTypes.default.string)])
93
+ };
94
+ var _default = exports.default = ConfigList;