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