diff --git a/CMakeLists.txt b/CMakeLists.txt
index 40da32e7cb7a47a4dd2af81d45dae83b5f7594a2..6afe8ca7623be5a5cde9f2fb1bb6b54f1f8dea34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -498,6 +498,8 @@ if(NOT CBMROOT_MINIMAL)
       "${CMAKE_INSTALL_PREFIX}/include/mvd"
       "${CMAKE_INSTALL_PREFIX}/include/littrack"
       "${CMAKE_INSTALL_PREFIX}/include/KF"
+      "${CMAKE_INSTALL_PREFIX}/include/AnalysisTree"
+      "${CMAKE_INSTALL_PREFIX}/include/AnalysisTreeQA"
      )
   set(CMAKE_INSTALL_LIBDIR lib)
   SET(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/cbmroot)
diff --git a/external/AnalysisTree.patch b/external/AnalysisTree.patch
new file mode 100644
index 0000000000000000000000000000000000000000..0b79724ec96a06f3d3a25794b25c82db5e8c30cc
--- /dev/null
+++ b/external/AnalysisTree.patch
@@ -0,0 +1,112 @@
+diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
+index ab4c300..765e1db 100644
+--- a/core/CMakeLists.txt
++++ b/core/CMakeLists.txt
+@@ -16,7 +16,28 @@ string(REPLACE ".cpp" ".hpp" HEADERS "${SOURCES}")
+ list(APPEND HEADERS "Constants.hpp" "Detector.hpp")
+ 
+ add_library(AnalysisTreeBase SHARED ${SOURCES} G__AnalysisTreeBase.cxx)
+-ROOT_GENERATE_DICTIONARY(G__AnalysisTreeBase ${HEADERS} LINKDEF AnalysisTreeCoreLinkDef.h)
++
++if(${ROOT_VERSION} VERSION_GREATER 6.18.0)
++  message(STATUS "ROOT ${ROOT_VERSION}, use the standard ROOT_GENERATE_DICTIONARY macro.")
++  ROOT_GENERATE_DICTIONARY(G__AnalysisTreeBase ${HEADERS} LINKDEF AnalysisTreeCoreLinkDef.h)
++else()
++  message(STATUS "ROOT ${ROOT_VERSION} has a broken ROOT_GENERATE_DICTIONARY macro, so build the dictionary ourself.")
++  set(dictionary_includes ${HEADERS})
++  set(dictionary_linkdef "AnalysisTreeCoreLinkDef.h")
++  set(dictionary_source "G__AnalysisTreeBase.cxx")
++
++  add_custom_command(OUTPUT ${dictionary_source}
++                     COMMAND ${ROOT_rootcling_CMD} -f ${dictionary_source}
++                     -rml libAnalysisTreeBase
++                     -rmf libAnalysisTreeBase.rootmap
++                     -s   libAnalysisTreeBase
++                     -inlineInputHeader
++                     -I${CMAKE_CURRENT_SOURCE_DIR} ${dictionary_includes}
++                     ${CMAKE_CURRENT_SOURCE_DIR}/${dictionary_linkdef}
++                     DEPENDS ${dictionary_includes} ${dictionary_linkdef}
++                    )
++endif()
++
+ target_link_libraries(AnalysisTreeBase ${ROOT_LIBRARIES} EG)
+ 
+ add_custom_command(TARGET AnalysisTreeBase PRE_BUILD
+diff --git a/core/Constants.hpp b/core/Constants.hpp
+index ed7b9c6..f9cbcc3 100644
+--- a/core/Constants.hpp
++++ b/core/Constants.hpp
+@@ -109,4 +109,4 @@ enum EventHeaderFields : ShortInt_t {
+ 
+ }// namespace AnalysisTree
+ 
+-#endif
+\ No newline at end of file
++#endif
+diff --git a/core/Module.hpp b/core/Module.hpp
+index 9c523aa..c54d17e 100644
+--- a/core/Module.hpp
++++ b/core/Module.hpp
+@@ -93,4 +93,4 @@ class ModulePosition : public IndexedObject {
+ };
+ }// namespace AnalysisTree
+ 
+-#endif
+\ No newline at end of file
++#endif
+diff --git a/infra/CMakeLists.txt b/infra/CMakeLists.txt
+index ed7bd9b..a63a7b1 100644
+--- a/infra/CMakeLists.txt
++++ b/infra/CMakeLists.txt
+@@ -30,12 +30,34 @@ add_library(AnalysisTreeInfra SHARED ${SOURCES} G__AnalysisTreeInfra.cxx)
+ target_compile_definitions(AnalysisTreeInfra PUBLIC
+         $<$<BOOL:${Boost_FOUND}>:ANALYSISTREE_BOOST_FOUND>)
+ 
+-ROOT_GENERATE_DICTIONARY(G__AnalysisTreeInfra ${HEADERS}
+-        LINKDEF AnalysisTreeInfraLinkDef.h
+-        OPTIONS
+-            -I${CMAKE_BINARY_DIR}/include
+-            $<$<BOOL:${Boost_FOUND}>:-DANALYSISTREE_BOOST_FOUND>
+-        )
++if(${ROOT_VERSION} VERSION_GREATER 6.18.0)
++  message(STATUS "ROOT ${ROOT_VERSION}, use the standard ROOT_GENERATE_DICTIONARY macro.")
++  ROOT_GENERATE_DICTIONARY(G__AnalysisTreeInfra ${HEADERS}
++          LINKDEF AnalysisTreeInfraLinkDef.h
++          OPTIONS
++              -I${CMAKE_BINARY_DIR}/include
++              $<$<BOOL:${Boost_FOUND}>:-DANALYSISTREE_BOOST_FOUND>
++          )
++else()
++  message(STATUS "ROOT ${ROOT_VERSION} has a broken ROOT_GENERATE_DICTIONARY macro, so build the dictionary ourself.")
++  set(dictionary_includes ${HEADERS})
++  set(dictionary_linkdef "AnalysisTreeInfraLinkDef.h")
++  set(dictionary_source "G__AnalysisTreeInfra.cxx")
++
++  add_custom_command(OUTPUT ${dictionary_source}
++                     COMMAND ${ROOT_rootcling_CMD} -f ${dictionary_source}
++                     -rml libAnalysisTreeInfra
++                     -rmf libAnalysisTreeInfra.rootmap
++                     -s   libAnalysisTreeInfra
++                     -inlineInputHeader
++                     -I${CMAKE_CURRENT_SOURCE_DIR} ${dictionary_includes}
++                     -I${CMAKE_BINARY_DIR}/include
++                     -I${CMAKE_BINARY_DIR}/include/AnalysisTree
++                     $<$<BOOL:${Boost_FOUND}>:-DANALYSISTREE_BOOST_FOUND>
++                     ${CMAKE_CURRENT_SOURCE_DIR}/${dictionary_linkdef}
++                     DEPENDS ${dictionary_includes} ${dictionary_linkdef}
++                    )
++endif()
+ target_link_libraries(AnalysisTreeInfra
+         PUBLIC
+             ${ROOT_LIBRARIES}
+diff --git a/infra/SimpleCut.hpp b/infra/SimpleCut.hpp
+index 4ec5458..21fe68c 100644
+--- a/infra/SimpleCut.hpp
++++ b/infra/SimpleCut.hpp
+@@ -116,4 +116,4 @@ SimpleCut RangeCut(const std::string& variable_name, float lo, float hi, const s
+ SimpleCut EqualsCut(const std::string& variable_name, int value, const std::string& title = "");
+ 
+ }// namespace AnalysisTree
+-#endif//ANALYSISTREE_SIMPLECUT_H
+\ No newline at end of file
++#endif//ANALYSISTREE_SIMPLECUT_H
diff --git a/external/AnalysisTreeQA.patch b/external/AnalysisTreeQA.patch
new file mode 100644
index 0000000000000000000000000000000000000000..eda48c5c76daaf5b3fdaf238393428f9747befcd
--- /dev/null
+++ b/external/AnalysisTreeQA.patch
@@ -0,0 +1,45 @@
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index ee90134..0861bc8 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -20,11 +20,35 @@ endif ()
+ 
+ #add_dependencies(AnalysisTreeQA ${PROJECT_DEPENDENCIES})
+ 
+-ROOT_GENERATE_DICTIONARY(G__AnalysisTreeQA
+-        ${HEADERS}
+-        LINKDEF AnalysisTreeQALinkDef.h
+-        OPTIONS -I${CMAKE_BINARY_DIR}/include
+-        )
++if(${ROOT_VERSION} VERSION_GREATER 6.18.0)
++  message(STATUS "ROOT ${ROOT_VERSION}, use the standard ROOT_GENERATE_DICTIONARY macro.")
++  ROOT_GENERATE_DICTIONARY(G__AnalysisTreeQA
++          ${HEADERS}
++          LINKDEF AnalysisTreeQALinkDef.h
++          OPTIONS -I${CMAKE_BINARY_DIR}/include
++          )
++else()
++  message(STATUS "ROOT ${ROOT_VERSION} has a broken ROOT_GENERATE_DICTIONARY macro, so build the dictionary ourself.")
++  set(dictionary_includes ${HEADERS})
++  set(dictionary_linkdef "AnalysisTreeQALinkDef.h")
++  set(dictionary_source "G__AnalysisTreeQA.cxx")
++
++  add_custom_command(OUTPUT ${dictionary_source}
++                     COMMAND ${ROOT_rootcling_CMD} -f ${dictionary_source}
++                     -rml libAnalysisTreeQA
++                     -rmf libAnalysisTreeQA.rootmap
++                     -s   libAnalysisTreeQA
++                     -inlineInputHeader
++                     -I${AnalysisTree_INCLUDE_DIR}
++                     -I${CMAKE_CURRENT_SOURCE_DIR}
++                     ${dictionary_includes}
++                     ${CMAKE_CURRENT_SOURCE_DIR}/${dictionary_linkdef}
++                     DEPENDS ${dictionary_includes} ${dictionary_linkdef}
++                    )
++endif()
++
++
++
+ target_link_libraries(AnalysisTreeQA
+         PUBLIC
+         AnalysisTreeBase
diff --git a/external/InstallAnalysisTree.cmake b/external/InstallAnalysisTree.cmake
index 3793682c2da3bd55ead6e78e52b95fafc34473d2..0adf61ee62d9b2311328dd3a7013b58a3b8dc8d4 100644
--- a/external/InstallAnalysisTree.cmake
+++ b/external/InstallAnalysisTree.cmake
@@ -10,6 +10,7 @@ download_project_if_needed(PROJECT         AnalysisTree_source
         GIT_TAG         ${ANALYSISTREE_VERSION}
         SOURCE_DIR      ${CMAKE_CURRENT_SOURCE_DIR}/AnalysisTree
         TEST_FILE       CMakeLists.txt
+        PATCH_COMMAND   "patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/AnalysisTree.patch"
         )
 
 If(ProjectUpdated)
diff --git a/external/InstallAnalysisTreeQA.cmake b/external/InstallAnalysisTreeQA.cmake
index 8b57eb3067d78bf783bd0571532889c99d7dc7c9..eff500d4c1b2e42f8a77d4e3ad6faba0ed6f9776 100644
--- a/external/InstallAnalysisTreeQA.cmake
+++ b/external/InstallAnalysisTreeQA.cmake
@@ -9,6 +9,7 @@ download_project_if_needed(PROJECT         AnalysisTreeQA_source
         GIT_TAG         ${ANALYSISTREEQA_VERSION}
         SOURCE_DIR      ${CMAKE_CURRENT_SOURCE_DIR}/AnalysisTreeQA
         TEST_FILE       CMakeLists.txt
+        PATCH_COMMAND   "patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/AnalysisTreeQA.patch"
         )
 
 If(ProjectUpdated)