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