Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DataFormats/Detectors/TPC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ o2_add_library(

o2_target_root_dictionary(
DataFormatsTPC
EXTRA_PATCH src/VectorPadflagsCustomStreamer.cxx
HEADERS include/DataFormatsTPC/ClusterGroupAttribute.h
include/DataFormatsTPC/ClusterNative.h
include/DataFormatsTPC/ClusterNativeHelper.h
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/Detectors/TPC/src/DataFormatsTPCLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
#pragma link C++ class o2::tpc::ClusterHardwareContainerFixedSize < 8192> + ;
#pragma link C++ class o2::tpc::ClusterNativeContainer + ;
#pragma link C++ class o2::tpc::Digit + ;
#pragma link C++ enum o2::tpc::PadFlags + ; // enum itself
#pragma link C++ class o2::tpc::ZeroSuppressedContainer8kb + ;
#pragma link C++ class std::vector < o2::tpc::ClusterNative> + ;
#pragma link C++ class std::vector < o2::tpc::ClusterNativeContainer> + ;
#pragma link C++ class std::vector < o2::tpc::ClusterHardware> + ;
#pragma link C++ class std::vector < o2::tpc::ClusterHardwareContainerFixedSize < 8192>> + ;
#pragma link C++ class std::vector < o2::tpc::ClusterHardwareContainer8kb> + ;
#pragma link C++ class std::vector < o2::tpc::Digit> + ;
#pragma link C++ class std::vector < o2::tpc::PadFlags> + ;
#pragma link C++ class std::vector < o2::tpc::ZeroSuppressedContainer8kb> + ;
#pragma link C++ class o2::tpc::TrackTPC + ;
#pragma link C++ class o2::tpc::LaserTrack + ;
Expand Down
56 changes: 56 additions & 0 deletions DataFormats/Detectors/TPC/src/VectorPadflagsCustomStreamer.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

using std::vector;

void VectorPadFlagsStreamer(TBuffer& R__b, void* objp)
{
std::vector<o2::tpc::PadFlags>* obj = static_cast<std::vector<o2::tpc::PadFlags>*>(objp);
if (R__b.IsReading()) {
std::vector<int> R__stl;
R__stl.clear();
int R__n;
R__b >> R__n;
R__stl.reserve(R__n);
for (int R__i = 0; R__i < R__n; R__i++) {
Int_t readtemp;
R__b >> readtemp;
R__stl.push_back(readtemp);
}
auto data = reinterpret_cast<unsigned short*>(R__stl.data());
for (int i = 0; i < R__n; ++i) {
obj->push_back(static_cast<o2::tpc::PadFlags>(data[i]));
}
} else {
// We always save things with the old format.
R__b << (int)obj->size() / 2;
for (size_t i = 0; i < obj->size(); i++) {
R__b << (short)obj->at(i);
}
}
}

#define RootStreamerLocal(name, STREAMER) \
namespace ROOT \
{ \
\
/** \cond HIDDEN_SYMBOLS */ \
static auto _R__UNIQUE_(R__dummyStreamer) = \
[]() { TClass::GetClass<name>()->SetStreamerFunc(STREAMER); return 0; }(); \
/** \endcond */ \
R__UseDummy(_R__UNIQUE_(R__dummyStreamer)); \
}

// Let's not try to fix the old ROOT version, so that we can build
// the new ROOT with the patched code in the CI.
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 00)
RootStreamerLocal(vector<o2::tpc::PadFlags>, VectorPadFlagsStreamer);
#endif
9 changes: 6 additions & 3 deletions cmake/AddRootDictionary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function(add_root_dictionary target)
1
A
""
"LINKDEF"
"LINKDEF;EXTRA_PATCH"
"HEADERS;BASENAME")
if(A_UNPARSED_ARGUMENTS)
message(
Expand Down Expand Up @@ -112,7 +112,7 @@ function(add_root_dictionary target)
set(pcmBase ${dictionary}_rdict.pcm)
set(pcmFile ${lib_output_dir}/${pcmBase})
set(rootmapFile ${lib_output_dir}/lib${basename}.rootmap)

set(O2_TARGETPCMMAP_TARGET "${O2_TARGETPCMMAP_TARGET};${target}" CACHE INTERNAL "target/PCM map (target)")
set(O2_TARGETPCMMAP_PCM "${O2_TARGETPCMMAP_PCM};${pcmFile}" CACHE INTERNAL "target/PCM map (pcm)")

Expand All @@ -132,6 +132,7 @@ function(add_root_dictionary target)
set(includeDirs $<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>)
set(includeDirs $<REMOVE_DUPLICATES:${includeDirs}>)

list(LENGTH A_EXTRA_PATCH hasExtraPatch)
# add a custom command to generate the dictionary using rootcling
# cmake-format: off
add_custom_command(
Expand All @@ -146,11 +147,13 @@ function(add_root_dictionary target)
--include_dirs -I$<JOIN:${includeDirs},$<SEMICOLON>-I>
$<$<BOOL:${prop}>:--compile_defs>
$<$<BOOL:${prop}>:-D$<JOIN:${prop},$<SEMICOLON>-D>>
$<$<BOOL:${hasExtraPatch}>:--extra-patch>
$<$<BOOL:${hasExtraPatch}>:${CMAKE_CURRENT_LIST_DIR}/${A_EXTRA_PATCH}>
--pcmdeps "$<REMOVE_DUPLICATES:${list_pcm_deps_${target}}>"
--headers "${headers}"
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${pcmBase} ${pcmFile}
DEPENDS ${headers} "$<REMOVE_DUPLICATES:${list_pcm_deps_${target}}>")
DEPENDS ${headers} "$<REMOVE_DUPLICATES:${list_pcm_deps_${target}}>" ${A_EXTRA_PATCH})
# cmake-format: on

