ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AnalysisUtilities.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4AnalysisUtilities.hh
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 
27 // Author: Ivana Hrivnacova, 04/07/2012 (ivana@ipno.in2p3.fr)
28 
29 #ifndef G4AnalysisUtilities_h
30 #define G4AnalysisUtilities_h 1
31 
32 #include "globals.hh"
33 
34 #include <vector>
35 #include <memory>
36 
37 // Enumeration for definition of available output types
38 
39 enum class G4AnalysisOutput {
40  kCsv,
41 #ifdef TOOLS_USE_HDF5
42  kHdf5,
43 #endif
44  kRoot,
45  kXml,
46  kNone
47 };
48 
49 namespace G4Analysis
50 {
51 
52 // Constant expressions
53 //
54 // constexpr G4int kX = 0; // not yet supported on vc12
55 // constexpr G4int kY = 1; // not yet supported on vc12
56 // constexpr G4int kZ = 2; // not yet supported on vc12
57 const G4int kX = 0; // not yet supported on vc12
58 const G4int kY = 1; // not yet supported on vc12
59 const G4int kZ = 2; // not yet supported on vc12
60 
61 // Invalid object Id
62 //
63 // constexpr G4int kInvalidId = -1; // not yet supported on vc12
64 const G4int kInvalidId = -1; // not yet supported on vc12
65 
66 // Utility functions for checking input parameters
67 G4bool CheckNbins(G4int nbins);
69  const G4String& fcnName = "none",
70  const G4String& binSchemeName = "linear");
71 G4bool CheckEdges(const std::vector<G4double>& edges);
72 G4bool CheckName(const G4String& name, const G4String& objectType);
73 
74 // Get unit value with added handling of "none"
75 G4double GetUnitValue(const G4String& unit);
76 
77 // Add unit & fcn to the title
79  const G4String& unitName, const G4String& fcnName);
80 
81 // Tokenizer with taking into account composed strings within ""
82 void Tokenize(const G4String& line, std::vector<G4String>& tokens);
83 
84 // make-unique utility, not yet availabla in C++11
85 template<typename T, typename... Args>
86 std::unique_ptr<T> make_unique(Args&&... args)
87 {
88  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
89 }
90 
91 // get output type from name
92 G4AnalysisOutput GetOutput(const G4String& outputName, G4bool warn = true);
94 
95 /*
96 // make possible to print enumerators in class enum as integer
97 template <typename Enumeration>
98 auto as_integer(Enumeration const value)
99  -> typename std::underlying_type<Enumeration>::type
100 {
101  return static_cast<typename std::underlying_type<Enumeration>::type>(value);
102 }
103 */
104 
105 }
106 
107 #endif
108 
109 
110 
111