34#include "tools/histo/p2d"
41const G4int G4P2ToolsManager::kDimension = 2;
76void AddP2Annotation(tools::histo::p2d* p2d,
90 p2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
91 p2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
92 p2d->add_annotation(tools::histo::key_axis_z_title(), zaxisTitle);
96tools::histo::p2d* CreateToolsP2(
125 <<
" User binning scheme setting was ignored." <<
G4endl
126 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
130 if ( zmin == 0. && zmax == 0.) {
131 return new tools::histo::p2d(title,
132 nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
133 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
137 return new tools::histo::p2d(title,
138 nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
139 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
140 zfcn(zmin/zunit), zfcn(zmax/zunit));
147 std::vector<G4double> xedges;
148 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
149 std::vector<G4double> yedges;
150 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
151 if ( zmin == 0. && zmax == 0.) {
152 return new tools::histo::p2d(title, xedges, yedges);
154 return new tools::histo::p2d(title, xedges, yedges,
155 zfcn(zmin/zunit), zfcn(zmax/zunit));
161tools::histo::p2d* CreateToolsP2(
163 const std::vector<G4double>& xedges,
164 const std::vector<G4double>& yedges,
181 std::vector<G4double> xnewEdges;
183 std::vector<G4double> ynewEdges;
186 if ( zmin == 0. && zmax == 0.) {
187 return new tools::histo::p2d(title, xnewEdges, ynewEdges);
191 return new tools::histo::p2d(title, xnewEdges, ynewEdges,
192 zfcn(zmin/zunit), zfcn(zmax/zunit));
199void ConfigureToolsP2(tools::histo::p2d* p2d,
227 <<
" User binning scheme setting was ignored." <<
G4endl
228 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
232 if ( zmin == 0. && zmax == 0. ) {
233 p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
234 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
236 p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
237 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
238 zfcn(zmin/zunit), zfcn(zmax/zunit));
243 std::vector<G4double> xedges;
244 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
245 std::vector<G4double> yedges;
246 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
247 if ( zmin == 0. && zmax == 0. ) {
248 p2d->configure(xedges, yedges);
250 p2d->configure(xedges, yedges, zfcn(zmin/zunit), zfcn(zmax/zunit));
256void ConfigureToolsP2(tools::histo::p2d* p2d,
257 const std::vector<G4double>& xedges,
258 const std::vector<G4double>& yedges,
270 std::vector<G4double> xnewEdges;
275 std::vector<G4double> ynewEdges;
280 if ( zmin == 0. && zmax == 0. ) {
281 p2d->configure(xnewEdges, ynewEdges);
283 p2d->configure(xnewEdges, ynewEdges, zfcn(zmin/zunit), zfcn(zmax/zunit));
295void G4P2ToolsManager::AddP2Information(
const G4String& name,
305 auto hnInformation =
fHnManager->AddHnInformation(name, 3);
306 hnInformation->
AddDimension(xunitName, xfcnName, xbinScheme);
307 hnInformation->
AddDimension(yunitName, yfcnName, ybinScheme);
308 hnInformation->
AddDimension(zunitName, zfcnName, G4BinScheme::kLinear);
332 tools::histo::p2d* p2d
333 = CreateToolsP2(title,
334 nxbins, xmin, xmax, nybins, ymin, ymax, zmin, zmax,
335 xunitName, yunitName, zunitName,
336 xfcnName, yfcnName, zfcnName,
337 xbinSchemeName, ybinSchemeName);
340 AddP2Annotation(p2d, xunitName, yunitName, zunitName,
341 xfcnName, yfcnName, zfcnName);
347 name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
348 xbinScheme, ybinScheme);
363 const std::vector<G4double>& xedges,
364 const std::vector<G4double>& yedges,
376 tools::histo::p2d* p2d
377 = CreateToolsP2(title, xedges, yedges, zmin, zmax,
378 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
382 p2d, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
386 name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
387 G4BinScheme::kUser, G4BinScheme::kUser);
413 if ( ! p2d )
return false;
415 auto info =
fHnManager->GetHnInformation(
id,
"SetP2");
423 p2d, nxbins, xmin, xmax, nybins, ymin, ymax, zmin, zmax,
424 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
425 xbinSchemeName, ybinSchemeName);
428 AddP2Annotation(p2d, xunitName, yunitName, zunitName,
429 xfcnName, yfcnName, zfcnName);
435 info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
436 xbinScheme, ybinScheme);
446 const std::vector<G4double>& xedges,
447 const std::vector<G4double>& yedges,
455 if ( ! p2d )
return false;
457 auto info =
fHnManager->GetHnInformation(
id,
"SetP2");
464 ConfigureToolsP2(p2d, xedges, yedges, zmin, zmax,
465 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
468 AddP2Annotation(p2d, xunitName, yunitName, zunitName,
469 xfcnName, yfcnName, zfcnName);
473 info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
474 G4BinScheme::kUser, G4BinScheme::kUser);
486 if ( ! p2d )
return false;
488 return p2d->scale(factor);
497 if ( ! p2d )
return false;
504 =
fHnManager->GetHnDimensionInformation(
id,
kX,
"FillP2");
506 =
fHnManager->GetHnDimensionInformation(
id,
kY,
"FillP2");
508 =
fHnManager->GetHnDimensionInformation(
id,
kZ,
"FillP2");
510 p2d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
511 yInfo->fFcn(yvalue/yInfo->fUnit),
512 zInfo->fFcn(zvalue/zInfo->fUnit), weight);
518 description <<
" id " <<
id
519 <<
" xvalue " << xvalue
520 <<
" xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
521 <<
" yvalue " << yvalue
522 <<
" yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
523 <<
" zvalue " << zvalue
524 <<
" zfcn(zvalue/zunit) " << zInfo->fFcn(zvalue/zInfo->fUnit)
525 <<
" weight " << weight;
535 return GetTId(name, warn);
542 if ( ! p2d )
return 0;
553 if ( ! p2d )
return 0.;
562 if ( ! p2d )
return 0.;
571 if ( ! p2d )
return 0.;
580 if ( ! p2d )
return 0;
591 if ( ! p2d )
return 0.;
600 if ( ! p2d )
return 0.;
609 if ( ! p2d )
return 0.;
620 if ( ! p2d )
return 0.;
629 if ( ! p2d )
return 0.;
638 if ( ! p2d )
return false;
647 if ( ! p2d )
return false;
656 if ( ! p2d )
return false;
665 if ( ! p2d )
return false;
674 if ( ! p2d )
return "";
683 if ( ! p2d )
return "";
692 if ( ! p2d )
return "";
701 if ( ! p2d )
return "";
730 AddP2Annotation(p2d,
"none",
"none",
"none",
"none",
"none",
"none");
732 AddP2Information(name,
"none",
"none",
"none",
"none",
"none",
"none",
733 G4BinScheme::kLinear, G4BinScheme::kLinear);
747 const std::vector<tools::histo::p2d*>& p2Vector)
754 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::p2d * > &tVector)
G4int RegisterT(tools::histo::p2d *t, const G4String &name)
std::shared_ptr< G4HnManager > fHnManager
tools::histo::p2d * 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)