# add dictionary source to the target sources
Expand Down
16 changes: 9 additions & 7 deletions cmake/O2TargetRootDictionary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,9 @@ function(o2_target_root_dictionary baseTargetName)
1
A
""
"LINKDEF"
"LINKDEF;EXTRA_PATCH"
"HEADERS")

if(A_UNPARSED_ARGUMENTS)
message(
FATAL_ERROR "Unexpected unparsed arguments: ${A_UNPARSED_ARGUMENTS}")
endif()

if(${ARGC} LESS 1)
message(
FATAL_ERROR
Expand Down Expand Up @@ -96,6 +91,13 @@ function(o2_target_root_dictionary baseTargetName)

# now that we have the O2 specific stuff computed, delegate the actual work to
# the add_root_dictionary function
add_root_dictionary(${target} HEADERS ${A_HEADERS} LINKDEF ${A_LINKDEF})
if(NOT A_EXTRA_PATCH)
add_root_dictionary(${target} HEADERS ${A_HEADERS} LINKDEF ${A_LINKDEF})
else()
add_root_dictionary(${target}
EXTRA_PATCH ${A_EXTRA_PATCH}
HEADERS ${A_HEADERS}
LINKDEF ${A_LINKDEF})
endif()

endfunction()
23 changes: 23 additions & 0 deletions cmake/rootcling_wrapper.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ while [[ $# -gt 0 ]]; do
PCMDEPS="$2"
shift 2
;;
--extra-patch)
EXTRA_PATCH="$2"
shift 2
;;
*)
if [[ -z "$1" ]]; then
shift
Expand Down Expand Up @@ -82,6 +86,18 @@ esac

LOGFILE=${DICTIONARY_FILE}.log

echo @CMAKE_COMMAND@ -E env "LD_LIBRARY_PATH=$libpath" @ROOT_rootcling_CMD@ \
-f $DICTIONARY_FILE \
-inlineInputHeader \
-noGlobalUsingStd \
-rmf ${ROOTMAP_FILE} \
-rml ${ROOTMAP_LIBRARY_NAME} \
${INCLUDE_DIRS//;/ } \
${COMPILE_DEFINITIONS//;/ } \
${PCMDEPS:+-m }${PCMDEPS//;/ -m } \
${HEADERS//;/ } \
> ${LOGFILE} 2>&1 || ROOTCLINGRETVAL=$?

@CMAKE_COMMAND@ -E env "LD_LIBRARY_PATH=$libpath" @ROOT_rootcling_CMD@ \
-f $DICTIONARY_FILE \
-inlineInputHeader \
Expand All @@ -94,6 +110,13 @@ LOGFILE=${DICTIONARY_FILE}.log
${HEADERS//;/ } \
> ${LOGFILE} 2>&1 || ROOTCLINGRETVAL=$?

# Add the extra patch file at the end of the generated dictionary.
# This is needed to inject custom streamers (e.g. for std::vector<PadFlags>)
# to our dictionary.
if [ ! X"${EXTRA_PATCH}" = X ]; then
cat $EXTRA_PATCH >> ${DICTIONARY_FILE}
fi

if [[ ${ROOTCLINGRETVAL:-0} != "0" ]]; then
cat ${LOGFILE} >&2
rm -f $DICTIONARY_FILE
Expand Down