From bbd0d93645c9bad5eab4c64fc46b9de49b696fed Mon Sep 17 00:00:00 2001
From: Tamas Gal <tgal@km3net.de>
Date: Mon, 18 Feb 2019 20:26:17 +0100
Subject: [PATCH] Fix parameters

---
 scripts/k40_calibration.py | 70 ++++++++++++++++++++++++--------------
 1 file changed, 44 insertions(+), 26 deletions(-)

diff --git a/scripts/k40_calibration.py b/scripts/k40_calibration.py
index 01371bc..0dcae54 100755
--- a/scripts/k40_calibration.py
+++ b/scripts/k40_calibration.py
@@ -11,6 +11,7 @@ The following script calculates the PMT time offsets using K40 coincidences
 """
 # Author: Jonas Reubelt <jreubelt@km3net.de> and Tamas Gal <tgal@km3net.de>
 # License: MIT
+import os
 import km3pipe as kp
 import km3pipe.style
 from km3modules import k40
@@ -19,29 +20,46 @@ from km3modules.plot import IntraDOMCalibrationPlotter
 
 km3pipe.style.use('km3pipe')
 
-DET_ID = 39
-
-pipe = kp.Pipeline(timeit=True)
-pipe.attach(
-    kp.io.ch.CHPump,
-    host='127.0.0.1',
-    port=6001,
-    tags='IO_TSL1, IO_MONIT',
-    timeout=7 * 60 * 60 * 24,
-    max_queue=200000)
-pipe.attach(kp.io.ch.CHTagger)
-pipe.attach(StatusBar, every=50000)
-pipe.attach(MemoryObserver, every=100000)
-pipe.attach(k40.MedianPMTRatesService, only_if='IO_MONIT')
-pipe.attach(kp.io.daq.TimesliceParser)
-pipe.attach(k40.TwofoldCounter, tmax=10, dump_filename='../twofold_counts.p')
-pipe.attach(Siphon, volume=10 * 60 * 180, flush=True)
-pipe.attach(k40.K40BackgroundSubtractor)
-pipe.attach(k40.IntraDOMCalibrator, ctmin=-1, det_id=DET_ID)
-pipe.attach(
-    IntraDOMCalibrationPlotter,
-    det_oid="D0DU004MA",
-    data_path='../data',
-    plots_path='../plots')
-pipe.attach(k40.ResetTwofoldCounts)
-pipe.drain()
+
+def main():
+    from docopt import docopt
+    args = docopt(__doc__)
+
+    det_id = int(args['-d'])
+    plots_path = args['-o']
+    ligier_ip = args['-l']
+    ligier_port = int(args['-p'])
+
+    det_oid = kp.db.DBManager().get_det_oid(det_id)
+
+    pipe = kp.Pipeline(timeit=True)
+    pipe.attach(
+        kp.io.ch.CHPump,
+        host=ligier_ip,
+        port=ligier_port,
+        tags='IO_TSL1, IO_MONIT',
+        timeout=7 * 60 * 60 * 24,
+        max_queue=200000)
+    pipe.attach(kp.io.ch.CHTagger)
+    pipe.attach(StatusBar, every=50000)
+    pipe.attach(MemoryObserver, every=100000)
+    pipe.attach(k40.MedianPMTRatesService, only_if='IO_MONIT')
+    pipe.attach(kp.io.daq.TimesliceParser)
+    pipe.attach(
+        k40.TwofoldCounter,
+        tmax=10,
+        dump_filename=os.path.join(plots_path, 'twofold_counts.p'))
+    pipe.attach(Siphon, volume=10 * 60 * 180, flush=True)
+    pipe.attach(k40.K40BackgroundSubtractor)
+    pipe.attach(k40.IntraDOMCalibrator, ctmin=-1, det_id=det_id)
+    pipe.attach(
+        IntraDOMCalibrationPlotter,
+        det_oid=det_oid,
+        data_path=plots_path,
+        plots_path=plots_path)
+    pipe.attach(k40.ResetTwofoldCounts)
+    pipe.drain()
+
+
+if __name__ == '__main__':
+    main()
-- 
GitLab