From 3b89937f4ef6504d14492ee474264f7773a98b5c Mon Sep 17 00:00:00 2001
From: Sascha Stahl <sascha.stahl@cern.ch>
Date: Sat, 17 Sep 2016 18:01:26 +0200
Subject: [PATCH 1/6] Initial commit of Functor cache for Turbo streaming
 productions

---
 Phys/TurboCache/CMakeLists.txt                | 69 +++++++++++++++++++
 Phys/TurboCache/cmt/requirements              | 13 ++++
 Phys/TurboCache/doc/release.notes             | 14 ++++
 .../options/DisableLoKiCacheFunctors.py       |  3 +
 Phys/TurboCache/options/NoEvents.py           |  2 +
 Phys/TurboCache/options/SilenceErrors.py      |  3 +
 Phys/TurboCache/options/Streams_v4r1.py       |  8 +++
 .../TurboCache/options/SuppressLogMessages.py | 43 ++++++++++++
 .../options/Tesla_Data_2016_forStreams_v2.py  | 18 +++++
 9 files changed, 173 insertions(+)
 create mode 100644 Phys/TurboCache/CMakeLists.txt
 create mode 100644 Phys/TurboCache/cmt/requirements
 create mode 100644 Phys/TurboCache/doc/release.notes
 create mode 100644 Phys/TurboCache/options/DisableLoKiCacheFunctors.py
 create mode 100644 Phys/TurboCache/options/NoEvents.py
 create mode 100644 Phys/TurboCache/options/SilenceErrors.py
 create mode 100644 Phys/TurboCache/options/Streams_v4r1.py
 create mode 100644 Phys/TurboCache/options/SuppressLogMessages.py
 create mode 100755 Phys/TurboCache/options/Tesla_Data_2016_forStreams_v2.py

