Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4H3ToolsManager.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 "G4H3ToolsManager.hh"
32 #include "G4BaseHistoUtilities.hh"
33 #include "G4AnalysisUtilities.hh"
34 
35 #include "tools/histo/h3d"
36 
37 #include <fstream>
38 
39 using namespace G4Analysis;
40 
41 // static definitions
42 const G4int G4H3ToolsManager::kDimension = 3;
43 
44 //_____________________________________________________________________________
46  : G4VH3Manager(),
47  G4THnManager<tools::histo::h3d>(state, "H3")
48 {}
49 
50 //_____________________________________________________________________________
52 {}
53 
54 //
55 // Utility functions
56 //
57 
58 namespace {
59 
60 //_____________________________________________________________________________
61 void UpdateH3Information(G4HnInformation* hnInformation,
62  const G4String& xunitName,
63  const G4String& yunitName,
64  const G4String& zunitName,
65  const G4String& xfcnName,
66  const G4String& yfcnName,
67  const G4String& zfcnName,
68  G4BinScheme xbinScheme,
69  G4BinScheme ybinScheme,
70  G4BinScheme zbinScheme)
71 {
72  hnInformation->SetDimension(kX, xunitName, xfcnName, xbinScheme);
73  hnInformation->SetDimension(kY, yunitName, yfcnName, ybinScheme);
74  hnInformation->SetDimension(kZ, zunitName, zfcnName, zbinScheme);
75 }
76 
77 //_____________________________________________________________________________
78 void AddH3Annotation(tools::histo::h3d* h3d,
79  const G4String& xunitName,
80  const G4String& yunitName,
81  const G4String& zunitName,
82  const G4String& xfcnName,
83  const G4String& yfcnName,
84  const G4String& zfcnName)
85 {
86  G4String xaxisTitle;
87  G4String yaxisTitle;
88  G4String zaxisTitle;
89  UpdateTitle(xaxisTitle, xunitName, xfcnName);
90  UpdateTitle(yaxisTitle, yunitName, yfcnName);
91  UpdateTitle(zaxisTitle, zunitName, zfcnName);
92  h3d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
93  h3d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
94  h3d->add_annotation(tools::histo::key_axis_z_title(), zaxisTitle);
95 }
96 
97 //_____________________________________________________________________________
98 tools::histo::h3d* CreateToolsH3(
99  const G4String& title,
100  G4int nxbins, G4double xmin, G4double xmax,
101  G4int nybins, G4double ymin, G4double ymax,
102  G4int nzbins, G4double zmin, G4double zmax,
103  const G4String& xunitName,
104  const G4String& yunitName,
105  const G4String& zunitName,
106  const G4String& xfcnName,
107  const G4String& zfcnName,
108  const G4String& yfcnName,
109  const G4String& xbinSchemeName,
110  const G4String& ybinSchemeName,
111  const G4String& zbinSchemeName)
112 {
113  auto xunit = GetUnitValue(xunitName);
114  auto yunit = GetUnitValue(yunitName);
115  auto zunit = GetUnitValue(zunitName);
116  auto xfcn = GetFunction(xfcnName);
117  auto yfcn = GetFunction(yfcnName);
118  auto zfcn = GetFunction(zfcnName);
119  auto xbinScheme = GetBinScheme(xbinSchemeName);
120  auto ybinScheme = GetBinScheme(ybinSchemeName);
121  auto zbinScheme = GetBinScheme(zbinSchemeName);
122 
123  if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog && zbinScheme != G4BinScheme::kLog) {
124  if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser || zbinScheme == G4BinScheme::kUser) {
125  // This should never happen, but let's make sure about it
126  // by issuing a warning
127  G4ExceptionDescription description;
128  description
129  << " User binning scheme setting was ignored." << G4endl
130  << " Linear binning will be applied with given (nbins, xmin, xmax) values";
131  G4Exception("G4H3ToolsManager::CreateH3",
132  "Analysis_W013", JustWarning, description);
133  }
134  return new tools::histo::h3d(title,
135  nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
136  nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
137  nzbins, zfcn(zmin/zunit), zfcn(zmax/zunit));
138  // h3 objects are deleted in destructor and reset when
139  // closing a file.
140  }
141  else {
142  // Compute edges
143  std::vector<G4double> xedges;
144  ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
145  std::vector<G4double> yedges;
146  ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
147  std::vector<G4double> zedges;
148  ComputeEdges(nzbins, zmin, zmax, zunit, zfcn, zbinScheme, zedges);
149  return new tools::histo::h3d(title, xedges, yedges, zedges);
150  }
151 }
152 
153 //_____________________________________________________________________________
154 tools::histo::h3d* CreateToolsH3(
155  const G4String& title,
156  const std::vector<G4double>& xedges,
157  const std::vector<G4double>& yedges,
158  const std::vector<G4double>& zedges,
159  const G4String& xunitName,
160  const G4String& yunitName,
161  const G4String& zunitName,
162  const G4String& xfcnName,
163  const G4String& yfcnName,
164  const G4String& zfcnName)
165 {
166  auto xunit = GetUnitValue(xunitName);
167  auto yunit = GetUnitValue(yunitName);
168  auto zunit = GetUnitValue(zunitName);
169  auto xfcn = GetFunction(xfcnName);
170  auto yfcn = GetFunction(yfcnName);
171  auto zfcn = GetFunction(zfcnName);
172 
173  // Apply function
174  std::vector<G4double> xnewEdges;
175  ComputeEdges(xedges, xunit, xfcn, xnewEdges);
176  std::vector<G4double> ynewEdges;
177  ComputeEdges(yedges, yunit, yfcn, ynewEdges);
178  std::vector<G4double> znewEdges;
179  ComputeEdges(zedges, zunit, zfcn, znewEdges);
180 
181  return new tools::histo::h3d(title, xnewEdges, ynewEdges, znewEdges);
182  // h3 objects are deleted in destructor and reset when
183  // closing a file.
184 }
185 
186 //_____________________________________________________________________________
187 void ConfigureToolsH3(tools::histo::h3d* h3d,
188  G4int nxbins, G4double xmin, G4double xmax,
189  G4int nybins, G4double ymin, G4double ymax,
190  G4int nzbins, G4double zmin, G4double zmax,
191  const G4String& xunitName,
192  const G4String& yunitName,
193  const G4String& zunitName,
194  const G4String& xfcnName,
195  const G4String& yfcnName,
196  const G4String& zfcnName,
197  const G4String& xbinSchemeName,
198  const G4String& ybinSchemeName,
199  const G4String& zbinSchemeName)
200 {
201  auto xunit = GetUnitValue(xunitName);
202  auto yunit = GetUnitValue(yunitName);
203  auto zunit = GetUnitValue(zunitName);
204  auto xfcn = GetFunction(xfcnName);
205  auto yfcn = GetFunction(yfcnName);
206  auto zfcn = GetFunction(zfcnName);
207  auto xbinScheme = GetBinScheme(xbinSchemeName);
208  auto ybinScheme = GetBinScheme(ybinSchemeName);
209  auto zbinScheme = GetBinScheme(zbinSchemeName);
210 
211  if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog && zbinScheme != G4BinScheme::kLog) {
212  if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser || zbinScheme == G4BinScheme::kUser) {
213  // This should never happen, but let's make sure about it
214  // by issuing a warning
215  G4ExceptionDescription description;
216  description
217  << " User binning scheme setting was ignored." << G4endl
218  << " Linear binning will be applied with given (nbins, xmin, xmax) values";
219  G4Exception("G4H3ToolsManager::CreateH3",
220  "Analysis_W013", JustWarning, description);
221  }
222  h3d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
223  nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
224  nzbins, zfcn(zmin/zunit), zfcn(zmax/zunit));
225  }
226  else {
227  // Compute bins
228  std::vector<G4double> xedges;
229  ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
230  std::vector<G4double> yedges;
231  ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
232  std::vector<G4double> zedges;
233  ComputeEdges(nzbins, zmin, zmax, zunit, zfcn, zbinScheme, zedges);
234  h3d->configure(xedges, yedges, zedges);
235  }
236 }
237 
238 //_____________________________________________________________________________
239 void ConfigureToolsH3(tools::histo::h3d* h3d,
240  const std::vector<G4double>& xedges,
241  const std::vector<G4double>& yedges,
242  const std::vector<G4double>& zedges,
243  const G4String& xunitName,
244  const G4String& yunitName,
245  const G4String& zunitName,
246  const G4String& xfcnName,
247  const G4String& yfcnName,
248  const G4String& zfcnName)
249 {
250  auto xunit = GetUnitValue(xunitName);
251  auto xfcn = GetFunction(xfcnName);
252  std::vector<G4double> xnewEdges;
253  ComputeEdges(xedges, xunit, xfcn, xnewEdges);
254 
255  auto yunit = GetUnitValue(yunitName);
256  auto yfcn = GetFunction(yfcnName);
257  std::vector<G4double> ynewEdges;
258  ComputeEdges(yedges, yunit, yfcn, ynewEdges);
259 
260  auto zunit = GetUnitValue(zunitName);
261  auto zfcn = GetFunction(zfcnName);
262  std::vector<G4double> znewEdges;
263  ComputeEdges(zedges, zunit, zfcn, znewEdges);
264 
265  h3d->configure(xnewEdges, ynewEdges, znewEdges);
266 }
267 
268 }
269 
270 
271 //
272 // private methods
273 //
274 
275 //_____________________________________________________________________________
276 void G4H3ToolsManager::AddH3Information(const G4String& name,
277  const G4String& xunitName,
278  const G4String& yunitName,
279  const G4String& zunitName,
280  const G4String& xfcnName,
281  const G4String& yfcnName,
282  const G4String& zfcnName,
283  G4BinScheme xbinScheme,
284  G4BinScheme ybinScheme,
285  G4BinScheme zbinScheme) const
286 {
287  auto hnInformation = fHnManager->AddHnInformation(name, 3);
288  hnInformation->AddDimension(xunitName, xfcnName, xbinScheme);
289  hnInformation->AddDimension(yunitName, yfcnName, ybinScheme);
290  hnInformation->AddDimension(zunitName, zfcnName, zbinScheme);
291 }
292 
293 //
294 // protected methods
295 //
296 
297 //_____________________________________________________________________________
299  G4int nxbins, G4double xmin, G4double xmax,
300  G4int nybins, G4double ymin, G4double ymax,
301  G4int nzbins, G4double zmin, G4double zmax,
302  const G4String& xunitName, const G4String& yunitName,
303  const G4String& zunitName,
304  const G4String& xfcnName, const G4String& yfcnName,
305  const G4String& zfcnName,
306  const G4String& xbinSchemeName,
307  const G4String& ybinSchemeName,
308  const G4String& zbinSchemeName)
309 
310 {
311 #ifdef G4VERBOSE
312  if ( fState.GetVerboseL4() )
313  fState.GetVerboseL4()->Message("create", "H3", name);
314 #endif
315  tools::histo::h3d* h3d
316  = CreateToolsH3(title,
317  nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax,
318  xunitName, yunitName, zunitName,
319  xfcnName, yfcnName, zfcnName,
320  xbinSchemeName, ybinSchemeName, zbinSchemeName);
321 
322  // Add annotation
323  AddH3Annotation(h3d, xunitName, yunitName, zunitName,
324  xfcnName, yfcnName, zfcnName);
325 
326  // Save H3 information
327  auto xbinScheme = GetBinScheme(xbinSchemeName);
328  auto ybinScheme = GetBinScheme(ybinSchemeName);
329  auto zbinScheme = GetBinScheme(zbinSchemeName);
330  AddH3Information(
331  name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
332  xbinScheme, ybinScheme, zbinScheme);
333 
334  // Register histogram
335  G4int id = RegisterT(h3d, name);
336 
337 #ifdef G4VERBOSE
338  if ( fState.GetVerboseL2() )
339  fState.GetVerboseL2()->Message("create", "H3", name);
340 #endif
341 
342  return id;
343 }
344 
345 //_____________________________________________________________________________
347  const std::vector<G4double>& xedges,
348  const std::vector<G4double>& yedges,
349  const std::vector<G4double>& zedges,
350  const G4String& xunitName, const G4String& yunitName,
351  const G4String& zunitName,
352  const G4String& xfcnName, const G4String& yfcnName,
353  const G4String& zfcnName)
354 
355 {
356 #ifdef G4VERBOSE
357  if ( fState.GetVerboseL4() )
358  fState.GetVerboseL4()->Message("create", "H3", name);
359 #endif
360  tools::histo::h3d* h3d
361  = CreateToolsH3(title, xedges, yedges, zedges,
362  xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
363 
364  // Add annotation
365  AddH3Annotation(h3d, xunitName, yunitName, zunitName,
366  xfcnName, yfcnName, zfcnName);
367 
368  // Save H3 information
369  AddH3Information(
370  name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
372 
373  // Register histogram
374  G4int id = RegisterT(h3d, name);
375 
376 #ifdef G4VERBOSE
377  if ( fState.GetVerboseL2() )
378  fState.GetVerboseL2()->Message("create", "H3", name);
379 #endif
380 
381  return id;
382 }
383 
384 //_____________________________________________________________________________
386  G4int nxbins, G4double xmin, G4double xmax,
387  G4int nybins, G4double ymin, G4double ymax,
388  G4int nzbins, G4double zmin, G4double zmax,
389  const G4String& xunitName, const G4String& yunitName,
390  const G4String& zunitName,
391  const G4String& xfcnName, const G4String& yfcnName,
392  const G4String& zfcnName,
393  const G4String& xbinSchemeName,
394  const G4String& ybinSchemeName,
395  const G4String& zbinSchemeName)
396 {
397  auto h3d = GetTInFunction(id, "SetH3", false, false);
398  if ( ! h3d ) return false;
399 
400  auto info = fHnManager->GetHnInformation(id, "SetH3");
401 #ifdef G4VERBOSE
402  if ( fState.GetVerboseL4() )
403  fState.GetVerboseL4()->Message("configure", "H3", info->GetName());
404 #endif
405 
406  // Configure tools h3
407  ConfigureToolsH3(
408  h3d, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax,
409  xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
410  xbinSchemeName, ybinSchemeName, zbinSchemeName);
411 
412  // Add annotation
413  AddH3Annotation(h3d, xunitName, yunitName, zunitName,
414  xfcnName, yfcnName, zfcnName);
415 
416  // Update information
417  auto xbinScheme = GetBinScheme(xbinSchemeName);
418  auto ybinScheme = GetBinScheme(ybinSchemeName);
419  auto zbinScheme = GetBinScheme(zbinSchemeName);
420  UpdateH3Information(
421  info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
422  xbinScheme, ybinScheme, zbinScheme);
423 
424  // Set activation
425  fHnManager->SetActivation(id, true);
426 
427  return true;
428 }
429 
430 //_____________________________________________________________________________
432  const std::vector<G4double>& xedges,
433  const std::vector<G4double>& yedges,
434  const std::vector<G4double>& zedges,
435  const G4String& xunitName, const G4String& yunitName,
436  const G4String& zunitName,
437  const G4String& xfcnName, const G4String& yfcnName,
438  const G4String& zfcnName)
439 {
440  auto h3d = GetTInFunction(id, "SetH3", false, false);
441  if ( ! h3d ) return false;
442 
443  auto info = fHnManager->GetHnInformation(id, "SetH3");
444 #ifdef G4VERBOSE
445  if ( fState.GetVerboseL4() )
446  fState.GetVerboseL4()->Message("configure", "H3", info->GetName());
447 #endif
448 
449  // Configure tools h3
450  ConfigureToolsH3(h3d, xedges, yedges, zedges,
451  xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
452 
453  // Add annotation
454  AddH3Annotation(h3d, xunitName, yunitName, zunitName,
455  xfcnName, yfcnName, zfcnName);
456 
457  // Update information
458  UpdateH3Information(
459  info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
461 
462  // Set activation
463  fHnManager->SetActivation(id, true);
464 
465  return true;
466 }
467 
468 //_____________________________________________________________________________
470 {
471  auto h3d = GetTInFunction(id, "ScaleH3", false, false);
472  if ( ! h3d ) return false;
473 
474  return h3d->scale(factor);
475 }
476 
477 //_____________________________________________________________________________
479  G4double xvalue, G4double yvalue, G4double zvalue,
480  G4double weight)
481 {
482  auto h3d = GetTInFunction(id, "FillH3", true, false);
483  if ( ! h3d ) return false;
484 
485  if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
486  return false;
487  }
488 
490  = fHnManager->GetHnDimensionInformation(id, kX, "FillH3");
492  = fHnManager->GetHnDimensionInformation(id, kY, "FillH3");
494  = fHnManager->GetHnDimensionInformation(id, kZ, "FillH3");
495 
496  h3d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
497  yInfo->fFcn(yvalue/yInfo->fUnit),
498  zInfo->fFcn(zvalue/zInfo->fUnit), weight);
499 #ifdef G4VERBOSE
500  if ( fState.GetVerboseL4() ) {
501  G4ExceptionDescription description;
502  description << " id " << id
503  << " xvalue " << xvalue
504  << " xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
505  << " yvalue " << yvalue
506  << " yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
507  << " zvalue " << zvalue
508  << " zfcn(zvalue/zunit) " << zInfo->fFcn(zvalue/zInfo->fUnit)
509  << " weight " << weight;
510  fState.GetVerboseL4()->Message("fill", "H3", description);
511  }
512 #endif
513  return true;
514 }
515 
516 //_____________________________________________________________________________
518 {
519  return GetTId(name, warn);
520 }
521 
522 //_____________________________________________________________________________
524 {
525  auto h3d = GetTInFunction(id, "GetH3NXbins");
526  if ( ! h3d ) return 0;
527 
528  return GetNbins(*h3d, kX);
529 }
530 
531 //_____________________________________________________________________________
533 {
534 // Returns xmin value with applied unit and histogram function
535 
536  auto h3d = GetTInFunction(id, "GetH3Xmin");
537  if ( ! h3d ) return 0.;
538 
539  return GetMin(*h3d, kX);
540 }
541 
542 //_____________________________________________________________________________
544 {
545  auto h3d = GetTInFunction(id, "GetH3Xmax");
546  if ( ! h3d ) return 0.;
547 
548  return GetMax(*h3d, kX);
549 }
550 
551 //_____________________________________________________________________________
553 {
554  auto h3d = GetTInFunction(id, "GetH3XWidth", true, false);
555  if ( ! h3d ) return 0.;
556 
557  return GetWidth(*h3d, kX, fHnManager->GetHnType());
558 }
559 
560 //_____________________________________________________________________________
562 {
563  auto h3d = GetTInFunction(id, "GetH3NYbins");
564  if ( ! h3d ) return 0;
565 
566  return GetNbins(*h3d, kY);
567 }
568 
569 //_____________________________________________________________________________
571 {
572 // Returns xmin value with applied unit and histogram function
573 
574  auto h3d = GetTInFunction(id, "GetH3Ymin");
575  if ( ! h3d ) return 0.;
576 
577  return GetMin(*h3d, kY);
578 }
579 
580 //_____________________________________________________________________________
582 {
583  auto h3d = GetTInFunction(id, "GetH3Ymax");
584  if ( ! h3d ) return 0.;
585 
586  return GetMax(*h3d, kY);
587 }
588 
589 //_____________________________________________________________________________
591 {
592  auto h3d = GetTInFunction(id, "GetH3YWidth", true, false);
593  if ( ! h3d ) return 0.;
594 
595  return GetWidth(*h3d, kY, fHnManager->GetHnType());
596 }
597 
598 //_____________________________________________________________________________
600 {
601  auto h3d = GetTInFunction(id, "GetH3NZbins");
602  if ( ! h3d ) return 0;
603 
604  return GetNbins(*h3d, kZ);
605 }
606 
607 //_____________________________________________________________________________
609 {
610 // Returns xmin value with applied unit and histogram function
611 
612  auto h3d = GetTInFunction(id, "GetH3Zmin");
613  if ( ! h3d ) return 0.;
614 
615  return GetMin(*h3d, kZ);
616 }
617 
618 //_____________________________________________________________________________
620 {
621  auto h3d = GetTInFunction(id, "GetH3Zmax");
622  if ( ! h3d ) return 0.;
623 
624  return GetMax(*h3d, kZ);
625 }
626 
627 //_____________________________________________________________________________
629 {
630  auto h3d = GetTInFunction(id, "GetH3ZWidth", true, false);
631  if ( ! h3d ) return 0.;
632 
633  return GetWidth(*h3d, kZ, fHnManager->GetHnType());
634 }
635 
636 //_____________________________________________________________________________
638 {
639  auto h3d = GetTInFunction(id, "SetH3Title");
640  if ( ! h3d ) return false;
641 
642  return SetTitle(*h3d, title);
643 }
644 
645 //_____________________________________________________________________________
647 {
648  auto h3d = GetTInFunction(id, "SetH3XAxisTitle");
649  if ( ! h3d ) return false;
650 
651  return SetAxisTitle(*h3d, kX, title);
652 }
653 
654 //_____________________________________________________________________________
656 {
657  auto h3d = GetTInFunction(id, "SetH3YAxisTitle");
658  if ( ! h3d ) return false;
659 
660  return SetAxisTitle(*h3d, kY, title);
661 }
662 
663 //_____________________________________________________________________________
665 {
666  auto h3d = GetTInFunction(id, "SetH3ZAxisTitle");
667  if ( ! h3d ) return false;
668 
669  return SetAxisTitle(*h3d, kZ, title);
670 }
671 
672 //_____________________________________________________________________________
674 {
675  auto h3d = GetTInFunction(id, "GetH3Title");
676  if ( ! h3d ) return "";
677 
678  return GetTitle(*h3d);
679 }
680 
681 //_____________________________________________________________________________
683 {
684  auto h3d = GetTInFunction(id, "GetH3XAxisTitle");
685  if ( ! h3d ) return "";
686 
687  return GetAxisTitle(*h3d, kX, fHnManager->GetHnType());
688 }
689 
690 //_____________________________________________________________________________
692 {
693  auto h3d = GetTInFunction(id, "GetH3YAxisTitle");
694  if ( ! h3d ) return "";
695 
696  return GetAxisTitle(*h3d, kY, fHnManager->GetHnType());
697 }
698 
699 //_____________________________________________________________________________
701 {
702  auto h3d = GetTInFunction(id, "GetH3ZAxisTitle");
703  if ( ! h3d ) return "";
704 
705  return GetAxisTitle(*h3d, kZ, fHnManager->GetHnType());
706 }
707 
708 //_____________________________________________________________________________
709 G4bool G4H3ToolsManager::WriteOnAscii(std::ofstream& /*output*/)
710 {
711 // Write selected objects on ASCII file
712 // According to the implementation by Michel Maire, originally in
713 // extended examples.
714 // Not yet available for H3
715 
716  return ! fHnManager->IsAscii();
717 }
718 
719 //
720 // public methods
721 //
722 
723 //_____________________________________________________________________________
724 G4int G4H3ToolsManager::AddH3(const G4String& name, tools::histo::h3d* h3d)
725 {
726 #ifdef G4VERBOSE
727  if ( fState.GetVerboseL4() )
728  fState.GetVerboseL4()->Message("add", "H3", name);
729 #endif
730 
731  // Add annotation
732  AddH3Annotation(h3d, "none", "none", "none", "none", "none", "none");
733  // Add information
734  AddH3Information(name, "none", "none", "none", "none", "none", "none",
736 
737  // Register histogram
738  G4int id = RegisterT(h3d, name);
739 
740 #ifdef G4VERBOSE
741  if ( fState.GetVerboseL2() )
742  fState.GetVerboseL2()->Message("add", "H3", name);
743 #endif
744  return id;
745 }
746 
747 //_____________________________________________________________________________
749  const std::vector<tools::histo::h3d*>& h3Vector)
750 {
751  AddTVector(h3Vector);
752 }
753 
754 //_____________________________________________________________________________
755 tools::histo::h3d* G4H3ToolsManager::GetH3(G4int id, G4bool warn,
756  G4bool onlyIfActive) const
757 {
758  return GetTInFunction(id, "GetH3", warn, onlyIfActive);
759 }
760 
G4double GetWidth(const G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &hnType)
const XML_Char XML_Encoding * info
Definition: expat.h:530
virtual G4bool SetH3YAxisTitle(G4int id, const G4String &title) final
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
virtual G4double GetH3Ymin(G4int id) const final
const XML_Char * name
Definition: expat.h:151
void AddH3Vector(const std::vector< tools::histo::h3d * > &h3Vector)
G4String GetTitle(const G4ToolsBaseHisto &baseHisto)
const G4int kZ
G4int AddH3(const G4String &name, tools::histo::h3d *h3d)
G4String GetAxisTitle(const G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &hnType)
virtual G4double GetH3Ymax(G4int id) const final
G4double GetMin(const G4ToolsBaseHisto &baseHisto, G4int dimension)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
virtual G4bool SetH3Title(G4int id, const G4String &title) final
void ComputeEdges(G4int nbins, G4double xmin, G4double xmax, G4double unit, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
Definition: G4BinScheme.cc:56
virtual G4bool ScaleH3(G4int id, G4double factor) final
virtual G4String GetH3YAxisTitle(G4int id) const final
virtual G4double GetH3ZWidth(G4int id) const final
G4bool SetAxisTitle(G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &title)
virtual G4bool SetH3(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4int nzbins, G4double zmin, G4double zmax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear", const G4String &zbinScheme="linear") final
virtual G4bool SetH3ZAxisTitle(G4int id, const G4String &title) final
int G4int
Definition: G4Types.hh:78
std::shared_ptr< G4HnManager > fHnManager
Definition: G4THnManager.hh:83
virtual G4double GetH3YWidth(G4int id) const final
G4int RegisterT(tools::histo::h3d *t, const G4String &name)
const G4AnalysisVerbose * GetVerboseL2() const
virtual G4int GetH3Nybins(G4int id) const final
virtual G4int GetH3Nzbins(G4int id) const final
void UpdateTitle(G4String &title, const G4String &unitName, const G4String &fcnName)
const G4AnalysisManagerState & fState
Definition: G4THnManager.hh:80
virtual G4bool WriteOnAscii(std::ofstream &output) final
G4int GetTId(const G4String &name, G4bool warn=true) const
const G4AnalysisVerbose * GetVerboseL4() const
virtual G4double GetH3XWidth(G4int id) const final
bool G4bool
Definition: G4Types.hh:79
const G4int kX
virtual G4double GetH3Zmin(G4int id) const final
virtual G4bool FillH3(G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight=1.0) final
tools::histo::h3d * GetTInFunction(G4int id, G4String functionName, G4bool warn=true, G4bool onlyIfActive=true) const
G4double GetUnitValue(const G4String &unit)
G4bool SetTitle(G4ToolsBaseHisto &baseHisto, const G4String &title)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4Fcn GetFunction(const G4String &fcnName)
Definition: G4Fcn.cc:36
virtual G4int CreateH3(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4int nzbins, G4double zmin, G4double zmax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear", const G4String &zbinScheme="linear") final
void AddTVector(const std::vector< tools::histo::h3d * > &tVector)
virtual G4double GetH3Xmax(G4int id) const final
virtual G4double GetH3Xmin(G4int id) const final
virtual G4String GetH3XAxisTitle(G4int id) const final
G4BinScheme GetBinScheme(const G4String &binSchemeName)
Definition: G4BinScheme.cc:36
#define G4endl
Definition: G4ios.hh:61
G4double GetMax(const G4ToolsBaseHisto &baseHisto, G4int dimension)
G4BinScheme
Definition: G4BinScheme.hh:40
virtual ~G4H3ToolsManager()
G4int GetNbins(const G4ToolsBaseHisto &baseHisto, G4int dimension)
double G4double
Definition: G4Types.hh:76
virtual G4bool SetH3XAxisTitle(G4int id, const G4String &title) final
void AddDimension(const G4String &unitName, const G4String &fcnName, G4BinScheme binScheme)
virtual G4int GetH3Nxbins(G4int id) const final
const G4int kY
tools::histo::h3d * GetH3(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
subroutine title
Definition: hijing1.383.f:5980
virtual G4String GetH3Title(G4int id) const final
virtual G4int GetH3Id(const G4String &name, G4bool warn=true) const final
G4H3ToolsManager(const G4AnalysisManagerState &state)
virtual G4String GetH3ZAxisTitle(G4int id) const final
virtual G4double GetH3Zmax(G4int id) const final
void SetDimension(G4int dimension, const G4String &unitName, const G4String &fcnName, G4BinScheme binScheme)