ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4P2ToolsManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4P2ToolsManager.cc
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 
27 // Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
28 
29 #include "G4P2ToolsManager.hh"
31 #include "G4BaseHistoUtilities.hh"
32 #include "G4AnalysisUtilities.hh"
33 
34 #include "tools/histo/p2d"
35 
36 #include <fstream>
37 
38 using namespace G4Analysis;
39 
40 // static definitions
42 
43 //_____________________________________________________________________________
45  : G4VP2Manager(),
46  G4THnManager<tools::histo::p2d>(state, "P2")
47 {}
48 
49 //_____________________________________________________________________________
51 {}
52 
53 //
54 // Utility functions
55 //
56 
57 namespace {
58 
59 //_____________________________________________________________________________
60 void UpdateP2Information(G4HnInformation* hnInformation,
61  const G4String& xunitName,
62  const G4String& yunitName,
63  const G4String& zunitName,
64  const G4String& xfcnName,
65  const G4String& yfcnName,
66  const G4String& zfcnName,
67  G4BinScheme xbinScheme,
68  G4BinScheme ybinScheme)
69 {
70  hnInformation->SetDimension(kX, xunitName, xfcnName, xbinScheme);
71  hnInformation->SetDimension(kY, yunitName, yfcnName, ybinScheme);
72  hnInformation->SetDimension(kZ, zunitName, zfcnName, G4BinScheme::kLinear);
73 }
74 
75 //_____________________________________________________________________________
76 void AddP2Annotation(tools::histo::p2d* p2d,
77  const G4String& xunitName,
78  const G4String& yunitName,
79  const G4String& zunitName,
80  const G4String& xfcnName,
81  const G4String& yfcnName,
82  const G4String& zfcnName)
83 {
84  G4String xaxisTitle;
85  G4String yaxisTitle;
86  G4String zaxisTitle;
87  UpdateTitle(xaxisTitle, xunitName, xfcnName);
88  UpdateTitle(yaxisTitle, yunitName, yfcnName);
89  UpdateTitle(zaxisTitle, zunitName, zfcnName);
90  p2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
91  p2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
92  p2d->add_annotation(tools::histo::key_axis_z_title(), zaxisTitle);
93 }
94 
95 //_____________________________________________________________________________
96 tools::histo::p2d* CreateToolsP2(
97  const G4String& title,
98  G4int nxbins, G4double xmin, G4double xmax,
99  G4int nybins, G4double ymin, G4double ymax,
100  G4double zmin, G4double zmax,
101  const G4String& xunitName,
102  const G4String& yunitName,
103  const G4String& zunitName,
104  const G4String& xfcnName,
105  const G4String& zfcnName,
106  const G4String& yfcnName,
107  const G4String& xbinSchemeName,
108  const G4String& ybinSchemeName)
109 {
110  auto xunit = GetUnitValue(xunitName);
111  auto yunit = GetUnitValue(yunitName);
112  auto zunit = GetUnitValue(zunitName);
113  auto xfcn = GetFunction(xfcnName);
114  auto yfcn = GetFunction(yfcnName);
115  auto zfcn = GetFunction(zfcnName);
116  auto xbinScheme = GetBinScheme(xbinSchemeName);
117  auto ybinScheme = GetBinScheme(ybinSchemeName);
118 
119  if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog) {
120  if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser ) {
121  // This should never happen, but let's make sure about it
122  // by issuing a warning
123  G4ExceptionDescription description;
124  description
125  << " User binning scheme setting was ignored." << G4endl
126  << " Linear binning will be applied with given (nbins, xmin, xmax) values";
127  G4Exception("G4P2ToolsManager::CreateP2",
128  "Analysis_W013", JustWarning, description);
129  }
130  if ( zmin == 0. && zmax == 0.) {
131  return new tools::histo::p2d(title,
132  nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
133  nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
134  // p2 objects are deleted in destructor and reset when
135  // closing a file.
136  } else {
137  return new tools::histo::p2d(title,
138  nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
139  nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
140  zfcn(zmin/zunit), zfcn(zmax/zunit));
141  // p2 objects are deleted in destructor and reset when
142  // closing a file.
143  }
144  }
145  else {
146  // Compute edges
147  std::vector<G4double> xedges;
148  ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
149  std::vector<G4double> yedges;
150  ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
151  if ( zmin == 0. && zmax == 0.) {
152  return new tools::histo::p2d(title, xedges, yedges);
153  } else {
154  return new tools::histo::p2d(title, xedges, yedges,
155  zfcn(zmin/zunit), zfcn(zmax/zunit));
156  }
157  }
158 }
159 
160 //_____________________________________________________________________________
161 tools::histo::p2d* CreateToolsP2(
162  const G4String& title,
163  const std::vector<G4double>& xedges,
164  const std::vector<G4double>& yedges,
165  G4double zmin, G4double zmax,
166  const G4String& xunitName,
167  const G4String& yunitName,
168  const G4String& zunitName,
169  const G4String& xfcnName,
170  const G4String& yfcnName,
171  const G4String& zfcnName)
172 {
173  auto xunit = GetUnitValue(xunitName);
174  auto yunit = GetUnitValue(yunitName);
175  auto zunit = GetUnitValue(zunitName);
176  auto xfcn = GetFunction(xfcnName);
177  auto yfcn = GetFunction(yfcnName);
178  auto zfcn = GetFunction(zfcnName);
179 
180  // Apply function
181  std::vector<G4double> xnewEdges;
182  ComputeEdges(xedges, xunit, xfcn, xnewEdges);
183  std::vector<G4double> ynewEdges;
184  ComputeEdges(yedges, yunit, yfcn, ynewEdges);
185 
186  if ( zmin == 0. && zmax == 0.) {
187  return new tools::histo::p2d(title, xnewEdges, ynewEdges);
188  // p2 objects are deleted in destructor and reset when
189  // closing a file.
190  } else {
191  return new tools::histo::p2d(title, xnewEdges, ynewEdges,
192  zfcn(zmin/zunit), zfcn(zmax/zunit));
193  // p2 objects are deleted in destructor and reset when
194  // closing a file.
195  }
196 }
197 
198 //_____________________________________________________________________________
199 void ConfigureToolsP2(tools::histo::p2d* p2d,
200  G4int nxbins, G4double xmin, G4double xmax,
201  G4int nybins, G4double ymin, G4double ymax,
202  G4double zmin, G4double zmax,
203  const G4String& xunitName,
204  const G4String& yunitName,
205  const G4String& zunitName,
206  const G4String& xfcnName,
207  const G4String& yfcnName,
208  const G4String& zfcnName,
209  const G4String& xbinSchemeName,
210  const G4String& ybinSchemeName)
211 {
212  auto xunit = GetUnitValue(xunitName);
213  auto yunit = GetUnitValue(yunitName);
214  auto zunit = GetUnitValue(zunitName);
215  auto xfcn = GetFunction(xfcnName);
216  auto yfcn = GetFunction(yfcnName);
217  auto zfcn = GetFunction(zfcnName);
218  auto xbinScheme = GetBinScheme(xbinSchemeName);
219  auto ybinScheme = GetBinScheme(ybinSchemeName);
220 
221  if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog) {
222  if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser) {
223  // This should never happen, but let's make sure about it
224  // by issuing a warning
225  G4ExceptionDescription description;
226  description
227  << " User binning scheme setting was ignored." << G4endl
228  << " Linear binning will be applied with given (nbins, xmin, xmax) values";
229  G4Exception("G4P2ToolsManager::CreateP2",
230  "Analysis_W013", JustWarning, description);
231  }
232  if ( zmin == 0. && zmax == 0. ) {
233  p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
234  nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
235  } else {
236  p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
237  nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
238  zfcn(zmin/zunit), zfcn(zmax/zunit));
239  }
240  }
241  else {
242  // Compute bins
243  std::vector<G4double> xedges;
244  ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
245  std::vector<G4double> yedges;
246  ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
247  if ( zmin == 0. && zmax == 0. ) {
248  p2d->configure(xedges, yedges);
249  } else {
250  p2d->configure(xedges, yedges, zfcn(zmin/zunit), zfcn(zmax/zunit));
251  }
252  }
253 }
254 
255 //_____________________________________________________________________________
256 void ConfigureToolsP2(tools::histo::p2d* p2d,
257  const std::vector<G4double>& xedges,
258  const std::vector<G4double>& yedges,
259  G4double zmin, G4double zmax,
260  const G4String& xunitName,
261  const G4String& yunitName,
262  const G4String& zunitName,
263  const G4String& xfcnName,
264  const G4String& yfcnName,
265  const G4String& zfcnName)
266 {
267  // Apply function to edges
268  auto xunit = GetUnitValue(xunitName);
269  auto xfcn = GetFunction(xfcnName);
270  std::vector<G4double> xnewEdges;
271  ComputeEdges(xedges, xunit, xfcn, xnewEdges);
272 
273  auto yunit = GetUnitValue(yunitName);
274  auto yfcn = GetFunction(yfcnName);
275  std::vector<G4double> ynewEdges;
276  ComputeEdges(yedges, yunit, yfcn, ynewEdges);
277 
278  auto zunit = GetUnitValue(zunitName);
279  auto zfcn = GetFunction(zfcnName);
280  if ( zmin == 0. && zmax == 0. ) {
281  p2d->configure(xnewEdges, ynewEdges);
282  } else {
283  p2d->configure(xnewEdges, ynewEdges, zfcn(zmin/zunit), zfcn(zmax/zunit));
284  }
285 }
286 
287 }
288 
289 
290 //
291 // private methods
292 //
293 
294 //_____________________________________________________________________________
296  const G4String& xunitName,
297  const G4String& yunitName,
298  const G4String& zunitName,
299  const G4String& xfcnName,
300  const G4String& yfcnName,
301  const G4String& zfcnName,
302  G4BinScheme xbinScheme,
303  G4BinScheme ybinScheme) const
304 {
305  auto hnInformation = fHnManager->AddHnInformation(name, 3);
306  hnInformation->AddDimension(xunitName, xfcnName, xbinScheme);
307  hnInformation->AddDimension(yunitName, yfcnName, ybinScheme);
308  hnInformation->AddDimension(zunitName, zfcnName, G4BinScheme::kLinear);
309 }
310 
311 //
312 // protected methods
313 //
314 
315 //_____________________________________________________________________________
317  G4int nxbins, G4double xmin, G4double xmax,
318  G4int nybins, G4double ymin, G4double ymax,
319  G4double zmin, G4double zmax,
320  const G4String& xunitName, const G4String& yunitName,
321  const G4String& zunitName,
322  const G4String& xfcnName, const G4String& yfcnName,
323  const G4String& zfcnName,
324  const G4String& xbinSchemeName,
325  const G4String& ybinSchemeName)
326 
327 {
328 #ifdef G4VERBOSE
329  if ( fState.GetVerboseL4() )
330  fState.GetVerboseL4()->Message("create", "P2", name);
331 #endif
332  tools::histo::p2d* p2d
333  = CreateToolsP2(title,
334  nxbins, xmin, xmax, nybins, ymin, ymax, zmin, zmax,
335  xunitName, yunitName, zunitName,
336  xfcnName, yfcnName, zfcnName,
337  xbinSchemeName, ybinSchemeName);
338 
339  // Add annotation
340  AddP2Annotation(p2d, xunitName, yunitName, zunitName,
341  xfcnName, yfcnName, zfcnName);
342 
343  // Save P2 information
344  auto xbinScheme = GetBinScheme(xbinSchemeName);
345  auto ybinScheme = GetBinScheme(ybinSchemeName);
347  name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
348  xbinScheme, ybinScheme);
349 
350  // Register profile
351  G4int id = RegisterT(p2d, name);
352 
353 #ifdef G4VERBOSE
354  if ( fState.GetVerboseL2() )
355  fState.GetVerboseL2()->Message("create", "P2", name);
356 #endif
357 
358  return id;
359 }
360 
361 //_____________________________________________________________________________
363  const std::vector<G4double>& xedges,
364  const std::vector<G4double>& yedges,
365  G4double zmin, G4double zmax,
366  const G4String& xunitName, const G4String& yunitName,
367  const G4String& zunitName,
368  const G4String& xfcnName, const G4String& yfcnName,
369  const G4String& zfcnName)
370 
371 {
372 #ifdef G4VERBOSE
373  if ( fState.GetVerboseL4() )
374  fState.GetVerboseL4()->Message("create", "P2", name);
375 #endif
376  tools::histo::p2d* p2d
377  = CreateToolsP2(title, xedges, yedges, zmin, zmax,
378  xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
379 
380  // Add annotation
381  AddP2Annotation(
382  p2d, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
383 
384  // Save P2 information
386  name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
387  G4BinScheme::kUser, G4BinScheme::kUser);
388 
389  // Register profile
390  G4int id = RegisterT(p2d, name);
391 
392 #ifdef G4VERBOSE
393  if ( fState.GetVerboseL2() )
394  fState.GetVerboseL2()->Message("create", "P2", name);
395 #endif
396 
397  return id;
398 }
399 
400 //_____________________________________________________________________________
402  G4int nxbins, G4double xmin, G4double xmax,
403  G4int nybins, G4double ymin, G4double ymax,
404  G4double zmin, G4double zmax,
405  const G4String& xunitName, const G4String& yunitName,
406  const G4String& zunitName,
407  const G4String& xfcnName, const G4String& yfcnName,
408  const G4String& zfcnName,
409  const G4String& xbinSchemeName,
410  const G4String& ybinSchemeName)
411 {
412  auto p2d = GetTInFunction(id, "SetP2", false, false);
413  if ( ! p2d ) return false;
414 
415  auto info = fHnManager->GetHnInformation(id, "SetP2");
416 #ifdef G4VERBOSE
417  if ( fState.GetVerboseL4() )
418  fState.GetVerboseL4()->Message("configure", "P2", info->GetName());
419 #endif
420 
421  // Configure tools p2
422  ConfigureToolsP2(
423  p2d, nxbins, xmin, xmax, nybins, ymin, ymax, zmin, zmax,
424  xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
425  xbinSchemeName, ybinSchemeName);
426 
427  // Add annotation
428  AddP2Annotation(p2d, xunitName, yunitName, zunitName,
429  xfcnName, yfcnName, zfcnName);
430 
431  // Update information
432  auto xbinScheme = GetBinScheme(xbinSchemeName);
433  auto ybinScheme = GetBinScheme(ybinSchemeName);
434  UpdateP2Information(
435  info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
436  xbinScheme, ybinScheme);
437 
438  // Set activation
439  fHnManager->SetActivation(id, true);
440 
441  return true;
442 }
443 
444 //_____________________________________________________________________________
446  const std::vector<G4double>& xedges,
447  const std::vector<G4double>& yedges,
448  G4double zmin, G4double zmax,
449  const G4String& xunitName, const G4String& yunitName,
450  const G4String& zunitName,
451  const G4String& xfcnName, const G4String& yfcnName,
452  const G4String& zfcnName)
453 {
454  auto p2d = GetTInFunction(id, "SetP2", false, false);
455  if ( ! p2d ) return false;
456 
457  auto info = fHnManager->GetHnInformation(id, "SetP2");
458 #ifdef G4VERBOSE
459  if ( fState.GetVerboseL4() )
460  fState.GetVerboseL4()->Message("configure", "P2", info->GetName());
461 #endif
462 
463  // Configure tools p2
464  ConfigureToolsP2(p2d, xedges, yedges, zmin, zmax,
465  xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
466 
467  // Add annotation
468  AddP2Annotation(p2d, xunitName, yunitName, zunitName,
469  xfcnName, yfcnName, zfcnName);
470 
471  // Update information
472  UpdateP2Information(
473  info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
474  G4BinScheme::kUser, G4BinScheme::kUser);
475 
476  // Set activation
477  fHnManager->SetActivation(id, true);
478 
479  return true;
480 }
481 
482 //_____________________________________________________________________________
484 {
485  auto p2d = GetTInFunction(id, "ScaleP2", false, false);
486  if ( ! p2d ) return false;
487 
488  return p2d->scale(factor);
489 }
490 
491 //_____________________________________________________________________________
493  G4double xvalue, G4double yvalue, G4double zvalue,
495 {
496  auto p2d = GetTInFunction(id, "FillP2", true, false);
497  if ( ! p2d ) return false;
498 
499  if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
500  return false;
501  }
502 
503  auto xInfo
504  = fHnManager->GetHnDimensionInformation(id, kX, "FillP2");
505  auto yInfo
506  = fHnManager->GetHnDimensionInformation(id, kY, "FillP2");
507  auto zInfo
508  = fHnManager->GetHnDimensionInformation(id, kZ, "FillP2");
509 
510  p2d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
511  yInfo->fFcn(yvalue/yInfo->fUnit),
512  zInfo->fFcn(zvalue/zInfo->fUnit), weight);
513 #ifdef G4VERBOSE
514  if ( fState.GetVerboseL4() ) {
515  G4ExceptionDescription description;
516  //description << " id " << id
517  // << " xvalue " << xvalue << " yvalue " << yvalue << " zvalue " << zvalue;
518  description << " id " << id
519  << " xvalue " << xvalue
520  << " xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
521  << " yvalue " << yvalue
522  << " yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
523  << " zvalue " << zvalue
524  << " zfcn(zvalue/zunit) " << zInfo->fFcn(zvalue/zInfo->fUnit)
525  << " weight " << weight;
526  fState.GetVerboseL4()->Message("fill", "P2", description);
527  }
528 #endif
529  return true;
530 }
531 
532 //_____________________________________________________________________________
534 {
535  return GetTId(name, warn);
536 }
537 
538 //_____________________________________________________________________________
540 {
541  auto p2d = GetTInFunction(id, "GetP2NXbins");
542  if ( ! p2d ) return 0;
543 
544  return GetNbins(*p2d, kX);
545 }
546 
547 //_____________________________________________________________________________
549 {
550 // Returns xmin value with applied unit and profile function
551 
552  auto p2d = GetTInFunction(id, "GetP2Xmin");
553  if ( ! p2d ) return 0.;
554 
555  return GetMin(*p2d, kX);
556 }
557 
558 //_____________________________________________________________________________
560 {
561  auto p2d = GetTInFunction(id, "GetP2Xmax");
562  if ( ! p2d ) return 0.;
563 
564  return GetMax(*p2d, kX);
565 }
566 
567 //_____________________________________________________________________________
569 {
570  auto p2d = GetTInFunction(id, "GetP2XWidth", true, false);
571  if ( ! p2d ) return 0.;
572 
573  return GetWidth(*p2d, kX, fHnManager->GetHnType());
574 }
575 
576 //_____________________________________________________________________________
578 {
579  auto p2d = GetTInFunction(id, "GetP2NYbins");
580  if ( ! p2d ) return 0;
581 
582  return GetNbins(*p2d, kY);
583 }
584 
585 //_____________________________________________________________________________
587 {
588 // Returns xmin value with applied unit and profile function
589 
590  auto p2d = GetTInFunction(id, "GetP2Ymin");
591  if ( ! p2d ) return 0.;
592 
593  return GetMin(*p2d, kY);
594 }
595 
596 //_____________________________________________________________________________
598 {
599  auto p2d = GetTInFunction(id, "GetP2Ymax");
600  if ( ! p2d ) return 0.;
601 
602  return GetMax(*p2d, kY);
603 }
604 
605 //_____________________________________________________________________________
607 {
608  auto p2d = GetTInFunction(id, "GetP2YWidth", true, false);
609  if ( ! p2d ) return 0.;
610 
611  return GetWidth(*p2d, kY, fHnManager->GetHnType());
612 }
613 
614 //_____________________________________________________________________________
616 {
617 // Returns xmin value with applied unit and profile function
618 
619  auto p2d = GetTInFunction(id, "GetP2Zmin");
620  if ( ! p2d ) return 0.;
621 
622  return GetMin(*p2d, kZ);
623 }
624 
625 //_____________________________________________________________________________
627 {
628  auto p2d = GetTInFunction(id, "GetP2Zmax");
629  if ( ! p2d ) return 0.;
630 
631  return GetMax(*p2d, kZ);
632 }
633 
634 //_____________________________________________________________________________
636 {
637  auto p2d = GetTInFunction(id, "SetP2Title");
638  if ( ! p2d ) return false;
639 
640  return SetTitle(*p2d, title);
641 }
642 
643 //_____________________________________________________________________________
645 {
646  auto p2d = GetTInFunction(id, "SetP2XAxisTitle");
647  if ( ! p2d ) return false;
648 
649  return SetAxisTitle(*p2d, kX, title);
650 }
651 
652 //_____________________________________________________________________________
654 {
655  auto p2d = GetTInFunction(id, "SetP2YAxisTitle");
656  if ( ! p2d ) return false;
657 
658  return SetAxisTitle(*p2d, kY, title);
659 }
660 
661 //_____________________________________________________________________________
663 {
664  auto p2d = GetTInFunction(id, "SetP2ZAxisTitle");
665  if ( ! p2d ) return false;
666 
667  return SetAxisTitle(*p2d, kZ, title);
668 }
669 
670 //_____________________________________________________________________________
672 {
673  auto p2d = GetTInFunction(id, "GetP2Title");
674  if ( ! p2d ) return "";
675 
676  return GetTitle(*p2d);
677 }
678 
679 //_____________________________________________________________________________
681 {
682  auto p2d = GetTInFunction(id, "GetP2XAxisTitle");
683  if ( ! p2d ) return "";
684 
685  return GetAxisTitle(*p2d, kX, fHnManager->GetHnType());
686 }
687 
688 //_____________________________________________________________________________
690 {
691  auto p2d = GetTInFunction(id, "GetP2YAxisTitle");
692  if ( ! p2d ) return "";
693 
694  return GetAxisTitle(*p2d, kY, fHnManager->GetHnType());
695 }
696 
697 //_____________________________________________________________________________
699 {
700  auto p2d = GetTInFunction(id, "GetP2ZAxisTitle");
701  if ( ! p2d ) return "";
702 
703  return GetAxisTitle(*p2d, kZ, fHnManager->GetHnType());
704 }
705 
706 //_____________________________________________________________________________
707 G4bool G4P2ToolsManager::WriteOnAscii(std::ofstream& /*output*/)
708 {
709 // Write selected objects on ASCII file
710 // According to the implementation by Michel Maire, originally in
711 // extended examples.
712 // Not yet available for P2
713 
714  return ! fHnManager->IsAscii();
715 }
716 
717 //
718 // public methods
719 //
720 
721 //_____________________________________________________________________________
722 G4int G4P2ToolsManager::AddP2(const G4String& name, tools::histo::p2d* p2d)
723 {
724 #ifdef G4VERBOSE
725  if ( fState.GetVerboseL4() )
726  fState.GetVerboseL4()->Message("add", "P2", name);
727 #endif
728 
729  // Add annotation
730  AddP2Annotation(p2d, "none", "none", "none", "none", "none", "none");
731  // Add information
732  AddP2Information(name, "none", "none", "none", "none", "none", "none",
733  G4BinScheme::kLinear, G4BinScheme::kLinear);
734 
735  // Register profile
736  G4int id = RegisterT(p2d, name);
737 
738 #ifdef G4VERBOSE
739  if ( fState.GetVerboseL2() )
740  fState.GetVerboseL2()->Message("add", "P2", name);
741 #endif
742  return id;
743 }
744 
745 //_____________________________________________________________________________
747  const std::vector<tools::histo::p2d*>& p2Vector)
748 {
749  AddTVector(p2Vector);
750 }
751 
752 //_____________________________________________________________________________
753 tools::histo::p2d* G4P2ToolsManager::GetP2(G4int id, G4bool warn,
754  G4bool onlyIfActive) const
755 {
756  return GetTInFunction(id, "GetP2", warn, onlyIfActive);
757 }
758