diff --git a/Phys/TurboCache/CMakeLists.txt b/Phys/TurboCache/CMakeLists.txt
new file mode 100644
index 000000000..7599cbe7d
--- /dev/null
+++ b/Phys/TurboCache/CMakeLists.txt
@@ -0,0 +1,69 @@
+################################################################################
+# Package: TurboCache
+################################################################################
+gaudi_subdir(TurboCache v1r0)
+
+gaudi_depends_on_subdirs(Phys/Tesla
+                         Phys/LoKiHlt)
+
+# Do not build for the -O0 platform, as this seems to have problems.
+# To be investigated...
+if ( NOT "$ENV{CMTCONFIG}" STREQUAL "x86_64-slc6-gcc48-do0" )
+
+ foreach(pack Tesla )
+   # FIXME: this will be needed until GAUDI-1055 is fixed.
+   if(EXISTS ${CMAKE_BINARY_DIR}/Phys/${pack}/genConf/${pack})
+     gaudi_build_env(PREPEND PYTHONPATH ${CMAKE_BINARY_DIR}/Phys/${pack}/genConf/${pack})
+   endif()
+ #  if(TARGET ${pack}Conf)
+ #    set(deps ${conf_deps} ${pack}Conf )
+ #  endif()
+ #  if(TARGET ${pack}ComponentsList)
+ #    set(deps ${conf_deps} ${pack}ComponentsList )
+ #  endif()
+ endforeach()
+ 
+ # Import the cache creation module
+
+ include(LoKiFunctorsCache)
+
+ # Set dependency so caches build last, after Tesla itself.
+ set ( conf_deps ${deps} TeslaConfUserDB )
+
+ # Build the caches, most recent first
+ foreach(production Turbo03)
+  if (production STREQUAL Turbo03)
+   # Cannot set with $APPCONFIGROOT apparently
+   #set ( optsfile1 $ENV{APPCONFIGROOT}/options/Turbo/Tesla_Data_2016_forStreams_v2.py )
+   set ( optsfile1 ${CMAKE_CURRENT_SOURCE_DIR}/options/Tesla_Data_2016_forStreams_v2.py )
+  endif()
+  foreach(version v4r1)
+   # Stripping cache name
+   set ( sname S${production}_${version}FunctorCache )
+   
+   #set ( optsfile1 $ENV{APPCONFIGROOT}/options/Turbo/Streams_${version}.py )
+   set ( optsfile2 ${CMAKE_CURRENT_SOURCE_DIR}/options/Streams_${version}.py )
+   # cache build if options exist
+   if ( EXISTS ${optsfile1} )
+   
+     # Print this cache
+     MESSAGE( STATUS "S" ${production} ${version} " : " ${optsfile1} " " ${optsfile2} )
+   
+     # Build !
+     loki_functors_cache(${sname}
+                         options/SuppressLogMessages.py
+                         ${optsfile1}
+                         ${optsfile2}
+                         options/SilenceErrors.py 
+                         options/NoEvents.py
+                         options/DisableLoKiCacheFunctors.py
+                         LINK_LIBRARIES LoKiHltLib
+                         DEPENDS ${conf_deps}
+                         SPLIT 10
+			 FACTORIES HltFactory Hlt2HltFactory)
+   
+   endif()
+
+  endforeach()
+ endforeach()
+endif()
diff --git a/Phys/TurboCache/cmt/requirements b/Phys/TurboCache/cmt/requirements
new file mode 100644
index 000000000..dc2ff29a4
--- /dev/null
+++ b/Phys/TurboCache/cmt/requirements
@@ -0,0 +1,13 @@
+# =============================================================================
+# Created    : 2016-09-14
+# Maintainer : 
+# =============================================================================
+package           TurboCache
+version           v1r0
+
+# The build of this package is not enabled with CMT
+
+# =============================================================================
+# The END
+# =============================================================================
+
diff --git a/Phys/TurboCache/doc/release.notes b/Phys/TurboCache/doc/release.notes
new file mode 100644
index 000000000..7018dfe28
--- /dev/null
+++ b/Phys/TurboCache/doc/release.notes
@@ -0,0 +1,14 @@
+! -----------------------------------------------------------------------------
+! Package     : TurboCache
+! Responsible : 
+! Purpose     : Keep C++ functors for turbo
+! Created     : 2016-09-17
+! -----------------------------------------------------------------------------
+
+2016-09-17 - Sascha Stahl
+- Initial commit of TurboCache, creates the cache for the first streaming 
+  production of 2016.
+
+! -----------------------------------------------------------------------------
+! The END
+! -----------------------------------------------------------------------------
diff --git a/Phys/TurboCache/options/DisableLoKiCacheFunctors.py b/Phys/TurboCache/options/DisableLoKiCacheFunctors.py
new file mode 100644
index 000000000..e168c86cc
--- /dev/null
+++ b/Phys/TurboCache/options/DisableLoKiCacheFunctors.py
@@ -0,0 +1,3 @@
+
+from Configurables import ApplicationMgr
+ApplicationMgr().Environment['LOKI_DISABLE_CACHE'] = '1'
diff --git a/Phys/TurboCache/options/NoEvents.py b/Phys/TurboCache/options/NoEvents.py
new file mode 100644
index 000000000..769ef8f05
--- /dev/null
+++ b/Phys/TurboCache/options/NoEvents.py
@@ -0,0 +1,2 @@
+from Configurables import Tesla
+Tesla().EvtMax = 0
diff --git a/Phys/TurboCache/options/SilenceErrors.py b/Phys/TurboCache/options/SilenceErrors.py
new file mode 100644
index 000000000..3aef38f82
--- /dev/null
+++ b/Phys/TurboCache/options/SilenceErrors.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+from Gaudi.Configuration import MessageSvc, FATAL
+MessageSvc(OutputLevel=FATAL)
diff --git a/Phys/TurboCache/options/Streams_v4r1.py b/Phys/TurboCache/options/Streams_v4r1.py
new file mode 100644
index 000000000..0973550cd
--- /dev/null
+++ b/Phys/TurboCache/options/Streams_v4r1.py
@@ -0,0 +1,8 @@
+from TurboStreamProd.streams import turbo_streams 
+from Configurables import Tesla
+Tesla().Streams = turbo_streams
+
+#Tesla().ValidateStreams = True
+# Turn on Sascha's algorithm ignoring TurboCalib
+Tesla().EnableLineChecker = True
+Tesla().IgnoredLines = [".*TurboCalib"]
diff --git a/Phys/TurboCache/options/SuppressLogMessages.py b/Phys/TurboCache/options/SuppressLogMessages.py
new file mode 100644
index 000000000..9b04125c7
--- /dev/null
+++ b/Phys/TurboCache/options/SuppressLogMessages.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+from Gaudi.Configuration import log
+import logging
+import re
+
+IGNORED_MESSAGES = map(re.compile,
+                       (
+                        # errors
+                        r'The default_config of .* (is not a dictionary|has incorrect keys)',
+                        r'The key .* is not allowed',
+                        r'Allowed keys are:',
+                        # warnings
+                        r'Line .* is declared but not appended to any stream',
+                        r'uses plain Gaudi configurable',
+                        r'has non-default configuration',
+                        r'    .*\(default =',
+                        r'The usage of unique HLT is deprecated',
+                        r'Requests Flavor Tagging but is not assigned',
+                        r'has prescale <= 0',
+                        r'share the same output location',
+                        r'how to add new bank',
+                        r'Using default tag.*for partition',
+                        r'The lines going to MDST.DST are',
+                        r'No explicit tuning for DataType',
+                        r'something else configured a decoder already',
+                        r'REMOVE UT decoding from DataOnDemand',
+                        r'Applied corrections configured via options for',
+                        r'requesting factory via old name'
+                       ))
+
+_orig_log_filter = log.filter
+def old_stripping_filter(record):
+    '''
+    Hide known warnings and errors in old Stripping configurations.
+    '''
+    if record.levelno >= logging.WARNING:
+        if any(exp.search(record.msg) for exp in IGNORED_MESSAGES):
+            return False
+        if not record.msg.strip():
+            return False # why should anyone want to print an empty warning?
+    return _orig_log_filter(record)
+
+log.filter = old_stripping_filter
diff --git a/Phys/TurboCache/options/Tesla_Data_2016_forStreams_v2.py b/Phys/TurboCache/options/Tesla_Data_2016_forStreams_v2.py
new file mode 100755
index 000000000..1c9d55981
--- /dev/null
+++ b/Phys/TurboCache/options/Tesla_Data_2016_forStreams_v2.py
@@ -0,0 +1,18 @@
+from Configurables import Tesla 
+Tesla().Pack = True
+Tesla().InputType = "RAW"
+Tesla().DataType = '2016'
+Tesla().Simulation = False
+Tesla().Mode = 'Online'
+Tesla().RawFormatVersion = 0.2
+Tesla().VertRepLoc = 'Hlt2'
+Tesla().Park=True
+Tesla().KillInputHlt2Reps=True
+
+Tesla().outputSuffix = ".mdst"
+#Tesla().outputPrefix = "TURBO_"
+
+### Already juggled online
+Tesla().VetoJuggle = True
+
+Tesla().HDRFilter=True
-- 
GitLab


