43 std::string::size_type begIdx, std::string::size_type& endIdx)
45 while ( line[(
G4int)begIdx] ==
' ') ++begIdx;
46 if ( line[(
G4int)begIdx] ==
'"' ) {
47 endIdx = line.find(
'"', begIdx+1);
48 if ( endIdx == std::string::npos ) endIdx = line.length();
49 token = line.substr(begIdx+1, (endIdx-1)-begIdx);
53 endIdx = line.find(
' ', begIdx);
54 if ( endIdx == std::string::npos ) endIdx = line.length();
55 token = line.substr(begIdx, endIdx-begIdx);
57 return ( token.length() > 0 );
67 const std::string_view inClass,
68 const std::string_view inFunction)
70 auto source = std::string(inClass) +
"::" + std::string(inFunction);
78 if ( unit !=
"none" ) {
80 if ( value == 0. ) value = 1.;
89 std::string::size_type begIdx = 0;
90 std::string::size_type endIdx = 0;
94 if ( GetToken(line, token, begIdx, endIdx) ) {
97 tokens.push_back(token);
101 while ( endIdx < line.length() );
107 if (outputName ==
"csv")
return G4AnalysisOutput::kCsv;
108 if (outputName ==
"hdf5")
return G4AnalysisOutput::kHdf5;
109 if (outputName ==
"root")
return G4AnalysisOutput::kRoot;
110 if (outputName ==
"xml")
return G4AnalysisOutput::kXml;
111 if (outputName ==
"none")
return G4AnalysisOutput::kNone;
114 Warn(
"\"" + outputName +
"\" output type is not supported.",
kNamespaceName,
"GetOutput");
116 return G4AnalysisOutput::kNone;
123 case G4AnalysisOutput::kCsv:
126 case G4AnalysisOutput::kHdf5:
129 case G4AnalysisOutput::kRoot:
132 case G4AnalysisOutput::kXml:
135 case G4AnalysisOutput::kNone:
140 Warn(
"\"" + to_string(
static_cast<int>(output)) +
141 "\" output type is not supported.",
151 G4fs::path filePath(fileName.data());
152 if ( filePath.has_parent_path()) {
153 return filePath.parent_path().string() +
"/" + filePath.stem().string();
156 return filePath.stem().string();
166 G4fs::path filePath(fileName.data());
167 if ( filePath.has_extension() ) {
168 auto extension = filePath.extension().string();
170 return extension.substr(1, extension.length());
173 return defaultExtension;
198 if (extension.size() != 0u) {
200 name.append(extension);
220 name.append(std::to_string(cycle));
225 if (extension.size() != 0u) {
227 name.append(extension);
250 name.append(ntupleName);
255 name.append(std::to_string(cycle));
260 std::ostringstream os;
263 name.append(os.str());
268 if (extension.size() != 0u) {
270 name.append(extension);
280 G4int ntupleFileNumber,
291 std::ostringstream os;
292 os << ntupleFileNumber;
294 name.append(os.str());
299 name.append(std::to_string(cycle));
304 if (extension.size() != 0u) {
306 name.append(extension);
327 name.append(std::to_string(cycle));
332 std::ostringstream os;
335 name.append(os.str());
340 if (extension.size() != 0u) {
342 name.append(extension);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static G4double GetValueOf(const G4String &)
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4String GetTnFileName(const G4String &fileName, const G4String &fileType, G4int cycle=0)
G4String GetPlotFileName(const G4String &fileName)
constexpr std::string_view kNamespaceName
G4double GetUnitValue(const G4String &unit)
G4String GetOutputName(G4AnalysisOutput outputType)
G4AnalysisOutput GetOutput(const G4String &outputName, G4bool warn=true)
G4String GetNtupleFileName(const G4String &fileName, const G4String &fileType, const G4String &ntupleName, G4int cycle=0)
G4String GetHnFileName(const G4String &fileName, const G4String &fileType, const G4String &hnType, const G4String &hnName)
G4String GetBaseName(const G4String &fileName)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)