Geant4_10
G4AnalysisUtilities.cc
Go to the documentation of this file.
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 // $Id:$
27 
28 // Author: Ivana Hrivnacova, 22/08/2013 (ivana@ipno.in2p3.fr)
29 
30 #include "G4AnalysisUtilities.hh"
31 #include "G4BinScheme.hh"
32 #include "G4UnitsTable.hh"
33 
34 namespace G4Analysis
35 {
36 
37 //_____________________________________________________________________________
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 }
51 
52 
53 //_____________________________________________________________________________
54 G4bool CheckMinMax(G4double xmin, G4double xmax, const G4String& binSchemeName)
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 }
80 
81 //_____________________________________________________________________________
82 G4bool CheckEdges(const std::vector<G4double>& edges)
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 }
96 
97 //_____________________________________________________________________________
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 }
107 
108 //_____________________________________________________________________________
110  const G4String& unitName,
111  const G4String& fcnName)
112 {
113  if ( fcnName != "none" ) { title += " "; title += fcnName; title += "("; }
114  if ( unitName != "none" ) { title += " ["; title += unitName; title += "]";}
115  if ( fcnName != "none" ) { title += ")"; }
116 }
117 
118 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double G4NeutronHPJENDLHEData::G4double result
int G4int
Definition: G4Types.hh:78
void UpdateTitle(G4String &title, const G4String &unitName, const G4String &fcnName)
static G4double GetValueOf(const G4String &)
bool G4bool
Definition: G4Types.hh:79
G4bool CheckMinMax(G4double xmin, G4double xmax, const G4String &binSchemeName)
G4double GetUnitValue(const G4String &unit)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
subroutine title(NA, NB, NCA, NCB)
Definition: dpm25nuc7.f:1744
G4BinScheme GetBinScheme(const G4String &binSchemeName)
Definition: G4BinScheme.cc:36
const XML_Char int const XML_Char * value
Definition: expat.h:331
#define G4endl
Definition: G4ios.hh:61
G4bool CheckNbins(G4int nbins)
double G4double
Definition: G4Types.hh:76
G4bool CheckEdges(const std::vector< G4double > &edges)