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(
125 <<
" User binning scheme setting was ignored." <<
G4endl
126 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
130 return new tools::histo::h2d(title,
131 nxbins, xfcn(xmin), xfcn(xmax),
132 nybins, yfcn(ymin), yfcn(ymax));
138 std::vector<G4double> xedges;
139 ComputeEdges(nxbins, xmin, xmax, xfcn, xbinScheme, xedges);
140 std::vector<G4double> yedges;
141 ComputeEdges(nybins, ymin, ymax, yfcn, ybinScheme, yedges);
142 return new tools::histo::h2d(title, xedges, yedges);
147 tools::histo::h2d* CreateToolsH2(
149 const std::vector<G4double>& xedges,
150 const std::vector<G4double>& yedges,
158 std::vector<G4double> xnewEdges;
160 std::vector<G4double> ynewEdges;
163 return new tools::histo::h2d(title, xnewEdges, ynewEdges);
169 void ConfigureToolsH2(tools::histo::h2d* h2d,
188 <<
" User binning scheme setting was ignored." <<
G4endl
189 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
193 h2d->configure(nxbins, xfcn(xmin), xfcn(xmax),
194 nybins, yfcn(ymin), yfcn(ymax));
198 std::vector<G4double> xedges;
199 ComputeEdges(nxbins, xmin, xmax, xfcn, xbinScheme, xedges);
200 std::vector<G4double> yedges;
201 ComputeEdges(nybins, ymin, ymax, yfcn, ybinScheme, yedges);
202 h2d->configure(xedges, yedges);
207 void ConfigureToolsH2(tools::histo::h2d* h2d,
208 const std::vector<G4double>& xedges,
209 const std::vector<G4double>& yedges,
214 std::vector<G4double> xnewEdges;
218 std::vector<G4double> ynewEdges;
221 h2d->configure(xnewEdges, ynewEdges);
234 G4bool onlyIfActive)
const
239 G4String inFunction =
"G4H2ToolsManager::";
240 inFunction += functionName;
242 description <<
" " <<
"histogram " <<
id <<
" does not exist.";
273 xunit, yunit, xfcn, yfcn,
274 xbinScheme, ybinScheme);
307 tools::histo::h2d* h2d
308 = CreateToolsH2(title, nxbins, xmin, xmax, nybins, ymin, ymax,
309 xfcnName, yfcnName, xbinSchemeName, ybinSchemeName);
312 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
318 name, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
333 const std::vector<G4double>& xedges,
334 const std::vector<G4double>& yedges,
343 tools::histo::h2d* h2d
344 = CreateToolsH2(title, xedges, yedges, xfcnName, yfcnName);
347 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
374 if ( ! h2d )
return false;
384 h2d, nxbins, xmin, xmax, nybins, ymin, ymax, xfcnName, yfcnName,
385 xbinSchemeName, xbinSchemeName);
388 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
394 info, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
404 const std::vector<G4double>& xedges,
405 const std::vector<G4double>& yedges,
410 if ( ! h2d )
return false;
419 ConfigureToolsH2(h2d, xedges, yedges, xfcnName, yfcnName);
422 AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
438 if ( ! h2d )
return false;
440 return h2d->scale(factor);
449 if ( ! h2d )
return false;
461 description <<
" id " <<
id
462 <<
" xvalue " << xvalue <<
" yvalue " << yvalue;
472 std::map<G4String, G4int>::const_iterator it =
fH2NameIdMap.find(name);
475 G4String inFunction =
"G4H2ToolsManager::GetH2Id";
477 description <<
" " <<
"histogram " << name <<
" does not exist.";
489 if ( ! h2d )
return 0;
491 return h2d->axis_x().bins();
500 if ( ! h2d )
return 0;
502 return h2d->axis_x().lower_edge();
509 if ( ! h2d )
return 0;
511 return h2d->axis_x().upper_edge();
517 tools::histo::h2d* h2d =
GetH2InFunction(
id,
"GetH2XWidth",
true,
false);
518 if ( ! h2d )
return 0;
520 G4int nbins = h2d->axis_x().bins();
523 description <<
" nbins = 0 (for h2 id = " <<
id <<
").";
529 return ( h2d->axis_x().upper_edge() - h2d->axis_x().lower_edge())/nbins;
536 if ( ! h2d )
return 0;
538 return h2d->axis_y().bins();
547 if ( ! h2d )
return 0;
549 return h2d->axis_y().lower_edge();
556 if ( ! h2d )
return 0;
558 return h2d->axis_y().upper_edge();
564 tools::histo::h2d* h2d =
GetH2InFunction(
id,
"GetH2YWidth",
true,
false);
565 if ( ! h2d )
return 0;
567 G4int nbins = h2d->axis_y().bins();
570 description <<
" nbins = 0 (for h2 id = " <<
id <<
").";
576 return ( h2d->axis_y().upper_edge() - h2d->axis_y().lower_edge())/nbins;
583 if ( ! h2d )
return false;
585 return h2d->set_title(title);
592 if ( ! h2d )
return false;
594 h2d->add_annotation(tools::histo::key_axis_x_title(), title);
602 if ( ! h2d )
return false;
604 h2d->add_annotation(tools::histo::key_axis_y_title(), title);
612 if ( ! h2d )
return false;
614 h2d->add_annotation(tools::histo::key_axis_z_title(), title);
622 if ( ! h2d )
return "";
631 if ( ! h2d )
return "";
634 G4bool result = h2d->annotation(tools::histo::key_axis_x_title(), title);
637 description <<
" Failed to get x_axis title for h2 id = " <<
id <<
").";
650 if ( ! h2d )
return "";
653 G4bool result = h2d->annotation(tools::histo::key_axis_y_title(), title);
656 description <<
" Failed to get y_axis title for h2 id = " <<
id <<
").";
669 if ( ! h2d )
return "";
672 G4bool result = h2d->annotation(tools::histo::key_axis_z_title(), title);
675 description <<
" Failed to get z_axis title for h2 id = " <<
id <<
").";
701 const std::vector<tools::histo::h2d*>& h2Vector)
707 std::vector<tools::histo::h2d*>::const_iterator itw = h2Vector.begin();
708 std::vector<tools::histo::h2d*>::iterator it;
710 (*it)->add(*(*itw++));
723 G4bool finalResult =
true;
725 std::vector<tools::histo::h2d*>::iterator it;
727 G4bool result = (*it)->reset();
728 if ( ! result ) finalResult =
false;
742 G4bool onlyIfActive)
const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
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 ComputeEdges(G4int nbins, G4double xmin, G4double xmax, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
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