35 #include "tools/histo/h2d"
44 fBaseToolsManager(
"H2"),
53 std::vector<tools::histo::h2d*>::iterator it;
83 xInformation->
fUnit = xunit;
84 xInformation->
fFcn = xfcn;
91 yInformation->
fUnit = yunit;
92 yInformation->
fFcn = yfcn;
97 void AddH2Annotation(tools::histo::h2d* h2d,
107 h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
108 h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
112 tools::histo::h2d* CreateToolsH2(
136 <<
" User binning scheme setting was ignored." <<
G4endl
137 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
141 return new tools::histo::h2d(title,
142 nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
143 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
149 std::vector<G4double> xedges;
150 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
151 std::vector<G4double> yedges;
152 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
153 return new tools::histo::h2d(title, xedges, yedges);
158 tools::histo::h2d* CreateToolsH2(
160 const std::vector<G4double>& xedges,
161 const std::vector<G4double>& yedges,
173 std::vector<G4double> xnewEdges;
175 std::vector<G4double> ynewEdges;
178 return new tools::histo::h2d(title, xnewEdges, ynewEdges);
184 void ConfigureToolsH2(tools::histo::h2d* h2d,
207 <<
" User binning scheme setting was ignored." <<
G4endl
208 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
212 h2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
213 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
217 std::vector<G4double> xedges;
218 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
219 std::vector<G4double> yedges;
220 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
221 h2d->configure(xedges, yedges);
226 void ConfigureToolsH2(tools::histo::h2d* h2d,
227 const std::vector<G4double>& xedges,
228 const std::vector<G4double>& yedges,
236 std::vector<G4double> xnewEdges;
241 std::vector<G4double> ynewEdges;
244 h2d->configure(xnewEdges, ynewEdges);
257 G4bool onlyIfActive)
const
262 G4String inFunction =
"G4H2ToolsManager::";
263 inFunction += functionName;
265 description <<
" " <<
"histogram " <<
id <<
" does not exist.";
296 xunit, yunit, xfcn, yfcn,
297 xbinScheme, ybinScheme);
330 tools::histo::h2d* h2d
331 = CreateToolsH2(title, nxbins, xmin, xmax, nybins, ymin, ymax,
332 xunitName, yunitName, xfcnName, yfcnName,
333 xbinSchemeName, ybinSchemeName);
336 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
342 name, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
357 const std::vector<G4double>& xedges,
358 const std::vector<G4double>& yedges,
367 tools::histo::h2d* h2d
368 = CreateToolsH2(title, xedges, yedges,
369 xunitName, yunitName, xfcnName, yfcnName);
372 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
399 if ( ! h2d )
return false;
409 h2d, nxbins, xmin, xmax, nybins, ymin, ymax,
410 xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName, ybinSchemeName);
413 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
419 info, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
429 const std::vector<G4double>& xedges,
430 const std::vector<G4double>& yedges,
435 if ( ! h2d )
return false;
444 ConfigureToolsH2(h2d, xedges, yedges, xunitName, yunitName, xfcnName, yfcnName);
447 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
463 if ( ! h2d )
return false;
465 return h2d->scale(factor);
474 if ( ! h2d )
return false;
485 h2d->fill(xInfo->
fFcn(xvalue/xInfo->
fUnit),
486 yInfo->
fFcn(yvalue/yInfo->
fUnit), weight);
490 description <<
" id " <<
id
491 <<
" xvalue " << xvalue
492 <<
" xfcn(xvalue/xunit) " << xInfo->
fFcn(xvalue/xInfo->
fUnit)
493 <<
" yvalue " << yvalue
494 <<
" yfcn(yvalue/yunit) " << yInfo->
fFcn(yvalue/yInfo->
fUnit)
495 <<
" weight " << weight;
505 std::map<G4String, G4int>::const_iterator it =
fH2NameIdMap.find(name);
508 G4String inFunction =
"G4H2ToolsManager::GetH2Id";
510 description <<
" " <<
"histogram " << name <<
" does not exist.";
522 if ( ! h2d )
return 0;
533 if ( ! h2d )
return 0;
542 if ( ! h2d )
return 0;
550 tools::histo::h2d* h2d =
GetH2InFunction(
id,
"GetH2XWidth",
true,
false);
551 if ( ! h2d )
return 0;
560 if ( ! h2d )
return 0;
571 if ( ! h2d )
return 0;
580 if ( ! h2d )
return 0;
588 tools::histo::h2d* h2d =
GetH2InFunction(
id,
"GetH2YWidth",
true,
false);
589 if ( ! h2d )
return 0;
598 if ( ! h2d )
return false;
607 if ( ! h2d )
return false;
616 if ( ! h2d )
return false;
625 if ( ! h2d )
return false;
634 if ( ! h2d )
return "";
643 if ( ! h2d )
return "";
652 if ( ! h2d )
return "";
661 if ( ! h2d )
return "";
690 AddH2Annotation(h2d,
"none",
"none",
"none",
"none");
707 const std::vector<tools::histo::h2d*>& h2Vector)
713 std::vector<tools::histo::h2d*>::const_iterator itw = h2Vector.begin();
714 std::vector<tools::histo::h2d*>::iterator it;
716 (*it)->add(*(*itw++));
729 G4bool finalResult =
true;
731 std::vector<tools::histo::h2d*>::iterator it;
733 G4bool result = (*it)->reset();
734 if ( ! result ) finalResult =
false;
748 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)
static const G4double factor
G4Fcn GetFunction(const G4String &fcnName)
G4BinScheme GetBinScheme(const G4String &binSchemeName)
void AddH2Information(const G4String &name, const G4String &xunitName, const G4String &yunitName, const G4String &xfcnName, const G4String &yfcnName, G4double xunit, G4double yunit, G4Fcn fx, G4Fcn fy, G4BinScheme xBinScheme, G4BinScheme yBinScheme)
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