Skip to content

Commit 422095f

Browse files
authored
[O2B-1286] Fix luminosity parsing to correspond to JSON format (#11)
* Initialize optionals * Add logging for new dispatches * Add JSON representation of phase and logging
1 parent 2e8cab5 commit 422095f

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

TselectLHC.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
#Data Provides we need
1+
#Data Provides we need - https://confluence.cern.ch/display/expcomm/DIP+LHC
22
dip/acc/LHC/RunControl/RunConfiguration
33
dip/acc/LHC/RunControl/BeamMode
44
dip/acc/LHC/Beam/BetaStar/Bstar2
55
dip/acc/LHC/Beam/Energy
6+
dip/acc/LHC/RunControl/SafeBeam
7+
8+
# LHC_IF data added specifically for Bookkeeping
9+
dip/ALICE/LHC/Bookkeeping/Source
10+
dip/ALICE/LHC/Bookkeeping/CTPClock
11+
612
dip/ALICE/MCS/Dipole/Current
713
dip/ALICE/MCS/Solenoid/Current
814
dip/ALICE/MCS/Dipole/Polarity
915
dip/ALICE/MCS/Solenoid/Polarity
10-
dip/acc/LHC/RunControl/SafeBeam
16+
1117
#
1218
#dip/ALICE/LHClogbook/RunControl/CirculatingBunchConfig/Beam2
1319
#dip/acc/LHC/Beam/Intensity/Beam2

src/alice/dip/BookkeepingClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,11 @@ public void updateRun(RunInfoObj runObj) {
285285
}
286286

287287
if (runObj.getPhaseShiftAtStart().isPresent()) {
288-
requestBody += "\n\"phaseShiftAtStart\":" + runObj.getPhaseShiftAtStart().get() + ",";
288+
requestBody += "\n\"phaseShiftAtStart\":" + runObj.getPhaseShiftAtStartAsJson() + ",";
289289
}
290290

291291
if (runObj.getPhaseShiftAtStop().isPresent()) {
292-
requestBody += "\n\"phaseShiftAtEnd\":" + runObj.getPhaseShiftAtStop().get() + ",";
292+
requestBody += "\n\"phaseShiftAtEnd\":" + runObj.getPhaseShiftAtStopAsJson() + ",";
293293
}
294294

295295
if (!hasModifications) { // no updates to be done !
@@ -304,14 +304,14 @@ public void updateRun(RunInfoObj runObj) {
304304

305305
requestBody += "\n}";
306306

307-
AliDip2BK.log(1, "BKwriter.UpdateRun", "RUN =" + runObj.RunNo + " UPDATE JSON request=\n" + requestBody);
307+
AliDip2BK.log(3, "BKwriter.UpdateRun", "RUN =" + runObj.RunNo + " UPDATE JSON request=\n" + requestBody);
308308

309309
String patchRunRequest = bookkeepingUrl + "/api/runs?runNumber=" + runObj.RunNo;
310310

311311
if (bookkeepingToken != null) {
312312
patchRunRequest += "&token=" + bookkeepingToken;
313313
}
314-
314+
AliDip2BK.log(2, "BKwriter.Format of Update", requestBody);
315315
HttpRequest request = HttpRequest.newBuilder()
316316
.uri(URI.create(patchRunRequest))
317317
.header("Content-Type", "application/json")
@@ -323,7 +323,7 @@ public void updateRun(RunInfoObj runObj) {
323323
response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
324324

325325
if (response.statusCode() == 200) {
326-
AliDip2BK.log(2, "BKwriter.UpdateRun", "Succesful Update for RUN=" + runObj.RunNo);
326+
AliDip2BK.log(2, "BKwriter.UpdateRun", "Successful Update for RUN=" + runObj.RunNo);
327327
} else {
328328
AliDip2BK.log(3, "BKwriter.UpdateRun", "ERROR for RUN=" + runObj.RunNo + " Code=" + +response.statusCode() + " Message=" + response.body());
329329
}

src/alice/dip/DipMessagesProcessor.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,12 @@ private void handleBookkeepingSourceMessage(DipData dipData) throws BadParameter
787787
var acceptance = dipData.extractFloat("Acceptance");
788788
var crossSection = dipData.extractFloat("CrossSection");
789789
var efficiency = dipData.extractFloat("Efficiency");
790-
790+
AliDip2BK.log(
791+
2,
792+
"ProcData.dispatch",
793+
" Bookkeeping Source: Acceptance=" + acceptance + " CrossSection=" + crossSection
794+
+ " Efficiency=" + efficiency
795+
);
791796
luminosityManager.setTriggerEfficiency(efficiency);
792797
luminosityManager.setTriggerAcceptance(acceptance);
793798
luminosityManager.setCrossSection(crossSection);
@@ -797,6 +802,11 @@ private void handleBookkeepingCtpClockMessage(DipData dipData) throws BadParamet
797802
var phaseShiftBeam1 = dipData.extractFloat("PhaseShift_Beam1");
798803
var phaseShiftBeam2 = dipData.extractFloat("PhaseShift_Beam2");
799804

805+
AliDip2BK.log(
806+
2,
807+
"ProcData.dispatch",
808+
" Bookkeeping CTP Clock: PhaseShift_Beam1=" + phaseShiftBeam1 + " PhaseShift_Beam2=" + phaseShiftBeam2
809+
);
800810
luminosityManager.setPhaseShift(new PhaseShift(phaseShiftBeam1, phaseShiftBeam2));
801811
}
802812
}

src/alice/dip/RunInfoObj.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,21 @@ public Optional<PhaseShift> getPhaseShiftAtStart() {
270270
public Optional<PhaseShift> getPhaseShiftAtStop() {
271271
return this.luminosityAtStop.flatMap(LuminosityView::phaseShift);
272272
}
273+
274+
private String formatPhaseShiftAsJson(PhaseShift phaseShift) {
275+
return String.format("{\"beam1\":%f,\"beam2\":%f}", phaseShift.beam1(), phaseShift.beam2());
276+
}
277+
278+
public String getPhaseShiftAtStartAsJson() {
279+
return this.luminosityAtStart.phaseShift()
280+
.map(this::formatPhaseShiftAsJson)
281+
.orElse("{}");
282+
}
283+
284+
public String getPhaseShiftAtStopAsJson() {
285+
return this.luminosityAtStop
286+
.flatMap(LuminosityView::phaseShift)
287+
.map(this::formatPhaseShiftAsJson)
288+
.orElse("{}");
289+
}
273290
}

0 commit comments

Comments
 (0)