@@ -44,9 +44,12 @@ public class DipMessagesProcessor implements Runnable {
4444 ArrayList <RunInfoObj > ActiveRuns = new ArrayList <>();
4545 private BlockingQueue <MessageItem > outputQueue = new ArrayBlockingQueue <>(100 );
4646
47- public DipMessagesProcessor (BookkeepingClient bookkeepingClient ) {
47+ private final LuminosityManager luminosityManager ;
48+
49+ public DipMessagesProcessor (BookkeepingClient bookkeepingClient , LuminosityManager luminosityManager ) {
4850
4951 this .bookkeepingClient = bookkeepingClient ;
52+ this .luminosityManager = luminosityManager ;
5053
5154 Thread t = new Thread (this );
5255 t .start ();
@@ -122,7 +125,13 @@ public synchronized void newRunSignal(long date, int runNumber) {
122125
123126 if (rio == null ) {
124127 if (currentFill != null ) {
125- RunInfoObj newrun = new RunInfoObj (date , runNumber , currentFill .clone (), currentAlice .clone ());
128+ RunInfoObj newrun = new RunInfoObj (
129+ date ,
130+ runNumber ,
131+ currentFill .clone (),
132+ currentAlice .clone (),
133+ luminosityManager .getView ()
134+ );
126135 ActiveRuns .add (newrun );
127136 AliDip2BK .log (
128137 2 ,
@@ -154,12 +163,18 @@ public synchronized void newRunSignal(long date, int runNumber) {
154163 }
155164 }
156165 } else {
157- RunInfoObj newrun = new RunInfoObj (date , runNumber , null , currentAlice .clone ());
166+ RunInfoObj newrun = new RunInfoObj (
167+ date ,
168+ runNumber ,
169+ null ,
170+ currentAlice .clone (),
171+ luminosityManager .getView ()
172+ );
158173 ActiveRuns .add (newrun );
159174 AliDip2BK .log (
160- 2 ,
161- "ProcData.newRunSignal" ,
162- " NEW RUN NO =" + runNumber + " currentFILL is NULL Perhaps Cosmics Run"
175+ 2 ,
176+ "ProcData.newRunSignal" ,
177+ " NEW RUN NO =" + runNumber + " currentFILL is NULL Perhaps Cosmics Run"
163178 );
164179 bookkeepingClient .updateRun (newrun );
165180 }
@@ -179,6 +194,8 @@ public synchronized void stopRunSignal(long time, int runNumber) {
179194 rio .setEORtime (time );
180195 if (currentFill != null ) rio .LHC_info_stop = currentFill .clone ();
181196 rio .alice_info_stop = currentAlice .clone ();
197+ rio .setLuminosityAtStop (luminosityManager .getView ());
198+ bookkeepingClient .updateRun (rio );
182199
183200 EndRun (rio );
184201 } else {
@@ -220,6 +237,12 @@ public void processNextInQueue(MessageItem messageItem) {
220237 case "dip/ALICE/MCS/Dipole/Polarity" :
221238 handleDipolePolarityMessage (messageItem .data );
222239 break ;
240+ case "dip/ALICE/LHC/Bookkeeping/Source" :
241+ handleBookkeepingSourceMessage (messageItem .data );
242+ break ;
243+ case "dip/ALICE/LHC/Bookkeeping/CTPClock" :
244+ handleBookkeepingCtpClockMessage (messageItem .data );
245+ break ;
223246 default :
224247 AliDip2BK .log (
225248 4 ,
@@ -464,18 +487,18 @@ public void EndRun(RunInfoObj r1) {
464487 }
465488
466489 AliDip2BK .log (
467- 2 ,
468- "ProcData.EndRun" ,
469- " Correctly closed runNo=" + r1 .RunNo + " ActiveRuns size=" + ActiveRuns .size () + " " + runList1
490+ 2 ,
491+ "ProcData.EndRun" ,
492+ " Correctly closed runNo=" + r1 .RunNo + " ActiveRuns size=" + ActiveRuns .size () + " " + runList1
470493 );
471494
472495 if (r1 .LHC_info_start .fillNo != r1 .LHC_info_stop .fillNo ) {
473496
474497 AliDip2BK .log (
475- 5 ,
476- "ProcData.EndRun" ,
477- " !!!! RUN =" + r1 .RunNo + " Statred FillNo=" + r1 .LHC_info_start .fillNo
478- + " and STOPED with FillNo=" + r1 .LHC_info_stop .fillNo
498+ 5 ,
499+ "ProcData.EndRun" ,
500+ " !!!! RUN =" + r1 .RunNo + " Statred FillNo=" + r1 .LHC_info_start .fillNo
501+ + " and STOPED with FillNo=" + r1 .LHC_info_stop .fillNo
479502 );
480503 }
481504 }
@@ -526,10 +549,10 @@ public void newFillNo(long date, String strFno, String par1, String par2, String
526549 }
527550 } else {
528551 AliDip2BK .log (
529- 3 ,
530- "ProcData.newFillNo" ,
531- " Received new FILL no=" + no + " BUT is an active FILL =" + currentFill .fillNo
532- + " Close the old one and created the new one"
552+ 3 ,
553+ "ProcData.newFillNo" ,
554+ " Received new FILL no=" + no + " BUT is an active FILL =" + currentFill .fillNo
555+ + " Close the old one and created the new one"
533556 );
534557 currentFill .endedTime = (new Date ()).getTime ();
535558 if (AliDip2BK .KEEP_FILLS_HISTORY_DIRECTORY != null ) {
@@ -557,9 +580,9 @@ public void newBeamMode(long date, String BeamMode) {
557580 if (mc < 0 ) {
558581
559582 AliDip2BK .log (
560- 2 ,
561- "ProcData.newBeamMode" ,
562- "New beam mode=" + BeamMode + " for FILL_NO=" + currentFill .fillNo
583+ 2 ,
584+ "ProcData.newBeamMode" ,
585+ "New beam mode=" + BeamMode + " for FILL_NO=" + currentFill .fillNo
563586 );
564587 bookkeepingClient .updateLhcFill (currentFill );
565588 saveState ();
@@ -570,9 +593,9 @@ public void newBeamMode(long date, String BeamMode) {
570593 writeFillHistFile (currentFill );
571594 }
572595 AliDip2BK .log (
573- 3 ,
574- "ProcData.newBeamMode" ,
575- "CLOSE Fill_NO=" + currentFill .fillNo + " Based on new beam mode=" + BeamMode
596+ 3 ,
597+ "ProcData.newBeamMode" ,
598+ "CLOSE Fill_NO=" + currentFill .fillNo + " Based on new beam mode=" + BeamMode
576599 );
577600 currentFill = null ;
578601 }
@@ -710,4 +733,31 @@ public void writeHistFile(String filename, ArrayList<TimestampedFloat> A) {
710733 AliDip2BK .log (4 , "ProcData.writeHistFile" , " ERROR writing file=" + filename + " ex=" + e );
711734 }
712735 }
736+
737+ private void handleBookkeepingSourceMessage (DipData dipData ) throws BadParameter , TypeMismatch {
738+ var acceptance = dipData .extractFloat ("Acceptance" );
739+ var crossSection = dipData .extractFloat ("CrossSection" );
740+ var efficiency = dipData .extractFloat ("Efficiency" );
741+ AliDip2BK .log (
742+ 2 ,
743+ "ProcData.dispatch" ,
744+ " Bookkeeping Source: Acceptance=" + acceptance + " CrossSection=" + crossSection
745+ + " Efficiency=" + efficiency
746+ );
747+ luminosityManager .setTriggerEfficiency (efficiency );
748+ luminosityManager .setTriggerAcceptance (acceptance );
749+ luminosityManager .setCrossSection (crossSection );
750+ }
751+
752+ private void handleBookkeepingCtpClockMessage (DipData dipData ) throws BadParameter , TypeMismatch {
753+ var phaseShiftBeam1 = dipData .extractFloat ("PhaseShift_Beam1" );
754+ var phaseShiftBeam2 = dipData .extractFloat ("PhaseShift_Beam2" );
755+
756+ AliDip2BK .log (
757+ 2 ,
758+ "ProcData.dispatch" ,
759+ " Bookkeeping CTP Clock: PhaseShift_Beam1=" + phaseShiftBeam1 + " PhaseShift_Beam2=" + phaseShiftBeam2
760+ );
761+ luminosityManager .setPhaseShift (new PhaseShift (phaseShiftBeam1 , phaseShiftBeam2 ));
762+ }
713763}
0 commit comments