diff --git a/Online/EventBuilding/CMakeLists.txt b/Online/EventBuilding/CMakeLists.txt
index b0caaeaed60d6808f70a17511c54a49516337365..67ad71b884d6d15876176a7b410f67ea31a4344c 100644
--- a/Online/EventBuilding/CMakeLists.txt
+++ b/Online/EventBuilding/CMakeLists.txt
@@ -24,107 +24,151 @@ gaudi_depends_on_subdirs(Online/Dataflow
 # TODO use find_package for PCIe40 libs
 #Check for local PCIE40.If not present do not build event builder libraries
 # TODO NO_CACHE is currently no supported by CMake < 3.21 check what it does in the future
-find_path(PCIE40_DAQ_INC NAMES "daq40.hpp" "daq.h" "id.h" PATHS /usr/include/lhcb/daq40)
+
+if (NOT DEFINED PCIE40_ROOT)
+  set(PCIE40_ROOT "/usr")
+endif()
+
+set(PCIE_40_LIBRARIES)
+foreach(lib IN ITEMS pcie40_daq pcie40_id pcie40)
+  find_library(${lib}_path ${lib}
+    HINTS
+      ${PCIE40_ROOT}/lib64
+      ${PCIE40_ROOT}/lib
+    NO_DEFAULT_PATH)
+  if (${${lib}_path} STREQUAL "${lib}_path-NOTFOUND")
+    set(PCIE40_FOUND FALSE)
+  else()
+    list(APPEND PCIE_40_LIBRARIES ${${lib}_path})
+  endif()
+endforeach()
+
+find_path(PCIE40_DAQ_INC NAMES "daq40.hpp" "daq.h" "id.h" PATHS ${PCIE40_ROOT}/include/lhcb/daq40)
 if ( "${PCIE40_DAQ_INC}" STREQUAL "PCIE40_DAQ_INC-NOTFOUND" )
-  message(STATUS "+======================================================================+")
-  message(STATUS "|   PCIE40 DAQ not present. Will not build EventBuilding libraries.    |")
-  message(STATUS "+======================================================================+")
-  return()
+  message(STATUS "+++ PCIE40 DAQ not present. Will build minimal EventBuilding library.")
+  set(PCIE40_FOUND FALSE)
+else()
+  set(PCIE_40_INCLUDE_DIRS ${PCIE40_ROOT}/include/lhcb/daq40 ${PCIE40_ROOT}/include/lhcb)
+
+  try_compile(HAVE_RECENT_PCIE40 "${CMAKE_BINARY_DIR}/temp" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/test_daq40.cpp"
+              LINK_LIBRARIES ${PCIE_40_LIBRARIES}
+              CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${PCIE_40_INCLUDE_DIRS}")
+
+  if (HAVE_RECENT_PCIE40)
+    message(STATUS "+++ Found recent PCIE40: ${PCIE40_DAQ_INC}")
+    set(PCIE40_FOUND TRUE)
+  else()
+    message(STATUS "+++ PCIE40 DAQ is too old. Will build minimal EventBuilding library.")
+    set(PCIE40_FOUND FALSE)
+  endif()
 endif()
-return()
 
-find_package(MPI COMPONENTS CXX)
-if(NOT MPI_CXX_FOUND)
-  # When not found there is the following red herring,
-  # see https://gitlab.kitware.com/cmake/cmake/-/issues/21491
+if (PCIE40_FOUND)
+  find_package(MPI COMPONENTS CXX)
+  if(NOT MPI_CXX_FOUND)
+    # When not found there is the following red herring,
+    # see https://gitlab.kitware.com/cmake/cmake/-/issues/21491
+    #
+    # -- Could NOT find MPI (missing: MPI_CXX_FOUND CXX)
+    #     Reason given by package: MPI component 'Fortran' was requested, but language Fortran is not enabled.
+    #
+    message(STATUS "+++ MPI not present. Will build minimal EventBuilding library")
+  endif()
+else()
+  set(MPI_CXX_FOUND FALSE)
+endif()
+
+if (PCIE40_FOUND AND MPI_CXX_FOUND)
+  #fpisani fixed find of external libraries
+  include(Numa)
+  find_package(PkgConfig REQUIRED)
+
+  set(OLD_CONFIG_PATH $ENV{PKG_CONFIG_PATH})
+  #TODO check if there is a better way to identify this path
+  set(ENV{PKG_CONFIG_PATH} /usr/lib64/pkgconfig)
+  pkg_search_module(GLIB2 REQUIRED glib-2.0)
+  #add_definitions(${MPI_CXX_COMPILE_DEFINITIONS})
+
+  find_package(Boost REQUIRED COMPONENTS system filesystem regex)
+  find_package(ROOT REQUIRED COMPONENTS Hist)
   #
-  # -- Could NOT find MPI (missing: MPI_CXX_FOUND CXX)
-  #     Reason given by package: MPI component 'Fortran' was requested, but language Fortran is not enabled.
+  #If we want to globally rename the DD4hep namespace to Online, enable the line below !
+  add_definitions(-DDD4hep=Online)
   #
-  message(STATUS "+======================================================================+")
-  message(STATUS "|   MPI not present. Will not build EventBuilding libraries.           |")
-  message(STATUS "+======================================================================+")
-  return()
-endif()
+  #
+  #-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
+  #EventBuilding basic client library
+  #Note : The ROOT dependency is only required to declare Monitors of type THX
+  #-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
+  set(INFINIBAND_LIBRARIES ibverbs pthread)
+  set(INFINIBAND_DIRS include/infiniband_net)
 
-#fpisani fixed find of external libraries
-include(Numa)
-find_package(PkgConfig REQUIRED)
+  include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${MPI_CXX_INCLUDE_DIRS} ${PCIE_40_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS})
 
-set(OLD_CONFIG_PATH $ENV{PKG_CONFIG_PATH})
-#TODO check if there is a better way to identify this path
-set(ENV{PKG_CONFIG_PATH} /usr/lib64/pkgconfig)
-pkg_search_module(GLIB2 REQUIRED glib-2.0)
-#add_definitions(${MPI_CXX_COMPILE_DEFINITIONS})
+  gaudi_add_library(EventBuildingLib
+                    src/*.cpp
+                    src/events_dispatch/*.cpp
+                    src/infiniband_net/*.cpp
+                    PUBLIC_HEADERS EventBuilding EventBuilding/events_dispatch
+                    INCLUDE_DIRS ${MPI_CXX_INCLUDE_DIRS} ${PCIE_40_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${INFINIBAND_DIRS}
+                    LINK_LIBRARIES dim ROOT OnlineBase DataflowLib DAQEventLib
+                    ${MPI_CXX_LIBRARIES} ${PCIE_40_LIBRARIES} ${GLIB2_LIBRARIES}
+                    ${INFINIBAND_LIBRARIES})
 
-find_package(Boost REQUIRED COMPONENTS system filesystem regex)
-find_package(ROOT REQUIRED COMPONENTS Hist)
-#
-#If we want to globally rename the DD4hep namespace to Online, enable the line below !
-add_definitions(-DDD4hep=Online)
-#
-#
-#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-#EventBuilding basic client library
-#Note : The ROOT dependency is only required to declare Monitors of type THX
-#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-set(INFINIBAND_LIBRARIES ibverbs pthread)
-set(INFINIBAND_DIRS include/infiniband_net)
-set(PCIE_40_LIBRARIES pcie40_daq pcie40_id pcie40)
-set(PCIE_40_INCLUDE_DIRS /usr/include/lhcb/daq40 /usr/include/lhcb)
-
-include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${MPI_CXX_INCLUDE_DIRS} ${PCIE_40_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS})
-
-gaudi_add_library(EventBuildingLib
-                  src/*.cpp
-                  src/events_dispatch/*.cpp
-                  src/infiniband_net/*.cpp
-                  PUBLIC_HEADERS EventBuilding EventBuilding/events_dispatch
-                  INCLUDE_DIRS ${MPI_CXX_INCLUDE_DIRS} ${PCIE_40_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${INFINIBAND_DIRS}
-                  LINK_LIBRARIES dim ROOT OnlineBase DataflowLib DAQEventLib
-                  ${MPI_CXX_LIBRARIES} ${PCIE_40_LIBRARIES} ${GLIB2_LIBRARIES}
-                  ${INFINIBAND_LIBRARIES})
-
-
-target_include_directories(EventBuildingLib BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
-target_include_directories(EventBuildingLib BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/infiniband_net)
-target_compile_options(EventBuildingLib PRIVATE -std=c++2a)
-if(NOT CMAKE_CXX_COMPILER_ID STREQUAL  "Clang")
-  target_compile_options(EventBuildingLib PRIVATE -fconcepts)
-endif()
 
-# ---------------------------------------------------------------------------------------
-#   Commonly used DataflowExample components
-# ---------------------------------------------------------------------------------------
-gaudi_add_library(EventBuilding
- 	          components/*.cpp
-                  INCLUDE_DIRS ${NUMA_INCLUDE_DIR}  ${MPI_CXX_INCLUDE_DIRS} ${PCIE_40_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS}
-                  NO_PUBLIC_HEADERS
-                  LINK_LIBRARIES dim Boost OnlineBase DataflowLib EventBuildingLib ${NUMA_LIBRARIES} ${GLIB2_LIBRARIES}
-                  ${MPI_CXX_LIBRARIES} ${PCIE_40_LIBRARIES})
-
-target_include_directories(EventBuilding BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
-target_include_directories(EventBuilding BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/infiniband_net)
-target_compile_options(EventBuilding PRIVATE -std=c++2a)
-if(NOT CMAKE_CXX_COMPILER_ID STREQUAL  "Clang")
-  target_compile_options(EventBuildingLib PRIVATE -fconcepts)
-endif()
+  target_compile_definitions(EventBuildingLib PRIVATE HAVE_PCIE40)
+  target_include_directories(EventBuildingLib BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+  target_include_directories(EventBuildingLib BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/infiniband_net)
+  target_compile_options(EventBuildingLib PRIVATE -std=c++2a)
+  if(NOT CMAKE_CXX_COMPILER_ID STREQUAL  "Clang")
+    target_compile_options(EventBuildingLib PRIVATE -fconcepts)
+  endif()
 
-#
-# ---> Steer the property parser:
-# If we want to rename the Gaudi namespace to Online, enable the line below!
-#target_compile_definitions(DataflowExample PRIVATE -DDataflowExample_NS=Online)
-gaudi_generate_componentslist(EventBuilding)
-#
-# ---------------------------------------------------------------------------------------
-# If there is a scripts directory
-#gaudi_install_scripts()
-# If there are python components
-#gaudi_install_python_modules()
-# ---------------------------------------------------------------------------------------
-#   Testing
-# ---------------------------------------------------------------------------------------
-# Enable QMTests
-#gaudi_add_test(QMTest QMTEST)
-
-set(ENV{PKG_CONFIG_PATH} ${OLD_CONFIG_PATH})
+  # ---------------------------------------------------------------------------------------
+  #   Commonly used DataflowExample components
+  # ---------------------------------------------------------------------------------------
+  gaudi_add_library(EventBuilding
+   	          components/*.cpp
+                    INCLUDE_DIRS ${NUMA_INCLUDE_DIR}  ${MPI_CXX_INCLUDE_DIRS} ${PCIE_40_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS}
+                    NO_PUBLIC_HEADERS
+                    LINK_LIBRARIES dim Boost OnlineBase DataflowLib EventBuildingLib ${NUMA_LIBRARIES} ${GLIB2_LIBRARIES}
+                    ${MPI_CXX_LIBRARIES} ${PCIE_40_LIBRARIES})
+
+  target_include_directories(EventBuilding BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+  target_include_directories(EventBuilding BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/infiniband_net)
+  target_compile_options(EventBuilding PRIVATE -std=c++2a)
+  if(NOT CMAKE_CXX_COMPILER_ID STREQUAL  "Clang")
+    target_compile_options(EventBuildingLib PRIVATE -fconcepts)
+  endif()
+
+  #
+  # ---> Steer the property parser:
+  # If we want to rename the Gaudi namespace to Online, enable the line below!
+  #target_compile_definitions(DataflowExample PRIVATE -DDataflowExample_NS=Online)
+  gaudi_generate_componentslist(EventBuilding)
+  #
+  # ---------------------------------------------------------------------------------------
+  # If there is a scripts directory
+  #gaudi_install_scripts()
+  # If there are python components
+  #gaudi_install_python_modules()
+  # ---------------------------------------------------------------------------------------
+  #   Testing
+  # ---------------------------------------------------------------------------------------
+  # Enable QMTests
+  #gaudi_add_test(QMTest QMTEST)
+
+  set(ENV{PKG_CONFIG_PATH} ${OLD_CONFIG_PATH})
+else()
+  gaudi_add_library(EventBuildingLib
+                      src/mdf_tools.cpp
+                      src/MEP_tools.cpp
+                      src/MFP_tools.cpp
+                      src/raw_tools.cpp
+                      src/generic_block.cpp
+                      src/tools.cpp
+                    PUBLIC_HEADERS
+                      EventBuilding
+                    LINK_LIBRARIES
+                      DAQEventLib)
+endif()
diff --git a/Online/EventBuilding/EventBuilding/MEP_tools.hpp b/Online/EventBuilding/EventBuilding/MEP_tools.hpp
index 509e217408ccc9c4271e426aa54372cf873fb140..ea809781201ac7eb88866f00af00ab672ad85c43 100644
--- a/Online/EventBuilding/EventBuilding/MEP_tools.hpp
+++ b/Online/EventBuilding/EventBuilding/MEP_tools.hpp
@@ -10,7 +10,7 @@ namespace EB {
   typedef uint32_t offset_type;
 
   constexpr uint16_t MEP_magic = 0xCEFA;
-  constexpr uint16_t MEP_wrap = ~MEP_magic;
+  constexpr uint16_t MEP_wrap = 0xFFFF - MEP_magic;
   // size of a word in bytes (see p_words and offsets)
   constexpr size_t MEP_WORD_SIZE = (32 / 8);
 
@@ -147,9 +147,14 @@ namespace EB {
   // alignent in the mpf header in bytes
   constexpr size_t MEP_alignment = 4;
 
+  bool operator==(const MEP::iterator& a, const MEP::iterator& b);
+  bool operator!=(const MEP::iterator& a, const MEP::iterator& b);
+  bool operator==(const MEP::const_iterator& a, const MEP::const_iterator& b);
+  bool operator!=(const MEP::const_iterator& a, const MEP::const_iterator& b);
+
   std::ostream& operator<<(std::ostream& os, const MEP_header& header);
   std::ostream& operator<<(std::ostream& os, const MEP& mep);
 
 } // namespace EB
 
-#endif // MEP_TOOLS_H
\ No newline at end of file
+#endif // MEP_TOOLS_H
diff --git a/Online/EventBuilding/EventBuilding/MFP_tools.hpp b/Online/EventBuilding/EventBuilding/MFP_tools.hpp
index 48a8525162e796659849cad8bac9c2ea06f27192..4995df3e92919ad2e310bbe87e005ba58137c5ef 100644
--- a/Online/EventBuilding/EventBuilding/MFP_tools.hpp
+++ b/Online/EventBuilding/EventBuilding/MFP_tools.hpp
@@ -162,8 +162,13 @@ namespace EB {
   // alignent in the mpf header in bytes
   constexpr size_t MFP_alignment = 4;
 
+  bool operator==(const MFP::iterator& a, const MFP::iterator& b);
+  bool operator!=(const MFP::iterator& a, const MFP::iterator& b);
+  bool operator==(const MFP::const_iterator& a, const MFP::const_iterator& b);
+  bool operator!=(const MFP::const_iterator& a, const MFP::const_iterator& b);
+
   std::ostream& operator<<(std::ostream& os, const MFP_header& header);
   std::ostream& operator<<(std::ostream& os, const MFP& mfp);
 } // namespace EB
 
-#endif // MFP_TOOLS_H
\ No newline at end of file
+#endif // MFP_TOOLS_H
diff --git a/Online/EventBuilding/EventBuilding/mdf_tools.hpp b/Online/EventBuilding/EventBuilding/mdf_tools.hpp
index 233da6e5b54c467ba49a726e842fbc71f6e62650..eb92aac0a1dd0949aacbd043582ea21f320d66b5 100644
--- a/Online/EventBuilding/EventBuilding/mdf_tools.hpp
+++ b/Online/EventBuilding/EventBuilding/mdf_tools.hpp
@@ -18,30 +18,30 @@ namespace EB {
     // MDF generic header field
     // size of the data block including the headers repeated 3 times for
     // redundancy
-    uint32_t size[3];
+    uint32_t size[3] = {0, 0, 0};
     // base32 checksum 0 if not used
-    uint32_t checksum;
+    uint32_t checksum = 0;
     // compression info 4 bits compression algorithm 4 bits compressio factor
-    uint8_t compression_information;
+    uint8_t compression_information = 0;
     // 4 bits header type 4 bit header length in 32 bit words
-    uint8_t header_information;
+    uint8_t header_information = 0;
     // data type
-    uint8_t data_type;
+    uint8_t data_type = 0;
     // spare field
-    uint8_t spare;
+    uint8_t spare = 0;
 
     bool is_valid() const { return (size[0] == size[1]) && (size[0] == size[2]); }
   };
 
   struct __attribute__((__packed__)) specific_header {
     // Trigger mask (if no mask is available, all bytes should be set to 0xFF)
-    uint32_t trigger_mask[4];
+    uint32_t trigger_mask[4] = {0, 0, 0, 0};
     // Run number
-    uint32_t run;
+    uint32_t run = 0;
     // Orbit number
-    uint32_t orbit;
+    uint32_t orbit = 0;
     // Bunch crossing ID
-    uint32_t bxid;
+    uint32_t bxid = 0;
   };
 
   struct __attribute__((__packed__)) MDF_header {
@@ -94,4 +94,4 @@ namespace EB {
 
 } // namespace EB
 
-#endif // MDF_TOOLS_H
\ No newline at end of file
+#endif // MDF_TOOLS_H
diff --git a/Online/EventBuilding/EventBuilding/raw_tools.hpp b/Online/EventBuilding/EventBuilding/raw_tools.hpp
index 4fa57a5019dc272e44a3e800f87be062af5eab58..b2ca1dff3c740bb9c423cf60c8d07f4f8a0ef792 100644
--- a/Online/EventBuilding/EventBuilding/raw_tools.hpp
+++ b/Online/EventBuilding/EventBuilding/raw_tools.hpp
@@ -4,7 +4,7 @@
 #include <unistd.h>
 #include <stdint.h>
 #include <iostream>
-#include "generic_block.hpp"
+#include "EventBuilding/generic_block.hpp"
 #include <unordered_map>
 #include <map>
 #include <iostream>
@@ -99,7 +99,16 @@ namespace EB {
 
   const std::string ToString(const BankType);
 
+  typedef std::pair<uint8_t, uint16_t> type_id_pair_type;
+
+  #ifdef HAVE_PCIE40
+  // TODO implement a proper conversion
+  type_id_pair_type new_src_id_to_old(uint16_t src_id);
+
+  uint16_t old_to_new(EB::type_id_pair_type src_id);
+
   uint16_t type_to_partition_id(const BankType b_type);
+  #endif
 
   std::ostream& operator<<(std::ostream& os, const BankType);
 
@@ -118,11 +127,13 @@ namespace EB {
 
     bool is_valid() const { return (magic == block_magic); }
 
+    #ifdef HAVE_PCIE40
     int get_sys_src_id() const;
     int get_src_id_num() const;
 
     void set_sys_src_id(uint16_t sys_src_id);
     void set_src_id_num(uint16_t src_id_num);
+    #endif
 
     std::ostream& print(std::ostream& os) const;
     friend std::ostream& operator<<(std::ostream& os, const raw_header& header);
@@ -142,12 +153,6 @@ namespace EB {
     int read_block(void* data, void* buffer, size_t buffer_size);
   };
 
-  typedef std::pair<uint8_t, uint16_t> type_id_pair_type;
-
-  // TODO implement a proper conversion
-  type_id_pair_type new_src_id_to_old(uint16_t src_id);
-
-  uint16_t old_to_new(EB::type_id_pair_type src_id);
 
   struct type_src_id_hash {
     std::size_t operator()(const type_id_pair_type& p) const { return std::hash<int>{}(p.first << 16 | p.second); }
diff --git a/Online/EventBuilding/cmake/test_daq40.cpp b/Online/EventBuilding/cmake/test_daq40.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..61d57c728982402cce40ca08afdf1d32245abc2f
--- /dev/null
+++ b/Online/EventBuilding/cmake/test_daq40.cpp
@@ -0,0 +1,7 @@
+#include <pcie40/daq.h>
+
+int main() {
+
+  P40_DAQ_STREAM stream = P40_DAQ_STREAM::P40_DAQ_STREAM_ODIN0;
+
+}
diff --git a/Online/EventBuilding/src/mdf_tools.cpp b/Online/EventBuilding/src/mdf_tools.cpp
index 84d992b57e43854ab3986d804c03686bdb3c303a..e44f7774e8484de8309124a1a6baf8963dca259d 100644
--- a/Online/EventBuilding/src/mdf_tools.cpp
+++ b/Online/EventBuilding/src/mdf_tools.cpp
@@ -9,7 +9,7 @@ EB::MDF_block::MDF_block(int fd) : Generic_block()
   }
 }
 
-EB::MDF_block::MDF_block(std::shared_ptr<char> payload, size_t size) : Generic_block(payload, size) { header = {0}; }
+EB::MDF_block::MDF_block(std::shared_ptr<char> payload, size_t size) : Generic_block(payload, size) {}
 
 EB::MDF_block::MDF_block(int fd, std::shared_ptr<char> payload, size_t size) : Generic_block(payload, size)
 {
@@ -68,7 +68,7 @@ int EB::MDF_block::read_block(int fd)
 
     if (realloc_ok) {
       n_bytes = read(fd, _payload.get(), payload_size);
-      if (n_bytes != payload_size) {
+      if (n_bytes == -1 || static_cast<size_t>(n_bytes) != payload_size) {
         std::cerr << "ERROR truncated file" << std::endl;
         ret_val = -EINVAL;
       }
diff --git a/Online/EventBuilding/src/raw_tools.cpp b/Online/EventBuilding/src/raw_tools.cpp
index cddb623ff98578756c0dc8bf83016e6d09cabb07..5dd12b66b616d8c615c668d469403d0bec98c787 100644
--- a/Online/EventBuilding/src/raw_tools.cpp
+++ b/Online/EventBuilding/src/raw_tools.cpp
@@ -1,7 +1,9 @@
 #include "EventBuilding/raw_tools.hpp"
 #include "EventBuilding/tools.hpp"
 // TODO check why this file breaks linking if include in header file
-#include <lhcb/daq40/sourceid.h>
+#ifdef HAVE_PCIE40
+#include <daq40/sourceid.h>
+#endif
 
 EB::raw_block::raw_block() : Generic_block() { header = {}; }
 
@@ -27,12 +29,6 @@ size_t EB::raw_header::payload_mem_size() const { return mem_size() - sizeof(thi
 
 size_t EB::raw_header::payload_size() const { return size - sizeof(this); }
 
-int EB::raw_header::get_sys_src_id() const { return SourceId_sys(src_id); }
-int EB::raw_header::get_src_id_num() const { return SourceId_num(src_id); }
-
-void EB::raw_header::set_sys_src_id(uint16_t sys_src_id) { src_id = (sys_src_id << 11) | (src_id & 0x1F); }
-void EB::raw_header::set_src_id_num(uint16_t src_id_num) { src_id = (src_id & 0xF800) | (src_id_num & 0x7FF); }
-
 const std::string EB::ToString(const BankType b_type)
 {
   switch (b_type) {
@@ -117,6 +113,13 @@ const std::string EB::ToString(const BankType b_type)
 
 std::ostream& EB::operator<<(std::ostream& os, const BankType b_type) { return os << ToString(b_type); }
 
+#ifdef HAVE_PCIE40
+int EB::raw_header::get_sys_src_id() const { return SourceId_sys(src_id); }
+int EB::raw_header::get_src_id_num() const { return SourceId_num(src_id); }
+
+void EB::raw_header::set_sys_src_id(uint16_t sys_src_id) { src_id = (sys_src_id << 11) | (src_id & 0x1F); }
+void EB::raw_header::set_src_id_num(uint16_t src_id_num) { src_id = (src_id & 0xF800) | (src_id_num & 0x7FF); }
+
 uint16_t EB::type_to_partition_id(const BankType b_type)
 {
   switch (b_type) {
@@ -139,3 +142,4 @@ uint16_t EB::old_to_new(EB::type_id_pair_type src_id_type)
 {
   return (type_to_partition_id(static_cast<BankType>(src_id_type.first)) << 11) | (src_id_type.second & 0x7FF);
 }
+#endif