diff --git a/Utilities/KalTest/CMakeLists.txt b/Utilities/KalTest/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..65fba19a54749a7dc885d91f576388805f0fcc65
--- /dev/null
+++ b/Utilities/KalTest/CMakeLists.txt
@@ -0,0 +1,51 @@
+##############################################################################
+# Package: KalTest
+#    Desc: import from ILCSoft
+##############################################################################
+
+gaudi_subdir(KalTest v0r0)
+
+find_package(ROOT REQUIRED COMPONENTS MathCore)
+
+gaudi_depends_on_subdirs()
+
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
+
+SET( ROOT_DICT_CINT_DEFINITIONS "-DHANDLE_DICT_EXCEPTIONS=IGNORED_FOR_CINT" )
+
+INCLUDE( MyFindROOT )
+INCLUDE( MacroRootDict )
+
+SET( lib_input_dirs src/geomlib src/kallib src/kaltracklib src/utils )
+
+FOREACH( lib_input_dir ${lib_input_dirs} )
+    LIST( APPEND ROOT_DICT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${lib_input_dir} )
+ENDFOREACH()
+
+#MESSAGE( STATUS "ROOT_DICT_INCLUDE_DIRS: ${ROOT_DICT_INCLUDE_DIRS}" )
+
+FOREACH( lib_input_dir ${lib_input_dirs} )
+
+    AUX_SOURCE_DIRECTORY( ${lib_input_dir} lib_sources )
+
+    PREPARE_ROOT_DICT_HEADERS( ${lib_input_dir} )
+
+    INSTALL(DIRECTORY ${lib_input_dir}/ DESTINATION "include/kaltest"
+        FILES_MATCHING PATTERN "*.h" PATTERN "LinkDef.h" EXCLUDE
+    )
+
+    GEN_ROOT_DICT_SOURCES( ${lib_input_dir}Dict.cxx )
+
+    LIST( APPEND lib_sources ${ROOT_DICT_OUTPUT_SOURCES} )
+
+ENDFOREACH()
+
+include_directories( ${ROOT_DICT_INCLUDE_DIRS} )
+include_directories( ${ROOT_INCLUDE_DIRS} )
+
+set(KalTestLib_srcs ${lib_sources})
+
+gaudi_add_library(KalTestLib ${KalTestLib_srcs}
+			     PUBLIC_HEADERS kaltest
+			     LINK_LIBRARIES GaudiKernel ROOT
+)
diff --git a/Utilities/KalTest/cmake/MacroCheckPackageLibs.cmake b/Utilities/KalTest/cmake/MacroCheckPackageLibs.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..c4451b3e40839e00dcefe08680a34ef98a3dd2b6
--- /dev/null
+++ b/Utilities/KalTest/cmake/MacroCheckPackageLibs.cmake
@@ -0,0 +1,164 @@
+##############################################################################
+# macro for checkin package libraries in ${PKG_ROOT}/lib
+#
+#
+# macro usage:
+#   CHECK_PACKAGE_LIBS( PACKAGE_NAME stdlib1 stdlib2 ... stdlibn )
+#       only standard libraries should be passed as arguments to the macro
+#       component libraries are set by cmake in PKG_FIND_COMPONENTS (when
+#       calling FIND_PACKAGE with COMPONENTS argument) or through the
+#       variable PKG_USE_COMPONENTS
+#
+#
+# required variables:
+#   PKG_ROOT    : path to PKG root directory
+#
+#
+# returns following variables:
+#   PKG_LIBRARY_DIRS : list of paths to be used with LINK_DIRECTORIES
+#   PGK_LIBRARIES    : list of STANDARD libraries (NOT including COMPONENTS)
+#   PKG_COMPONENT_LIBRARIES    : list of COMPONENT libraries
+#   PKG_${COMPONENT}_FOUND     : set to TRUE or FALSE for each library
+#   PKG_${COMPONENT}_LIBRARY   : path to each individual library
+#
+#
+# PKG_LIBRARIES and PKG_LIBRARY_DIRS will be empty if any of the standard
+#   libraries is missing
+#
+# @author Jan Engels, Desy
+##############################################################################
+
+
+SET( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE )
+
+MACRO( CHECK_PACKAGE_LIBS _pkgname )
+
+    SET( _std_lib_missing FALSE )
+    SET( _ext_lib_missing FALSE )
+
+    SET( _std_libnames ${ARGN} )
+    SET( _ext_libnames ${${_pkgname}_FIND_COMPONENTS} ${${_pkgname}_USE_COMPONENTS} )
+
+    IF( _ext_libnames )
+        SEPARATE_ARGUMENTS( _ext_libnames )
+        LIST( REMOVE_DUPLICATES _ext_libnames )
+    ENDIF()
+
+    IF( NOT ${_pkgname}_FIND_QUIETLY )
+        MESSAGE( STATUS "Check for ${_pkgname}_LIBRARIES: ${_std_libnames}" )
+        IF( _ext_libnames )
+            MESSAGE( STATUS "Check for ${_pkgname}_COMPONENT_LIBRARIES: ${_ext_libnames}" )
+        ENDIF()
+    ENDIF()
+
+    SET( ${_pkgname}_LIBRARY_DIRS )
+    MARK_AS_ADVANCED( ${_pkgname}_LIBRARY_DIRS )
+
+    SET( ${_pkgname}_LIBRARIES )
+    MARK_AS_ADVANCED( ${_pkgname}_LIBRARIES )
+    
+    SET( ${_pkgname}_COMPONENT_LIBRARIES )
+    MARK_AS_ADVANCED( ${_pkgname}_COMPONENT_LIBRARIES )
+
+    SET( ${_pkgname}_COMPONENT_VARIABLES )
+    MARK_AS_ADVANCED( ${_pkgname}_COMPONENT_VARIABLES )
+
+    FOREACH( _libname ${_std_libnames} ${_ext_libnames} )
+
+        # flag to check if it is a standard or a component library
+        LIST( FIND _std_libnames "${_libname}" _aux )
+        IF( ${_aux} LESS 0 )
+           SET( _is_std_lib FALSE )
+        ELSE()
+           SET( _is_std_lib TRUE )
+        ENDIF()
+
+        # libname in upper case
+        STRING( TOUPPER ${_libname} _ulibname )
+
+        SET( ${_pkgname}_${_ulibname}_LIBRARY ${_pkgname}_${_ulibname}_LIBRARY-NOTFOUND )
+        MARK_AS_ADVANCED( ${_pkgname}_${_ulibname}_LIBRARY )
+
+        # WARNING: using PATH_SUFFIXES may cause problems when using variable CMAKE_FIND_ROOT_PATH
+        #           this problem does not occur if expanding PATHS
+        #           look in FindMySQL.cmake for more info
+        #FIND_LIBRARY( ${_pkgname}_${_ulibname}_LIBRARY NAMES ${_libname} PATHS
+        #    ${${_pkgname}_ROOT} ${${_pkgname}_DIR} ${${_pkgname}_LIB_SEARCH_PATH}
+        #    PATH_SUFFIXES lib64 lib
+        #    NO_DEFAULT_PATH
+        #)
+
+        FIND_LIBRARY( ${_pkgname}_${_ulibname}_LIBRARY NAMES ${_libname} PATHS
+            ${${_pkgname}_ROOT}/lib64 ${${_pkgname}_ROOT}/lib
+            ${${_pkgname}_DIR}/lib64 ${${_pkgname}_DIR}/lib
+            ${${_pkgname}_LIB_SEARCH_PATH} ${${_pkgname}_LIB_SEARCH_PATH}/lib64 ${${_pkgname}_LIB_SEARCH_PATH}/lib
+            NO_DEFAULT_PATH
+        )
+
+        IF( NOT ${_pkgname}_DIR )
+            FIND_LIBRARY( ${_pkgname}_${_ulibname}_LIBRARY NAMES ${_libname} )
+        ENDIF()
+        
+        IF( ${_pkgname}_FIND_REQUIRED )
+            LIST( APPEND ${_pkgname}_COMPONENT_VARIABLES ${_pkgname}_${_ulibname}_LIBRARY )
+        ENDIF()
+
+        IF( ${_pkgname}_${_ulibname}_LIBRARY ) # if library found
+
+            SET( ${_pkgname}_${_ulibname}_FOUND TRUE )
+            
+            # split libraries in PKG_LIBRARIES and PKG_COMPONENT_LIBRARIES
+            IF( _is_std_lib )
+                LIST( APPEND ${_pkgname}_LIBRARIES ${${_pkgname}_${_ulibname}_LIBRARY} )
+            ELSE()
+                LIST( APPEND ${_pkgname}_COMPONENT_LIBRARIES ${${_pkgname}_${_ulibname}_LIBRARY} )
+            ENDIF()
+
+            GET_FILENAME_COMPONENT( _aux ${${_pkgname}_${_ulibname}_LIBRARY} PATH )
+            LIST( APPEND ${_pkgname}_LIBRARY_DIRS ${_aux} )
+
+            IF( NOT ${_pkgname}_FIND_QUIETLY )
+                MESSAGE( STATUS "Check for ${_pkgname}_${_ulibname}_LIBRARY: ${${_pkgname}_${_ulibname}_LIBRARY} -- ok" )
+            ENDIF()
+
+        ELSE() # library not found
+
+            SET( ${_pkgname}_${_ulibname}_FOUND FALSE )
+
+            IF( _is_std_lib )
+                SET( _std_lib_missing TRUE )
+            ELSE()
+                SET( _ext_lib_missing TRUE )
+            ENDIF()
+
+            IF( NOT ${_pkgname}_FIND_QUIETLY )
+                MESSAGE( STATUS "Check for ${_pkgname}_${_ulibname}_LIBRARY: ${_libname} -- failed" )
+            ENDIF()
+
+        ENDIF()
+
+    ENDFOREACH()
+
+    # clear PKG_LIBRARIES if standard library is missing
+    IF( _std_lib_missing )
+        SET( ${_pkgname}_LIBRARIES )
+    ENDIF()
+
+    # clear PKG_COMPONENT_LIBRARIES if a component library is missing and
+    # FIND_PACKAGE called with REQUIRED argument
+    IF( _ext_lib_missing AND ${_pkgname}_FIND_REQUIRED )
+        SET( ${_pkgname}_COMPONENT_LIBRARIES )
+    ENDIF()
+
+    # remove duplicate paths in PKG_LIBRARY_DIRS
+    IF( ${_pkgname}_LIBRARY_DIRS )
+        LIST( REMOVE_DUPLICATES ${_pkgname}_LIBRARY_DIRS )
+    ENDIF()
+
+    # debug
+    #MESSAGE( STATUS "${_pkgname}_LIBRARIES: ${${_pkgname}_LIBRARIES}" )
+    #MESSAGE( STATUS "${_pkgname}_COMPONENT_LIBRARIES: ${${_pkgname}_COMPONENT_LIBRARIES}" )
+    #MESSAGE( STATUS "${_pkgname}_LIBRARY_DIRS: ${${_pkgname}_LIBRARY_DIRS}" )
+
+ENDMACRO( CHECK_PACKAGE_LIBS _pkgname )
+
diff --git a/Utilities/KalTest/cmake/MacroCheckPackageVersion.cmake b/Utilities/KalTest/cmake/MacroCheckPackageVersion.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..e3ec75d9faa2ee03919d01179636fb1ba843e41e
--- /dev/null
+++ b/Utilities/KalTest/cmake/MacroCheckPackageVersion.cmake
@@ -0,0 +1,108 @@
+##############################################################################
+# macro for checking a package version
+#
+# this macro should be called from your PKGVersion.cmake or from a
+#   FindPKG.cmake module with the following arguments:
+#       _pkgname    : The package name
+#       _iversion   : The installed version of the package
+#
+#
+# the following conventions are used:
+#
+#   if FIND_PACKAGE is called with EXACT argument than the version has to
+#   match EXACTLY, i.e.:
+#       1.5 == 1.5
+#       1.5 == 1.5.0
+#       1.5 == 1.5.0.0
+#       1.5.2 == 1.5.2.0
+#       1.5.2.1 == 1.5.2.1
+#       1.5.2 != 1.5.2.1
+#       1.5 != 1.5.0.1
+#
+#
+#   otherwise a MINIMUM_REQUIRED version is checked for, i.e. the same
+#   behavior as with the cmake variable CMAKE_MINIMUM_REQUIRED, e.g.:
+#       searching: 1.2     --> installed: 1.5.2.2 --> compatible
+#       searching: 1.5     --> installed: 1.5.2.2 --> compatible
+#       searching: 1.5.2.1 --> installed: 1.5.2.2 --> compatible
+#       searching: 1.5.2.3 --> installed: 1.5.2.2 --> unsuitable
+#       searching: 1.7     --> installed: 1.5.2.2 --> unsuitable
+#
+#
+# following variables are returned (internally to cmake):
+#   PACKAGE_VERSION_EXACT       : set to TRUE if exact version was found
+#   PACKAGE_VERSION_COMPATIBLE  : set to TRUE if version is compatible
+#   PACKAGE_VERSION_UNSUITABLE  : set to TRUE if version found is unsuitable
+#
+#
+# @author Jan Engels, Desy IT
+##############################################################################
+
+# these variables are evaluated internally by the cmake command FIND_PACKAGE to mark this
+# package as suitable or not depending on the required version
+SET( PACKAGE_VERSION_EXACT FALSE )
+SET( PACKAGE_VERSION_COMPATIBLE TRUE )
+SET( PACKAGE_VERSION_UNSUITABLE FALSE )
+
+
+# cmake internal variable PACKAGE_FIND_NAME is not defined on FindPKG.cmake
+# modules, therefore it is passed as an argument to the macro
+# _iversion is the installed version of the package
+# _sversion is the version searched by the user with FIND_PACKAGE
+#MACRO( CHECK_PACKAGE_VERSION _pkgname _iversion )
+MACRO( CHECK_PACKAGE_VERSION _pkgname ) # left with one argument only for backwards compatibility
+
+    IF( NOT "${ARGV1}" STREQUAL "" )
+        SET( _iversion ${ARGV1} )
+    ELSE()
+        SET( _iversion ${${_pkgname}_VERSION_MAJOR}.${${_pkgname}_VERSION_MINOR}.${${_pkgname}_VERSION_PATCH}.${${_pkgname}_VERSION_TWEAK} )
+    ENDIF()
+
+    #SET( _sversion_major ${${_pkgname}_FIND_VERSION_MAJOR} )
+    #SET( _sversion_minor ${${_pkgname}_FIND_VERSION_MINOR} )
+
+    SET( _sversion ${${_pkgname}_FIND_VERSION} )
+
+    IF( NOT ${_pkgname}_FIND_QUIETLY )
+        MESSAGE( STATUS "Check for ${_pkgname} (${_iversion})" )
+    ENDIF()
+
+    # only do work if FIND_PACKAGE called with a version argument
+    IF( _sversion )
+
+        #IF( NOT ${_pkgname}_FIND_QUIETLY )
+        #    MESSAGE( STATUS "Check for ${_pkgname}: looking for version ${_sversion}" )
+        #ENDIF()
+
+        IF( ${_iversion} VERSION_EQUAL ${_sversion} ) # if version matches EXACTLY
+            #IF( NOT ${_pkgname}_FIND_QUIETLY )
+            #    MESSAGE( STATUS "Check for ${_pkgname}: exact version found: ${_iversion}" )
+            #ENDIF()
+            SET( PACKAGE_VERSION_EXACT TRUE )
+        ELSE() # if version does not match EXACTLY, check if it is compatible/suitable
+
+            # installed version must be greater or equal than version searched by the user, i.e.
+            # like with the CMAKE_MINIMUM_REQUIRED commando
+            # if user asks for version 1.2.5 then any version >= 1.2.5 is suitable/compatible
+            IF( NOT ${_sversion} VERSION_LESS ${_iversion} )
+                SET( PACKAGE_VERSION_UNSUITABLE TRUE )
+            ENDIF()
+            # -------------------------------------------------------------------------------------
+
+            IF( ${_pkgname}_FIND_VERSION_EXACT ) # if exact version was required search must fail!!
+                #IF( NOT ${_pkgname}_FIND_QUIETLY )
+                #    MESSAGE( "Check for ${_pkgname}: could not find exact version" )
+                #ENDIF()
+                SET( PACKAGE_VERSION_UNSUITABLE TRUE )
+            ENDIF()
+
+        ENDIF()
+
+        IF( PACKAGE_VERSION_UNSUITABLE )
+            SET( PACKAGE_VERSION_COMPATIBLE FALSE )
+        ENDIF()
+
+    ENDIF( _sversion )
+
+ENDMACRO( CHECK_PACKAGE_VERSION )
+
diff --git a/Utilities/KalTest/cmake/MacroRootDict.cmake b/Utilities/KalTest/cmake/MacroRootDict.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..ed7747fd24cf553be16f1c55eed643fae39d205e
--- /dev/null
+++ b/Utilities/KalTest/cmake/MacroRootDict.cmake
@@ -0,0 +1,145 @@
+IF(APPLE)
+    SET( LD_LIBRARY_PATH_VAR DYLD_LIBRARY_PATH )
+ELSE()
+    SET( LD_LIBRARY_PATH_VAR LD_LIBRARY_PATH )
+ENDIF()
+SET( LD_LIBRARY_PATH_CONTENTS $ENV{${LD_LIBRARY_PATH_VAR}} )
+#MESSAGE( STATUS "LD_LIBRARY_PATH_CONTENTS: ${LD_LIBRARY_PATH_CONTENTS}" )
+#MESSAGE( STATUS "ROOT_CINT_EXECUTABLE: ${ROOT_CINT_EXECUTABLE}" )
+
+SET( ROOT_CINT_WRAPPER ${LD_LIBRARY_PATH_VAR}=${ROOT_LIBRARY_DIR}:${LD_LIBRARY_PATH_CONTENTS} ${ROOT_CINT_EXECUTABLE} )
+
+IF( NOT DEFINED ROOT_DICT_OUTPUT_DIR )
+    SET( ROOT_DICT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/rootdict" )
+ENDIF()
+
+# clean generated header files with 'make clean'
+SET_DIRECTORY_PROPERTIES( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ROOT_DICT_OUTPUT_DIR}" )
+
+IF( NOT ROOT_FIND_QUIETLY )
+    MESSAGE( STATUS "Check for ROOT_DICT_OUTPUT_DIR: ${PROJECT_BINARY_DIR}/rootdict" )
+    MESSAGE( STATUS "Check for ROOT_DICT_CINT_DEFINITIONS: ${ROOT_DICT_CINT_DEFINITIONS}" )
+ENDIF()
+
+
+# ============================================================================
+# helper macro to prepare input headers for GEN_ROOT_DICT_SOURCES
+#   sorts LinkDef.h to be the last header (required by rootcint)
+#
+# arguments:
+#   input_dir - directory to search for headers matching *.h
+#
+# returns:
+#   ROOT_DICT_INPUT_HEADERS - all header files found in input_dir with
+#       LinkDef.h as the last header (if found)
+#
+# ----------------------------------------------------------------------------
+MACRO( PREPARE_ROOT_DICT_HEADERS _input_dir )
+
+    FILE( GLOB ROOT_DICT_INPUT_HEADERS "${_input_dir}/*.h" )
+    FILE( GLOB _linkdef_hdr "${_input_dir}/LinkDef.h" )
+
+    #LIST( FIND ROOT_DICT_INPUT_HEADERS ${_linkdef_hdr} _aux )
+    #IF( ${_aux} EQUAL 0 OR ${_aux} GREATER 0 )
+    #    LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" )
+    #    LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" )
+    #ENDIF()
+
+    IF( _linkdef_hdr )
+        LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" )
+        LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}")
+    ENDIF()
+
+    #MESSAGE( STATUS "ROOT_DICT_INPUT_HEADERS: ${ROOT_DICT_INPUT_HEADERS}" )
+
+ENDMACRO( PREPARE_ROOT_DICT_HEADERS )
+
+
+
+# ============================================================================
+# helper macro to generate Linkdef.h files for rootcint
+#
+# arguments:
+#   namespace - prefix used for creating header <namespace>_Linkdef.h
+#   ARGN      - list of sources to be used for generating Linkdef.h
+#
+# returns:
+#   ROOT_DICT_INPUT_HEADERS - all header files + <namespace>_LinkDef.h in the
+#       correct order to be used by macro GEN_ROOT_DICT_SOURCES
+#
+# ----------------------------------------------------------------------------
+MACRO( GEN_ROOT_DICT_LINKDEF_HEADER _namespace )
+
+    SET( _input_headers ${ARGN} )
+    SET( _linkdef_header "${ROOT_DICT_OUTPUT_DIR}/${_namespace}_Linkdef.h" )
+
+    FOREACH( _header ${_input_headers} )
+        SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#pragma link C++ defined_in \\\"${_header}\\\"\\;\\\\n" )
+    ENDFOREACH()
+
+    ADD_CUSTOM_COMMAND(
+        OUTPUT ${_linkdef_header}
+        COMMAND mkdir -p ${ROOT_DICT_OUTPUT_DIR}
+        COMMAND printf "${${_namespace}_file_contents}" > ${_linkdef_header}
+        DEPENDS ${_input_headers}
+        COMMENT "generating: ${_linkdef_header}"
+    )
+
+    SET( ROOT_DICT_INPUT_HEADERS ${_input_headers} ${_linkdef_header} )
+
+ENDMACRO()
+
+
+# ============================================================================
+# macro for generating root dict sources with rootcint
+#
+# arguments:
+#   dict_src_filename - filename of the dictionary source (to be generated)
+#
+# requires following variables:
+#       ROOT_DICT_INPUT_HEADERS - list of headers needed to generate dict source
+#           * if LinkDef.h is in the list it must be at the end !!
+#       ROOT_DICT_INCLUDE_DIRS - list of include dirs to pass to rootcint -I..
+#       ROOT_DICT_CINT_DEFINITIONS - extra definitions to pass to rootcint
+#       ROOT_DICT_OUTPUT_DIR - where dictionary source should be generated
+#
+# returns:
+#       ROOT_DICT_OUTPUT_SOURCES - list containing generated source and other
+#           previously generated sources
+                                    
+# ----------------------------------------------------------------------------
+MACRO( GEN_ROOT_DICT_SOURCE _dict_src_filename )
+
+    # TODO check for ROOT_CINT_EXECUTABLE
+
+    # need to prefix all include dirs with -I
+    set( _dict_includes )
+    FOREACH( _inc ${ROOT_DICT_INCLUDE_DIRS} )
+        SET( _dict_includes "${_dict_includes}\t-I${_inc}")  #fg: the \t fixes a wired string expansion 
+        #SET( _dict_includes ${_dict_includes} -I${_inc} )
+    ENDFOREACH()
+
+    STRING( REPLACE "/" "_" _dict_src_filename_nosc ${_dict_src_filename} )
+    SET( _dict_src_file ${ROOT_DICT_OUTPUT_DIR}/${_dict_src_filename_nosc} )
+    STRING( REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" _dict_hdr_file "${_dict_src_file}" )
+    #message("${ROOT_DICT_INPUT_HEADERS}")
+    ADD_CUSTOM_COMMAND(
+        OUTPUT  ${_dict_src_file} ${_dict_hdr_file}
+        COMMAND mkdir -p ${ROOT_DICT_OUTPUT_DIR}
+        COMMAND ${ROOT_CINT_WRAPPER} -f "${_dict_src_file}" -c ${ROOT_DICT_CINT_DEFINITIONS} ${_dict_includes} ${ROOT_DICT_INPUT_HEADERS}
+        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+        DEPENDS ${ROOT_DICT_INPUT_HEADERS}
+        COMMENT "generating: ${_dict_src_file} ${_dict_hdr_file}"
+    )
+    LIST( APPEND ROOT_DICT_OUTPUT_SOURCES ${_dict_src_file} )
+
+ENDMACRO()
+
+# for backwards compatibility
+MACRO( GEN_ROOT_DICT_SOURCES _dict_src_filename )
+    #MESSAGE( "USING DEPRECATED GEN_ROOT_DICT_SOURCES. PLEASE USE GEN_ROOT_DICT_SOURCE instead." )
+    SET( ROOT_DICT_OUTPUT_SOURCES )
+    GEN_ROOT_DICT_SOURCE( ${_dict_src_filename} )
+ENDMACRO()
+# ============================================================================
+
diff --git a/Utilities/KalTest/cmake/MyFindROOT.cmake b/Utilities/KalTest/cmake/MyFindROOT.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..567ce159fc7b846f509fd6c968be7e292a0e98f9
--- /dev/null
+++ b/Utilities/KalTest/cmake/MyFindROOT.cmake
@@ -0,0 +1,316 @@
+###############################################################################
+# cmake module for finding ROOT
+#
+# requires:
+#   MacroCheckPackageLibs.cmake for checking package libraries
+#
+# Following cmake variables are returned by this module:
+#
+#   ROOT_FOUND              : set to TRUE if ROOT found
+#       If FIND_PACKAGE is called with REQUIRED and COMPONENTS arguments
+#       ROOT_FOUND is only set to TRUE if ALL components are found.
+#       If REQUIRED is NOT set components may or may not be available
+#
+#   ROOT_LIBRARIES          : list of ROOT libraries (NOT including COMPONENTS)
+#   ROOT_INCLUDE_DIRS       : list of paths to be used with INCLUDE_DIRECTORIES
+#   ROOT_LIBRARY_DIRS       : list of paths to be used with LINK_DIRECTORIES
+#   ROOT_COMPONENT_LIBRARIES    : list of ROOT component libraries
+#   ROOT_${COMPONENT}_FOUND     : set to TRUE or FALSE for each library
+#   ROOT_${COMPONENT}_LIBRARY   : path to individual libraries
+#   
+#
+#   Please note that by convention components should be entered exactly as
+#   the library names, i.e. the component name equivalent to the library
+#   $ROOTSYS/lib/libMathMore.so should be called MathMore and NOT:
+#       mathmore or Mathmore or MATHMORE
+#
+#   However to follow the usual cmake convention it is agreed that the
+#   ROOT_${COMPONENT}_FOUND and ROOT_${COMPONENT}_LIBRARY variables are ALL
+#   uppercase, i.e. the MathMore component returns: ROOT_MATHMORE_FOUND and
+#   ROOT_MATHMORE_LIBRARY NOT ROOT_MathMore_FOUND or ROOT_MathMore_LIBRARY
+#
+#
+# The additional ROOT components should be defined as follows:
+# FIND_PACKAGE( ROOT COMPONENTS MathMore Gdml Geom ...)
+#
+# If components are required use:
+# FIND_PACKAGE( ROOT REQUIRED COMPONENTS MathMore Gdml Geom ...)
+#
+# If only root is required and components are NOT required use:
+# FIND_PACKAGE( ROOT REQUIRED )
+# FIND_PACKAGE( ROOT COMPONENTS MathMore Gdml Geom ... QUIET )
+#   then you need to check for ROOT_MATHMORE_FOUND, ROOT_GDML_FOUND, etc.
+#
+# The variable ROOT_USE_COMPONENTS can also be used before calling
+# FIND_PACKAGE, i.e.:
+# SET( ROOT_USE_COMPONENTS MathMore Gdml Geom )
+# FIND_PACKAGE( ROOT REQUIRED ) # all ROOT_USE_COMPONENTS must also be found
+# FIND_PACKAGE( ROOT ) # check for ROOT_FOUND, ROOT_MATHMORE_FOUND, etc.
+#
+# @author Jan Engels, DESY
+###############################################################################
+
+# ==============================================
+# ===        ROOT_CONFIG_EXECUTABLE          ===
+# ==============================================
+
+SET( ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND )
+MARK_AS_ADVANCED( ROOT_CONFIG_EXECUTABLE )
+# FIND_PROGRAM: Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again. 
+FIND_PROGRAM( ROOT_CONFIG_EXECUTABLE root-config PATHS ${ROOT_DIR}/bin NO_DEFAULT_PATH )
+FIND_PROGRAM( ROOT_CONFIG_EXECUTABLE root-config PATHS $ENV{ROOTSYS}/bin NO_DEFAULT_PATH)
+FIND_PROGRAM( ROOT_CONFIG_EXECUTABLE root-config PATHS ENV PATH )
+FIND_PROGRAM( ROOT_CONFIG_EXECUTABLE root-config )
+
+IF( NOT ROOT_FIND_QUIETLY )
+    MESSAGE( STATUS "Check for ROOT_CONFIG_EXECUTABLE: ${ROOT_CONFIG_EXECUTABLE}" )
+ENDIF()
+
+IF( ROOT_CONFIG_EXECUTABLE )
+
+
+    # ==============================================
+    # ===          ROOT_VERSION                  ===
+    # ==============================================
+
+    INCLUDE( MacroCheckPackageVersion )
+    
+    EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --version
+        OUTPUT_VARIABLE _version
+        RESULT_VARIABLE _exit_code
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    IF( _exit_code EQUAL 0 )
+
+        # set required variables for MacroCheckPackageVersion
+        STRING(REGEX REPLACE "^([0-9]+).*" "\\1" ROOT_VERSION_MAJOR "${_version}")
+        STRING(REGEX REPLACE "^[0-9]+.([0-9]+).*" "\\1" ROOT_VERSION_MINOR "${_version}")
+        STRING(REGEX REPLACE "^[0-9]+.[0-9]+.([0-9]+).*" "\\1" ROOT_VERSION_PATCH "${_version}")
+
+        SET( ROOT_VERSION "${ROOT_VERSION_MAJOR}.${ROOT_VERSION_MINOR}.${ROOT_VERSION_PATCH}" )
+    ENDIF()
+
+    CHECK_PACKAGE_VERSION( ROOT ${ROOT_VERSION} )
+
+
+
+    # ==============================================
+    # ===          ROOT_PREFIX                   ===
+    # ==============================================
+
+    # get root prefix from root-config output
+    EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --prefix
+        OUTPUT_VARIABLE ROOT_PREFIX
+        RESULT_VARIABLE _exit_code
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    IF( NOT _exit_code EQUAL 0 )
+        # clear variable if root-config exits with error
+        # it might contain garbage
+        SET( ROOT_PREFIX )
+    ENDIF()
+
+    # PKG_ROOT variables are a cmake standard
+    # since this package is also called ROOT the variable name
+    # becomes ROOT_ROOT ...
+    SET( ROOT_ROOT ${ROOT_PREFIX} )
+
+
+
+    # ==============================================
+    # ===          ROOT_BIN_DIR                  ===
+    # ==============================================
+
+    # get bindir from root-config output
+    EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --bindir
+        OUTPUT_VARIABLE ROOT_BIN_DIR
+        RESULT_VARIABLE _exit_code
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    IF( NOT _exit_code EQUAL 0 )
+        # clear variable if root-config exits with error
+        # it might contain garbage
+        SET( ROOT_BIN_DIR )
+    ENDIF()
+
+
+
+    # ==============================================
+    # ===          ROOT_EXECUTABLE               ===
+    # ==============================================
+
+
+    SET( ROOT_EXECUTABLE ROOT_EXECUTABLE-NOTFOUND )
+    MARK_AS_ADVANCED( ROOT_EXECUTABLE )
+    FIND_PROGRAM( ROOT_EXECUTABLE root PATHS ${ROOT_BIN_DIR} NO_DEFAULT_PATH )
+
+    IF( NOT ROOT_FIND_QUIETLY )
+        MESSAGE( STATUS "Check for ROOT_EXECUTABLE: ${ROOT_EXECUTABLE}" )
+    ENDIF()
+
+
+
+
+    # ==============================================
+    # ===          ROOT_CINT_EXECUTABLE          ===
+    # ==============================================
+
+
+    # find rootcint
+    SET( ROOT_CINT_EXECUTABLE ROOT_CINT_EXECUTABLE-NOTFOUND )
+    MARK_AS_ADVANCED( ROOT_CINT_EXECUTABLE )
+    FIND_PROGRAM( ROOT_CINT_EXECUTABLE rootcint PATHS ${ROOT_BIN_DIR} NO_DEFAULT_PATH )
+
+    IF( NOT ROOT_FIND_QUIETLY )
+        MESSAGE( STATUS "Check for ROOT_CINT_EXECUTABLE: ${ROOT_CINT_EXECUTABLE}" )
+    ENDIF()
+
+
+
+    # ==============================================
+    # ===          ROOT_INCLUDE_DIR              ===
+    # ==============================================
+
+    # get include dir from root-config output
+    EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --incdir
+        OUTPUT_VARIABLE _inc_dir
+        RESULT_VARIABLE _exit_code
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    IF( NOT _exit_code EQUAL 0 )
+        # clear variable if root-config exits with error
+        # it might contain garbage
+        SET( _inc_dir )
+    ENDIF()
+
+
+    SET( ROOT_INCLUDE_DIRS ROOT_INCLUDE_DIRS-NOTFOUND )
+    MARK_AS_ADVANCED( ROOT_INCLUDE_DIRS )
+
+    FIND_PATH( ROOT_INCLUDE_DIRS
+        NAMES TH1.h
+        PATHS ${ROOT_DIR}/include ${_inc_dir}
+        NO_DEFAULT_PATH
+    )
+
+
+
+    # ==============================================
+    # ===            ROOT_LIBRARIES              ===
+    # ==============================================
+
+    # get library dir from root-config output
+    EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --libdir
+        OUTPUT_VARIABLE ROOT_LIBRARY_DIR
+        RESULT_VARIABLE _exit_code
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    IF( NOT _exit_code EQUAL 0 )
+        # clear variable if root-config exits with error
+        # it might contain garbage
+        SET( ROOT_LIBRARY_DIR )
+    ENDIF()
+
+
+
+    # ========== standard root libraries =================
+
+    # standard root libraries (without components)
+    SET( _root_libnames )
+
+    # get standard root libraries from 'root-config --libs' output
+    EXECUTE_PROCESS( COMMAND "${ROOT_CONFIG_EXECUTABLE}" --noauxlibs --libs
+        OUTPUT_VARIABLE _aux
+        RESULT_VARIABLE _exit_code
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    IF( _exit_code EQUAL 0 )
+        
+        # create a list out of the output
+        SEPARATE_ARGUMENTS( _aux )
+
+        # remove first item -L compiler flag
+        LIST( REMOVE_AT _aux 0 )
+
+        FOREACH( _lib ${_aux} )
+
+            # extract libnames from -l compiler flags
+            STRING( REGEX REPLACE "^-.(.*)$" "\\1" _libname "${_lib}")
+
+            # fix for some root-config versions which export -lz even if using --noauxlibs
+            IF( NOT _libname STREQUAL "z" )
+
+                # append all library names into a list
+                LIST( APPEND _root_libnames ${_libname} )
+
+            ENDIF()
+
+        ENDFOREACH()
+
+    ENDIF()
+
+
+
+    # ========== additional root components =================
+
+    #LIST( APPEND ROOT_FIND_COMPONENTS Minuit2 ) # DEPRECATED !!!
+
+
+    # ---------- libraries --------------------------------------------------------
+    INCLUDE( MacroCheckPackageLibs )
+
+    SET( ROOT_LIB_SEARCH_PATH ${ROOT_LIBRARY_DIR} )
+
+    # only standard libraries should be passed as arguments to CHECK_PACKAGE_LIBS
+    # additional components are set by cmake in variable PKG_FIND_COMPONENTS
+    # first argument should be the package name
+    CHECK_PACKAGE_LIBS( ROOT ${_root_libnames} )
+
+
+
+
+    # ====== DL LIBRARY ==================================================
+    # workaround for cmake bug in 64 bit:
+    # see: http://public.kitware.com/mantis/view.php?id=10813
+    IF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
+        FIND_LIBRARY( DL_LIB NAMES ${CMAKE_DL_LIBS} dl PATHS /usr/lib64 /lib64 NO_DEFAULT_PATH )
+    ENDIF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
+
+    FIND_LIBRARY( DL_LIB NAMES ${CMAKE_DL_LIBS} dl )
+    MARK_AS_ADVANCED( DL_LIB )
+
+    IF( NOT ROOT_FIND_QUIETLY )
+        MESSAGE( STATUS "Check for libdl.so: ${DL_LIB}" )
+    ENDIF()
+
+ENDIF( ROOT_CONFIG_EXECUTABLE )
+
+# Threads library
+#FIND_PACKAGE( Threads REQUIRED)
+
+
+# ---------- final checking ---------------------------------------------------
+INCLUDE( FindPackageHandleStandardArgs )
+# set ROOT_FOUND to TRUE if all listed variables are TRUE and not empty
+# ROOT_COMPONENT_VARIABLES will be set if FIND_PACKAGE is called with REQUIRED argument
+FIND_PACKAGE_HANDLE_STANDARD_ARGS( ROOT DEFAULT_MSG ROOT_INCLUDE_DIRS ROOT_LIBRARIES ${ROOT_COMPONENT_VARIABLES} PACKAGE_VERSION_COMPATIBLE DL_LIB )
+
+IF( ROOT_FOUND )
+    LIST( APPEND ROOT_LIBRARIES ${DL_LIB} )
+    # FIXME DEPRECATED
+    SET( ROOT_DEFINITIONS "-DUSEROOT -DUSE_ROOT -DMARLIN_USE_ROOT" )
+    MARK_AS_ADVANCED( ROOT_DEFINITIONS )
+
+    # file including MACROS for generating root dictionary sources
+    GET_FILENAME_COMPONENT( _aux ${CMAKE_CURRENT_LIST_FILE} PATH )
+    SET( ROOT_DICT_MACROS_FILE ${_aux}/MacroRootDict.cmake )
+
+ENDIF( ROOT_FOUND )
+
+# ---------- cmake bug --------------------------------------------------------
+# ROOT_FIND_REQUIRED is not reset between FIND_PACKAGE calls, i.e. the following
+# code fails when geartgeo component not available: (fixed in cmake 2.8)
+# FIND_PACKAGE( ROOT REQUIRED )
+# FIND_PACKAGE( ROOT COMPONENTS geartgeo QUIET )
+SET( ROOT_FIND_REQUIRED )
+
diff --git a/Utilities/KalTest/kaltest/KalTrackDim.h b/Utilities/KalTest/kaltest/KalTrackDim.h
new file mode 100644
index 0000000000000000000000000000000000000000..c71efbf0c5ecdacae3df27e50174a612983bebee
--- /dev/null
+++ b/Utilities/KalTest/kaltest/KalTrackDim.h
@@ -0,0 +1,9 @@
+#ifndef KALDIM_H
+#define KALDIM_H
+#define kMdim 2
+#ifdef __NOT0__
+#define kSdim 5
+#else
+#define kSdim 6
+#endif
+#endif
diff --git a/Utilities/KalTest/kaltest/TAttDrawable.h b/Utilities/KalTest/kaltest/TAttDrawable.h
new file mode 100644
index 0000000000000000000000000000000000000000..3383a39af6a4d04d2e2f726e977dce746afa7a57
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TAttDrawable.h
@@ -0,0 +1,37 @@
+#ifndef TATTDRAWABLE_H
+#define TATTDRAWABLE_H
+//*************************************************************************
+//* ===================
+//*  TAttDrawable Class
+//* ===================
+//*
+//* (Description)
+//*    TAttDrawable class adds drawable attribute to an object.
+//* (Requires)
+//* 	none
+//* (Provides)
+//* 	class TAttDrawable
+//* (Update Recored)
+//*    2004/11/04  K.Fujii	Original very primitive version.
+//*
+//*************************************************************************
+//
+#include <Rtypes.h>
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for Drawale Objects
+//  ------------------------------
+//
+class TAttDrawable {
+public:
+   TAttDrawable() {}
+   virtual ~TAttDrawable() {}
+
+   virtual void   Draw(const Char_t *opt="");
+   virtual void   Draw(Int_t /* color */, const Char_t *opt="");
+private:
+
+   ClassDef(TAttDrawable, 1)  // Base class for drawable objects
+};
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TAttElement.h b/Utilities/KalTest/kaltest/TAttElement.h
new file mode 100644
index 0000000000000000000000000000000000000000..3f9905e03e33fa454de66143f8707e7caad3e47e
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TAttElement.h
@@ -0,0 +1,55 @@
+#ifndef TATTELEMENT_H
+#define TATTELEMENT_H
+//*************************************************************************
+//* ===================
+//*  TAttElement Class
+//* ===================
+//*
+//* (Description)
+//*    TAttElement class adds constituent attribute to an object.
+//* (Requires)
+//* 	none
+//* (Provides)
+//* 	class TAttElement
+//* (Update Recored)
+//*    2003/10/10  K.Fujii	Original very primitive version.
+//*
+//*************************************************************************
+//
+#include <Rtypes.h>
+
+//_____________________________________________________________________
+//  --------------------------------
+//  Base Class for Element Objects
+//  --------------------------------
+//
+class TAttElement {
+public:
+   TAttElement() : fParentPtr(0) {}
+   virtual ~TAttElement() {}
+
+   inline virtual const TAttElement  & GetParent(Bool_t recur = kTRUE) const;
+
+   inline virtual void  SetParentPtr(TAttElement *obj)  { fParentPtr = obj; }
+
+private:
+   TAttElement *fParentPtr;	 // pointer to parent
+
+   ClassDef(TAttElement,1)  // Base class for lockable objects
+};
+
+//_____________________________________________________________________
+//  --------------------------------
+//  Inline functions, if any
+//  --------------------------------
+const TAttElement & TAttElement::GetParent(Bool_t recursive) const
+{
+   if (fParentPtr) {
+      if (recursive) return fParentPtr->GetParent(recursive);
+      else           return *fParentPtr;
+   } else {
+      return *this;
+   }
+}
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TAttLockable.h b/Utilities/KalTest/kaltest/TAttLockable.h
new file mode 100644
index 0000000000000000000000000000000000000000..8b6d068bf2a43d9a4aadd144d4ec961b9f539cb4
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TAttLockable.h
@@ -0,0 +1,39 @@
+#ifndef TATTLOCKABLE_H
+#define TATTLOCKABLE_H
+//*************************************************************************
+//* ===================
+//*  TAttLockable Class
+//* ===================
+//*
+//* (Description)
+//*    TAttLockable class adds lockable attribute to an object.
+//* (Requires)
+//* 	none
+//* (Provides)
+//* 	class Lockable
+//* (Update Recored)
+//*    1999/06/05  K.Fujii	Original very primitive version.
+//*
+//*************************************************************************
+//
+#include <Rtypes.h>
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for Lockale Objects
+//  ------------------------------
+//
+class TAttLockable {
+public:
+   TAttLockable() : fStatus(kFALSE) {}
+   virtual ~TAttLockable() {}
+
+   inline virtual Bool_t IsLocked() const { return fStatus;   }
+   inline virtual void   Lock()           { fStatus = kTRUE;  }
+   inline virtual void   Unlock()         { fStatus = kFALSE; }
+private:
+   Bool_t fStatus;	 // lock byte
+
+   ClassDef(TAttLockable,1)  // Base class for lockable objects
+};
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TCircle.h b/Utilities/KalTest/kaltest/TCircle.h
new file mode 100644
index 0000000000000000000000000000000000000000..2bb548aa72649420ccfd7d22f1778816b76abb63
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TCircle.h
@@ -0,0 +1,56 @@
+#ifndef TCIRCLE_H
+#define TCIRCLE_H
+//*************************************************************************
+//* ====================
+//*  TCircle Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a circle object.
+//* (Requires)
+//*     TVCurve
+//* (Provides)
+//*     class TCircle
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include <iostream>
+#include "TVector2.h"
+#include "TVCurve.h"
+
+using namespace std;
+//_____________________________________________________________________
+//  -----------------------------------
+//  Circle Class
+//  -----------------------------------
+
+class TCircle : public TVCurve {
+public:
+   TCircle(Double_t r = 1., Double_t xc = 0., Double_t yc = 0.);
+   virtual ~TCircle() {}
+
+   virtual Int_t   CalcXingPointWith(const TCircle  &c,
+                                           TVector2  xx[],
+                                           Double_t  eps = 1.e-8) const;
+
+   inline virtual       Double_t   GetRadius() const { return fR;  }
+   inline virtual const TVector2 & GetCenter() const { return fXc; }
+
+   inline virtual       void       DebugPrint() const;
+
+private:
+   Double_t fR;         // radius
+   TVector2 fXc;        // center
+ 
+   ClassDef(TCircle,1)      // circle class
+};
+
+void TCircle::DebugPrint() const
+{
+   cerr << " radius = " << fR
+        << " center = (" << fXc.X() << "," << fXc.Y() << ")" << endl;
+}
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TCutCone.h b/Utilities/KalTest/kaltest/TCutCone.h
new file mode 100644
index 0000000000000000000000000000000000000000..b66cfef1f8e73f51c5fea356c75ea3fa053da57c
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TCutCone.h
@@ -0,0 +1,122 @@
+#ifndef TCUTCONE_H
+#define TCUTCONE_H
+//*************************************************************************
+//* ====================
+//*  TCutCone Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a conical surface object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class TCutCone
+//* (Update Recored)
+//*   2012/01/19  K.Fujii       Original version derived from THYpe.
+//*                             This class is implemented as an extreme
+//*                             (fR0=0) case of THype, thereby containing
+//*                             both -ve and +ve sides. If you want to
+//*                             restrict them to one side, override
+//*                             IsOnSurface(), etc.
+//*************************************************************************
+//
+#include "TVSurface.h"
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Hype Class
+//  -----------------------------------
+
+class TCutCone : public TVSurface {
+public:
+   TCutCone(Double_t z1 = 0.5,
+            Double_t hlen = 1.0,
+            Double_t tana = 0.1,
+            Double_t xc = 0., 
+            Double_t yc = 0, 
+            Double_t zc = 0.)
+      : fZ1(z1), 
+        fHalfLen(hlen), 
+        fXc(xc,yc,zc), 
+        fTanA(tana)
+   {
+   }
+
+   virtual ~TCutCone() {}
+
+   virtual Double_t CalcS   (const TVector3 &xx) const;
+   virtual TMatrixD CalcDSDx(const TVector3 &xx) const;
+
+   inline virtual       Bool_t     IsOnSurface(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside  (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetSortingPolicy()              const;
+
+   inline virtual       Double_t   GetZ1     () const { return fZ1;   } 
+   inline virtual const TVector3 & GetXc     () const { return fXc;   } 
+   inline virtual       Double_t   GetTanA   () const { return fTanA; }
+   inline virtual       Double_t   GetLength () const;
+   inline virtual       Double_t   GetZmin   () const;
+   inline virtual       Double_t   GetZmax   () const;
+
+private:
+   Double_t fZ1;          // z position of the front face
+   Double_t fHalfLen;     // half length (cone length from the apex)
+   TVector3 fXc;          // center
+   Double_t fTanA;        // tan(half cone angle)
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+   static const Double_t kTol = 1.e-5; // tolerance
+#else
+   static const Double_t kTol; // tolerance
+#endif
+ 
+   ClassDef(TCutCone,1)      // hype class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+Double_t TCutCone::GetLength () const 
+{ 
+   return 2*fHalfLen;
+} 
+
+Double_t TCutCone::GetZmin() const
+{
+   return TMath::Min(fXc.Z() - fHalfLen, fXc.Z() + fHalfLen);
+}
+
+Double_t TCutCone::GetZmax() const
+{
+   return TMath::Max(fXc.Z() - fHalfLen, fXc.Z() + fHalfLen);
+}
+
+Bool_t TCutCone::IsOnSurface(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   Double_t r   = xxc.Perp();
+   Double_t z   = xxc.Z();
+   Double_t s   = r*r - fTanA*fTanA*z*z;
+   
+   return (TMath::Abs(s) < kTol && xx.Z() >= GetZmin() && xx.Z() <= GetZmax());
+} 
+
+Bool_t TCutCone::IsOutside(const TVector3 &xx) const
+{
+   Double_t r  = (xx-fXc).Perp();
+   Double_t z  = xx.Z();
+   Double_t R2 =fTanA*fTanA*z*z;
+   
+   return (r*r > R2 || z < GetZmin() || z > GetZmax());
+} 
+
+Double_t TCutCone::GetSortingPolicy() const
+{
+   return GetZ1()*GetTanA();
+}
+#endif
+
diff --git a/Utilities/KalTest/kaltest/TCylinder.h b/Utilities/KalTest/kaltest/TCylinder.h
new file mode 100644
index 0000000000000000000000000000000000000000..793da6310ca0395efaf3341233d767eb94776d7f
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TCylinder.h
@@ -0,0 +1,104 @@
+#ifndef TCYLINDER_H
+#define TCYLINDER_H
+//*************************************************************************
+//* ====================
+//*  TCylinder Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a cylinder object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class TCylinder
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*   2005/02/23  K.Fujii       Added GetSortingPolicy().
+//*
+//*************************************************************************
+//
+#include "TVSurface.h"
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+#include <cmath>
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Cylinder Class
+//  -----------------------------------
+
+class TCylinder : public TVSurface {
+public:
+   TCylinder(Double_t r = 1., Double_t hlen  = 1., 
+             Double_t xc = 0., Double_t yc = 0, Double_t zc = 0.)
+           : fR(r), fHalfLen(hlen), fXc(xc,yc,zc) {}
+
+   virtual ~TCylinder() {}
+
+   virtual Int_t CalcXingPointWith(const TVTrack  &hel,
+                                         TVector3 &xx,
+                                         Double_t &phi,
+                                         Int_t     mode,
+                                         Double_t  eps  = 1.e-8) const;
+
+   virtual Double_t CalcS   (const TVector3 &xx) const;
+   virtual TMatrixD CalcDSDx(const TVector3 &xx) const;
+
+   inline virtual       Bool_t     IsOnSurface(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside  (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetSortingPolicy()              const;
+
+   inline virtual       Double_t   GetR      () const { return fR;    } 
+   inline virtual const TVector3 & GetXc     () const { return fXc;   } 
+   inline virtual       Double_t   GetLength () const;
+   inline virtual       Double_t   GetZmin   () const;
+   inline virtual       Double_t   GetZmax   () const;
+
+private:
+   Double_t fR;           // radius
+   Double_t fHalfLen;     // half length
+   TVector3 fXc;          // center
+ 
+   ClassDef(TCylinder,1)      // cylinder class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+Double_t TCylinder::GetLength () const 
+{ 
+   return 2*fHalfLen;
+} 
+
+Double_t TCylinder::GetZmin() const
+{
+   return fXc.Z() - fHalfLen;
+}
+
+Double_t TCylinder::GetZmax() const
+{
+   return fXc.Z() + fHalfLen;
+}
+
+Bool_t TCylinder::IsOnSurface(const TVector3 &xx) const
+{
+   return (xx.Z() >= GetZmin() && xx.Z() <= GetZmax()) && std::fabs( (xx-fXc).Perp() - fR ) < 1.e-6;
+} 
+
+Bool_t TCylinder::IsOutside(const TVector3 &xx) const
+{
+   Double_t r = (xx-fXc).Perp();
+   Double_t z = xx.Z();
+   return (r > fR || z < GetZmin() || z > GetZmax());
+} 
+
+Double_t TCylinder::GetSortingPolicy() const
+{
+   return GetR();
+}
+#endif
+
diff --git a/Utilities/KalTest/kaltest/THelicalTrack.h b/Utilities/KalTest/kaltest/THelicalTrack.h
new file mode 100644
index 0000000000000000000000000000000000000000..26f9a2de53c05b66c3471d79262ff478358f4593
--- /dev/null
+++ b/Utilities/KalTest/kaltest/THelicalTrack.h
@@ -0,0 +1,86 @@
+#ifndef THELICALTRACK_H
+#define THELICALTRACK_H
+//*************************************************************************
+//* ====================
+//*  THelicalTrack Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a helical track object.
+//*
+//*   A helix is parametrized in the standard way:
+//*
+//*      x = x0 + drho * cos(phi0) + rho * (cos(phi0) - cos(phi0 + phi))
+//*      y = y0 + drho * sin(phi0) + rho * (sin(phi0) - cos(sin0 + phi))
+//*      z = z0 + dz               - rho * tan(lambda) * phi
+//*
+//*   with 
+//*
+//*      rho = alpha/kappa
+//*
+//* (Requires)
+//*     TVTrack, TCylinder, TCircle, TVector3, TMatrixD
+//* (Provides)
+//*     class THelicalTrack
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+
+#include "TVTrack.h"
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Helical Track Class
+//  -----------------------------------
+
+class THelicalTrack : public TVTrack {
+public:
+
+   // Ctors and Dtor
+
+   THelicalTrack(Double_t dr    = 0.,
+                 Double_t phi0  = 0.,
+                 Double_t kappa = 1.e-5,
+                 Double_t dz    = 0.,
+                 Double_t tanl  = 0.,
+                 Double_t x0    = 0.,
+                 Double_t y0    = 0.,
+                 Double_t z0    = 0.,
+                 Double_t b     = 30.);
+
+   THelicalTrack(const TMatrixD &a, const TVector3 &x0, Double_t b = 30.);
+   THelicalTrack(const TVector3 &x1, const TVector3 &x2, const TVector3 &x3,
+                 Double_t b = 30., Bool_t dir = kIterForward);
+
+   virtual ~THelicalTrack() {}
+
+   // Utility methods
+
+   virtual void MoveTo(const TVector3 &x0to,
+                             Double_t &fid,
+                             TMatrixD *F = 0,
+                             TMatrixD *C = 0);
+
+   TVector3 CalcXAt   (Double_t phi) const;
+   TMatrixD CalcDxDa  (Double_t phi) const;
+   TMatrixD CalcDxDphi(Double_t phi) const;
+   void     CalcDapDa (Double_t fid,
+                       Double_t dr,
+                       Double_t drp,
+                       TMatrixD &F)  const;
+
+private:
+   void CalcStartHelix(const TVector3 &x1,
+                       const TVector3 &x2,
+                       const TVector3 &x3,
+                             Bool_t    dir = kIterForward);
+
+private:
+
+   ClassDef(THelicalTrack,1)      // circle class
+};
+
+#endif
+
diff --git a/Utilities/KalTest/kaltest/THype.h b/Utilities/KalTest/kaltest/THype.h
new file mode 100644
index 0000000000000000000000000000000000000000..04e4765d06b864ab8b09baee20240e0124aedb08
--- /dev/null
+++ b/Utilities/KalTest/kaltest/THype.h
@@ -0,0 +1,110 @@
+#ifndef THYPE_H
+#define THYPE_H
+//*************************************************************************
+//* ====================
+//*  THype Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a hyperboloidal surface object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class THype
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*   2005/02/23  K.Fujii       Added GetSortingPolicy().
+//*
+//*************************************************************************
+//
+#include "TVSurface.h"
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Hype Class
+//  -----------------------------------
+
+class THype : public TVSurface {
+public:
+   THype(Double_t r = 1., Double_t hlen  = 1., Double_t tana = 0.,
+         Double_t xc = 0., Double_t yc = 0, Double_t zc = 0.)
+           : fR0(r), fHalfLen(hlen), fXc(xc,yc,zc), fTanA(tana) {}
+
+   virtual ~THype() {}
+
+   virtual Double_t CalcS   (const TVector3 &xx) const;
+   virtual TMatrixD CalcDSDx(const TVector3 &xx) const;
+
+   inline virtual       Bool_t     IsOnSurface(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside  (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetSortingPolicy()              const;
+
+   inline virtual       Double_t   GetR0     () const { return fR0;   } 
+   inline virtual const TVector3 & GetXc     () const { return fXc;   } 
+   inline virtual       Double_t   GetTanA   () const { return fTanA; }
+   inline virtual       Double_t   GetLength () const;
+   inline virtual       Double_t   GetZmin   () const;
+   inline virtual       Double_t   GetZmax   () const;
+
+private:
+   Double_t fR0;          // radius at z = 0.
+   Double_t fHalfLen;     // half length
+   TVector3 fXc;          // center
+   Double_t fTanA;        // tan(stereo angle)
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+   static const Double_t kTol = 1.e-5; // tolerance
+#else
+   static const Double_t kTol; // tolerance
+#endif
+ 
+   ClassDef(THype,1)      // hype class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+Double_t THype::GetLength () const 
+{ 
+   return 2*fHalfLen;
+} 
+
+Double_t THype::GetZmin() const
+{
+   return fXc.Z() - fHalfLen;
+}
+
+Double_t THype::GetZmax() const
+{
+   return fXc.Z() + fHalfLen;
+}
+
+Bool_t THype::IsOnSurface(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   Double_t r   = xxc.Perp();
+   Double_t z   = xxc.Z();
+   Double_t s   = r*r - fTanA*fTanA*z*z - fR0*fR0;
+   
+   return (TMath::Abs(s) < kTol && xx.Z() >= GetZmin() && xx.Z() <= GetZmax());
+} 
+
+Bool_t THype::IsOutside(const TVector3 &xx) const
+{
+   Double_t r  = (xx-fXc).Perp();
+   Double_t z  = xx.Z();
+   Double_t R2 = fR0*fR0 + fTanA*fTanA*z*z;
+   
+   return (r*r > R2 || z < GetZmin() || z > GetZmax());
+} 
+
+Double_t THype::GetSortingPolicy() const
+{
+   return GetR0();
+}
+#endif
+
diff --git a/Utilities/KalTest/kaltest/TKalDetCradle.h b/Utilities/KalTest/kaltest/TKalDetCradle.h
new file mode 100644
index 0000000000000000000000000000000000000000..f666378e82b7ed68bad514fd3218e4efd3556ea2
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TKalDetCradle.h
@@ -0,0 +1,84 @@
+#ifndef TKALDETCRADLE_H
+#define TKALDETCRADLE_H
+//*************************************************************************
+//* =====================
+//*  TKalDetCradle Class
+//* =====================
+//*
+//* (Description)
+//*   A sigleton to hold information of detector system
+//*   used in Kalman filter classes.
+//* (Requires)
+//* 	TObjArray
+//* 	TVKalDetector
+//* (Provides)
+//* 	class TKalDetCradle
+//* (Update Recored)
+//*   2005/02/23  A.Yamaguchi	 Original Version.
+//*   2005/08/14  K.Fujii        Removed CalcTable(), GetMeasLayerTable(),
+//*                              GetPhiTable(), and GetDir() and added
+//*                              Transport() to do their functions.
+//*   2010/04/06  K.Fujii        Modified Transport() to allow a 1-dim hit,
+//*                              for which pivot is at the xpected hit.
+//*
+//*************************************************************************
+
+#include "TObjArray.h"     // from ROOT
+#include "TAttElement.h"   // from Utils
+#include "TKalMatrix.h"    // from KalTrackLib
+
+class TKalTrackSite;
+class TVKalDetector;
+class TVMeasLayer;
+
+//_____________________________________________________________________
+//  ------------------------------
+//   Detector system class
+//  ------------------------------
+
+class TKalDetCradle : public TObjArray, public TAttElement {
+public:
+   TKalDetCradle(Int_t n = 1);
+   virtual ~TKalDetCradle();
+
+   // Utility methods
+   virtual void Install(TVKalDetector &det);
+
+   inline virtual void   SwitchOnMS   ()       { fIsMSON = kTRUE;    }
+   inline virtual void   SwitchOffMS  ()       { fIsMSON = kFALSE;   }
+   inline virtual void   SwitchOnDEDX ()       { fIsDEDXON = kTRUE;  }
+   inline virtual void   SwitchOffDEDX()       { fIsDEDXON = kFALSE; }
+   inline virtual void   Close        ()       { fIsClosed = kTRUE; Update(); }
+   inline virtual void   Reopen       ()       { fIsClosed = kFALSE; }
+   inline virtual Bool_t IsMSOn       () const { return fIsMSON;     }
+   inline virtual Bool_t IsDEDXOn     () const { return fIsDEDXON;   }
+   inline virtual Bool_t IsClosed     () const { return fIsClosed;   }
+
+   void Transport(const TKalTrackSite  &from, // site from
+                        TKalTrackSite  &to,   // site to
+                        TKalMatrix     &sv,   // state vector
+                        TKalMatrix     &F,    // propagator matrix
+                        TKalMatrix     &Q);   // process noise matrix
+
+   int Transport(const TKalTrackSite  &from, // site from
+                 const TVMeasLayer    &to,   // layer to reach
+		       TVector3       &x0,   // intersection point 
+		       TKalMatrix     &sv,   // state vector
+		       TKalMatrix     &F,    // propagator matrix
+		       TKalMatrix     &Q);   // process noise matrix
+
+
+
+private:
+   void Update();
+
+private:
+   Bool_t    fIsMSON;         //! switch for multiple scattering
+   Bool_t    fIsDEDXON;       //! switch for energy loss
+   Bool_t    fDone;           //! flag to tell if sorting done
+   Bool_t    fIsClosed;       //! flag to tell if cradle closed
+
+   ClassDef(TKalDetCradle,1)  // Base class for detector system
+};
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TKalFilterCond.h b/Utilities/KalTest/kaltest/TKalFilterCond.h
new file mode 100644
index 0000000000000000000000000000000000000000..54970788ac7d340c1ae14559465ad53d1a0ce907
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TKalFilterCond.h
@@ -0,0 +1,35 @@
+#ifndef TKALFILTERCOND_H
+#define TKALFILTERCOND_H
+//*************************************************************************
+//* =====================
+//*  TKalFilterCond Class
+//* =====================
+//*
+//* (Description)
+//*   A class to specify filter conditions used in Kalman filter.
+//* (Requires)
+//* (Provides)
+//* 	class TKalFilterCond
+//* (Update Recored)
+//*   2010/04/06  K.Fujii        Original Version.
+//*
+//*************************************************************************
+#include "Rtypes.h"
+//_____________________________________________________________________
+//  ------------------------------
+//   Filter condition class
+//  ------------------------------
+
+class TKalTrackSite;
+
+class TKalFilterCond {
+ public:
+  
+  // need virtual destructor is we have virtual functions
+  virtual ~TKalFilterCond() {};
+  
+  virtual Bool_t IsAccepted(const TKalTrackSite &site);
+  
+  ClassDef(TKalFilterCond,1)  // Base class for detector system
+    };
+#endif
diff --git a/Utilities/KalTest/kaltest/TKalMatrix.h b/Utilities/KalTest/kaltest/TKalMatrix.h
new file mode 100644
index 0000000000000000000000000000000000000000..947b92c02f0b96eb6f990a1e3da3acc1888bcc05
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TKalMatrix.h
@@ -0,0 +1,58 @@
+#ifndef TKALMATRIX_H
+#define TKALMATRIX_H
+//*************************************************************************
+//* ===================
+//*  TKalMatrix Class
+//* ===================
+//*
+//* (Description)
+//*    TKalMatrix is a wrapper of TMatrixD.
+//* (Requires)
+//* 	TMatrixD
+//* (Provides)
+//* 	class TKalMatrix
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*
+//*************************************************************************
+
+#include "TMatrixD.h"
+#include "TVector3.h"
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for matrix used by Kalman filter
+//  ------------------------------
+//
+class TKalMatrix : public TMatrixD { 
+public:
+   TKalMatrix(Int_t rowdim = 1, Int_t coldim = 1);
+
+   TKalMatrix(const TKalMatrix &orig);
+   TKalMatrix(const TMatrixD &orig);
+                                                                                
+   TKalMatrix(TMatrixD::EMatrixCreatorsOp1 op,
+              const TKalMatrix &prototype);
+   TKalMatrix(TMatrixD::EMatrixCreatorsOp1 op,
+              const TMatrixD &prototype);
+                                                                                
+   TKalMatrix(const TKalMatrix &a,
+              TMatrixD::EMatrixCreatorsOp2 op,
+              const TKalMatrix &b) ;
+   TKalMatrix(const TMatrixD &a,
+              TMatrixD::EMatrixCreatorsOp2 op,
+              const TMatrixD &b) ;
+
+   TKalMatrix(const TVector3 &v);
+
+   virtual ~TKalMatrix() {}
+
+   virtual void      DebugPrint(Option_t *opt = "", Int_t nc = 5) const;
+
+   static TKalMatrix ToKalMat  (const TVector3 &vec);
+   static TVector3   ToThreeVec(const TMatrixD &mat);
+   
+private:
+   
+   ClassDef(TKalMatrix,1)      // Base class for Kalman matrix
+};
+#endif
diff --git a/Utilities/KalTest/kaltest/TKalTrack.h b/Utilities/KalTest/kaltest/TKalTrack.h
new file mode 100644
index 0000000000000000000000000000000000000000..13540c2928d7392307ba46445c0c57fd7838de66
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TKalTrack.h
@@ -0,0 +1,54 @@
+#ifndef TKALTRACK_H
+#define TKALTRACK_H
+//*************************************************************************
+//* =================
+//*  TKalTrack Class
+//* =================
+//*
+//* (Description)
+//*   Track class for Kalman filter
+//* (Requires)
+//*     TVKalSystem
+//* (Provides)
+//*     class TKalTrack
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima	Original version.
+//*   2005/02/23  A.Yamaguchi	Added a new data member fMass and its
+//*                             getter and setter.
+//*   2005/08/15  K.Fujii       Removed fDir and its getter and setter.
+//*   2005/08/25  K.Fujii       Added Drawable attribute.
+//*   2005/08/26  K.Fujii       Removed Drawable attribute.
+//*
+//*************************************************************************
+                                                                                
+#include "TVKalSystem.h"       // from KalLib
+#include "TKalTrackState.h"    // from KalTrackLib
+
+//_________________________________________________________________________
+//  ------------------------------
+//   TKalTrack: Kalman Track class
+//  ------------------------------
+                                                                                
+class TKalTrack : public TVKalSystem {
+public:
+   TKalTrack(Int_t n = 1);
+   ~TKalTrack() {}
+
+   inline virtual void      SetMass(Double_t m)           { fMass = m;    }
+   inline virtual Double_t  GetMass()             const   { return fMass; }
+
+   Double_t FitToHelix(TKalTrackState &a, TKalMatrix &C, Int_t &ndf);
+
+private:
+   Double_t     fMass;        // mass [GeV]
+
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+   static const Double_t kMpi = 0.13957018; //! pion mass [GeV]
+#else
+   static const Double_t kMpi;              //! pion mass [GeV]
+#endif
+
+   ClassDef(TKalTrack,1)  // Base class for Kalman Filter
+};
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TKalTrackSite.h b/Utilities/KalTest/kaltest/TKalTrackSite.h
new file mode 100644
index 0000000000000000000000000000000000000000..3764e87f58efa5d5c5a3666ca63a003f7a0be391
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TKalTrackSite.h
@@ -0,0 +1,76 @@
+#ifndef TKALTRACKSITE_H
+#define TKALTRACKSITE_H
+//*************************************************************************
+//* =====================
+//*  TKalTrackSite Class
+//* =====================
+//*
+//* (Description)
+//*   Track measurement site class used by Kalman filter.
+//* (Requires)
+//*     TKalTrackState
+//* (Provides)
+//*     class TKalTrackSite
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2004/09/17  K.Fujii           Added ownership flag.
+//*   2010/04/06  K.Fujii           Added a setter for the pivot and a
+//*                                 condition object
+//*
+//*************************************************************************
+
+#include "TVector3.h"    // from ROOT
+#include "TVKalSite.h"   // from KalLib
+#include "TVTrackHit.h"  // from KalTrackLib
+
+class TVKalState;
+class TKalTrackState;
+class TKalFilterCond;
+
+//_________________________________________________________________________
+//  ---------------------------------
+//  Class for Kalman measurement site
+//  ---------------------------------
+//
+class TKalTrackSite : public TVKalSite {
+public:
+   TKalTrackSite(Int_t m = kMdim, Int_t p = kSdim);
+   TKalTrackSite( const TVTrackHit &ht, 
+                        Int_t       p = kSdim);
+   ~TKalTrackSite();
+
+   Int_t        CalcExpectedMeasVec  (const TVKalState &a, TKalMatrix &h);
+   Int_t        CalcMeasVecDerivative(const TVKalState &a, TKalMatrix &H);
+   Bool_t       IsAccepted();
+
+   void         DebugPrint() const;
+
+   inline const TVTrackHit & GetHit    () const { return *fHitPtr;             }
+   inline const TVector3   & GetPivot  () const { return fX0;                  }
+   inline       Double_t     GetBfield () const { return fHitPtr->GetBfield(); }
+   inline       Bool_t       IsInB     () const { return GetBfield() != 0.;    }
+   inline       Bool_t       IsHitOwner() const { return fIsHitOwner;          }
+
+   inline       void   SetPivot     (const TVector3 &x0)  { fX0 = x0;          }
+   inline       void   SetHitOwner  (Bool_t b=kTRUE)      { fIsHitOwner = b;   }
+   inline       void   SetFilterCond(TKalFilterCond *cp)  { fCondPtr    = cp;  }
+
+private:
+   TVKalState & CreateState(const TKalMatrix &sv, Int_t type = 0);
+   TVKalState & CreateState(const TKalMatrix &sv,
+                            const TKalMatrix &C,
+                                  Int_t       type = 0);
+   Int_t        CalcXexp   (const TVKalState &a, 
+                                  TVector3   &xx,
+                                  Double_t   &phi) const;
+
+private:
+   const TVTrackHit     *fHitPtr;     // pointer to corresponding hit
+         TVector3        fX0;         // pivot
+         Bool_t          fIsHitOwner; // true if site owns hit
+         TKalFilterCond *fCondPtr;    // pointer to filter condition object
+
+   ClassDef(TKalTrackSite,1)  // sample measurement site class
+};
+                                                                                
+#endif
diff --git a/Utilities/KalTest/kaltest/TKalTrackState.h b/Utilities/KalTest/kaltest/TKalTrackState.h
new file mode 100644
index 0000000000000000000000000000000000000000..6931adcf0aa8c13fa6029584ca9d154623c152ba
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TKalTrackState.h
@@ -0,0 +1,76 @@
+#ifndef TKALTRACKSTATE_H
+#define TKALTRACKSTATE_H
+//*************************************************************************
+//* ======================
+//*  TKalTrackState Class
+//* ======================
+//*
+//* (Description)
+//*   Track state vector class used in Kalman Filter.
+//* (Requires)
+//*     TVKalState
+//* (Provides)
+//*     class TKalTrackState
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2005/02/23  A.Yamaguchi       Added CalcDapDa method.
+//*   2005/02/XX  A.Yamaguchi       Moved CalcDapDa method to THelicalTrack.
+//*   2005/08/13  K.Fujii           Removed CalcProcessNoise method.
+//*   2010/04/06  K.Fujii           Modified MoveTo to allow a 1-dim hit,
+//*                                 for which pivot is at the xpected hit.
+//*
+//*************************************************************************
+
+#include "TVKalState.h"         // from KalLib
+#include "THelicalTrack.h"      // from GeomLib
+#include "TStraightTrack.h"     // from GeomLib
+#include "KalTrackDim.h"        // from KalTrackLib
+
+class TKalTrackSite;
+
+//_________________________________________________________________________
+//  -----------------------------------
+//  Base Class for Kalman state vector
+//  -----------------------------------
+//
+
+class TKalTrackState : public TVKalState {
+                                                                                
+public:
+                                                                                
+   // Ctors and Dtor
+                                                                                
+   TKalTrackState(Int_t p = kSdim);
+   TKalTrackState(const TKalMatrix &sv, Int_t type = 0, Int_t p = kSdim);
+   TKalTrackState(const TKalMatrix &sv, const TKalMatrix &c, 
+                        Int_t type = 0, Int_t p = kSdim);
+   TKalTrackState(const TKalMatrix &sv, const TVKalSite &site, 
+                        Int_t type = 0, Int_t p = kSdim);
+   TKalTrackState(const TKalMatrix &sv, const TKalMatrix &c,
+                  const TVKalSite &site, Int_t type = 0, Int_t p = kSdim);
+   virtual ~TKalTrackState() {}
+                                                                                
+   // Implementation of paraent class pure virtuals
+                                                                                
+   TKalTrackState * MoveTo(TVKalSite  &to, 
+                           TKalMatrix &F, 
+                           TKalMatrix *QPtr = 0) const;
+   TKalTrackState & MoveTo(TVKalSite  &to, 
+                           TKalMatrix &F, 
+                           TKalMatrix &Q) const;
+   void         DebugPrint() const;
+
+   // Derived class methods
+
+   THelicalTrack   GetHelix() const;
+   TStraightTrack  GetLine () const;
+   TVTrack        &CreateTrack() const;
+
+private:
+
+   TVector3 fX0;		// pivot
+
+   ClassDef(TKalTrackState,1)      // sample state vector class
+};
+                                                                                
+#endif
diff --git a/Utilities/KalTest/kaltest/TPlane.h b/Utilities/KalTest/kaltest/TPlane.h
new file mode 100644
index 0000000000000000000000000000000000000000..a75d6737b3efa6406340b401beb9c126cce9db71
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TPlane.h
@@ -0,0 +1,80 @@
+#ifndef TPLANE_H
+#define TPLANE_H
+//*************************************************************************
+//* ====================
+//*  TPlane Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a flat plane object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class TPlane
+//* (Update Recored)
+//*   2004/10/30  A.Yamaguchi       Original version.
+//*   2005/02/23  K.Fujii           Added GetSortingPolicy().
+//*
+//*************************************************************************
+//
+#include "TVSurface.h"
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Plane Class
+//  -----------------------------------
+
+class TPlane : public TVSurface {
+public:
+   TPlane();
+   TPlane(const TVector3 &xc);
+   TPlane(const TVector3 &xc, const TVector3 &n);
+
+   virtual ~TPlane() {}
+
+   virtual Double_t CalcS   (const TVector3 &xx) const;
+   virtual TMatrixD CalcDSDx(const TVector3 &xx) const;
+
+   inline virtual const TVector3 & GetXc     () const { return fXc;     } 
+   inline virtual const TVector3 & GetNormal () const { return fNormal; } 
+   inline virtual       Bool_t     IsOnSurface(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside  (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetSortingPolicy()              const;
+
+
+private:
+   TVector3 fXc;          // center
+   TVector3 fNormal;      // normal
+ 
+   ClassDef(TPlane,1)      // plane class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+
+Bool_t TPlane::IsOnSurface(const TVector3 &xx) const
+{
+#if 0
+   return (xx - fXc) * fNormal == 0. ? kTRUE : kFALSE; 
+#else
+   return kTRUE;
+#endif
+} 
+
+Bool_t TPlane::IsOutside(const TVector3 &xx) const
+{
+   return (xx - fXc) * fNormal > 0. ? kTRUE : kFALSE; 
+} 
+
+Double_t TPlane::GetSortingPolicy() const
+{
+   return TMath::Abs(fXc*fNormal.Unit());
+}
+#endif
+
diff --git a/Utilities/KalTest/kaltest/TStraightTrack.h b/Utilities/KalTest/kaltest/TStraightTrack.h
new file mode 100644
index 0000000000000000000000000000000000000000..d48c91e144dd923bd37a8fe20190237b46e924a0
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TStraightTrack.h
@@ -0,0 +1,75 @@
+#ifndef TSTRAIGHTTRACK_H
+#define TSTRAIGHTTRACK_H
+//*************************************************************************
+//* ======================
+//*  TStraightTrack Class
+//* ======================
+//*
+//* (Description)
+//*   A class to implement a straight track object.
+//*
+//*   The stragiht track is implemented as the kappa->infinity limit
+//*   of a helical track:
+//*
+//*      x = x0 + drho * cos(phi0) - t * sin(phi0)
+//*      y = y0 + drho * sin(phi0) + t * cos(phi0)
+//*      z = z0 + dz               + t * tan(lambda)
+//*
+//* (Requires)
+//*     TVTrack, TCylinder, TCircle, TVector3, TMatrixD
+//* (Provides)
+//*     class TStraightTrack
+//* (Update Recored)
+//*   2003/10/24  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+
+#include "TVTrack.h"
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Straight Track Class
+//  -----------------------------------
+
+class TStraightTrack : public TVTrack {
+public:
+
+   // Ctors and Dtor
+
+   TStraightTrack(Double_t dr    = 0.,
+                  Double_t phi0  = 0.,
+                  Double_t kappa = 1.e-5,
+                  Double_t dz    = 0.,
+                  Double_t tanl  = 0.,
+                  Double_t x0    = 0.,
+                  Double_t y0    = 0.,
+                  Double_t z0    = 0.,
+                  Double_t b     = 0.);
+
+   TStraightTrack(const TMatrixD &a, const TVector3 & x0, Double_t b = 0.);
+
+   virtual ~TStraightTrack() {}
+
+   // Utility methods
+
+   virtual void MoveTo(const TVector3 &x0to,
+                             Double_t &t,
+                             TMatrixD *F = 0,
+                             TMatrixD *C = 0);
+
+   TVector3 CalcXAt   (Double_t phi) const;
+   TMatrixD CalcDxDa  (Double_t phi) const;
+   TMatrixD CalcDxDphi(Double_t phi) const;
+   void     CalcDapDa (Double_t fid,
+                       Double_t dr,
+                       Double_t drp,
+                       TMatrixD &F)  const;
+
+private:
+
+   ClassDef(TStraightTrack,1)      // circle class
+};
+
+#endif
+
diff --git a/Utilities/KalTest/kaltest/TTube.h b/Utilities/KalTest/kaltest/TTube.h
new file mode 100644
index 0000000000000000000000000000000000000000..f10a135e2e29453d52c051b1bea98dda009835e7
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TTube.h
@@ -0,0 +1,92 @@
+#ifndef TTUBE_H
+#define TTUBE_H
+//*************************************************************************
+//* ====================
+//*  TTube Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a tube object.
+//* (Requires)
+//*     TVSolid
+//* (Provides)
+//*     class TTube
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include "TVSolid.h"
+#include "TVector3.h"
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Cylinder Class
+//  -----------------------------------
+
+class TTube : public TVSolid {
+public:
+   TTube(Double_t rin =  0., Double_t rout = 1., Double_t hlen  = 1., 
+             Double_t xc = 0., Double_t yc = 0, Double_t zc = 0.)
+           : fRin(rin), fRout(rout), fHalfLen(hlen), fXc(xc,yc,zc) {}
+
+   virtual ~TTube() {}
+
+   virtual Int_t CalcXingPointWith(const TVTrack  &hel,
+                                         Double_t &phi,
+                                         TVector3 &xx,
+                                         Int_t     mode,
+                                         Double_t  eps = 1.e-8)   const;
+
+   inline virtual       Bool_t     IsOnBarrel(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetRin    () const { return fRin;  } 
+   inline virtual       Double_t   GetRout   () const { return fRout; } 
+   inline virtual const TVector3 & GetXc     () const { return fXc;   } 
+   inline virtual       Double_t   GetLength () const;
+   inline virtual       Double_t   GetZmin   () const;
+   inline virtual       Double_t   GetZmax   () const;
+
+private:
+   Double_t fRin;         // inner radius
+   Double_t fRout;        // outer radius
+   Double_t fHalfLen;     // half length
+   TVector3 fXc;          // center
+ 
+   ClassDef(TTube,1)      // TTube class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+Double_t TTube::GetLength () const 
+{ 
+   return 2*fHalfLen;
+} 
+
+Double_t TTube::GetZmin() const
+{
+   return fXc.Z() - fHalfLen;
+}
+
+Double_t TTube::GetZmax() const
+{
+   return fXc.Z() + fHalfLen;
+}
+
+Bool_t TTube::IsOnBarrel(const TVector3 &xx) const
+{
+   return (xx.Z() >= GetZmin() && xx.Z() <= GetZmax());
+} 
+
+Bool_t TTube::IsOutside(const TVector3 &xx) const
+{
+   Double_t r = (xx-fXc).Perp();
+   Double_t z = xx.Z();
+   return (r < fRin || r > fRout || z < GetZmin() || z > GetZmax());
+} 
+#endif
+
diff --git a/Utilities/KalTest/kaltest/TVCurve.h b/Utilities/KalTest/kaltest/TVCurve.h
new file mode 100644
index 0000000000000000000000000000000000000000..040912825ded5dfdeb1f52254aa75508c9343595
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVCurve.h
@@ -0,0 +1,32 @@
+#ifndef TVCURVE_H
+#define TVCURVE_H
+//*************************************************************************
+//* ====================
+//*  TVCurve Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for various curves.
+//* (Requires)
+//*     TObject;
+//* (Provides)
+//*     class TVCurve
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include "TObject.h"
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any curve
+//  -----------------------------------
+
+class TVCurve : public TObject {
+public:
+private:
+ 
+   ClassDef(TVCurve,1)      // Base class for any curve
+};
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TVKalDetector.h b/Utilities/KalTest/kaltest/TVKalDetector.h
new file mode 100644
index 0000000000000000000000000000000000000000..0edc3946f65bd5088081955a42cb7a06be17c948
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVKalDetector.h
@@ -0,0 +1,39 @@
+#ifndef TVKALDETECTOR_H
+#define TVKALDETECTOR_H
+//*************************************************************************
+//* =====================
+//*  TVKalDetector Class
+//* =====================
+//*
+//* (Description)
+//*   Base class to hold information of detector system
+//*   used in Kalman filter classes.
+//* (Requires)
+//* 	TObjArray
+//* (Provides)
+//* 	class TVKalDetector
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*   2005/02/23  A.Yamaguchi	Moved most methods to TKalDetCradle.
+//*
+//*************************************************************************
+
+#include "TObjArray.h"        // from ROOT
+#include "TAttElement.h"      // from Utils
+
+//_________________________________________________________________________
+// ------------------------------
+//  Detector system class
+// ------------------------------
+//
+
+class TVKalDetector : public TObjArray, public TAttElement {
+public:
+   // Ctors and Dtor
+   TVKalDetector(Int_t n = 1) : TObjArray(n) {}
+   virtual ~TVKalDetector() {}
+
+   ClassDef(TVKalDetector,1)  // Base class for detector system
+};
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TVKalSite.h b/Utilities/KalTest/kaltest/TVKalSite.h
new file mode 100644
index 0000000000000000000000000000000000000000..d00345af335c708b91b79bacb42aafd3cf97fd2a
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVKalSite.h
@@ -0,0 +1,124 @@
+#ifndef TVKALSITE_H
+#define TVKALSITE_H
+//*************************************************************************
+//* ===================
+//*  TVKalSite Class
+//* ===================
+//*
+//* (Description)
+//*   This is the base class for measurement vector used by Kalman filter.
+//* (Requires)
+//* 	TKalMatrix
+//* (Provides)
+//* 	class TVKalSite
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*   2005/02/23  A.Yamaguchi	Added getter and setter for a new static
+//*                             data member, fgKalSysPtr.
+//*   2005/08/25  A.Yamaguchi	Removed getter and setter for a new static
+//*                             data member, fgKalSysPtr.
+//*   2009/06/18  K.Fujii       Implement inverse Kalman filter
+//*
+//*************************************************************************
+//
+#include "TObjArray.h"
+
+#include "TAttLockable.h"
+#include "TKalMatrix.h"
+#include "TVKalState.h"
+
+class TVKalSystem;
+
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for Kalman measurement vector
+//  ------------------------------
+//
+class TVKalSite : public TObjArray, public TAttLockable {
+friend class TVKalSystem;
+
+public:
+   enum EStType { kPredicted = 0,
+                  kFiltered,
+                  kSmoothed,
+                  kInvFiltered };
+public:
+   // Ctors and Dtor
+
+   TVKalSite(Int_t m = 2, Int_t p = 6);
+   virtual ~TVKalSite();
+             
+   // Utility Methods
+
+   virtual Int_t   CalcExpectedMeasVec  (const TVKalState &a,
+                                               TKalMatrix &m) = 0;
+   virtual Int_t   CalcMeasVecDerivative(const TVKalState &a,
+                                               TKalMatrix &H) = 0;
+   virtual Bool_t  IsAccepted() = 0;
+
+   virtual void    DebugPrint() const = 0;
+
+   virtual Bool_t  Filter();
+
+   virtual void    Smooth(TVKalSite &pre);
+
+   virtual void    InvFilter();
+
+   inline  void    Add(TObject *obj);
+   
+   // Getters
+
+   inline virtual Int_t        GetDimension() const { return fM.GetNrows(); }
+   inline virtual TVKalState & GetCurState ()       { return *fCurStatePtr; }
+   inline virtual TVKalState & GetCurState () const { return *fCurStatePtr; }
+   inline virtual TVKalState & GetState (EStType t);
+   inline virtual TKalMatrix & GetMeasVec      ()   { return fM;            }
+   inline virtual TKalMatrix & GetMeasNoiseMat ()   { return fV;            }
+   inline virtual TKalMatrix & GetResVec       ()   { return fResVec;       }
+   inline virtual TKalMatrix & GetCovMat       ()   { return fR;            }
+   inline virtual Double_t     GetDeltaChi2() const { return fDeltaChi2;    }
+          virtual TKalMatrix   GetResVec (EStType t);
+
+private:
+   // Private utility methods
+
+   virtual TVKalState & CreateState(const TKalMatrix &sv, Int_t type = 0) = 0;
+   virtual TVKalState & CreateState(const TKalMatrix &sv, const TKalMatrix &c,
+                                    Int_t type = 0) = 0;
+
+private:
+   
+   // private data member -------------------------------------------
+
+   TVKalState    *fCurStatePtr; // pointer to current best state
+   TKalMatrix     fM;           // measurement vector: M(m,1)
+   TKalMatrix     fV;           // noise matrix: M(m,m)
+   TKalMatrix     fH;           // H = (@h/@a): M(m,p)
+   TKalMatrix     fHt;          // H^t = (@h/@a)^t: M(p,m)
+   TKalMatrix     fResVec;      // m - h(a): M(m,1)
+   TKalMatrix     fR;           // covariance matrix: M(m,m)
+   Double_t       fDeltaChi2;   // chi2 increment
+
+   ClassDef(TVKalSite,1)      // Base class for measurement vector objects
+};
+
+//=======================================================
+// inline functions
+//=======================================================
+
+void TVKalSite::Add(TObject *obj)
+{
+   TObjArray::Add(obj);
+   fCurStatePtr = static_cast<TVKalState *>(obj);
+   fCurStatePtr->SetSitePtr(this);
+}
+
+TVKalState & TVKalSite::GetState(TVKalSite::EStType t)
+{
+   TVKalState *ap = 0;
+   if (t >= 0 && t < GetEntries()) {
+      ap = static_cast<TVKalState *>(UncheckedAt(t));
+   }
+   return *ap;
+}
+#endif
diff --git a/Utilities/KalTest/kaltest/TVKalState.h b/Utilities/KalTest/kaltest/TVKalState.h
new file mode 100644
index 0000000000000000000000000000000000000000..38efabd27814efd840f65834261512184024ed5a
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVKalState.h
@@ -0,0 +1,90 @@
+#ifndef TVKALSTATE_H
+#define TVKALSTATE_H
+//*************************************************************************
+//* ====================
+//*  TVKalState Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for a state vector used in Kalman Filter.
+//* (Requires)
+//* 	TKalMatrix
+//* (Provides)
+//* 	class TVKalState
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*
+//*************************************************************************
+//
+#include "TKalMatrix.h"
+class TVKalSite;
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for Kalman state vector
+//  -----------------------------------
+//
+class TVKalState : public TKalMatrix { 
+public:
+
+   // Ctors and Dtor
+
+   TVKalState(Int_t type = 0, Int_t p = 6);
+   TVKalState(const TKalMatrix &sv, Int_t type = 0, Int_t p = 6);
+   TVKalState(const TKalMatrix &sv, const TKalMatrix &c, 
+              Int_t type = 0, Int_t p = 6);
+   TVKalState(const TKalMatrix &sv, const TVKalSite &site, 
+              Int_t type = 0, Int_t p = 6);
+   TVKalState(const TKalMatrix &sv, const TKalMatrix &c,
+              const TVKalSite &site, Int_t type = 0, Int_t p = 6);
+   virtual ~TVKalState() {}
+
+   // Pure virtuals to be implemented in derived classes
+   //
+   // MoveTo should calculate
+   //    a:  predicted state vector      : a^k-1_k = f_k-1(a_k-1)
+   //    F:  propagator derivative       : F_k-1   = (@f_k-1/@a_k-1)
+   //    Q:  process noise from k-1 to k : Q_k-1)
+   // and return a^k-1_k.
+   //
+
+   virtual TVKalState * MoveTo(TVKalSite  &to,
+                               TKalMatrix &F,
+                               TKalMatrix *QPtr = 0) const = 0;
+   virtual TVKalState & MoveTo(TVKalSite  &to,
+                               TKalMatrix &F,
+                               TKalMatrix &Q) const = 0;
+
+   virtual void         DebugPrint() const = 0;
+
+   virtual void         Propagate(TVKalSite &to); // calculates f, F, and Q
+ 
+   
+   // Getters
+
+   inline virtual Int_t GetDimension                () const { return GetNrows(); }
+   inline virtual const TVKalSite  & GetSite        () const { return *fSitePtr; }
+   inline virtual const TKalMatrix & GetCovMat      () const { return fC; }
+   inline virtual const TKalMatrix & GetProcNoiseMat() const { return fQ; }
+   inline virtual const TKalMatrix & GetPropMat     (const Char_t *t = "") const { return (t[0] == 'T' ? fFt : fF); } 
+
+   // Setters
+
+   inline virtual void SetStateVec    (const TKalMatrix &c) { TMatrixD::operator=(c); }
+   inline virtual void SetCovMat      (const TKalMatrix &c) { fC       = c; }
+   inline virtual void SetProcNoiseMat(const TKalMatrix &q) { fQ       = q; }
+   inline virtual void SetSitePtr     (TVKalSite  *s)       { fSitePtr = s; }
+
+private:
+   
+   // private data members -------------------------------------------
+
+   Int_t       fType;    // (0,1,2,3) = (uninited,predicted,filtered,smoothed)
+   TVKalSite  *fSitePtr; // pointer to corresponding KalSite
+   TKalMatrix  fF;       // propagator matrix to next site (F = @f/@a)
+   TKalMatrix  fFt;      // transposed propagator matrix (F^T = (@f/@a)^T)
+   TKalMatrix  fQ;       // process noise from this to the next sites
+   TKalMatrix  fC;       // covariance matrix
+  
+   ClassDef(TVKalState,1)      // Base class for state vector objects
+};
+#endif
diff --git a/Utilities/KalTest/kaltest/TVKalSystem.h b/Utilities/KalTest/kaltest/TVKalSystem.h
new file mode 100644
index 0000000000000000000000000000000000000000..fff6d5a8631cb0211e9b8af29e6b6dbe34af8987
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVKalSystem.h
@@ -0,0 +1,82 @@
+#ifndef TVKALSYSTEM_H
+#define TVKALSYSTEM_H
+//*************************************************************************
+//* ===================
+//*  TVKalSystem Class
+//* ===================
+//*
+//* (Description)
+//*   Base class for Kalman filtering class
+//* (Requires)
+//* 	TObjArray
+//* (Provides)
+//* 	class TVKalSystem
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*   2005/08/25  A.Yamaguchi	Added fgCurInstancePtr and its getter & setter.
+//*   2009/06/18  K.Fujii       Implement inverse Kalman filter
+//*
+//*************************************************************************
+
+#include "TObjArray.h"
+#include "TVKalSite.h"
+
+//_____________________________________________________________________
+//  ------------------------------
+//  Kalman Filtering class
+//  ------------------------------
+//
+class TKalMatrix;
+
+class TVKalSystem : public TObjArray {
+friend class TVKalSite;
+public:
+
+   // Ctors and Dtor
+
+   TVKalSystem(Int_t n = 1);
+   virtual ~TVKalSystem();
+
+   // Utility methods
+
+   virtual Bool_t AddAndFilter(TVKalSite &next);
+   virtual void   SmoothBackTo(Int_t k);
+   virtual void   SmoothAll();
+   virtual void   InvFilter(Int_t k);
+
+   inline  void   Add(TObject *obj);
+
+   // Getters
+
+   inline virtual TVKalSite  & GetCurSite()     { return *fCurSitePtr; }
+   inline virtual TVKalState & GetState(TVKalSite::EStType t) 
+                                   { return fCurSitePtr->GetState(t); }
+   inline virtual Double_t     GetChi2() { return fChi2; }
+          virtual Int_t        GetNDF (Bool_t self = kTRUE);
+   
+   static         TVKalSystem *GetCurInstancePtr() { return fgCurInstancePtr; }
+
+   // Setters
+
+private:
+   static void SetCurInstancePtr(TVKalSystem *ksp) { fgCurInstancePtr = ksp; }
+
+private:
+   TVKalSite   *fCurSitePtr;  // pointer to current site
+   Double_t     fChi2;        // current total chi2
+
+   static TVKalSystem *fgCurInstancePtr;  //! currently active instance
+   
+   ClassDef(TVKalSystem,1)  // Base class for Kalman Filter
+};
+
+//=======================================================
+// inline functions
+//=======================================================
+
+void TVKalSystem::Add(TObject *obj)
+{
+   TObjArray::Add(obj); 
+   fCurSitePtr = static_cast<TVKalSite *>(obj);
+}
+#endif
diff --git a/Utilities/KalTest/kaltest/TVMeasLayer.h b/Utilities/KalTest/kaltest/TVMeasLayer.h
new file mode 100644
index 0000000000000000000000000000000000000000..5cdc314352f89963a5a8dc560c0623dac861c177
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVMeasLayer.h
@@ -0,0 +1,86 @@
+#ifndef TVMEASLAYER_H
+#define TVMEASLAYER_H
+//*************************************************************************
+//* ====================
+//*  TVMeasLayer Class
+//* ====================
+//*
+//* (Description)
+//*   Measurement layer interface class.
+//* (Requires)
+//* (Provides)
+//*     class TVMeasLayer
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2005/02/23  A.Yamaguchi       Added new data members, fFwdX0Inv,
+//*                                 fBwdX0Inv and fIndex, and their
+//*                                 corresponding getters and setters.
+//*                                 Added a new method, GetX0Inv().
+//*   2005/0X/XX  A.Yamaguchi       Replaced fFwdX0Inv, fBwdX0Inv, and
+//*                                 their getters and setters by
+//*                                 fMaterialOutPtr, fMaterialInPtr, and
+//*                                 their getters and setters.
+//*   2005/08/15  K.Fujii           Added fIsActive and IsActive().
+//*   2011/12/03  S.Aplin           Added new member: name 
+//*                                 default value set to "TVMeasLayer"
+//*                                 and corresponding member function
+//*                                 TString GetName()  
+//*
+//*************************************************************************
+
+#include "TVector3.h"       // from ROOT
+#include "TMaterial.h"      // from ROOT
+#include "TAttElement.h"    // from Utils
+#include "TKalMatrix.h"     // from KalLib
+#include "KalTrackDim.h"    // from KalTrackLib
+
+class TVTrack;
+class TVTrackHit;
+
+class TVMeasLayer : public TAttElement {
+public:
+   // Ctors and Dtor
+
+   TVMeasLayer(TMaterial &matIn, 
+               TMaterial &matOut,
+               Bool_t     isactive = kTRUE,
+               const Char_t    *name = "TVMeasLayer");
+   virtual ~TVMeasLayer() {}
+
+   // Utiliy Methods
+
+   virtual TKalMatrix XvToMv   (const TVTrackHit &ht,
+                                const TVector3   &xv) const = 0;
+   virtual TVector3   HitToXv  (const TVTrackHit &ht) const = 0;
+   virtual void       CalcDhDa (const TVTrackHit &ht,
+                                const TVector3   &xv,
+                                const TKalMatrix &dxphiada,
+                                      TKalMatrix &H)  const = 0;
+
+   inline virtual TMaterial &GetMaterial(Bool_t isoutgoing) const
+              { return isoutgoing ? *fMaterialOutPtr : *fMaterialInPtr; }
+     
+   inline  Int_t      GetIndex() const  { return fIndex;    }
+   inline  void       SetIndex(Int_t i) { fIndex = i;       }    
+   inline  Bool_t     IsActive() const  { return fIsActive; }
+
+   virtual Double_t   GetEnergyLoss (      Bool_t    isoutgoing,
+                                     const TVTrack  &hel,
+                                           Double_t  df) const;
+   virtual void       CalcQms       (      Bool_t    isoutgoing,
+                                     const TVTrack  &hel,
+                                           Double_t  df,
+                                           TKalMatrix &Qms) const;
+
+  inline TString       GetName() const { return fname;    }
+  
+private:
+   TMaterial     *fMaterialInPtr;   // pointer of inner Material
+   TMaterial     *fMaterialOutPtr;  // pointer of outer Material
+   Int_t          fIndex;           // index in TKalDetCradle
+   Bool_t         fIsActive;        // flag to tell layer is active or not
+  const Char_t   *fname;
+   ClassDef(TVMeasLayer,1)      // Measurement layer interface class
+};
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TVSolid.h b/Utilities/KalTest/kaltest/TVSolid.h
new file mode 100644
index 0000000000000000000000000000000000000000..83b4f57e20505c8bda69f27297ec0e604f2957b3
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVSolid.h
@@ -0,0 +1,32 @@
+#ifndef TVSOLID_H
+#define TVSOLID_H
+//*************************************************************************
+//* ====================
+//*  TVSolid Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for various solids.
+//* (Requires)
+//*     TObject;
+//* (Provides)
+//*     class TVSolid
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include "TObject.h"
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any solid
+//  -----------------------------------
+
+class TVSolid : public TObject {
+public:
+private:
+ 
+   ClassDef(TVSolid,1)      // Base class for any solid
+};
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TVSurface.h b/Utilities/KalTest/kaltest/TVSurface.h
new file mode 100644
index 0000000000000000000000000000000000000000..be0a085a4ab3a00d09b2f5dbfe533f670d937e4a
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVSurface.h
@@ -0,0 +1,68 @@
+#ifndef TVSURFACE_H
+#define TVSURFACE_H
+//*************************************************************************
+//* ====================
+//*  TVSurface Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for various solids.
+//* (Requires)
+//*     TObject;
+//* (Provides)
+//*     class TVSurface
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*   2005/02/23  K.Fujii       Added new methods, Compare() and
+//*                             GetSortingPolicy().
+//*
+//*   2011/06/17  D.Kamai       Added new method, GetOutwardNormal() 
+//*                             
+//*************************************************************************
+//
+#include "TObject.h"
+#include "TMatrixD.h"
+#include "TVector3.h"
+
+class TVTrack;
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any surface
+//  -----------------------------------
+
+class TVSurface : public TObject {
+public:
+
+   virtual Int_t    CalcXingPointWith(const TVTrack  &hel,
+                                            TVector3 &xx,
+                                            Double_t &phi,
+                                            Double_t  eps = 1.e-8) const;
+   virtual Int_t    CalcXingPointWith(const TVTrack  &hel,
+                                            TVector3 &xx,
+                                            Double_t &phi,
+                                            Int_t     mode,
+   				            Double_t  eps = 1.e-8) const;
+
+   virtual Double_t CalcS            (const TVector3 &xx) const = 0;
+   virtual TMatrixD CalcDSDx         (const TVector3 &xx) const = 0;
+   virtual Bool_t   IsOnSurface      (const TVector3 &xx) const = 0;
+   virtual Bool_t   IsOutside        (const TVector3 &xx) const = 0;
+   inline virtual TVector3 GetOutwardNormal (const TVector3 &xx) const;
+  
+   virtual Double_t GetSortingPolicy ()                   const = 0;
+
+   virtual Int_t    Compare   (const TObject *obj) const;
+   virtual Bool_t   IsSortable()                   const { return kTRUE; }
+   
+private:
+ 
+   ClassDef(TVSurface,1)      // Base class for any surface
+};
+
+TVector3 TVSurface::GetOutwardNormal(const TVector3 &xx) const
+{
+  TMatrixD dsdx = CalcDSDx(xx);
+  return TVector3(dsdx(0,0),dsdx(0,1),dsdx(0,2)).Unit();
+}
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TVTrack.h b/Utilities/KalTest/kaltest/TVTrack.h
new file mode 100644
index 0000000000000000000000000000000000000000..9e8f0f4548363a1b9aa6573a094863186e221413
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVTrack.h
@@ -0,0 +1,150 @@
+#ifndef TVTRACK_H
+#define TVTRACK_H
+//*************************************************************************
+//* ===============
+//*  TVTrack Class
+//* ===============
+//*
+//* (Description)
+//*   This is the base class for various tracks.
+//* (Requires)
+//*     TVCurve;
+//* (Provides)
+//*     class TVTrack
+//* (Update Recored)
+//*   2003/10/24  K.Fujii       Original version.
+//*   2005/08/14  K.Fujii       Added IsInB().
+//*
+//*************************************************************************
+//
+
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+#if 1
+#include "TMath.h"
+#include "TCollection.h"
+#endif
+
+#include "TVCurve.h"
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any track
+//  -----------------------------------
+
+class TVTrack : public TVCurve {
+public:
+   // Ctors and Dtor
+
+   TVTrack(Double_t dr    = 0.,
+           Double_t phi0  = 0.,
+           Double_t kappa = 1.e-5,
+           Double_t dz    = 0.,
+           Double_t tanl  = 0.,
+           Double_t x0    = 0.,
+           Double_t y0    = 0.,
+           Double_t z0    = 0.,
+           Double_t b     = 30.);
+
+   TVTrack(const TMatrixD &a, const TVector3 & x0, Double_t b = 30.);
+
+   virtual ~TVTrack() {}
+
+   // Utility methods
+
+   virtual void MoveTo(const TVector3 &x0to,
+                             Double_t &fid,
+                             TMatrixD *F = 0,
+                             TMatrixD *C = 0) = 0;
+
+   virtual void MoveTo(const TVector3 &x0to,
+                             Double_t &fid,
+                             TMatrixD &C)
+   {
+      Int_t sdim = C.GetNrows();
+      TMatrixD F(sdim, sdim);
+      MoveTo(x0to,fid,&F,&C);
+   }
+
+   inline virtual void ScatterBy(Double_t dphi, Double_t dtnl)
+   {
+      fPhi0  += dphi;
+      fKappa += (fKappa*fTanL/(1+fTanL*fTanL)) * dtnl;
+      fTanL  += dtnl;
+   }
+
+   inline virtual void  PutInto(TMatrixD &sv) const
+   {
+      sv(0,0) = fDrho;
+      sv(1,0) = fPhi0;
+      sv(2,0) = fKappa;
+      sv(3,0) = fDz;
+      sv(4,0) = fTanL;
+   }
+
+   virtual TVector3 CalcXAt   (Double_t phi) const = 0;
+   virtual TMatrixD CalcDxDa  (Double_t phi) const = 0;
+   virtual TMatrixD CalcDxDphi(Double_t phi) const = 0;
+   virtual void     CalcDapDa (Double_t fid,
+                               Double_t dr,
+                               Double_t drp,
+                               TMatrixD &F)  const = 0;
+
+   // Getters
+
+   inline virtual       Double_t   GetDrho     () const { return fDrho;  }
+   inline virtual       Double_t   GetPhi0     () const { return fPhi0;  }
+   inline virtual       Double_t   GetKappa    () const { return fKappa; }
+   inline virtual       Double_t   GetDz       () const { return fDz;    }
+   inline virtual       Double_t   GetTanLambda() const { return fTanL;  }
+   inline virtual const TVector3 & GetPivot    () const { return fX0;    }
+   inline virtual       Double_t   GetRho      () const { return fAlpha/fKappa; }
+   inline virtual       Double_t   GetPtoR     () const { return fAlpha; }
+
+   // Setters
+
+   inline virtual void  SetTo(const TMatrixD &sv, const TVector3 &x0)
+   {
+      fDrho  = sv(0,0);
+      fPhi0  = sv(1,0);
+      fKappa = sv(2,0);
+      fDz    = sv(3,0);
+      fTanL  = sv(4,0);
+      fX0    = x0;
+   }
+
+   inline virtual void SetMagField(Double_t b)
+   {
+     // // units: mm, sec, Tesla
+     if (b != 0.) fAlpha = kGiga/kLightVelocity*1000./b;
+     // units: cm, sec, kGaus
+     //if (b != 0.) fAlpha = kGiga/kLightVelocity*100./(b/10);
+     else         fAlpha = kInfinity;
+   }
+	
+   inline virtual Bool_t IsInB() const { return fAlpha < kInfinity ? kTRUE : kFALSE; }
+
+protected:
+   Double_t fDrho;      // drho
+   Double_t fPhi0;      // phi0
+   Double_t fKappa;     // kappa
+   Double_t fDz;        // dz
+   Double_t fTanL;      // tanl
+   TVector3 fX0;        // pivot
+   Double_t fAlpha;     // alpha
+
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+   static const Double_t kLightVelocity = 2.99792458e8; //! light velocity [m/sec]
+   static const Double_t kGiga          = 1.0e9;        //! Giga = 10^{9}
+   static const Double_t kInfinity      = 1.e+20;       //! infinity
+#else
+   static const Double_t kLightVelocity;                //! light velocity [m/sec]
+   static const Double_t kGiga;                         //! Giga = 10^{9}
+   static const Double_t kInfinity;                     //! infinity
+#endif
+
+   ClassDef(TVTrack,1)      // Base class for any track
+};
+
+#endif
diff --git a/Utilities/KalTest/kaltest/TVTrackHit.h b/Utilities/KalTest/kaltest/TVTrackHit.h
new file mode 100644
index 0000000000000000000000000000000000000000..9559bb624fd9e23f31b7a39c5e9ea3afbd61bf64
--- /dev/null
+++ b/Utilities/KalTest/kaltest/TVTrackHit.h
@@ -0,0 +1,55 @@
+#ifndef TVTRACKHIT_H
+#define TVTRACKHIT_H
+
+//*************************************************************************
+//* ====================
+//*  TVTrackHit Class
+//* ====================
+//*
+//* (Description)
+//*   Abstract base class to store single hit information.
+//* (Requires)
+//* (Provides)
+//*     class TVTrackHit
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2005/08/11  K.Fujii           Removed fXX and its getter and setter.
+//*
+//*************************************************************************
+
+#include "TVector3.h"      // from ROOT
+#include "TKalMatrix.h"    // from KalLib
+#include "KalTrackDim.h"   // from KalTrackLib
+#include "TVMeasLayer.h"   // from KalTrackLib
+
+class TVTrackHit : public TKalMatrix {
+public:
+   TVTrackHit(Int_t m = kMdim);
+
+   TVTrackHit(const TVMeasLayer &ms, Double_t *x, Double_t *dx, 
+              Double_t b = 30., Int_t m = kMdim);
+   TVTrackHit(const TVTrackHit &hit);
+
+   virtual ~TVTrackHit();
+
+   inline virtual Double_t GetX (Int_t i) const { return (*this)(i,0);      }
+   inline virtual Double_t GetDX(Int_t i) const { return (*this)(i,1);      }
+   inline virtual Int_t    GetDimension() const { return fDim;              }
+   inline virtual Double_t GetBfield()    const { return fBfield;           }
+
+   inline virtual const TVMeasLayer & GetMeasLayer() const 
+                                                { return *fMeasLayerPtr;    }
+
+   virtual TKalMatrix XvToMv  (const TVector3 &xv, Double_t t0)  const = 0;
+
+  //   virtual void       DebugPrint(Option_t *opt = "")        const = 0;
+
+private:
+   Int_t         fDim;            // dimension of coordinate space
+   Double_t      fBfield;         // B field
+   TVMeasLayer  *fMeasLayerPtr;   // pointer to measurement layer
+
+   ClassDef(TVTrackHit,1)      // Sample hit class
+};
+
+#endif
diff --git a/Utilities/KalTest/src/CMakeLists.txt.remove b/Utilities/KalTest/src/CMakeLists.txt.remove
new file mode 100644
index 0000000000000000000000000000000000000000..e56e882093ee6f8d8a681f9080d3b43fd118a527
--- /dev/null
+++ b/Utilities/KalTest/src/CMakeLists.txt.remove
@@ -0,0 +1,42 @@
+# build KalTest library
+
+SET( lib_input_dirs geomlib kallib kaltracklib utils )
+
+FOREACH( lib_input_dir ${lib_input_dirs} )
+    LIST( APPEND ROOT_DICT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${lib_input_dir} )
+ENDFOREACH()
+
+#MESSAGE( STATUS "ROOT_DICT_INCLUDE_DIRS: ${ROOT_DICT_INCLUDE_DIRS}" )
+
+FOREACH( lib_input_dir ${lib_input_dirs} )
+
+    AUX_SOURCE_DIRECTORY( ${lib_input_dir} lib_sources )
+
+    PREPARE_ROOT_DICT_HEADERS( ${lib_input_dir} )
+
+    INSTALL_DIRECTORY( ${lib_input_dir}/ DESTINATION "include/kaltest"
+        FILES_MATCHING PATTERN "*.h" PATTERN "LinkDef.h" EXCLUDE
+    )
+
+    GEN_ROOT_DICT_SOURCES( ${lib_input_dir}Dict.cxx )
+    
+    LIST( APPEND lib_sources ${ROOT_DICT_OUTPUT_SOURCES} )
+
+ENDFOREACH()
+
+INCLUDE_DIRECTORIES( ${ROOT_DICT_INCLUDE_DIRS} )
+INCLUDE_DIRECTORIES( ${ROOT_INCLUDE_DIRS} )
+
+#MESSAGE( STATUS "KalTest lib sources: ${lib_sources}" )
+
+ADD_SHARED_LIBRARY( KalTest ${lib_sources} )
+INSTALL_SHARED_LIBRARY( KalTest DESTINATION lib )
+TARGET_LINK_LIBRARIES( KalTest ${ROOT_LIBRARIES} )
+
+IF( APPLE ) #---- need special linker flags for ROOT dictionary on MacOS
+    SET_TARGET_PROPERTIES( KalTest PROPERTIES
+        LINK_FLAGS "-single_module -undefined dynamic_lookup -bind_at_load"
+    )
+ENDIF( APPLE )
+
+
diff --git a/Utilities/KalTest/src/geomlib/Imakefile b/Utilities/KalTest/src/geomlib/Imakefile
new file mode 100644
index 0000000000000000000000000000000000000000..8f0b2c6ee5f3b5fc655e6a2f47a2ab57499f1a48
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/Imakefile
@@ -0,0 +1,62 @@
+#include "../../conf/makejsf.tmpl"
+
+LDFLAGS   = /* $(GLIBS) */
+
+INSTALLDIR    = ../..
+SOREV         = 2005.01
+PACKAGENAME   = S4Geom
+
+SRCS          = THelicalTrack.$(SrcSuf)  \
+		TCircle.$(SrcSuf) \
+		TVCutCone.$(SrcSuf) \
+		TVCurve.$(SrcSuf) \
+		TCylinder.$(SrcSuf) \
+                TPlane.$(SrcSuf) \
+		THype.$(SrcSuf) \
+		TStraightTrack.$(SrcSuf) \
+		TTube.$(SrcSuf) \
+		TVSolid.$(SrcSuf) \
+		TVSurface.$(SrcSuf) \
+		TVTrack.$(SrcSuf)
+
+OBJS	      =	$(subst .$(SrcSuf),.$(ObjSuf),$(SRCS)) \
+		$(PACKAGENAME)Dict.$(ObjSuf)
+
+HDRS	      = $(subst .$(SrcSuf),.h,$(SRCS))
+
+DICTNAME      = $(PACKAGENAME)Dict
+
+LIBNAME       = $(PACKAGENAME)
+
+SONAME        = lib$(LIBNAME).$(DllSuf).$(SOREV)
+
+LIBINSTALLDIR = $(INSTALLDIR)/lib
+INCINSTALLDIR = $(INSTALLDIR)/include
+INCPATH	      = -I. -I$(INCINSTALLDIR)
+CXXFLAGS     += $(INCPATH) -O0 -g 
+SHLIBLDFLAGS  = $(DYLIBFLAGS)
+
+all:: $(SONAME)
+
+SharedLibraryTarget($(LIBNAME),$(SOREV),$(OBJS),.,.)
+
+InstallSharedLibrary($(LIBNAME),$(SOREV),$(LIBINSTALLDIR))
+
+InstallMultipleFlags($(HDRS),$(INCINSTALLDIR),-m 644)
+
+clean:: 
+	@rm -f $(OBJS) core *.$(DllSuf) $(DICTNAME).$(SrcSuf) $(DICTNAME).h
+
+depend:: $(SRCS) $(HDRS)
+	for i in $(SRCS); do \
+	rmkdepend -a -- $(CXXFLAGS) $(INCPATH) $(DEPENDFILES) -- $$i; done
+
+distclean:: clean
+	@rm -f $(OBJS) core *.$(DllSuf) *.$(DylibSuf)
+	@rm -f $(DICTNAME).$(SrcSuf) $(DICTNAME).h *~
+	@rm -f $(SONAME) *.root Makefile
+
+$(DICTNAME).$(SrcSuf): $(HDRS) LinkDef.h
+	@echo "Generating dictionary ..."
+	rootcint -f $(DICTNAME).$(SrcSuf) \
+ 		-c -I$(INCINSTALLDIR) $(HDRS) LinkDef.h
diff --git a/Utilities/KalTest/src/geomlib/LinkDef.h b/Utilities/KalTest/src/geomlib/LinkDef.h
new file mode 100644
index 0000000000000000000000000000000000000000..76322c6ce358eed5a308e3b60a3eb22e6ece95b0
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/LinkDef.h
@@ -0,0 +1,20 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class TCircle+;
+#pragma link C++ class TCutCone+;
+#pragma link C++ class TCylinder+;
+#pragma link C++ class TPlane+;
+#pragma link C++ class THype+;
+#pragma link C++ class TTube+;
+#pragma link C++ class THelicalTrack+;
+#pragma link C++ class TStraightTrack+;
+#pragma link C++ class TVCurve+;
+#pragma link C++ class TVSolid+;
+#pragma link C++ class TVSurface+;
+#pragma link C++ class TVTrack+;
+
+#endif
diff --git a/Utilities/KalTest/src/geomlib/TCircle.cxx b/Utilities/KalTest/src/geomlib/TCircle.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..eca9a6d803adc90ec96e8d2b766b62cb57cc4454
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TCircle.cxx
@@ -0,0 +1,67 @@
+//*************************************************************************
+//* ====================
+//*  TCircle Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a circle object.
+//* (Requires)
+//*     TVCurve
+//* (Provides)
+//*     class TCircle
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include "TCircle.h"
+#if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
+#include "TMath.h"
+#endif
+//_____________________________________________________________________
+//  -----------------------------------
+//  Circle Class
+//  -----------------------------------
+
+ClassImp(TCircle)
+
+TCircle::TCircle(Double_t r, Double_t xc, Double_t yc)
+       : fR(r), fXc(xc,yc)
+{
+}
+
+Int_t TCircle::CalcXingPointWith(const TCircle  &c,
+                                       TVector2  xx[],
+                                       Double_t  eps) const
+{
+   TVector2 x12   = c.fXc - fXc;
+   Double_t a     = x12.Mod2();
+   Double_t sqa   = TMath::Sqrt(a);
+   Double_t radd  = fR + c.fR;
+   Double_t rsub  = fR - c.fR;
+   Double_t arsub = TMath::Abs(rsub);
+   if (sqa > radd+eps || sqa <= eps || sqa < arsub-eps) {
+      // no intersection
+      return 0;
+   } else if (sqa > radd-eps) {
+      // single intersection
+      xx[0] = fXc + (fR/sqa)*x12;
+      return 1;
+   } else {
+      // two intersection
+      Double_t d = radd*rsub + a;
+      a   = 1./sqa;
+      d  *= 0.5*a;
+      Double_t dp  = (fR+d)*(fR-d);
+      if (dp <= 0.) dp = 0.;
+      else          dp = TMath::Sqrt(dp)*a;
+      d  *= a;
+      TVector2 d1 = fXc + d*x12;
+      TVector2 d2(dp*x12.Y(), -dp*x12.X());
+      xx[0] = d1 + d2;
+      xx[1] = d1 - d2;
+
+      return 2;
+   }
+}
+
diff --git a/Utilities/KalTest/src/geomlib/TCircle.h b/Utilities/KalTest/src/geomlib/TCircle.h
new file mode 100644
index 0000000000000000000000000000000000000000..2bb548aa72649420ccfd7d22f1778816b76abb63
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TCircle.h
@@ -0,0 +1,56 @@
+#ifndef TCIRCLE_H
+#define TCIRCLE_H
+//*************************************************************************
+//* ====================
+//*  TCircle Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a circle object.
+//* (Requires)
+//*     TVCurve
+//* (Provides)
+//*     class TCircle
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include <iostream>
+#include "TVector2.h"
+#include "TVCurve.h"
+
+using namespace std;
+//_____________________________________________________________________
+//  -----------------------------------
+//  Circle Class
+//  -----------------------------------
+
+class TCircle : public TVCurve {
+public:
+   TCircle(Double_t r = 1., Double_t xc = 0., Double_t yc = 0.);
+   virtual ~TCircle() {}
+
+   virtual Int_t   CalcXingPointWith(const TCircle  &c,
+                                           TVector2  xx[],
+                                           Double_t  eps = 1.e-8) const;
+
+   inline virtual       Double_t   GetRadius() const { return fR;  }
+   inline virtual const TVector2 & GetCenter() const { return fXc; }
+
+   inline virtual       void       DebugPrint() const;
+
+private:
+   Double_t fR;         // radius
+   TVector2 fXc;        // center
+ 
+   ClassDef(TCircle,1)      // circle class
+};
+
+void TCircle::DebugPrint() const
+{
+   cerr << " radius = " << fR
+        << " center = (" << fXc.X() << "," << fXc.Y() << ")" << endl;
+}
+
+#endif
diff --git a/Utilities/KalTest/src/geomlib/TCutCone.cxx b/Utilities/KalTest/src/geomlib/TCutCone.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..642b42c401c00616fecee8b354cc4995a98d2b52
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TCutCone.cxx
@@ -0,0 +1,66 @@
+//*************************************************************************
+//* ====================
+//*  TCutCone Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a hyperboloidal surface object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class TCutCone
+//* (Update Recored)
+//*   2012/01/19  K.Fujii       Original version derived from THYpe.
+//*                             This class is implemented as an extreme
+//*                             (fR0=0) case of THype, thereby containing
+//*                             both -ve and +ve sides. If you want to
+//*                             restrict them to one side, override
+//*                             IsOnSurface(), etc.
+//*************************************************************************
+//
+#include <iostream>
+#include "TCircle.h"
+#include "TCutCone.h"
+#include "TVTrack.h"
+
+using namespace std;
+
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+#else
+const Double_t TCutCone::kTol = 1.e-5; // tolerance
+#endif
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  TCutCone Class
+//  -----------------------------------
+
+ClassImp(TCutCone)
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate S
+//  -----------------------------------
+//
+Double_t TCutCone::CalcS(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   Double_t r   = xxc.Perp();
+   Double_t s   = (r - xxc.Z()*fTanA) * (r + xxc.Z()* fTanA);
+   return s;
+}
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate (@S/@x)
+//  -----------------------------------
+//
+TMatrixD TCutCone::CalcDSDx(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   TMatrixD dsdx(1,3);
+   dsdx(0,0) =  2.* xxc.X();
+   dsdx(0,1) =  2.* xxc.Y();
+   dsdx(0,2) = -2.* xxc.Z() * fTanA * fTanA;
+   return dsdx;
+}
diff --git a/Utilities/KalTest/src/geomlib/TCutCone.h b/Utilities/KalTest/src/geomlib/TCutCone.h
new file mode 100644
index 0000000000000000000000000000000000000000..b66cfef1f8e73f51c5fea356c75ea3fa053da57c
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TCutCone.h
@@ -0,0 +1,122 @@
+#ifndef TCUTCONE_H
+#define TCUTCONE_H
+//*************************************************************************
+//* ====================
+//*  TCutCone Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a conical surface object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class TCutCone
+//* (Update Recored)
+//*   2012/01/19  K.Fujii       Original version derived from THYpe.
+//*                             This class is implemented as an extreme
+//*                             (fR0=0) case of THype, thereby containing
+//*                             both -ve and +ve sides. If you want to
+//*                             restrict them to one side, override
+//*                             IsOnSurface(), etc.
+//*************************************************************************
+//
+#include "TVSurface.h"
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Hype Class
+//  -----------------------------------
+
+class TCutCone : public TVSurface {
+public:
+   TCutCone(Double_t z1 = 0.5,
+            Double_t hlen = 1.0,
+            Double_t tana = 0.1,
+            Double_t xc = 0., 
+            Double_t yc = 0, 
+            Double_t zc = 0.)
+      : fZ1(z1), 
+        fHalfLen(hlen), 
+        fXc(xc,yc,zc), 
+        fTanA(tana)
+   {
+   }
+
+   virtual ~TCutCone() {}
+
+   virtual Double_t CalcS   (const TVector3 &xx) const;
+   virtual TMatrixD CalcDSDx(const TVector3 &xx) const;
+
+   inline virtual       Bool_t     IsOnSurface(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside  (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetSortingPolicy()              const;
+
+   inline virtual       Double_t   GetZ1     () const { return fZ1;   } 
+   inline virtual const TVector3 & GetXc     () const { return fXc;   } 
+   inline virtual       Double_t   GetTanA   () const { return fTanA; }
+   inline virtual       Double_t   GetLength () const;
+   inline virtual       Double_t   GetZmin   () const;
+   inline virtual       Double_t   GetZmax   () const;
+
+private:
+   Double_t fZ1;          // z position of the front face
+   Double_t fHalfLen;     // half length (cone length from the apex)
+   TVector3 fXc;          // center
+   Double_t fTanA;        // tan(half cone angle)
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+   static const Double_t kTol = 1.e-5; // tolerance
+#else
+   static const Double_t kTol; // tolerance
+#endif
+ 
+   ClassDef(TCutCone,1)      // hype class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+Double_t TCutCone::GetLength () const 
+{ 
+   return 2*fHalfLen;
+} 
+
+Double_t TCutCone::GetZmin() const
+{
+   return TMath::Min(fXc.Z() - fHalfLen, fXc.Z() + fHalfLen);
+}
+
+Double_t TCutCone::GetZmax() const
+{
+   return TMath::Max(fXc.Z() - fHalfLen, fXc.Z() + fHalfLen);
+}
+
+Bool_t TCutCone::IsOnSurface(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   Double_t r   = xxc.Perp();
+   Double_t z   = xxc.Z();
+   Double_t s   = r*r - fTanA*fTanA*z*z;
+   
+   return (TMath::Abs(s) < kTol && xx.Z() >= GetZmin() && xx.Z() <= GetZmax());
+} 
+
+Bool_t TCutCone::IsOutside(const TVector3 &xx) const
+{
+   Double_t r  = (xx-fXc).Perp();
+   Double_t z  = xx.Z();
+   Double_t R2 =fTanA*fTanA*z*z;
+   
+   return (r*r > R2 || z < GetZmin() || z > GetZmax());
+} 
+
+Double_t TCutCone::GetSortingPolicy() const
+{
+   return GetZ1()*GetTanA();
+}
+#endif
+
diff --git a/Utilities/KalTest/src/geomlib/TCylinder.cxx b/Utilities/KalTest/src/geomlib/TCylinder.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..a2c8a2f8b2bb59190aff6ec0f000f93dadb36dcb
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TCylinder.cxx
@@ -0,0 +1,148 @@
+//*************************************************************************
+//* ====================
+//*  TCylinder Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a cylinder object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class TCylinder
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.  Currently fXc is 
+//*                             supposed to be at the origin
+//*   2009/05/30  K.Fujii       Now allow nonzero fXc.
+//*
+//*************************************************************************
+//
+#include <iostream>
+#include "TCircle.h"
+#include "TCylinder.h"
+#include "TVTrack.h"
+
+using namespace std;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Cylinder Class
+//  -----------------------------------
+
+ClassImp(TCylinder)
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate S
+//  -----------------------------------
+//
+Double_t TCylinder::CalcS(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   Double_t s   = xxc.X() * xxc.X() + xxc.Y() * xxc.Y() - fR * fR;
+   return s;
+}
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate (@S/@x)
+//  -----------------------------------
+//
+TMatrixD TCylinder::CalcDSDx(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   TMatrixD dsdx(1,3);
+   dsdx(0,0) = 2.*xxc.X();
+   dsdx(0,1) = 2.*xxc.Y();
+   dsdx(0,2) = 0.;
+   return dsdx;
+}
+
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate crossing point with track
+//  -----------------------------------
+//
+Int_t TCylinder::CalcXingPointWith(const TVTrack  &hel,
+                                         TVector3 &xx,
+                                         Double_t &phi,
+                                         Int_t     mode,
+                                         Double_t  eps) const
+{
+   // This assumes nonzero B field.
+   //
+   // Copy helix parameters to local variables.
+   //
+                                                                                
+   Double_t dr  = hel.GetDrho();
+   Double_t fi0 = hel.GetPhi0();
+   Double_t cpa = hel.GetKappa();
+   Double_t dz  = hel.GetDz();
+   Double_t tnl = hel.GetTanLambda();
+   TVector3 X0  = hel.GetPivot();
+                                                                                
+   //
+   // Check if charge is nonzero.
+   //
+                                                                                
+   Int_t    chg = (Int_t)TMath::Sign(1.1,cpa);
+   if (!chg) {
+      cerr << ">>>> Error >>>> TCylinder::CalcXingPointWith" << endl
+           << "      Kappa = 0 is invalid for a helix "          << endl;
+      return -1;
+   }
+                                                                                
+   //
+   // Project everything to XY plane and calculate crossing points.
+   //
+                                                                                
+   Double_t rho  = hel.GetRho();
+   Double_t rdr  = rho + dr;
+   Double_t zdz  = X0.Z() + dz;
+   Double_t csf0 = TMath::Cos(fi0);
+   Double_t snf0 = TMath::Sin(fi0);
+   Double_t xc  = X0.X() + rdr*csf0;
+   Double_t yc  = X0.Y() + rdr*snf0;
+   Double_t zc  = zdz;
+                                                                                
+   Double_t r   = TMath::Abs(rho);
+   TCircle  c(r,xc,yc);
+                                                                                
+   Double_t rv  = GetR();
+   Double_t xcv = GetXc().X();
+   Double_t ycv = GetXc().Y();
+   TCircle  cv(rv,xcv,ycv);
+                                                                                
+   TVector2 xxp[2];
+   Int_t nx = c.CalcXingPointWith(cv, xxp);
+   if (nx != 2) return 0;
+                                                                                
+   //
+   // Crossing detected.
+   //
+                                                                                
+   static const Double_t kPi     = TMath::Pi();
+   static const Double_t kHalfPi = 0.5*TMath::Pi();
+   static const Double_t kTwoPi  = 2.0*TMath::Pi();
+                                                                                
+   phi = 9999.;
+   for (Int_t ix=0; ix<nx; ix++) {
+      Double_t x   = xxp[ix].X() - xc;
+      Double_t y   = xxp[ix].Y() - yc;
+      Double_t dfi = TMath::ATan2(y,x) - fi0 - kHalfPi*(1+chg);
+      if (!mode) {
+         while (dfi < -kPi) dfi += kTwoPi;
+         while (dfi >= kPi) dfi -= kTwoPi;
+      } else {
+         Int_t sign = (mode > 0 ? +1 : -1); // (+1,-1) = (fwd,bwd)
+         while (dfi <  0.)     dfi += kTwoPi;
+         while (dfi >= kTwoPi) dfi -= kTwoPi;
+         if (sign*chg > 0) dfi -= kTwoPi;
+      }
+      if (TMath::Abs(dfi) < TMath::Abs(phi)) {
+         phi = dfi;
+         xx.SetXYZ(xxp[ix].X(), xxp[ix].Y(), zc - rho*tnl*phi);
+      }
+   }
+   return (IsOnSurface(xx) ? 1 : 0);
+}
diff --git a/Utilities/KalTest/src/geomlib/TCylinder.h b/Utilities/KalTest/src/geomlib/TCylinder.h
new file mode 100644
index 0000000000000000000000000000000000000000..793da6310ca0395efaf3341233d767eb94776d7f
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TCylinder.h
@@ -0,0 +1,104 @@
+#ifndef TCYLINDER_H
+#define TCYLINDER_H
+//*************************************************************************
+//* ====================
+//*  TCylinder Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a cylinder object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class TCylinder
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*   2005/02/23  K.Fujii       Added GetSortingPolicy().
+//*
+//*************************************************************************
+//
+#include "TVSurface.h"
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+#include <cmath>
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Cylinder Class
+//  -----------------------------------
+
+class TCylinder : public TVSurface {
+public:
+   TCylinder(Double_t r = 1., Double_t hlen  = 1., 
+             Double_t xc = 0., Double_t yc = 0, Double_t zc = 0.)
+           : fR(r), fHalfLen(hlen), fXc(xc,yc,zc) {}
+
+   virtual ~TCylinder() {}
+
+   virtual Int_t CalcXingPointWith(const TVTrack  &hel,
+                                         TVector3 &xx,
+                                         Double_t &phi,
+                                         Int_t     mode,
+                                         Double_t  eps  = 1.e-8) const;
+
+   virtual Double_t CalcS   (const TVector3 &xx) const;
+   virtual TMatrixD CalcDSDx(const TVector3 &xx) const;
+
+   inline virtual       Bool_t     IsOnSurface(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside  (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetSortingPolicy()              const;
+
+   inline virtual       Double_t   GetR      () const { return fR;    } 
+   inline virtual const TVector3 & GetXc     () const { return fXc;   } 
+   inline virtual       Double_t   GetLength () const;
+   inline virtual       Double_t   GetZmin   () const;
+   inline virtual       Double_t   GetZmax   () const;
+
+private:
+   Double_t fR;           // radius
+   Double_t fHalfLen;     // half length
+   TVector3 fXc;          // center
+ 
+   ClassDef(TCylinder,1)      // cylinder class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+Double_t TCylinder::GetLength () const 
+{ 
+   return 2*fHalfLen;
+} 
+
+Double_t TCylinder::GetZmin() const
+{
+   return fXc.Z() - fHalfLen;
+}
+
+Double_t TCylinder::GetZmax() const
+{
+   return fXc.Z() + fHalfLen;
+}
+
+Bool_t TCylinder::IsOnSurface(const TVector3 &xx) const
+{
+   return (xx.Z() >= GetZmin() && xx.Z() <= GetZmax()) && std::fabs( (xx-fXc).Perp() - fR ) < 1.e-6;
+} 
+
+Bool_t TCylinder::IsOutside(const TVector3 &xx) const
+{
+   Double_t r = (xx-fXc).Perp();
+   Double_t z = xx.Z();
+   return (r > fR || z < GetZmin() || z > GetZmax());
+} 
+
+Double_t TCylinder::GetSortingPolicy() const
+{
+   return GetR();
+}
+#endif
+
diff --git a/Utilities/KalTest/src/geomlib/THelicalTrack.cxx b/Utilities/KalTest/src/geomlib/THelicalTrack.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..71b2300ea48ef2426446c751c1bcefa8ec009115
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/THelicalTrack.cxx
@@ -0,0 +1,424 @@
+//*************************************************************************
+//* ====================
+//*  THelicalTrack Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a helical track object.
+//* (Requires)
+//*     TVTrack, TCylinder, TCircle, TVector3, TMatrixD
+//* (Provides)
+//*     class THelicalTrack
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+
+#include <iostream>
+#include "THelicalTrack.h"
+
+using namespace std;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Helical Track Class
+//  -----------------------------------
+//
+//_____________________________________________________________________
+//  --------------
+//  Ctors and Dtor
+//  --------------
+//
+
+THelicalTrack::THelicalTrack(Double_t dr,
+                             Double_t phi0,
+                             Double_t kappa,
+                             Double_t dz,
+                             Double_t tanl,
+                             Double_t x0,
+                             Double_t y0,
+                             Double_t z0,
+                             Double_t b)
+             : TVTrack(dr,phi0,kappa,dz,tanl, x0,y0,z0, b)
+{
+}
+
+THelicalTrack::THelicalTrack(const TMatrixD &a, const TVector3 &x0, Double_t b)
+             : TVTrack(a, x0, b)
+{
+}
+
+THelicalTrack::THelicalTrack(const TVector3 &x1, 
+                             const TVector3 &x2,
+                             const TVector3 &x3,
+                                   Double_t  b,
+                                   Bool_t    dir)
+{
+   SetMagField(b);
+   CalcStartHelix(x1,x2,x3,dir);
+}
+
+//_____________________________________________________________________
+//  ----------------
+//  Utility methods
+//  ----------------
+
+void THelicalTrack::MoveTo(const TVector3 &xv0to, // new pivoit
+                                 Double_t &fid,   // deflection angle
+                                 TMatrixD *FPtr,  // propagator matrix
+                                 TMatrixD *CPtr)  // covariance matrix
+{
+   // ---------------------------------------------------
+   // (0) Preparation
+   // ---------------------------------------------------
+   //   Define some numerical constants.
+   //
+
+   static const Double_t kPi    = TMath::Pi();
+   static const Double_t kTwoPi = 2.0*kPi;
+
+   //   Copy helix parmeters to local variables
+
+   Double_t dr    = fDrho;
+   Double_t fi0   = fPhi0;
+   while (fi0 < 0.)      fi0 += kTwoPi;
+   while (fi0 > kTwoPi)  fi0 -= kTwoPi;
+   Double_t cpa   = fKappa;
+   Double_t dz    = fDz;
+   Double_t tnl   = fTanL;
+
+   Double_t x0    = fX0.X();
+   Double_t y0    = fX0.Y();
+   Double_t z0    = fX0.Z();
+   Double_t xv    = xv0to.X();
+   Double_t yv    = xv0to.Y();
+   Double_t zv    = xv0to.Z();
+
+   // ---------------------------------------------------
+   // (1) Calculate a' = f_k-1(a_k-1)
+   // ---------------------------------------------------
+   //        a' = (dr', fi0', cpa', dz', tnl')
+   //        a  = (dr , fi0 , cpa , dz , tnl )
+   //
+
+   Double_t r     = fAlpha/cpa;
+   Double_t rdr   = r + dr;
+   Double_t csf0  = TMath::Cos(fi0);
+   Double_t snf0  = TMath::Sqrt(TMath::Max(0.0, (1.0-csf0)*(1.0+csf0)));
+   if (fi0 > kPi) snf0 = -snf0;
+
+   Double_t xc    = x0 + rdr*csf0;
+   Double_t yc    = y0 + rdr*snf0;
+   Double_t fi0p  = 0.;
+
+   if (cpa > 0.) fi0p = TMath::ATan2((yc-yv),(xc-xv));
+   if (cpa < 0.) fi0p = TMath::ATan2((yv-yc),(xv-xc));
+   while (fi0p < 0.)      fi0p += kTwoPi;
+   while (fi0p > kTwoPi)  fi0p -= kTwoPi;
+
+   Double_t csf   = TMath::Cos(fi0p);
+   Double_t snf   = TMath::Sqrt(TMath::Max(0.0, (1.0-csf)*(1.0+csf)));
+   if (fi0p > kPi) snf = -snf;
+
+   Double_t anrm  = 1.0/TMath::Sqrt(csf*csf+snf*snf);
+            csf  *= anrm;
+            snf  *= anrm;
+   Double_t csfd  = csf*csf0 + snf*snf0;
+   Double_t snfd  = snf*csf0 - csf*snf0;
+
+   fid   = fi0p - fi0;
+   while (fid < 0)      fid += kTwoPi;
+   while (fid > kTwoPi) fid -= kTwoPi;
+   if    (fid > kPi)    fid -= kTwoPi;
+
+   Double_t drp   = (xc-xv)*csf + (yc-yv)*snf - r;
+   Double_t dzp   = z0 - zv + dz - r*tnl*fid;
+  
+  
+#if 0 //======== this code should not be necessary with a bug fix in TKalDetCradle =====================
+
+  // make sure that the helix really moves to the closest point to the reference point
+  // use protective_counter to ensure we don't enter an infinate loop
+  
+  if (tnl > 1.0e-10) { // protect against unreasonably small values of tnl, as in the case special case of a circle this will lead to division by zero below 
+    
+    double phi_to_ref =  dzp/(-r*tnl);
+    int protective_counter = 0;
+    
+    while ((phi_to_ref < -kPi) && protective_counter < 1000 ) {
+      phi_to_ref += kTwoPi;
+      ++protective_counter;
+    }
+    
+    protective_counter = 0;
+    
+    while ((phi_to_ref >  kPi) && protective_counter < 1000 ) {
+      phi_to_ref -= kTwoPi;
+      ++protective_counter;
+    }
+    
+    double phi_correction = dzp/(-r*tnl) - phi_to_ref;
+    
+    dzp += phi_correction*r*tnl;
+
+  }
+  
+#endif // =============================================================================================
+
+
+   TMatrixD av(5,1);
+   av(0,0) = drp;
+   av(1,0) = fi0p;
+   av(2,0) = cpa;
+   av(3,0) = dzp;
+   av(4,0) = tnl;
+
+   THelicalTrack helto(av,xv0to);
+   helto.fAlpha = fAlpha;
+
+   if (!FPtr && !CPtr) {
+      *this = helto;
+      return;
+   }
+
+   TMatrixD Fdummy(5,5);
+   TMatrixD &F = FPtr ? *FPtr : Fdummy;
+
+   // ---------------------------------------------------
+   // (2) Calculate @a'/@a = @a'/a = F_k-1
+   // ---------------------------------------------------
+   //        a' = (dr', fi0', cpa', dz', tnl')
+   //        a  = (dr , fi0 , cpa , dz , tnl )
+   //
+
+   Double_t rdrpr = 1.0/(r+drp);
+   Double_t rcpar = r/cpa;
+
+   // @drho'/@a
+   F(0,0) = csfd;
+   F(0,1) = rdr*snfd;
+   F(0,2) = rcpar*(1.0-csfd);
+   F(0,3) = 0;
+   F(0,4) = 0;
+
+   // @phi0'/@a
+   F(1,0) = -rdrpr*snfd;
+   F(1,1) =  rdr*rdrpr*csfd;
+   F(1,2) =  rcpar*rdrpr*snfd;
+   F(1,3) =  0;
+   F(1,4) =  0;
+
+   // @kappa'/@a
+   F(2,0) = 0;
+   F(2,1) = 0;
+   F(2,2) = 1;
+   F(2,3) = 0;
+   F(2,4) = 0;
+
+   // @dz'/@a
+   F(3,0) =  r*rdrpr*tnl*snfd;
+   F(3,1) =  r*tnl*(1.0-rdr*rdrpr*csfd);
+   F(3,2) =  rcpar*tnl*(fid-r*rdrpr*snfd);
+   F(3,3) =  1;
+   F(3,4) = -r*fid;
+
+   // @tanl'/@a
+   F(4,0) = 0;
+   F(4,1) = 0;
+   F(4,2) = 0;
+   F(4,3) = 0;
+   F(4,4) = 1;
+
+   if (!CPtr) {
+      *this = helto;
+      return;
+   }
+
+   // ---------------------------------------------------
+   // (3) Calculate C' = C^k-1_k
+   // ---------------------------------------------------
+
+   TMatrixD &C  = *CPtr;
+   TMatrixD  Ft = TMatrixD(TMatrixD::kTransposed, F);
+   TMatrixD  Cp = F * C * Ft;
+   C = Cp;
+
+   *this = helto;
+}
+
+TVector3 THelicalTrack::CalcXAt(Double_t phi) const
+{
+   Double_t csf0 = TMath::Cos(fPhi0);
+   Double_t snf0 = TMath::Sin(fPhi0);
+   Double_t snfd = TMath::Sin(fPhi0 + phi);
+   Double_t csfd = TMath::Cos(fPhi0 + phi);
+   Double_t rho  = fAlpha/fKappa;
+
+   Double_t x    = fX0.X() + fDrho * csf0 + rho * (csf0 - csfd);
+   Double_t y    = fX0.Y() + fDrho * snf0 + rho * (snf0 - snfd);
+   Double_t z    = fX0.Z() + fDz          - rho * fTanL * phi;
+
+#if 0
+   std::cerr << "THelicalTrack::CalcXAt" << std::endl;
+   std::cerr << " phi0 = " << fPhi0 << std::endl;
+   std::cerr << " phi  = " << phi   << std::endl;
+   std::cerr << " Drho = " << fDrho << std::endl;
+   std::cerr << " rho  = " << rho   << std::endl;
+   std::cerr << " x0   = " << fX0.X()     << std::endl;
+   std::cerr << " y0   = " << fX0.Y()     << std::endl;
+   std::cerr << " z0   = " << fX0.Z()     << std::endl;
+   std::cerr << " x    = " << x     << std::endl;
+   std::cerr << " y    = " << y     << std::endl;
+   std::cerr << " z    = " << z     << std::endl;
+#endif
+
+   return TVector3(x,y,z);
+}
+
+TMatrixD THelicalTrack::CalcDxDa(Double_t phi) const
+{
+   Double_t fi0   = fPhi0;
+   Double_t r     = fAlpha/fKappa;
+   Double_t rcpar = r/fKappa;
+
+   Double_t snf0 = TMath::Sin(fi0);
+   Double_t csf0 = TMath::Cos(fi0);
+   Double_t snfd = TMath::Sin(fi0 + phi);
+   Double_t csfd = TMath::Cos(fi0 + phi);
+
+   TMatrixD dxda(3,5);
+   // @x/@a
+   dxda(0,0) =  csf0;
+   dxda(0,1) = -fDrho * snf0 - r * (snf0 - snfd);
+   dxda(0,2) = -rcpar * (csf0 - csfd);
+   dxda(0,3) =  0;
+   dxda(0,4) =  0;
+
+   // @y/@a
+   dxda(1,0) =  snf0;
+   dxda(1,1) =  fDrho * csf0 + r *(csf0 - csfd);
+   dxda(1,2) = -rcpar * (snf0 - snfd);
+   dxda(1,3) =  0;
+   dxda(1,4) =  0;
+
+   // @z/@a
+   dxda(2,0) = 0;
+   dxda(2,1) = 0;
+   dxda(2,2) = rcpar * phi * fTanL;
+   dxda(2,3) = 1;
+   dxda(2,4) = - r * phi;
+
+   return dxda;
+}
+
+TMatrixD THelicalTrack::CalcDxDphi(Double_t phi) const
+{
+   Double_t r    = fAlpha/fKappa;
+
+   Double_t snfd = TMath::Sin(fPhi0 + phi);
+   Double_t csfd = TMath::Cos(fPhi0 + phi);
+
+   TMatrixD dxdphi(3,1);
+   dxdphi(0,0) =  r * snfd;
+   dxdphi(1,0) = -r * csfd;
+   dxdphi(2,0) = -r * fTanL;
+
+   return dxdphi;
+}
+
+void THelicalTrack::CalcStartHelix(const TVector3 &x1,
+                                   const TVector3 &x2,
+                                   const TVector3 &x3,
+                                         Bool_t    dir)
+{
+   static const TVector3 ez(0., 0., 1.);
+   TVector3 x12 = x2 - x1;
+   TVector3 x13 = x3 - x1;
+   TVector3 x23 = x3 - x2;
+   x12.SetZ(0.);
+   x13.SetZ(0.);
+   x23.SetZ(0.);
+   Double_t x12mag = x12.Mag();
+   x12 = x12.Unit();
+   Double_t x13mag = x13.Mag();
+   x13 = x13.Unit();
+   Double_t x23mag = x23.Mag();
+   x23 = x23.Unit();
+
+   Double_t sinHalfPhi23 = x12.Cross(x13).Z();
+   Double_t cosHalfPhi23 = 0.5 * (x13mag/x12mag + (1. - x23mag/x12mag)*(x12mag + x23mag)/x13mag);
+   Double_t halfPhi23 = TMath::ATan2(sinHalfPhi23, cosHalfPhi23);
+
+   Double_t r  = -0.5 * x23mag / sinHalfPhi23;
+
+   TVector3 xc = 0.5 * (x2 + x3) + r * cosHalfPhi23 * x23.Cross(ez);
+
+   if (dir == kIterBackward) r = -r;
+   TMatrixD sv(5,1);
+   sv(0,0) = 0;
+   sv(1,0) = TMath::ATan2(r * (xc.Y() - x1.Y()), r * (xc.X() - x1.X()));
+   sv(2,0) = GetPtoR() / r;
+   sv(3,0) = 0;
+   sv(4,0) = (x2.Z() - x3.Z()) / (r * 2 * halfPhi23);
+
+   SetTo(sv, x1);
+}
+
+void THelicalTrack::CalcDapDa(Double_t  fid,
+                              Double_t  dr,
+                              Double_t  drp,
+                              TMatrixD &F) const
+{
+   // ---------------------------------------------------
+   // (2) Calculate @a'/@a = @a'/a = F_k-1
+   // ---------------------------------------------------
+   //        a' = (dr', fi0', cpa', dz', tnl')
+   //        a  = (dr , fi0 , cpa , dz , tnl )
+   //
+                                                                                
+   // @drho'/@a
+   Double_t cpa   = fKappa;
+   Double_t tnl   = fTanL;
+   Double_t csfd  = TMath::Cos(fid);
+   Double_t snfd  = TMath::Sin(fid);
+   Double_t r     = fAlpha / cpa;
+   Double_t rdr   = r + dr;
+   Double_t rcpar = r / cpa;
+   Double_t rdrpr = 1. / (r + drp);
+                                                                                
+   F(0,0) = csfd;
+   F(0,1) = rdr*snfd;
+   F(0,2) = rcpar*(1.-csfd);
+   F(0,3) = 0.;
+   F(0,4) = 0.;
+                                                                                
+   // @phi0'/@a
+   F(1,0) = -rdrpr*snfd;
+   F(1,1) =  rdr*rdrpr*csfd;
+   F(1,2) =  rcpar*rdrpr*snfd;
+   F(1,3) =  0.;
+   F(1,4) =  0.;
+                                                                                
+   // @kappa'/@a
+   F(2,0) = 0.;
+   F(2,1) = 0.;
+   F(2,2) = 1.;
+   F(2,3) = 0.;
+   F(2,4) = 0.;
+                                                                                
+   // @dz'/@a
+   F(3,0) =  r*rdrpr*tnl*snfd;
+   F(3,1) =  r*tnl*(1.-rdr*rdrpr*csfd);
+   F(3,2) =  rcpar*tnl*(fid-r*rdrpr*snfd);
+   F(3,3) =  1.;
+   F(3,4) = -r*fid;
+                                                                                
+   // @tanl'/@a
+   F(4,0) = 0.;
+   F(4,1) = 0.;
+   F(4,2) = 0.;
+   F(4,3) = 0.;
+   F(4,4) = 1.;
+}
+
diff --git a/Utilities/KalTest/src/geomlib/THelicalTrack.h b/Utilities/KalTest/src/geomlib/THelicalTrack.h
new file mode 100644
index 0000000000000000000000000000000000000000..26f9a2de53c05b66c3471d79262ff478358f4593
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/THelicalTrack.h
@@ -0,0 +1,86 @@
+#ifndef THELICALTRACK_H
+#define THELICALTRACK_H
+//*************************************************************************
+//* ====================
+//*  THelicalTrack Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a helical track object.
+//*
+//*   A helix is parametrized in the standard way:
+//*
+//*      x = x0 + drho * cos(phi0) + rho * (cos(phi0) - cos(phi0 + phi))
+//*      y = y0 + drho * sin(phi0) + rho * (sin(phi0) - cos(sin0 + phi))
+//*      z = z0 + dz               - rho * tan(lambda) * phi
+//*
+//*   with 
+//*
+//*      rho = alpha/kappa
+//*
+//* (Requires)
+//*     TVTrack, TCylinder, TCircle, TVector3, TMatrixD
+//* (Provides)
+//*     class THelicalTrack
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+
+#include "TVTrack.h"
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Helical Track Class
+//  -----------------------------------
+
+class THelicalTrack : public TVTrack {
+public:
+
+   // Ctors and Dtor
+
+   THelicalTrack(Double_t dr    = 0.,
+                 Double_t phi0  = 0.,
+                 Double_t kappa = 1.e-5,
+                 Double_t dz    = 0.,
+                 Double_t tanl  = 0.,
+                 Double_t x0    = 0.,
+                 Double_t y0    = 0.,
+                 Double_t z0    = 0.,
+                 Double_t b     = 30.);
+
+   THelicalTrack(const TMatrixD &a, const TVector3 &x0, Double_t b = 30.);
+   THelicalTrack(const TVector3 &x1, const TVector3 &x2, const TVector3 &x3,
+                 Double_t b = 30., Bool_t dir = kIterForward);
+
+   virtual ~THelicalTrack() {}
+
+   // Utility methods
+
+   virtual void MoveTo(const TVector3 &x0to,
+                             Double_t &fid,
+                             TMatrixD *F = 0,
+                             TMatrixD *C = 0);
+
+   TVector3 CalcXAt   (Double_t phi) const;
+   TMatrixD CalcDxDa  (Double_t phi) const;
+   TMatrixD CalcDxDphi(Double_t phi) const;
+   void     CalcDapDa (Double_t fid,
+                       Double_t dr,
+                       Double_t drp,
+                       TMatrixD &F)  const;
+
+private:
+   void CalcStartHelix(const TVector3 &x1,
+                       const TVector3 &x2,
+                       const TVector3 &x3,
+                             Bool_t    dir = kIterForward);
+
+private:
+
+   ClassDef(THelicalTrack,1)      // circle class
+};
+
+#endif
+
diff --git a/Utilities/KalTest/src/geomlib/THype.cxx b/Utilities/KalTest/src/geomlib/THype.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..49fe26c8279228fd9e83e9c5d4b800ba265cd377
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/THype.cxx
@@ -0,0 +1,62 @@
+//*************************************************************************
+//* ====================
+//*  THype Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a hyperboloidal surface object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class THype
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version. Currently fXc is
+//*                             supposed to be at the origin.
+//*************************************************************************
+//
+#include <iostream>
+#include "TCircle.h"
+#include "THype.h"
+#include "TVTrack.h"
+
+using namespace std;
+
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+#else
+const Double_t THype::kTol = 1.e-5; // tolerance
+#endif
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  THype Class
+//  -----------------------------------
+
+ClassImp(THype)
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate S
+//  -----------------------------------
+//
+Double_t THype::CalcS(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   Double_t s   = xxc.X() * xxc.X() + xxc.Y() * xxc.Y()
+                   - fR0 * fR0 - xxc.Z() * xxc.Z() * fTanA * fTanA;
+   return s;
+}
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate (@S/@x)
+//  -----------------------------------
+//
+TMatrixD THype::CalcDSDx(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   TMatrixD dsdx(1,3);
+   dsdx(0,0) =  2.* xxc.X();
+   dsdx(0,1) =  2.* xxc.Y();
+   dsdx(0,2) = -2.* xxc.Z() * fTanA * fTanA;
+   return dsdx;
+}
diff --git a/Utilities/KalTest/src/geomlib/THype.h b/Utilities/KalTest/src/geomlib/THype.h
new file mode 100644
index 0000000000000000000000000000000000000000..04e4765d06b864ab8b09baee20240e0124aedb08
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/THype.h
@@ -0,0 +1,110 @@
+#ifndef THYPE_H
+#define THYPE_H
+//*************************************************************************
+//* ====================
+//*  THype Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a hyperboloidal surface object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class THype
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*   2005/02/23  K.Fujii       Added GetSortingPolicy().
+//*
+//*************************************************************************
+//
+#include "TVSurface.h"
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Hype Class
+//  -----------------------------------
+
+class THype : public TVSurface {
+public:
+   THype(Double_t r = 1., Double_t hlen  = 1., Double_t tana = 0.,
+         Double_t xc = 0., Double_t yc = 0, Double_t zc = 0.)
+           : fR0(r), fHalfLen(hlen), fXc(xc,yc,zc), fTanA(tana) {}
+
+   virtual ~THype() {}
+
+   virtual Double_t CalcS   (const TVector3 &xx) const;
+   virtual TMatrixD CalcDSDx(const TVector3 &xx) const;
+
+   inline virtual       Bool_t     IsOnSurface(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside  (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetSortingPolicy()              const;
+
+   inline virtual       Double_t   GetR0     () const { return fR0;   } 
+   inline virtual const TVector3 & GetXc     () const { return fXc;   } 
+   inline virtual       Double_t   GetTanA   () const { return fTanA; }
+   inline virtual       Double_t   GetLength () const;
+   inline virtual       Double_t   GetZmin   () const;
+   inline virtual       Double_t   GetZmax   () const;
+
+private:
+   Double_t fR0;          // radius at z = 0.
+   Double_t fHalfLen;     // half length
+   TVector3 fXc;          // center
+   Double_t fTanA;        // tan(stereo angle)
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+   static const Double_t kTol = 1.e-5; // tolerance
+#else
+   static const Double_t kTol; // tolerance
+#endif
+ 
+   ClassDef(THype,1)      // hype class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+Double_t THype::GetLength () const 
+{ 
+   return 2*fHalfLen;
+} 
+
+Double_t THype::GetZmin() const
+{
+   return fXc.Z() - fHalfLen;
+}
+
+Double_t THype::GetZmax() const
+{
+   return fXc.Z() + fHalfLen;
+}
+
+Bool_t THype::IsOnSurface(const TVector3 &xx) const
+{
+   TVector3 xxc = xx - fXc;
+   Double_t r   = xxc.Perp();
+   Double_t z   = xxc.Z();
+   Double_t s   = r*r - fTanA*fTanA*z*z - fR0*fR0;
+   
+   return (TMath::Abs(s) < kTol && xx.Z() >= GetZmin() && xx.Z() <= GetZmax());
+} 
+
+Bool_t THype::IsOutside(const TVector3 &xx) const
+{
+   Double_t r  = (xx-fXc).Perp();
+   Double_t z  = xx.Z();
+   Double_t R2 = fR0*fR0 + fTanA*fTanA*z*z;
+   
+   return (r*r > R2 || z < GetZmin() || z > GetZmax());
+} 
+
+Double_t THype::GetSortingPolicy() const
+{
+   return GetR0();
+}
+#endif
+
diff --git a/Utilities/KalTest/src/geomlib/TPlane.cxx b/Utilities/KalTest/src/geomlib/TPlane.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..ca9a6fc3fe4b63f6769a2c865c17be8b40650bdb
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TPlane.cxx
@@ -0,0 +1,67 @@
+//*************************************************************************
+//* ====================
+//*  TPlane Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a plane object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class TPlane
+//* (Update Recored)
+//*   2004/10/30  A.Yamaguchi   Original version.  Currently fXc is 
+//*                             supposed to be at the origin
+//*
+//*************************************************************************
+//
+#include "TPlane.h"
+
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Plane Class
+//  -----------------------------------
+
+ClassImp(TPlane)
+
+TPlane::TPlane()
+      : fXc(), fNormal()
+{
+} 
+
+TPlane::TPlane(const TVector3 &xc)
+      : fXc(xc), fNormal(xc.Unit())
+{
+} 
+
+TPlane::TPlane(const TVector3 &xc, const TVector3 &n)
+      : fXc(xc), fNormal(n.Unit())
+{
+} 
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate S
+//  -----------------------------------
+//
+Double_t TPlane::CalcS(const TVector3 &xx) const
+{
+   return (xx - fXc) * fNormal;
+}
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate (@S/@x)
+//  -----------------------------------
+//
+TMatrixD TPlane::CalcDSDx(const TVector3 &xx) const
+{
+   TMatrixD dsdx(1,3);
+   dsdx(0,0) = fNormal.X(); 
+   dsdx(0,1) = fNormal.Y(); 
+   dsdx(0,2) = fNormal.Z();
+   return dsdx;
+}
+
+
diff --git a/Utilities/KalTest/src/geomlib/TPlane.h b/Utilities/KalTest/src/geomlib/TPlane.h
new file mode 100644
index 0000000000000000000000000000000000000000..a75d6737b3efa6406340b401beb9c126cce9db71
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TPlane.h
@@ -0,0 +1,80 @@
+#ifndef TPLANE_H
+#define TPLANE_H
+//*************************************************************************
+//* ====================
+//*  TPlane Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a flat plane object.
+//* (Requires)
+//*     TVSurface
+//* (Provides)
+//*     class TPlane
+//* (Update Recored)
+//*   2004/10/30  A.Yamaguchi       Original version.
+//*   2005/02/23  K.Fujii           Added GetSortingPolicy().
+//*
+//*************************************************************************
+//
+#include "TVSurface.h"
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Plane Class
+//  -----------------------------------
+
+class TPlane : public TVSurface {
+public:
+   TPlane();
+   TPlane(const TVector3 &xc);
+   TPlane(const TVector3 &xc, const TVector3 &n);
+
+   virtual ~TPlane() {}
+
+   virtual Double_t CalcS   (const TVector3 &xx) const;
+   virtual TMatrixD CalcDSDx(const TVector3 &xx) const;
+
+   inline virtual const TVector3 & GetXc     () const { return fXc;     } 
+   inline virtual const TVector3 & GetNormal () const { return fNormal; } 
+   inline virtual       Bool_t     IsOnSurface(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside  (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetSortingPolicy()              const;
+
+
+private:
+   TVector3 fXc;          // center
+   TVector3 fNormal;      // normal
+ 
+   ClassDef(TPlane,1)      // plane class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+
+Bool_t TPlane::IsOnSurface(const TVector3 &xx) const
+{
+#if 0
+   return (xx - fXc) * fNormal == 0. ? kTRUE : kFALSE; 
+#else
+   return kTRUE;
+#endif
+} 
+
+Bool_t TPlane::IsOutside(const TVector3 &xx) const
+{
+   return (xx - fXc) * fNormal > 0. ? kTRUE : kFALSE; 
+} 
+
+Double_t TPlane::GetSortingPolicy() const
+{
+   return TMath::Abs(fXc*fNormal.Unit());
+}
+#endif
+
diff --git a/Utilities/KalTest/src/geomlib/TStraightTrack.cxx b/Utilities/KalTest/src/geomlib/TStraightTrack.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..413e13925e6e07ceaf709afff6a16953f75e5a52
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TStraightTrack.cxx
@@ -0,0 +1,282 @@
+//*************************************************************************
+//* ======================
+//*  TStraightTrack Class
+//* ======================
+//*
+//* (Description)
+//*   A class to implement a straight track object.
+//* (Requires)
+//*     TVTrack, TCylinder, TCircle, TVector3, TMatrixD
+//* (Provides)
+//*     class TStraightTrack
+//* (Update Recored)
+//*   2003/10/24  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+
+#include <iostream>
+#include "TStraightTrack.h"
+
+using namespace std;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Straight Track Class
+//  -----------------------------------
+//
+//_____________________________________________________________________
+//  --------------
+//  Ctors and Dtor
+//  --------------
+//
+
+TStraightTrack::TStraightTrack(Double_t dr,
+                               Double_t phi0,
+                               Double_t kappa,
+                               Double_t dz,
+                               Double_t tanl,
+                               Double_t x0,
+                               Double_t y0,
+                               Double_t z0,
+                               Double_t b)
+             : TVTrack(dr,phi0,kappa,dz,tanl, x0,y0,z0, b)
+{
+}
+
+TStraightTrack::TStraightTrack(const TMatrixD &a,
+                               const TVector3 &x0,
+                                     Double_t  b)
+             : TVTrack(a, x0, b)
+{
+}
+
+//_____________________________________________________________________
+//  ----------------
+//  Utility methods
+//  ----------------
+
+void TStraightTrack::MoveTo(const TVector3 &xv0to,
+                                  Double_t &t,
+                                  TMatrixD *FPtr,
+                                  TMatrixD *CPtr)
+{
+   // ---------------------------------------------------
+   // (0) Preparation
+   // ---------------------------------------------------
+   //   Define some numerical constants.
+   //
+
+   static const Double_t kPi    = TMath::Pi();
+   static const Double_t kTwoPi = 2.0*kPi;
+
+   //   Copy helix parmeters to local variables
+
+   Double_t dr    = fDrho;
+   Double_t fi0   = fPhi0;
+   while (fi0 < 0.)      fi0 += kTwoPi;
+   while (fi0 > kTwoPi)  fi0 -= kTwoPi;
+   Double_t cpa   = fKappa;
+   Double_t dz    = fDz;
+   Double_t tnl   = fTanL;
+                                                                                
+   Double_t x0    = fX0.X();
+   Double_t y0    = fX0.Y();
+   Double_t z0    = fX0.Z();
+   Double_t xv    = xv0to.X();
+   Double_t yv    = xv0to.Y();
+   Double_t zv    = xv0to.Z();
+
+   // ---------------------------------------------------
+   // (1) Calculate a' = f_k-1(a_k-1)
+   // ---------------------------------------------------
+   //        a' = (dr', fi0', cpa', dz', tnl')
+   //        a  = (dr , fi0 , cpa , dz , tnl )
+   //
+
+   Double_t csf0  = TMath::Cos(fi0);
+   Double_t snf0  = TMath::Sqrt( TMath::Max(0.0, (1.0-csf0)*(1.0+csf0)) );
+   if (fi0 > kPi) snf0 = -snf0;
+
+            t     = -(xv - x0) * snf0 + (yv - y0) * csf0;
+
+   Double_t drp   = dr - (xv - x0) * csf0 - (yv - y0) * snf0;
+   Double_t dzp   = dz - (zv - z0) + t * tnl;
+
+   TMatrixD av(5,1);
+   av(0,0) = drp;
+   av(1,0) = fi0;
+   av(2,0) = cpa;
+   av(3,0) = dzp;
+   av(4,0) = tnl;
+
+   TStraightTrack helto(av,xv0to);
+   helto.fAlpha = fAlpha;
+   
+   if (!FPtr && !CPtr) {
+      *this = helto;
+      return;
+   }
+
+   TMatrixD Fdummy(5,5);
+   TMatrixD &F = FPtr ? *FPtr : Fdummy;
+
+   // ---------------------------------------------------
+   // (2) Calculate @a'/@a = @a'/a = F_k-1
+   // ---------------------------------------------------
+   //        a' = (dr', fi0', cpa', dz', tnl')
+   //        a  = (dr , fi0 , cpa , dz , tnl )
+   //
+
+   // @drho'/@a
+   F(0,0) =  1;
+   F(0,1) = -t;
+   F(0,2) =  0;
+   F(0,3) =  0;
+   F(0,4) =  0;
+                                                                                
+   // @phi0'/@a
+   F(1,0) =  0;
+   F(1,1) =  1;
+   F(1,2) =  0;
+   F(1,3) =  0;
+   F(1,4) =  0;
+                                                                                
+   // @kappa'/@a
+
+   F(2,0) =  0;
+   F(2,1) =  0;
+   F(2,2) =  1;
+   F(2,3) =  0;
+   F(2,4) =  0;
+   
+   // @dz'/@a
+   F(3,0) =  0;
+   F(3,1) =  (drp - dr)* tnl;
+   F(3,2) =  0;
+   F(3,3) =  1;
+   F(3,4) =  t;
+    
+   // @tanl'/@a
+   F(4,0) = 0;
+   F(4,1) = 0;
+   F(4,2) = 0;
+   F(4,3) = 0;
+   F(4,4) = 1;
+
+   if (!CPtr) {
+      *this = helto;
+      return;
+   }
+
+   // ---------------------------------------------------
+   // (3) Calculate C' = C^k-1_k
+   // ---------------------------------------------------
+
+   TMatrixD &C  = *CPtr;
+   TMatrixD  Ft = TMatrixD(TMatrixD::kTransposed, F);
+   TMatrixD  Cp = F * C * Ft;
+   C = Cp;
+
+   *this = helto;
+}
+
+TVector3 TStraightTrack::CalcXAt(Double_t t) const
+{
+   Double_t csf0 = TMath::Cos(fPhi0);
+   Double_t snf0 = TMath::Sin(fPhi0);
+
+   Double_t x    = fX0.X() + fDrho * csf0 - t * snf0;
+   Double_t y    = fX0.Y() + fDrho * snf0 + t * csf0;
+   Double_t z    = fX0.Z() + fDz          + t * fTanL;
+
+   return TVector3(x,y,z);
+}
+
+TMatrixD TStraightTrack::CalcDxDa(Double_t t) const
+{
+   Double_t fi0   = fPhi0;
+
+   Double_t snf0 = TMath::Sin(fi0);
+   Double_t csf0 = TMath::Cos(fi0);
+
+   TMatrixD dxda(3,5);
+   // @x/@a
+   dxda(0,0) =  csf0;
+   dxda(0,1) = - fDrho * snf0 - t * csf0;
+   dxda(0,2) = 0;
+   dxda(0,3) = 0;
+   dxda(0,4) = 0;
+
+   // @y/@a
+   dxda(1,0) = snf0;
+   dxda(1,1) = fDrho * csf0 - t * snf0;
+   dxda(1,2) = 0;
+   dxda(1,3) = 0;
+   dxda(1,4) = 0;
+
+   // @z/@a
+   dxda(2,0) = 0;
+   dxda(2,1) = 0;
+   dxda(2,2) = 0;
+   dxda(2,3) = 1;
+   dxda(2,4) = t;
+
+   return dxda;
+}
+
+TMatrixD TStraightTrack::CalcDxDphi(Double_t t) const
+{
+   Double_t snf0 = TMath::Sin(fPhi0);
+   Double_t csf0 = TMath::Cos(fPhi0);
+
+   TMatrixD dxdphi(3,1);
+   dxdphi(0,0) = -snf0;
+   dxdphi(1,0) =  csf0;
+   dxdphi(2,0) =  fTanL;
+
+   return dxdphi;
+}
+
+void TStraightTrack::CalcDapDa(Double_t fid,
+                               Double_t dr,
+                               Double_t drp,
+                               TMatrixD &F) const
+{
+   // @drho'/@a
+   F(0,0) =  1;
+   F(0,1) = -fid;
+   F(0,2) =  0;
+   F(0,3) =  0;
+   F(0,4) =  0;
+                                                                                
+   // @phi0'/@a
+   F(1,0) =  0;
+   F(1,1) =  1;
+   F(1,2) =  0;
+   F(1,3) =  0;
+   F(1,4) =  0;
+                                                                                
+   // @kappa'/@a
+                                                                                
+   F(2,0) =  0;
+   F(2,1) =  0;
+   F(2,2) =  1;
+   F(2,3) =  0;
+   F(2,4) =  0;
+                                                                                
+   // @dz'/@a
+   F(3,0) =  0;
+   F(3,1) =  (drp - dr)* fTanL;
+   F(3,2) =  0;
+   F(3,3) =  1;
+   F(3,4) =  fid;
+                                                                                
+   // @tanl'/@a
+   F(4,0) = 0;
+   F(4,1) = 0;
+   F(4,2) = 0;
+   F(4,3) = 0;
+   F(4,4) = 1;
+} 
+
diff --git a/Utilities/KalTest/src/geomlib/TStraightTrack.h b/Utilities/KalTest/src/geomlib/TStraightTrack.h
new file mode 100644
index 0000000000000000000000000000000000000000..d48c91e144dd923bd37a8fe20190237b46e924a0
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TStraightTrack.h
@@ -0,0 +1,75 @@
+#ifndef TSTRAIGHTTRACK_H
+#define TSTRAIGHTTRACK_H
+//*************************************************************************
+//* ======================
+//*  TStraightTrack Class
+//* ======================
+//*
+//* (Description)
+//*   A class to implement a straight track object.
+//*
+//*   The stragiht track is implemented as the kappa->infinity limit
+//*   of a helical track:
+//*
+//*      x = x0 + drho * cos(phi0) - t * sin(phi0)
+//*      y = y0 + drho * sin(phi0) + t * cos(phi0)
+//*      z = z0 + dz               + t * tan(lambda)
+//*
+//* (Requires)
+//*     TVTrack, TCylinder, TCircle, TVector3, TMatrixD
+//* (Provides)
+//*     class TStraightTrack
+//* (Update Recored)
+//*   2003/10/24  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+
+#include "TVTrack.h"
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Straight Track Class
+//  -----------------------------------
+
+class TStraightTrack : public TVTrack {
+public:
+
+   // Ctors and Dtor
+
+   TStraightTrack(Double_t dr    = 0.,
+                  Double_t phi0  = 0.,
+                  Double_t kappa = 1.e-5,
+                  Double_t dz    = 0.,
+                  Double_t tanl  = 0.,
+                  Double_t x0    = 0.,
+                  Double_t y0    = 0.,
+                  Double_t z0    = 0.,
+                  Double_t b     = 0.);
+
+   TStraightTrack(const TMatrixD &a, const TVector3 & x0, Double_t b = 0.);
+
+   virtual ~TStraightTrack() {}
+
+   // Utility methods
+
+   virtual void MoveTo(const TVector3 &x0to,
+                             Double_t &t,
+                             TMatrixD *F = 0,
+                             TMatrixD *C = 0);
+
+   TVector3 CalcXAt   (Double_t phi) const;
+   TMatrixD CalcDxDa  (Double_t phi) const;
+   TMatrixD CalcDxDphi(Double_t phi) const;
+   void     CalcDapDa (Double_t fid,
+                       Double_t dr,
+                       Double_t drp,
+                       TMatrixD &F)  const;
+
+private:
+
+   ClassDef(TStraightTrack,1)      // circle class
+};
+
+#endif
+
diff --git a/Utilities/KalTest/src/geomlib/TTube.cxx b/Utilities/KalTest/src/geomlib/TTube.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..307ebb1e1bde0910e2abba5c5244fafb0585b09e
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TTube.cxx
@@ -0,0 +1,141 @@
+//*************************************************************************
+//* ====================
+//*  TTube Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a tube object.
+//* (Requires)
+//*     TVSolid
+//* (Provides)
+//*     class TTube
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include <iostream>
+#include "TCircle.h"
+#include "TTube.h"
+#include "TVTrack.h"
+
+using namespace std;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Tube Class
+//  -----------------------------------
+
+ClassImp(TTube)
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate crossing point with helix
+//  -----------------------------------
+//
+Int_t TTube::CalcXingPointWith(const TVTrack  &hel,
+                                     Double_t &phi,
+                                     TVector3 &xx,
+                                     Int_t     mode,
+                                     Double_t  eps) const
+{
+   // This assumes nonzero B field.
+   //
+   // Copy helix parameters to local variables.
+   //
+
+   Double_t dr  = hel.GetDrho();
+   Double_t fi0 = hel.GetPhi0();
+   Double_t cpa = hel.GetKappa();
+   Double_t dz  = hel.GetDz();
+   Double_t tnl = hel.GetTanLambda();
+   TVector3 X0  = hel.GetPivot();
+
+   //
+   // Check if charge is nonzero.
+   //
+                                                                                
+   Int_t    chg = (Int_t)TMath::Sign(1.1,cpa);
+   if (!chg) {
+      cerr << ">>>> Error >>>> TTube::CalcXingPointWith" << endl
+           << "      Kappa = 0 is invalid for a helix "          << endl;
+      return -1;
+   }
+                                                                                
+   //
+   // Project everything to XY plane and calculate crossing points.
+   //
+                                                                                
+   Double_t rho  = hel.GetRho();
+   Double_t rdr  = rho + dr;
+   Double_t zdz  = X0.Z() + dz;
+   Double_t csf0 = TMath::Cos(fi0);
+   Double_t snf0 = TMath::Sin(fi0);
+   Double_t xc  = X0.X() + rdr*csf0;
+   Double_t yc  = X0.Y() + rdr*snf0;
+   Double_t zc  = zdz;
+                                                                                
+   Double_t r   = TMath::Abs(rho);
+   TCircle  c(r,xc,yc);
+                                                                                
+   Double_t rv  = GetRout();
+   Double_t xcv = GetXc().X();
+   Double_t ycv = GetXc().Y();
+   TCircle  cv(rv,xcv,ycv);
+                                                                                
+   TVector2 xxp[2];
+   Int_t nx = c.CalcXingPointWith(cv, xxp);
+                                                                                
+   //
+   // Switch on the number of crossing points.
+   //
+                                                                                
+   static const Double_t kPi     = TMath::Pi();
+   static const Double_t kHalfPi = 0.5*TMath::Pi();
+   static const Double_t kTwoPi  = 2.0*TMath::Pi();
+                                                                                
+   Int_t iret = 0;
+   switch (nx) {
+      case 2:  // track hitting barrel part
+         phi = 9999.;
+         for (Int_t ix=0; ix<nx; ix++) {
+            Double_t x   = xxp[ix].X() - xc;
+            Double_t y   = xxp[ix].Y() - yc;
+            Double_t dfi = TMath::ATan2(y,x) - fi0 - kHalfPi*(1+chg);
+            if (!mode) {
+               while (dfi < -kPi) dfi += kTwoPi;
+               while (dfi >= kPi) dfi -= kTwoPi;
+            } else {
+               Int_t sign = (mode > 0 ? +1 : -1); // (+1,-1) = (fwd,bwd)
+               while (dfi <  0.)     dfi += kTwoPi;
+               while (dfi >= kTwoPi) dfi -= kTwoPi;
+               if (sign*chg > 0) dfi -= kTwoPi;
+            }
+            if (TMath::Abs(dfi) < TMath::Abs(phi)) {
+               phi = dfi;
+               xx.SetXYZ(xxp[ix].X(), xxp[ix].Y(), zc - rho*tnl*dfi);
+            }
+         }
+         if (IsOnBarrel(xx)) return 1;
+      default: // track hitting end cap part
+         if (TMath::Abs(tnl) < 0.1) {
+            return 0;
+         } else if (tnl < 0.) {
+            xx.SetZ(GetZmin());
+            iret = 2;
+         } else {
+            xx.SetZ(GetZmax());
+            iret = 3;
+         }
+         phi = (zdz-xx.Z())/rho/tnl;
+         if (TMath::Abs(phi) > kTwoPi) {
+            return 0;
+         } else {
+            xx.SetX(xc - rho*TMath::Cos(phi+fi0));
+            xx.SetY(yc - rho*TMath::Sin(phi+fi0));
+            if (IsOutside(xx)) return 0;
+         }
+         break;
+   }
+   return iret;
+}
diff --git a/Utilities/KalTest/src/geomlib/TTube.h b/Utilities/KalTest/src/geomlib/TTube.h
new file mode 100644
index 0000000000000000000000000000000000000000..f10a135e2e29453d52c051b1bea98dda009835e7
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TTube.h
@@ -0,0 +1,92 @@
+#ifndef TTUBE_H
+#define TTUBE_H
+//*************************************************************************
+//* ====================
+//*  TTube Class
+//* ====================
+//*
+//* (Description)
+//*   A class to implement a tube object.
+//* (Requires)
+//*     TVSolid
+//* (Provides)
+//*     class TTube
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include "TVSolid.h"
+#include "TVector3.h"
+
+class TVTrack;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Cylinder Class
+//  -----------------------------------
+
+class TTube : public TVSolid {
+public:
+   TTube(Double_t rin =  0., Double_t rout = 1., Double_t hlen  = 1., 
+             Double_t xc = 0., Double_t yc = 0, Double_t zc = 0.)
+           : fRin(rin), fRout(rout), fHalfLen(hlen), fXc(xc,yc,zc) {}
+
+   virtual ~TTube() {}
+
+   virtual Int_t CalcXingPointWith(const TVTrack  &hel,
+                                         Double_t &phi,
+                                         TVector3 &xx,
+                                         Int_t     mode,
+                                         Double_t  eps = 1.e-8)   const;
+
+   inline virtual       Bool_t     IsOnBarrel(const TVector3 &xx) const;
+   inline virtual       Bool_t     IsOutside (const TVector3 &xx) const;
+
+   inline virtual       Double_t   GetRin    () const { return fRin;  } 
+   inline virtual       Double_t   GetRout   () const { return fRout; } 
+   inline virtual const TVector3 & GetXc     () const { return fXc;   } 
+   inline virtual       Double_t   GetLength () const;
+   inline virtual       Double_t   GetZmin   () const;
+   inline virtual       Double_t   GetZmax   () const;
+
+private:
+   Double_t fRin;         // inner radius
+   Double_t fRout;        // outer radius
+   Double_t fHalfLen;     // half length
+   TVector3 fXc;          // center
+ 
+   ClassDef(TTube,1)      // TTube class
+};
+//=======================================================
+// inline functions
+//=======================================================
+
+Double_t TTube::GetLength () const 
+{ 
+   return 2*fHalfLen;
+} 
+
+Double_t TTube::GetZmin() const
+{
+   return fXc.Z() - fHalfLen;
+}
+
+Double_t TTube::GetZmax() const
+{
+   return fXc.Z() + fHalfLen;
+}
+
+Bool_t TTube::IsOnBarrel(const TVector3 &xx) const
+{
+   return (xx.Z() >= GetZmin() && xx.Z() <= GetZmax());
+} 
+
+Bool_t TTube::IsOutside(const TVector3 &xx) const
+{
+   Double_t r = (xx-fXc).Perp();
+   Double_t z = xx.Z();
+   return (r < fRin || r > fRout || z < GetZmin() || z > GetZmax());
+} 
+#endif
+
diff --git a/Utilities/KalTest/src/geomlib/TVCurve.cxx b/Utilities/KalTest/src/geomlib/TVCurve.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..38b3fcc7c74981898e1b1026f81ce0a902b7c0f0
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TVCurve.cxx
@@ -0,0 +1,22 @@
+//*************************************************************************
+//* ====================
+//*  TVCurve Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for various curves.
+//* (Requires)
+//*     TObject;
+//* (Provides)
+//*     class TVCurve
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include "TVCurve.h"
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any curve
+//  -----------------------------------
+ClassImp(TVCurve)
diff --git a/Utilities/KalTest/src/geomlib/TVCurve.h b/Utilities/KalTest/src/geomlib/TVCurve.h
new file mode 100644
index 0000000000000000000000000000000000000000..040912825ded5dfdeb1f52254aa75508c9343595
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TVCurve.h
@@ -0,0 +1,32 @@
+#ifndef TVCURVE_H
+#define TVCURVE_H
+//*************************************************************************
+//* ====================
+//*  TVCurve Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for various curves.
+//* (Requires)
+//*     TObject;
+//* (Provides)
+//*     class TVCurve
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include "TObject.h"
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any curve
+//  -----------------------------------
+
+class TVCurve : public TObject {
+public:
+private:
+ 
+   ClassDef(TVCurve,1)      // Base class for any curve
+};
+
+#endif
diff --git a/Utilities/KalTest/src/geomlib/TVSolid.cxx b/Utilities/KalTest/src/geomlib/TVSolid.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..afc58e5ca93e4ae8b5cd4f957ad559dd90ab74b5
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TVSolid.cxx
@@ -0,0 +1,23 @@
+//*************************************************************************
+//* ====================
+//*  TVSolid Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for various solids.
+//* (Requires)
+//*     TObject;
+//* (Provides)
+//*     class TVSolid
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include "TVSolid.h"
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any solid
+//  -----------------------------------
+
+ClassImp(TVSolid)
diff --git a/Utilities/KalTest/src/geomlib/TVSolid.h b/Utilities/KalTest/src/geomlib/TVSolid.h
new file mode 100644
index 0000000000000000000000000000000000000000..83b4f57e20505c8bda69f27297ec0e604f2957b3
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TVSolid.h
@@ -0,0 +1,32 @@
+#ifndef TVSOLID_H
+#define TVSOLID_H
+//*************************************************************************
+//* ====================
+//*  TVSolid Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for various solids.
+//* (Requires)
+//*     TObject;
+//* (Provides)
+//*     class TVSolid
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+#include "TObject.h"
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any solid
+//  -----------------------------------
+
+class TVSolid : public TObject {
+public:
+private:
+ 
+   ClassDef(TVSolid,1)      // Base class for any solid
+};
+
+#endif
diff --git a/Utilities/KalTest/src/geomlib/TVSurface.cxx b/Utilities/KalTest/src/geomlib/TVSurface.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..3294ab991b2cf9def7125ec4a1d307025a9e808d
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TVSurface.cxx
@@ -0,0 +1,127 @@
+//*************************************************************************
+//* ====================
+//*  TVSurface Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for various surfaces.
+//* (Requires)
+//*     TObject;
+//* (Provides)
+//*     class TVSurface
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*   2005/02/23  K.Fujii       Added new methods, Compare() and
+//*                             GetSortingPolicy().
+//*
+//*************************************************************************
+//
+#include <iostream>
+#include "TVSurface.h"
+#include "TVTrack.h"
+
+using namespace std;
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any surface
+//  -----------------------------------
+
+ClassImp(TVSurface)
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Calculate crossing point with track
+//  -----------------------------------
+//
+Int_t TVSurface::CalcXingPointWith(const TVTrack  &hel,
+                                         TVector3 &xx,
+                                         Double_t &phi,
+                                         Double_t  eps) const
+{
+   return CalcXingPointWith(hel,xx,phi,0,eps);
+}
+
+Int_t TVSurface::CalcXingPointWith(const TVTrack  &hel,
+				         TVector3 &xx,
+				         Double_t &phi,
+				         Int_t     mode,
+				         Double_t  eps) const
+{
+
+   static const Int_t       maxcount   = 100;
+   static const Double_t    initlambda = 1.e-10;
+   static const Double_t    lambdaincr = 10.;
+   static const Double_t    lambdadecr = 0.1;
+   
+   xx = hel.CalcXAt(phi);
+
+   Double_t  lastphi =  phi;
+   Double_t  lasts   =  99999;
+   Double_t  lambda  =  initlambda;
+
+   TVector3  lastxx  =  xx;
+   Int_t     count   =  0;
+
+   Double_t s;
+
+   while (1) {
+      if (count > maxcount) {
+         s       = lasts;
+         phi     = lastphi;
+         xx      = lastxx;
+#if 0
+         cerr << "TVSurface::CalcXingPointWith:"
+              << "   --- Loop count limit reached ---------- " << endl
+              << "   phi    : " << phi    << endl
+              << "   x      : " << xx.X() << " "
+                                << xx.Y() << " "
+                                << xx.Z() << endl 
+              << "   s      : " << s      << endl
+              << "   lambda : " << lambda << endl;
+#endif
+         return 0;
+      }
+      count++;
+      s  = CalcS(xx);
+      if (TMath::Abs(s) < eps) break;
+      if (TMath::Abs(s) < TMath::Abs(lasts)) {
+         lasts   = s;
+         lastphi = phi;
+         lastxx  = xx;
+         lambda *= lambdadecr;
+      } else {
+         s       = lasts;
+         phi     = lastphi;
+         xx      = lastxx;
+         lambda *= lambdaincr;
+      }
+      TMatrixD dsdx   = CalcDSDx(xx);
+      TMatrixD dxdphi = hel.CalcDxDphi(phi);
+      TMatrixD dsdphi = dsdx * dxdphi;
+      Double_t denom = (1 + lambda) * dsdphi(0,0);
+      phi -= s / denom;
+      xx   = hel.CalcXAt(phi);
+   }
+
+   if( mode!=0 ){ // (+1,-1) = (fwd,bwd)
+     const Int_t chg = (Int_t)TMath::Sign(1.1, hel.GetKappa());
+     if( chg*phi*mode > 0){
+       return 0;
+     }
+   }
+   
+   return (IsOnSurface(xx) ? 1 : 0);
+}
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Compare to Surfaces
+//  -----------------------------------
+//
+Int_t TVSurface::Compare(const TObject *obj) const
+{
+   Double_t me  = GetSortingPolicy();
+   Double_t you = dynamic_cast<const TVSurface *>(obj)->GetSortingPolicy();
+   return me < you ? -1 : (me > you ? +1 : 0);
+}
diff --git a/Utilities/KalTest/src/geomlib/TVSurface.h b/Utilities/KalTest/src/geomlib/TVSurface.h
new file mode 100644
index 0000000000000000000000000000000000000000..be0a085a4ab3a00d09b2f5dbfe533f670d937e4a
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TVSurface.h
@@ -0,0 +1,68 @@
+#ifndef TVSURFACE_H
+#define TVSURFACE_H
+//*************************************************************************
+//* ====================
+//*  TVSurface Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for various solids.
+//* (Requires)
+//*     TObject;
+//* (Provides)
+//*     class TVSurface
+//* (Update Recored)
+//*   2003/10/03  K.Fujii       Original version.
+//*   2005/02/23  K.Fujii       Added new methods, Compare() and
+//*                             GetSortingPolicy().
+//*
+//*   2011/06/17  D.Kamai       Added new method, GetOutwardNormal() 
+//*                             
+//*************************************************************************
+//
+#include "TObject.h"
+#include "TMatrixD.h"
+#include "TVector3.h"
+
+class TVTrack;
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any surface
+//  -----------------------------------
+
+class TVSurface : public TObject {
+public:
+
+   virtual Int_t    CalcXingPointWith(const TVTrack  &hel,
+                                            TVector3 &xx,
+                                            Double_t &phi,
+                                            Double_t  eps = 1.e-8) const;
+   virtual Int_t    CalcXingPointWith(const TVTrack  &hel,
+                                            TVector3 &xx,
+                                            Double_t &phi,
+                                            Int_t     mode,
+   				            Double_t  eps = 1.e-8) const;
+
+   virtual Double_t CalcS            (const TVector3 &xx) const = 0;
+   virtual TMatrixD CalcDSDx         (const TVector3 &xx) const = 0;
+   virtual Bool_t   IsOnSurface      (const TVector3 &xx) const = 0;
+   virtual Bool_t   IsOutside        (const TVector3 &xx) const = 0;
+   inline virtual TVector3 GetOutwardNormal (const TVector3 &xx) const;
+  
+   virtual Double_t GetSortingPolicy ()                   const = 0;
+
+   virtual Int_t    Compare   (const TObject *obj) const;
+   virtual Bool_t   IsSortable()                   const { return kTRUE; }
+   
+private:
+ 
+   ClassDef(TVSurface,1)      // Base class for any surface
+};
+
+TVector3 TVSurface::GetOutwardNormal(const TVector3 &xx) const
+{
+  TMatrixD dsdx = CalcDSDx(xx);
+  return TVector3(dsdx(0,0),dsdx(0,1),dsdx(0,2)).Unit();
+}
+
+#endif
diff --git a/Utilities/KalTest/src/geomlib/TVTrack.cxx b/Utilities/KalTest/src/geomlib/TVTrack.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..4eb727e25418ed68d7f3d501d90c3f32372e096c
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TVTrack.cxx
@@ -0,0 +1,61 @@
+//*************************************************************************
+//* ===============
+//*  TVTrack Class
+//* ===============
+//*
+//* (Description)
+//*   A class to implement a track object.
+//* (Requires)
+//*     TVCurve
+//* (Provides)
+//*     class TVTrack
+//* (Update Recored)
+//*   2003/10/24  K.Fujii       Original version.
+//*
+//*************************************************************************
+//
+
+#include <iostream>
+#include "TVTrack.h"
+
+using namespace std;
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+#else
+const Double_t TVTrack::kLightVelocity = 2.99792458e8;
+const Double_t TVTrack::kGiga          = 1.e9;
+const Double_t TVTrack::kInfinity      = 1.e20;
+#endif
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Track Class
+//  -----------------------------------
+//
+//_____________________________________________________________________
+//  --------------
+//  Ctors and Dtor
+//  --------------
+//
+
+TVTrack::TVTrack(Double_t dr,
+                 Double_t phi0,
+                 Double_t kappa,
+                 Double_t dz,
+                 Double_t tanl,
+                 Double_t x0,
+                 Double_t y0,
+                 Double_t z0,
+                 Double_t b)
+             : fDrho(dr), fPhi0(phi0), fKappa(kappa), fDz(dz), fTanL(tanl),
+               fX0(x0,y0,z0)
+{
+   SetMagField(b);
+}
+
+TVTrack::TVTrack(const TMatrixD &a, const TVector3 & x0, Double_t b)
+             : fDrho(a(0,0)), fPhi0(a(1,0)), fKappa(a(2,0)), 
+               fDz(a(3,0)), fTanL(a(4,0)),
+               fX0(x0)
+{
+   SetMagField(b);
+}
diff --git a/Utilities/KalTest/src/geomlib/TVTrack.h b/Utilities/KalTest/src/geomlib/TVTrack.h
new file mode 100644
index 0000000000000000000000000000000000000000..9e8f0f4548363a1b9aa6573a094863186e221413
--- /dev/null
+++ b/Utilities/KalTest/src/geomlib/TVTrack.h
@@ -0,0 +1,150 @@
+#ifndef TVTRACK_H
+#define TVTRACK_H
+//*************************************************************************
+//* ===============
+//*  TVTrack Class
+//* ===============
+//*
+//* (Description)
+//*   This is the base class for various tracks.
+//* (Requires)
+//*     TVCurve;
+//* (Provides)
+//*     class TVTrack
+//* (Update Recored)
+//*   2003/10/24  K.Fujii       Original version.
+//*   2005/08/14  K.Fujii       Added IsInB().
+//*
+//*************************************************************************
+//
+
+#include "TVector3.h"
+#include "TMatrixD.h"
+
+#if 1
+#include "TMath.h"
+#include "TCollection.h"
+#endif
+
+#include "TVCurve.h"
+
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for any track
+//  -----------------------------------
+
+class TVTrack : public TVCurve {
+public:
+   // Ctors and Dtor
+
+   TVTrack(Double_t dr    = 0.,
+           Double_t phi0  = 0.,
+           Double_t kappa = 1.e-5,
+           Double_t dz    = 0.,
+           Double_t tanl  = 0.,
+           Double_t x0    = 0.,
+           Double_t y0    = 0.,
+           Double_t z0    = 0.,
+           Double_t b     = 30.);
+
+   TVTrack(const TMatrixD &a, const TVector3 & x0, Double_t b = 30.);
+
+   virtual ~TVTrack() {}
+
+   // Utility methods
+
+   virtual void MoveTo(const TVector3 &x0to,
+                             Double_t &fid,
+                             TMatrixD *F = 0,
+                             TMatrixD *C = 0) = 0;
+
+   virtual void MoveTo(const TVector3 &x0to,
+                             Double_t &fid,
+                             TMatrixD &C)
+   {
+      Int_t sdim = C.GetNrows();
+      TMatrixD F(sdim, sdim);
+      MoveTo(x0to,fid,&F,&C);
+   }
+
+   inline virtual void ScatterBy(Double_t dphi, Double_t dtnl)
+   {
+      fPhi0  += dphi;
+      fKappa += (fKappa*fTanL/(1+fTanL*fTanL)) * dtnl;
+      fTanL  += dtnl;
+   }
+
+   inline virtual void  PutInto(TMatrixD &sv) const
+   {
+      sv(0,0) = fDrho;
+      sv(1,0) = fPhi0;
+      sv(2,0) = fKappa;
+      sv(3,0) = fDz;
+      sv(4,0) = fTanL;
+   }
+
+   virtual TVector3 CalcXAt   (Double_t phi) const = 0;
+   virtual TMatrixD CalcDxDa  (Double_t phi) const = 0;
+   virtual TMatrixD CalcDxDphi(Double_t phi) const = 0;
+   virtual void     CalcDapDa (Double_t fid,
+                               Double_t dr,
+                               Double_t drp,
+                               TMatrixD &F)  const = 0;
+
+   // Getters
+
+   inline virtual       Double_t   GetDrho     () const { return fDrho;  }
+   inline virtual       Double_t   GetPhi0     () const { return fPhi0;  }
+   inline virtual       Double_t   GetKappa    () const { return fKappa; }
+   inline virtual       Double_t   GetDz       () const { return fDz;    }
+   inline virtual       Double_t   GetTanLambda() const { return fTanL;  }
+   inline virtual const TVector3 & GetPivot    () const { return fX0;    }
+   inline virtual       Double_t   GetRho      () const { return fAlpha/fKappa; }
+   inline virtual       Double_t   GetPtoR     () const { return fAlpha; }
+
+   // Setters
+
+   inline virtual void  SetTo(const TMatrixD &sv, const TVector3 &x0)
+   {
+      fDrho  = sv(0,0);
+      fPhi0  = sv(1,0);
+      fKappa = sv(2,0);
+      fDz    = sv(3,0);
+      fTanL  = sv(4,0);
+      fX0    = x0;
+   }
+
+   inline virtual void SetMagField(Double_t b)
+   {
+     // // units: mm, sec, Tesla
+     if (b != 0.) fAlpha = kGiga/kLightVelocity*1000./b;
+     // units: cm, sec, kGaus
+     //if (b != 0.) fAlpha = kGiga/kLightVelocity*100./(b/10);
+     else         fAlpha = kInfinity;
+   }
+	
+   inline virtual Bool_t IsInB() const { return fAlpha < kInfinity ? kTRUE : kFALSE; }
+
+protected:
+   Double_t fDrho;      // drho
+   Double_t fPhi0;      // phi0
+   Double_t fKappa;     // kappa
+   Double_t fDz;        // dz
+   Double_t fTanL;      // tanl
+   TVector3 fX0;        // pivot
+   Double_t fAlpha;     // alpha
+
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+   static const Double_t kLightVelocity = 2.99792458e8; //! light velocity [m/sec]
+   static const Double_t kGiga          = 1.0e9;        //! Giga = 10^{9}
+   static const Double_t kInfinity      = 1.e+20;       //! infinity
+#else
+   static const Double_t kLightVelocity;                //! light velocity [m/sec]
+   static const Double_t kGiga;                         //! Giga = 10^{9}
+   static const Double_t kInfinity;                     //! infinity
+#endif
+
+   ClassDef(TVTrack,1)      // Base class for any track
+};
+
+#endif
diff --git a/Utilities/KalTest/src/kallib/Imakefile b/Utilities/KalTest/src/kallib/Imakefile
new file mode 100644
index 0000000000000000000000000000000000000000..f6a24db463e62180649eaff310475360cdc06887
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/Imakefile
@@ -0,0 +1,54 @@
+#include "../../conf/makejsf.tmpl"
+
+LDFLAGS   = /* $(GLIBS) */
+
+INSTALLDIR    = ../..
+SOREV         = 2005.01
+PACKAGENAME   = S4Kalman
+
+SRCS          = TKalMatrix.$(SrcSuf)  \
+		TVKalSite.$(SrcSuf) \
+		TVKalState.$(SrcSuf) \
+		TVKalSystem.$(SrcSuf)
+
+OBJS	      =	$(subst .$(SrcSuf),.$(ObjSuf),$(SRCS)) \
+		$(PACKAGENAME)Dict.$(ObjSuf)
+
+HDRS	      = $(subst .$(SrcSuf),.h,$(SRCS))
+
+DICTNAME      = $(PACKAGENAME)Dict
+
+LIBNAME       = $(PACKAGENAME)
+
+SONAME        = lib$(LIBNAME).$(DllSuf).$(SOREV)
+
+LIBINSTALLDIR = $(INSTALLDIR)/lib
+INCINSTALLDIR = $(INSTALLDIR)/include
+INCPATH	      = -I. -I$(INCINSTALLDIR)
+CXXFLAGS     += $(INCPATH) -O0 -g 
+SHLIBLDFLAGS  = $(DYLIBFLAGS)
+
+all:: $(SONAME)
+
+SharedLibraryTarget($(LIBNAME),$(SOREV),$(OBJS),.,.)
+
+InstallSharedLibrary($(LIBNAME),$(SOREV),$(LIBINSTALLDIR))
+
+InstallMultipleFlags($(HDRS),$(INCINSTALLDIR),-m 644)
+
+clean:: 
+	@rm -f $(OBJS) core *.$(DllSuf) $(DICTNAME).$(SrcSuf) $(DICTNAME).h
+
+depend:: $(SRCS) $(HDRS)
+	for i in $(SRCS); do \
+	rmkdepend -a -- $(CXXFLAGS) $(INCPATH) $(DEPENDFILES) -- $$i; done
+
+distclean:: clean
+	@rm -f $(OBJS) core *.$(DllSuf) *.$(DylibSuf)
+	@rm -f $(DICTNAME).$(SrcSuf) $(DICTNAME).h *~
+	@rm -f $(SONAME) *.root Makefile
+
+$(DICTNAME).$(SrcSuf): $(HDRS) LinkDef.h
+	@echo "Generating dictionary ..."
+	rootcint -f $(DICTNAME).$(SrcSuf) \
+ 		-c -I$(INCINSTALLDIR) $(HDRS) LinkDef.h
diff --git a/Utilities/KalTest/src/kallib/LinkDef.h b/Utilities/KalTest/src/kallib/LinkDef.h
new file mode 100644
index 0000000000000000000000000000000000000000..38cd360482aae2e6736d756bafe73f2d98b6478a
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/LinkDef.h
@@ -0,0 +1,12 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class TKalMatrix+;
+#pragma link C++ class TVKalSite+;
+#pragma link C++ class TVKalState+;
+#pragma link C++ class TVKalSystem+;
+
+#endif
diff --git a/Utilities/KalTest/src/kallib/TKalMatrix.cxx b/Utilities/KalTest/src/kallib/TKalMatrix.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..f5789334c25f2eba6697983ec8b93a3c4a44fb6b
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/TKalMatrix.cxx
@@ -0,0 +1,148 @@
+//*************************************************************************
+//* ====================
+//*  TKalMatrix Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for matrix used by Kalman filter.
+//* (Requires)
+//* 	TMatrixD
+//* (Provides)
+//* 	class TKalMatrix
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*
+//*************************************************************************
+//
+#include <iostream>
+#include <iomanip>
+#include "TString.h"
+#include "TKalMatrix.h"
+
+//_____________________________________________________________________
+//  ------------------------------
+//  A Wrapper for TMatrixD
+//  ------------------------------
+//
+ClassImp(TKalMatrix)
+
+//-------------------------------------------------------
+// Ctors and Dtor
+//-------------------------------------------------------
+
+TKalMatrix::TKalMatrix(Int_t rowdim, Int_t coldim)
+              :TMatrixD(rowdim, coldim)
+{
+}
+                                                                                
+TKalMatrix::TKalMatrix(const TKalMatrix &orig)
+              :TMatrixD(orig)
+{
+}
+                                                                                
+TKalMatrix::TKalMatrix(const TMatrixD &orig)
+              :TMatrixD(orig)
+{
+}
+
+TKalMatrix::TKalMatrix(TMatrixD::EMatrixCreatorsOp1 op,
+                             const TKalMatrix &prototype)
+              :TMatrixD(op, prototype)
+{
+}
+                                                                                
+TKalMatrix::TKalMatrix(TMatrixD::EMatrixCreatorsOp1 op,
+                             const TMatrixD &prototype)
+              :TMatrixD(op, prototype)
+{
+}
+                                                                                
+TKalMatrix::TKalMatrix(const TKalMatrix &a,
+                             TMatrixD::EMatrixCreatorsOp2 op,
+                             const TKalMatrix &b)
+              :TMatrixD(a, op, b)
+{
+}
+
+TKalMatrix::TKalMatrix(const TMatrixD &a,
+                             TMatrixD::EMatrixCreatorsOp2 op,
+                             const TMatrixD &b)
+              :TMatrixD(a, op, b)
+{
+}
+
+TKalMatrix::TKalMatrix(const TVector3 &v)
+              :TMatrixD(TKalMatrix::ToKalMat(v))
+{
+}
+
+//-------------------------------------------------------
+// Print
+//-------------------------------------------------------
+
+void TKalMatrix::DebugPrint(Option_t *opt, Int_t ncolsps) const
+{
+   using namespace std;
+
+   Int_t ncols   = GetNcols();
+   Int_t nrows   = GetNrows();
+   Int_t nsheets = (ncols-1)/ncolsps + 1;
+   Int_t lastcw  = ncols - ncolsps*(nsheets-1);
+   Int_t ns      = 0;
+
+   TString title(opt);
+   TString off(title.Length());
+   for (Int_t c=0; c<title.Length(); c++) off += " ";
+
+   for (Int_t sc = 1; sc <= ncols; sc += ncolsps) {
+      ns++;
+      if (ns == 1) cerr << title << "+-";
+      if (ns == nsheets) {
+         for (Int_t ib = 1; ib <= 11*lastcw; ib++) cerr << " ";
+         cerr << "-+" << endl;
+      } else {
+         cerr << endl;
+      }
+      for (Int_t i = 1; i <= nrows; i++) {
+         if (ns == 1) cerr << off << "| ";
+         for (Int_t j = sc; j < sc+ncolsps && j <= ncols; j++) {
+            cerr // << setiosflags(ios::scientific) 
+                 << setw(11) << setprecision(4)
+                 << (*this)(i-1,j-1);
+            if (j == ncols) cerr << " |";
+         }
+         cerr << endl;
+      }
+      if (ns == 1) cerr << off << "+-";
+      if (ns == nsheets) {
+         for (Int_t ib = 1; ib <= 11*lastcw; ib++) cerr << " ";
+         cerr << "-+" << endl;
+      } else {
+         cerr << endl;
+      }
+   }
+}
+
+//-------------------------------------------------------
+// VectorToMatrix
+//-------------------------------------------------------
+
+TKalMatrix TKalMatrix::ToKalMat(const TVector3 &a)
+{
+   TKalMatrix md(3,1);
+   md(0,0) = a.x();
+   md(1,0) = a.y();
+   md(2,0) = a.z();
+   return md;
+}
+
+//-------------------------------------------------------
+// MatrixToVector
+//-------------------------------------------------------
+
+TVector3 TKalMatrix::ToThreeVec(const TMatrixD &a)
+{
+   TVector3 v;
+   v.SetXYZ(a(0,0), a(1,0),a(2,0));
+   return v;
+}
diff --git a/Utilities/KalTest/src/kallib/TKalMatrix.h b/Utilities/KalTest/src/kallib/TKalMatrix.h
new file mode 100644
index 0000000000000000000000000000000000000000..947b92c02f0b96eb6f990a1e3da3acc1888bcc05
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/TKalMatrix.h
@@ -0,0 +1,58 @@
+#ifndef TKALMATRIX_H
+#define TKALMATRIX_H
+//*************************************************************************
+//* ===================
+//*  TKalMatrix Class
+//* ===================
+//*
+//* (Description)
+//*    TKalMatrix is a wrapper of TMatrixD.
+//* (Requires)
+//* 	TMatrixD
+//* (Provides)
+//* 	class TKalMatrix
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*
+//*************************************************************************
+
+#include "TMatrixD.h"
+#include "TVector3.h"
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for matrix used by Kalman filter
+//  ------------------------------
+//
+class TKalMatrix : public TMatrixD { 
+public:
+   TKalMatrix(Int_t rowdim = 1, Int_t coldim = 1);
+
+   TKalMatrix(const TKalMatrix &orig);
+   TKalMatrix(const TMatrixD &orig);
+                                                                                
+   TKalMatrix(TMatrixD::EMatrixCreatorsOp1 op,
+              const TKalMatrix &prototype);
+   TKalMatrix(TMatrixD::EMatrixCreatorsOp1 op,
+              const TMatrixD &prototype);
+                                                                                
+   TKalMatrix(const TKalMatrix &a,
+              TMatrixD::EMatrixCreatorsOp2 op,
+              const TKalMatrix &b) ;
+   TKalMatrix(const TMatrixD &a,
+              TMatrixD::EMatrixCreatorsOp2 op,
+              const TMatrixD &b) ;
+
+   TKalMatrix(const TVector3 &v);
+
+   virtual ~TKalMatrix() {}
+
+   virtual void      DebugPrint(Option_t *opt = "", Int_t nc = 5) const;
+
+   static TKalMatrix ToKalMat  (const TVector3 &vec);
+   static TVector3   ToThreeVec(const TMatrixD &mat);
+   
+private:
+   
+   ClassDef(TKalMatrix,1)      // Base class for Kalman matrix
+};
+#endif
diff --git a/Utilities/KalTest/src/kallib/TVKalSite.cxx b/Utilities/KalTest/src/kallib/TVKalSite.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..be6dcbe770e15503994c58b570531040ca4d9d52
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/TVKalSite.cxx
@@ -0,0 +1,187 @@
+//*************************************************************************
+//* ====================
+//*  TVKalSite Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for measurement vector used by Kalman filter.
+//* (Requires)
+//* 	TKalMatrix
+//*   TVKalState
+//* (Provides)
+//* 	class TVKalSite
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*   2009/06/18  K.Fujii       Implement inverse Kalman filter
+//*
+//*************************************************************************
+//
+
+#include <iostream>
+#include <cstdlib>
+#include "TVKalSite.h"
+#include "TVKalState.h"
+
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for measurement vector used by Kalman filter
+//  ------------------------------
+//
+ClassImp(TVKalSite)
+
+TVKalSite::TVKalSite(Int_t m, Int_t p)
+                   :TObjArray(2),
+                    TAttLockable(),
+                    fCurStatePtr(0), 
+                    fM(m,1),
+                    fV(m,m),
+                    fH(m,p),
+                    fHt(p,m),
+                    fResVec(m,1),
+                    fR(m,m),
+                    fDeltaChi2(0.)
+{
+   // Create fStateVector at constractor of concreate class:
+   // SetStateVector(new TXXXKalmanStateVector(.....))
+}
+
+TVKalSite::~TVKalSite()
+{
+}
+
+//---------------------------------------------------------------
+// Filter
+//---------------------------------------------------------------
+
+Bool_t TVKalSite::Filter()
+{
+   // prea and preC should be preset by TVKalState::Propagate()
+   TVKalState &prea = GetState(TVKalSite::kPredicted);
+   TKalMatrix h = fM;
+   if (!CalcExpectedMeasVec(prea,h)) return kFALSE;
+   TKalMatrix pull  = fM - h;
+   TKalMatrix preC  = GetState(TVKalSite::kPredicted).GetCovMat();
+
+   // Calculate fH and fHt
+
+   if (!CalcMeasVecDerivative(prea,fH)) return kFALSE;
+   fHt = TKalMatrix(TKalMatrix::kTransposed, fH);
+
+   // Calculate covariance matrix of residual
+
+   TKalMatrix preR    = fV + fH * preC * fHt;
+   TKalMatrix preRinv = TKalMatrix(TKalMatrix::kInverted, preR);
+
+   // Calculate kalman gain matrix
+
+   TKalMatrix preCinv = TKalMatrix(TKalMatrix::kInverted, preC);
+   TKalMatrix G       = TKalMatrix(TKalMatrix::kInverted, fV);
+
+   // Calculate filtered state vector
+
+   TKalMatrix curCinv = preCinv + fHt * G * fH; 
+   TKalMatrix curC    = TKalMatrix(TKalMatrix::kInverted, curCinv);
+   TKalMatrix K       = curC * fHt * G;
+
+   TKalMatrix Kpull  = K * pull;
+   TKalMatrix Kpullt = TKalMatrix(TKalMatrix::kTransposed,Kpull);
+   TKalMatrix av     = prea + Kpull;
+   TVKalState &a     = CreateState(av,curC,TVKalSite::kFiltered);
+   TVKalState *aPtr  = &a;
+
+   Add(aPtr);
+   SetOwner();
+
+   // Calculate chi2 increment
+
+   fR      = fV - fH * curC *fHt;
+   if (!CalcExpectedMeasVec(a,h)) return kFALSE;
+   fResVec = fM - h;
+   TKalMatrix curResVect = TKalMatrix(TKalMatrix::kTransposed, fResVec);
+   fDeltaChi2 = (curResVect * G * fResVec + Kpullt * preCinv * Kpull)(0,0);
+
+   if (IsAccepted()) return kTRUE;
+   else              return kFALSE;
+}
+
+//---------------------------------------------------------------
+// Smooth
+//---------------------------------------------------------------
+
+void TVKalSite::Smooth(TVKalSite &pre)
+{
+   if (&GetState(TVKalSite::kSmoothed)) return;
+
+   TVKalState &cura  = GetState(TVKalSite::kFiltered);
+   TVKalState &prea  = pre.GetState(TVKalSite::kPredicted);
+   TVKalState &sprea = pre.GetState(TVKalSite::kSmoothed);
+
+   TKalMatrix curC    = cura.GetCovMat();
+   TKalMatrix curFt   = cura.GetPropMat("T");
+   TKalMatrix preC    = prea.GetCovMat();
+   TKalMatrix spreC   = sprea.GetCovMat();
+   TKalMatrix preCinv = TKalMatrix(TKalMatrix::kInverted, preC);
+   TKalMatrix curA    = curC * curFt * preCinv;
+   TKalMatrix curAt   = TKalMatrix(TKalMatrix::kTransposed, curA);
+   TKalMatrix scurC   = curC + curA * (spreC - preC) * curAt;
+
+   TKalMatrix sv = cura + curA * (sprea - prea);
+   Add(&CreateState(sv,scurC,TVKalSite::kSmoothed));
+   SetOwner();
+
+   // Update residual vector
+
+   fR       = fV - fH * scurC *fHt;
+   fResVec -= fH * (sv - cura);
+   TKalMatrix curResVect = TKalMatrix(TKalMatrix::kTransposed, fResVec);
+   TKalMatrix curRinv    = TKalMatrix(TKalMatrix::kInverted, fR);
+   fDeltaChi2 = (curResVect * curRinv * fResVec)(0,0);
+}
+
+//---------------------------------------------------------------
+// InvFilter
+//---------------------------------------------------------------
+
+void TVKalSite::InvFilter()
+{
+   if (&GetState(TVKalSite::kInvFiltered)) return;
+
+   TVKalState &sa = GetState(TVKalSite::kSmoothed);
+   TKalMatrix pull = fResVec;
+
+   TKalMatrix sC     = sa.GetCovMat();
+   TKalMatrix sR     = fH * sC * fHt - fV;
+   TKalMatrix sRinv  = TKalMatrix(TKalMatrix::kInverted, sR);
+   TKalMatrix Kstar  = sC * fHt * sRinv;
+   TKalMatrix svstar = sa + Kstar * pull;
+   TKalMatrix sCinv  = TKalMatrix(TKalMatrix::kInverted, sC);
+   TKalMatrix G      = TKalMatrix(TKalMatrix::kInverted, fV);
+   TKalMatrix Cstar  = TKalMatrix(TKalMatrix::kInverted, sCinv + fHt * G * fH);
+   Add(&CreateState(svstar,Cstar,TVKalSite::kInvFiltered));
+   SetOwner();
+}
+
+//---------------------------------------------------------------
+// Getters
+//---------------------------------------------------------------
+
+TKalMatrix TVKalSite::GetResVec (TVKalSite::EStType t)
+{
+   using namespace std;
+   TVKalState &a  = GetState(t);
+   TVKalState &sa = (&GetState(TVKalSite::kSmoothed) != 0
+                    ? GetState(TVKalSite::kSmoothed)
+                    : GetState(TVKalSite::kFiltered));
+   if (!&a || !&sa) {
+     cerr << ":::::: ERROR in TVKalSite::GetResVec(EStType) " << endl
+          << " Invalid states requested"                      << endl
+          << " &a = " << &a << " &sa = " << &sa               << endl
+          << " Abort!"                                        << endl;
+     ::abort();
+   }
+   if (&a == &sa) {
+      return fResVec;
+   } else {
+      return (fResVec - fH * (a - sa));
+   }
+}
diff --git a/Utilities/KalTest/src/kallib/TVKalSite.h b/Utilities/KalTest/src/kallib/TVKalSite.h
new file mode 100644
index 0000000000000000000000000000000000000000..d00345af335c708b91b79bacb42aafd3cf97fd2a
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/TVKalSite.h
@@ -0,0 +1,124 @@
+#ifndef TVKALSITE_H
+#define TVKALSITE_H
+//*************************************************************************
+//* ===================
+//*  TVKalSite Class
+//* ===================
+//*
+//* (Description)
+//*   This is the base class for measurement vector used by Kalman filter.
+//* (Requires)
+//* 	TKalMatrix
+//* (Provides)
+//* 	class TVKalSite
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*   2005/02/23  A.Yamaguchi	Added getter and setter for a new static
+//*                             data member, fgKalSysPtr.
+//*   2005/08/25  A.Yamaguchi	Removed getter and setter for a new static
+//*                             data member, fgKalSysPtr.
+//*   2009/06/18  K.Fujii       Implement inverse Kalman filter
+//*
+//*************************************************************************
+//
+#include "TObjArray.h"
+
+#include "TAttLockable.h"
+#include "TKalMatrix.h"
+#include "TVKalState.h"
+
+class TVKalSystem;
+
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for Kalman measurement vector
+//  ------------------------------
+//
+class TVKalSite : public TObjArray, public TAttLockable {
+friend class TVKalSystem;
+
+public:
+   enum EStType { kPredicted = 0,
+                  kFiltered,
+                  kSmoothed,
+                  kInvFiltered };
+public:
+   // Ctors and Dtor
+
+   TVKalSite(Int_t m = 2, Int_t p = 6);
+   virtual ~TVKalSite();
+             
+   // Utility Methods
+
+   virtual Int_t   CalcExpectedMeasVec  (const TVKalState &a,
+                                               TKalMatrix &m) = 0;
+   virtual Int_t   CalcMeasVecDerivative(const TVKalState &a,
+                                               TKalMatrix &H) = 0;
+   virtual Bool_t  IsAccepted() = 0;
+
+   virtual void    DebugPrint() const = 0;
+
+   virtual Bool_t  Filter();
+
+   virtual void    Smooth(TVKalSite &pre);
+
+   virtual void    InvFilter();
+
+   inline  void    Add(TObject *obj);
+   
+   // Getters
+
+   inline virtual Int_t        GetDimension() const { return fM.GetNrows(); }
+   inline virtual TVKalState & GetCurState ()       { return *fCurStatePtr; }
+   inline virtual TVKalState & GetCurState () const { return *fCurStatePtr; }
+   inline virtual TVKalState & GetState (EStType t);
+   inline virtual TKalMatrix & GetMeasVec      ()   { return fM;            }
+   inline virtual TKalMatrix & GetMeasNoiseMat ()   { return fV;            }
+   inline virtual TKalMatrix & GetResVec       ()   { return fResVec;       }
+   inline virtual TKalMatrix & GetCovMat       ()   { return fR;            }
+   inline virtual Double_t     GetDeltaChi2() const { return fDeltaChi2;    }
+          virtual TKalMatrix   GetResVec (EStType t);
+
+private:
+   // Private utility methods
+
+   virtual TVKalState & CreateState(const TKalMatrix &sv, Int_t type = 0) = 0;
+   virtual TVKalState & CreateState(const TKalMatrix &sv, const TKalMatrix &c,
+                                    Int_t type = 0) = 0;
+
+private:
+   
+   // private data member -------------------------------------------
+
+   TVKalState    *fCurStatePtr; // pointer to current best state
+   TKalMatrix     fM;           // measurement vector: M(m,1)
+   TKalMatrix     fV;           // noise matrix: M(m,m)
+   TKalMatrix     fH;           // H = (@h/@a): M(m,p)
+   TKalMatrix     fHt;          // H^t = (@h/@a)^t: M(p,m)
+   TKalMatrix     fResVec;      // m - h(a): M(m,1)
+   TKalMatrix     fR;           // covariance matrix: M(m,m)
+   Double_t       fDeltaChi2;   // chi2 increment
+
+   ClassDef(TVKalSite,1)      // Base class for measurement vector objects
+};
+
+//=======================================================
+// inline functions
+//=======================================================
+
+void TVKalSite::Add(TObject *obj)
+{
+   TObjArray::Add(obj);
+   fCurStatePtr = static_cast<TVKalState *>(obj);
+   fCurStatePtr->SetSitePtr(this);
+}
+
+TVKalState & TVKalSite::GetState(TVKalSite::EStType t)
+{
+   TVKalState *ap = 0;
+   if (t >= 0 && t < GetEntries()) {
+      ap = static_cast<TVKalState *>(UncheckedAt(t));
+   }
+   return *ap;
+}
+#endif
diff --git a/Utilities/KalTest/src/kallib/TVKalState.cxx b/Utilities/KalTest/src/kallib/TVKalState.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..bd509381744491e0529dcf185189b7eeba92df71
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/TVKalState.cxx
@@ -0,0 +1,120 @@
+//*************************************************************************
+//* ====================
+//*  TVKalState Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for state vector used by Kalman filter.
+//* (Requires)
+//* 	TKalMatrix
+//* (Provides)
+//* 	class TVKalState
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version
+//*
+//*************************************************************************
+//
+#include "TVKalState.h"
+#include "TVKalSite.h"
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for measurement vector used by Kalman filter
+//  ------------------------------
+//
+ClassImp(TVKalState)
+
+TVKalState::TVKalState(Int_t type, Int_t p)
+                  : TKalMatrix(p,1),
+                    fType(type),
+                    fSitePtr(0),
+                    fF(p,p),
+                    fFt(p,p),
+                    fQ(p,p),
+                    fC(p,p)
+{
+   fF.UnitMatrix();
+   fFt.UnitMatrix();
+}
+
+TVKalState::TVKalState(const TKalMatrix &sv, 
+                       Int_t type, Int_t p)
+                  : TKalMatrix(sv),
+                    fType(type),
+                    fSitePtr(0),
+                    fF(p,p),
+                    fFt(p,p),
+                    fQ(p,p),
+                    fC(p,p)
+{
+   fF.UnitMatrix();
+   fFt.UnitMatrix();
+}
+
+TVKalState::TVKalState(const TKalMatrix &sv, const TKalMatrix &c,
+                       Int_t type, Int_t p)
+                  : TKalMatrix(sv),
+                    fType(type),
+                    fSitePtr(0),
+                    fF(p,p),
+                    fFt(p,p),
+                    fQ(p,p),
+                    fC(c)
+{
+   fF.UnitMatrix();
+   fFt.UnitMatrix();
+}
+
+TVKalState::TVKalState(const TKalMatrix &sv, const TVKalSite &site, 
+                       Int_t type, Int_t p)
+                  : TKalMatrix(sv),
+                    fType(type),
+                    fSitePtr((TVKalSite *)&site),
+                    fF(p,p),
+                    fFt(p,p),
+                    fQ(p,p),
+                    fC(p,p)
+{
+   fF.UnitMatrix();
+   fFt.UnitMatrix();
+}
+
+TVKalState::TVKalState(const TKalMatrix &sv, const TKalMatrix &c,
+                       const TVKalSite &site, Int_t type, Int_t p)
+                  : TKalMatrix(sv),
+                    fType(type),
+                    fSitePtr((TVKalSite *)&site),
+                    fF(p,p),
+                    fFt(p,p),
+                    fQ(p,p),
+                    fC(c)
+{
+   fF.UnitMatrix();
+   fFt.UnitMatrix();
+}
+
+//-------------------------------------------------------------------
+// Propagate
+//------------------------------------------------------------------
+
+void TVKalState::Propagate(TVKalSite &to)
+{
+   // Calculate 
+   //    prea:	predicted state vector      : a^k-1_k = f_k-1(a_k-1)
+   //    fF:    propagator derivative       : F_k-1   = (@f_k-1/@a_k-1)
+   //    fQ:    process noise from k-1 to k : Q_k-1)
+
+   TVKalState &prea    = MoveTo(to,fF,fQ);
+   TVKalState *preaPtr = &prea;
+
+   fFt = TKalMatrix(TKalMatrix::kTransposed, fF);
+
+   // Calculate covariance matrix
+
+   TKalMatrix preC = fF * fC * fFt + fQ;
+
+   // Set predicted state vector and covariance matrix to next site
+
+   prea.SetCovMat(preC);
+   to.Add(preaPtr);
+   to.SetOwner();
+}
diff --git a/Utilities/KalTest/src/kallib/TVKalState.h b/Utilities/KalTest/src/kallib/TVKalState.h
new file mode 100644
index 0000000000000000000000000000000000000000..38efabd27814efd840f65834261512184024ed5a
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/TVKalState.h
@@ -0,0 +1,90 @@
+#ifndef TVKALSTATE_H
+#define TVKALSTATE_H
+//*************************************************************************
+//* ====================
+//*  TVKalState Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class for a state vector used in Kalman Filter.
+//* (Requires)
+//* 	TKalMatrix
+//* (Provides)
+//* 	class TVKalState
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*
+//*************************************************************************
+//
+#include "TKalMatrix.h"
+class TVKalSite;
+//_____________________________________________________________________
+//  -----------------------------------
+//  Base Class for Kalman state vector
+//  -----------------------------------
+//
+class TVKalState : public TKalMatrix { 
+public:
+
+   // Ctors and Dtor
+
+   TVKalState(Int_t type = 0, Int_t p = 6);
+   TVKalState(const TKalMatrix &sv, Int_t type = 0, Int_t p = 6);
+   TVKalState(const TKalMatrix &sv, const TKalMatrix &c, 
+              Int_t type = 0, Int_t p = 6);
+   TVKalState(const TKalMatrix &sv, const TVKalSite &site, 
+              Int_t type = 0, Int_t p = 6);
+   TVKalState(const TKalMatrix &sv, const TKalMatrix &c,
+              const TVKalSite &site, Int_t type = 0, Int_t p = 6);
+   virtual ~TVKalState() {}
+
+   // Pure virtuals to be implemented in derived classes
+   //
+   // MoveTo should calculate
+   //    a:  predicted state vector      : a^k-1_k = f_k-1(a_k-1)
+   //    F:  propagator derivative       : F_k-1   = (@f_k-1/@a_k-1)
+   //    Q:  process noise from k-1 to k : Q_k-1)
+   // and return a^k-1_k.
+   //
+
+   virtual TVKalState * MoveTo(TVKalSite  &to,
+                               TKalMatrix &F,
+                               TKalMatrix *QPtr = 0) const = 0;
+   virtual TVKalState & MoveTo(TVKalSite  &to,
+                               TKalMatrix &F,
+                               TKalMatrix &Q) const = 0;
+
+   virtual void         DebugPrint() const = 0;
+
+   virtual void         Propagate(TVKalSite &to); // calculates f, F, and Q
+ 
+   
+   // Getters
+
+   inline virtual Int_t GetDimension                () const { return GetNrows(); }
+   inline virtual const TVKalSite  & GetSite        () const { return *fSitePtr; }
+   inline virtual const TKalMatrix & GetCovMat      () const { return fC; }
+   inline virtual const TKalMatrix & GetProcNoiseMat() const { return fQ; }
+   inline virtual const TKalMatrix & GetPropMat     (const Char_t *t = "") const { return (t[0] == 'T' ? fFt : fF); } 
+
+   // Setters
+
+   inline virtual void SetStateVec    (const TKalMatrix &c) { TMatrixD::operator=(c); }
+   inline virtual void SetCovMat      (const TKalMatrix &c) { fC       = c; }
+   inline virtual void SetProcNoiseMat(const TKalMatrix &q) { fQ       = q; }
+   inline virtual void SetSitePtr     (TVKalSite  *s)       { fSitePtr = s; }
+
+private:
+   
+   // private data members -------------------------------------------
+
+   Int_t       fType;    // (0,1,2,3) = (uninited,predicted,filtered,smoothed)
+   TVKalSite  *fSitePtr; // pointer to corresponding KalSite
+   TKalMatrix  fF;       // propagator matrix to next site (F = @f/@a)
+   TKalMatrix  fFt;      // transposed propagator matrix (F^T = (@f/@a)^T)
+   TKalMatrix  fQ;       // process noise from this to the next sites
+   TKalMatrix  fC;       // covariance matrix
+  
+   ClassDef(TVKalState,1)      // Base class for state vector objects
+};
+#endif
diff --git a/Utilities/KalTest/src/kallib/TVKalSystem.cxx b/Utilities/KalTest/src/kallib/TVKalSystem.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..5c4bee34568af89f0be4b9c1d16083b9778aa389
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/TVKalSystem.cxx
@@ -0,0 +1,153 @@
+//*************************************************************************
+//* ====================
+//*  TVKalSystem Class
+//* ====================
+//*
+//* (Description)
+//*   This is the base class of Kalman filter.
+//* (Requires)
+//* 	TObject
+//* (Provides)
+//* 	class TVKalSystem
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*   2009/06/18  K.Fujii       Implement inverse Kalman filter
+//*
+//*************************************************************************
+
+#include <iostream>
+#include <cstdlib>
+#include "TVKalSystem.h"
+#include "TVKalState.h"
+
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for measurement vector used by Kalman filter
+//  ------------------------------
+//
+ClassImp(TVKalSystem)
+
+TVKalSystem *TVKalSystem::fgCurInstancePtr = 0;
+
+TVKalSystem::TVKalSystem(Int_t n) 
+            :TObjArray(n),
+             fCurSitePtr(0),
+             fChi2(0.)
+{
+   if (!fgCurInstancePtr) fgCurInstancePtr = this;
+}
+
+TVKalSystem::~TVKalSystem() 
+{
+   if (this == fgCurInstancePtr) fgCurInstancePtr = 0;
+}
+
+//-------------------------------------------------------
+// AddAndFilter 
+//-------------------------------------------------------
+
+Bool_t TVKalSystem::AddAndFilter(TVKalSite &next)
+{
+   SetCurInstancePtr(this);
+
+   //
+   // Propagate current state to the next site
+   //
+
+   GetState(TVKalSite::kFiltered).Propagate(next);
+   
+   //
+   // Calculate new pull and gain matrix
+   //
+
+   if (next.Filter()) {
+      //
+      // Add this to the system if accepted.
+      //
+
+      Add(&next);
+      fChi2 += next.GetDeltaChi2();
+      return kTRUE;
+   } else {
+      return kFALSE; 
+   }
+}
+
+//-------------------------------------------------------
+// GetNDF
+//-------------------------------------------------------
+
+Int_t TVKalSystem::GetNDF(Bool_t self)
+{
+   Int_t ndf    = 0;
+   Int_t nsites = GetEntries();
+   for (Int_t isite=1; isite<nsites; isite++) {
+       TVKalSite &site = *static_cast<TVKalSite *>(At(isite));
+       if (!site.IsLocked()) ndf += site.GetDimension();
+   }
+   if (self) ndf -= GetCurSite().GetCurState().GetDimension();
+   return ndf;
+}
+
+//-------------------------------------------------------
+// SmoothBackTo 
+//-------------------------------------------------------
+
+void TVKalSystem::SmoothBackTo(Int_t k)
+{
+   TIter previous(this,kIterBackward);
+   TIter cur     (this,kIterBackward);
+
+   TVKalSite  *prePtr;
+   TVKalSite  *curPtr = static_cast<TVKalSite *>(cur());
+   TVKalState &cura   = curPtr->GetState(TVKalSite::kFiltered);
+   TVKalState &scura  = curPtr->GetState(TVKalSite::kSmoothed); 
+   if (!&scura) {
+      curPtr->Add(&curPtr->CreateState(cura, cura.GetCovMat(),
+                                       TVKalSite::kSmoothed));
+   }
+
+   while ((curPtr = static_cast<TVKalSite *>(cur())) && 
+          (prePtr = static_cast<TVKalSite *>(previous()))) {
+      curPtr->Smooth(*prePtr);
+      fCurSitePtr = curPtr;
+      if (IndexOf(curPtr) == k) break;
+   }
+}
+
+//-------------------------------------------------------
+// SmoothAll 
+//-------------------------------------------------------
+
+void TVKalSystem::SmoothAll()
+{
+   SmoothBackTo(0);
+}
+
+//-------------------------------------------------------
+// InvFilter
+//-------------------------------------------------------
+
+void TVKalSystem::InvFilter(Int_t k)
+{
+   using namespace std;
+   //
+   // Check if site k exists
+   //
+   TVKalSite  *curPtr = static_cast<TVKalSite *>(At(k));
+   if (!curPtr) {
+      cerr << "::::: ERROR in TVKalSystem::InvFilter(k=" << k << ")"  << endl
+           << "  Site " << k << " nonexistent! Abort!"
+           << endl;
+      ::abort();
+   }
+   //
+   // Check if site k already smoothed
+   //
+   if (!&curPtr->GetState(TVKalSite::kSmoothed)) SmoothBackTo(k);
+   //
+   // Inverse filter site k
+   //
+   fCurSitePtr = curPtr;
+   curPtr->InvFilter();
+}
diff --git a/Utilities/KalTest/src/kallib/TVKalSystem.h b/Utilities/KalTest/src/kallib/TVKalSystem.h
new file mode 100644
index 0000000000000000000000000000000000000000..fff6d5a8631cb0211e9b8af29e6b6dbe34af8987
--- /dev/null
+++ b/Utilities/KalTest/src/kallib/TVKalSystem.h
@@ -0,0 +1,82 @@
+#ifndef TVKALSYSTEM_H
+#define TVKALSYSTEM_H
+//*************************************************************************
+//* ===================
+//*  TVKalSystem Class
+//* ===================
+//*
+//* (Description)
+//*   Base class for Kalman filtering class
+//* (Requires)
+//* 	TObjArray
+//* (Provides)
+//* 	class TVKalSystem
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*   2005/08/25  A.Yamaguchi	Added fgCurInstancePtr and its getter & setter.
+//*   2009/06/18  K.Fujii       Implement inverse Kalman filter
+//*
+//*************************************************************************
+
+#include "TObjArray.h"
+#include "TVKalSite.h"
+
+//_____________________________________________________________________
+//  ------------------------------
+//  Kalman Filtering class
+//  ------------------------------
+//
+class TKalMatrix;
+
+class TVKalSystem : public TObjArray {
+friend class TVKalSite;
+public:
+
+   // Ctors and Dtor
+
+   TVKalSystem(Int_t n = 1);
+   virtual ~TVKalSystem();
+
+   // Utility methods
+
+   virtual Bool_t AddAndFilter(TVKalSite &next);
+   virtual void   SmoothBackTo(Int_t k);
+   virtual void   SmoothAll();
+   virtual void   InvFilter(Int_t k);
+
+   inline  void   Add(TObject *obj);
+
+   // Getters
+
+   inline virtual TVKalSite  & GetCurSite()     { return *fCurSitePtr; }
+   inline virtual TVKalState & GetState(TVKalSite::EStType t) 
+                                   { return fCurSitePtr->GetState(t); }
+   inline virtual Double_t     GetChi2() { return fChi2; }
+          virtual Int_t        GetNDF (Bool_t self = kTRUE);
+   
+   static         TVKalSystem *GetCurInstancePtr() { return fgCurInstancePtr; }
+
+   // Setters
+
+private:
+   static void SetCurInstancePtr(TVKalSystem *ksp) { fgCurInstancePtr = ksp; }
+
+private:
+   TVKalSite   *fCurSitePtr;  // pointer to current site
+   Double_t     fChi2;        // current total chi2
+
+   static TVKalSystem *fgCurInstancePtr;  //! currently active instance
+   
+   ClassDef(TVKalSystem,1)  // Base class for Kalman Filter
+};
+
+//=======================================================
+// inline functions
+//=======================================================
+
+void TVKalSystem::Add(TObject *obj)
+{
+   TObjArray::Add(obj); 
+   fCurSitePtr = static_cast<TVKalSite *>(obj);
+}
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/Imakefile b/Utilities/KalTest/src/kaltracklib/Imakefile
new file mode 100644
index 0000000000000000000000000000000000000000..6e2dd20af7efd67d7faf0afb6405974c49c8f9f1
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/Imakefile
@@ -0,0 +1,59 @@
+#include "../../conf/makejsf.tmpl"
+
+LDFLAGS   = /* $(GLIBS) */
+
+INSTALLDIR    = ../..
+SOREV         = 2005.01
+PACKAGENAME   = S4KalTrack
+
+SRCS          = TVTrackHit.$(SrcSuf) \
+		TVMeasLayer.$(SrcSuf) \
+		TKalTrackSite.$(SrcSuf) \
+		TKalTrackState.$(SrcSuf) \
+		TKalTrack.$(SrcSuf) \
+		TKalDetCradle.$(SrcSuf) \
+		TVKalDetector.$(SrcSuf) \
+		TKalFilterCond.$(SrcSuf)
+
+
+OBJS	      =	$(subst .$(SrcSuf),.$(ObjSuf),$(SRCS)) \
+		$(PACKAGENAME)Dict.$(ObjSuf)
+
+HDRS	      = $(subst .$(SrcSuf),.h,$(SRCS)) KalTrackDim.h
+
+DICTNAME      = $(PACKAGENAME)Dict
+
+LIBNAME       = $(PACKAGENAME)
+
+SONAME        = lib$(LIBNAME).$(DllSuf).$(SOREV)
+
+LIBINSTALLDIR = $(INSTALLDIR)/lib
+INCINSTALLDIR = $(INSTALLDIR)/include
+INCPATH	      = -I. -I$(INCINSTALLDIR)
+CXXFLAGS     += $(INCPATH) -O0 -g 
+SHLIBLDFLAGS  = $(DYLIBFLAGS)
+
+all:: $(SONAME)
+
+SharedLibraryTarget($(LIBNAME),$(SOREV),$(OBJS),.,.)
+
+InstallSharedLibrary($(LIBNAME),$(SOREV),$(LIBINSTALLDIR))
+
+InstallMultipleFlags($(HDRS),$(INCINSTALLDIR),-m 644)
+
+clean:: 
+	@rm -f $(OBJS) core *.$(DllSuf) $(DICTNAME).$(SrcSuf) $(DICTNAME).h
+
+depend:: $(SRCS) $(HDRS)
+	for i in $(SRCS); do \
+	rmkdepend -a -- $(CXXFLAGS) $(INCPATH) $(DEPENDFILES) -- $$i; done
+
+distclean:: clean
+	@rm -f $(OBJS) core *.$(DllSuf) *.$(DylibSuf)
+	@rm -f $(DICTNAME).$(SrcSuf) $(DICTNAME).h *~
+	@rm -f $(SONAME) *.root Makefile
+
+$(DICTNAME).$(SrcSuf): $(HDRS) LinkDef.h
+	@echo "Generating dictionary ..."
+	rootcint -f $(DICTNAME).$(SrcSuf) \
+ 		-c -I$(INCINSTALLDIR) $(HDRS) LinkDef.h
diff --git a/Utilities/KalTest/src/kaltracklib/KalTrackDim.h b/Utilities/KalTest/src/kaltracklib/KalTrackDim.h
new file mode 100644
index 0000000000000000000000000000000000000000..c71efbf0c5ecdacae3df27e50174a612983bebee
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/KalTrackDim.h
@@ -0,0 +1,9 @@
+#ifndef KALDIM_H
+#define KALDIM_H
+#define kMdim 2
+#ifdef __NOT0__
+#define kSdim 5
+#else
+#define kSdim 6
+#endif
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/LinkDef.h b/Utilities/KalTest/src/kaltracklib/LinkDef.h
new file mode 100644
index 0000000000000000000000000000000000000000..4eaa502a09f9e7ce028388220c0cf935ce1184cb
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/LinkDef.h
@@ -0,0 +1,16 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class TVTrackHit+;
+#pragma link C++ class TVMeasLayer+;
+#pragma link C++ class TKalTrackSite+;
+#pragma link C++ class TKalTrackState+;
+#pragma link C++ class TKalTrack+;
+#pragma link C++ class TKalDetCradle+;
+#pragma link C++ class TVKalDetector+;
+#pragma link C++ class TKalFilterCond+;
+
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/TKalDetCradle.cxx b/Utilities/KalTest/src/kaltracklib/TKalDetCradle.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..5f8c643d242d5289b0f8170e2153819cc6ede1ab
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalDetCradle.cxx
@@ -0,0 +1,287 @@
+//*************************************************************************
+//* =====================
+//*  TKalDetCradle Class
+//* =====================
+//*
+//* (Description)
+//*   A singleton class to hold information of detector system
+//*   used in Kalman filter classes.
+//* (Requires)
+//*     TObjArray
+//*     TVKalDetector
+//* (Provides)
+//*     class TKalDetCradle
+//* (Update Recored)
+//*   2005/02/23  A.Yamaguchi  	Original version.
+//*   2005/08/14  K.Fujii        Removed CalcTable(), GetMeasLayerTable(),
+//*                              GetPhiTable(), and GetDir() and added
+//*                              Transport() to do their functions.
+//*   2010/04/06  K.Fujii        Modified Transport() to allow a 1-dim hit,
+//*                              for which pivot is at the expected hit.
+//*
+//*************************************************************************
+
+#include "TKalDetCradle.h"   // from KalTrackLib
+#include "TVMeasLayer.h"     // from KalTrackLib
+#include "TVKalDetector.h"   // from KalTrackLib
+#include "TKalTrackSite.h"   // from KalTrackLib
+#include "TKalTrackState.h"  // from KalTrackLib
+#include "TVSurface.h"       // from GeomLib
+#include <memory>            // from STL
+#include <iostream>          // from STL
+
+ClassImp(TKalDetCradle)
+
+//_________________________________________________________________________
+//  ----------------------------------
+//   Ctors and Dtor
+//  ----------------------------------
+
+TKalDetCradle::TKalDetCradle(Int_t n)
+: TObjArray(n), fIsMSON(kTRUE), fIsDEDXON(kTRUE),
+fDone(kFALSE), fIsClosed(kFALSE)
+{
+}
+
+TKalDetCradle::~TKalDetCradle()
+{
+}
+
+//_________________________________________________________________________
+//  ----------------------------------
+//   Utility Methods
+//  ----------------------------------
+//_________________________________________________________________________
+// -----------------
+//  Install
+// -----------------
+//    installs a sub-detector into this cradle.
+//
+void TKalDetCradle::Install(TVKalDetector &det)
+{
+  if (IsClosed()) {
+    std::cerr << ">>>> Error!! >>>> TKalDetCradle::Install" << std::endl
+    << "      Cradle already closed. Abort!!"     << std::endl;
+    abort();
+  }
+  TIter next(&det);
+  TObject *mlp = 0;  // measment layer pointer
+  while ((mlp = next())) {
+    Add(mlp);
+    dynamic_cast<TAttElement *>(mlp)->SetParentPtr(&det);
+    det.SetParentPtr(this);
+  }
+  fDone = kFALSE;
+}
+
+void TKalDetCradle::Transport(const TKalTrackSite  &from,   // site from
+                              TKalTrackSite  &to,     // site to
+                              TKalMatrix     &sv,     // state vector
+                              TKalMatrix     &F,      // propagator matrix
+                              TKalMatrix     &Q)      // process noise matrix
+{
+  
+  const TVMeasLayer& ml_to = to.GetHit().GetMeasLayer() ;
+  TVector3  x0;
+  this->Transport(from, ml_to, x0, sv, F, Q ) ;
+  
+  THelicalTrack hel(sv, x0, to.GetHit().GetBfield()) ;
+  
+  // ---------------------------------------------------------------------
+  //  Move pivot from last expected hit to actural hit at site to
+  // ---------------------------------------------------------------------
+  
+  if (to.GetDimension() > 1) {
+    
+    double fid = 0.;                            
+    Int_t sdim = sv.GetNrows();              // number of track parameters
+    TKalMatrix DF(sdim, sdim);               // propagator matrix segment
+    
+    hel.MoveTo(to.GetPivot(), fid, &DF);     // move pivot to actual hit (to)
+    F = DF * F;                              // update F accordingly
+    hel.PutInto(sv);                         // save updated hel to sv
+    
+  } else {
+    to.SetPivot(x0);                         // if it is a 1-dim hit
+  }
+  
+}
+
+//
+//
+//
+//_________________________________________________________________________
+// -----------------
+//  Transport
+// -----------------
+//    transports state (sv) from site (from) to layer (ml_to), taking into 
+//    account multiple scattering and energy loss and updates state (sv),
+//    fills pivot in x0, propagator matrix (F), and process noise matrix (Q).
+//
+
+int TKalDetCradle::Transport(const TKalTrackSite  &from,  // site from
+                             const TVMeasLayer    &ml_to, // layer to reach
+                             TVector3       &x0,    // pivot for sv
+                             TKalMatrix     &sv,    // state vector
+                             TKalMatrix     &F,     // propagator matrix
+                             TKalMatrix     &Q)     // process noise matrix
+{
+  // ---------------------------------------------------------------------
+  //  Sort measurement layers in this cradle if not
+  // ---------------------------------------------------------------------
+  if (!fDone) Update();
+	
+  // ---------------------------------------------------------------------
+  //  Locate sites from and to in this cradle
+  // ---------------------------------------------------------------------
+  Int_t  fridx = from.GetHit().GetMeasLayer().GetIndex(); // index of site from
+  Int_t  toidx = ml_to.GetIndex();                        // index of layer to
+  Int_t  di    = fridx > toidx ? -1 : 1;                  // layer increment
+
+  std::auto_ptr<TVTrack> help(&static_cast<TKalTrackState &>
+                              (from.GetCurState()).CreateTrack()); // tmp track
+  
+  TVTrack &hel = *help;
+
+  //=====================
+  // FIXME
+  //=====================
+  TVector3 xfrom = from.GetPivot();                             // get the referenece point 
+  TVector3 xto;                                                 // reference point at destination to be returned by CalcXingPointWith
+  Double_t fito = 0;                                            // deflection angle to destination to be returned by CalcXingPointWith
+  
+  const TVSurface *sfp = dynamic_cast<const TVSurface *>(&ml_to);// surface at destination
+  
+  sfp->CalcXingPointWith(hel, xto, fito, 0);                    // the default tolerance is used
+                                                                // as mode is 0 here the closest point crossing point is taken
+                                                                // this means that if we are at the top of a looping track 
+                                                                // and the point to which we want to move is on the other side of 
+                                                                // the loop but has a lower radius the transport will move down 
+                                                                // through all layers and segfault on reaching index -1
+  
+  //   if( does_cross < 1 ) return does_cross ;
+  
+  TMatrixD dxdphi = hel.CalcDxDphi(fito);                       // tangent vector at destination surface                       
+  TVector3 dxdphiv(dxdphi(0,0),dxdphi(1,0),dxdphi(2,0));        // convert matirix diagonal to vector
+//  Double_t cpa = hel.GetKappa();                                // get pt
+
+  Bool_t isout = -fito*dxdphiv.Dot(sfp->GetOutwardNormal(xto)) < 0 ? kTRUE : kFALSE;  // out-going or in-coming at the destination surface
+  //=====================
+  // ENDFIXME
+  //=====================
+ 
+  TVector3 xx;                               // expected hit position vector
+  Double_t fid     = 0.;                     // deflection angle from the last hit
+  
+  Int_t sdim = sv.GetNrows();                // number of track parameters
+  F.UnitMatrix();                            // set the propagator matrix to the unit matrix
+  Q.Zero();                                  // zero the noise matrix
+  
+  TKalMatrix DF(sdim, sdim);                 // propagator matrix segment
+  
+  // ---------------------------------------------------------------------
+  //  Loop over layers and transport sv, F, and Q step by step
+  // ---------------------------------------------------------------------
+  Int_t ifr = fridx; // set index to the index of the intitial starting layer
+  
+  // here we make first make sure that the helix is at the crossing point of the current surface.
+  // this is necessary to ensure that the material is only accounted for between fridx and toidx
+  // otherwise it is possible to have inconsistencies with material treatment.
+  // loop until we reach the index toidx, which is the surface we need to reach
+  for (Int_t ito=fridx; (di>0 && ito<=toidx)||(di<0 && ito>=toidx); ito += di) {
+    
+    Double_t fid_temp = fid; // deflection angle from the last layer crossing
+    
+    int mode = ito!=fridx ? di : 0; // need to move to the from site as the helix may not be on the crossing point yet, meaning that the eloss and ms will be incorrectely attributed ...
+
+    if (dynamic_cast<TVSurface *>(At(ito))->CalcXingPointWith(hel, xx, fid, mode)) { // if we have a crossing point at this surface, note di specifies if we are moving forwards or backwards
+      
+      //=====================
+      // FIXME
+      //=====================
+      static const Double_t kMergin = 1.0;
+      // if the distance from the current crossing point to the starting point - kMergin(1mm) is greater than the distance from the destination to the starting point
+      // this is needed to skip crossing points which come from the far side of the IP, for a cylinder this would not be a problem
+      // but for the bounded planes it is perfectly posible due to the sorting in R
+      // reset the deflection angle and skip this layer
+      // this would at stop layers being added which are too far away but I am not sure how this will work with the problem described above. 
+      if( (xx-xfrom).Mag() - kMergin > (xto-xfrom).Mag() ){  
+        fid = fid_temp;
+        continue ;
+      }
+      //=====================
+      // ENDFIXME
+      //=====================
+      const TVMeasLayer   &ml  = *dynamic_cast<TVMeasLayer *>(At(ifr)); // get the last layer 
+      
+      TKalMatrix Qms(sdim, sdim);                                       
+      if (IsMSOn()&& ito!=fridx ){
+        
+        ml.CalcQms(isout, hel, fid, Qms);                   // Qms for this step, using the fact that the material was found to be outgoing or incomming above, and the distance from the last layer 
+      }
+      
+      hel.MoveTo(xx, fid, &DF);         // move the helix to the present crossing point, DF will simply have its values overwritten so it could be explicitly set to unity here
+      if (sdim == 6) DF(5, 5) = 1.;     // t0 stays the same
+      F = DF * F;                       // update F
+      TKalMatrix DFt  = TKalMatrix(TMatrixD::kTransposed, DF);
+      
+      Q = DF * (Q + Qms) * DFt;         // transport Q to the present crossing point
+      
+      if (IsDEDXOn() && ito!=fridx) {
+        hel.PutInto(sv);                              // copy hel to sv
+                                                      // whether the helix is moving forwards or backwards is calculated using the sign of the charge and the sign of the deflection angle  
+                                                      // Bool_t isfwd = ((cpa > 0 && df < 0) || (cpa <= 0 && df > 0)) ? kForward : kBackward;  // taken from TVMeasurmentLayer::GetEnergyLoss  not df = fid
+        sv(2,0) += ml.GetEnergyLoss(isout, hel, fid); // correct for dE/dx, returns delta kappa i.e. the change in pt 
+        hel.SetTo(sv, hel.GetPivot());                // save sv back to hel
+      }
+      ifr = ito; // for the next iteration set the "previous" layer to the current layer moved to 
+
+
+    } else {  // if there is no crossing point reset fid to its original value:
+
+      fid = fid_temp ;
+    }
+
+  } // end of loop over surfaces
+  
+  //   // ---------------------------------------------------------------------
+  //   //  Move pivot to crossing point with layer to move to 
+  //   // ---------------------------------------------------------------------
+  //   dynamic_cast<const TVSurface *>(&ml_to)->CalcXingPointWith(hel, xx, fid);
+  //   hel.MoveTo(xx, fid, &DF); // move pivot to expected hit, DF will simply have its values overwritten so it could be explicitly set to unity here
+  //   F = DF * F;                          // update F accordingly
+  
+  x0 = hel.GetPivot() ;
+  hel.PutInto(sv);                     // save updated hel to sv
+  
+  return 0;
+  
+}
+
+
+
+//_________________________________________________________________________
+// -----------------
+//  Update
+// -----------------
+//    sorts meaurement layers according to layer's sorting policy
+//    and puts index to layers from inside to outside.
+//
+void TKalDetCradle::Update()
+{
+  fDone = kTRUE;
+  
+  UnSort();   // unsort
+  Sort();     // sort layers according to sorting policy
+  
+  TIter next(this);
+  TVMeasLayer *mlp = 0;
+  Int_t i = 0;
+  
+  while ((mlp = dynamic_cast<TVMeasLayer *>(next()))) {
+    mlp->SetIndex(i++);
+  }
+  
+}
+
+
diff --git a/Utilities/KalTest/src/kaltracklib/TKalDetCradle.h b/Utilities/KalTest/src/kaltracklib/TKalDetCradle.h
new file mode 100644
index 0000000000000000000000000000000000000000..f666378e82b7ed68bad514fd3218e4efd3556ea2
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalDetCradle.h
@@ -0,0 +1,84 @@
+#ifndef TKALDETCRADLE_H
+#define TKALDETCRADLE_H
+//*************************************************************************
+//* =====================
+//*  TKalDetCradle Class
+//* =====================
+//*
+//* (Description)
+//*   A sigleton to hold information of detector system
+//*   used in Kalman filter classes.
+//* (Requires)
+//* 	TObjArray
+//* 	TVKalDetector
+//* (Provides)
+//* 	class TKalDetCradle
+//* (Update Recored)
+//*   2005/02/23  A.Yamaguchi	 Original Version.
+//*   2005/08/14  K.Fujii        Removed CalcTable(), GetMeasLayerTable(),
+//*                              GetPhiTable(), and GetDir() and added
+//*                              Transport() to do their functions.
+//*   2010/04/06  K.Fujii        Modified Transport() to allow a 1-dim hit,
+//*                              for which pivot is at the xpected hit.
+//*
+//*************************************************************************
+
+#include "TObjArray.h"     // from ROOT
+#include "TAttElement.h"   // from Utils
+#include "TKalMatrix.h"    // from KalTrackLib
+
+class TKalTrackSite;
+class TVKalDetector;
+class TVMeasLayer;
+
+//_____________________________________________________________________
+//  ------------------------------
+//   Detector system class
+//  ------------------------------
+
+class TKalDetCradle : public TObjArray, public TAttElement {
+public:
+   TKalDetCradle(Int_t n = 1);
+   virtual ~TKalDetCradle();
+
+   // Utility methods
+   virtual void Install(TVKalDetector &det);
+
+   inline virtual void   SwitchOnMS   ()       { fIsMSON = kTRUE;    }
+   inline virtual void   SwitchOffMS  ()       { fIsMSON = kFALSE;   }
+   inline virtual void   SwitchOnDEDX ()       { fIsDEDXON = kTRUE;  }
+   inline virtual void   SwitchOffDEDX()       { fIsDEDXON = kFALSE; }
+   inline virtual void   Close        ()       { fIsClosed = kTRUE; Update(); }
+   inline virtual void   Reopen       ()       { fIsClosed = kFALSE; }
+   inline virtual Bool_t IsMSOn       () const { return fIsMSON;     }
+   inline virtual Bool_t IsDEDXOn     () const { return fIsDEDXON;   }
+   inline virtual Bool_t IsClosed     () const { return fIsClosed;   }
+
+   void Transport(const TKalTrackSite  &from, // site from
+                        TKalTrackSite  &to,   // site to
+                        TKalMatrix     &sv,   // state vector
+                        TKalMatrix     &F,    // propagator matrix
+                        TKalMatrix     &Q);   // process noise matrix
+
+   int Transport(const TKalTrackSite  &from, // site from
+                 const TVMeasLayer    &to,   // layer to reach
+		       TVector3       &x0,   // intersection point 
+		       TKalMatrix     &sv,   // state vector
+		       TKalMatrix     &F,    // propagator matrix
+		       TKalMatrix     &Q);   // process noise matrix
+
+
+
+private:
+   void Update();
+
+private:
+   Bool_t    fIsMSON;         //! switch for multiple scattering
+   Bool_t    fIsDEDXON;       //! switch for energy loss
+   Bool_t    fDone;           //! flag to tell if sorting done
+   Bool_t    fIsClosed;       //! flag to tell if cradle closed
+
+   ClassDef(TKalDetCradle,1)  // Base class for detector system
+};
+
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/TKalFilterCond.cxx b/Utilities/KalTest/src/kaltracklib/TKalFilterCond.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..64579bfbc8402591a8a6de615988eac083e77fdc
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalFilterCond.cxx
@@ -0,0 +1,42 @@
+//*************************************************************************
+//* =====================
+//*  TKalFilterCond Class
+//* =====================
+//*
+//* (Description)
+//*   A class to specify filter conditions used in Kalman filter.
+//* (Requires)
+//* (Provides)
+//* 	class TKalFilterCond
+//* (Update Recored)
+//*   2010/04/06  K.Fujii        Original Version.
+//*
+//*************************************************************************
+
+#include "TKalFilterCond.h"
+#include "TKalTrackSite.h"
+#include <iostream>
+
+//_____________________________________________________________________
+//  ------------------------------
+//   Filter condition class
+//  ------------------------------
+
+ClassImp(TKalFilterCond)
+
+Bool_t TKalFilterCond::IsAccepted(const TKalTrackSite &site)
+{
+#if 0
+   // return kTRUE if this site is acceptable
+   using namespace std;
+   Double_t delchi2 = site.GetDeltaChi2();
+   if (delchi2 > 25.) {
+      cerr << ">>>> TKalFilterCond::IsAccepted >>>>>>>>>>>>> " << endl
+           << " Too big chi2 increment!!! " << endl;
+      site.DebugPrint();
+      return kFALSE;
+   }
+#else
+   return kTRUE;
+#endif
+}
diff --git a/Utilities/KalTest/src/kaltracklib/TKalFilterCond.h b/Utilities/KalTest/src/kaltracklib/TKalFilterCond.h
new file mode 100644
index 0000000000000000000000000000000000000000..54970788ac7d340c1ae14559465ad53d1a0ce907
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalFilterCond.h
@@ -0,0 +1,35 @@
+#ifndef TKALFILTERCOND_H
+#define TKALFILTERCOND_H
+//*************************************************************************
+//* =====================
+//*  TKalFilterCond Class
+//* =====================
+//*
+//* (Description)
+//*   A class to specify filter conditions used in Kalman filter.
+//* (Requires)
+//* (Provides)
+//* 	class TKalFilterCond
+//* (Update Recored)
+//*   2010/04/06  K.Fujii        Original Version.
+//*
+//*************************************************************************
+#include "Rtypes.h"
+//_____________________________________________________________________
+//  ------------------------------
+//   Filter condition class
+//  ------------------------------
+
+class TKalTrackSite;
+
+class TKalFilterCond {
+ public:
+  
+  // need virtual destructor is we have virtual functions
+  virtual ~TKalFilterCond() {};
+  
+  virtual Bool_t IsAccepted(const TKalTrackSite &site);
+  
+  ClassDef(TKalFilterCond,1)  // Base class for detector system
+    };
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/TKalTrack.cxx b/Utilities/KalTest/src/kaltracklib/TKalTrack.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..23ae6a2033bd4e619eba606e0ccb2064ec1b608b
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalTrack.cxx
@@ -0,0 +1,181 @@
+//*************************************************************************
+//* =================
+//*  TKalTrack Class
+//* =================
+//*
+//* (Description)
+//*   Track class for Kalman filter
+//* (Requires)
+//*     TVKalSystem
+//* (Provides)
+//*     class TKalTrack
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima   Original version.
+//*   2005/02/23  A.Yamaguchi   Added a new data member, fMass.
+//*   2005/08/25  K.Fujii       Added drawable attribute.
+//*   2005/08/26  K.Fujii       Removed drawable attribute.
+//*
+//*************************************************************************
+                                                                                
+#include "TKalTrackState.h"    // from KalTrackLib
+#include "TKalTrackSite.h"     // from KalTrackLib
+#include "TKalTrack.h"         // from KalTrackLib
+#include <iostream>            // from STL
+
+using namespace std;
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+#else
+const Double_t TKalTrack::kMpi = 0.13957018; // pion mass [GeV]
+#endif
+
+
+//_________________________________________________________________________
+//  ------------------------------
+//   TKalTrack: Kalman rack class
+//  ------------------------------
+
+ClassImp(TKalTrack)
+                                                                                
+//_________________________________________________________________________
+//  ----------------------------------
+//   Ctor
+//  ----------------------------------
+TKalTrack::TKalTrack(Int_t n)
+          :TVKalSystem(n), fMass(kMpi)
+{
+}
+
+//_________________________________________________________________________
+//  ----------------------------------
+//   Utility Method
+//  ----------------------------------
+//_________________________________________________________________________
+// -----------------
+//  FitToHelix
+// -----------------
+//    chi^2-fits hits belonging to this track to a single helix.
+//
+Double_t TKalTrack::FitToHelix(TKalTrackState &a, TKalMatrix &C, Int_t &ndf)
+{
+   // Define static constants...
+ 
+   static const Double_t kChi2Dum = 1.e20;
+   static const Double_t kChi2Tol = 1.e-8;
+   static const Double_t kLambda  = 1.;
+   static const Double_t kLincr   = 10.;
+   static const Double_t kLdecr   = 0.1;
+   static const Int_t    kLoopMax = 100;
+
+   // Initialize return values...
+
+   TKalTrackState abest(a);
+   Double_t   chi2best = kChi2Dum;
+   Double_t   lambda   = kLambda;
+   Int_t      nloops   = 0;
+
+   ndf = 0;
+   Int_t      nsites   = 0;
+   Double_t   chi2     = 0.;
+
+   // Prepare som matrices
+
+   TIter      next(this);
+   TKalTrackSite &site0 = *(TKalTrackSite *)next();
+
+   Int_t mdim = site0.GetDimension();
+   Int_t sdim = site0.GetCurState().GetDimension();
+
+   TKalMatrix    dchi2dabest(1   , sdim);
+   TKalMatrix    dchi2da    (1   , sdim);
+   TKalMatrix    d2chi2dada (sdim, sdim);
+   TKalMatrix    d2chi2best (sdim, sdim);
+   TKalMatrix    curh       (mdim, 1   );
+   TKalMatrix    curH       (mdim, sdim);
+   TKalMatrix    curHt      (sdim, mdim);
+   TKalMatrix    curVinv    (mdim, mdim);
+   TKalMatrix    curResVec  (mdim, 1   );
+
+   // Minimization loop starts here
+
+   while (1) {
+       if (nloops > kLoopMax) {
+          cerr << "TKalTrack::FitToHelix >>>>>>>>>>>>>>"
+               << " Loop count limit reached. nloops = " << nloops << endl;
+          a = abest;
+          chi2  = chi2best;
+          break;
+       }
+       nloops++;
+
+       d2chi2dada.Zero();
+       dchi2da.Zero();
+       chi2 = 0;
+
+       // Loop over hits and accumulate chi2
+
+       next.Reset();
+       TKalTrackSite *sitePtr = 0;
+       nsites  = 0;
+       while ((sitePtr = (TKalTrackSite *)next())) {
+           TKalTrackSite   &site = *sitePtr;
+
+           if (site.IsLocked())                      continue;
+           if (!site.CalcExpectedMeasVec  (a, curh)) continue;
+           if (!site.CalcMeasVecDerivative(a, curH)) continue;
+           nsites++;	// site accepted
+
+           //dchi2/da
+           curVinv   = TKalMatrix(TKalMatrix::kInverted,site.GetMeasNoiseMat());
+           curResVec = site.GetMeasVec() - curh;
+
+           TKalMatrix curResVecT(TKalMatrix::kTransposed, curResVec);
+           dchi2da += (curResVecT * curVinv * curH);
+
+           // accumulate chi2
+           Double_t delchi2 = (curResVecT * curVinv * curResVec)(0,0);
+           chi2 += delchi2;
+
+           // inverse covariance matrix
+           TKalMatrix curHt(TKalMatrix::kTransposed, curH);
+           d2chi2dada += (curHt * curVinv * curH);
+       }
+
+       //
+       // if (chi2best - chi2) < kChi2Tol, break while loop.
+       //
+
+       if (TMath::Abs(chi2best - chi2) < kChi2Tol) {
+           d2chi2best = d2chi2dada;
+           break;
+       }
+
+       if (chi2 < chi2best) {
+           // chi2 decreased. Save this step as the current best
+           chi2best    = chi2;
+           abest       = (TKalTrackState &)a;
+           dchi2dabest = dchi2da;
+           d2chi2best  = d2chi2dada;
+           lambda     *= kLdecr;
+       } else {
+           // chi2 increased. Restore the current best
+           dchi2da     = dchi2dabest;
+           d2chi2dada  = d2chi2best;
+           lambda     *= kLincr;
+       }
+
+       // Modify the 2nd derivative and try again
+
+       for (Int_t i=0; i<sdim; i++) {
+           d2chi2dada(i, i) *= (1 + lambda);
+       }
+
+       TKalMatrix d2chi2dadainv(TKalMatrix::kInverted, d2chi2dada);
+       TKalMatrix dchi2daT     (TKalMatrix::kTransposed, dchi2da);
+       a += (d2chi2dadainv * dchi2daT);
+   }
+
+   ndf  = nsites * mdim - sdim;
+   C    = TKalMatrix(TKalMatrix::kInverted, d2chi2best);
+
+   return chi2;
+}
diff --git a/Utilities/KalTest/src/kaltracklib/TKalTrack.h b/Utilities/KalTest/src/kaltracklib/TKalTrack.h
new file mode 100644
index 0000000000000000000000000000000000000000..13540c2928d7392307ba46445c0c57fd7838de66
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalTrack.h
@@ -0,0 +1,54 @@
+#ifndef TKALTRACK_H
+#define TKALTRACK_H
+//*************************************************************************
+//* =================
+//*  TKalTrack Class
+//* =================
+//*
+//* (Description)
+//*   Track class for Kalman filter
+//* (Requires)
+//*     TVKalSystem
+//* (Provides)
+//*     class TKalTrack
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima	Original version.
+//*   2005/02/23  A.Yamaguchi	Added a new data member fMass and its
+//*                             getter and setter.
+//*   2005/08/15  K.Fujii       Removed fDir and its getter and setter.
+//*   2005/08/25  K.Fujii       Added Drawable attribute.
+//*   2005/08/26  K.Fujii       Removed Drawable attribute.
+//*
+//*************************************************************************
+                                                                                
+#include "TVKalSystem.h"       // from KalLib
+#include "TKalTrackState.h"    // from KalTrackLib
+
+//_________________________________________________________________________
+//  ------------------------------
+//   TKalTrack: Kalman Track class
+//  ------------------------------
+                                                                                
+class TKalTrack : public TVKalSystem {
+public:
+   TKalTrack(Int_t n = 1);
+   ~TKalTrack() {}
+
+   inline virtual void      SetMass(Double_t m)           { fMass = m;    }
+   inline virtual Double_t  GetMass()             const   { return fMass; }
+
+   Double_t FitToHelix(TKalTrackState &a, TKalMatrix &C, Int_t &ndf);
+
+private:
+   Double_t     fMass;        // mass [GeV]
+
+#if __GNUC__ < 4 && !defined(__STRICT_ANSI__)
+   static const Double_t kMpi = 0.13957018; //! pion mass [GeV]
+#else
+   static const Double_t kMpi;              //! pion mass [GeV]
+#endif
+
+   ClassDef(TKalTrack,1)  // Base class for Kalman Filter
+};
+
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/TKalTrackSite.cxx b/Utilities/KalTest/src/kaltracklib/TKalTrackSite.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..528fede6e88df4c7f951095e5c178e512a64fdac
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalTrackSite.cxx
@@ -0,0 +1,161 @@
+//*************************************************************************
+//* =====================
+//*  TKalTrackSite Class
+//* =====================
+//*
+//* (Description)
+//*   Track measurement site class used by Kalman filter.
+//* (Requires)
+//*     TKalTrackState
+//* (Provides)
+//*     class TKalTrackSite
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2010/04/06  K.Fujii           Modified a c-tor to allow a 1-dim hit,
+//*                                 for which pivot is at the xpected hit.
+//*                                 Modified IsAccepted() to allow user-
+//*                                 defined filter conditions.
+//*
+//*************************************************************************
+
+#include "TKalTrackSite.h"    // from KalTrackLib
+#include "TKalTrackState.h"   // from KalTrackLib
+#include "TVTrackHit.h"       // from KalTrackLib
+#include "TKalFilterCond.h"   // from KalTrackLib
+#include "TVSurface.h"        // from GeomLib
+
+#include <iostream>           // from STL
+#include <memory>             // from STL
+
+using namespace std;
+
+//_________________________________________________________________________
+//  ----------------------------------
+//   Class for measurement site
+//  ----------------------------------
+//
+ClassImp(TKalTrackSite)
+
+//_________________________________________________________________________
+//  ----------------------------------
+//  Ctors and Dtor
+//  ----------------------------------
+TKalTrackSite::TKalTrackSite(Int_t m, Int_t p)
+              : TVKalSite(m,p), fHitPtr(0), fX0(), fIsHitOwner(kFALSE),
+                fCondPtr(0)
+{
+}
+
+TKalTrackSite::TKalTrackSite(const TVTrackHit &ht,
+                                   Int_t       p)
+              : TVKalSite(ht.GetDimension(),p),
+                fHitPtr(static_cast<const TVTrackHit *>(&ht)), 
+                fX0(),
+                fIsHitOwner(kFALSE),
+                fCondPtr(0)
+{
+   for (Int_t i=0; i<ht.GetDimension(); i++) {
+      GetMeasVec     ()(i,0) = ht.GetX(i);
+      GetMeasNoiseMat()(i,i) = TMath::Power(ht.GetDX(i),2);
+   }
+   // Leave the pivot at the origin for a 1-dim hit
+   if (ht.GetDimension() > 1) fX0 = ht.GetMeasLayer().HitToXv(ht);
+}
+
+TKalTrackSite::~TKalTrackSite()
+{
+   if (IsHitOwner() && fHitPtr) delete fHitPtr;
+}
+
+//_________________________________________________________________________
+//  ----------------------------------
+//  Implementation of public methods
+//  ----------------------------------
+
+TVKalState & TKalTrackSite::CreateState(const TKalMatrix &sv, Int_t type)
+{
+   SetOwner();
+   return *(new TKalTrackState(sv,*this,type));
+}
+
+TVKalState & TKalTrackSite::CreateState(const TKalMatrix &sv,
+                                        const TKalMatrix &c,
+                                              Int_t       type)
+{
+   SetOwner();
+   return *(new TKalTrackState(sv,c,*this,type));
+}
+
+Int_t TKalTrackSite::CalcXexp(const TVKalState &a, 
+                                    TVector3   &xx, 
+                                    Double_t   &phi) const
+{
+   std::auto_ptr<TVTrack> hel(&static_cast<const TKalTrackState &>(a).CreateTrack());
+
+   const TVSurface &ms = dynamic_cast<const TVSurface &>(GetHit().GetMeasLayer());
+   return ms.CalcXingPointWith(*hel,xx,phi);
+}
+
+
+
+Int_t TKalTrackSite::CalcExpectedMeasVec(const TVKalState &a, TKalMatrix &h)
+{
+   Double_t phi = 0.;
+   TVector3 xxv;
+   if (!CalcXexp(a,xxv,phi)) return 0;	// no hit
+
+   if (a.GetNrows() == 6) h = GetHit().XvToMv(xxv,a(5,0));
+   else                   h = GetHit().XvToMv(xxv,0.);
+
+   return 1;
+}
+
+Int_t TKalTrackSite::CalcMeasVecDerivative(const TVKalState &a,
+                                                 TKalMatrix &H)
+{
+   // Calculate 
+   //    H = (@h/@a) = (@d/@a, @z/@a)^t
+   // where
+   //        h(a) = (d, z)^t: expected meas vector
+   //        a = (drho, phi0, kappa, dz, tanl, t0)
+   //
+
+   TVector3      xxv;
+   Double_t      phi = 0.;
+
+   if (!CalcXexp(a,xxv,phi)) return 0; // hit on S(x) = 0
+
+   const TVSurface &ms = dynamic_cast<const TVSurface &>(GetHit().GetMeasLayer());
+   TKalMatrix    dsdx(ms.CalcDSDx(xxv));   // (@S(x)/@x)
+
+   std::auto_ptr<TVTrack> hel(&static_cast<const TKalTrackState &>(a).CreateTrack());
+
+   TKalMatrix    dxda   = hel->CalcDxDa(phi);  	     // (@x(phi,a)/@a)
+   TKalMatrix    dxdphi = hel->CalcDxDphi(phi);	     // (@x(phi,a)/@phi)
+
+   TKalMatrix dphida = dsdx * dxda;
+   TKalMatrix dsdphi = dsdx * dxdphi;
+   Double_t denom = -dsdphi(0,0);
+   dphida *= 1/denom;
+
+   TKalMatrix dxphiada = dxdphi * dphida + dxda; // (@x(phi(a),a)/@a)
+
+   GetHit().GetMeasLayer().CalcDhDa(GetHit(), xxv, dxphiada, H); // H = (@h/@a)
+
+   return 1;
+}
+
+Bool_t TKalTrackSite::IsAccepted()
+{
+   if (fCondPtr) return fCondPtr->IsAccepted(*this);
+   else          return kTRUE;
+}
+
+void TKalTrackSite::DebugPrint() const
+{
+   cerr << " dchi2 = " << GetDeltaChi2()   << endl;
+   cerr << " res_d = " << (*(TKalTrackSite *)this).GetResVec()(0,0) << endl;
+   cerr << " res_z = " << (*(TKalTrackSite *)this).GetResVec()(1,0) << endl;
+   fHitPtr->DebugPrint();
+}
+
diff --git a/Utilities/KalTest/src/kaltracklib/TKalTrackSite.h b/Utilities/KalTest/src/kaltracklib/TKalTrackSite.h
new file mode 100644
index 0000000000000000000000000000000000000000..3764e87f58efa5d5c5a3666ca63a003f7a0be391
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalTrackSite.h
@@ -0,0 +1,76 @@
+#ifndef TKALTRACKSITE_H
+#define TKALTRACKSITE_H
+//*************************************************************************
+//* =====================
+//*  TKalTrackSite Class
+//* =====================
+//*
+//* (Description)
+//*   Track measurement site class used by Kalman filter.
+//* (Requires)
+//*     TKalTrackState
+//* (Provides)
+//*     class TKalTrackSite
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2004/09/17  K.Fujii           Added ownership flag.
+//*   2010/04/06  K.Fujii           Added a setter for the pivot and a
+//*                                 condition object
+//*
+//*************************************************************************
+
+#include "TVector3.h"    // from ROOT
+#include "TVKalSite.h"   // from KalLib
+#include "TVTrackHit.h"  // from KalTrackLib
+
+class TVKalState;
+class TKalTrackState;
+class TKalFilterCond;
+
+//_________________________________________________________________________
+//  ---------------------------------
+//  Class for Kalman measurement site
+//  ---------------------------------
+//
+class TKalTrackSite : public TVKalSite {
+public:
+   TKalTrackSite(Int_t m = kMdim, Int_t p = kSdim);
+   TKalTrackSite( const TVTrackHit &ht, 
+                        Int_t       p = kSdim);
+   ~TKalTrackSite();
+
+   Int_t        CalcExpectedMeasVec  (const TVKalState &a, TKalMatrix &h);
+   Int_t        CalcMeasVecDerivative(const TVKalState &a, TKalMatrix &H);
+   Bool_t       IsAccepted();
+
+   void         DebugPrint() const;
+
+   inline const TVTrackHit & GetHit    () const { return *fHitPtr;             }
+   inline const TVector3   & GetPivot  () const { return fX0;                  }
+   inline       Double_t     GetBfield () const { return fHitPtr->GetBfield(); }
+   inline       Bool_t       IsInB     () const { return GetBfield() != 0.;    }
+   inline       Bool_t       IsHitOwner() const { return fIsHitOwner;          }
+
+   inline       void   SetPivot     (const TVector3 &x0)  { fX0 = x0;          }
+   inline       void   SetHitOwner  (Bool_t b=kTRUE)      { fIsHitOwner = b;   }
+   inline       void   SetFilterCond(TKalFilterCond *cp)  { fCondPtr    = cp;  }
+
+private:
+   TVKalState & CreateState(const TKalMatrix &sv, Int_t type = 0);
+   TVKalState & CreateState(const TKalMatrix &sv,
+                            const TKalMatrix &C,
+                                  Int_t       type = 0);
+   Int_t        CalcXexp   (const TVKalState &a, 
+                                  TVector3   &xx,
+                                  Double_t   &phi) const;
+
+private:
+   const TVTrackHit     *fHitPtr;     // pointer to corresponding hit
+         TVector3        fX0;         // pivot
+         Bool_t          fIsHitOwner; // true if site owns hit
+         TKalFilterCond *fCondPtr;    // pointer to filter condition object
+
+   ClassDef(TKalTrackSite,1)  // sample measurement site class
+};
+                                                                                
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/TKalTrackState.cxx b/Utilities/KalTest/src/kaltracklib/TKalTrackState.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..9c0b7a440c2a00a36f8fe537bc83a7445f9c45f0
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalTrackState.cxx
@@ -0,0 +1,161 @@
+//*************************************************************************
+//* ======================
+//*  TKalTrackState Class
+//* ======================
+//*
+//* (Description)
+//*   Track state vector class used in Kalman Filter.
+//* (Requires)
+//*     TVKalState
+//* (Provides)
+//*     class TKalTrackState
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2005/02/23  Y.Yamaguchi       Improved CalcProcessNoise().
+//*   2005/08/14  K.Fujii           Removed CalcProcessNoise() and
+//*                                 let TKalDetCradle::Transport() do its
+//*                                 function.
+//*   2010/04/06  K.Fujii           Modified MoveTo to allow a 1-dim hit,
+//*                                 for which pivot is at the xpected hit.
+//*
+//*************************************************************************
+
+#include "TKalDetCradle.h"      // from KalTrackLib
+#include "TVKalDetector.h"      // from KalTrackLib
+#include "TKalTrackState.h"     // from KalTrackLib
+#include "TKalTrackSite.h"      // from KalTrackLib
+#include "TKalTrack.h"          // from KalTrackLib
+
+#include <iostream>             // from STL
+#include <memory>               // from STL
+
+using namespace std;
+
+//_________________________________________________________________________
+// -----------------------------------
+//  Kalman track state vector
+// -----------------------------------
+//_________________________________________________________________________
+// -----------------
+//  Ctors and Dtor
+// -----------------
+//
+TKalTrackState::TKalTrackState(Int_t p) 
+           : TVKalState(p), fX0()
+{
+}
+
+TKalTrackState::TKalTrackState(const TKalMatrix &sv, Int_t type, Int_t p) 
+           : TVKalState(sv,type,p), fX0()
+{
+}
+
+TKalTrackState::TKalTrackState(const TKalMatrix &sv, const TKalMatrix &c,
+                                     Int_t type, Int_t p) 
+           : TVKalState(sv,c,type,p), fX0()
+{
+}
+
+TKalTrackState::TKalTrackState(const TKalMatrix &sv, const TVKalSite &site,
+                                     Int_t type, Int_t p) 
+           : TVKalState(sv,site,type,p), 
+             fX0(((TKalTrackSite *)&site)->GetPivot())
+{
+}
+
+TKalTrackState::TKalTrackState(const TKalMatrix &sv, const TKalMatrix &c,
+                               const TVKalSite &site, Int_t type, Int_t p) 
+           : TVKalState(sv,c,site,type,p),
+             fX0(((TKalTrackSite *)&site)->GetPivot())
+{
+}
+
+//_________________________________________________________________________
+// ----------------------------------------------
+//  Implementation of base-class pure virtuals
+// ----------------------------------------------
+//
+TKalTrackState * TKalTrackState::MoveTo(TVKalSite  &to,
+                                        TKalMatrix &F,
+                                        TKalMatrix *QPtr) const
+{	
+   if (QPtr) {
+      const TKalTrackSite &from   = static_cast<const TKalTrackSite &>(GetSite());
+            TKalTrackSite &siteto = static_cast<TKalTrackSite &>(to);
+            TKalDetCradle &det    = const_cast<TKalDetCradle &>
+                                       (static_cast<const TKalDetCradle &>
+                                          (from.GetHit().GetMeasLayer().GetParent()));
+      Int_t sdim = GetDimension();
+      TKalMatrix sv(sdim,1);
+      det.Transport(from, siteto, sv, F, *QPtr); // siteto's pivot might be modified
+      if (sdim == 6) {
+         sv(5,0) = (*this)(5,0);
+         F (5,5) = 1.;
+      }
+      return new TKalTrackState(sv, siteto, TVKalSite::kPredicted, sdim);
+   } else {
+      return 0;
+   }
+}
+
+TKalTrackState & TKalTrackState::MoveTo(TVKalSite  &to,
+                                        TKalMatrix &F,
+                                        TKalMatrix &Q) const
+{
+   return *MoveTo(to, F, &Q);
+}
+
+void TKalTrackState::DebugPrint() const
+{
+   cerr << "          +-     -+   " << "+-" <<  endl
+        << "          | drho  |   " << "| " << (*this)(0,0) << endl
+        << "          | phi0  |   " << "| " << (*this)(1,0) << endl
+        << " a      = | kappa | = " << "| " << (*this)(2,0) << endl
+        << "          | dz    |   " << "| " << (*this)(3,0) << endl
+        << "          | tanl  |   " << "| " << (*this)(4,0) << endl;
+   if (GetDimension() == 6) {
+      cerr 
+        << "          | t0    |   " << "| " << (*this)(5,0) << endl;
+   }
+   cerr << "          +-     -+   " << "+-" << endl;
+   cerr << "          +-" << endl 
+        << " X0     = | " << fX0.X() << endl
+        << "          | " << fX0.Y() << endl
+        << "          | " << fX0.Z() << endl
+        << "          +-" << endl;
+   GetCovMat().DebugPrint(" covMat = ", 6);
+}
+
+//_________________________________________________________________________
+// --------------------------------
+//  Derived class methods
+// --------------------------------
+//
+THelicalTrack TKalTrackState::GetHelix() const
+{
+   TKalMatrix a(5,1);
+   for (Int_t i=0; i<5; i++) a(i,0) = (*this)(i,0);
+   return THelicalTrack(a,fX0,((TKalTrackSite *)&GetSite())->GetBfield());
+}
+
+TStraightTrack TKalTrackState::GetLine() const
+{
+   TKalMatrix a(5,1);
+   for (Int_t i=0; i<5; i++) a(i,0) = (*this)(i,0);
+   return TStraightTrack(a,fX0,((TKalTrackSite *)&GetSite())->GetBfield());
+}
+
+TVTrack &TKalTrackState::CreateTrack() const
+{
+   TVTrack *tkp = 0;
+
+   TKalMatrix a(5,1);
+   for (Int_t i=0; i<5; i++) a(i,0) = (*this)(i,0);
+   Double_t bfield = static_cast<const TKalTrackSite &>(GetSite()).GetBfield();
+
+   if (bfield == 0.) tkp = new TStraightTrack(a,fX0);
+   else              tkp = new THelicalTrack(a,fX0, bfield);
+
+   return *tkp;
+}
+
diff --git a/Utilities/KalTest/src/kaltracklib/TKalTrackState.h b/Utilities/KalTest/src/kaltracklib/TKalTrackState.h
new file mode 100644
index 0000000000000000000000000000000000000000..6931adcf0aa8c13fa6029584ca9d154623c152ba
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TKalTrackState.h
@@ -0,0 +1,76 @@
+#ifndef TKALTRACKSTATE_H
+#define TKALTRACKSTATE_H
+//*************************************************************************
+//* ======================
+//*  TKalTrackState Class
+//* ======================
+//*
+//* (Description)
+//*   Track state vector class used in Kalman Filter.
+//* (Requires)
+//*     TVKalState
+//* (Provides)
+//*     class TKalTrackState
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2005/02/23  A.Yamaguchi       Added CalcDapDa method.
+//*   2005/02/XX  A.Yamaguchi       Moved CalcDapDa method to THelicalTrack.
+//*   2005/08/13  K.Fujii           Removed CalcProcessNoise method.
+//*   2010/04/06  K.Fujii           Modified MoveTo to allow a 1-dim hit,
+//*                                 for which pivot is at the xpected hit.
+//*
+//*************************************************************************
+
+#include "TVKalState.h"         // from KalLib
+#include "THelicalTrack.h"      // from GeomLib
+#include "TStraightTrack.h"     // from GeomLib
+#include "KalTrackDim.h"        // from KalTrackLib
+
+class TKalTrackSite;
+
+//_________________________________________________________________________
+//  -----------------------------------
+//  Base Class for Kalman state vector
+//  -----------------------------------
+//
+
+class TKalTrackState : public TVKalState {
+                                                                                
+public:
+                                                                                
+   // Ctors and Dtor
+                                                                                
+   TKalTrackState(Int_t p = kSdim);
+   TKalTrackState(const TKalMatrix &sv, Int_t type = 0, Int_t p = kSdim);
+   TKalTrackState(const TKalMatrix &sv, const TKalMatrix &c, 
+                        Int_t type = 0, Int_t p = kSdim);
+   TKalTrackState(const TKalMatrix &sv, const TVKalSite &site, 
+                        Int_t type = 0, Int_t p = kSdim);
+   TKalTrackState(const TKalMatrix &sv, const TKalMatrix &c,
+                  const TVKalSite &site, Int_t type = 0, Int_t p = kSdim);
+   virtual ~TKalTrackState() {}
+                                                                                
+   // Implementation of paraent class pure virtuals
+                                                                                
+   TKalTrackState * MoveTo(TVKalSite  &to, 
+                           TKalMatrix &F, 
+                           TKalMatrix *QPtr = 0) const;
+   TKalTrackState & MoveTo(TVKalSite  &to, 
+                           TKalMatrix &F, 
+                           TKalMatrix &Q) const;
+   void         DebugPrint() const;
+
+   // Derived class methods
+
+   THelicalTrack   GetHelix() const;
+   TStraightTrack  GetLine () const;
+   TVTrack        &CreateTrack() const;
+
+private:
+
+   TVector3 fX0;		// pivot
+
+   ClassDef(TKalTrackState,1)      // sample state vector class
+};
+                                                                                
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/TVKalDetector.cxx b/Utilities/KalTest/src/kaltracklib/TVKalDetector.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..438b72fe663cfb84d498f3fa9469f358dd6091d5
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TVKalDetector.cxx
@@ -0,0 +1,22 @@
+//*************************************************************************
+//* =====================
+//*  TVKalDetector Class
+//* =====================
+//*
+//* (Description)
+//*   Base class to hold information of detector system
+//*   used in Kalman filter classes.
+//* (Requires)
+//* 	TObjArray
+//* (Provides)
+//* 	class TVKalDetector
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*   2005/08/14  K.Fujii  Moved GetEnergyLoss() and CalcQms() to
+//*                        TVMeasLayer.
+//*
+//*************************************************************************
+
+#include "TVKalDetector.h"
+
+ClassImp(TVKalDetector)
diff --git a/Utilities/KalTest/src/kaltracklib/TVKalDetector.h b/Utilities/KalTest/src/kaltracklib/TVKalDetector.h
new file mode 100644
index 0000000000000000000000000000000000000000..0edc3946f65bd5088081955a42cb7a06be17c948
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TVKalDetector.h
@@ -0,0 +1,39 @@
+#ifndef TVKALDETECTOR_H
+#define TVKALDETECTOR_H
+//*************************************************************************
+//* =====================
+//*  TVKalDetector Class
+//* =====================
+//*
+//* (Description)
+//*   Base class to hold information of detector system
+//*   used in Kalman filter classes.
+//* (Requires)
+//* 	TObjArray
+//* (Provides)
+//* 	class TVKalDetector
+//* (Update Recored)
+//*   2003/09/30  K.Fujii	Original version.
+//*   2005/02/23  A.Yamaguchi	Moved most methods to TKalDetCradle.
+//*
+//*************************************************************************
+
+#include "TObjArray.h"        // from ROOT
+#include "TAttElement.h"      // from Utils
+
+//_________________________________________________________________________
+// ------------------------------
+//  Detector system class
+// ------------------------------
+//
+
+class TVKalDetector : public TObjArray, public TAttElement {
+public:
+   // Ctors and Dtor
+   TVKalDetector(Int_t n = 1) : TObjArray(n) {}
+   virtual ~TVKalDetector() {}
+
+   ClassDef(TVKalDetector,1)  // Base class for detector system
+};
+
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/TVMeasLayer.cxx b/Utilities/KalTest/src/kaltracklib/TVMeasLayer.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..b11457defeacd5aad9269a2493a2d44e633644f4
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TVMeasLayer.cxx
@@ -0,0 +1,179 @@
+//*************************************************************************
+//* ====================
+//*  TVMeasLayer Class
+//* ====================
+//*
+//* (Description)
+//*   Measurement layer interface class.
+//* (Requires)
+//* (Provides)
+//*     class TVMeasLayer
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2005/02/23  A.Yamaguchi       Added new data members, fFwdX0Inv,
+//*                                 fBwdX0Inv and fIndex, and their
+//*                                 corresponding getters and setters.
+//*                                 Added a new method, GetX0Inv().
+//*   2005/0X/XX  A.Yamaguchi       Replaced fFwdX0Inv, fBwdX0Inv, and
+//*                                 their getters and setters by
+//*                                 fMaterialOutPtr, fMaterialInPtr, and
+//*                                 their getters and setters.
+//*   2005/08/15  K.Fujii           Added fIsActive and IsActive().
+//*                                 Moved GetEnergyLoss() and CalcQms()
+//*                                 from TVKalDetector.
+//*   2011/12/03  S.Aplin           Added new member: name 
+//*                                 default value set to "TVMeasLayer"
+//*                                 and corresponding member function
+//*                                 TString GetName()
+//*
+//*************************************************************************
+
+#include "TVMeasLayer.h"  // from KalTrackLib
+#include "TKalTrack.h"    // from KalTrackLib
+#include "TVTrack.h"      // from KalTrackLib
+
+ClassImp(TVMeasLayer)
+
+//_________________________________________________________________________
+// ----------------------------------
+//  Ctor
+// ----------------------------------
+TVMeasLayer::TVMeasLayer(TMaterial     &matIn,
+                         TMaterial     &matOut,
+                         Bool_t         isactive,
+                         const Char_t    *name)
+           : fMaterialInPtr(&matIn),
+             fMaterialOutPtr(&matOut),
+             fIndex(0),
+             fIsActive(isactive),
+             fname(name)
+{
+}
+
+//_________________________________________________________________________
+//  ----------------------------------
+//   Utility Methods
+//  ----------------------------------
+//_________________________________________________________________________
+// -----------------
+//  GetEnergyLoss
+// -----------------
+//    returns energy loss.
+//
+Double_t TVMeasLayer::GetEnergyLoss(      Bool_t    isoutgoing,
+                                    const TVTrack  &hel,
+                                          Double_t  df) const
+{
+   Double_t cpa    = hel.GetKappa();
+   Double_t tnl    = hel.GetTanLambda(); 
+   Double_t tnl2   = tnl * tnl;
+   Double_t tnl21  = 1. + tnl2;
+   Double_t cslinv = TMath::Sqrt(tnl21);
+   Double_t mom2   = tnl21 / (cpa * cpa);
+
+   // -----------------------------------------
+   // Bethe-Bloch eq. (Physical Review D P195.)
+   // -----------------------------------------
+   static const Double_t kK   = 0.307075e-3;     // [GeV*cm^2]
+   static const Double_t kMe  = 0.510998902e-3;  // electron mass [GeV]
+   static const Double_t kMpi = 0.13957018;      // pion mass [GeV]
+
+   TKalTrack *ktp  = static_cast<TKalTrack *>(TVKalSystem::GetCurInstancePtr());
+   Double_t   mass = ktp ? ktp->GetMass() : kMpi;
+
+   const TMaterial &mat = GetMaterial(isoutgoing);
+   Double_t dnsty = mat.GetDensity();		// density
+   Double_t A     = mat.GetA();                 // atomic mass
+   Double_t Z     = mat.GetZ();                 // atomic number
+   //Double_t I    = Z * 1.e-8;			// mean excitation energy [GeV]
+   //Double_t I    = (2.4 +Z) * 1.e-8;		// mean excitation energy [GeV]
+   Double_t I    = (9.76 * Z + 58.8 * TMath::Power(Z, -0.19)) * 1.e-9;
+   Double_t hwp  = 28.816 * TMath::Sqrt(dnsty * Z/A) * 1.e-9;
+   Double_t bg2  = mom2 / (mass * mass);
+   Double_t gm2  = 1. + bg2;
+   Double_t meM  = kMe / mass;
+   Double_t x    = log10(TMath::Sqrt(bg2));
+   Double_t C0   = - (2. * log(I/hwp) + 1.);
+   Double_t a    = -C0/27.;
+   Double_t del;
+   if (x >= 3.)            del = 4.606 * x + C0;
+   else if (0.<=x && x<3.) del = 4.606 * x + C0 + a * TMath::Power(3.-x, 3.);
+   else                    del = 0.;
+   Double_t tmax = 2.*kMe*bg2 / (1. + meM*(2.*TMath::Sqrt(gm2) + meM)); 
+   Double_t dedx = kK * Z/A * gm2/bg2 * (0.5*log(2.*kMe*bg2*tmax / (I*I))
+                 - bg2/gm2 - del);
+
+   Double_t path = hel.IsInB()
+                 ? TMath::Abs(hel.GetRho()*df)*cslinv
+                 : TMath::Abs(df)*cslinv;
+
+   //fg: switched from using cm to mm in KalTest - material (density) and energy still in GeV and cm
+   path /= 10. ; 
+
+   Double_t edep = dedx * dnsty * path;
+
+
+   Double_t cpaa = TMath::Sqrt(tnl21 / (mom2 + edep
+                 * (edep + 2. * TMath::Sqrt(mom2 + mass * mass))));
+   Double_t dcpa = TMath::Abs(cpa) - cpaa;
+
+   static const Bool_t kForward  = kTRUE;
+   static const Bool_t kBackward = kFALSE;
+   Bool_t isfwd = ((cpa > 0 && df < 0) || (cpa <= 0 && df > 0)) ? kForward : kBackward;
+   return isfwd ? (cpa > 0 ? dcpa : -dcpa) : (cpa > 0 ? -dcpa : dcpa);
+}
+
+//_________________________________________________________________________
+// -----------------
+//  CalQms
+// -----------------
+//    calculates process noise matrix for multiple scattering with
+//    thin layer approximation.
+//
+void TVMeasLayer::CalcQms(      Bool_t       isoutgoing,
+                          const TVTrack     &hel,
+                                Double_t     df,
+                                TKalMatrix  &Qms) const
+{
+   Double_t cpa    = hel.GetKappa();
+   Double_t tnl    = hel.GetTanLambda(); 
+   Double_t tnl2   = tnl * tnl;
+   Double_t tnl21  = 1. + tnl2;
+   Double_t cpatnl = cpa * tnl;
+   Double_t cslinv = TMath::Sqrt(tnl21);
+   Double_t mom    = TMath::Abs(1. / cpa) * cslinv;
+
+   static const Double_t kMpi = 0.13957018; // pion mass [GeV]
+   TKalTrack *ktp  = static_cast<TKalTrack *>(TVKalSystem::GetCurInstancePtr());
+   Double_t   mass = ktp ? ktp->GetMass() : kMpi;
+   Double_t   beta = mom / TMath::Sqrt(mom * mom + mass * mass);
+
+   const TMaterial &mat = GetMaterial(isoutgoing);
+   Double_t x0inv = 1. / mat.GetRadLength();  // radiation length inverse
+
+   // *Calculate sigma_ms0 =============================================
+   static const Double_t kMS1  = 0.0136;
+   static const Double_t kMS12 = kMS1 * kMS1;
+   static const Double_t kMS2  = 0.038;
+   
+   Double_t path = hel.IsInB()
+                 ? TMath::Abs(hel.GetRho()*df)*cslinv
+                 : TMath::Abs(df)*cslinv;
+
+   //fg: switched from using cm to mm in KalTest - material (density) and energy still in GeV and cm
+   path /= 10. ; 
+
+   Double_t xl   = path * x0inv;
+   // ------------------------------------------------------------------
+   // Very Crude Treatment!!
+   Double_t tmp = 1. + kMS2 * TMath::Log(TMath::Max(1.e-4, xl));
+   tmp /= (mom * beta);
+   Double_t sgms2 = kMS12 * xl * tmp * tmp;
+   // ------------------------------------------------------------------
+
+   Qms(1,1) = sgms2 * tnl21;
+   Qms(2,2) = sgms2 * cpatnl * cpatnl;
+   Qms(2,4) = sgms2 * cpatnl * tnl21;
+   Qms(4,2) = sgms2 * cpatnl * tnl21;
+   Qms(4,4) = sgms2 * tnl21  * tnl21;
+}
diff --git a/Utilities/KalTest/src/kaltracklib/TVMeasLayer.h b/Utilities/KalTest/src/kaltracklib/TVMeasLayer.h
new file mode 100644
index 0000000000000000000000000000000000000000..5cdc314352f89963a5a8dc560c0623dac861c177
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TVMeasLayer.h
@@ -0,0 +1,86 @@
+#ifndef TVMEASLAYER_H
+#define TVMEASLAYER_H
+//*************************************************************************
+//* ====================
+//*  TVMeasLayer Class
+//* ====================
+//*
+//* (Description)
+//*   Measurement layer interface class.
+//* (Requires)
+//* (Provides)
+//*     class TVMeasLayer
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2005/02/23  A.Yamaguchi       Added new data members, fFwdX0Inv,
+//*                                 fBwdX0Inv and fIndex, and their
+//*                                 corresponding getters and setters.
+//*                                 Added a new method, GetX0Inv().
+//*   2005/0X/XX  A.Yamaguchi       Replaced fFwdX0Inv, fBwdX0Inv, and
+//*                                 their getters and setters by
+//*                                 fMaterialOutPtr, fMaterialInPtr, and
+//*                                 their getters and setters.
+//*   2005/08/15  K.Fujii           Added fIsActive and IsActive().
+//*   2011/12/03  S.Aplin           Added new member: name 
+//*                                 default value set to "TVMeasLayer"
+//*                                 and corresponding member function
+//*                                 TString GetName()  
+//*
+//*************************************************************************
+
+#include "TVector3.h"       // from ROOT
+#include "TMaterial.h"      // from ROOT
+#include "TAttElement.h"    // from Utils
+#include "TKalMatrix.h"     // from KalLib
+#include "KalTrackDim.h"    // from KalTrackLib
+
+class TVTrack;
+class TVTrackHit;
+
+class TVMeasLayer : public TAttElement {
+public:
+   // Ctors and Dtor
+
+   TVMeasLayer(TMaterial &matIn, 
+               TMaterial &matOut,
+               Bool_t     isactive = kTRUE,
+               const Char_t    *name = "TVMeasLayer");
+   virtual ~TVMeasLayer() {}
+
+   // Utiliy Methods
+
+   virtual TKalMatrix XvToMv   (const TVTrackHit &ht,
+                                const TVector3   &xv) const = 0;
+   virtual TVector3   HitToXv  (const TVTrackHit &ht) const = 0;
+   virtual void       CalcDhDa (const TVTrackHit &ht,
+                                const TVector3   &xv,
+                                const TKalMatrix &dxphiada,
+                                      TKalMatrix &H)  const = 0;
+
+   inline virtual TMaterial &GetMaterial(Bool_t isoutgoing) const
+              { return isoutgoing ? *fMaterialOutPtr : *fMaterialInPtr; }
+     
+   inline  Int_t      GetIndex() const  { return fIndex;    }
+   inline  void       SetIndex(Int_t i) { fIndex = i;       }    
+   inline  Bool_t     IsActive() const  { return fIsActive; }
+
+   virtual Double_t   GetEnergyLoss (      Bool_t    isoutgoing,
+                                     const TVTrack  &hel,
+                                           Double_t  df) const;
+   virtual void       CalcQms       (      Bool_t    isoutgoing,
+                                     const TVTrack  &hel,
+                                           Double_t  df,
+                                           TKalMatrix &Qms) const;
+
+  inline TString       GetName() const { return fname;    }
+  
+private:
+   TMaterial     *fMaterialInPtr;   // pointer of inner Material
+   TMaterial     *fMaterialOutPtr;  // pointer of outer Material
+   Int_t          fIndex;           // index in TKalDetCradle
+   Bool_t         fIsActive;        // flag to tell layer is active or not
+  const Char_t   *fname;
+   ClassDef(TVMeasLayer,1)      // Measurement layer interface class
+};
+
+#endif
diff --git a/Utilities/KalTest/src/kaltracklib/TVTrackHit.cxx b/Utilities/KalTest/src/kaltracklib/TVTrackHit.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..ad9284ac48e2974f09ef1fafb08a6a409ecd3176
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TVTrackHit.cxx
@@ -0,0 +1,54 @@
+//*************************************************************************
+//* ====================
+//*  TVTrackHit Class
+//* ====================
+//*
+//* (Description)
+//*   Abstract base class to store single hit information.
+//* (Requires)
+//* (Provides)
+//*     class TVTrackHit
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*
+//*************************************************************************
+
+#include "TVTrackHit.h"   // from KalTrackLib
+
+ClassImp(TVTrackHit)
+
+//_________________________________________________________________________
+//  ----------------------------------
+//  Ctors and Dtor
+//  ----------------------------------
+
+TVTrackHit::TVTrackHit(Int_t m)
+          : TKalMatrix(m,2), fDim(m), fBfield(30.), fMeasLayerPtr(0)
+{
+}
+      
+TVTrackHit::TVTrackHit(const TVMeasLayer &ms,
+                             Double_t    *x,
+                             Double_t    *dx, 
+                             Double_t     b,
+                             Int_t        m)
+          : TKalMatrix(m,2), fDim(m), fBfield(b),
+            fMeasLayerPtr((TVMeasLayer *)&ms)
+{
+   for (Int_t i=0; i<m; i++) {
+      (*this)(i,0) = x [i];
+      (*this)(i,1) = dx[i];
+   }
+}
+
+TVTrackHit::TVTrackHit(const TVTrackHit &hit)
+          : TKalMatrix(hit), 
+            fDim(hit.fDim),
+            fBfield(hit.fBfield),
+            fMeasLayerPtr(hit.fMeasLayerPtr)
+{
+}
+
+TVTrackHit::~TVTrackHit()
+{
+}
diff --git a/Utilities/KalTest/src/kaltracklib/TVTrackHit.h b/Utilities/KalTest/src/kaltracklib/TVTrackHit.h
new file mode 100644
index 0000000000000000000000000000000000000000..9559bb624fd9e23f31b7a39c5e9ea3afbd61bf64
--- /dev/null
+++ b/Utilities/KalTest/src/kaltracklib/TVTrackHit.h
@@ -0,0 +1,55 @@
+#ifndef TVTRACKHIT_H
+#define TVTRACKHIT_H
+
+//*************************************************************************
+//* ====================
+//*  TVTrackHit Class
+//* ====================
+//*
+//* (Description)
+//*   Abstract base class to store single hit information.
+//* (Requires)
+//* (Provides)
+//*     class TVTrackHit
+//* (Update Recored)
+//*   2003/09/30  Y.Nakashima       Original version.
+//*   2005/08/11  K.Fujii           Removed fXX and its getter and setter.
+//*
+//*************************************************************************
+
+#include "TVector3.h"      // from ROOT
+#include "TKalMatrix.h"    // from KalLib
+#include "KalTrackDim.h"   // from KalTrackLib
+#include "TVMeasLayer.h"   // from KalTrackLib
+
+class TVTrackHit : public TKalMatrix {
+public:
+   TVTrackHit(Int_t m = kMdim);
+
+   TVTrackHit(const TVMeasLayer &ms, Double_t *x, Double_t *dx, 
+              Double_t b = 30., Int_t m = kMdim);
+   TVTrackHit(const TVTrackHit &hit);
+
+   virtual ~TVTrackHit();
+
+   inline virtual Double_t GetX (Int_t i) const { return (*this)(i,0);      }
+   inline virtual Double_t GetDX(Int_t i) const { return (*this)(i,1);      }
+   inline virtual Int_t    GetDimension() const { return fDim;              }
+   inline virtual Double_t GetBfield()    const { return fBfield;           }
+
+   inline virtual const TVMeasLayer & GetMeasLayer() const 
+                                                { return *fMeasLayerPtr;    }
+
+   virtual TKalMatrix XvToMv  (const TVector3 &xv, Double_t t0)  const = 0;
+
+  //   virtual void       DebugPrint(Option_t *opt = "")        const = 0;
+
+private:
+   Int_t         fDim;            // dimension of coordinate space
+   Double_t      fBfield;         // B field
+   TVMeasLayer  *fMeasLayerPtr;   // pointer to measurement layer
+
+   ClassDef(TVTrackHit,1)      // Sample hit class
+};
+
+#endif
diff --git a/Utilities/KalTest/src/utils/Imakefile b/Utilities/KalTest/src/utils/Imakefile
new file mode 100644
index 0000000000000000000000000000000000000000..674cb1dd4d6c5c3cce984d24d56a9919d828b29a
--- /dev/null
+++ b/Utilities/KalTest/src/utils/Imakefile
@@ -0,0 +1,53 @@
+#include "../../conf/makejsf.tmpl"
+
+INSTALLDIR    = ../..
+PACKAGENAME   = S4Utils
+SOREV         = 2005.01
+
+SRCS          = TAttDrawable.$(SrcSuf) \
+                TAttElement.$(SrcSuf) \
+                TAttLockable.$(SrcSuf)
+
+OBJS	      =	$(subst .$(SrcSuf),.$(ObjSuf),$(SRCS)) \
+		$(PACKAGENAME)Dict.$(ObjSuf)
+
+HDRS	      = $(subst .$(SrcSuf),.h,$(SRCS))
+
+DICTNAME      = $(PACKAGENAME)Dict
+
+LIBNAME       = $(PACKAGENAME)
+
+SONAME        = lib$(LIBNAME).$(DllSuf).$(SOREV)
+
+LIBINSTALLDIR = $(INSTALLDIR)/lib
+INCINSTALLDIR = $(INSTALLDIR)/include
+INCPATH	      = -I. -I$(INCINSTALLDIR) 
+CXXFLAGS     += $(INCPATH)
+SHLIBLDFLAGS  = $(DYLIBFLAGS)
+
+
+all:: $(SONAME)
+
+SharedLibraryTarget($(LIBNAME),$(SOREV),$(OBJS),.,.)
+
+InstallSharedLibrary($(LIBNAME),$(SOREV),$(LIBINSTALLDIR))
+
+InstallMultipleFlags($(HDRS),$(INCINSTALLDIR),-m 644)
+
+clean:: 
+	@rm -f $(OBJS) core *.$(DllSuf) $(DICTNAME).$(SrcSuf) $(DICTNAME).h $(SONAME) *.$(DylibSuf)
+
+depend:: $(SRCS) $(HDRS)
+	for i in $(SRCS); do \
+	rmkdepend -a -- $(DEPENDFILES) -- $$i; done
+
+
+distclean:: clean
+	@rm -f $(OBJS) core *.$(DllSuf) $(DICTNAME).$(SrcSuf) $(DICTNAME).h *~
+	@rm -f $(SONAME) *.root Makefile
+	@(cd $(INSTALLDIR); rm -f *.root *.tdr *.out *~ core)
+
+$(DICTNAME).$(SrcSuf): $(HDRS) LinkDef.h
+	@echo "Generating dictionary ..."
+	rootcint -f $(DICTNAME).$(SrcSuf) \
+	         -c $(HDRS) LinkDef.h
diff --git a/Utilities/KalTest/src/utils/LinkDef.h b/Utilities/KalTest/src/utils/LinkDef.h
new file mode 100644
index 0000000000000000000000000000000000000000..599b5eb0aea9029429ced6340aa56259a01fa6e5
--- /dev/null
+++ b/Utilities/KalTest/src/utils/LinkDef.h
@@ -0,0 +1,11 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class TAttDrawable+;
+#pragma link C++ class TAttElement+;
+#pragma link C++ class TAttLockable+;
+
+#endif
diff --git a/Utilities/KalTest/src/utils/TAttDrawable.cxx b/Utilities/KalTest/src/utils/TAttDrawable.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..0b2b06dadb229e89fdce195e67aa469771cba93a
--- /dev/null
+++ b/Utilities/KalTest/src/utils/TAttDrawable.cxx
@@ -0,0 +1,38 @@
+//*************************************************************************
+//* ====================
+//*  TAttDrawable Class
+//* ====================
+//*
+//* (Description)
+//*    TAttDrawable class adds drawable attribute to an object.
+//* (Requires)
+//* 	none
+//* (Provides)
+//* 	class TAttDrawable
+//* (Update Recored)
+//*    2004/11/04  K.Fujii	Original very primitive version.
+//*
+//*************************************************************************
+//
+#include "TAttDrawable.h"
+//_________________________________________________________________________
+//  -------------------------------
+//  Base Class for Drawable Objects
+//  -------------------------------
+//
+ClassImp(TAttDrawable)
+
+//=========================================================================
+//* Draw ------------------------------------------------------------------
+
+void TAttDrawable::Draw(const Char_t *opt)
+{
+   static Int_t color = 0;
+   color++;
+   color %= 10;
+   Draw(color, opt);
+}
+
+void TAttDrawable::Draw(Int_t /* color */, const Char_t * /* opt */)
+{
+}
diff --git a/Utilities/KalTest/src/utils/TAttDrawable.h b/Utilities/KalTest/src/utils/TAttDrawable.h
new file mode 100644
index 0000000000000000000000000000000000000000..3383a39af6a4d04d2e2f726e977dce746afa7a57
--- /dev/null
+++ b/Utilities/KalTest/src/utils/TAttDrawable.h
@@ -0,0 +1,37 @@
+#ifndef TATTDRAWABLE_H
+#define TATTDRAWABLE_H
+//*************************************************************************
+//* ===================
+//*  TAttDrawable Class
+//* ===================
+//*
+//* (Description)
+//*    TAttDrawable class adds drawable attribute to an object.
+//* (Requires)
+//* 	none
+//* (Provides)
+//* 	class TAttDrawable
+//* (Update Recored)
+//*    2004/11/04  K.Fujii	Original very primitive version.
+//*
+//*************************************************************************
+//
+#include <Rtypes.h>
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for Drawale Objects
+//  ------------------------------
+//
+class TAttDrawable {
+public:
+   TAttDrawable() {}
+   virtual ~TAttDrawable() {}
+
+   virtual void   Draw(const Char_t *opt="");
+   virtual void   Draw(Int_t /* color */, const Char_t *opt="");
+private:
+
+   ClassDef(TAttDrawable, 1)  // Base class for drawable objects
+};
+
+#endif
diff --git a/Utilities/KalTest/src/utils/TAttElement.cxx b/Utilities/KalTest/src/utils/TAttElement.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..b086fc8630e8729d0e1b21993e070050ba3a30f6
--- /dev/null
+++ b/Utilities/KalTest/src/utils/TAttElement.cxx
@@ -0,0 +1,24 @@
+//*************************************************************************
+//* ===================
+//*  TAttElement Class
+//* ===================
+//*
+//* (Description)
+//*    TAttElement class adds constituent attribute to an object.
+//* (Requires)
+//* 	none
+//* (Provides)
+//* 	class TAttElement
+//* (Update Recored)
+//*    2003/10/10  K.Fujii	Original very primitive version.
+//*
+//*************************************************************************
+//
+#include "TAttElement.h"
+//_____________________________________________________________________
+//  --------------------------------
+//  Base Class for Element Objects
+//  --------------------------------
+//
+
+ClassImp(TAttElement)
diff --git a/Utilities/KalTest/src/utils/TAttElement.h b/Utilities/KalTest/src/utils/TAttElement.h
new file mode 100644
index 0000000000000000000000000000000000000000..3f9905e03e33fa454de66143f8707e7caad3e47e
--- /dev/null
+++ b/Utilities/KalTest/src/utils/TAttElement.h
@@ -0,0 +1,55 @@
+#ifndef TATTELEMENT_H
+#define TATTELEMENT_H
+//*************************************************************************
+//* ===================
+//*  TAttElement Class
+//* ===================
+//*
+//* (Description)
+//*    TAttElement class adds constituent attribute to an object.
+//* (Requires)
+//* 	none
+//* (Provides)
+//* 	class TAttElement
+//* (Update Recored)
+//*    2003/10/10  K.Fujii	Original very primitive version.
+//*
+//*************************************************************************
+//
+#include <Rtypes.h>
+
+//_____________________________________________________________________
+//  --------------------------------
+//  Base Class for Element Objects
+//  --------------------------------
+//
+class TAttElement {
+public:
+   TAttElement() : fParentPtr(0) {}
+   virtual ~TAttElement() {}
+
+   inline virtual const TAttElement  & GetParent(Bool_t recur = kTRUE) const;
+
+   inline virtual void  SetParentPtr(TAttElement *obj)  { fParentPtr = obj; }
+
+private:
+   TAttElement *fParentPtr;	 // pointer to parent
+
+   ClassDef(TAttElement,1)  // Base class for lockable objects
+};
+
+//_____________________________________________________________________
+//  --------------------------------
+//  Inline functions, if any
+//  --------------------------------
+const TAttElement & TAttElement::GetParent(Bool_t recursive) const
+{
+   if (fParentPtr) {
+      if (recursive) return fParentPtr->GetParent(recursive);
+      else           return *fParentPtr;
+   } else {
+      return *this;
+   }
+}
+
+#endif
diff --git a/Utilities/KalTest/src/utils/TAttLockable.cxx b/Utilities/KalTest/src/utils/TAttLockable.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..d2d81325be8a62fe5a262ce4fadb05430f9c4041
--- /dev/null
+++ b/Utilities/KalTest/src/utils/TAttLockable.cxx
@@ -0,0 +1,23 @@
+//*************************************************************************
+//* ====================
+//*  TAttLockable Class
+//* ====================
+//*
+//* (Description)
+//*    TAttLockable class adds lockable attribute to an object.
+//* (Requires)
+//* 	none
+//* (Provides)
+//* 	class Lockable
+//* (Update Recored)
+//*    1999/06/05  K.Fujii	Original very primitive version.
+//*
+//*************************************************************************
+//
+#include "TAttLockable.h"
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for Lockale Objects
+//  ------------------------------
+//
+ClassImp(TAttLockable)
diff --git a/Utilities/KalTest/src/utils/TAttLockable.h b/Utilities/KalTest/src/utils/TAttLockable.h
new file mode 100644
index 0000000000000000000000000000000000000000..8b6d068bf2a43d9a4aadd144d4ec961b9f539cb4
--- /dev/null
+++ b/Utilities/KalTest/src/utils/TAttLockable.h
@@ -0,0 +1,39 @@
+#ifndef TATTLOCKABLE_H
+#define TATTLOCKABLE_H
+//*************************************************************************
+//* ===================
+//*  TAttLockable Class
+//* ===================
+//*
+//* (Description)
+//*    TAttLockable class adds lockable attribute to an object.
+//* (Requires)
+//* 	none
+//* (Provides)
+//* 	class Lockable
+//* (Update Recored)
+//*    1999/06/05  K.Fujii	Original very primitive version.
+//*
+//*************************************************************************
+//
+#include <Rtypes.h>
+//_____________________________________________________________________
+//  ------------------------------
+//  Base Class for Lockale Objects
+//  ------------------------------
+//
+class TAttLockable {
+public:
+   TAttLockable() : fStatus(kFALSE) {}
+   virtual ~TAttLockable() {}
+
+   inline virtual Bool_t IsLocked() const { return fStatus;   }
+   inline virtual void   Lock()           { fStatus = kTRUE;  }
+   inline virtual void   Unlock()         { fStatus = kFALSE; }
+private:
+   Bool_t fStatus;	 // lock byte
+
+   ClassDef(TAttLockable,1)  // Base class for lockable objects
+};
+
+#endif