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
@@ -0,0 +1,62 @@
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 _MetadataContext = _interopRequireDefault(require("../contexts/MetadataContext"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ 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; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
15
+ 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); } /*****************************************************************************\
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
+ class StrippingBadge extends _react.default.Component {
26
+ render() {
27
+ // TODO: configurable baseURL, remove baseURL from metadata (or make it a top-level key)
28
+ const url = this.props.line && this.context.loaded.stripping ? this.context.metadata.stripping[this.props.version][this.props.line].url[this.props.stream] : "http://lhcbdoc.web.cern.ch/lhcbdoc/stripping/config/stripping" + this.props.version + "/index.html";
29
+ const {
30
+ description
31
+ } = this.context.loaded.strippingHints ? this.context.metadata.strippingHints[this.props.version] : {
32
+ description: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Spinner, {
33
+ animation: "border"
34
+ })
35
+ };
36
+ const badgeProps = this.props.showlink ? {
37
+ as: "a",
38
+ href: url,
39
+ target: "_blank"
40
+ } : {};
41
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
42
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Tooltip, {
43
+ children: description
44
+ }),
45
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, {
46
+ pill: true,
47
+ bg: "info",
48
+ ...badgeProps,
49
+ children: "S" + this.props.version
50
+ })
51
+ });
52
+ }
53
+ }
54
+ _defineProperty(StrippingBadge, "contextType", _MetadataContext.default);
55
+ StrippingBadge.propTypes = {
56
+ line: _propTypes.default.string,
57
+ version: _propTypes.default.string,
58
+ stream: _propTypes.default.string,
59
+ link: _propTypes.default.string,
60
+ showlink: _propTypes.default.bool
61
+ };
62
+ var _default = exports.default = StrippingBadge;
@@ -0,0 +1,48 @@
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 _StrippingBadge = _interopRequireDefault(require("./StrippingBadge"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ /*****************************************************************************\
14
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
15
+ * *
16
+ * This software is distributed under the terms of the GNU General Public *
17
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
18
+ * *
19
+ * In applying this licence, CERN does not waive the privileges and immunities *
20
+ * granted to it by virtue of its status as an Intergovernmental Organization *
21
+ * or submit itself to any jurisdiction. *
22
+ \*****************************************************************************/
23
+
24
+ class StrippingLine extends _react.default.Component {
25
+ render() {
26
+ const strippingInfo = this.props.versions.map(version => /*#__PURE__*/(0, _jsxRuntime.jsx)(_StrippingBadge.default, {
27
+ version: version,
28
+ showlink: this.props.showlink,
29
+ ...this.props
30
+ }, "".concat(this.props.line, "-S").concat(version, "-badge")));
31
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
32
+ children: [this.props.line, /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Stack, {
33
+ direction: "horizontal",
34
+ style: {
35
+ flexWrap: "wrap"
36
+ },
37
+ gap: 1,
38
+ children: strippingInfo
39
+ })]
40
+ });
41
+ }
42
+ }
43
+ StrippingLine.propTypes = {
44
+ versions: _propTypes.default.arrayOf(_propTypes.default.string),
45
+ line: _propTypes.default.string,
46
+ showlink: _propTypes.default.bool
47
+ };
48
+ var _default = exports.default = StrippingLine;
@@ -0,0 +1,46 @@
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 _MetadataContext = _interopRequireDefault(require("../contexts/MetadataContext"));
11
+ var _utils = require("../lib/utils");
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
+ class TupleTool extends _react.default.Component {
27
+ render() {
28
+ const toolClass = this.props.tool.split("/")[0];
29
+ const description = this.context.loaded.tupleTools ? (0, _utils.get_tupleTool_description)(toolClass, this.context.metadata.tupleTools.tupleTools) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Spinner, {
30
+ animation: "border"
31
+ });
32
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.OverlayTrigger, {
33
+ overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Tooltip, {
34
+ children: description
35
+ }),
36
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
37
+ children: this.props.tool
38
+ })
39
+ });
40
+ }
41
+ }
42
+ _defineProperty(TupleTool, "contextType", _MetadataContext.default);
43
+ TupleTool.propTypes = {
44
+ tool: _propTypes.default.string
45
+ };
46
+ var _default = exports.default = TupleTool;
@@ -0,0 +1,127 @@
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 _utils = require("../utils");
9
+ var _Tooltip = _interopRequireDefault(require("react-bootstrap/Tooltip"));
10
+ var _OverlayTrigger = _interopRequireDefault(require("react-bootstrap/OverlayTrigger"));
11
+ var _MetadataContext = _interopRequireDefault(require("../MetadataContext"));
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
+ const {
27
+ search
28
+ } = window.location;
29
+ const query = new URLSearchParams(search).get("s");
30
+ //const [searchQuery, setSearchQuery] = useState(query || '')
31
+
32
+ function compare(a, b) {
33
+ return Object.keys(a)[0] > Object.keys(b)[0] ? 1 : Object.keys(a)[0] < Object.keys(b)[0] ? -1 : 0;
34
+ }
35
+ class VariablesSearch extends _react.default.Component {
36
+ constructor() {
37
+ super(...arguments);
38
+ _defineProperty(this, "state", {
39
+ variables: (0, _utils.parse_searchitem_descriptions)(this.context.metadata.lokiVariables),
40
+ searchQuery: query || ""
41
+ });
42
+ }
43
+ filterVariables(variables, query) {
44
+ /*
45
+ const nInclOptions = variables.filter(
46
+ variable => !Object.keys(variable)[0].toLowerCase().includes(query.toLowerCase())
47
+ );
48
+ */
49
+ const inclOptions = variables.filter(variable => Object.keys(variable)[0].toLowerCase().includes(query.toLowerCase()) && Object.keys(variable)[0].toLowerCase() !== query.toLowerCase());
50
+ const matchedOptions = variables.filter(variable => Object.keys(variable)[0].toLowerCase() === query.toLowerCase());
51
+ const orderedNewOptions = matchedOptions.sort(compare);
52
+ //this.setState({
53
+ return orderedNewOptions.concat(inclOptions);
54
+ //});
55
+ /* if (!query) {
56
+ return variables;
57
+ }
58
+ return variables.filter((variable) => {
59
+ const name = Object.keys(variable)[0].toLowerCase();
60
+ return name.includes(query.toLowerCase());
61
+ });*/
62
+ }
63
+ render() {
64
+ //const {decay} = this.props
65
+ const filteredVariables = this.filterVariables(this.state.variables, this.state.searchQuery);
66
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
67
+ width: "20px",
68
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
69
+ action: "/",
70
+ method: "get",
71
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
72
+ htmlFor: "header-search",
73
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
74
+ className: "visually-hidden",
75
+ children: "Search variables"
76
+ })
77
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
78
+ value: this.state.searchQuery,
79
+ onInput: e => this.setState({
80
+ searchQuery: e.target.value
81
+ }),
82
+ type: "text",
83
+ id: "header-search",
84
+ placeholder: "Search variables",
85
+ name: "s"
86
+ })]
87
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
88
+ className: "scroll",
89
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
90
+ children: filteredVariables.map((variable, index) =>
91
+ /*#__PURE__*/
92
+ // <li key={Object.keys(variable)[0]}>
93
+ (0, _jsxRuntime.jsx)("div", {
94
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
95
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_OverlayTrigger.default, {
96
+ placement: "top",
97
+ delay: {
98
+ hide: 450,
99
+ show: 300
100
+ },
101
+ overlay: props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
102
+ ...props,
103
+ children: Object.values(variable)[0]
104
+ }),
105
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
106
+ children: Object.keys(variable)[0]
107
+ })
108
+ })
109
+ })
110
+ }, index)
111
+
112
+ //</li>
113
+ )
114
+ })
115
+ })]
116
+ });
117
+ }
118
+ }
119
+ _defineProperty(VariablesSearch, "contextType", _MetadataContext.default);
120
+ var _default = exports.default = VariablesSearch;
121
+ /* <div>
122
+ <ul>
123
+ {filteredVariables.map(variable => (
124
+ <li key={Object.keys(variable)[0]}>{Object.keys(variable)[0]}</li>
125
+ ))}
126
+ </ul>
127
+ </div> */
@@ -0,0 +1,35 @@
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
+ /*****************************************************************************\
13
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
14
+ * *
15
+ * This software is distributed under the terms of the GNU General Public *
16
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
17
+ * *
18
+ * In applying this licence, CERN does not waive the privileges and immunities *
19
+ * granted to it by virtue of its status as an Intergovernmental Organization *
20
+ * or submit itself to any jurisdiction. *
21
+ \*****************************************************************************/
22
+
23
+ class YearBadge extends _react.default.Component {
24
+ render() {
25
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, {
26
+ pill: true,
27
+ bg: "success",
28
+ children: this.props.year
29
+ });
30
+ }
31
+ }
32
+ YearBadge.propTypes = {
33
+ year: _propTypes.default.string
34
+ };
35
+ var _default = exports.default = YearBadge;
@@ -0,0 +1,70 @@
1
+ {
2
+ "metadata_baseurl": "https://lbwizard-metadata.web.cern.ch/2.0.1/",
3
+ "metadata_files": {
4
+ "particleProperties": "particle_properties",
5
+ "lokiVariables": "loki",
6
+ "decays": "decays",
7
+ "stripping": "stripping",
8
+ "strippingHints": "stripping_hints",
9
+ "userHints": "user_hints",
10
+ "tupleTools": "tupletools",
11
+ "dataset": "dataset"
12
+ },
13
+ "batch_size": 10,
14
+ "particleTagGroupStyles": {
15
+ "category": "dark",
16
+ "charge": "primary",
17
+ "flavour": "success",
18
+ "spin": "danger",
19
+ "lifetime": "secondary"
20
+ },
21
+ "dttGraphOptions": {
22
+ "layout": {
23
+ "hierarchical": {"sortMethod": "directed"}
24
+ },
25
+ "nodes": {
26
+ "borderWidth": 0,
27
+ "borderWidthSelected": 0,
28
+ "imagePadding": 10,
29
+ "font": {
30
+ "strokeWidth": 20,
31
+ "background": "white"
32
+ },
33
+ "color": {
34
+ "background": "white",
35
+ "highlight": {"background": "white"},
36
+ "hover": {"background": "#eee"}
37
+ },
38
+ "scaling": {
39
+ "min": 32,
40
+ "max": 32
41
+ },
42
+ "value": 1,
43
+ "shape": "image",
44
+ "shapeProperties": {
45
+ "useBorderWithImage": true,
46
+ "useImageSize": false
47
+ }
48
+ },
49
+ "edges": {
50
+ "color": "black",
51
+ "width": 1,
52
+ "selectionWidth": 0,
53
+ "hoverWidth": 0
54
+ },
55
+ "physics": {
56
+ "enabled": false
57
+ },
58
+ "interaction": {
59
+ "dragNodes": false,
60
+ "multiselect": true,
61
+ "selectConnectedEdges": false,
62
+ "hoverConnectedEdges": false,
63
+ "hover": true,
64
+ "zoomView": false
65
+ },
66
+ "height": "500px",
67
+ "autoResize": true,
68
+ "width": "100%"
69
+ }
70
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MetadataContext = void 0;
7
+ exports.MetadataLoadWall = MetadataLoadWall;
8
+ exports.MetadataProvider = MetadataProvider;
9
+ exports.createMetadataLoadWall = createMetadataLoadWall;
10
+ exports.createMetadataProvider = createMetadataProvider;
11
+ exports.useMetadataContext = exports.default = void 0;
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+ var _reactBootstrap = require("react-bootstrap");
14
+ var _react = require("react");
15
+ var _utils = require("../lib/utils");
16
+ var _config2 = _interopRequireDefault(require("../config"));
17
+ var _jsxRuntime = require("react/jsx-runtime");
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+ /*****************************************************************************\
20
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
21
+ * *
22
+ * This software is distributed under the terms of the GNU General Public *
23
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
24
+ * *
25
+ * In applying this licence, CERN does not waive the privileges and immunities *
26
+ * granted to it by virtue of its status as an Intergovernmental Organization *
27
+ * or submit itself to any jurisdiction. *
28
+ \*****************************************************************************/
29
+
30
+ const MetadataContext = exports.MetadataContext = /*#__PURE__*/(0, _react.createContext)({});
31
+ var _default = exports.default = MetadataContext;
32
+ const useMetadataContext = _init => (0, _react.useContext)(MetadataContext);
33
+ exports.useMetadataContext = useMetadataContext;
34
+ function createMetadataProvider(_config, _ref) {
35
+ let {
36
+ children
37
+ } = _ref;
38
+ let metadataTemplate = {};
39
+ Object.keys(_config.metadata_files).forEach((key, _index) => {
40
+ metadataTemplate[key] = {};
41
+ });
42
+ const [metadata, setMetadata] = (0, _react.useState)(metadataTemplate);
43
+ let loadedTemplate = {};
44
+ Object.keys(_config.metadata_files).forEach((key, _index) => {
45
+ loadedTemplate[key] = false;
46
+ });
47
+ const [loaded, setLoaded] = (0, _react.useState)(loadedTemplate);
48
+ const [error, setError] = (0, _react.useState)(null);
49
+ const getMetadata = async () => {
50
+ Object.keys(_config.metadata_files).forEach((key, _index) => {
51
+ (0, _utils.loadDict)(_config.metadata_files[key]).then(result => {
52
+ setMetadata(prevState => ({
53
+ ...prevState,
54
+ [key]: result
55
+ }));
56
+ setLoaded(prevState => ({
57
+ ...prevState,
58
+ [key]: true
59
+ }));
60
+ }, e => {
61
+ setError(e);
62
+ });
63
+ });
64
+ };
65
+ (0, _react.useEffect)(() => {
66
+ getMetadata();
67
+ }, []);
68
+ if (error) {
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("h1", {
70
+ children: ["Oops: ", "".concat(error)]
71
+ });
72
+ } else {
73
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(MetadataContext.Provider, {
74
+ value: {
75
+ loaded: loaded,
76
+ metadata: metadata
77
+ },
78
+ children: children
79
+ });
80
+ }
81
+ }
82
+ function MetadataProvider(children) {
83
+ return createMetadataProvider(_config2.default, children);
84
+ }
85
+ MetadataProvider.propTypes = {
86
+ children: _propTypes.default.node
87
+ };
88
+ /* Wrap a component with <MetadataLoadWall> to show a loading screen until all metadata is fetched
89
+ * This is the "lazy option". It's better UX to have a fine-grained response to individual keys in context.loaded
90
+ * e.g. this.context.loaded.particleProperties? this.context.metadata.particleProperties[particle].html : particle;
91
+ */
92
+ function createMetadataLoadWall(_config, _ref2) {
93
+ let {
94
+ children
95
+ } = _ref2;
96
+ const context = useMetadataContext();
97
+ if (Object.values(context.loaded).some(v => !v)) {
98
+ const loadingSpinner = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Spinner, {
99
+ animation: "border",
100
+ role: "status",
101
+ size: "sm"
102
+ });
103
+ const doneBadge = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, {
104
+ bg: "success",
105
+ children: "Done"
106
+ });
107
+ const message = Object.keys(context.loaded).map(x => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ListGroup.Item, {
108
+ children: [x, " ", context.loaded[x] ? doneBadge : loadingSpinner]
109
+ }, x));
110
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
111
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Alert, {
112
+ variant: "warning",
113
+ children: ["Fetching metadata from the", " ", /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Alert.Link, {
114
+ href: _config.metadata_baseurl,
115
+ target: "_blank",
116
+ children: "backend"
117
+ }), ". This should take a few seconds."]
118
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
119
+ variant: "flush",
120
+ children: message
121
+ })]
122
+ });
123
+ } else {
124
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
125
+ children: children
126
+ });
127
+ }
128
+ }
129
+ function MetadataLoadWall(children) {
130
+ return createMetadataLoadWall(_config2.default, children);
131
+ }
132
+ MetadataLoadWall.propTypes = {
133
+ children: _propTypes.default.node
134
+ };
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _reactDom = _interopRequireDefault(require("react-dom"));
4
+ var _App = _interopRequireDefault(require("./components/App"));
5
+ var _jsxRuntime = require("react/jsx-runtime");
6
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
+ /*****************************************************************************\
8
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
9
+ * *
10
+ * This software is distributed under the terms of the GNU General Public *
11
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
12
+ * *
13
+ * In applying this licence, CERN does not waive the privileges and immunities *
14
+ * granted to it by virtue of its status as an Intergovernmental Organization *
15
+ * or submit itself to any jurisdiction. *
16
+ \*****************************************************************************/
17
+
18
+ _reactDom.default.render( /*#__PURE__*/(0, _jsxRuntime.jsx)(_App.default, {}), document.getElementById("root"));
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*****************************************************************************\
8
+ * (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
9
+ * *
10
+ * This software is distributed under the terms of the GNU General Public *
11
+ * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
12
+ * *
13
+ * In applying this licence, CERN does not waive the privileges and immunities *
14
+ * granted to it by virtue of its status as an Intergovernmental Organization *
15
+ * or submit itself to any jurisdiction. *
16
+ \*****************************************************************************/
17
+ class BKPath {
18
+ constructor(path) {
19
+ this.path = path;
20
+ this.isMC = path.split("/")[1] === "MC";
21
+ }
22
+ getStrippingVersion() {
23
+ return this.path.split("/")[this.isMC ? 7 : 6].replace("Stripping", "").replace("NoPrescalingFlagged", "");
24
+ }
25
+ getYear() {
26
+ return this.path.split("/")[2].replace("Collision", "20");
27
+ }
28
+ getPolarity() {
29
+ const matchingPolarities = ["MagUp", "MagDown"].filter(polarity => this.path.includes(polarity));
30
+ if (matchingPolarities.length === 1) {
31
+ return matchingPolarities;
32
+ } else {
33
+ return "?";
34
+ }
35
+ }
36
+ getFilename() {
37
+ return this.path.split("/")[this.isMC ? 9 : 8];
38
+ }
39
+ getEventType() {
40
+ return this.path.split("/")[this.isMC ? 8 : 7];
41
+ }
42
+ isValid() {
43
+ const bkArray = this.path.split("/");
44
+ if (bkArray[0] !== "") {
45
+ return false;
46
+ }
47
+ if (!this.path.toLowerCase().endsWith("dst")) {
48
+ return false;
49
+ }
50
+ if (bkArray.length === 9 && bkArray[1] === "LHCb") {
51
+ return true;
52
+ } else if (bkArray.length === 10 && bkArray[1] === "MC") {
53
+ return true;
54
+ }
55
+ return false;
56
+ }
57
+ }
58
+ var _default = exports.default = BKPath;