From 5b37c28b277702641334d15e37d2a0a2c3710540 Mon Sep 17 00:00:00 2001
From: Paras Naik <paras.naik@cern.ch>
Date: Tue, 18 Apr 2017 18:35:47 +0200
Subject: [PATCH 1/6] Removed CKThetaQuartzRefractCorrections from the mirror
 alignment, now using defaults

---
 .../python/PyMirrAlignOnline/RichAnalyzer.py                | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
index 8f70f662d..b84ecfce3 100644
--- a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
+++ b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
@@ -197,11 +197,11 @@ def patchBrunel(true_online_version, alignConf, n):
   EventLoopMgr().Warnings    = False
 
   # Hack by Chris
-  #print "# Warning using CKThetaQuartzRefractCorrections = [ 0,-0.0001,0 ]"
   from Configurables import RichRecSysConf
   rConf = RichRecSysConf("RichOfflineRec")
-  #rConf.richTools().photonReco().CKThetaQuartzRefractCorrections = [ 0,-0.001,0 ]
-  rConf.richTools().photonReco().CKThetaQuartzRefractCorrections = [ -0.00625, 0.000247332, 2.9e-5 ]
+  # 2017-04-18 Chris suggests removing CKThetaQuartzRefractCorrections:
+  # print "# Warning using CKThetaQuartzRefractCorrections = ( -0.00625, 0.000247332, 2.9e-5 )"
+  # rConf.richTools().photonReco().CKThetaQuartzRefractCorrections = ( -0.00625, 0.000247332, 2.9e-5 )
   rConf.setProp("PidConfig", "None")
 
   # Need a postConfigAction to apply the correct condtions
-- 
GitLab


From 0ed5d37ee0b50fd3d2c0083345e7ce627826f344 Mon Sep 17 00:00:00 2001
From: Paras Naik <paras.naik@cern.ch>
Date: Tue, 18 Apr 2017 18:58:31 +0200
Subject: [PATCH 2/6] Changed CKThetaResRange type from list to tuple, as
 required by the newest Rec

---
 .../python/PyMirrAlignOnline/RichAnalyzer.py                  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
index b84ecfce3..9c2c0a2b3 100644
--- a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
+++ b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
@@ -239,7 +239,7 @@ def patchBrunel(true_online_version, alignConf, n):
   ## 2017-03-22 We now also want our special monitor with RichRecQC "TightMirror" cuts [similar to hacked RichRecQC we used in 2016] to run. #####  
   RichRecQCConf ("OfflineRichMoni").addMonitor("PhotonMonitoringAlignOnline") # i.e. this is NOT a default monitor
   ## Added the next line on 2016-04-08, to Open up the CK res plot range, for the Wide photon selection
-  RichRecQCConf ("OfflineRichMoni").CKThetaResRange = [ 0.05, 0.008, 0.004 ]
+  RichRecQCConf ("OfflineRichMoni").CKThetaResRange = ( 0.05, 0.008, 0.004 )
   ##############################################################################################
   RichRecQCConf ("OfflineRichMoni").removeMonitor("TracklessRingAngles"    )
   RichRecQCConf ("OfflineRichMoni").removeMonitor("TracklessRingPeakSearch")
@@ -275,7 +275,7 @@ def patchBrunel(true_online_version, alignConf, n):
   RichAlign.R1NTupleProduce = False
 
   deltatheta = alignConf.getProp("deltaThetaWindow")/1000.
-  RichAlign.DeltaThetaRange = [0.04,deltatheta, deltatheta ]
+  RichAlign.DeltaThetaRange = [ 0.04, deltatheta, deltatheta ]
 
   brunel.OutputLevel       = MSG_INFO
   brunel.PrintFreq         = 100
-- 
GitLab


From 684a00e80a7156254e0d977b550bdf240dc6fc38 Mon Sep 17 00:00:00 2001
From: Paras Naik <paras.naik@cern.ch>
Date: Tue, 18 Apr 2017 19:20:24 +0200
Subject: [PATCH 3/6] Changed the alignment elapsed time timer to start upon
 each CONFIGURE

---
 .../python/PyMirrAlignOnline/Iterator.py                   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/Iterator.py b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/Iterator.py
index ec872d2e4..ded67f632 100644
--- a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/Iterator.py
+++ b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/Iterator.py
@@ -20,7 +20,7 @@ from   distutils  import dir_util
 ##### Here is where the party starts!
 ########################################################################################################################     
 def run(whichRich):
-  start_time = time()
+  start_time = time() # this is a default, will be updated when the CONFIGURE command is received
   
   ### define the communicator who will communicate with the run-control
   com = Communicator('ALIGNITER')
@@ -87,6 +87,7 @@ def run(whichRich):
     ########################################################################################################################       
     if command.startswith('configure') and state == State.NOT_READY:
       print "CONFIGURE command received at " + strftime("%Y-%m-%d %H:%M:%S", gmtime()) + " UTC"
+      start_time = time() # sets the timer to zero on every CONFIGURE
       setupHelper = SetupHelper(alignConf)
       xmlHelper = XMLFileHelper(alignConf)
       ssretr = SaveSetRetriever("LHCbA", "AligWrk_Rich" + str(whichRich))
@@ -197,7 +198,7 @@ def run(whichRich):
             print "INFO Alignment has converged after the ", n_it, "th iteration!"
           else:
             print "INFO Alignment has reached its maximum number of iterations and has not converged. :("
-          elapsed_time = time() - start_time # Elapsed time since run(whichRich) was called
+          elapsed_time = time() - start_time # Elapsed time since CONFIGURE (not START!)
           if updateHelper.updateDecision(n_it):
               updateHelper.updateDB()
               setupHelper.finalize(conv, n_it, compareXML, elapsed_time, True)
