Skip to content

Commit 038e493

Browse files
committed
Mat.LUT object must be saved as ccdb_object to be reachable from CCDB
1 parent c05ffa5 commit 038e493

6 files changed

Lines changed: 22 additions & 29 deletions

File tree

Detectors/Base/include/DetectorsBase/MatLayerCylSet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class MatLayerCylSet : public o2::gpu::FlatObject
7474
void populateFromTGeo(int ntrPerCel = 10);
7575
void optimizePhiSlices(float maxRelDiff = 0.05);
7676

77-
void dumpToTree(const std::string outName = "matbudTree.root") const;
78-
void writeToFile(std::string outFName = "matbud.root", std::string name = "MatBud");
79-
static MatLayerCylSet* loadFromFile(std::string inpFName = "matbud.root", std::string name = "MatBud");
77+
void dumpToTree(const std::string& outName = "matbudTree.root") const;
78+
void writeToFile(const std::string& outFName = "matbud.root");
79+
static MatLayerCylSet* loadFromFile(const std::string& inpFName = "matbud.root");
8080
static MatLayerCylSet* rectifyPtrFromFile(MatLayerCylSet* ptr);
8181

8282
void flatten();

Detectors/Base/src/MatLayerCylSet.cxx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void MatLayerCylSet::populateFromTGeo(int ntrPerCell)
116116
}
117117

118118
//________________________________________________________________________________
119-
void MatLayerCylSet::dumpToTree(const std::string outName) const
119+
void MatLayerCylSet::dumpToTree(const std::string& outName) const
120120
{
121121
/// dump per cell info to the tree
122122

@@ -157,37 +157,32 @@ void MatLayerCylSet::dumpToTree(const std::string outName) const
157157
}
158158

159159
//________________________________________________________________________________
160-
void MatLayerCylSet::writeToFile(std::string outFName, std::string name)
160+
void MatLayerCylSet::writeToFile(const std::string& outFName)
161161
{
162162
/// store to file
163163

164164
TFile outf(outFName.data(), "recreate");
165165
if (outf.IsZombie()) {
166166
return;
167167
}
168-
if (name.empty()) {
169-
name = "matBud";
170-
}
171-
outf.WriteObjectAny(this, Class(), name.data());
168+
outf.WriteObjectAny(this, Class(), "ccdb_object");
172169
outf.Close();
173170
}
174171

