28void* extractFromTFile(TFile&
file, TClass
const* cl,
const char* what)
33 auto object =
file.GetObjectChecked(what, cl);
37 std::string objectName(cl->GetName());
38 objectName.erase(std::find_if(objectName.rbegin(), objectName.rend(), [](
unsigned char ch) {
39 return !std::isspace(ch);
42 objectName.erase(objectName.begin(), std::find_if(objectName.begin(), objectName.end(), [](
unsigned char ch) {
43 return !std::isspace(ch);
46 object =
file.GetObjectChecked(objectName.c_str(), cl);
47 LOG(warn) <<
"Did not find object under expected name " << what;
51 LOG(warn) <<
"Found object under deprecated name " << cl->GetName();
56 if (cl->InheritsFrom(
"TObject")) {
61 tree->LoadBaskets(0x1L << 32);
62 tree->SetDirectory(
nullptr);
65 auto h =
dynamic_cast<TH1*
>((
TObject*)
object);
67 h->SetDirectory(
nullptr);
81 Int_t previousErrorLevel = gErrorIgnoreLevel;
82 gErrorIgnoreLevel = kFatal;
83 auto* dh = o2::header::get<o2::header::DataHeader*>(
ref.header);
84 const char* buff =
const_cast<char*
>(
ref.payload);
85 size_t flSize = dh->payloadSize;
87 constexpr char FlatHeaderAnnot[] =
"$HEADER$";
88 constexpr int Offset =
sizeof(
int) +
sizeof(FlatHeaderAnnot);
90 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});
92 if (dh->payloadSize >= Offset &&
93 !std::strncmp(buff + dh->payloadSize -
sizeof(FlatHeaderAnnot), FlatHeaderAnnot,
sizeof(FlatHeaderAnnot))) {
94 headerSize = *
reinterpret_cast<const int*
>(buff + dh->payloadSize - Offset);
97 LOGP(fatal,
"Anomalous flattened header size {} extracted", headerSize);
99 TMemFile memFile(
"name",
const_cast<char*
>(
ref.payload), dh->payloadSize - headerSize,
"READ");
100 gErrorIgnoreLevel = previousErrorLevel;
101 if (memFile.IsZombie()) {
105 TClass* tcl = TClass::GetClass(tinfo);
106 result = extractFromTFile(memFile, tcl,
"ccdb_object");
108 throw runtime_error_f(
"Couldn't retrieve object corresponding to %s from TFile", tcl->GetName());
116 auto* dh = o2::header::get<o2::header::DataHeader*>(
ref.header);
117 const char* buff =
const_cast<char*
>(
ref.payload);
119 constexpr char FlatHeaderAnnot[] =
"$HEADER$";
120 constexpr int Offset =
sizeof(
int) +
sizeof(FlatHeaderAnnot);
121 int headerSize = 0, ss0 = 0;
122 std::map<std::string, std::string>
res;
123 if (dh->payloadSize >= Offset && !std::strncmp(buff + dh->payloadSize -
sizeof(FlatHeaderAnnot), FlatHeaderAnnot,
sizeof(FlatHeaderAnnot))) {
124 headerSize = *
reinterpret_cast<const int*
>(buff + dh->payloadSize - Offset);
126 LOGP(warn,
"CCDB headers were not added to condition object blob, returning dummy header map");
130 if (headerSize < 0) {
131 LOGP(fatal,
"Anomalous flattened header size {} extracted", headerSize);
134 buff += dh->payloadSize - headerSize;
135 headerSize -= Offset;
136 const char* str0 = &buff[ss0++];
137 while (ss0 < headerSize) {
138 if (buff[ss0++] == 0) {
142 res.emplace(std::string(str0), std::string(&buff[ss0]));
143 LOGP(
debug,
"Header{} {}:{}",
res.size(), std::string(str0), std::string(&buff[ss0]));
Class for time synchronization of RawReader instances.
Defining PrimaryVertex explicitly as messageable.
RuntimeErrorRef runtime_error_f(const char *,...)
static std::map< std::string, std::string > extractCCDBHeaders(DataRef const &ref)
static void * decodeCCDB(DataRef const &ref, std::type_info const &info)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))