34#include "tools/histo/h3d"
41const G4int G4H3ToolsManager::kDimension = 3;
77void AddH3Annotation(tools::histo::h3d* h3d,
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);
97tools::histo::h3d* CreateToolsH3(
128 <<
" User binning scheme setting was ignored." <<
G4endl
129 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
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));
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);
153tools::histo::h3d* CreateToolsH3(
155 const std::vector<G4double>& xedges,
156 const std::vector<G4double>& yedges,
157 const std::vector<G4double>& zedges,
173 std::vector<G4double> xnewEdges;
175 std::vector<G4double> ynewEdges;
177 std::vector<G4double> znewEdges;
180 return new tools::histo::h3d(title, xnewEdges, ynewEdges, znewEdges);
186void ConfigureToolsH3(tools::histo::h3d* h3d,
216 <<
" User binning scheme setting was ignored." <<
G4endl
217 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
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));
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);
238void ConfigureToolsH3(tools::histo::h3d* h3d,
239 const std::vector<G4double>& xedges,
240 const std::vector<G4double>& yedges,
241 const std::vector<G4double>& zedges,
251 std::vector<G4double> xnewEdges;
256 std::vector<G4double> ynewEdges;
261 std::vector<G4double> znewEdges;
264 h3d->configure(xnewEdges, ynewEdges, znewEdges);
275void G4H3ToolsManager::AddH3Information(
const G4String& name,
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);
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);
322 AddH3Annotation(h3d, xunitName, yunitName, zunitName,
323 xfcnName, yfcnName, zfcnName);
330 name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
331 xbinScheme, ybinScheme, zbinScheme);
346 const std::vector<G4double>& xedges,
347 const std::vector<G4double>& yedges,
348 const std::vector<G4double>& zedges,
359 tools::histo::h3d* h3d
360 = CreateToolsH3(title, xedges, yedges, zedges,
361 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
364 AddH3Annotation(h3d, xunitName, yunitName, zunitName,
365 xfcnName, yfcnName, zfcnName);
369 name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
370 G4BinScheme::kUser, G4BinScheme::kUser, G4BinScheme::kUser);
397 if ( ! h3d )
return false;
399 auto info =
fHnManager->GetHnInformation(
id,
"SetH3");
407 h3d, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax,
408 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
409 xbinSchemeName, ybinSchemeName, zbinSchemeName);
412 AddH3Annotation(h3d, xunitName, yunitName, zunitName,
413 xfcnName, yfcnName, zfcnName);
420 info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
421 xbinScheme, ybinScheme, zbinScheme);
431 const std::vector<G4double>& xedges,
432 const std::vector<G4double>& yedges,
433 const std::vector<G4double>& zedges,
440 if ( ! h3d )
return false;
442 auto info =
fHnManager->GetHnInformation(
id,
"SetH3");
449 ConfigureToolsH3(h3d, xedges, yedges, zedges,
450 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
453 AddH3Annotation(h3d, xunitName, yunitName, zunitName,
454 xfcnName, yfcnName, zfcnName);
458 info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
459 G4BinScheme::kUser, G4BinScheme::kUser, G4BinScheme::kUser);
471 if ( ! h3d )
return false;
473 return h3d->scale(factor);
482 if ( ! h3d )
return false;
489 =
fHnManager->GetHnDimensionInformation(
id,
kX,
"FillH3");
491 =
fHnManager->GetHnDimensionInformation(
id,
kY,
"FillH3");
493 =
fHnManager->GetHnDimensionInformation(
id,
kZ,
"FillH3");
495 h3d->fill(xInfo->
fFcn(xvalue/xInfo->
fUnit),
497 zInfo->
fFcn(zvalue/zInfo->
fUnit), weight);
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;
518 return GetTId(name, warn);
525 if ( ! h3d )
return 0;
536 if ( ! h3d )
return 0.;
545 if ( ! h3d )
return 0.;
554 if ( ! h3d )
return 0.;
563 if ( ! h3d )
return 0;
574 if ( ! h3d )
return 0.;
583 if ( ! h3d )
return 0.;
592 if ( ! h3d )
return 0.;
601 if ( ! h3d )
return 0;
612 if ( ! h3d )
return 0.;
621 if ( ! h3d )
return 0.;
630 if ( ! h3d )
return 0.;
639 if ( ! h3d )
return false;
648 if ( ! h3d )
return false;
657 if ( ! h3d )
return false;
666 if ( ! h3d )
return false;
675 if ( ! h3d )
return "";
684 if ( ! h3d )
return "";
693 if ( ! h3d )
return "";
702 if ( ! h3d )
return "";
731 AddH3Annotation(h3d,
"none",
"none",
"none",
"none",
"none",
"none");
733 AddH3Information(name,
"none",
"none",
"none",
"none",
"none",
"none",
734 G4BinScheme::kLinear, G4BinScheme::kLinear, G4BinScheme::kLinear);
748 const std::vector<tools::histo::h3d*>& h3Vector)
755 G4bool onlyIfActive)
const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
const G4AnalysisVerbose * GetVerboseL2() const
G4bool GetIsActivation() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState
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
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)
G4bool SetTitle(G4ToolsBaseHisto &baseHisto, const G4String &title)
G4double GetMin(const G4ToolsBaseHisto &baseHisto, G4int dimension)
G4double GetMax(const G4ToolsBaseHisto &baseHisto, G4int dimension)
G4double GetUnitValue(const G4String &unit)
void ComputeEdges(G4int nbins, G4double xmin, G4double xmax, G4double unit, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
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)