From 6f0517c1ee9414ec9730770dadd6d24da68a2ec7 Mon Sep 17 00:00:00 2001
From: Rosen Matev <rosen.matev@cern.ch>
Date: Thu, 6 Jul 2017 23:56:18 +0200
Subject: [PATCH] Fix functor cache for Tesla

---
 Phys/TurboCache/CMakeLists.txt                | 87 +++++++------------
 .../TurboCache/options/SuppressLogMessages.py | 44 +---------
 2 files changed, 36 insertions(+), 95 deletions(-)

diff --git a/Phys/TurboCache/CMakeLists.txt b/Phys/TurboCache/CMakeLists.txt
index 88665331d..116274f1c 100644
--- a/Phys/TurboCache/CMakeLists.txt
+++ b/Phys/TurboCache/CMakeLists.txt
@@ -11,64 +11,43 @@ gaudi_depends_on_subdirs(Phys/Tesla
                          Phys/LoKiAlgo
                          Phys/LoKiCore)
 
-# 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" )
+find_package(Boost)
+find_package(ROOT)
+include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS})
+
+set(options_Turbo04
+    ${AppConfig_DIR}/options/Turbo/Tesla_Data_2017.py
+    ${AppConfig_DIR}/options/Turbo/Streams_pp_2017.py
+    )
+
+set(options_Turbo04_TurCal
+    ${AppConfig_DIR}/options/Turbo/Tesla_Data_2017_TurCal.py
+    ${AppConfig_DIR}/options/Turbo/Tesla_Calibration_Hlt2Lines_2017.py
+    )
 
- 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)
+# Do not build for the -O0 platform, as this seems to have problems.
+if (NOT "$ENV{CMTCONFIG}" MATCHES ".*-do0$")
+
+  # Import the cache creation module
+  include(LoKiFunctorsCache)
 
- # Set dependency so caches build last, after Tesla itself.
- set ( conf_deps ${deps} TeslaConfUserDB )
+  # 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()
+  foreach(production Turbo04 Turbo04_TurCal)
+    set(cache_name ${production}_FunctorCache)
+    set(option_files ${options_${production}})
+    MESSAGE(STATUS "Cache for ${production} from: ${option_files}")
 
+    loki_functors_cache(${cache_name}
+                        options/SuppressLogMessages.py
+                        ${option_files}
+                        options/NoEvents.py
+                        options/DisableLoKiCacheFunctors.py
+                        FACTORIES HltFactory Hlt2HltFactory
+                        LINK_LIBRARIES LoKiHltLib
+                        DEPENDS ${conf_deps}
+                        SPLIT 10)
   endforeach()
- endforeach()
 endif()
diff --git a/Phys/TurboCache/options/SuppressLogMessages.py b/Phys/TurboCache/options/SuppressLogMessages.py
index 9b04125c7..a1353423f 100644
--- a/Phys/TurboCache/options/SuppressLogMessages.py
+++ b/Phys/TurboCache/options/SuppressLogMessages.py
@@ -1,43 +1,5 @@
-# -*- coding: utf-8 -*-
-from Gaudi.Configuration import log
 import logging
-import re
+from GaudiKernel.ProcessJobOptions import GetConsoleHandler
 
-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
+# Do not print any of the messages with level lower than WARNING
+GetConsoleHandler().disable(allowed=logging.WARNING)
-- 
GitLab