Skip to content

Commit 2441839

Browse files
authored
[O2B-1533] Adjust detector type ordering in DetectorsProvider (#2084)
* Moved the MUON-GLO, AOT-EVENT, AOT-GLO detectors towards the end of RCT tables. * Added DetectorOrders ENUM so we can easily define and manage future orderings.
1 parent d00bd3a commit 2441839

8 files changed

Lines changed: 94 additions & 20 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
import { DetectorType } from './DetectorTypes.js';
15+
16+
/**
17+
* Defines priority mappings for detector types.
18+
* Each key is a mapping between {@link DetectorType} values and their numeric priority
19+
* (larger values will appear first - see detectorsProvider LN88).
20+
*
21+
* - **DEFAULT**: Standard ordering used across most views.
22+
* - **RCT**: Ordering used in the Run Condition Table, which prioritizes PHYSICAL detectors.
23+
*/
24+
export const DetectorOrders = Object.freeze({
25+
DEFAULT: {
26+
[DetectorType.OTHER]: 0,
27+
[DetectorType.VIRTUAL]: 1,
28+
[DetectorType.PHYSICAL]: 2,
29+
[DetectorType.AOT_GLO]: 3,
30+
[DetectorType.AOT_EVENT]: 4,
31+
[DetectorType.MUON_GLO]: 5,
32+
[DetectorType.QC_ONLY]: 6,
33+
},
34+
RCT: {
35+
[DetectorType.OTHER]: 0,
36+
[DetectorType.AOT_GLO]: 1,
37+
[DetectorType.AOT_EVENT]: 2,
38+
[DetectorType.MUON_GLO]: 3,
39+
[DetectorType.VIRTUAL]: 4,
40+
[DetectorType.PHYSICAL]: 5,
41+
[DetectorType.QC_ONLY]: 6,
42+
},
43+
});

lib/public/services/detectors/detectorsProvider.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { switchCase } from '/js/src/index.js';
1515
import { getRemoteData } from '../../utilities/fetch/getRemoteData.js';
1616
import { ObservableData } from '../../utilities/ObservableData.js';
1717
import { DetectorType, DATA_TAKING_DETECTOR_TYPES, QC_DETECTORS } from '../../domain/enums/DetectorTypes.js';
18+
import { DetectorOrders } from '../../domain/enums/DetectorOrders.js';
1819

1920
import { NonPhysicalDetector } from '../../domain/enums/detectorsNames.mjs';
2021

@@ -44,9 +45,12 @@ const getQcDetectorsFromAllDetectors = (allDetectors) => allDetectors
4445
export class DetectorsProvider extends RemoteDataProvider {
4546
/**
4647
* Constructor
48+
*
49+
* @param {DetectorOrders} detectorOrder the order to base sorting on, default is DetectorOrders.DEFAULT
4750
*/
48-
constructor() {
51+
constructor(detectorOrder = DetectorOrders.DEFAULT) {
4952
super();
53+
this._detectorOrder = detectorOrder;
5054
this._physical$ = ObservableData.builder()
5155
.source(this._items$)
5256
.apply((remoteDetectors) => remoteDetectors.apply({
@@ -74,21 +78,14 @@ export class DetectorsProvider extends RemoteDataProvider {
7478
*/
7579
async getRemoteData() {
7680
const { data: detectors } = await getRemoteData('/api/detectors');
77-
const typeToOrderingKey = (type) => switchCase(type, {
78-
[DetectorType.OTHER]: 0,
79-
[DetectorType.VIRTUAL]: 1,
80-
[DetectorType.PHYSICAL]: 2,
81-
[DetectorType.AOT_GLO]: 3,
82-
[DetectorType.AOT_EVENT]: 4,
83-
[DetectorType.MUON_GLO]: 5,
84-
[DetectorType.QC_ONLY]: 6,
85-
});
81+
const typeToOrderingKey = (type) => switchCase(type, this._detectorOrder);
8682

8783
const orderingKey = (detector1, detector2) => {
8884
const specialPair = ['ZDC', 'TST'];
8985
if (specialPair.includes(detector1.name) && specialPair.includes(detector2.name)) {
9086
return detector1.name === 'ZDC' ? 1 : -1;
9187
}
88+
// Note the negative sign to have larger priority types appear first
9289
return -(typeToOrderingKey(detector1.type) - typeToOrderingKey(detector2.type)) * 10 + detector1.name.localeCompare(detector2.name);
9390
};
9491

@@ -161,3 +158,4 @@ export class DetectorsProvider extends RemoteDataProvider {
161158
}
162159

163160
export const detectorsProvider = new DetectorsProvider();
161+
export const rctDetectorsProvider = new DetectorsProvider(DetectorOrders.RCT);

lib/public/views/Runs/RunPerDataPass/RunsPerDataPassOverviewModel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { buildUrl, RemoteData } from '/js/src/index.js';
1414
import { ObservableData } from '../../../utilities/ObservableData.js';
1515
import { getRemoteDataSlice } from '../../../utilities/fetch/getRemoteDataSlice.js';
1616
import { getRemoteData } from '../../../utilities/fetch/getRemoteData.js';
17-
import { detectorsProvider } from '../../../services/detectors/detectorsProvider.js';
17+
import { rctDetectorsProvider } from '../../../services/detectors/detectorsProvider.js';
1818
import { FixedPdpBeamTypeRunsOverviewModel } from '../Overview/FixedPdpBeamTypeRunsOverviewModel.js';
1919
import { jsonPatch } from '../../../utilities/fetch/jsonPatch.js';
2020
import { jsonPut } from '../../../utilities/fetch/jsonPut.js';
@@ -43,7 +43,7 @@ export class RunsPerDataPassOverviewModel extends FixedPdpBeamTypeRunsOverviewMo
4343

4444
this._detectors$ = ObservableData
4545
.builder()
46-
.sources([detectorsProvider.qc$, this._dataPass$])
46+
.sources([rctDetectorsProvider.qc$, this._dataPass$])
4747
.apply((remoteDataList) => mergeRemoteData(remoteDataList)
4848
.apply({ Success: ([detectors, dataPass]) => ALL_CPASS_PRODUCTIONS_REGEX.test(dataPass.name)
4949
? detectors.filter(({ name, type }) => type !== DetectorType.AOT_GLO || DETECTOR_NAMES_NOT_IN_CPASSES.includes(name))

lib/public/views/Runs/RunPerPeriod/RunsPerLhcPeriodOverviewModel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
import { buildUrl, RemoteData } from '/js/src/index.js';
1414
import { TabbedPanelModel } from '../../../components/TabbedPanel/TabbedPanelModel.js';
15-
import { detectorsProvider } from '../../../services/detectors/detectorsProvider.js';
15+
import { rctDetectorsProvider } from '../../../services/detectors/detectorsProvider.js';
1616
import { jsonFetch } from '../../../utilities/fetch/jsonFetch.js';
1717
import { DetectorType } from '../../../domain/enums/DetectorTypes.js';
1818
import { ObservableData } from '../../../utilities/ObservableData.js';
@@ -38,11 +38,11 @@ export class RunsPerLhcPeriodOverviewModel extends FixedPdpBeamTypeRunsOverviewM
3838
this._lhcPeriodId = null;
3939
this._lhcPeriodStatistics$ = new ObservableData(RemoteData.notAsked());
4040

41-
this._onlineDetectors$ = detectorsProvider.physical$;
41+
this._onlineDetectors$ = rctDetectorsProvider.physical$;
4242

4343
this._syncDetectors$ = ObservableData
4444
.builder()
45-
.source(detectorsProvider.qc$)
45+
.source(rctDetectorsProvider.qc$)
4646
.apply((remoteDetectors) =>
4747
remoteDetectors.apply({
4848
Success: (detectors) => detectors.filter(({ type }) => [DetectorType.PHYSICAL, DetectorType.MUON_GLO].includes(type)),

lib/public/views/Runs/RunsPerSimulationPass/RunsPerSimulationPassOverviewModel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { buildUrl, RemoteData } from '/js/src/index.js';
1414
import { ObservableData } from '../../../utilities/ObservableData.js';
1515
import { getRemoteData } from '../../../utilities/fetch/getRemoteData.js';
16-
import { detectorsProvider } from '../../../services/detectors/detectorsProvider.js';
16+
import { rctDetectorsProvider } from '../../../services/detectors/detectorsProvider.js';
1717
import { FixedPdpBeamTypeRunsOverviewModel } from '../Overview/FixedPdpBeamTypeRunsOverviewModel.js';
1818

1919
/**
@@ -29,7 +29,7 @@ export class RunsPerSimulationPassOverviewModel extends FixedPdpBeamTypeRunsOver
2929

3030
this._simulationPass$ = new ObservableData(RemoteData.notAsked());
3131

32-
this._detectors$ = detectorsProvider.qc$;
32+
this._detectors$ = rctDetectorsProvider.qc$;
3333

3434
this.registerObervablesQcSummaryDependesOn([this._detectors$]);
3535
this.registerDetectorsNotBadFractionFilterModels(this._detectors$);

test/public/runs/runsPerDataPass.overview.test.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ module.exports = () => {
152152
.to.be.equal('Missing 3 verifications');
153153
});
154154

155+
it('should display detector columns in RCT order (AOT/MUON after physical)', async () => {
156+
const headers = await page.$$eval(
157+
'table thead th',
158+
(ths) => ths.map((th) => th.id).filter(Boolean),
159+
);
160+
161+
// See DetectorOrders.RCT in detectorOrders.js
162+
expect(headers.indexOf('VTX')).to.be.greaterThan(headers.indexOf('ZDC'));
163+
expect(headers.indexOf('MUD')).to.be.greaterThan(headers.indexOf('ZDC'));
164+
});
165+
155166
it('should ignore QC flags created by services in QC summaries of AOT and MUON ', async () => {
156167
await navigateToRunsPerDataPass(page, 2, 1, 3); // apass
157168
await expectInnerText(page, '#row106-VTX-text', '100');
@@ -394,10 +405,10 @@ module.exports = () => {
394405
const exportContent = fs.readFileSync(path.resolve(downloadPath, targetFileName)).toString();
395406

396407
expect(exportContent.trim()).to.be.eql([
397-
'runNumber;VTX;CPV',
408+
'runNumber;CPV;VTX',
398409
'108;"";""',
399-
'107;"";"Good (from: 1565290800000 to: 1565359260000) | Limited Acceptance MC Reproducible (from: 1565269140000 to: 1565290800000)"',
400-
'106;"Good (from: 1565269200000 to: 1565304200000) | Good (from: 1565324200000 to: 1565359200000)";"Limited Acceptance MC Reproducible (from: 1565304200000 to: 1565324200000) | Limited acceptance (from: 1565329200000 to: 1565334200000) | Bad (from: 1565339200000 to: 1565344200000)"',
410+
'107;"Good (from: 1565290800000 to: 1565359260000) | Limited Acceptance MC Reproducible (from: 1565269140000 to: 1565290800000)";""',
411+
'106;"Limited Acceptance MC Reproducible (from: 1565304200000 to: 1565324200000) | Limited acceptance (from: 1565329200000 to: 1565334200000) | Bad (from: 1565339200000 to: 1565344200000)";"Good (from: 1565269200000 to: 1565304200000) | Good (from: 1565324200000 to: 1565359200000)"',
401412
].join('\r\n'));
402413
fs.unlinkSync(path.resolve(downloadPath, targetFileName));
403414
});

test/public/runs/runsPerLhcPeriod.overview.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ module.exports = () => {
130130
await expectInnerText(page, '#row56-FT0', '83');
131131
});
132132

133+
it('should display detector columns in RCT order (AOT/MUON after physical) for synchronous flags', async () => {
134+
// Note test starts already on synchronous flags tab
135+
const headers = await page.$$eval(
136+
'table thead th',
137+
(ths) => ths.map((th) => th.id).filter(Boolean),
138+
);
139+
140+
// See DetectorOrders.RCT in detectorOrders.js
141+
expect(headers.indexOf('MUD')).to.be.greaterThan(headers.indexOf('ZDC'));
142+
});
143+
133144
it('should successfully sort by runNumber in ascending and descending manners', async () => {
134145
await testTableSortingByColumn(page, 'runNumber');
135146
});

test/public/runs/runsPerSimulationPass.overview.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,17 @@ module.exports = () => {
137137
await qcFlagService.delete(tmpQcFlag.id);
138138
});
139139

140+
it('should display detector columns in RCT order (AOT/MUON after physical)', async () => {
141+
const headers = await page.$$eval(
142+
'table thead th',
143+
(ths) => ths.map((th) => th.id).filter(Boolean),
144+
);
145+
146+
// See DetectorOrders.RCT in detectorOrders.js
147+
expect(headers.indexOf('VTX')).to.be.greaterThan(headers.indexOf('ZDC'));
148+
expect(headers.indexOf('MUD')).to.be.greaterThan(headers.indexOf('ZDC'));
149+
});
150+
140151
it('should successfully sort by runNumber in ascending and descending manners', async () => {
141152
await testTableSortingByColumn(page, 'runNumber');
142153
});

0 commit comments

Comments
 (0)