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;
503 return info->
fXFcn(h2d->axis_x().lower_edge()*info->
fXUnit);
510 if ( ! h2d )
return 0;
513 return info->
fXFcn(h2d->axis_x().upper_edge()*info->
fXUnit);
519 tools::histo::h2d* h2d =
GetH2InFunction(
id,
"GetH2XWidth",
true,
false);
520 if ( ! h2d )
return 0;
522 G4int nbins = h2d->axis_x().bins();
525 description <<
" nbins = 0 (for h2 id = " <<
id <<
").";
532 return ( info->
fXFcn(h2d->axis_x().upper_edge())
533 - info->
fXFcn(h2d->axis_x().lower_edge()))*info->
fXUnit/nbins;
540 if ( ! h2d )
return 0;
542 return h2d->axis_y().bins();
551 if ( ! h2d )
return 0;
554 return info->
fYFcn(h2d->axis_y().lower_edge()*info->
fYUnit);
561 if ( ! h2d )
return 0;
564 return info->
fYFcn(h2d->axis_y().upper_edge()*info->
fYUnit);
570 tools::histo::h2d* h2d =
GetH2InFunction(
id,
"GetH2YWidth",
true,
false);
571 if ( ! h2d )
return 0;
573 G4int nbins = h2d->axis_y().bins();
576 description <<
" nbins = 0 (for h2 id = " <<
id <<
").";
583 return ( info->
fYFcn(h2d->axis_y().upper_edge())
584 - info->
fYFcn(h2d->axis_y().lower_edge()))*info->
fYUnit/nbins;
591 if ( ! h2d )
return false;
593 return h2d->set_title(title);
600 if ( ! h2d )
return false;
602 h2d->add_annotation(tools::histo::key_axis_x_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_z_title(), title);
630 if ( ! h2d )
return "";
639 if ( ! h2d )
return "";
642 G4bool result = h2d->annotation(tools::histo::key_axis_x_title(), title);
645 description <<
" Failed to get x_axis title for h2 id = " <<
id <<
").";
658 if ( ! h2d )
return "";
661 G4bool result = h2d->annotation(tools::histo::key_axis_y_title(), title);
664 description <<
" Failed to get y_axis title for h2 id = " <<
id <<
").";
677 if ( ! h2d )
return "";
680 G4bool result = h2d->annotation(tools::histo::key_axis_z_title(), title);
683 description <<
" Failed to get z_axis title for h2 id = " <<
id <<
").";
709 const std::vector<tools::histo::h2d*>& h2Vector)
715 std::vector<tools::histo::h2d*>::const_iterator itw = h2Vector.begin();
716 std::vector<tools::histo::h2d*>::iterator it;
718 (*it)->add(*(*itw++));
731 G4bool finalResult =
true;
733 std::vector<tools::histo::h2d*>::iterator it;
735 G4bool result = (*it)->reset();
736 if ( ! result ) finalResult =
false;
750 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