Skip to content

Commit c0aa8a2

Browse files
[O2b-388] Display luminosity in run details (#1874)
* [O2B-1388] Display lumi in run details * Handle undefined CTP trigger counters * Use run in seconds and fix cross section unit * Fix units * Fix formatting * Add tests * Another attempt at fixing balloon tests * Forgot one bit * Remove leftover
1 parent 7ebe6eb commit c0aa8a2

12 files changed

Lines changed: 312 additions & 122 deletions

File tree

lib/database/seeders/20200713103855-runs.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ module.exports = {
13741374
fill_number: 6,
13751375
pdp_beam_type: 'PbPb',
13761376
lhc_beam_energy: 23.21,
1377-
lhc_beam_mode: 'STABLE',
1377+
lhc_beam_mode: 'STABLE BEAMS',
13781378
lhc_beta_star: 321.1321,
13791379
alice_l3_current: 30002545.12,
13801380
alice_l3_polarity: 'POSITIVE',
@@ -1392,6 +1392,9 @@ module.exports = {
13921392
updated_at: '2019-08-08 17:00:00',
13931393
created_at: '2019-08-08 17:00:00',
13941394
lhc_period_id: 1,
1395+
trigger_efficiency: 1,
1396+
trigger_acceptance: 0.7569974555,
1397+
cross_section: 78600,
13951398

13961399
inelastic_interaction_rate_avg: 20000,
13971400
inelastic_interaction_rate_at_start: 10000,
@@ -2670,7 +2673,7 @@ module.exports = {
26702673
dcs: false,
26712674
epn: true,
26722675
fill_number: 1,
2673-
epn_topology: 'a quite long topology, which will for sure require a balloon to be displayed properly',
2676+
epn_topology: 'quite a long topology, which will for sure require a balloon to be displayed properly',
26742677
concatenated_detectors: 'ACO, CPV, CTP, EMC, FIT, HMP, ITS, MCH, MFT, MID, PHS, TOF, TPC, TRD, ZDC',
26752678
lhc_period_id: 2,
26762679
lhc_beam_mode: 'STABLE BEAMS',
@@ -2709,7 +2712,7 @@ module.exports = {
27092712
dcs: false,
27102713
epn: true,
27112714
fill_number: 1,
2712-
epn_topology: 'a quite long topology, which will for sure require a balloon to be displayed properly',
2715+
epn_topology: 'quite a long topology, which will for sure require a balloon to be displayed properly',
27132716
concatenated_detectors: 'ACO, CPV, CTP, EMC, FIT, HMP, ITS, MCH, MFT, MID, PHS, TOF, TPC, TRD, ZDC',
27142717
trigger_value: 'OFF',
27152718
lhc_period_id: 2,
@@ -2748,7 +2751,7 @@ module.exports = {
27482751
dcs: false,
27492752
epn: true,
27502753
fill_number: 1,
2751-
epn_topology: 'a quite long topology, which will for sure require a balloon to be displayed properly',
2754+
epn_topology: 'quite a long topology, which will for sure require a balloon to be displayed properly',
27522755
concatenated_detectors: 'ACO, CPV, CTP, EMC, FIT, HMP, ITS, MCH, MFT, MID, PHS, TOF, TPC, TRD, ZDC',
27532756
lhc_period_id: 2,
27542757
lhc_beam_mode: 'STABLE BEAMS',
@@ -2765,6 +2768,10 @@ module.exports = {
27652768
other_file_count: 50,
27662769
other_file_size: '214920239535280',
27672770
definition: RunDefinition.PHYSICS,
2771+
trigger_efficiency: 1,
2772+
trigger_acceptance: 0.7569974555,
2773+
cross_section: 78600,
2774+
27682775
updated_at: '2019-08-09 14:00:00',
27692776
created_at: '2019-08-09 14:00:00',
27702777
},

lib/database/seeders/20220503120937-lhc-fills.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module.exports = {
2525
filling_scheme_name: '25ns_2352b_2340_2004_2133_108bpi_24inj',
2626
created_at: new Date('2019-08-09 16:00:00'),
2727
updated_at: new Date('2019-08-09 16:00:00'),
28+
colliding_bunches_count: 1234,
2829
},
2930
{
3031
fill_number: 2,
@@ -67,7 +68,7 @@ module.exports = {
6768
stable_beams_end: '2019-08-08 23:00:00',
6869
stable_beams_duration: 60 * 60 * 12,
6970
filling_scheme_name: 'Single_12b_8_1024_8_2018',
70-
colliding_bunches_count: 123456789,
71+
colliding_bunches_count: 2345,
7172
delivered_luminosity: 420,
7273
created_at: new Date('2019-08-09 21:00:00'),
7374
updated_at: new Date('2019-08-09 21:00:00'),

lib/database/seeders/20240603124221-add-trigger-counters.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,34 @@ module.exports = {
3232
created_at: '2024-06-03 14:46:27',
3333
updated_at: '2024-06-03 14:49:44',
3434
},
35+
{
36+
id: 3,
37+
timestamp: '2024-06-03 14:45:12',
38+
run_number: 54,
39+
class_name: 'C1ZNC-B-NOPF-CRU',
40+
lmb: 5748831462n,
41+
lma: 5748757057n,
42+
l0b: 5748757057n,
43+
l0a: 5748757056n,
44+
l1b: 5748757056n,
45+
l1a: 5748757056n,
46+
created_at: '2024-06-03 14:48:01',
47+
updated_at: '2024-06-03 14:50:48',
48+
},
49+
{
50+
id: 4,
51+
timestamp: '2024-06-03 14:45:12',
52+
run_number: 108,
53+
class_name: 'CMTVX-NONE-NOPF-CRU',
54+
lmb: 61766221961n,
55+
lma: 0,
56+
l0b: 15944142517n,
57+
l0a: 15942608365n,
58+
l1b: 1141098293n,
59+
l1a: 1141098293n,
60+
created_at: '2024-06-03 14:48:01',
61+
updated_at: '2024-06-03 14:50:48',
62+
},
3563
], { transaction }),
3664
])),
3765

lib/public/utilities/formatting/formatFloat.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/**
1515
* Format float number
1616
* @param {number} value number to be formatted
17+
* @param {object} [options] eventual options for formatting
1718
* @param {number} [options.precision = 3] precision of displayed value
1819
* @return {string} formatted number
1920
*/

lib/public/views/Runs/Details/RunDetailsModel.js

Lines changed: 77 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ export class RunDetailsModel extends Observable {
4141

4242
this._runNumber = null;
4343
this._runId = null;
44+
4445
this._runDetails = RemoteData.notAsked();
4546
this._eorReasonTypes = RemoteData.notAsked();
47+
this._ctpTriggerCounters = RemoteData.notAsked(); // Trigger counters are pre-fetched because they are used
48+
this._luminosityValues = RemoteData.notAsked();
49+
4650
this._detectors$ = detectorsProvider.dataTaking$;
4751
this._detectors$.bubbleTo(this);
4852

@@ -53,29 +57,40 @@ export class RunDetailsModel extends Observable {
5357
this._tabbedPanelModel = new RunDetailsTabbedPanelModel();
5458
this._tabbedPanelModel.bubbleTo(this);
5559

60+
/** @var {ApiError[]} */
5661
this._updateErrors = [];
5762
}
5863

5964
/**
6065
* Fetch all data related to run details
61-
* @param {number} [params.runNumber = null] the run Number of the run to display
62-
* @param {number} [params.runId = null] this parameter is deprecated, use runNumber instead if feasible
63-
* @param {string} [params.panelKey = null] the key of the current panel
66+
* @param {object} params page parameters
67+
* @param {number|null} [params.runNumber = null] the run Number of the run to display
68+
* @param {number|null} [params.runId = null] this parameter is deprecated, use runNumber instead if feasible
69+
* @param {string|null} [params.panelKey = null] the key of the current panel
6470
* @return {Promise<void>} promise
6571
*/
6672
async clearAndLoad({ runNumber = null, runId = null, panelKey = null }) {
6773
this.tabbedPanelModel.currentPanelKey = panelKey;
6874
this._updateErrors = [];
6975
this._runDetails = RemoteData.notAsked();
7076
this._eorReasonTypes = RemoteData.notAsked();
77+
this._ctpTriggerCounters = RemoteData.notAsked();
7178

7279
if (this._runNumber !== runNumber || this._runId !== runId) {
7380
this.clearAllEditors();
7481
}
7582
this._runId = runId;
7683
this._runNumber = runNumber;
77-
this._fetchReasonTypes();
78-
this._fetchOneRun();
84+
85+
const fetchOneRunPromise = this._fetchOneRun();
86+
const fetchCtpTriggerCounters = this._fetchCtpTriggerCounters();
87+
88+
// Load luminosity values
89+
await Promise.all([
90+
this._fetchReasonTypes(),
91+
fetchOneRunPromise,
92+
fetchCtpTriggerCounters,
93+
]);
7994
}
8095

8196
/**
@@ -103,6 +118,15 @@ export class RunDetailsModel extends Observable {
103118
return this._eorReasonTypes;
104119
}
105120

121+
/**
122+
* Return the remote CTP trigger counters
123+
*
124+
* @return {RemoteData<CtpTriggerCounters[], ApiError>} the remote CTP trigger counters
125+
*/
126+
get ctpTriggerCounters() {
127+
return this._ctpTriggerCounters;
128+
}
129+
106130
/**
107131
* Getter for all detectors
108132
*
@@ -115,24 +139,29 @@ export class RunDetailsModel extends Observable {
115139
/**
116140
* Retrieve a specified run from the API
117141
*
118-
* @return {Promise<void>} resolves once the run has been fetched
142+
* @return {Promise<Run>} resolves once the run has been fetched
119143
*/
120144
async _fetchOneRun() {
121145
this._runDetails = RemoteData.loading();
122146
this.notify();
123-
if (this._runNumber !== null) {
124-
return this._handleFetchRemoteRun(() => getRemoteData(`/api/runs/${this._runNumber}`));
125-
} else {
126-
return this._handleFetchRemoteRun(() => getRemoteData(`/api/legacy/runs/${this._runId}`));
127-
}
147+
148+
const runsApiUrl = this._runNumber !== null
149+
? `/api/runs/${this._runNumber}`
150+
: `/api/legacy/runs/${this._runId}`;
151+
152+
return this._handleFetchRemoteRun(() => getRemoteData(runsApiUrl));
128153
}
129154

130155
/**
131156
* Send updated RUN to be saved
157+
*
132158
* @return {void}
133159
*/
134160
async updateOneRun() {
135-
const { runNumber } = this._runDetails.payload;
161+
if (this._runNumber === null) {
162+
this._updateErrors = [{ title: 'No run number specified' }];
163+
}
164+
136165
this._runDetails = RemoteData.loading();
137166
this._updateErrors = [];
138167
this.notify();
@@ -147,7 +176,7 @@ export class RunDetailsModel extends Observable {
147176
};
148177

149178
try {
150-
await jsonFetch(`/api/runs/${runNumber}`, options);
179+
await jsonFetch(`/api/runs/${this._runNumber}`, options);
151180
} catch (e) {
152181
this._updateErrors = e;
153182
}
@@ -210,8 +239,13 @@ export class RunDetailsModel extends Observable {
210239
*/
211240
addNewEorReason() {
212241
const { category, title, description } = this.newEorReason;
213-
const reasonType =
214-
this._eorReasonTypes.payload.find((eorReasonType) => eorReasonType.category === category && eorReasonType.title === title);
242+
const reasonType = this._eorReasonTypes.match({
243+
Success: (eorReasonTypes) => eorReasonTypes.find(
244+
(eorReasonType) => eorReasonType.category === category && eorReasonType.title === title,
245+
),
246+
Other: () => null,
247+
});
248+
215249
if (reasonType) {
216250
this.runPatch.addEorReason({ reasonTypeId: reasonType.id, description });
217251
}
@@ -220,7 +254,7 @@ export class RunDetailsModel extends Observable {
220254
/**
221255
* Returns the model handling the tag picking for run update
222256
*
223-
* @return {PickerModel} the picker model
257+
* @return {TagSelectionDropdownModel} the picker model
224258
*/
225259
get editionTagPickerModel() {
226260
return this._editionTagPickerModel;
@@ -229,7 +263,7 @@ export class RunDetailsModel extends Observable {
229263
/**
230264
* Set the current edition tag picker model and register required observers
231265
*
232-
* @param {PickerModel} editionTagPickerModel the new tag picker model
266+
* @param {TagSelectionDropdownModel} editionTagPickerModel the new tag picker model
233267
*/
234268
set editionTagPickerModel(editionTagPickerModel) {
235269
this._editionTagPickerModel = editionTagPickerModel;
@@ -258,7 +292,7 @@ export class RunDetailsModel extends Observable {
258292
* Wrap the call to a function that fetch runs and update the model with the received data
259293
*
260294
* @param {function} fetchRuns the function that actually fetch runs
261-
* @return {Promise<void>} resolves once the runs are fetched and the model has been updated accordingly
295+
* @return {Promise<Run>} resolves once the runs are fetched and the model has been updated accordingly
262296
* @private
263297
*/
264298
async _handleFetchRemoteRun(fetchRuns) {
@@ -267,14 +301,15 @@ export class RunDetailsModel extends Observable {
267301
this._runDetails = RemoteData.success(run);
268302
this._runPatch = new RunPatch(run);
269303
this._runPatch.bubbleTo(this);
304+
270305
this.editionTagPickerModel = new TagSelectionDropdownModel({ defaultSelection: run.tags.map(tagToOption) });
271306
this._tabbedPanelModel.runNumber = run.runNumber;
272307
this._runNumber = run.runNumber;
308+
this.notify();
309+
return run;
273310
} catch (error) {
274311
this._runDetails = RemoteData.failure(error);
275312
}
276-
277-
this.notify();
278313
}
279314

280315
/**
@@ -295,6 +330,28 @@ export class RunDetailsModel extends Observable {
295330

296331
this.notify();
297332
}
333+
334+
/**
335+
* Fetch the trigger counters data for the current run
336+
*
337+
* @return {Promise<void>} resolves once data has been fetched or request failed
338+
* @private
339+
*/
340+
async _fetchCtpTriggerCounters() {
341+
if (this._runNumber !== null) {
342+
this._ctpTriggerCounters = RemoteData.loading();
343+
this.notify();
344+
345+
try {
346+
const { data: ctpTriggerCountersOfRun } = await getRemoteData(`/api/ctp-trigger-counters/${this._runNumber}`);
347+
this._ctpTriggerCounters = RemoteData.success(ctpTriggerCountersOfRun);
348+
} catch (error) {
349+
this._ctpTriggerCounters = RemoteData.failure(error);
350+
}
351+
352+
this.notify();
353+
}
354+
}
298355
}
299356

300357
/**
@@ -334,9 +391,6 @@ class RunDetailsTabbedPanelModel extends TabbedPanelModel {
334391
case RUN_DETAILS_PANELS_KEYS.DPL_PROCESSES:
335392
this._fetchDplTasksPanelData();
336393
break;
337-
case RUN_DETAILS_PANELS_KEYS.CTP_TRIGGER_COUNTERS:
338-
this._fetchCtpTriggerCountersPanelData();
339-
break;
340394
}
341395
}
342396

@@ -409,28 +463,6 @@ class RunDetailsTabbedPanelModel extends TabbedPanelModel {
409463
this.notify();
410464
}
411465
}
412-
413-
/**
414-
* Fetch the trigger counters data for the current run
415-
*
416-
* @return {void} resolves once data has been fetched or request failed
417-
* @private
418-
*/
419-
async _fetchCtpTriggerCountersPanelData() {
420-
this.currentPanelData = RemoteData.loading();
421-
this.notify();
422-
423-
if (this._runNumber !== null) {
424-
try {
425-
const { data: ctpTriggerCountersOfRun } = await getRemoteData(`/api/ctp-trigger-counters/${this._runNumber}`);
426-
this.currentPanelData = RemoteData.success(ctpTriggerCountersOfRun);
427-
} catch (error) {
428-
this.currentPanelData = RemoteData.failure(error);
429-
}
430-
}
431-
432-
this.notify();
433-
}
434466
}
435467

436468
/**

0 commit comments

Comments
 (0)