Geant4  10.01.p02
ExG4HbookH2Manager.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, 15/06/2011 (ivana@ipno.in2p3.fr)
32 
33 #ifdef G4_USE_HBOOK
34 
35 #include "ExG4HbookH2Manager.hh"
36 #include "ExG4HbookFileManager.hh"
37 #include "G4HnManager.hh"
39 #include "G4AnalysisUtilities.hh"
40 
41 #include <iostream>
42 
43 using namespace G4Analysis;
44 
45 const G4int ExG4HbookH2Manager::fgkDefaultH2HbookIdOffset = 100;
46 
47 //_____________________________________________________________________________
48 ExG4HbookH2Manager::ExG4HbookH2Manager(const G4AnalysisManagerState& state)
49  : G4VH2Manager(state),
50  fBaseToolsManager("H2"),
51  fFileManager(0),
52  fH2HbookIdOffset(-1),
53  fH2Vector(),
54  fH2BookingVector(),
55  fH2NameIdMap()
56 {
57 }
58 
59 //_____________________________________________________________________________
60 ExG4HbookH2Manager::~ExG4HbookH2Manager()
61 {
62  // Delete h2
63  Reset();
64 
65  // Delete h2 booking
66  std::vector<h2_booking*>::iterator it2;
67  for ( it2 = fH2BookingVector.begin(); it2 != fH2BookingVector.end(); it2++ ) {
68  delete *it2;
69  }
70 }
71 
72 //
73 // private methods
74 //
75 
76 //_____________________________________________________________________________
77 void ExG4HbookH2Manager::SetH2HbookIdOffset()
78 {
79 // Set fH2HbookIdOffset if needed
80 
81  if ( fH2HbookIdOffset == -1 ) {
82  if ( fFirstId > 0 )
83  fH2HbookIdOffset = 0;
84  else
85  fH2HbookIdOffset = 1;
86 
87  if ( fH2HbookIdOffset > 0 ) {
88  G4ExceptionDescription description;
89  description << "H2 will be defined in HBOOK with ID = G4_firstHistoId + 1";
90  G4Exception("ExG4HbookH2Manager::SetH1HbookIdOffset",
91  "Analysis_W013", JustWarning, description);
92  }
93  }
94 }
95 
96 //_____________________________________________________________________________
97 void ExG4HbookH2Manager::CreateH2sFromBooking()
98 {
99 // Create h2 from h2_booking.
100 
101  // Do nothing if any h2 histogram already exists
102  // or no h2 histograms are booked
103  if ( fH2Vector.size() || ( fH2BookingVector.size() == 0 ) ) return;
104 
105  // Go to histograms directory
106  if ( fFileManager->GetHistoDirectoryName() != "" ) {
107  G4String histoPath = "//PAWC/LUN1/";
108  histoPath.append(fFileManager->GetHistoDirectoryName().data());
109  tools::hbook::CHCDIR(histoPath.data()," ");
110  }
111 
112  // Create histograms
113  G4int index = 0;
114  std::vector<h2_booking*>::const_iterator it;
115  for ( it = fH2BookingVector.begin(); it != fH2BookingVector.end(); ++it) {
116  // Get information
117  G4int id = index + fFirstId;
118  G4HnInformation* info = fHnManager->GetHnInformation(id, "CreateH2FromBooking");
119  // Hbook index
120  G4int hbookIndex = fH2HbookIdOffset + index + fFirstId;
121  ++index;
122 
123 #ifdef G4VERBOSE
124  if ( fState.GetVerboseL3() )
125  fState.GetVerboseL3()->Message("create from booking", "h2", info->GetName());
126 #endif
127 
128  // Create h2
129  tools::hbook::h2* h2
130  = new tools::hbook::h2(hbookIndex, (*it)->fTitle,
131  (*it)->fNxbins, (*it)->fXmin, (*it)->fXmax,
132  (*it)->fNybins, (*it)->fYmin, (*it)->fYmax);
133  fH2Vector.push_back(h2);
134 
135 #ifdef G4VERBOSE
136  if ( fState.GetVerboseL3() ) {
137  G4ExceptionDescription description;
138  description << " name : " << info->GetName() << " hbook index : " << hbookIndex;
139  fState.GetVerboseL3()->Message("create from booking", "h2", description);
140  }
141 #endif
142  }
143 
144  if ( fFileManager->GetHistoDirectoryName() != "" ) {
145  // Return to //PAWC/LUN1 :
146  tools::hbook::CHCDIR("//PAWC/LUN1"," ");
147  }
148 }
149 
150 //_____________________________________________________________________________
151 void ExG4HbookH2Manager::Reset()
152 {
153 // Reset histograms and ntuple
154 
155  // Delete histograms
156  std::vector<tools::hbook::h2*>::iterator it2;
157  for (it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) {
158  delete *it2;
159  }
160 
161  // Clear vectors
162  fH2Vector.clear();
163 }
164 
165 //_____________________________________________________________________________
166 h2_booking* ExG4HbookH2Manager::GetH2Booking(G4int id, G4bool warn) const
167 {
168  G4int index = id - fFirstId;
169  if ( index < 0 || index >= G4int(fH2BookingVector.size()) ) {
170  if ( warn) {
171  G4ExceptionDescription description;
172  description << " " << "histo " << id << " does not exist.";
173  G4Exception("G4HbookAnalysisManager::GetH2Booking()",
174  "Analysis_W011", JustWarning, description);
175  }
176  return 0;
177  }
178 
179  return fH2BookingVector[index];
180 }
181 
182 //
183 // protected methods
184 //
185 
186 //_____________________________________________________________________________
187 G4bool ExG4HbookH2Manager::WriteOnAscii(std::ofstream& /*output*/)
188 {
189 // Write selected objects on ASCII file
190 // According to the implementation by Michel Maire, originally in
191 // extended examples.
192 // Not yet available for H2
193 
194  return false;
195 }
196 
197 //_____________________________________________________________________________
198 tools::hbook::h2* ExG4HbookH2Manager::GetH2InFunction(G4int id,
199  G4String functionName, G4bool warn,
200  G4bool onlyIfActive) const
201 {
202  G4int index = id - fFirstId;
203  if ( index < 0 || index >= G4int(fH2Vector.size()) ) {
204  if ( warn) {
205  G4String inFunction = "ExG4HbookH2Manager::";
206  inFunction += functionName;
207  G4ExceptionDescription description;
208  description << " " << "histogram " << id << " does not exist.";
209  G4Exception(inFunction, "Analysis_W011", JustWarning, description);
210  }
211  return 0;
212  }
213 
214  // Do not return histogram if inactive
215  if ( fState.GetIsActivation() && onlyIfActive && ( ! fHnManager->GetActivation(id) ) ) {
216  return 0;
217  }
218 
219  return fH2Vector[index];
220 }
221 
222 //
223 // public methods
224 //
225 
226 //_____________________________________________________________________________
227 G4int ExG4HbookH2Manager::CreateH2(const G4String& name, const G4String& title,
228  G4int nxbins, G4double xmin, G4double xmax,
229  G4int nybins, G4double ymin, G4double ymax,
230  const G4String& xunitName, const G4String& yunitName,
231  const G4String& xfcnName, const G4String& yfcnName,
232  const G4String& xbinSchemeName,
233  const G4String& ybinSchemeName)
234 
235 {
236  // HBook does not support user defined binning for H2
237  if ( xbinSchemeName != "linear" || ybinSchemeName != "linear" ) {
238  G4ExceptionDescription description;
239  description
240  << " "
241  << "Logarithimc binning is not supported for H2.";
242  G4Exception("ExG4HbookH2Manager::CreateH2",
243  "Analysis_F015", FatalException, description);
244  }
245 
246 #ifdef G4VERBOSE
247  if ( fState.GetVerboseL4() )
248  fState.GetVerboseL4()->Message("create", "H2", name);
249 #endif
250 
251  // Create h2 booking & information
252  G4int index = fH2BookingVector.size();
253  G4double xunit = GetUnitValue(xunitName);
254  G4double yunit = GetUnitValue(yunitName);
255  G4Fcn xfcn = GetFunction(xfcnName);
256  G4Fcn yfcn = GetFunction(yfcnName);
257  G4BinScheme xbinScheme = GetBinScheme(xbinSchemeName);
258  G4BinScheme ybinScheme = GetBinScheme(ybinSchemeName);
259  G4String newTitle(title);
260  UpdateTitle(newTitle, xunitName, xfcnName);
261  UpdateTitle(newTitle, yunitName, yfcnName);
262 
263  h2_booking* h2Booking = new h2_booking(nxbins, xfcn(xmin), xfcn(xmax),
264  nybins, yfcn(ymin), yfcn(ymax));
265  // h2_booking object is deleted in destructor
266  h2Booking->fTitle = newTitle;
267  fH2BookingVector.push_back(h2Booking);
268  fHnManager
269  ->AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName,
270  xunit, yunit, xfcn, yfcn, xbinScheme, ybinScheme);
271 
272  // Set fH1HbookIdOffset if needed
273  SetH2HbookIdOffset();
274 
275  // Hbook index
276  G4int hbookIndex = fH2HbookIdOffset + index + fFirstId;
277 
278  // Create h2 if the file is open
279  if ( fFileManager->IsFile() ) {
280  // Go to histograms directory
281  G4String histoPath = "//PAWC/LUN1/";
282  if ( fFileManager->GetHistoDirectoryName() != "" ) {
283  histoPath.append(fFileManager->GetHistoDirectoryName().data());
284  }
285  tools::hbook::CHCDIR(histoPath.data()," ");
286 
287  // Create histogram
288  tools::hbook::h2* h2
289  = new tools::hbook::h2(hbookIndex, title,
290  nxbins, xfcn(xmin), xfcn(xmax),
291  nybins, yfcn(ymin), yfcn(ymax));
292  // h2 objects are deleted when closing a file.
293  fH2Vector.push_back(h2);
294 
295  // Return to //PAWC/LUN1
296  if ( fFileManager->GetHistoDirectoryName() != "" ) {
297  tools::hbook::CHCDIR("//PAWC/LUN1"," ");
298  }
299  }
300 
301  fLockFirstId = true;
302 
303 #ifdef G4VERBOSE
304  if ( fState.GetVerboseL2() ) {
305  G4ExceptionDescription description;
306  description << " name : " << name << " hbook index : " << hbookIndex;
307  fState.GetVerboseL2()->Message("create", "H2", description);
308  }
309 #endif
310 
311  fH2NameIdMap[name] = index + fFirstId;
312  return index + fFirstId;
313 }
314 
315 //_____________________________________________________________________________
316 G4int ExG4HbookH2Manager::CreateH2(const G4String& /*name*/, const G4String& /*title*/,
317  const std::vector<G4double>& /*xedges*/,
318  const std::vector<G4double>& /*yedges*/,
319  const G4String& /*xunitName*/, const G4String& /*yunitName*/,
320  const G4String& /*xfcnName*/, const G4String& /*yfcnName*/)
321 {
322  // HBook does not support user defined binning for H2
323  G4ExceptionDescription description;
324  description
325  << " "
326  << "User defined binning is not supported for H2.";
327  G4Exception("ExG4HbookH2Manager::CreateH2",
328  "Analysis_F015", FatalException, description);
329  return 0;
330 }
331 
332 //_____________________________________________________________________________
333 G4bool ExG4HbookH2Manager::SetH2(G4int id,
334  G4int nxbins, G4double xmin, G4double xmax,
335  G4int nybins, G4double ymin, G4double ymax,
336  const G4String& xunitName, const G4String& yunitName,
337  const G4String& xfcnName, const G4String& yfcnName,
338  const G4String& xbinScheme, const G4String& ybinScheme)
339 {
340  // HBook does not support user defined binning for H2
341  if ( xbinScheme != "linear" || ybinScheme != "linear" ) {
342  G4ExceptionDescription description;
343  description
344  << " "
345  << "Logarithimc binning is not supported for H2.";
346  G4Exception("ExG4HbookH2Manager::CreateH2",
347  "Analysis_F015", FatalException, description);
348  }
349 
350  h2_booking* h2Booking = GetH2Booking(id, false);
351  if ( ! h2Booking ) {
352  G4ExceptionDescription description;
353  description << " " << "histogram " << id << " does not exist.";
354  G4Exception("G4HbookAnalysisManager::SetH2()",
355  "Analysis_W011", JustWarning, description);
356  return false;
357  }
358 
359  G4HnInformation* hnInfo = fHnManager->GetHnInformation(id, "SetH2");
360 #ifdef G4VERBOSE
361  if ( fState.GetVerboseL4() )
362  fState.GetVerboseL4()->Message("configure", "H2", hnInfo->GetName());
363 #endif
364 
365  // Keep new parameters in booking
366  G4double xunit = GetUnitValue(xunitName);
367  G4double yunit = GetUnitValue(yunitName);
368  G4Fcn xfcn = GetFunction(xfcnName);
369  G4Fcn yfcn = GetFunction(yfcnName);
370 
371  h2Booking->fNxbins = nxbins;
372  h2Booking->fXmin = xfcn(xmin/xunit);
373  h2Booking->fXmax = xfcn(xmax/xunit);
374  h2Booking->fNybins = nybins;
375  h2Booking->fYmin = yfcn(ymin/yunit);
376  h2Booking->fYmax = yfcn(ymax/yunit);
377 
378  // Keep new parameters in information
381  xInfo->fUnitName = xunitName;
382  xInfo->fFcnName = xfcnName;
383  xInfo->fUnit = xunit;
384  xInfo->fFcn = xfcn;
385 
388  yInfo->fUnitName = yunitName;
389  yInfo->fFcnName = yfcnName;
390  yInfo->fUnit = yunit;
391  yInfo->fFcn = yfcn;
392  fHnManager->SetActivation(id, true);
393 
394  G4String newTitle(h2Booking->fTitle);
395  UpdateTitle(newTitle, xunitName, xfcnName);
396  UpdateTitle(newTitle, yunitName, yfcnName);
397  h2Booking->fTitle = newTitle;
398 
399  // Re-configure histogram if it was already defined
400  if ( fH2Vector.size() ) {
401  tools::hbook::h2* h2 = GetH2(id);
402  h2->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
403  nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
404  }
405 
406  return true;
407 }
408 
409 //_____________________________________________________________________________
410 G4bool ExG4HbookH2Manager::SetH2(G4int /*id*/,
411  const std::vector<G4double>& /*xedges*/,
412  const std::vector<G4double>& /*yedges*/,
413  const G4String& /*xunitName*/, const G4String& /*yunitName*/,
414  const G4String& /*xfcnName*/, const G4String& /*yfcnName*/)
415 {
416  // HBook does not support user defined binning for H2
417  G4ExceptionDescription description;
418  description
419  << " "
420  << "User defined binning is not supported for H2.";
421  G4Exception("ExG4HbookH2Manager::CreateH2",
422  "Analysis_F015", FatalException, description);
423 
424  return false;
425 }
426 
427 //_____________________________________________________________________________
428 G4bool ExG4HbookH2Manager::ScaleH2(G4int id, G4double factor)
429 {
430  tools::hbook::h2* h2 = GetH2InFunction(id, "ScaleH2", false, false);
431  if ( ! h2 ) return false;
432 
433  return h2->scale(factor);
434 }
435 
436 //_____________________________________________________________________________
437 G4bool ExG4HbookH2Manager::FillH2(G4int id,
438  G4double xvalue, G4double yvalue,
439  G4double weight)
440 {
441  tools::hbook::h2* h2 = GetH2InFunction(id, "FillH2", true, false);
442  if ( ! h2 ) return false;
443 
444  if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) return false;
445 
447  = fHnManager->GetHnDimensionInformation(id, G4HnInformation::kX, "FillH2");
449  = fHnManager->GetHnDimensionInformation(id, G4HnInformation::kY, "FillH2");
450  h2->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
451  yInfo->fFcn(yvalue/yInfo->fUnit), weight);
452 #ifdef G4VERBOSE
453  if ( fState.GetVerboseL4() ) {
454  G4ExceptionDescription description;
455  description << " id " << id
456  << " xvalue " << xvalue
457  << " xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
458  << " yvalue " << yvalue
459  << " yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
460  << " weight " << weight;
461  fState.GetVerboseL4()->Message("fill", "H2", description);
462  }
463 #endif
464  return true;
465 }
466 
467 //_____________________________________________________________________________
468 tools::hbook::h2* ExG4HbookH2Manager::GetH2(G4int id, G4bool warn,
469  G4bool onlyIfActive) const
470 {
471  return GetH2InFunction(id, "GetH2", warn, onlyIfActive);
472 }
473 
474 //_____________________________________________________________________________
475 G4int ExG4HbookH2Manager::GetH2Id(const G4String& name, G4bool warn) const
476 {
477  std::map<G4String, G4int>::const_iterator it = fH2NameIdMap.find(name);
478  if ( it == fH2NameIdMap.end() ) {
479  if ( warn) {
480  G4String inFunction = "ExG4HbookH2Manager::GetH2Id";
481  G4ExceptionDescription description;
482  description << " " << "histogram " << name << " does not exist.";
483  G4Exception(inFunction, "Analysis_W011", JustWarning, description);
484  }
485  return -1;
486  }
487  return it->second;
488 }
489 
490 //_____________________________________________________________________________
491 G4int ExG4HbookH2Manager::GetH2Nxbins(G4int id) const
492 {
493  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2NXbins");
494  if ( ! h2 ) return 0;
495 
496  return fBaseToolsManager.GetNbins(h2->axis_x());
497 }
498 
499 //_____________________________________________________________________________
500 G4double ExG4HbookH2Manager::GetH2Xmin(G4int id) const
501 {
502 // Returns xmin value with applied unit and histogram function
503 
504  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Xmin");
505  if ( ! h2 ) return 0;
506 
507  return fBaseToolsManager.GetMin(h2->axis_x());
508 }
509 
510 //_____________________________________________________________________________
511 G4double ExG4HbookH2Manager::GetH2Xmax(G4int id) const
512 {
513  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Xmax");
514  if ( ! h2 ) return 0;
515 
516  return fBaseToolsManager.GetMin(h2->axis_x());
517 }
518 
519 //_____________________________________________________________________________
520 G4double ExG4HbookH2Manager::GetH2XWidth(G4int id) const
521 {
522  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2XWidth", true, false);
523  if ( ! h2 ) return 0;
524 
525  return fBaseToolsManager.GetWidth(h2->axis_x());
526 }
527 
528 //_____________________________________________________________________________
529 G4int ExG4HbookH2Manager::GetH2Nybins(G4int id) const
530 {
531  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2NYbins");
532  if ( ! h2 ) return 0;
533 
534  return fBaseToolsManager.GetNbins(h2->axis_y());
535 }
536 
537 //_____________________________________________________________________________
538 G4double ExG4HbookH2Manager::GetH2Ymin(G4int id) const
539 {
540 // Returns xmin value with applied unit and histogram function
541 
542  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Ymin");
543  if ( ! h2 ) return 0;
544 
545  return fBaseToolsManager.GetMin(h2->axis_y());
546 }
547 
548 //_____________________________________________________________________________
549 G4double ExG4HbookH2Manager::GetH2Ymax(G4int id) const
550 {
551  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Ymax");
552  if ( ! h2 ) return 0;
553 
554  return fBaseToolsManager.GetMax(h2->axis_y());
555 }
556 
557 //_____________________________________________________________________________
558 G4double ExG4HbookH2Manager::GetH2YWidth(G4int id) const
559 {
560  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2YWidth", true, false);
561  if ( ! h2 ) return 0;
562 
563  return fBaseToolsManager.GetWidth(h2->axis_y());
564 }
565 
566 //_____________________________________________________________________________
567 G4bool ExG4HbookH2Manager::SetH2Title(G4int id, const G4String& title)
568 {
569  h2_booking* h2Booking = GetH2Booking(id, false);
570  if ( ! h2Booking ) {
571  G4ExceptionDescription description;
572  description << " " << "histogram " << id << " does not exist.";
573  G4Exception("G4HbookAnalysisManager::SetH2Title()",
574  "Analysis_W011", JustWarning, description);
575  return false;
576  }
577 
578  h2Booking->fTitle = title;
579  return true;
580 }
581 
582 //_____________________________________________________________________________
583 G4bool ExG4HbookH2Manager::SetH2XAxisTitle(G4int id, const G4String& title)
584 {
585  tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2XAxisTitle");
586  if ( ! h2 ) return false;
587 
588  return fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kX, title);
589 }
590 
591 //_____________________________________________________________________________
592 G4bool ExG4HbookH2Manager::SetH2YAxisTitle(G4int id, const G4String& title)
593 {
594  tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2YAxisTitle");
595  if ( ! h2 ) return false;
596 
597  return fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kY, title);
598 }
599 
600 //_____________________________________________________________________________
601 G4bool ExG4HbookH2Manager::SetH2ZAxisTitle(G4int id, const G4String& title)
602 {
603  tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2ZAxisTitle");
604  if ( ! h2 ) return false;
605 
606  return fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kZ, title);
607 }
608 
609 //_____________________________________________________________________________
610 G4String ExG4HbookH2Manager::GetH2Title(G4int id) const
611 {
612  h2_booking* h2Booking = GetH2Booking(id, false);
613  if ( ! h2Booking ) {
614  G4ExceptionDescription description;
615  description << " " << "histogram " << id << " does not exist.";
616  G4Exception("G4HbookAnalysisManager::GetH2Title()",
617  "Analysis_W011", JustWarning, description);
618  return "";
619  }
620 
621  return h2Booking->fTitle;
622 }
623 
624 
625 //_____________________________________________________________________________
626 G4String ExG4HbookH2Manager::GetH2XAxisTitle(G4int id) const
627 {
628  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2XAxisTitle");
629  if ( ! h2 ) return "";
630 
631  return fBaseToolsManager.GetAxisTitle(*h2, ExG4HbookBaseHnManager::kX);
632 }
633 
634 //_____________________________________________________________________________
635 G4String ExG4HbookH2Manager::GetH2YAxisTitle(G4int id) const
636 {
637  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2YAxisTitle");
638  if ( ! h2 ) return "";
639 
640  return fBaseToolsManager.GetAxisTitle(*h2, ExG4HbookBaseHnManager::kY);
641 }
642 
643 //_____________________________________________________________________________
644 G4String ExG4HbookH2Manager::GetH2ZAxisTitle(G4int id) const
645 {
646  tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2ZAxisTitle");
647  if ( ! h2 ) return "";
648 
649  return fBaseToolsManager.GetAxisTitle(*h2, ExG4HbookBaseHnManager::kZ);
650 }
651 
652 //_____________________________________________________________________________
653 G4bool ExG4HbookH2Manager::SetH2HbookIdOffset(G4int offset)
654 {
655  if ( fH2Vector.size() ) {
656  G4ExceptionDescription description;
657  description
658  << "Cannot set H2HbookIdOffset as some H2 histogramms already exist.";
659  G4Exception("G4HbookAnalysisManager::SetH2HbookIdOffset()",
660  "Analysis_W013", JustWarning, description);
661  return false;
662  }
663 
664  if ( fFirstId + offset < 1 ) {
665  G4ExceptionDescription description;
666  description << "The first histogram HBOOK id must be >= 1.";
667  G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
668  "Analysis_W013", JustWarning, description);
669  return false;
670  }
671 
672  fH2HbookIdOffset = offset;
673  return true;
674 }
675 
676 #endif
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String name
Definition: TRTMaterials.hh:40
G4double(* G4Fcn)(G4double)
Definition: G4Fcn.hh:36
int G4int
Definition: G4Types.hh:78
void UpdateTitle(G4String &title, const G4String &unitName, const G4String &fcnName)
bool G4bool
Definition: G4Types.hh:79
G4double GetUnitValue(const G4String &unit)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const char * data() const
static const G4double factor
G4Fcn GetFunction(const G4String &fcnName)
Definition: G4Fcn.cc:36
G4String & append(const G4String &)
G4HnDimensionInformation * GetHnDimensionInformation(G4int dimension)
G4BinScheme GetBinScheme(const G4String &binSchemeName)
Definition: G4BinScheme.cc:36
Definition of the ExG4HbookH2Manager class.
G4String GetName() const
G4BinScheme
Definition: G4BinScheme.hh:40
double G4double
Definition: G4Types.hh:76
Definition of the ExG4HbookFileManager class.