Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4AnalysisUtilities.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 
0027 // Author: Ivana Hrivnacova, 04/07/2012  (ivana@ipno.in2p3.fr)
0028 
0029 #ifndef G4AnalysisUtilities_h
0030 #define G4AnalysisUtilities_h 1
0031 
0032 #include "G4Exception.hh"
0033 #include "globals.hh"
0034 
0035 #include <vector>
0036 #include <memory>
0037 #include <string_view>
0038 
0039 // Enumeration for definition of available output types
0040 
0041 enum class G4AnalysisOutput {
0042   kCsv,
0043   kHdf5,
0044   kRoot,
0045   kXml,
0046   kNone
0047 };
0048 
0049 namespace G4Analysis
0050 {
0051 
0052 // Constant expressions
0053 //
0054 constexpr G4int kX { 0 };
0055 constexpr G4int kY { 1 };
0056 constexpr G4int kZ { 2 };
0057 constexpr G4int kInvalidId { -1 };
0058 constexpr G4int kVL0 { 0 };
0059 constexpr G4int kVL1 { 1 };
0060 constexpr G4int kVL2 { 2 };
0061 constexpr G4int kVL3 { 3 };
0062 constexpr G4int kVL4 { 4 };
0063 constexpr unsigned int kDim1 { 1 };
0064 constexpr unsigned int kDim2 { 2 };
0065 constexpr unsigned int kDim3 { 3 };
0066 constexpr unsigned int kMaxDim { kDim3 };
0067 constexpr unsigned int kDefaultBasketSize { 32000 };
0068 constexpr unsigned int kDefaultBasketEntries {4000 };
0069 constexpr std::string_view kNamespaceName { "G4Analysis" };
0070 
0071 // Warning
0072 //
0073 void Warn(const G4String& message,
0074           const std::string_view inClass,
0075           const std::string_view inFunction);
0076 
0077 // Get unit value with added handling of "none"
0078 G4double GetUnitValue(const G4String& unit);
0079 
0080 // Tokenizer with taking into account composed strings within ""
0081 void Tokenize(const G4String& line, std::vector<G4String>& tokens);
0082 
0083 // Get output type from name
0084 G4AnalysisOutput GetOutput(const G4String& outputName, G4bool warn = true);
0085 size_t GetOutputId(const G4String& outputName, G4bool warn = true);
0086 G4String GetOutputName(G4AnalysisOutput outputType);
0087 
0088 // Get short hnType from the tools object
0089 template <typename HT>
0090 G4String GetHnType()
0091 {
0092   // tools::histo::h1d etc.
0093   G4String hnTypeLong = HT::s_class();
0094 
0095   // tools::histo::h1d -> h1 etc.
0096   return hnTypeLong.substr(14, 2);
0097 }
0098 
0099 template <typename HT>
0100 G4bool IsProfile()
0101 {
0102   // tools::histo::h1d etc.
0103   G4String hnTypeLong = HT::s_class();
0104 
0105   // tools::histo::h1d -> h1 etc.
0106   return hnTypeLong[14] == 'p';
0107 }
0108 
0109 // String conversion
0110 template <typename T>
0111 inline
0112 std::string ToString(const T& value)
0113 { return std::to_string(value); }
0114 
0115 template <>
0116 inline
0117 std::string ToString<std::string>(const std::string& value)
0118 { return value; }
0119 
0120 // File names utilities
0121 
0122 // Get file base name (without dot)
0123 G4String GetBaseName(const G4String& fileName);
0124 
0125 // Get file base extension (without dot)
0126 G4String GetExtension(const G4String& fileName,
0127             const G4String& defaultExtension = "");
0128 
0129 // Compose and return the histogram or profile specific file name:
0130 // - add _hn_hnName suffix to the file base name
0131 // - add file extension if not present
0132 G4String GetHnFileName(
0133             const G4String& fileName,
0134             const G4String& fileType,
0135             const G4String& hnType,
0136             const G4String& hnName);
0137 
0138 // Update Hn file name:
0139 // - add _vN  suffix to the base namer if cycle > 0
0140 G4String GetHnFileName(
0141             const G4String& fileName,
0142             const G4String& fileType,
0143             G4int cycle = 0);
0144 
0145 // Compose and return the ntuple specific file name:
0146 // - add _nt_ntupleName suffix to the file base name
0147 // - add _vN  suffix if cycle > 0
0148 // - add _tN suffix if called on thread worker
0149 // - add file extension if not present
0150 G4String GetNtupleFileName(
0151             const G4String& fileName,
0152             const G4String& fileType,
0153             const G4String& ntupleName,
0154             G4int cycle = 0);
0155 
0156 // Compose and return the ntuple specific file name:
0157 // - add _mFN suffix to the file base name where FN = ntupleFileNumber
0158 // - add _vN  suffix if cycle > 0
0159 // - add file extension if not present
0160 G4String GetNtupleFileName(
0161             const G4String& fileName,
0162             const G4String& fileType,
0163             G4int ntupleFileNumber,
0164             G4int cycle = 0);
0165 
0166 // Update file base name with the thread suffix:
0167 // - add _vN  suffix if cycle > 0
0168 // - add _tN suffix if called on thread worker
0169 // - add file extension if not present
0170 G4String GetTnFileName(
0171             const G4String& fileName,
0172             const G4String& fileType,
0173             G4int cycle = 0);
0174 
0175 // Generate plot file name for an output file name
0176 G4String GetPlotFileName(const G4String& fileName);
0177 
0178 }
0179 
0180 /*
0181 // make possible to print enumerators in class enum as integer
0182 template <typename Enumeration>
0183 auto as_integer(Enumeration const value)
0184     -> typename std::underlying_type<Enumeration>::type
0185 {
0186   return static_cast<typename std::underlying_type<Enumeration>::type>(value);
0187 }
0188 */
0189 
0190 #endif
0191