Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4Analysis Namespace Reference

Typedefs

using G4ToolsBaseHisto = tools::histo::base_histo< double, unsigned int, unsigned int, double, double >
 

Functions

G4int GetNbins (const G4ToolsBaseHisto &baseHisto, G4int dimension)
 
G4double GetMin (const G4ToolsBaseHisto &baseHisto, G4int dimension)
 
G4double GetMax (const G4ToolsBaseHisto &baseHisto, G4int dimension)
 
G4double GetWidth (const G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &hnType)
 
G4bool SetTitle (G4ToolsBaseHisto &baseHisto, const G4String &title)
 
G4bool SetAxisTitle (G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &title)
 
G4String GetTitle (const G4ToolsBaseHisto &baseHisto)
 
G4String GetAxisTitle (const G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &hnType)
 
G4bool CheckNbins (G4int nbins)
 
G4bool CheckMinMax (G4double xmin, G4double xmax, const G4String &fcnName="none", const G4String &binSchemeName="linear")
 
G4bool CheckEdges (const std::vector< G4double > &edges)
 
G4bool CheckName (const G4String &name, const G4String &objectType)
 
G4double GetUnitValue (const G4String &unit)
 
void UpdateTitle (G4String &title, const G4String &unitName, const G4String &fcnName)
 
void Tokenize (const G4String &line, std::vector< G4String > &tokens)
 
template<typename T , typename... Args>
std::unique_ptr< T > make_unique (Args &&...args)
 
G4AnalysisOutput GetOutput (const G4String &outputName)
 
G4String GetOutputName (G4AnalysisOutput outputType)
 
G4BinScheme GetBinScheme (const G4String &binSchemeName)
 