From 0bc8f8d1b020d04c67bb24c7fc89e440f974917b Mon Sep 17 00:00:00 2001
From: Sascha Stahl <sascha.stahl@cern.ch>
Date: Sat, 17 Sep 2016 18:07:23 +0200
Subject: [PATCH 2/6] Add extra dependencies, probably not needed

---
 Phys/TurboCache/CMakeLists.txt | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Phys/TurboCache/CMakeLists.txt b/Phys/TurboCache/CMakeLists.txt
index 7599cbe7d..a424a803f 100644
--- a/Phys/TurboCache/CMakeLists.txt
+++ b/Phys/TurboCache/CMakeLists.txt
@@ -4,7 +4,13 @@
 gaudi_subdir(TurboCache v1r0)
 
 gaudi_depends_on_subdirs(Phys/Tesla
-                         Phys/LoKiHlt)
+                         Phys/LoKiHlt
+                         Phys/LoKiArrayFunctors
+                         Phys/LoKiHlt
+                         Phys/LoKiPhys
+                         Phys/LoKiAlgo
+                         Phys/LoKiCore
+                         Phys/LoKiTrigger)
 
 # Do not build for the -O0 platform, as this seems to have problems.
 # To be investigated...
-- 
GitLab


From f84e260a11e15f1a0a29079812628586ec4a719b Mon Sep 17 00:00:00 2001
From: Sascha Stahl <sascha.stahl@cern.ch>
Date: Sat, 17 Sep 2016 18:08:05 +0200
Subject: [PATCH 3/6] Small fix

---
 Phys/TurboCache/CMakeLists.txt | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Phys/TurboCache/CMakeLists.txt b/Phys/TurboCache/CMakeLists.txt
index a424a803f..46d47996a 100644
--- a/Phys/TurboCache/CMakeLists.txt
+++ b/Phys/TurboCache/CMakeLists.txt
@@ -9,8 +9,7 @@ gaudi_depends_on_subdirs(Phys/Tesla
                          Phys/LoKiHlt
                          Phys/LoKiPhys
                          Phys/LoKiAlgo
-                         Phys/LoKiCore
-                         Phys/LoKiTrigger)
+                         Phys/LoKiCore)
 
 # Do not build for the -O0 platform, as this seems to have problems.
 # To be investigated...
-- 
GitLab


From 89bb6dabf62b391a747f41e4a79b71ef3e310adf Mon Sep 17 00:00:00 2001
From: Sascha Stahl <sascha.stahl@cern.ch>
Date: Sun, 18 Sep 2016 22:56:07 +0200
Subject: [PATCH 4/6] Add missing entry in DaVinciSys

---
 DaVinciSys/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/DaVinciSys/CMakeLists.txt b/DaVinciSys/CMakeLists.txt
