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,
113 <<
" User binning scheme setting was ignored." <<
G4endl
114 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
118 return new tools::histo::h1d(title, nbins, fcn(xmin), fcn(xmax));
122 std::vector<G4double> edges;
124 return new tools::histo::h1d(title, edges);
129 tools::histo::h1d* CreateToolsH1(
const G4String& title,
130 const std::vector<G4double>& edges,
136 std::vector<G4double> newEdges;
139 return new tools::histo::h1d(title, newEdges);
143 void ConfigureToolsH1(tools::histo::h1d* h1d,
157 <<
" User binning scheme setting was ignored." <<
G4endl
158 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
162 h1d->configure(nbins, fcn(xmin), fcn(xmax));
166 std::vector<G4double> edges;
168 h1d->configure(edges);
173 void ConfigureToolsH1(tools::histo::h1d* h1d,
174 const std::vector<G4double>& edges,
179 std::vector<G4double> newEdges;
182 h1d->configure(newEdges);
194 G4bool onlyIfActive)
const
199 G4String inFunction =
"G4H1ToolsManager::";
200 inFunction += functionName;
202 description <<
" " <<
"histogram " <<
id <<
" does not exist.";
253 tools::histo::h1d* h1d
254 = CreateToolsH1(title, nbins, xmin, xmax, fcnName, binSchemeName);
257 AddH1Annotation(h1d, unitName, fcnName);
275 const std::vector<G4double>& edges,
282 tools::histo::h1d* h1d
283 = CreateToolsH1(title, edges, fcnName);
286 AddH1Annotation(h1d, unitName, fcnName);
308 if ( ! h1d )
return false;
317 ConfigureToolsH1(h1d, nbins, xmin, xmax, fcnName, binSchemeName);
320 AddH1Annotation(h1d, unitName, fcnName);
324 UpdateH1Information(info, unitName, fcnName, binScheme);
334 const std::vector<G4double>& edges,
339 if ( ! h1d )
return false;
348 ConfigureToolsH1(h1d, edges, fcnName);
351 AddH1Annotation(h1d, unitName, fcnName);
367 if ( ! h1d )
return false;
369 return h1d->scale(factor);
376 if ( ! h1d )
return false;
384 h1d->fill(info->
fXFcn(value/info->
fXUnit), weight);
388 description <<
" id " <<
id <<
" value " << value;
398 std::map<G4String, G4int>::const_iterator it =
fH1NameIdMap.find(name);
401 G4String inFunction =
"G4H1ToolsManager::GetH1Id";
403 description <<
" " <<
"histogram " << name <<
" does not exist.";
415 if ( ! h1d )
return 0;
417 return h1d->axis().bins();
426 if ( ! h1d )
return 0;
429 return info->
fXFcn(h1d->axis().lower_edge()*info->
fXUnit);
436 if ( ! h1d )
return 0;
439 return info->
fXFcn(h1d->axis().upper_edge()*info->
fXUnit);
445 tools::histo::h1d* h1d =
GetH1InFunction(
id,
"GetH1XWidth",
true,
false);
446 if ( ! h1d )
return 0;
448 G4int nbins = h1d->axis().bins();
451 description <<
" nbins = 0 (for h1 id = " <<
id <<
").";
458 return ( info->
fXFcn(h1d->axis().upper_edge())
459 - info->
fXFcn(h1d->axis().lower_edge()))*info->
fXUnit/nbins;
466 if ( ! h1d )
return false;
468 return h1d->set_title(title);
475 if ( ! h1d )
return false;
477 h1d->add_annotation(tools::histo::key_axis_x_title(), title);
485 if ( ! h1d )
return false;
487 h1d->add_annotation(tools::histo::key_axis_y_title(), title);
495 if ( ! h1d )
return "";
505 if ( ! h1d )
return "";
508 G4bool result = h1d->annotation(tools::histo::key_axis_x_title(), title);
511 description <<
" Failed to get x_axis title for h1 id = " <<
id <<
").";
524 if ( ! h1d )
return "";
527 G4bool result = h1d->annotation(tools::histo::key_axis_y_title(), title);
530 description <<
" Failed to get y_axis title for h1 id = " <<
id <<
").";
551 if ( ! info->
fAscii )
continue;
559 output <<
"\n 1D histogram " <<
id <<
": " << h1->title()
560 <<
"\n \n \t X \t\t Y" <<
G4endl;
562 for (
G4int j=0; j<
G4int(h1->axis().bins()); ++j) {
563 output <<
" " << j <<
"\t"
564 << h1->axis().bin_center(j) <<
"\t"
565 << h1->bin_height(j) <<
G4endl;
578 const std::vector<tools::histo::h1d*>& h1Vector)
584 std::vector<tools::histo::h1d*>::const_iterator itw = h1Vector.begin();
585 std::vector<tools::histo::h1d*>::iterator it;
587 (*it)->add(*(*itw++));
600 G4bool finalResult =
true;
602 std::vector<tools::histo::h1d*>::iterator it;
604 G4bool result = (*it)->reset();
605 if ( ! result ) finalResult =
false;
619 G4bool onlyIfActive)
const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
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)
void ComputeEdges(G4int nbins, G4double xmin, G4double xmax, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
G4bool GetIsActivation() const
const G4AnalysisVerbose * GetVerboseL1() const
void SetActivation(G4bool activation)
const G4AnalysisManagerState & fState