Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
G4Analysis Namespace Reference

Functions

G4bool CheckNbins (G4int nbins)
 
G4bool CheckMinMax (G4double xmin, G4double xmax, const G4String &binSchemeName)
 
G4bool CheckEdges (const std::vector< G4double > &edges)
 
G4double GetUnitValue (const G4String &unit)
 
void UpdateTitle (G4String &title, const G4String &unitName, const G4String &fcnName)
 
G4BinScheme GetBinScheme (const G4String &binSchemeName)
 
void ComputeEdges (G4int nbins, G4double xmin, G4double xmax, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
 
void ComputeEdges (const std::vector< G4double > &edges, G4Fcn fcn, std::vector< G4double > &newEdges)
 
G4Fcn GetFunction (const G4String &fcnName)
 

Variables

const G4int kInvalidId = -1
 

Function Documentation

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

Definition at line 82 of file G4AnalysisUtilities.cc.

References G4endl, G4Exception(), and JustWarning.

Referenced by G4VAnalysisManager::CreateH1(), G4VAnalysisManager::CreateH2(), G4VAnalysisManager::SetH1(), and G4VAnalysisManager::SetH2().

83 {
84  if ( edges.size() <= 1 ) {
85  G4ExceptionDescription description;
86  description
87  << " Illegal edges vector (size <= 1)" << G4endl;
88  G4Exception("G4VAnalysisManager::CheckEdges",
89  "Analysis_W013", JustWarning, description);
90  return false;
91  }
92  else
93  return true;
94 
95 }
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
G4bool G4Analysis::CheckMinMax ( G4double  xmin,
G4double  xmax,
const G4String binSchemeName 
)

Definition at line 54 of file G4AnalysisUtilities.cc.

References G4endl, G4Exception(), GetBinScheme(), JustWarning, and kLogBinScheme.

Referenced by G4VAnalysisManager::CreateH1(), G4VAnalysisManager::CreateH2(), G4VAnalysisManager::SetH1(), and G4VAnalysisManager::SetH2().

55 {
56  G4bool result = true;
57 
58  if ( xmax <= xmin ) {
59  G4ExceptionDescription description;
60  description
61  << " Illegal values of (xmin >= xmax)" << G4endl;
62  G4Exception("G4VAnalysisManager::CheckMinMax",
63  "Analysis_W013", JustWarning, description);
64 
65  result = false;
66  }
67 
68  if ( ( GetBinScheme(binSchemeName) == kLogBinScheme ) && ( xmin == 0 ) ) {
69  G4ExceptionDescription description;
70  description
71  << " Illegal value of (xmin = 0) with logarithmic binning" << G4endl;
72  G4Exception("G4VAnalysisManager::CheckMinMax",
73  "Analysis_W013", JustWarning, description);
74 
75  result = false;
76  }
77 
78  return result;
79 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
bool G4bool
Definition: G4Types.hh:79
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
G4bool G4Analysis::CheckNbins ( G4int  nbins)

Definition at line 38 of file G4AnalysisUtilities.cc.

References G4endl, G4Exception(), and JustWarning.

Referenced by G4VAnalysisManager::CreateH1(), G4VAnalysisManager::CreateH2(), G4VAnalysisManager::SetH1(), and G4VAnalysisManager::SetH2().

39 {
40  if ( nbins <= 0 ) {
41  G4ExceptionDescription description;
42  description
43  << " Illegal value of number of bins: nbins <= 0" << G4endl;
44  G4Exception("G4VAnalysisManager::CheckNbins",
45  "Analysis_W013", JustWarning, description);
46  return false;
47  }
48  else
49  return true;
50 }
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
void G4Analysis::ComputeEdges ( G4int  nbins,
G4double  xmin,
G4double  xmax,
G4Fcn  fcn,
G4BinScheme  binScheme,
std::vector< G4double > &  edges 
)

Definition at line 56 of file G4BinScheme.cc.

References G4endl, G4Exception(), JustWarning, kLinearBinScheme, kLogBinScheme, and kUserBinScheme.

59 {
60 // Compute edges from parameters
61 
62  if ( binScheme == kLinearBinScheme ) {
63  G4double dx = (xmax - xmin ) / nbins;
64  G4double binValue = xmin;
65  while ( G4int(edges.size()) <= nbins ) {
66  edges.push_back(binValue);
67  binValue += dx;
68  }
69  }
70  else if ( binScheme == kLogBinScheme ) {
71  G4double dlog
72  = (std::log10(fcn(xmax)) - std::log10(fcn(xmin)))/ nbins;
73  G4double dx = std::pow(10, dlog);
74  G4double binValue = fcn(xmin);
75  while ( G4int(edges.size()) <= nbins ) {
76  edges.push_back(binValue);
77  binValue *= dx;
78  }
79  }
80  else if ( binScheme == kUserBinScheme ) {
81  // This should never happen, but let's make sure about it
82  // by issuing a warning
83  G4ExceptionDescription description;
84  description
85  << " User binning scheme setting was ignored." << G4endl
86  << " Linear binning will be applied with given (nbins, xmin, xmax) values";
87  G4Exception("G4Analysis::ComputeEdges",
88  "Analysis_W013", JustWarning, description);
89  }
90 }
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
double G4double
Definition: G4Types.hh:76
void G4Analysis::ComputeEdges ( const std::vector< G4double > &  edges,
G4Fcn  fcn,
std::vector< G4double > &  newEdges 
)

Definition at line 93 of file G4BinScheme.cc.

96 {
97 // Apply function to defined edges
98  std::vector<G4double>::const_iterator it;
99  for (it = edges.begin(); it != edges.end(); it++ ) {
100  newBins.push_back(fcn(*it));
101  }
102 }
G4BinScheme G4Analysis::GetBinScheme ( const G4String binSchemeName)

Definition at line 36 of file G4BinScheme.cc.

References G4endl, G4Exception(), JustWarning, kLinearBinScheme, and kLogBinScheme.

Referenced by CheckMinMax(), G4H1ToolsManager::CreateH1(), G4H2ToolsManager::CreateH2(), G4H1ToolsManager::SetH1(), and G4H2ToolsManager::SetH2().

37 {
38  G4BinScheme binScheme = kLinearBinScheme;
39  if ( binSchemeName != "linear" ) {
40  if ( binSchemeName == "log" )
41  binScheme = kLogBinScheme;
42  else {
43  // There is no name associated with kUserBinScheme
44  G4ExceptionDescription description;
45  description
46  << " \"" << binScheme << "\" 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
G4Fcn G4Analysis::GetFunction ( const G4String fcnName)

Definition at line 36 of file G4Fcn.cc.

References G4endl, G4Exception(), G4FcnIdentity(), and JustWarning.

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 G4FcnIdentity(G4double value)
Definition: G4Fcn.hh:39
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double(* G4Fcn)(G4double)
Definition: G4Fcn.hh:36
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
G4double G4Analysis::GetUnitValue ( const G4String unit)

Definition at line 98 of file G4AnalysisUtilities.cc.

References G4UnitDefinition::GetValueOf().

99 {
100  G4double value = 1.;
101  if ( unit != "none" ) {
102  value = G4UnitDefinition::GetValueOf(unit);
103  if ( value == 0. ) value = 1.;
104  }
105  return value;
106 }
static G4double GetValueOf(const G4String &)
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
void G4Analysis::UpdateTitle ( G4String title,
const G4String unitName,
const G4String fcnName 
)

Definition at line 109 of file G4AnalysisUtilities.cc.

112 {
113  if ( fcnName != "none" ) { title += " "; title += fcnName; title += "("; }
114  if ( unitName != "none" ) { title += " ["; title += unitName; title += "]";}
115  if ( fcnName != "none" ) { title += ")"; }
116 }

Variable Documentation

const G4int G4Analysis::kInvalidId = -1