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