35 #include "tools/histo/h1d"
39 using namespace G4Analysis;
56 std::vector<tools::histo::h1d*>::iterator it;
57 for (it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
80 information->
fXUnit = unit;
81 information->
fYUnit = unit;
82 information->
fXFcn = fcn;
83 information->
fYFcn = fcn;
95 h1d->add_annotation(tools::histo::key_axis_x_title(), axisTitle);
113 <<
" User binning scheme setting was ignored." <<
G4endl
114 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
122 std::vector<G4double> edges;
130 const std::vector<G4double>& edges,
136 std::vector<G4double> newEdges;
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);
174 const std::vector<G4double>& edges,
179 std::vector<G4double> newEdges;
182 h1d->configure(newEdges);
194 G4bool onlyIfActive)
const
197 if ( index < 0 || index >=
G4int(fH1Vector.size()) ) {
199 G4String inFunction =
"G4H1ToolsManager::";
200 inFunction += functionName;
202 description <<
" " <<
"histogram " <<
id <<
" does not exist.";
213 return fH1Vector[
index];
217 void G4H1ToolsManager::AddH1Information(
const G4String&
name,
231 G4int index = fH1Vector.size();
232 fH1Vector.push_back(h1d);
254 = CreateToolsH1(title, nbins, xmin, xmax, fcnName, binSchemeName);
257 AddH1Annotation(h1d, unitName, fcnName);
261 AddH1Information(name, unitName, fcnName, binScheme);
264 G4int id = RegisterToolsH1(h1d, name);
275 const std::vector<G4double>& edges,
283 = CreateToolsH1(title, edges, fcnName);
286 AddH1Annotation(h1d, unitName, fcnName);
292 G4int id = RegisterToolsH1(h1d, name);
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;
388 description <<
" id " <<
id <<
" value " <<
value;
398 std::map<G4String, G4int>::const_iterator it = fH1NameIdMap.find(name);
399 if ( it == fH1NameIdMap.end() ) {
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);
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 <<
").";
547 for (
G4int i=0; i<
G4int(fH1Vector.size()); ++i ) {
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;
586 for (it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
587 (*it)->add(*(*itw++));
600 G4bool finalResult =
true;
602 std::vector<tools::histo::h1d*>::iterator it;
603 for (it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
605 if ( ! result ) finalResult =
false;
614 return ! fH1Vector.size();
619 G4bool onlyIfActive)
const
621 return GetH1InFunction(
id,
"GetH1", warn, onlyIfActive);
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)
G4double G4NeutronHPJENDLHEData::G4double result
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)
subroutine title(NA, NB, NCA, NCB)
G4BinScheme GetBinScheme(const G4String &binSchemeName)
const XML_Char XML_Encoding * info
const XML_Char int const XML_Char * value
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