175172
//________________________________________________________________________________
176-
MatLayerCylSet* MatLayerCylSet::loadFromFile(std::string inpFName, std::string name)
173+
MatLayerCylSet* MatLayerCylSet::loadFromFile(const std::string& inpFName)
177174
{
178-
if (name.empty()) {
179-
name = "MatBud";
180-
}
181175
TFile inpf(inpFName.data());
182176
if (inpf.IsZombie()) {
183177
LOG(ERROR) << "Failed to open input file " << inpFName;
184178
return nullptr;
185179
}
186-
MatLayerCylSet* mb = rectifyPtrFromFile(reinterpret_cast<MatLayerCylSet*>(inpf.GetObjectChecked(name.data(), Class())));
187-
if (!mb) {
188-
LOG(ERROR) << "Failed to load " << name << " from " << inpFName;
180+
MatLayerCylSet* mb = reinterpret_cast<MatLayerCylSet*>(inpf.GetObjectChecked("ccdb_object", Class()));
181+
if (!mb && !(mb = reinterpret_cast<MatLayerCylSet*>(inpf.GetObjectChecked("MatBud", Class())))) { // for old objects
182+
LOG(ERROR) << "Failed to load mat.LUT from " << inpFName;
183+
return nullptr;
189184
}
190-
return mb;
185+
return rectifyPtrFromFile(mb);
191186
}
192187

193188
//________________________________________________________________________________

Detectors/Base/test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The optimized LUT will be stored in the matbud.root file.
1717

1818
Load it as:
1919
```
20-
auto mbr = o2::base::MatLayerCylSet::loadFromFile("matbud.root", "MatBud");
20+
auto mbr = o2::base::MatLayerCylSet::loadFromFile("matbud.root");
2121
```
2222

2323
To query mat. budget between 2 points use:

Detectors/Base/test/buildMatBudLUT.C

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@
2727

2828
o2::base::MatLayerCylSet mbLUT;
2929

30-
bool testMBLUT(std::string lutName = "MatBud", std::string lutFile = "matbud.root");
30+
bool testMBLUT(const std::string& lutFile = "matbud.root");
3131

32-
bool buildMatBudLUT(int nTst = 30, int maxLr = -1,
33-
std::string outName = "MatBud", std::string outFile = "matbud.root",
34-
std::string geomName = "");
32+
bool buildMatBudLUT(int nTst = 30, int maxLr = -1, const std::string& outFile = "matbud.root", const std::string& geomName = "");
3533

3634
struct LrData {
3735
float rMin = 0.f;
@@ -46,7 +44,7 @@ struct LrData {
4644
std::vector<LrData> lrData;
4745
void configLayers();
4846

49-
bool buildMatBudLUT(int nTst, int maxLr, std::string outName, std::string outFile, std::string geomNameInput)
47+
bool buildMatBudLUT(int nTst, int maxLr, const std::string& outFile, const std::string& geomNameInput)
5048
{
5149
auto geomName = o2::base::NameConf::getGeomFileName(geomNameInput);
5250
if (gSystem->AccessPathName(geomName.c_str())) { // if needed, create geometry
@@ -72,7 +70,7 @@ bool buildMatBudLUT(int nTst, int maxLr, std::string outName, std::string outFil
7270
mbLUT.optimizePhiSlices(); // move to populateFromTGeo
7371
mbLUT.flatten(); // move to populateFromTGeo
7472

75-
mbLUT.writeToFile(outFile, outName);
73+
mbLUT.writeToFile(outFile);
7674
sw.Stop();
7775
sw.Print();
7876
sw.Start(false);
@@ -83,13 +81,13 @@ bool buildMatBudLUT(int nTst, int maxLr, std::string outName, std::string outFil
8381
}
8482

8583
//_______________________________________________________________________
86-
bool testMBLUT(std::string lutName, std::string lutFile)
84+
bool testMBLUT(const std::string& lutFile)
8785
{
8886
// test reading and creation of copies
8987

90-
o2::base::MatLayerCylSet* mbr = o2::base::MatLayerCylSet::loadFromFile(lutFile, lutName);
88+
o2::base::MatLayerCylSet* mbr = o2::base::MatLayerCylSet::loadFromFile(lutFile);
9189
if (!mbr) {
92-
LOG(ERROR) << "Failed to read LUT " << lutName << " from " << lutFile;
90+
LOG(ERROR) << "Failed to read LUT from " << lutFile;
9391
return false;
9492
}
9593

GPU/GPUTracking/Standalone/tools/createLUT.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using namespace GPUCA_NAMESPACE::gpu;
99

1010
void createLUT()
1111
{
12-
o2::base::MatLayerCylSet* lut = o2::base::MatLayerCylSet::loadFromFile("matbud.root", "MatBud");
12+
o2::base::MatLayerCylSet* lut = o2::base::MatLayerCylSet::loadFromFile("matbud.root");
1313
gSystem->Load("libO2GPUTracking");
1414
GPUReconstruction* rec = GPUReconstruction::CreateInstance(GPUReconstruction::DeviceType::CPU);
1515
GPUChainTracking* chain = rec->AddChain<GPUChainTracking>();

GPU/Workflow/src/GPUWorkflowSpec.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ DataProcessorSpec getGPURecoWorkflowSpec(gpuworkflow::CompletionPolicyData* poli
248248
}
249249

250250
if (confParam.matLUTFile.size()) {
251-
config.configCalib.matLUT = o2::base::MatLayerCylSet::loadFromFile(confParam.matLUTFile.c_str(), "MatBud");
251+
config.configCalib.matLUT = o2::base::MatLayerCylSet::loadFromFile(confParam.matLUTFile.c_str());
252252
}
253253

254254
if (confParam.dEdxFile.size()) {

0 commit comments

Comments
 (0)