34#include "tools/histo/h2d"
41const G4int G4H2ToolsManager::kDimension = 2;
73void AddH2Annotation(tools::histo::h2d* h2d,
83 h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
84 h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
88tools::histo::h2d* CreateToolsH2(
112 <<
" User binning scheme setting was ignored." <<
G4endl
113 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
117 return new tools::histo::h2d(title,
118 nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
119 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
125 std::vector<G4double> xedges;
126 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
127 std::vector<G4double> yedges;
128 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
129 return new tools::histo::h2d(title, xedges, yedges);
134tools::histo::h2d* CreateToolsH2(
136 const std::vector<G4double>& xedges,
137 const std::vector<G4double>& yedges,
149 std::vector<G4double> xnewEdges;
151 std::vector<G4double> ynewEdges;
154 return new tools::histo::h2d(title, xnewEdges, ynewEdges);
160void ConfigureToolsH2(tools::histo::h2d* h2d,
183 <<
" User binning scheme setting was ignored." <<
G4endl
184 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
188 h2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
189 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
193 std::vector<G4double> xedges;
194 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
195 std::vector<G4double> yedges;
196 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
197 h2d->configure(xedges, yedges);
202void ConfigureToolsH2(tools::histo::h2d* h2d,
203 const std::vector<G4double>& xedges,
204 const std::vector<G4double>& yedges,
212 std::vector<G4double> xnewEdges;
217 std::vector<G4double> ynewEdges;
220 h2d->configure(xnewEdges, ynewEdges);
231void G4H2ToolsManager::AddH2Information(
const G4String& name,
239 auto hnInformation =
fHnManager->AddHnInformation(name, 2);
240 hnInformation->
AddDimension(xunitName, xfcnName, xbinScheme);
241 hnInformation->
AddDimension(yunitName, yfcnName, ybinScheme);
262 tools::histo::h2d* h2d
263 = CreateToolsH2(title, nxbins, xmin, xmax, nybins, ymin, ymax,
264 xunitName, yunitName, xfcnName, yfcnName,
265 xbinSchemeName, ybinSchemeName);
268 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
274 name, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
289 const std::vector<G4double>& xedges,
290 const std::vector<G4double>& yedges,
299 tools::histo::h2d* h2d
300 = CreateToolsH2(title, xedges, yedges,
301 xunitName, yunitName, xfcnName, yfcnName);
304 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
308 name, xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser, G4BinScheme::kUser);
331 if ( ! h2d )
return false;
333 auto info =
fHnManager->GetHnInformation(
id,
"SetH2");
341 h2d, nxbins, xmin, xmax, nybins, ymin, ymax,
342 xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName, ybinSchemeName);
345 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
351 info, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
361 const std::vector<G4double>& xedges,
362 const std::vector<G4double>& yedges,
367 if ( ! h2d )
return false;
369 auto info =
fHnManager->GetHnInformation(
id,
"SetH2");
376 ConfigureToolsH2(h2d, xedges, yedges, xunitName, yunitName, xfcnName, yfcnName);
379 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
383 info, xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser, G4BinScheme::kUser);
395 if ( ! h2d )
return false;
397 return h2d->scale(factor);
406 if ( ! h2d )
return false;
413 =
fHnManager->GetHnDimensionInformation(
id,
kX,
"FillH2");
415 =
fHnManager->GetHnDimensionInformation(
id,
kY,
"FillH2");
417 h2d->fill(xInfo->
fFcn(xvalue/xInfo->
fUnit),
418 yInfo->
fFcn(yvalue/yInfo->
fUnit), weight);
422 description <<
" id " <<
id
423 <<
" xvalue " << xvalue
424 <<
" xfcn(xvalue/xunit) " << xInfo->
fFcn(xvalue/xInfo->
fUnit)
425 <<
" yvalue " << yvalue
426 <<
" yfcn(yvalue/yunit) " << yInfo->
fFcn(yvalue/yInfo->
fUnit)
427 <<
" weight " << weight;
437 return GetTId(name, warn);
444 if ( ! h2d )
return 0;
455 if ( ! h2d )
return 0.;
464 if ( ! h2d )
return 0.;
473 if ( ! h2d )
return 0.;
482 if ( ! h2d )
return 0;
493 if ( ! h2d )
return 0.;
502 if ( ! h2d )
return 0.;
511 if ( ! h2d )
return 0.;
520 if ( ! h2d )
return false;
529 if ( ! h2d )
return false;
538 if ( ! h2d )
return false;
547 if ( ! h2d )
return false;
556 if ( ! h2d )
return "";
565 if ( ! h2d )
return "";
574 if ( ! h2d )
return "";
583 if ( ! h2d )
return "";
612 AddH2Annotation(h2d,
"none",
"none",
"none",
"none");
614 AddH2Information(name,
"none",
"none",
"none",
"none",
615 G4BinScheme::kLinear, G4BinScheme::kLinear);
629 const std::vector<tools::histo::h2d*>& h2Vector)
635 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::h2d * > &tVector)
G4int RegisterT(tools::histo::h2d *t, const G4String &name)
std::shared_ptr< G4HnManager > fHnManager
tools::histo::h2d * 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)