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