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.
- package/COPYING +674 -0
- package/README.md +79 -0
- package/dist/components/App.js +99 -0
- package/dist/components/ConfigDict.js +103 -0
- package/dist/components/ConfigList.js +94 -0
- package/dist/components/ConfigNode.js +323 -0
- package/dist/components/ConfigValue.js +85 -0
- package/dist/components/Dataset.js +67 -0
- package/dist/components/Decay.js +51 -0
- package/dist/components/DecayItem.js +101 -0
- package/dist/components/DecayTag.js +50 -0
- package/dist/components/DecayTree.js +452 -0
- package/dist/components/DecaysList.js +108 -0
- package/dist/components/DeleteButton.js +56 -0
- package/dist/components/DescriptorsSearch.js +351 -0
- package/dist/components/EventTypeBadge.js +42 -0
- package/dist/components/ItemSearch.js +119 -0
- package/dist/components/LinesTable.js +1111 -0
- package/dist/components/NtupleWizard.js +141 -0
- package/dist/components/ParticleTag.js +52 -0
- package/dist/components/PolarityBadge.js +35 -0
- package/dist/components/SearchItem.js +100 -0
- package/dist/components/SelectParticle.js +61 -0
- package/dist/components/SelectTag.js +66 -0
- package/dist/components/SelectTool.js +59 -0
- package/dist/components/SelectVariables.js +105 -0
- package/dist/components/StrippingBadge.js +62 -0
- package/dist/components/StrippingLine.js +48 -0
- package/dist/components/TupleTool.js +46 -0
- package/dist/components/VariablesSearch.js +127 -0
- package/dist/components/YearBadge.js +35 -0
- package/dist/config.json +70 -0
- package/dist/contexts/MetadataContext.js +134 -0
- package/dist/index.js +18 -0
- package/dist/lib/BKPath.js +58 -0
- package/dist/lib/DTTConfig.js +174 -0
- package/dist/lib/analysisHelpers.js +30 -0
- package/dist/lib/mathjax.js +35 -0
- package/dist/lib/utils.js +191 -0
- package/dist/style/DecaysList.css +15 -0
- package/package.json +66 -0
|
@@ -0,0 +1,174 @@
|
|
|
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(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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
|
+
return params;
|
|
142
|
+
} else {
|
|
143
|
+
return {};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Configure a TupleTool by passing a dict (ideally a modified version of the one returned by getToolConfig)
|
|
148
|
+
configureTool(branch, toolString, parameters) {
|
|
149
|
+
let target = this.getTarget(branch);
|
|
150
|
+
const index = this.findTool(target, toolString);
|
|
151
|
+
target.tools[index][toolString] = parameters;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Return the current config dict of a tool, so it can be modified by the user
|
|
155
|
+
getToolConfig(branch, toolString) {
|
|
156
|
+
const target = this.getTarget(branch);
|
|
157
|
+
const index = this.findTool(target, toolString);
|
|
158
|
+
return target.tools[index][toolString];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Delete a tool
|
|
162
|
+
removeTool(branch, toolString) {
|
|
163
|
+
let target = this.getTarget(branch);
|
|
164
|
+
const index = this.findTool(target, toolString);
|
|
165
|
+
target.tools.splice(index, 1);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Return a list of strings corresponding to the target's tool list
|
|
169
|
+
listTools(branch) {
|
|
170
|
+
const target = this.getTarget(branch);
|
|
171
|
+
return target.tools.map(tool => Object.keys(tool)[0]).sort();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
var _default = exports.default = DTTConfig;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/*****************************************************************************\
|
|
8
|
+
* (c) Copyright 2023 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
|
+
const analysisHelpers = [{
|
|
18
|
+
name: "__init__.py",
|
|
19
|
+
content: ""
|
|
20
|
+
}, {
|
|
21
|
+
name: "decaytreetuple.py",
|
|
22
|
+
content: "from Configurables import DaVinci, DecayTreeTuple, MCDecayTreeTuple\nfrom DecayTreeTuple.Configuration import addTupleTool\n\ntry:\n from six import string_types\nexcept ImportError:\n string_types = (str, unicode)\n\ndef parse_tools(configurable, tools, verbose = False):\n configurable_name = configurable.name()\n for tool in tools:\n if isinstance(tool, string_types):\n configurable.ToolList += [tool]\n if verbose: print(\"Adding {tool} to {configurable_name}.ToolList\".format(**locals()))\n elif isinstance(tool, dict):\n assert(len(tool) == 1) # must have one key: the name\n name = [key for key in tool][0]\n if verbose: print(\"Adding {name} to {configurable_name}\".format(**locals()))\n tool_conf = configurable.addTupleTool(name)\n tool_conf_name = tool_conf.name()\n for option, value in tool[name].items():\n if verbose: print(\"\t{tool_conf_name}.{option} = {value}\".format(**locals()))\n tool_conf.setProp(option, value)\n\ndef configure_dtt(config, verbose = False):\n dtt_class, dtt_name = config[\"name\"].split(\"/\")\n if dtt_class == \"DecayTreeTuple\":\n dtt = DecayTreeTuple(dtt_name)\n elif dtt_class == \"MCDecayTreeTuple\":\n dtt = MCDecayTreeTuple(dtt_name)\n else:\n raise ValueError(\"Class \"+dtt_class+\" not recognised\")\n dtt.setDescriptorTemplate(config[\"descriptorTemplate\"])\n dtt.Inputs = config[\"inputs\"]\n if DaVinci().InputType == \"MDST\":\n dtt.Inputs = [i.removeprefix(DaVinci().RootInTES+\"/\") for i in dtt.Inputs]\n dtt.ToolList = [] # Usually constructed with a default ToolList, but we want to replace that\n if \"tools\" in config:\n parse_tools(dtt, config[\"tools\"], verbose)\n if \"branches\" in config:\n for particle in config[\"branches\"]:\n if \"tools\" in config[\"branches\"][particle]:\n parse_tools(getattr(dtt, particle), config[\"branches\"][particle][\"tools\"], verbose)\n if \"groups\" in config:\n for group in config[\"groups\"]:\n for particle in group.split(\",\"):\n if \"tools\" in config[\"groups\"][group]:\n parse_tools(getattr(dtt, particle), config[\"groups\"][group][\"tools\"], verbose)\n if verbose:\n print(dtt)\n for particle in config[\"branches\"]:\n print(getattr(dtt, particle))\n return dtt\n\ndef save_config(dtt, verbose = False):\n \"\"\"\n Need to capture all non-blank properties and those of all child configurables\n \"\"\"\n raise NotImplementedError()\n\n"
|
|
23
|
+
}, {
|
|
24
|
+
name: "dst_writer.py",
|
|
25
|
+
content: "from DSTWriters.Configuration import SelDSTWriter, stripDSTStreamConf, stripDSTElements, stripMicroDSTStreamConf, stripMicroDSTElements\n\ndef write_dst(selection_sequences, enable_packing = True, selective_raw_event = False, microDST = False, is_mc = None, extra_items = None):\n # Configuration of SelDSTWriter\n if microDST:\n elements = {\"default\": stripMicroDSTElements(pack = enable_packing, isMC = is_mc)}\n config = {\"default\": stripMicroDSTStreamConf(pack = enable_packing, isMC = is_mc)}\n else:\n elements = {\"default\": stripDSTElements(pack = enable_packing)}\n config = {\"default\": stripDSTStreamConf(pack = enable_packing, selectiveRawEvent = selective_raw_event)}\n if extra_items:\n config[\"default\"].extraItems += extra_items\n dst_writer = SelDSTWriter(\"MyDSTWriter\", StreamConf = config, MicroDSTElements = elements, OutputFileSuffix = \"0\"*6, SelectionSequences = selection_sequences)\n return dst_writer.sequence()\n\n"
|
|
26
|
+
}, {
|
|
27
|
+
name: "stripping.py",
|
|
28
|
+
content: "from Configurables import EventNodeKiller, GaudiSequencer, ProcStatusCheck, StrippingTCK\nfrom StrippingConf.Configuration import StrippingConf, StrippingStream\nfrom StrippingSettings.Utils import strippingConfiguration\nfrom StrippingArchive.Utils import buildStreams\nfrom StrippingArchive import strippingArchive\n\nimport re\n\ndef line_name_is(name):\n \"\"\"\n Match stripping lines by exact name\n \"\"\"\n return lambda l: l.name() == name\n\ndef line_name_contains(phrase):\n \"\"\"\n Match stripping lines whose name contains a specific string\n \"\"\"\n return lambda l: phrase in l.name()\n\ndef line_name_matches(expression):\n \"\"\"\n Match stripping lines whose name matches a regular expression\n \"\"\"\n p = re.compile(expression)\n return lambda l: p.match(l.name())\n\ndef line_name_in_list(name_list):\n \"\"\"\n Match stripping lines whose name appears in a list\n \"\"\"\n return lambda l: l.name() in name_list\n\ndef stripping_tck(version, tes_prefix = \"Strip\"):\n \"\"\"\n Form a stripping TCK from the stripping version.\n The pattern is VVVVSSSS where V are digits from the DaVinci version, and S are digits from the Stripping version.\n The DaVinci version is taken from the MC production step. NB: this may not match the version used to strip data, due to MC-specific patches.\n The major version numbers have 2 digits of space, so they are written like the decimal number.\n The p and r version numbers have only 1 digit, so numbers 10 to 15 are represented by letters A-F.\n \"\"\"\n tck = {\n \"21r1\" : 0x36152110,\n \"21r1p1\": 0x39112111,\n \"21r1p2\": 0x39162112,\n \"21\" : 0x36152100,\n \"21r0p1\": 0x39112101,\n \"21r0p2\": 0x39162102,\n \"24r2\" : 0x44A52420,\n \"28r2\" : 0x44A52820,\n \"29r2\" : 0x42732920,\n \"29r2p1\": 0x42922921,\n \"34\" : 0x44703400,\n \"34r0p1\": 0x44A23401,\n }[version]\n return StrippingTCK(HDRLocation = \"/Event/{}/Phys/DecReports\".format(tes_prefix), TCK = tck)\n\nstripping_dv_versions = {\n \"21r1\" : \"v36r1p5\",\n \"21r1p1\": \"v39r1p1\",\n \"21r1p2\": \"v39r1p6\",\n \"21\" : \"v36r1p5\",\n \"21r0p1\": \"v39r1p1\",\n \"21r0p2\": \"v39r1p6\",\n \"24r2\" : \"v44r10p5\",\n \"28r2\" : \"v44r10p5\",\n \"29r2\" : \"v42r7p3\",\n \"29r2p1\": \"v42r9p2\",\n \"34\" : \"v44r7\",\n \"34r0p1\": \"v44r10p2\",\n}\n\nevent_node_killer = EventNodeKiller(\"StripKiller\", Nodes = [\"/Event/AllStreams\", \"/Event/Strip\"])\n\ndef custom_stripping_stream(version, line_filter, stream_name):\n \"\"\"\n Build a custom stripping stream with the desired lines\n \"\"\"\n # Build streams\n stripping_name = \"stripping{}\".format(version)\n conf = strippingConfiguration(stripping_name)\n archive = strippingArchive(stripping_name)\n all_streams = buildStreams(conf, archive)\n custom_stream = StrippingStream(stream_name)\n # Extract the desired lines and add them to the new stream\n for stream in all_streams:\n matched_lines = filter(line_filter, stream.lines)\n custom_stream.appendLines(matched_lines)\n return custom_stream\n\ndef stripping_mc_filter(version, line_filter, stream_name = \"Filter\"):\n \"\"\"\n Build custom stripping sequence with standard options for filtered MC production.\n \"\"\"\n # Configure the stripping\n custom_stream = custom_stripping_stream(version, line_filter, stream_name)\n stripping_conf = StrippingConf(Streams = [custom_stream], MaxCandidates = 2000, TESPrefix = \"Strip\", AcceptBadEvents = False, BadEventSelection = ProcStatusCheck())\n custom_stream.sequence().IgnoreFilterPassed = False\n # Combine the sequences\n seq = GaudiSequencer(\"{}Sequence\".format(stream_name))\n seq.Members += [stripping_conf.sequence(), stripping_tck(version, tes_prefix)]\n\ndef restripping(version, line_filter = line_name_contains(\"Stripping\"), stream_name = \"AllStreams\", tes_prefix = \"Strip\", max_candidates = 2000, accept_bad_events = False, ignore_filter_passed = False):\n \"\"\"\n Build custom stripping sequence for running on an already-stripped sample.\n \"\"\"\n # Configure the stripping\n custom_stream = custom_stripping_stream(version, line_filter, stream_name)\n stripping_conf = StrippingConf(Streams = [custom_stream], MaxCandidates = max_candidates, TESPrefix = tes_prefix, AcceptBadEvents = accept_bad_events, BadEventSelection = ProcStatusCheck())\n custom_stream.sequence().IgnoreFilterPassed = ignore_filter_passed\n # Combine the sequences\n seq = GaudiSequencer(\"{}Sequence\".format(stream_name))\n seq.Members += [event_node_killer, stripping_conf.sequence()]\n return seq\n\n"
|
|
29
|
+
}];
|
|
30
|
+
var _default = exports.default = analysisHelpers;
|
|
@@ -0,0 +1,35 @@
|
|
|
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;
|
|
@@ -0,0 +1,191 @@
|
|
|
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(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lhcb-ntuple-wizard-test",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "An application to access large-scale open data from LHCb",
|
|
5
|
+
"url": "https://gitlab.cern.ch/lhcb-dpa/wp6-analysis-preservation-and-open-data/lhcb-ntuple-wizard-frontend/issues",
|
|
6
|
+
"private": false,
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
15
|
+
"bootstrap": "^5.1.3",
|
|
16
|
+
"email-validator": "^2.0.4",
|
|
17
|
+
"js-yaml": "^4.1.0",
|
|
18
|
+
"jszip": "^3.7.1",
|
|
19
|
+
"lodash": "^4.17.21",
|
|
20
|
+
"lodash.memoize": "^4.1.2",
|
|
21
|
+
"mathjax-react": "^2.0.1",
|
|
22
|
+
"pako": "^2.1.0",
|
|
23
|
+
"react": "^17.0.2",
|
|
24
|
+
"react-bootstrap": "^2.0.3",
|
|
25
|
+
"react-bootstrap-icons": "^1.6.1",
|
|
26
|
+
"react-dom": "^17.0.2",
|
|
27
|
+
"react-graph-vis": "^1.0.7",
|
|
28
|
+
"react-infinite-scroll-component": "^6.1.0",
|
|
29
|
+
"react-router-dom": "^5.2.0",
|
|
30
|
+
"react-select": "^4.3.1",
|
|
31
|
+
"vite": "^5.1.1"
|
|
32
|
+
},
|
|
33
|
+
"overrides": {
|
|
34
|
+
"autoprefixer": "10.4.5"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"start": "vite --open",
|
|
38
|
+
"build": "vite build",
|
|
39
|
+
"preview": "vite preview",
|
|
40
|
+
"transpile": "babel src -d dist --copy-files",
|
|
41
|
+
"prepublishOnly": "npm run transpile"
|
|
42
|
+
},
|
|
43
|
+
"eslintConfig": {
|
|
44
|
+
"extends": [
|
|
45
|
+
"react-app",
|
|
46
|
+
"react-app/jest"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"browserslist": {
|
|
50
|
+
"production": [
|
|
51
|
+
">0.2%",
|
|
52
|
+
"not dead",
|
|
53
|
+
"not op_mini all"
|
|
54
|
+
],
|
|
55
|
+
"development": [
|
|
56
|
+
"last 1 chrome version",
|
|
57
|
+
"last 1 firefox version",
|
|
58
|
+
"last 1 safari version"
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@babel/cli": "^7.21.0",
|
|
63
|
+
"@babel/preset-env": "^7.21.4",
|
|
64
|
+
"@babel/preset-react": "^7.18.6"
|
|
65
|
+
}
|
|
66
|
+
}
|