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