void ComputeEdges (G4int nbins, G4double xmin, G4double xmax, G4double unit, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
 
void ComputeEdges (const std::vector< G4double > &edges, G4double unit, G4Fcn fcn, std::vector< G4double > &newEdges)
 
G4Fcn GetFunction (const G4String &fcnName)
 

Variables

const G4int kX = 0
 
const G4int kY = 1
 
const G4int kZ = 2
 
const G4int kInvalidId = -1
 

Typedef Documentation

using G4Analysis::G4ToolsBaseHisto = typedef tools::histo::base_histo<double, unsigned int, unsigned int, double, double>

Definition at line 43 of file G4BaseHistoUtilities.hh.

Function Documentation

G4bool G4Analysis::CheckEdges ( const std::vector< G4double > &  edges)

Definition at line 120 of file G4AnalysisUtilities.cc.

121 {
122  if ( edges.size() <= 1 ) {
123  G4ExceptionDescription description;
124  description
125  << " Illegal edges vector (size <= 1)" << G4endl;
126  G4Exception("G4VAnalysisManager::CheckEdges",
127  "Analysis_W013", JustWarning, description);
128  return false;
129  }
130  else
131  return true;
132 
133 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4Analysis::CheckMinMax ( G4double  xmin,
G4double  xmax,
const G4String fcnName = "none",
const G4String binSchemeName = "linear" 
)

Definition at line 78 of file G4AnalysisUtilities.cc.

80 {
81  auto result = true;
82 
83  if ( xmax <= xmin ) {
84  G4ExceptionDescription description;
85  description
86  << " Illegal values of (xmin >= xmax)" << G4endl;
87  G4Exception("G4VAnalysisManager::CheckMinMax",
88  "Analysis_W013", JustWarning, description);
89 
90  result = false;
91  }
92 
93  if ( ( fcnName != "none" ) && ( binSchemeName != "linear" ) ) {
94  G4ExceptionDescription description;
95  description
96  << " Combining Function and Binning scheme is not supported."
97  << G4endl;
98  G4Exception("G4VAnalysisManager::CheckMinMax",
99  "Analysis_W013", JustWarning, description);
100 
101  result = false;
102  }
103 
104  if ( ( GetBinScheme(binSchemeName) == G4BinScheme::kLog ||
105  fcnName == "log" || fcnName == "log10" ) && ( xmin == 0 ) ) {
106  G4ExceptionDescription description;
107  description
108  << " Illegal value of (xmin = 0) with logarithmic function or binning"
109  << G4endl;
110  G4Exception("G4VAnalysisManager::CheckMinMax",
111  "Analysis_W013", JustWarning, description);
112 
113  result = false;
114  }
115 
116  return result;
117 }
G4double G4ParticleHPJENDLHEData::G4double result
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4BinScheme GetBinScheme(const G4String &binSchemeName)
Definition: G4BinScheme.cc:36
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4Analysis::CheckName ( const G4String name,
const G4String objectType 
)

Definition at line 136 of file G4AnalysisUtilities.cc.

137 {
138  if ( ! name.size() ) {
139  G4ExceptionDescription description;
140  description
141  << " Empty " << objectType << " name is not allowed." << G4endl
142  << " " << objectType << " was not created." << G4endl;
143  G4Exception("G4VAnalysisManager::CheckName",
144  "Analysis_W013", JustWarning, description);
145  return false;
146  }
147  else
148  return true;
149 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4Analysis::CheckNbins ( G4int  nbins)

Definition at line 62 of file G4AnalysisUtilities.cc.

63 {
64  if ( nbins <= 0 ) {
65  G4ExceptionDescription description;
66  description
67  << " Illegal value of number of bins: nbins <= 0" << G4endl;
68  G4Exception("G4VAnalysisManager::CheckNbins",
69  "Analysis_W013", JustWarning, description);
70  return false;
71  }
72  else
73  return true;
74 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

void G4Analysis::ComputeEdges ( G4int  nbins,
G4double  xmin,
G4double  xmax,
G4double  unit,
G4Fcn  fcn,
G4BinScheme  binScheme,
std::vector< G4double > &  edges 
)

Definition at line 56 of file G4BinScheme.cc.

59 {
60 // Compute edges from parameters
61 
62  // Apply units
63  auto xumin = xmin/unit;
64  auto xumax = xmax/unit;
65 
66  if ( binScheme == G4BinScheme::kLinear ) {
67  auto dx = (fcn(xumax) - fcn(xumin) ) / nbins;
68  auto binValue = fcn(xumin);
69  while ( G4int(edges.size()) <= nbins ) { // Loop checking, 23.06.2015, I. Hrivnacova
70  edges.push_back(binValue);
71  binValue += dx;
72  }
73  }
74  else if ( binScheme == G4BinScheme::kLog ) {
75  // do not apply fcn
76  auto dlog
77  = (std::log10(xumax) - std::log10(xumin))/ nbins;
78  auto dx = std::pow(10, dlog);
79  auto binValue = xumin;
80  while ( G4int(edges.size()) <= nbins ) { // Loop checking, 23.06.2015, I. Hrivnacova
81  edges.push_back(binValue);
82  binValue *= dx;
83  }
84  }
85  else if ( binScheme == G4BinScheme::kUser ) {
86  // This should never happen, but let's make sure about it
87  // by issuing a warning
88  G4ExceptionDescription description;
89  description
90  << " User binning scheme setting was ignored." << G4endl
91  << " Linear binning will be applied with given (nbins, xmin, xmax) values";
92  G4Exception("G4Analysis::ComputeEdges",
93  "Analysis_W013", JustWarning, description);
94  }
95 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void G4Analysis::ComputeEdges ( const std::vector< G4double > &  edges,
G4double  unit,
G4Fcn  fcn,
std::vector< G4double > &  newEdges 
)

Definition at line 98 of file G4BinScheme.cc.

101 {
102 // Apply function to defined edges
103 
104  for (auto element : edges) {
105  newBins.push_back(fcn(element/unit));
106  }
107 }
G4String G4Analysis::GetAxisTitle ( const G4ToolsBaseHisto &  baseHisto,
G4int  dimension,
const G4String hnType 
)

Definition at line 110 of file G4BaseHistoUtilities.cc.

112 {
113  G4String title;
114  G4bool result = false;
115  if ( dimension == kX ) {
116  result = baseHisto.annotation(tools::histo::key_axis_x_title(), title);
117  }
118  else if ( dimension == kY ) {
119  result = baseHisto.annotation(tools::histo::key_axis_y_title(), title);
120  }
121  else if ( dimension == kZ ) {
122  result = baseHisto.annotation(tools::histo::key_axis_z_title(), title);
123  }
124 
125  if ( ! result ) {
126  G4String axes("xyz");
127  G4String axis = axes(dimension, 1);
128  G4String functionName = "Get";
129  functionName += hnType;
130  functionName += axis;
131  functionName += "Title";
132  G4ExceptionDescription description;
133  description << " Failed to get " << axis << " axis " << hnType << " title.";
134  G4Exception(functionName, "Analysis_W014", JustWarning, description);
135  return "";
136  }
137 
138  return title;
139 }
G4double G4ParticleHPJENDLHEData::G4double result
const G4int kZ
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
bool G4bool
Definition: G4Types.hh:79
const G4int kX
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4int kY

Here is the call graph for this function:

Here is the caller graph for this function:

G4BinScheme G4Analysis::GetBinScheme ( const G4String binSchemeName)

Definition at line 36 of file G4BinScheme.cc.

37 {
39  if ( binSchemeName != "linear" ) {
40  if ( binSchemeName == "log" )
41  binScheme = G4BinScheme::kLog;
42  else {
43  // There is no name associated with G4BinScheme::kUser
44  G4ExceptionDescription description;
45  description
46  << " \"" << binSchemeName << "\" binning scheme is not supported." << G4endl
47  << " " << "Linear binning will be applied.";
48  G4Exception("G4Analysis::GetBinScheme",
49  "Analysis_W013", JustWarning, description);
50  }
51  }
52  return binScheme;
53 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
G4BinScheme
Definition: G4BinScheme.hh:40

Here is the call graph for this function:

Here is the caller graph for this function:

G4Fcn G4Analysis::GetFunction ( const G4String fcnName)

Definition at line 36 of file G4Fcn.cc.

37 {
38  G4Fcn fcn = G4FcnIdentity;
39  if ( fcnName != "none" ) {
40  if ( fcnName == "log" ) fcn = std::log;
41  else if ( fcnName == "log10") fcn = std::log10;
42  else if ( fcnName == "exp" ) fcn = std::exp;
43  else {
44  G4ExceptionDescription description;
45  description
46  << " \"" << fcnName << "\" function is not supported." << G4endl
47  << " " << "No function will be applied to histogram values.";
48  G4Exception("G4Analysis::GetFunction",
49  "Analysis_W013", JustWarning, description);
50  }
51  }
52  return fcn;
53 }
G4double(*)(G4double) G4Fcn
Definition: G4Fcn.hh:36
G4double G4FcnIdentity(G4double value)
Definition: G4Fcn.hh:39
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4Analysis::GetMax ( const G4ToolsBaseHisto &  baseHisto,
G4int  dimension 
)

Definition at line 53 of file G4BaseHistoUtilities.cc.

54 {
55 // Returns max data value
56 
57  return baseHisto.get_axis(dimension).upper_edge();
58 }

Here is the caller graph for this function:

G4double G4Analysis::GetMin ( const G4ToolsBaseHisto &  baseHisto,
G4int  dimension 
)

Definition at line 45 of file G4BaseHistoUtilities.cc.

46 {
47 // Returns min data value
48 
49  return baseHisto.get_axis(dimension).lower_edge();
50 }

Here is the caller graph for this function:

G4int G4Analysis::GetNbins ( const G4ToolsBaseHisto &  baseHisto,
G4int  dimension 
)

Definition at line 39 of file G4BaseHistoUtilities.cc.

40 {
41  return baseHisto.get_axis(dimension).bins();
42 }

Here is the caller graph for this function:

G4AnalysisOutput G4Analysis::GetOutput ( const G4String outputName)

Definition at line 192 of file G4AnalysisUtilities.cc.

192  {
193  if ( outputName == "csv" ) { return G4AnalysisOutput::kCsv; }
194  else if ( outputName == "root" ) { return G4AnalysisOutput::kRoot; }
195  else if ( outputName == "xml" ) { return G4AnalysisOutput::kXml; }
196  else if ( outputName == "none" ) { return G4AnalysisOutput::kNone; }
197  else {
198  G4ExceptionDescription description;
199  description
200  << " \"" << outputName << "\" output type is not supported." << G4endl
201  << " " << "Root type will be used.";
202  G4Exception("G4Analysis::GetOutputType",
203  "Analysis_W013", JustWarning, description);
204  return G4AnalysisOutput::kNone;
205  }
206 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

G4String G4Analysis::GetOutputName ( G4AnalysisOutput  outputType)

Definition at line 209 of file G4AnalysisUtilities.cc.

209  {
210  switch ( output ) {
212  return "csv";
213  break;
215  return "root";
216  break;
218  return "xml";
219  break;
221  return "none";
222  break;
223  }
224  // should never reach this line
225  G4ExceptionDescription description;
226  description
227  << " \"" << static_cast<int>(output) << "\" is not handled." << G4endl
228  << " " << "none type will be used.";
229  G4Exception("G4Analysis::GetOutputName",
230  "Analysis_W013", JustWarning, description);
231  return "none";
232 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

G4String G4Analysis::GetTitle ( const G4ToolsBaseHisto &  baseHisto)

Definition at line 103 of file G4BaseHistoUtilities.cc.

104 {
105  return baseHisto.title();
106 }

Here is the caller graph for this function:

G4double G4Analysis::GetUnitValue ( const G4String unit)

Definition at line 152 of file G4AnalysisUtilities.cc.

153 {
154  G4double value = 1.;
155  if ( unit != "none" ) {
156  value = G4UnitDefinition::GetValueOf(unit);
157  if ( value == 0. ) value = 1.;
158  }
159  return value;
160 }
static G4double GetValueOf(const G4String &)
const XML_Char int const XML_Char * value
Definition: expat.h:331
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4Analysis::GetWidth ( const G4ToolsBaseHisto &  baseHisto,
G4int  dimension,
const G4String hnType 
)

Definition at line 61 of file G4BaseHistoUtilities.cc.

63 {
64  auto nbins = baseHisto.get_axis(dimension).bins();
65  if ( ! nbins ) {
66  G4String functionName = "Get";
67  functionName += hnType;
68  functionName += "Width";
69  G4ExceptionDescription description;
70  description << " nbins = 0 (for " << hnType << ").";
71  G4Exception(functionName, "Analysis_W014", JustWarning, description);
72  return 0.;
73  }
74 
75  return ( baseHisto.get_axis(dimension).upper_edge()
76  - baseHisto.get_axis(dimension).lower_edge() )/nbins;
77 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T , typename... Args>
std::unique_ptr<T> G4Analysis::make_unique ( Args &&...  args)

Definition at line 84 of file G4AnalysisUtilities.hh.

85 {
86  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
87 }
G4bool G4Analysis::SetAxisTitle ( G4ToolsBaseHisto &  baseHisto,
G4int  dimension,
const G4String title 
)

Definition at line 86 of file G4BaseHistoUtilities.cc.

88 {
89  if ( dimension == kX ) {
90  baseHisto.add_annotation(tools::histo::key_axis_x_title(), title);
91  }
92  else if ( dimension == kY ) {
93  baseHisto.add_annotation(tools::histo::key_axis_y_title(), title);
94  }
95  else if ( dimension == kZ ) {
96  baseHisto.add_annotation(tools::histo::key_axis_z_title(), title);
97  }
98 
99  return true;
100 }
const G4int kZ
const G4int kX
const G4int kY

Here is the caller graph for this function:

G4bool G4Analysis::SetTitle ( G4ToolsBaseHisto &  baseHisto,
const G4String title 
)

Definition at line 80 of file G4BaseHistoUtilities.cc.

81 {
82  return baseHisto.set_title(title);
83 }

Here is the caller graph for this function:

void G4Analysis::Tokenize ( const G4String line,
std::vector< G4String > &  tokens 
)

Definition at line 173 of file G4AnalysisUtilities.cc.

174 {
175  // Define start values
176  std::string::size_type begIdx = 0;
177  std::string::size_type endIdx = 0;
178  G4String token;
179 
180  do {
181  if ( GetToken(line, token, begIdx, endIdx) ) {
182  //G4cout << "got token: '" << token << "'" << G4endl;
183  //G4cout << "beg, end: " << begIdx << ", " << endIdx << G4endl;
184  tokens.push_back(token);
185  }
186  begIdx = endIdx + 1;
187  }
188  while ( endIdx < line.length() ); // Loop checking, 23.06.2015, I. Hrivnacova
189 }

Here is the caller graph for this function:

void G4Analysis::UpdateTitle ( G4String title,
const G4String unitName,
const G4String fcnName 
)

Definition at line 163 of file G4AnalysisUtilities.cc.

166 {
167  if ( fcnName != "none" ) { title += " "; title += fcnName; title += "("; }
168  if ( unitName != "none" ) { title += " ["; title += unitName; title += "]";}
169  if ( fcnName != "none" ) { title += ")"; }
170 }

Variable Documentation

const G4int G4Analysis::kInvalidId = -1

Definition at line 62 of file G4AnalysisUtilities.hh.

const G4int G4Analysis::kX = 0

Definition at line 55 of file G4AnalysisUtilities.hh.

const G4int G4Analysis::kY = 1

Definition at line 56 of file G4AnalysisUtilities.hh.

const G4int G4Analysis::kZ = 2

Definition at line 57 of file G4AnalysisUtilities.hh.