Skip to content

Commit 0b2a357

Browse files
committed
Macro to extract matLUT layers covering certain R-range
1 parent 0dd4156 commit 0b2a357

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

Detectors/Base/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ if(BUILD_SIMULATION)
7878
VMCWORKDIR=${CMAKE_BINARY_DIR}/stage/${CMAKE_INSTALL_DATADIR})
7979
endif()
8080

81+
install(FILES test/buildMatBudLUT.C
82+
test/extractLUTLayers.C
83+
DESTINATION share/macro/)
84+
8185
o2_add_test_root_macro(test/buildMatBudLUT.C
8286
PUBLIC_LINK_LIBRARIES O2::DetectorsBase
8387
LABELS detectorsbase)
88+
89+
o2_add_test_root_macro(test/extractLUTLayers.C
90+
PUBLIC_LINK_LIBRARIES O2::DetectorsBase
91+
LABELS detectorsbase)

Detectors/Base/test/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ auto mb = mbl.getMatBudget(xyz0[0],xyz0[1],xyz0[2], xyz1[0],xyz1[1],xyz1[2]);
3030
3131
std::cout << "<rho>= " << mb.meanRho << " <x/X0>= " << mb.meanX2X0 << "\n";
3232
```
33+
34+
Macro `extractLUTLayers.C` can be used to extract layers covering certain radius range to obtain more compact LUT.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#if !defined(__CLING__) || defined(__ROOTCLING__)
13+
#include "DetectorsBase/MatLayerCylSet.h"
14+
#include "Framework/Logger.h"
15+
#include "CCDB/BasicCCDBManager.h"
16+
#include <regex>
17+
#endif
18+
19+
// Macro to extract layers covering selected radial range into the separate LUT file.
20+
21+
o2::base::MatLayerCylSet* extractLUTLayers(const o2::base::MatLayerCylSet* src, const std::string& outName, float rmin = 0., float rmax = 84., float toler = 1e-6)
22+
{
23+
auto* cp = src->extractCopy(rmin, rmax, toler);
24+
if (!cp) {
25+
LOGP(error, "failed to extract layers for {} < r < {}", rmin, rmax);
26+
}
27+
if (outName.size()) {
28+
cp->writeToFile(outName);
29+
}
30+
return cp;
31+
}
32+
33+
void extractLUTLayers(const std::string& fname, float rmin = 0., float rmax = 84., float toler = 1e-6)
34+
{
35+
const auto src = o2::base::MatLayerCylSet::loadFromFile(fname);
36+
if (!src) {
37+
LOGP(error, "failed to open source LUT from {}", fname);
38+
return;
39+
}
40+
auto fnameOut = std::regex_replace(fname, std::regex(R"(.root)"), fmt::format("_r{}_{}.root", rmin, rmax));
41+
auto cp = extractLUTLayers(src, fnameOut, rmin, rmax, toler);
42+
}
43+
44+
void extractLUTLayers(long timestamp, float rmin = 0., float rmax = 84., float toler = 1e-6)
45+
{
46+
auto& mg = o2::ccdb::BasicCCDBManager::instance();
47+
mg.setTimestamp(timestamp);
48+
const auto src = o2::base::MatLayerCylSet::rectifyPtrFromFile(mg.get<o2::base::MatLayerCylSet>("GLO/Param/MatLUT"));
49+
if (!src) {
50+
LOGP(error, "failed to open load LUT from CCDB for timestamp {}", timestamp);
51+
return;
52+
}
53+
auto fnameOut = fmt::format("matbudLUT_ts{}_r{}_{}.root", timestamp, rmin, rmax);
54+
auto cp = extractLUTLayers(src, fnameOut, rmin, rmax, toler);
55+
}

0 commit comments

Comments
 (0)