35 #include "tools/histo/h3d"
44 fBaseToolsManager(
"H3"),
53 std::vector<tools::histo::h3d*>::iterator it;
88 xInformation->
fUnit = xunit;
89 xInformation->
fFcn = xfcn;
96 yInformation->
fUnit = yunit;
97 yInformation->
fFcn = yfcn;
104 zInformation->
fUnit = zunit;
105 zInformation->
fFcn = zfcn;
110 void AddH3Annotation(tools::histo::h3d* h3d,
124 h3d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
125 h3d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
126 h3d->add_annotation(tools::histo::key_axis_z_title(), zaxisTitle);
130 tools::histo::h3d* CreateToolsH3(
161 <<
" User binning scheme setting was ignored." <<
G4endl
162 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
166 return new tools::histo::h3d(title,
167 nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
168 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
169 nzbins, zfcn(zmin/zunit), zfcn(zmax/zunit));
175 std::vector<G4double> xedges;
176 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
177 std::vector<G4double> yedges;
178 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
179 std::vector<G4double> zedges;
180 ComputeEdges(nzbins, zmin, zmax, zunit, zfcn, zbinScheme, zedges);
181 return new tools::histo::h3d(title, xedges, yedges, zedges);
186 tools::histo::h3d* CreateToolsH3(
188 const std::vector<G4double>& xedges,
189 const std::vector<G4double>& yedges,
190 const std::vector<G4double>& zedges,
206 std::vector<G4double> xnewEdges;
208 std::vector<G4double> ynewEdges;
210 std::vector<G4double> znewEdges;
213 return new tools::histo::h3d(title, xnewEdges, ynewEdges, znewEdges);
219 void ConfigureToolsH3(tools::histo::h3d* h3d,
249 <<
" User binning scheme setting was ignored." <<
G4endl
250 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
254 h3d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
255 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
256 nzbins, zfcn(zmin/zunit), zfcn(zmax/zunit));
260 std::vector<G4double> xedges;
261 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
262 std::vector<G4double> yedges;
263 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
264 std::vector<G4double> zedges;
265 ComputeEdges(nzbins, zmin, zmax, zunit, zfcn, zbinScheme, zedges);
266 h3d->configure(xedges, yedges, zedges);
271 void ConfigureToolsH3(tools::histo::h3d* h3d,
272 const std::vector<G4double>& xedges,
273 const std::vector<G4double>& yedges,
274 const std::vector<G4double>& zedges,
284 std::vector<G4double> xnewEdges;
289 std::vector<G4double> ynewEdges;
294 std::vector<G4double> znewEdges;
297 h3d->configure(xnewEdges, ynewEdges, znewEdges);
310 G4bool onlyIfActive)
const
315 G4String inFunction =
"G4H3ToolsManager::";
316 inFunction += functionName;
318 description <<
" " <<
"histogram " <<
id <<
" does not exist.";
354 xfcnName, yfcnName, zfcnName,
355 xunit, yunit, zunit, xfcn, yfcn, zfcn,
356 xbinScheme, ybinScheme, zbinScheme);
393 tools::histo::h3d* h3d
394 = CreateToolsH3(title,
395 nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax,
396 xunitName, yunitName, zunitName,
397 xfcnName, yfcnName, zfcnName,
398 xbinSchemeName, ybinSchemeName, zbinSchemeName);
401 AddH3Annotation(h3d, xunitName, yunitName, zunitName,
402 xfcnName, yfcnName, zfcnName);
409 name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
410 xbinScheme, ybinScheme, zbinScheme);
425 const std::vector<G4double>& xedges,
426 const std::vector<G4double>& yedges,
427 const std::vector<G4double>& zedges,
438 tools::histo::h3d* h3d
439 = CreateToolsH3(title, xedges, yedges, zedges,
440 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
443 AddH3Annotation(h3d, xunitName, yunitName, zunitName,
444 xfcnName, yfcnName, zfcnName);
448 name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
476 if ( ! h3d )
return false;
486 h3d, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax,
487 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
488 xbinSchemeName, ybinSchemeName, zbinSchemeName);
491 AddH3Annotation(h3d, xunitName, yunitName, zunitName,
492 xfcnName, yfcnName, zfcnName);
499 info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
500 xbinScheme, ybinScheme, zbinScheme);
510 const std::vector<G4double>& xedges,
511 const std::vector<G4double>& yedges,
512 const std::vector<G4double>& zedges,
519 if ( ! h3d )
return false;
528 ConfigureToolsH3(h3d, xedges, yedges, zedges,
529 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
532 AddH3Annotation(h3d, xunitName, yunitName, zunitName,
533 xfcnName, yfcnName, zfcnName);
537 info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
550 if ( ! h3d )
return false;
552 return h3d->scale(factor);
561 if ( ! h3d )
return false;
574 h3d->fill(xInfo->
fFcn(xvalue/xInfo->
fUnit),
576 zInfo->
fFcn(zvalue/zInfo->
fUnit), weight);
580 description <<
" id " <<
id
581 <<
" xvalue " << xvalue
582 <<
" xfcn(xvalue/xunit) " << xInfo->
fFcn(xvalue/xInfo->
fUnit)
583 <<
" yvalue " << yvalue
584 <<
" yfcn(yvalue/yunit) " << yInfo->
fFcn(yvalue/yInfo->
fUnit)
585 <<
" zvalue " << zvalue
586 <<
" zfcn(zvalue/zunit) " << zInfo->
fFcn(zvalue/zInfo->
fUnit)
587 <<
" weight " << weight;
597 std::map<G4String, G4int>::const_iterator it =
fH3NameIdMap.find(name);
600 G4String inFunction =
"G4H3ToolsManager::GetH3Id";
602 description <<
" " <<
"histogram " << name <<
" does not exist.";
614 if ( ! h3d )
return 0;
625 if ( ! h3d )
return 0;
634 if ( ! h3d )
return 0;
642 tools::histo::h3d* h3d =
GetH3InFunction(
id,
"GetH3XWidth",
true,
false);
643 if ( ! h3d )
return 0;
652 if ( ! h3d )
return 0;
663 if ( ! h3d )
return 0;
672 if ( ! h3d )
return 0;
680 tools::histo::h3d* h3d =
GetH3InFunction(
id,
"GetH3YWidth",
true,
false);
681 if ( ! h3d )
return 0;
690 if ( ! h3d )
return 0;
701 if ( ! h3d )
return 0;
710 if ( ! h3d )
return 0;
718 tools::histo::h3d* h3d =
GetH3InFunction(
id,
"GetH3ZWidth",
true,
false);
719 if ( ! h3d )
return 0;
728 if ( ! h3d )
return false;
737 if ( ! h3d )
return false;
746 if ( ! h3d )
return false;
755 if ( ! h3d )
return false;
764 if ( ! h3d )
return "";
773 if ( ! h3d )
return "";
782 if ( ! h3d )
return "";
791 if ( ! h3d )
return "";
820 AddH3Annotation(h3d,
"none",
"none",
"none",
"none",
"none",
"none");
837 const std::vector<tools::histo::h3d*>& h3Vector)
843 std::vector<tools::histo::h3d*>::const_iterator itw = h3Vector.begin();
844 std::vector<tools::histo::h3d*>::iterator it;
846 (*it)->add(*(*itw++));
859 G4bool finalResult =
true;
861 std::vector<tools::histo::h3d*>::iterator it;
863 G4bool result = (*it)->reset();
864 if ( ! result ) finalResult =
false;
878 G4bool onlyIfActive)
const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
void ComputeEdges(G4int nbins, G4double xmin, G4double xmax, G4double unit, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
G4double(* G4Fcn)(G4double)
G4HnInformation * GetHnInformation(G4int id, G4String functionName="", G4bool warn=true) const
G4bool GetActivation(G4int id) const
const G4AnalysisVerbose * GetVerboseL2() const
void UpdateTitle(G4String &title, const G4String &unitName, const G4String &fcnName)
const G4AnalysisVerbose * GetVerboseL4() const
G4double GetUnitValue(const G4String &unit)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void AddH3Information(const G4String &name, const G4String &xunitName, const G4String &yunitName, const G4String &zunitName, const G4String &xfcnName, const G4String &yfcnName, const G4String &zfcnName, G4double xunit, G4double yunit, G4double zunit, G4Fcn fx, G4Fcn fy, G4Fcn fz, G4BinScheme xBinScheme, G4BinScheme yBinScheme, G4BinScheme zBinScheme)
static const G4double factor
G4Fcn GetFunction(const G4String &fcnName)
G4BinScheme GetBinScheme(const G4String &binSchemeName)
G4bool GetIsActivation() const
const G4AnalysisVerbose * GetVerboseL1() const
void SetActivation(G4bool activation)
const G4AnalysisManagerState & fState
G4HnDimensionInformation * GetHnDimensionInformation(G4int id, G4int dimension, G4String functionName="", G4bool warn=true) const