35 #include "tools/histo/h1d"
56 std::vector<tools::histo::h1d*>::iterator it;
80 information->
fXUnit = unit;
81 information->
fYUnit = unit;
82 information->
fXFcn = fcn;
83 information->
fYFcn = fcn;
89 void AddH1Annotation(tools::histo::h1d* h1d,
95 h1d->add_annotation(tools::histo::key_axis_x_title(), axisTitle);
99 tools::histo::h1d* CreateToolsH1(
const G4String& title,
115 <<
" User binning scheme setting was ignored." <<
G4endl
116 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
120 return new tools::histo::h1d(title, nbins, fcn(xmin/unit), fcn(xmax/unit));
124 std::vector<G4double> edges;
125 ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
126 return new tools::histo::h1d(title, edges);
131 tools::histo::h1d* CreateToolsH1(
const G4String& title,
132 const std::vector<G4double>& edges,
140 std::vector<G4double> newEdges;
143 return new tools::histo::h1d(title, newEdges);
147 void ConfigureToolsH1(tools::histo::h1d* h1d,
163 <<
" User binning scheme setting was ignored." <<
G4endl
164 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
168 h1d->configure(nbins, fcn(xmin/unit), fcn(xmax/unit));
172 std::vector<G4double> edges;
173 ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
174 h1d->configure(edges);
179 void ConfigureToolsH1(tools::histo::h1d* h1d,
180 const std::vector<G4double>& edges,
187 std::vector<G4double> newEdges;
190 h1d->configure(newEdges);
202 G4bool onlyIfActive)
const
207 G4String inFunction =
"G4H1ToolsManager::";
208 inFunction += functionName;
210 description <<
" " <<
"histogram " <<
id <<
" does not exist.";
261 tools::histo::h1d* h1d
262 = CreateToolsH1(title, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
265 AddH1Annotation(h1d, unitName, fcnName);
283 const std::vector<G4double>& edges,
290 tools::histo::h1d* h1d
291 = CreateToolsH1(title, edges, unitName, fcnName);
294 AddH1Annotation(h1d, unitName, fcnName);
316 if ( ! h1d )
return false;
325 ConfigureToolsH1(h1d, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
328 AddH1Annotation(h1d, unitName, fcnName);
332 UpdateH1Information(info, unitName, fcnName, binScheme);
342 const std::vector<G4double>& edges,
347 if ( ! h1d )
return false;
356 ConfigureToolsH1(h1d, edges, unitName, fcnName);
359 AddH1Annotation(h1d, unitName, fcnName);
375 if ( ! h1d )
return false;
377 return h1d->scale(factor);
384 if ( ! h1d )
return false;
392 h1d->fill(info->
fXFcn(value/info->
fXUnit), weight);
396 description <<
" id " <<
id <<
" value " << value;
406 std::map<G4String, G4int>::const_iterator it =
fH1NameIdMap.find(name);
409 G4String inFunction =
"G4H1ToolsManager::GetH1Id";
411 description <<
" " <<
"histogram " << name <<
" does not exist.";
423 if ( ! h1d )
return 0;
425 return h1d->axis().bins();
434 if ( ! h1d )
return 0;
436 return h1d->axis().lower_edge();
443 if ( ! h1d )
return 0;
445 return h1d->axis().upper_edge();
451 tools::histo::h1d* h1d =
GetH1InFunction(
id,
"GetH1XWidth",
true,
false);
452 if ( ! h1d )
return 0;
454 G4int nbins = h1d->axis().bins();
457 description <<
" nbins = 0 (for h1 id = " <<
id <<
").";
463 return ( h1d->axis().upper_edge() - h1d->axis().lower_edge())/nbins;
470 if ( ! h1d )
return false;
472 return h1d->set_title(title);
479 if ( ! h1d )
return false;
481 h1d->add_annotation(tools::histo::key_axis_x_title(), title);
489 if ( ! h1d )
return false;
491 h1d->add_annotation(tools::histo::key_axis_y_title(), title);
499 if ( ! h1d )
return "";
509 if ( ! h1d )
return "";
512 G4bool result = h1d->annotation(tools::histo::key_axis_x_title(), title);
515 description <<
" Failed to get x_axis title for h1 id = " <<
id <<
").";
528 if ( ! h1d )
return "";
531 G4bool result = h1d->annotation(tools::histo::key_axis_y_title(), title);
534 description <<
" Failed to get y_axis title for h1 id = " <<
id <<
").";
555 if ( ! info->
fAscii )
continue;
563 output <<
"\n 1D histogram " <<
id <<
": " << h1->title()
564 <<
"\n \n \t X \t\t Y" <<
G4endl;
566 for (
G4int j=0; j<
G4int(h1->axis().bins()); ++j) {
567 output <<
" " << j <<
"\t"
568 << h1->axis().bin_center(j) <<
"\t"
569 << h1->bin_height(j) <<
G4endl;
582 const std::vector<tools::histo::h1d*>& h1Vector)
588 std::vector<tools::histo::h1d*>::const_iterator itw = h1Vector.begin();
589 std::vector<tools::histo::h1d*>::iterator it;
591 (*it)->add(*(*itw++));
604 G4bool finalResult =
true;
606 std::vector<tools::histo::h1d*>::iterator it;
608 G4bool result = (*it)->reset();
609 if ( ! result ) finalResult =
false;
623 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)
void AddH1Information(const G4String &name, const G4String &unitName, const G4String &fcnName, G4double unit, G4Fcn fx, G4BinScheme binScheme)
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 * GetVerboseL3() const
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)
G4bool GetIsActivation() const
const G4AnalysisVerbose * GetVerboseL1() const
void SetActivation(G4bool activation)
const G4AnalysisManagerState & fState