35 #include "tools/histo/h2d"
52 std::vector<tools::histo::h2d*>::iterator it;
81 information->
fXUnit = xunit;
82 information->
fYUnit = yunit;
83 information->
fXFcn = xfcn;
84 information->
fYFcn = yfcn;
90 void AddH2Annotation(tools::histo::h2d* h2d,
100 h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
101 h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
105 tools::histo::h2d* CreateToolsH2(
129 <<
" User binning scheme setting was ignored." <<
G4endl
130 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
134 return new tools::histo::h2d(title,
135 nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
136 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
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 return new tools::histo::h2d(title, xedges, yedges);
151 tools::histo::h2d* CreateToolsH2(
153 const std::vector<G4double>& xedges,
154 const std::vector<G4double>& yedges,
166 std::vector<G4double> xnewEdges;
168 std::vector<G4double> ynewEdges;
171 return new tools::histo::h2d(title, xnewEdges, ynewEdges);
177 void ConfigureToolsH2(tools::histo::h2d* h2d,
200 <<
" User binning scheme setting was ignored." <<
G4endl
201 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
205 h2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
206 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
210 std::vector<G4double> xedges;
211 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
212 std::vector<G4double> yedges;
213 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
214 h2d->configure(xedges, yedges);
219 void ConfigureToolsH2(tools::histo::h2d* h2d,
220 const std::vector<G4double>& xedges,
221 const std::vector<G4double>& yedges,
229 std::vector<G4double> xnewEdges;
234 std::vector<G4double> ynewEdges;
237 h2d->configure(xnewEdges, ynewEdges);
250 G4bool onlyIfActive)
const
255 G4String inFunction =
"G4H2ToolsManager::";
256 inFunction += functionName;
258 description <<
" " <<
"histogram " <<
id <<
" does not exist.";
289 xunit, yunit, xfcn, yfcn,
290 xbinScheme, ybinScheme);
323 tools::histo::h2d* h2d
324 = CreateToolsH2(title, nxbins, xmin, xmax, nybins, ymin, ymax,
325 xunitName, yunitName, xfcnName, yfcnName,
326 xbinSchemeName, ybinSchemeName);
329 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
335 name, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
350 const std::vector<G4double>& xedges,
351 const std::vector<G4double>& yedges,
360 tools::histo::h2d* h2d
361 = CreateToolsH2(title, xedges, yedges,
362 xunitName, yunitName, xfcnName, yfcnName);
365 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
392 if ( ! h2d )
return false;
402 h2d, nxbins, xmin, xmax, nybins, ymin, ymax,
403 xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName, ybinSchemeName);
406 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
412 info, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
422 const std::vector<G4double>& xedges,
423 const std::vector<G4double>& yedges,
428 if ( ! h2d )
return false;
437 ConfigureToolsH2(h2d, xedges, yedges, xunitName, yunitName, xfcnName, yfcnName);
440 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
456 if ( ! h2d )
return false;
458 return h2d->scale(factor);
467 if ( ! h2d )
return false;
479 description <<
" id " <<
id
480 <<
" xvalue " << xvalue <<
" yvalue " << yvalue;
490 std::map<G4String, G4int>::const_iterator it =
fH2NameIdMap.find(name);
493 G4String inFunction =
"G4H2ToolsManager::GetH2Id";
495 description <<
" " <<
"histogram " << name <<
" does not exist.";
507 if ( ! h2d )
return 0;
509 return h2d->axis_x().bins();
518 if ( ! h2d )
return 0;
520 return h2d->axis_x().lower_edge();
527 if ( ! h2d )
return 0;
529 return h2d->axis_x().upper_edge();
535 tools::histo::h2d* h2d =
GetH2InFunction(
id,
"GetH2XWidth",
true,
false);
536 if ( ! h2d )
return 0;
538 G4int nbins = h2d->axis_x().bins();
541 description <<
" nbins = 0 (for h2 id = " <<
id <<
").";
547 return ( h2d->axis_x().upper_edge() - h2d->axis_x().lower_edge())/nbins;
554 if ( ! h2d )
return 0;
556 return h2d->axis_y().bins();
565 if ( ! h2d )
return 0;
567 return h2d->axis_y().lower_edge();
574 if ( ! h2d )
return 0;
576 return h2d->axis_y().upper_edge();
582 tools::histo::h2d* h2d =
GetH2InFunction(
id,
"GetH2YWidth",
true,
false);
583 if ( ! h2d )
return 0;
585 G4int nbins = h2d->axis_y().bins();
588 description <<
" nbins = 0 (for h2 id = " <<
id <<
").";
594 return ( h2d->axis_y().upper_edge() - h2d->axis_y().lower_edge())/nbins;
601 if ( ! h2d )
return false;
603 return h2d->set_title(title);
610 if ( ! h2d )
return false;
612 h2d->add_annotation(tools::histo::key_axis_x_title(), title);
620 if ( ! h2d )
return false;
622 h2d->add_annotation(tools::histo::key_axis_y_title(), title);
630 if ( ! h2d )
return false;
632 h2d->add_annotation(tools::histo::key_axis_z_title(), title);
640 if ( ! h2d )
return "";
649 if ( ! h2d )
return "";
652 G4bool result = h2d->annotation(tools::histo::key_axis_x_title(), title);
655 description <<
" Failed to get x_axis title for h2 id = " <<
id <<
").";
668 if ( ! h2d )
return "";
671 G4bool result = h2d->annotation(tools::histo::key_axis_y_title(), title);
674 description <<
" Failed to get y_axis title for h2 id = " <<
id <<
").";
687 if ( ! h2d )
return "";
690 G4bool result = h2d->annotation(tools::histo::key_axis_z_title(), title);
693 description <<
" Failed to get z_axis title for h2 id = " <<
id <<
").";
719 const std::vector<tools::histo::h2d*>& h2Vector)
725 std::vector<tools::histo::h2d*>::const_iterator itw = h2Vector.begin();
726 std::vector<tools::histo::h2d*>::iterator it;
728 (*it)->add(*(*itw++));
741 G4bool finalResult =
true;
743 std::vector<tools::histo::h2d*>::iterator it;
745 G4bool result = (*it)->reset();
746 if ( ! result ) finalResult =
false;
760 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)
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