Project
Loading...
Searching...
No Matches
NameConf.cxx
Go to the documentation of this file.
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
13#include <fmt/format.h>
14#include <cstdlib>
15#include <memory>
16
18
19using namespace o2::base;
20
21std::string NameConf::buildFileName(const std::string_view prefix, const std::string_view delimiter, const std::string_view defPrefix, const std::string_view defName,
22 const std::string_view extension, const std::string_view optDir)
23{
24 if (o2::utils::Str::pathIsDirectory(prefix)) { // if path is directory, just add to default name, ignoring optional directory optDir argument
25 return o2::utils::Str::concat_string(prefix, "/", defPrefix, delimiter, defName, '.', extension);
26 } else if (!prefix.empty() && o2::utils::Str::pathExists(prefix)) { // explicit file path is provided, use it directly
27 return std::string(prefix);
28 }
29 auto dir = o2::utils::Str::rectifyDirectory(optDir); // directory might have been provided
30 // is the prefix really prefix or a file-name
31 if (!prefix.empty()) {
32 auto path = o2::utils::Str::concat_string(dir, prefix);
34 return path;
35 }
36 }
37 return o2::utils::Str::concat_string(dir, prefix.empty() ? defPrefix : prefix, delimiter, defName, '.', extension);
38}
39
40// Filename to store geometry file
41std::string NameConf::getGeomFileName(const std::string_view prefix)
42{
44}
45
46// Filename to store geometry file
47std::string NameConf::getAlignedGeomFileName(const std::string_view prefix)
48{
50}
51
52// Filename to store general run parameters (GRP)
53std::string NameConf::getCollisionContextFileName(const std::string_view prefix)
54{
56}
57
58// Filename to store general run parameters (GRP)
59std::string NameConf::getGRPFileName(const std::string_view prefix)
60{
62}
63
64// Filename to store general run parameters from ECS (GRPECS)
65std::string NameConf::getGRPECSFileName(const std::string_view prefix)
66{
68}
69
70// Filename to store general run parameters from LHCIF (GRPLHCIF)
71std::string NameConf::getGRPLHCIFFileName(const std::string_view prefix)
72{
74}
75
76// Filename to store general run parameters from ECS (GRPECS)
77std::string NameConf::getGRPMagFieldFileName(const std::string_view prefix)
78{
80}
81
82// Filename to store simulation cuts/process summary
83std::string NameConf::getCutProcFileName(std::string_view prefix)
84{
86}
87
88// Filename to store material LUT file
89std::string NameConf::getMatLUTFileName(const std::string_view prefix)
90{
91 return buildFileName(prefix, "", "", MATBUDLUT, ROOT_EXT_STRING, Instance().mDirMatLUT);
92}
93
94std::string NameConf::getCTFFileName(uint32_t run, uint32_t orb, uint32_t id, const std::string& host, const std::string_view prefix)
95{
96 return o2::utils::Str::concat_string(prefix, '_', fmt::format("run{:08d}_orbit{:010d}_tf{:010d}_{}", run, orb, id, host), ".root");
97}
98
99std::string NameConf::getRawTFFileName(uint32_t run, uint32_t orb, uint32_t id, const std::string& host, const std::string_view prefix)
100{
101 return o2::utils::Str::concat_string(prefix, '_', fmt::format("run{:08d}_orbit{:010d}_tf{:010d}_{}", run, orb, id, host), ".tf");
102}
103
105{
106 return o2::utils::Str::concat_string(CTFDICT, ".root");
107}
108
109// Filename to store general run parameters (GRP)
110std::string NameConf::getTFIDInfoFileName(const std::string_view prefix)
111{
112 return buildFileName(prefix, "_", "o2", TFIDINFO, ROOT_EXT_STRING, Instance().mDirTFIDINFO);
113}
114
115// Default CCDB server.
116//
117// Precedence: an explicit NameConf.mCCDBServer (configKeyValues) wins; otherwise
118// ALICEO2_CCDB_PRODUCTION_HOST, then ALICEO2_CCDB_HOST, then the compiled-in
119// production server. The environment lets a build container reach CCDB through
120// a broker (CI's security-proxy) without every tool growing its own option --
121// the CCDB test suites, GRPTool and testTPCCalDet already read these names.
122// Unset, behaviour is unchanged.
124{
125 static const std::string kCompiledDefault = "http://alice-ccdb.cern.ch/"; // keep equal to mCCDBServer's initializer
126 const auto& configured = Instance().mCCDBServer;
127 if (configured != kCompiledDefault) {
128 return configured;
129 }
130 for (const char* var : {"ALICEO2_CCDB_PRODUCTION_HOST", "ALICEO2_CCDB_HOST"}) {
131 if (const char* host = std::getenv(var); host && *host) {
132 return host;
133 }
134 }
135 return configured;
136}
137
138std::string NameConf::getConfigOutputFileName(const std::string& procName, const std::string& confName, bool json)
139{
140 std::string nm = procName;
141 if (!confName.empty()) {
142 nm += '_' + confName;
143 }
144 return fmt::format("ConfigParam_{}.{}", nm, json ? "json" : "ini");
145}
#define O2ParamImpl(classname)
Definition of the Names Generator class.
static std::string getAlignedGeomFileName(const std::string_view prefix="")
Definition NameConf.cxx:47
std::string mDirGRPECS
Definition NameConf.h:142
static constexpr std::string_view GRP_STRING
Definition NameConf.h:121
std::string mDirTFIDINFO
Definition NameConf.h:148
static constexpr std::string_view GRPMAGFIELD_STRING
Definition NameConf.h:124
std::string mDirGRPLHCIF
Definition NameConf.h:143
static std::string getGRPECSFileName(const std::string_view prefix=STANDARDSIMPREFIX)
Definition NameConf.cxx:65
static constexpr std::string_view ROOT_EXT_STRING
Definition NameConf.h:131
static std::string getGeomFileName(const std::string_view prefix="")
Definition NameConf.cxx:41
static std::string getGRPLHCIFFileName(const std::string_view prefix=STANDARDSIMPREFIX)
Definition NameConf.cxx:71
static std::string getCTFFileName(uint32_t run, uint32_t orb, uint32_t id, const std::string &host, const std::string_view prefix="o2_ctf")
Definition NameConf.cxx:94
static constexpr std::string_view DAT_EXT_STRING
Definition NameConf.h:132
static std::string getCutProcFileName(const std::string_view prefix="")
Definition NameConf.cxx:83
static std::string getCTFDictFileName()
Definition NameConf.cxx:104
static std::string getGRPFileName(const std::string_view prefix=STANDARDSIMPREFIX)
Definition NameConf.cxx:59
std::string mDirCollContext
Definition NameConf.h:147
std::string mDirGeom
Definition NameConf.h:145
std::string mDirGRP
Definition NameConf.h:141
static std::string getMatLUTFileName(const std::string_view prefix="")
Definition NameConf.cxx:89
static std::string buildFileName(const std::string_view prefix, const std::string_view delimiter, const std::string_view defPrefix, const std::string_view defName, const std::string_view extension, const std::string_view optDir="")
Definition NameConf.cxx:21
static std::string getConfigOutputFileName(const std::string &procName, const std::string &confName="", bool json=true)
Definition NameConf.cxx:138
static constexpr std::string_view GRPLHCIF_STRING
Definition NameConf.h:123
static constexpr std::string_view ALIGNEDGEOM_FILE_STRING
Definition NameConf.h:128
static std::string getCollisionContextFileName(const std::string_view prefix="")
Definition NameConf.cxx:53
static constexpr std::string_view CUT_FILE_STRING
Definition NameConf.h:129
static constexpr std::string_view STANDARDSIMPREFIX
Definition NameConf.h:118
static constexpr std::string_view COLLISIONCONTEXT
Definition NameConf.h:136
static constexpr std::string_view MATBUDLUT
Definition NameConf.h:135
static std::string getRawTFFileName(uint32_t run, uint32_t orb, uint32_t id, const std::string &host, const std::string_view prefix="o2_rawtf_dump")
Definition NameConf.cxx:99
static constexpr std::string_view GRPECS_STRING
Definition NameConf.h:122
std::string mDirMatLUT
Definition NameConf.h:146
static std::string getTFIDInfoFileName(const std::string_view prefix="o2")
Definition NameConf.cxx:110
static std::string getCCDBServer()
Definition NameConf.cxx:123
std::string mDirGRPMagField
Definition NameConf.h:144
std::string mCCDBServer
Definition NameConf.h:149
static std::string getGRPMagFieldFileName(const std::string_view prefix=STANDARDSIMPREFIX)
Definition NameConf.cxx:77
static constexpr std::string_view GEOM_FILE_STRING
Definition NameConf.h:127
static constexpr std::string_view CTFDICT
Definition NameConf.h:92
static constexpr std::string_view TFIDINFO
Definition NameConf.h:138
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
nlohmann::json json
static bool pathIsDirectory(const std::string_view p)
static std::string rectifyDirectory(const std::string_view p)
static bool pathExists(const std::string_view p)
static std::string concat_string(Ts const &... ts)