Geant4  10.01.p03
G4H2ToolsManager.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: G4H2ToolsManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
29 
30 #include "G4H2ToolsManager.hh"
31 #include "G4HnManager.hh"
33 #include "G4AnalysisUtilities.hh"
34 
35 #include "tools/histo/h2d"
36 
37 #include <fstream>
38 
39 using namespace G4Analysis;
40 
41 //_____________________________________________________________________________
43  : G4VH2Manager(state),
44  fBaseToolsManager("H2"),
45  fH2Vector(),
46  fH2NameIdMap()
47 {
48 }
49 
50 //_____________________________________________________________________________
52 {
53  std::vector<tools::histo::h2d*>::iterator it;
54  for (it = fH2Vector.begin(); it != fH2Vector.end(); it++ ) {
55  delete (*it);
56  }
57 }
58 
59 //
60 // Utility functions
61 //
62 
63 namespace {
64 
65 //_____________________________________________________________________________
66 void UpdateH2Information(G4HnInformation* hnInformation,
67  const G4String& xunitName,
68  const G4String& yunitName,
69  const G4String& xfcnName,
70  const G4String& yfcnName,
71  G4BinScheme xbinScheme,
72  G4BinScheme ybinScheme)
73 {
74  G4double xunit = GetUnitValue(xunitName);
75  G4double yunit = GetUnitValue(yunitName);
76  G4Fcn xfcn = GetFunction(xfcnName);
77  G4Fcn yfcn = GetFunction(yfcnName);
78 
79  G4HnDimensionInformation* xInformation
81  xInformation->fUnitName = xunitName;
82  xInformation->fFcnName = xfcnName;
83  xInformation->fUnit = xunit;
84  xInformation->fFcn = xfcn;
85  xInformation->fBinScheme = xbinScheme;
86 
87  G4HnDimensionInformation* yInformation
89  yInformation->fUnitName = yunitName;
90  yInformation->fFcnName = yfcnName;
91  yInformation->fUnit = yunit;
92  yInformation->fFcn = yfcn;
93  yInformation->fBinScheme = ybinScheme;
94 }
95 
96 //_____________________________________________________________________________
97 void AddH2Annotation(tools::histo::h2d* h2d,
98  const G4String& xunitName,
99  const G4String& yunitName,
100  const G4String& xfcnName,
101  const G4String& yfcnName)
102 {
103  G4String xaxisTitle;
104  G4String yaxisTitle;
105  UpdateTitle(xaxisTitle, xunitName, xfcnName);
106  UpdateTitle(yaxisTitle, yunitName, yfcnName);
107  h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
108  h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
109 }
110 
111 //_____________________________________________________________________________
112 tools::histo::h2d* CreateToolsH2(
113  const G4String& title,
114  G4int nxbins, G4double xmin, G4double xmax,
115  G4int nybins, G4double ymin, G4double ymax,
116  const G4String& xunitName,
117  const G4String& yunitName,
118  const G4String& xfcnName,
119  const G4String& yfcnName,
120  const G4String& xbinSchemeName,
121  const G4String& ybinSchemeName)
122 {
123  G4double xunit = GetUnitValue(xunitName);
124  G4double yunit = GetUnitValue(yunitName);
125  G4Fcn xfcn = GetFunction(xfcnName);
126  G4Fcn yfcn = GetFunction(yfcnName);
127  G4BinScheme xbinScheme = GetBinScheme(xbinSchemeName);
128  G4BinScheme ybinScheme = GetBinScheme(ybinSchemeName);
129 
130  if ( xbinScheme != kLogBinScheme && ybinScheme != kLogBinScheme) {
131  if ( xbinScheme == kUserBinScheme || ybinScheme == kUserBinScheme) {
132  // This should never happen, but let's make sure about it
133  // by issuing a warning
134  G4ExceptionDescription description;
135  description
136  << " User binning scheme setting was ignored." << G4endl
137  << " Linear binning will be applied with given (nbins, xmin, xmax) values";
138  G4Exception("G4H2ToolsManager::CreateH2",
139  "Analysis_W013", JustWarning, description);
140  }
141  return new tools::histo::h2d(title,
142  nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
143  nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
144  // h2 objects are deleted in destructor and reset when
145  // closing a file.
146  }
147  else {
148  // Compute edges
149  std::vector<G4double> xedges;
150  ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
151  std::vector<G4double> yedges;
152  ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
153  return new tools::histo::h2d(title, xedges, yedges);
154  }
155 }
156 
157 //_____________________________________________________________________________
158 tools::histo::h2d* CreateToolsH2(
159  const G4String& title,
160  const std::vector<G4double>& xedges,
161  const std::vector<G4double>& yedges,
162  const G4String& xunitName,
163  const G4String& yunitName,
164  const G4String& xfcnName,
165  const G4String& yfcnName)
166 {
167  G4double xunit = GetUnitValue(xunitName);
168  G4double yunit = GetUnitValue(yunitName);
169  G4Fcn xfcn = GetFunction(xfcnName);
170  G4Fcn yfcn = GetFunction(yfcnName);
171 
172  // Apply function
173  std::vector<G4double> xnewEdges;
174  ComputeEdges(xedges, xunit, xfcn, xnewEdges);
175  std::vector<G4double> ynewEdges;
176  ComputeEdges(yedges, yunit, yfcn, ynewEdges);
177 
178  return new tools::histo::h2d(title, xnewEdges, ynewEdges);
179  // h2 objects are deleted in destructor and reset when
180  // closing a file.
181 }
182 
183 //_____________________________________________________________________________
184 void ConfigureToolsH2(tools::histo::h2d* h2d,
185  G4int nxbins, G4double xmin, G4double xmax,
186  G4int nybins, G4double ymin, G4double ymax,
187  const G4String& xunitName,
188  const G4String& yunitName,
189  const G4String& xfcnName,
190  const G4String& yfcnName,
191  const G4String& xbinSchemeName,
192  const G4String& ybinSchemeName)
193 {
194  G4double xunit = GetUnitValue(xunitName);
195  G4double yunit = GetUnitValue(yunitName);
196  G4Fcn xfcn = GetFunction(xfcnName);
197  G4Fcn yfcn = GetFunction(yfcnName);
198  G4BinScheme xbinScheme = GetBinScheme(xbinSchemeName);
199  G4BinScheme ybinScheme = GetBinScheme(ybinSchemeName);
200 
201  if ( xbinScheme != kLogBinScheme && ybinScheme != kLogBinScheme) {
202  if ( xbinScheme == kUserBinScheme || ybinScheme == kUserBinScheme) {
203  // This should never happen, but let's make sure about it
204  // by issuing a warning
205  G4ExceptionDescription description;
206  description
207  << " User binning scheme setting was ignored." << G4endl
208  << " Linear binning will be applied with given (nbins, xmin, xmax) values";
209  G4Exception("G4H2ToolsManager::CreateH2",
210  "Analysis_W013", JustWarning, description);
211  }
212  h2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
213  nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
214  }
215  else {
216  // Compute bins
217  std::vector<G4double> xedges;
218  ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
219  std::vector<G4double> yedges;
220  ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
221  h2d->configure(xedges, yedges);
222  }
223 }
224 
225 //_____________________________________________________________________________
226 void ConfigureToolsH2(tools::histo::h2d* h2d,
227  const std::vector<G4double>& xedges,
228  const std::vector<G4double>& yedges,
229  const G4String& xunitName,
230  const G4String& yunitName,
231  const G4String& xfcnName,
232  const G4String& yfcnName)
233 {
234  G4double xunit = GetUnitValue(xunitName);
235  G4Fcn xfcn = GetFunction(xfcnName);
236  std::vector<G4double> xnewEdges;
237  ComputeEdges(xedges, xunit, xfcn, xnewEdges);
238 
239  G4double yunit = GetUnitValue(yunitName);
240  G4Fcn yfcn = GetFunction(yfcnName);
241  std::vector<G4double> ynewEdges;
242  ComputeEdges(yedges, yunit, yfcn, ynewEdges);
243 
244  h2d->configure(xnewEdges, ynewEdges);
245 }
246 
247 }
248 
249 
250 //
251 // private methods
252 //
253 
254 //_____________________________________________________________________________
256  G4String functionName, G4bool warn,
257  G4bool onlyIfActive) const
258 {
259  G4int index = id - fFirstId;
260  if ( index < 0 || index >= G4int(fH2Vector.size()) ) {
261  if ( warn) {
262  G4String inFunction = "G4H2ToolsManager::";
263  inFunction += functionName;
264  G4ExceptionDescription description;
265  description << " " << "histogram " << id << " does not exist.";
266  G4Exception(inFunction, "Analysis_W011", JustWarning, description);
267  }
268  return 0;
269  }
270 
271  // Do not return histogram if inactive
272  if ( fState.GetIsActivation() && onlyIfActive &&
273  ( ! fHnManager->GetActivation(id) ) ) {
274  return 0;
275  }
276 
277  return fH2Vector[index];
278 }
279 
280 
281 //_____________________________________________________________________________
283  const G4String& xunitName,
284  const G4String& yunitName,
285  const G4String& xfcnName,
286  const G4String& yfcnName,
287  G4BinScheme xbinScheme,
288  G4BinScheme ybinScheme) const
289 {
290  G4double xunit = GetUnitValue(xunitName);
291  G4double yunit = GetUnitValue(yunitName);
292  G4Fcn xfcn = GetFunction(xfcnName);
293  G4Fcn yfcn = GetFunction(yfcnName);
294  fHnManager
295  ->AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName,
296  xunit, yunit, xfcn, yfcn,
297  xbinScheme, ybinScheme);
298 }
299 
300 //_____________________________________________________________________________
301 G4int G4H2ToolsManager::RegisterToolsH2(tools::histo::h2d* h2d,
302  const G4String& name)
303 {
304  G4int index = fH2Vector.size();
305  fH2Vector.push_back(h2d);
306 
307  fLockFirstId = true;
308  fH2NameIdMap[name] = index + fFirstId;
309  return index + fFirstId;
310 }
311 
312 //
313 // protected methods
314 //
315 
316 //_____________________________________________________________________________
318  G4int nxbins, G4double xmin, G4double xmax,
319  G4int nybins, G4double ymin, G4double ymax,
320  const G4String& xunitName, const G4String& yunitName,
321  const G4String& xfcnName, const G4String& yfcnName,
322  const G4String& xbinSchemeName,
323  const G4String& ybinSchemeName)
324 
325 {
326 #ifdef G4VERBOSE
327  if ( fState.GetVerboseL4() )
328  fState.GetVerboseL4()->Message("create", "H2", name);
329 #endif
330  tools::histo::h2d* h2d
331  = CreateToolsH2(title, nxbins, xmin, xmax, nybins, ymin, ymax,
332  xunitName, yunitName, xfcnName, yfcnName,
333  xbinSchemeName, ybinSchemeName);
334 
335  // Add annotation
336  AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
337 
338  // Save H2 information
339  G4BinScheme xbinScheme = GetBinScheme(xbinSchemeName);
340  G4BinScheme ybinScheme = GetBinScheme(ybinSchemeName);
342  name, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
343 
344  // Register histogram
345  G4int id = RegisterToolsH2(h2d, name);
346 
347 #ifdef G4VERBOSE
348  if ( fState.GetVerboseL2() )
349  fState.GetVerboseL2()->Message("create", "H2", name);
350 #endif
351 
352  return id;
353 }
354 
355 //_____________________________________________________________________________
357  const std::vector<G4double>& xedges,
358  const std::vector<G4double>& yedges,
359  const G4String& xunitName, const G4String& yunitName,
360  const G4String& xfcnName, const G4String& yfcnName)
361 
362 {
363 #ifdef G4VERBOSE
364  if ( fState.GetVerboseL4() )
365  fState.GetVerboseL4()->Message("create", "H2", name);
366 #endif
367  tools::histo::h2d* h2d
368  = CreateToolsH2(title, xedges, yedges,
369  xunitName, yunitName, xfcnName, yfcnName);
370 
371  // Add annotation
372  AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
373 
374  // Save H2 information
376  name, xunitName, yunitName, xfcnName, yfcnName, kUserBinScheme, kUserBinScheme);
377 
378  // Register histogram
379  G4int id = RegisterToolsH2(h2d, name);
380 
381 #ifdef G4VERBOSE
382  if ( fState.GetVerboseL2() )
383  fState.GetVerboseL2()->Message("create", "H2", name);
384 #endif
385 
386  return id;
387 }
388 
389 //_____________________________________________________________________________
391  G4int nxbins, G4double xmin, G4double xmax,
392  G4int nybins, G4double ymin, G4double ymax,
393  const G4String& xunitName, const G4String& yunitName,
394  const G4String& xfcnName, const G4String& yfcnName,
395  const G4String& xbinSchemeName,
396  const G4String& ybinSchemeName)
397 {
398  tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2", false, false);
399  if ( ! h2d ) return false;
400 
401  G4HnInformation* info = fHnManager->GetHnInformation(id, "SetH2");
402 #ifdef G4VERBOSE
403  if ( fState.GetVerboseL4() )
404  fState.GetVerboseL4()->Message("configure", "H2", info->GetName());
405 #endif
406 
407  // Configure tools h2
408  ConfigureToolsH2(
409  h2d, nxbins, xmin, xmax, nybins, ymin, ymax,
410  xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName, ybinSchemeName);
411 
412  // Add annotation
413  AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
414 
415  // Update information
416  G4BinScheme xbinScheme = GetBinScheme(xbinSchemeName);
417  G4BinScheme ybinScheme = GetBinScheme(ybinSchemeName);
418  UpdateH2Information(
419  info, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
420 
421  // Set activation
422  fHnManager->SetActivation(id, true);
423 
424  return true;
425 }
426 
427 //_____________________________________________________________________________
429  const std::vector<G4double>& xedges,
430  const std::vector<G4double>& yedges,
431  const G4String& xunitName, const G4String& yunitName,
432  const G4String& xfcnName, const G4String& yfcnName)
433 {
434  tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2", false, false);
435  if ( ! h2d ) return false;
436 
437  G4HnInformation* info = fHnManager->GetHnInformation(id, "SetH2");
438 #ifdef G4VERBOSE
439  if ( fState.GetVerboseL4() )
440  fState.GetVerboseL4()->Message("configure", "H2", info->GetName());
441 #endif
442 
443  // Configure tools h2
444  ConfigureToolsH2(h2d, xedges, yedges, xunitName, yunitName, xfcnName, yfcnName);
445 
446  // Add annotation
447  AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
448 
449  // Update information
450  UpdateH2Information(
451  info, xunitName, yunitName, xfcnName, yfcnName, kUserBinScheme, kUserBinScheme);
452 
453  // Set activation
454  fHnManager->SetActivation(id, true);
455 
456  return true;
457 }
458 
459 //_____________________________________________________________________________
461 {
462  tools::histo::h2d* h2d = GetH2InFunction(id, "ScaleH2", false, false);
463  if ( ! h2d ) return false;
464 
465  return h2d->scale(factor);
466 }
467 
468 //_____________________________________________________________________________
470  G4double xvalue, G4double yvalue,
471  G4double weight)
472 {
473  tools::histo::h2d* h2d = GetH2InFunction(id, "FillH2", true, false);
474  if ( ! h2d ) return false;
475 
476  if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
477  return false;
478  }
479 
484 
485  h2d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
486  yInfo->fFcn(yvalue/yInfo->fUnit), weight);
487 #ifdef G4VERBOSE
488  if ( fState.GetVerboseL4() ) {
489  G4ExceptionDescription description;
490  description << " id " << id
491  << " xvalue " << xvalue
492  << " xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
493  << " yvalue " << yvalue
494  << " yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
495  << " weight " << weight;
496  fState.GetVerboseL4()->Message("fill", "H2", description);
497  }
498 #endif
499  return true;
500 }
501 
502 //_____________________________________________________________________________
504 {
505  std::map<G4String, G4int>::const_iterator it = fH2NameIdMap.find(name);
506  if ( it == fH2NameIdMap.end() ) {
507  if ( warn) {
508  G4String inFunction = "G4H2ToolsManager::GetH2Id";
509  G4ExceptionDescription description;
510  description << " " << "histogram " << name << " does not exist.";
511  G4Exception(inFunction, "Analysis_W011", JustWarning, description);
512  }
513  return kInvalidId;
514  }
515  return it->second;
516 }
517 
518 //_____________________________________________________________________________
520 {
521  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2NXbins");
522  if ( ! h2d ) return 0;
523 
525 }
526 
527 //_____________________________________________________________________________
529 {
530 // Returns xmin value with applied unit and histogram function
531 
532  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Xmin");
533  if ( ! h2d ) return 0;
534 
536 }
537 
538 //_____________________________________________________________________________
540 {
541  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Xmax");
542  if ( ! h2d ) return 0;
543 
545 }
546 
547 //_____________________________________________________________________________
549 {
550  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2XWidth", true, false);
551  if ( ! h2d ) return 0;
552 
554 }
555 
556 //_____________________________________________________________________________
558 {
559  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2NYbins");
560  if ( ! h2d ) return 0;
561 
563 }
564 
565 //_____________________________________________________________________________
567 {
568 // Returns xmin value with applied unit and histogram function
569 
570  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Ymin");
571  if ( ! h2d ) return 0;
572 
574 }
575 
576 //_____________________________________________________________________________
578 {
579  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Ymax");
580  if ( ! h2d ) return 0;
581 
583 }
584 
585 //_____________________________________________________________________________
587 {
588  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2YWidth", true, false);
589  if ( ! h2d ) return 0;
590 
592 }
593 
594 //_____________________________________________________________________________
596 {
597  tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2Title");
598  if ( ! h2d ) return false;
599 
600  return fBaseToolsManager.SetTitle(*h2d, title);
601 }
602 
603 //_____________________________________________________________________________
605 {
606  tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2XAxisTitle");
607  if ( ! h2d ) return false;
608 
610 }
611 
612 //_____________________________________________________________________________
614 {
615  tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2YAxisTitle");
616  if ( ! h2d ) return false;
617 
619 }
620 
621 //_____________________________________________________________________________
623 {
624  tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2ZAxisTitle");
625  if ( ! h2d ) return false;
626 
628 }
629 
630 //_____________________________________________________________________________
632 {
633  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Title");
634  if ( ! h2d ) return "";
635 
636  return fBaseToolsManager.GetTitle(*h2d);
637 }
638 
639 //_____________________________________________________________________________
641 {
642  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2XAxisTitle");
643  if ( ! h2d ) return "";
644 
646 }
647 
648 //_____________________________________________________________________________
650 {
651  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2YAxisTitle");
652  if ( ! h2d ) return "";
653 
655 }
656 
657 //_____________________________________________________________________________
659 {
660  tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2ZAxisTitle");
661  if ( ! h2d ) return "";
662 
664 }
665 
666 //_____________________________________________________________________________
667 G4bool G4H2ToolsManager::WriteOnAscii(std::ofstream& /*output*/)
668 {
669 // Write selected objects on ASCII file
670 // According to the implementation by Michel Maire, originally in
671 // extended examples.
672 // Not yet available for H2
673 
674  return ! fHnManager->IsAscii();
675 }
676 
677 //
678 // public methods
679 //
680 
681 //_____________________________________________________________________________
682 G4int G4H2ToolsManager::AddH2(const G4String& name, tools::histo::h2d* h2d)
683 {
684 #ifdef G4VERBOSE
685  if ( fState.GetVerboseL4() )
686  fState.GetVerboseL4()->Message("add", "H2", name);
687 #endif
688 
689  // Add annotation
690  AddH2Annotation(h2d, "none", "none", "none", "none");
691  // Add information
692  AddH2Information(name, "none", "none", "none", "none",
694 
695  // Register histogram
696  G4int id = RegisterToolsH2(h2d, name);
697 
698 #ifdef G4VERBOSE
699  if ( fState.GetVerboseL2() )
700  fState.GetVerboseL2()->Message("add", "H2", name);
701 #endif
702  return id;
703 }
704 
705 //_____________________________________________________________________________
707  const std::vector<tools::histo::h2d*>& h2Vector)
708 {
709 #ifdef G4VERBOSE
710  if ( fState.GetVerboseL4() )
711  fState.GetVerboseL4()->Message("merge", "all h2", "");
712 #endif
713  std::vector<tools::histo::h2d*>::const_iterator itw = h2Vector.begin();
714  std::vector<tools::histo::h2d*>::iterator it;
715  for (it = fH2Vector.begin(); it != fH2Vector.end(); it++ ) {
716  (*it)->add(*(*itw++));
717  }
718 #ifdef G4VERBOSE
719  if ( fState.GetVerboseL1() )
720  fState.GetVerboseL1()->Message("merge", "all h2", "");
721 #endif
722 }
723 
724 //_____________________________________________________________________________
726 {
727 // Reset histograms and ntuple
728 
729  G4bool finalResult = true;
730 
731  std::vector<tools::histo::h2d*>::iterator it;
732  for (it = fH2Vector.begin(); it != fH2Vector.end(); it++ ) {
733  G4bool result = (*it)->reset();
734  if ( ! result ) finalResult = false;
735  }
736 
737  return finalResult;
738 }
739 
740 //_____________________________________________________________________________
742 {
743  return ! fH2Vector.size();
744 }
745 
746 //_____________________________________________________________________________
747 tools::histo::h2d* G4H2ToolsManager::GetH2(G4int id, G4bool warn,
748  G4bool onlyIfActive) const
749 {
750  return GetH2InFunction(id, "GetH2", warn, onlyIfActive);
751 }
752 
virtual G4int GetH2Nybins(G4int id) const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
G4bool IsAscii() const
Definition: G4HnManager.cc:162
G4HnManager * fHnManager
virtual G4String GetH2YAxisTitle(G4int id) const
virtual G4bool SetH2YAxisTitle(G4int id, const G4String &title)
virtual G4String GetH2XAxisTitle(G4int id) const
G4bool SetTitle(G4ToolsBaseHisto &baseHisto, const G4String &title)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String GetTitle(const G4ToolsBaseHisto &baseHisto) const
void ComputeEdges(G4int nbins, G4double xmin, G4double xmax, G4double unit, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
Definition: G4BinScheme.cc:56
void AddH2Information(const G4String &name, const G4String &xunitName, const G4String &yunitName, const G4String &xfcnName, const G4String &yfcnName, G4BinScheme xbinScheme, G4BinScheme ybinScheme) const
virtual ~G4H2ToolsManager()
virtual G4double GetH2Ymax(G4int id) const
static const G4int kY
G4String name
Definition: TRTMaterials.hh:40
G4double(* G4Fcn)(G4double)
Definition: G4Fcn.hh:36
G4bool IsEmpty() const
virtual G4double GetH2Xmin(G4int id) const
virtual tools::histo::h2d * GetH2InFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4int GetH2Nxbins(G4int id) const
virtual G4bool SetH2ZAxisTitle(G4int id, const G4String &title)
static const G4int kZ
int G4int
Definition: G4Types.hh:78
G4int RegisterToolsH2(tools::histo::h2d *h2d, const G4String &name)
virtual G4String GetH2Title(G4int id) const
G4String GetAxisTitle(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
G4HnInformation * GetHnInformation(G4int id, G4String functionName="", G4bool warn=true) const
Definition: G4HnManager.cc:123
G4bool GetActivation(G4int id) const
Definition: G4HnManager.cc:270
const G4AnalysisVerbose * GetVerboseL2() const
void UpdateTitle(G4String &title, const G4String &unitName, const G4String &fcnName)
std::vector< tools::histo::h2d * > fH2Vector
void AddH2Vector(const std::vector< tools::histo::h2d * > &h2Vector)
virtual G4double GetH2YWidth(G4int id) const
virtual G4bool WriteOnAscii(std::ofstream &output)
G4int GetNbins(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
const G4AnalysisVerbose * GetVerboseL4() const
bool G4bool
Definition: G4Types.hh:79
virtual G4bool SetH2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear")
G4BaseToolsManager fBaseToolsManager
G4double GetWidth(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
virtual G4bool SetH2XAxisTitle(G4int id, const G4String &title)
G4double GetUnitValue(const G4String &unit)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
tools::histo::h2d * GetH2(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4String GetH2ZAxisTitle(G4int id) const
static const G4double factor
G4Fcn GetFunction(const G4String &fcnName)
Definition: G4Fcn.cc:36
virtual G4double GetH2Ymin(G4int id) const
virtual G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear")
G4int AddH2(const G4String &name, tools::histo::h2d *h2d)
virtual G4double GetH2Xmax(G4int id) const
virtual G4double GetH2XWidth(G4int id) const
G4double GetMax(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
G4HnDimensionInformation * GetHnDimensionInformation(G4int dimension)
G4BinScheme GetBinScheme(const G4String &binSchemeName)
Definition: G4BinScheme.cc:36
virtual G4int GetH2Id(const G4String &name, G4bool warn=true) const
#define G4endl
Definition: G4ios.hh:61
G4String GetName() const
G4BinScheme
Definition: G4BinScheme.hh:40
void AddH2Information(const G4String &name, const G4String &xunitName, const G4String &yunitName, const G4String &xfcnName, const G4String &yfcnName, G4double xunit, G4double yunit, G4Fcn fx, G4Fcn fy, G4BinScheme xBinScheme, G4BinScheme yBinScheme)
Definition: G4HnManager.cc:73
std::map< G4String, G4int > fH2NameIdMap
double G4double
Definition: G4Types.hh:76
G4double GetMin(const G4ToolsBaseHisto &baseHisto, G4int dimension) const
virtual G4bool FillH2(G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0)
virtual G4bool SetH2Title(G4int id, const G4String &title)
const G4int kInvalidId
virtual G4bool ScaleH2(G4int id, G4double factor)
const G4AnalysisVerbose * GetVerboseL1() const
void SetActivation(G4bool activation)
Definition: G4HnManager.cc:188
const G4AnalysisManagerState & fState
G4H2ToolsManager(const G4AnalysisManagerState &state)
G4bool SetAxisTitle(G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &title)
static const G4int kX
G4HnDimensionInformation * GetHnDimensionInformation(G4int id, G4int dimension, G4String functionName="", G4bool warn=true) const
Definition: G4HnManager.cc:145