@@ -235,7 +236,7 @@ def run(whichRich):
       
     elif command.startswith('stop') and state in (State.RUNNING, State.READY):
       print "STOP command received at " + strftime("%Y-%m-%d %H:%M:%S", gmtime()) + " UTC"
-      elapsed_time = time() - start_time # Elapsed time since run(whichRich) was called
+      elapsed_time = time() - start_time # Elapsed time since CONFIGURE (not START!)
       setupHelper.finalize(conv, n_it, compareXML, elapsed_time, False)
       state = State.READY
     elif command.startswith('reset'):
-- 
GitLab


From b31d78d27856cbcf82ac92c7648b32b6b7786124 Mon Sep 17 00:00:00 2001
From: Paras Naik <paras.naik@cern.ch>
Date: Tue, 18 Apr 2017 19:50:21 +0200
Subject: [PATCH 4/6] Changed elapsed time in ELOG and summary.txt to a more
 readable format

---
 .../python/PyMirrAlignOnline/SetupHelper.py   | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/SetupHelper.py b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/SetupHelper.py
index bc6a6127b..6f9602357 100644
--- a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/SetupHelper.py
+++ b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/SetupHelper.py
@@ -82,6 +82,9 @@ class SetupHelper:
 
     #def writeInLogbook(Fill, activity, updated = False, file2upload=None, version = None, bigVariations=None):
     def writeInLogbook(self, conv, n_it, elapsed_time, summaryFile, ChangeWRTDBFile, ckResSummaryFile, DBUpdated, nEvents):
+        hh, r = divmod(elapsed_time, 3600)
+        mm, ss = divmod(r, 60)
+        elapsed_time_str = "{:0>2}:{:0>2}:{:05.2f}".format(int(hh),int(mm),ss)
         host = 'lblogbook.cern.ch' 
         port = 8080
         username = 'common Common\\!'
@@ -97,14 +100,14 @@ class SetupHelper:
         text += " for RICH"
         text += str(self.whichRich)
         if conv:
-            text += " converged in "
-            text += str(elapsed_time)
-            text += " seconds. "
+            text += " ran for "
+            text += elapsed_time_str
+            text += " and converged. "
             subject = 'Alignment converged'
         else:
             text += " ran for "
-            text += str(elapsed_time)
-            text += " seconds and did not converge. "
+            text += elapsed_time_str
+            text += " and did not converge. "
         text += "We processed "
         text += str(nEvents)
         text += " events from the RICH"
@@ -151,6 +154,10 @@ class SetupHelper:
         return 0
 
     def writeSummary(self, conv, n_it, elapsed_time, summaryFile, DBUpdated, nEvents):
+        hh, r = divmod(elapsed_time, 3600)
+        mm, ss = divmod(r, 60)
+        elapsed_time_str = "{:0>2}:{:0>2}:{:05.2f}".format(int(hh),int(mm),ss)
+        
         import OnlineEnv as Online
         runs = Online.DeferredRuns
         hasi = ''
@@ -183,7 +190,7 @@ class SetupHelper:
         args += 'stopToleranceSecZ      = ' + str(self.alignConf.getProp('stopToleranceSecZ')) + '\n'
         args += '\n'
         args += 'Number of events  = ' + str(nEvents) + '\n'
-        args += 'Elapsed time      = ' + str(elapsed_time) + ' seconds' + '\n'
+        args += 'Elapsed time      = ' + elapsed_time_str + '\n'
         args += 'DB updated        = ' + str(DBUpdated) + '\n'
         f.write(args)
         f.close()
-- 
GitLab


From 9a34459dfb1e4be24c558cdd19eb390ac5aca3fc Mon Sep 17 00:00:00 2001
From: Paras Naik <paras.naik@cern.ch>
Date: Wed, 19 Apr 2017 14:07:41 +0200
Subject: [PATCH 5/6] brunel.UseDBSnapshot now is False in RichAnalyzer (this
 may be temporary, currently needed to acces HPD QE info from DBs)

---
 .../python/PyMirrAlignOnline/RichAnalyzer.py                    | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
index 9c2c0a2b3..1dcdab2c3 100644
--- a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
+++ b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
@@ -114,6 +114,8 @@ def patchBrunel(true_online_version, alignConf, n):
   brunel.CondDBtag = ConditionsMap.CondDBTag
   brunel.Histograms =  "Expert"
   brunel.DataType = "2016"
+  # brunel.UseDBSnapshot = True
+  # 20180419 - Recommendation by Roel to avoid missing HPD QE error, due to move of QEs to Online DB
   brunel.UseDBSnapshot = True
 
   brunel.OutputType='NONE'
-- 
GitLab


From e0c867f8de824e28eb629d88b6eef6e2668fe4f6 Mon Sep 17 00:00:00 2001
From: Paras Naik <paras.naik@cern.ch>
Date: Wed, 19 Apr 2017 14:10:00 +0200
Subject: [PATCH 6/6] brunel.UseDBSnapshot now is False in RichAnalyzer (this
 may be temporary, currently needed to acces HPD QE info from DBs) 2

---
 .../python/PyMirrAlignOnline/RichAnalyzer.py                    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
index 1dcdab2c3..5660334f9 100644
--- a/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
+++ b/Rich/RichMirrorAlignmentOnline/python/PyMirrAlignOnline/RichAnalyzer.py
@@ -116,7 +116,7 @@ def patchBrunel(true_online_version, alignConf, n):
   brunel.DataType = "2016"
   # brunel.UseDBSnapshot = True
   # 20180419 - Recommendation by Roel to avoid missing HPD QE error, due to move of QEs to Online DB
-  brunel.UseDBSnapshot = True
+  brunel.UseDBSnapshot = False
 
   brunel.OutputType='NONE'
 
-- 
GitLab