Skip to content

Commit 99a7714

Browse files
wiechulashahor02
authored andcommitted
Add possibility for head only object
In case the file name is set to 'headersOnly' an empty object with only headers is created. This is e.g. necessary for pure redirect entries.
1 parent 754936f commit 99a7714

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

CCDB/src/UploadTool.cxx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -147,33 +147,41 @@ int main(int argc, char* argv[])
147147
meta[p.first] = p.second;
148148
}
149149

150-
TFile f(filename.c_str());
151-
auto key = f.GetKey(keyname.c_str());
152-
if (key) {
153-
// get type of key
154-
auto classname = key->GetClassName();
155-
auto tcl = TClass::GetClass(classname);
156-
auto object = f.Get<void>(keyname.c_str());
157-
if (tcl->InheritsFrom("TTree")) {
158-
auto tree = static_cast<TTree*>(object);
159-
tree->LoadBaskets(0x1L << 32); // make tree memory based
160-
tree->SetDirectory(nullptr);
161-
}
162-
// convert classname to typeinfo
163-
// typeinfo
164-
auto ti = tcl->GetTypeInfo();
165-
166-
std::cout << " Uploading an object of type " << key->GetClassName()
167-
<< " to path " << path << " with timestamp validity from " << starttimestamp
168-
<< " to " << endtimestamp << "\n";
169-
170-
api.storeAsTFile_impl(object, *ti, path, meta, starttimestamp, endtimestamp);
150+
if (filename == "headersOnly") {
151+
api.storeAsBinaryFile(nullptr, 0, "ignored", "", path, meta, starttimestamp, endtimestamp);
171152
if (!api.isSnapshotMode() && meta.find("adjustableEOV") != meta.end() && meta.find("default") == meta.end()) {
172-
o2::ccdb::CcdbObjectInfo oi(path, classname, filename, meta, starttimestamp, endtimestamp);
153+
o2::ccdb::CcdbObjectInfo oi(path, "", "", meta, starttimestamp, endtimestamp);
173154
o2::ccdb::adjustOverriddenEOV(api, oi);
174155
}
175156
} else {
176-
std::cerr << "Key " << keyname << " does not exist\n";
157+
TFile f(filename.c_str());
158+
auto key = f.GetKey(keyname.c_str());
159+
if (key) {
160+
// get type of key
161+
auto classname = key->GetClassName();
162+
auto tcl = TClass::GetClass(classname);
163+
auto object = f.Get<void>(keyname.c_str());
164+
if (tcl->InheritsFrom("TTree")) {
165+
auto tree = static_cast<TTree*>(object);
166+
tree->LoadBaskets(0x1L << 32); // make tree memory based
167+
tree->SetDirectory(nullptr);
168+
}
169+
// convert classname to typeinfo
170+
// typeinfo
171+
auto ti = tcl->GetTypeInfo();
172+
173+
std::cout << " Uploading an object of type " << key->GetClassName()
174+
<< " to path " << path << " with timestamp validity from " << starttimestamp
175+
<< " to " << endtimestamp << "\n";
176+
177+
api.storeAsTFile_impl(object, *ti, path, meta, starttimestamp, endtimestamp);
178+
if (!api.isSnapshotMode() && meta.find("adjustableEOV") != meta.end() && meta.find("default") == meta.end()) {
179+
o2::ccdb::CcdbObjectInfo oi(path, classname, filename, meta, starttimestamp, endtimestamp);
180+
o2::ccdb::adjustOverriddenEOV(api, oi);
181+
}
182+
} else {
183+
std::cerr << "Key " << keyname << " does not exist\n";
184+
}
177185
}
178186

179187
return 0;

0 commit comments

Comments
 (0)