Skip to content

Commit fdd6ae2

Browse files
committed
new patch for TPCFlagsMemberCustomStreamer.cxx
1 parent 21f77e0 commit fdd6ae2

1 file changed

Lines changed: 32 additions & 25 deletions

File tree

Detectors/TPC/base/src/TPCFlagsMemberCustomStreamer.cxx

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
#include <TMemberStreamer.h>
1414
#include <TBuffer.h>
1515
#include <TClass.h>
16+
#include <TError.h>
1617
#include <DataFormatsTPC/Defs.h>
17-
#include <cstdlib>
1818
#include <iostream>
19+
#include <cstdlib>
20+
#include <vector>
1921

2022
// to enable assert statements
2123
#ifdef NDEBUG
@@ -66,32 +68,37 @@ void MemberVectorPadFlagsStreamer(TBuffer& R__b, void* objp, int n)
6668
}
6769
}
6870

69-
// Register the streamer via static global initialization on library load.
70-
// The streamer is only correct in combination with new ROOT.
71-
//
72-
// Do not use ROOT::GenerateInitInstance here: it is not available in all ROOT
73-
// builds/versions where this file is compiled. Also do not assert if the class
74-
// lookup fails during static initialization: depending on library load order the
75-
// dictionary may not be available yet, and killing the process at this point
76-
// makes the whole build/load fail.
71+
// register the streamer via static global initialization (on library load)
72+
// the streamer is only correct in combination with new ROOT
7773
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 00)
78-
namespace
74+
namespace ROOT
7975
{
80-
[[maybe_unused]] __attribute__((used)) int _R__dummyStreamer_3 = []() {
81-
if (std::getenv("TPC_PADFLAGS_STREAMER_OFF")) {
82-
return 0;
83-
}
76+
static __attribute__((used)) int _R__dummyStreamer_3 =
77+
([]() {
78+
if (getenv("TPC_PADFLAGS_STREAMER_OFF")) {
79+
return 0;
80+
}
8481

85-
auto* cl = TClass::GetClass<o2::tpc::CalArray<o2::tpc::PadFlags>>();
86-
if (!cl) {
87-
std::cerr << "Warning in TPCFlagsMemberCustomStreamer: could not find "
88-
<< "TClass for o2::tpc::CalArray<o2::tpc::PadFlags>; "
89-
<< "PadFlags member streamer was not registered" << std::endl;
90-
return 0;
91-
}
82+
auto cl = TClass::GetClass(
83+
"o2::tpc::CalArray<o2::tpc::PadFlags>",
84+
true, // try to autoload dictionary
85+
true // silent
86+
);
87+
88+
if (!cl) {
89+
::Warning("TPCFlagsMemberCustomStreamer",
90+
"could not find TClass for "
91+
"o2::tpc::CalArray<o2::tpc::PadFlags>; "
92+
"PadFlags member streamer was not registered");
93+
return 0;
94+
}
95+
96+
cl->AdoptMemberStreamer(
97+
"mData",
98+
new TMemberStreamer(MemberVectorPadFlagsStreamer)
99+
);
92100

93-
cl->AdoptMemberStreamer("mData", new TMemberStreamer(MemberVectorPadFlagsStreamer));
94-
return 0;
95-
}();
96-
} // namespace
101+
return 0;
102+
})();
103+
} // namespace ROOT
97104
#endif

0 commit comments

Comments
 (0)