|
| 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