-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathUploadMatBudLUT.C
More file actions
39 lines (36 loc) · 1.45 KB
/
UploadMatBudLUT.C
File metadata and controls
39 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include "CommonUtils/NameConf.h"
#include "CCDB/CcdbApi.h"
#include "CCDB/BasicCCDBManager.h"
#include "Framework/Logger.h"
#include <fmt/format.h>
#include "DetectorsBase/MatLayerCylSet.h"
#include "CommonUtils/StringUtils.h"
#endif
// upload material LUT to CCDB
bool UploadMatBudLUT(const std::string& matLUTFile, long tmin = 0, long tmax = -1, const std::string& url = "GLO/Param/MatLUT", const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080")
{
o2::base::MatLayerCylSet* lut = nullptr;
if (o2::utils::Str::pathExists(matLUTFile)) {
lut = o2::base::MatLayerCylSet::loadFromFile(matLUTFile);
} else {
LOG(error) << "Material LUT " << matLUTFile << " file is absent";
return false;
}
o2::ccdb::CcdbApi api;
api.init(ccdbHost.c_str()); // or http://localhost:8080 for a local installation
std::map<std::string, std::string> metadata; // can be empty
metadata["comment"] = "Material lookup table";
api.storeAsTFileAny(lut, url, metadata, tmin, tmax);
return true;
}
auto fetchMatBudLUT(const std::string& url = "GLO/Param/MatLUT", const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080")
{
auto& mgr = o2::ccdb::BasicCCDBManager::instance();
mgr.setURL(ccdbHost);
auto lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(mgr.get<o2::base::MatLayerCylSet>(url));
if (!lut) {
LOG(error) << "Failed to fetch material LUT from " << ccdbHost << "/" << url;
}
return lut;
}