29void* extractFromTFile(TFile& file, TClass
const* cl,
const char* what)
34 auto object =
file.GetObjectChecked(what, cl);
38 std::string objectName(cl->GetName());
39 objectName.erase(std::find_if(objectName.rbegin(), objectName.rend(), [](
unsigned char ch) {
40 return !std::isspace(ch);
43 objectName.erase(objectName.begin(), std::find_if(objectName.begin(), objectName.end(), [](
unsigned char ch) {
44 return !std::isspace(ch);
47 object =
file.GetObjectChecked(objectName.c_str(), cl);
48 LOG(warn) <<
"Did not find object under expected name " << what;
52 LOG(warn) <<
"Found object under deprecated name " << cl->GetName();
57 if (cl->InheritsFrom(
"TObject")) {
62 tree->LoadBaskets(0x1L << 32);
63 tree->SetDirectory(
nullptr);
66 auto h =
dynamic_cast<TH1*
>((
TObject*)
object);
68 h->SetDirectory(
nullptr);
82 Int_t previousErrorLevel = gErrorIgnoreLevel;
83 gErrorIgnoreLevel = kFatal;
84 auto* dh = o2::header::get<o2::header::DataHeader*>(
ref.header);
85 const char* buff =
const_cast<char*
>(
ref.payload);
86 size_t flSize = dh->payloadSize;
88 constexpr char FlatHeaderAnnot[] =
"$HEADER$";
89 constexpr int Offset =
sizeof(
int) +
sizeof(FlatHeaderAnnot);
91 LOGP(
debug,
"DHPayloadSize={}>{} Ref:{}/{} Cmp {}:{}", dh->payloadSize, Offset, dh->dataOrigin.as<std::string>(), dh->dataDescription.as<std::string>(), std::string{buff + dh->payloadSize - sizeof(FlatHeaderAnnot)}, std::string{FlatHeaderAnnot});
93 if (dh->payloadSize >= Offset &&
94 !std::strncmp(buff + dh->payloadSize -
sizeof(FlatHeaderAnnot), FlatHeaderAnnot,
sizeof(FlatHeaderAnnot))) {
95 headerSize = *
reinterpret_cast<const int*
>(buff + dh->payloadSize - Offset);
98 LOGP(fatal,
"Anomalous flattened header size {} extracted for CCDB object {}/{}", headerSize, dh->dataOrigin.as<std::string>(), dh->dataDescription.as<std::string>());
100 TMemFile memFile(
"name",
const_cast<char*
>(
ref.payload), dh->payloadSize - headerSize,
"READ");
101 gErrorIgnoreLevel = previousErrorLevel;
102 if (memFile.IsZombie()) {
106 TClass* tcl = TClass::GetClass(tinfo);
107 result = extractFromTFile(memFile, tcl,
"ccdb_object");
109 throw runtime_error_f(
"Couldn't retrieve object corresponding to %s from TFile", tcl->GetName());
117 auto* dh = o2::header::get<o2::header::DataHeader*>(
ref.header);
118 const char* buff =
const_cast<char*
>(
ref.payload);
120 constexpr char FlatHeaderAnnot[] =
"$HEADER$";
121 constexpr int Offset =
sizeof(
int) +
sizeof(FlatHeaderAnnot);
122 int headerSize = 0, ss0 = 0;
123 std::map<std::string, std::string>
res;
124 if (dh->payloadSize >= Offset && !std::strncmp(buff + dh->payloadSize -
sizeof(FlatHeaderAnnot), FlatHeaderAnnot,
sizeof(FlatHeaderAnnot))) {
125 headerSize = *
reinterpret_cast<const int*
>(buff + dh->payloadSize - Offset);
127 LOGP(warn,
"CCDB headers were not added to condition object blob, returning dummy header map");
131 if (headerSize < 0) {
132 LOGP(fatal,
"Anomalous flattened header size {} extracted for CCDB object {}/{}", headerSize, dh->dataOrigin.as<std::string>(), dh->dataDescription.as<std::string>());
135 buff += dh->payloadSize - headerSize;
136 headerSize -= Offset;
137 const char* str0 = &buff[ss0++];
138 while (ss0 < headerSize) {
139 if (buff[ss0++] == 0) {
143 res.emplace(std::string(str0), std::string(&buff[ss0]));
144 LOGP(
debug,
"Header{} {}:{}",
res.size(), std::string(str0), std::string(&buff[ss0]));
154 auto* dh = o2::header::get<o2::header::DataHeader*>(
ref.header);
155 const char* buff =
ref.payload;
156 size_t payloadSize = dh->payloadSize;
157 constexpr char FlatHeaderAnnot[] =
"$HEADER$";
158 constexpr size_t Offset =
sizeof(
int) +
sizeof(FlatHeaderAnnot);
160 if (payloadSize >= Offset &&
161 !std::strncmp(buff + payloadSize -
sizeof(FlatHeaderAnnot), FlatHeaderAnnot,
sizeof(FlatHeaderAnnot))) {
162 headerSize = *
reinterpret_cast<const int*
>(buff + payloadSize - Offset);
164 return {buff, payloadSize - headerSize};
Class for time synchronization of RawReader instances.
Defining ITS Vertex explicitly as messageable.
RuntimeErrorRef runtime_error_f(const char *,...)
int32_t const char * file
static std::map< std::string, std::string > extractCCDBHeaders(DataRef const &ref)
static void * decodeCCDB(DataRef const &ref, std::type_info const &info)
static std::span< const char > getCCDBPayloadBlob(DataRef const &ref)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))