Geant4  10.01.p03
G4BaseToolsManager.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, 24/07/2014 (ivana@ipno.in2p3.fr)
29 
30 #include "G4BaseToolsManager.hh"
31 
32 #include "tools/histo/axis"
33 
34 
35 // static data
36 
40 
41 //
42 // Constructors, destructor
43 //
44 
45 //_____________________________________________________________________________
47  : fHnType(hnType)
48 {
49 }
50 
51 //_____________________________________________________________________________
53 {
54 }
55 
56 //_____________________________________________________________________________
58  G4int dimension) const
59 {
60  return baseHisto.get_axis(dimension).bins();
61 }
62 
63 //_____________________________________________________________________________
65  G4int dimension) const
66 {
67 // Returns min data value
68 
69  return baseHisto.get_axis(dimension).lower_edge();
70 }
71 
72 //_____________________________________________________________________________
74  G4int dimension) const
75 {
76 // Returns max data value
77 
78  return baseHisto.get_axis(dimension).upper_edge();
79 }
80 
81 //_____________________________________________________________________________
83  G4int dimension) const
84 {
85  G4int nbins = baseHisto.get_axis(dimension).bins();
86  if ( ! nbins ) {
87  G4String functionName = "G4BaseToolsManager::Get";
88  functionName += fHnType;
89  functionName += "Width";
90  G4ExceptionDescription description;
91  description << " nbins = 0 (for " << fHnType << ").";
92  G4Exception(functionName, "Analysis_W014", JustWarning, description);
93  return 0;
94  }
95 
96  return ( baseHisto.get_axis(dimension).upper_edge()
97  - baseHisto.get_axis(dimension).lower_edge() )/nbins;
98 }
99 
100 //_____________________________________________________________________________
102  const G4String& title)
103 {
104  return baseHisto.set_title(title);
105 }
106 
107 //_____________________________________________________________________________
109  G4int dimension, const G4String& title)
110 {
111  if ( dimension == 0 ) {
112  baseHisto.add_annotation(tools::histo::key_axis_x_title(), title);
113  }
114  else if ( dimension == 1 ) {
115  baseHisto.add_annotation(tools::histo::key_axis_y_title(), title);
116  }
117  else if ( dimension == 2 ) {
118  baseHisto.add_annotation(tools::histo::key_axis_z_title(), title);
119  }
120 
121  return true;
122 }
123 
124 //_____________________________________________________________________________
126 {
127  return baseHisto.title();
128 }
129 
130 
131 //_____________________________________________________________________________
133  G4int dimension) const
134 {
135  G4String title;
136  G4bool result = false;
137  if ( dimension == 0 ) {
138  result = baseHisto.annotation(tools::histo::key_axis_x_title(), title);
139  }
140  else if ( dimension == 1 ) {
141  result = baseHisto.annotation(tools::histo::key_axis_y_title(), title);
142  }
143  else if ( dimension == 2 ) {
144  result = baseHisto.annotation(tools::histo::key_axis_z_title(), title);
145  }
146 
147  if ( ! result ) {
148  G4String axes("xyz");
149  G4String axis = axes(dimension, 1);
150  G4String functionName = "G4BaseToolsManager::Get";
151  functionName += fHnType;
152  functionName += axis;
153  functionName += "Title";
154  G4ExceptionDescription description;
155  description << " Failed to get " << axis << " axis " << fHnType << " title.";
156  G4Exception(functionName, "Analysis_W014", JustWarning, description);
157  return "";
158  }
159 
160  return title;
161 }
G4bool SetTitle(G4ToolsBaseHisto &baseHisto, const G4String &title)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String GetTitle(const G4ToolsBaseHisto &baseHisto) const
static const G4int kY
static const G4int kZ
int G4int
Definition: G4Types.hh:78
G4String GetAxisTitle(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
G4BaseToolsManager(const G4String &hnType)
G4int GetNbins(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
bool G4bool
Definition: G4Types.hh:79
G4double GetWidth(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
tools::histo::base_histo< double, unsigned int, unsigned int, double, double > G4ToolsBaseHisto
G4double GetMax(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
double G4double
Definition: G4Types.hh:76
G4double GetMin(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
G4bool SetAxisTitle(G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &title)
static const G4int kX