index 901895bbb..dd3c38af2 100644
--- a/DaVinciSys/CMakeLists.txt
+++ b/DaVinciSys/CMakeLists.txt
@@ -7,6 +7,7 @@ gaudi_depends_on_subdirs(DaVinciTests
                          ##############################
                          # Temporarily moved in from Stripping, for S23 release
                          Phys/StrippingCache
+			 Phys/TurboCache
                          ##############################
                          Phys/DaVinci
                          Phys/KaliCalo
-- 
GitLab


From c101a27b59405d48eb8b2424ceb45395ec426a61 Mon Sep 17 00:00:00 2001
From: Sascha Stahl <sascha.stahl@cern.ch>
Date: Sun, 18 Sep 2016 22:57:35 +0200
Subject: [PATCH 5/6] Update cmt requirements file

---
 DaVinciSys/cmt/requirements | 1 +
 1 file changed, 1 insertion(+)

diff --git a/DaVinciSys/cmt/requirements b/DaVinciSys/cmt/requirements
index c4fc60e7b..d35d8dcc7 100755
--- a/DaVinciSys/cmt/requirements
+++ b/DaVinciSys/cmt/requirements
@@ -8,6 +8,7 @@ branches doc cmt
 # To be decided if longer term this stays in the DaVinci 
 # project, or moves elsewhere.
 use StrippingCache   *     Phys
+use TurboCache   *     Phys
 ##############################
 
 # Packages
-- 
GitLab


From 40d3ab65b3c79c8a67d210e3df77efb37663f340 Mon Sep 17 00:00:00 2001
From: Rosen Matev <rosen.matev@cern.ch>
Date: Tue, 20 Sep 2016 19:18:05 +0200
Subject: [PATCH 6/6] Workaround for the TurboCache compilation

---
 DaVinciSys/CMakeLists.txt                                | 5 +++--
 Phys/TurboCache/options/NoEvents.py                      | 2 +-
 Phys/TurboCache/options/Streams_v4r1.py                  | 4 ++--
 Phys/TurboCache/options/Tesla_Data_2016_forStreams_v2.py | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/DaVinciSys/CMakeLists.txt b/DaVinciSys/CMakeLists.txt
index dd3c38af2..4939136fd 100644
--- a/DaVinciSys/CMakeLists.txt
+++ b/DaVinciSys/CMakeLists.txt
@@ -7,10 +7,11 @@ gaudi_depends_on_subdirs(DaVinciTests
                          ##############################
                          # Temporarily moved in from Stripping, for S23 release
                          Phys/StrippingCache
-			 Phys/TurboCache
                          ##############################
                          Phys/DaVinci
                          Phys/KaliCalo
-                         Phys/Tesla)
+                         Phys/Tesla
+                         Phys/TurboCache
+                         )
 
 gaudi_add_test(QMTest QMTEST)
diff --git a/Phys/TurboCache/options/NoEvents.py b/Phys/TurboCache/options/NoEvents.py
index 769ef8f05..147e369ef 100644
--- a/Phys/TurboCache/options/NoEvents.py
+++ b/Phys/TurboCache/options/NoEvents.py
@@ -1,2 +1,2 @@
-from Configurables import Tesla
+from Tesla.Configuration import Tesla
 Tesla().EvtMax = 0
diff --git a/Phys/TurboCache/options/Streams_v4r1.py b/Phys/TurboCache/options/Streams_v4r1.py
index 0973550cd..6594f48d5 100644
--- a/Phys/TurboCache/options/Streams_v4r1.py
+++ b/Phys/TurboCache/options/Streams_v4r1.py
@@ -1,5 +1,5 @@
-from TurboStreamProd.streams import turbo_streams 
-from Configurables import Tesla
+from TurboStreamProd.streams import turbo_streams
+from Tesla.Configuration import Tesla
 Tesla().Streams = turbo_streams
 
 #Tesla().ValidateStreams = True
diff --git a/Phys/TurboCache/options/Tesla_Data_2016_forStreams_v2.py b/Phys/TurboCache/options/Tesla_Data_2016_forStreams_v2.py
index 1c9d55981..42b238e74 100755
--- a/Phys/TurboCache/options/Tesla_Data_2016_forStreams_v2.py
+++ b/Phys/TurboCache/options/Tesla_Data_2016_forStreams_v2.py
@@ -1,4 +1,4 @@
-from Configurables import Tesla 
+from Tesla.Configuration import Tesla
 Tesla().Pack = True
 Tesla().InputType = "RAW"
 Tesla().DataType = '2016'
-- 
GitLab