36 #include "tools/histo/h1d"
49 fBaseToolsManager(
"H1"),
58 std::vector<tools::histo::h1d*>::iterator it;
82 information->
fUnit = unit;
83 information->
fFcn = fcn;
88 void AddH1Annotation(tools::histo::h1d* h1d,
94 h1d->add_annotation(tools::histo::key_axis_x_title(), axisTitle);
98 tools::histo::h1d* CreateToolsH1(
const G4String& title,
114 <<
" User binning scheme setting was ignored." <<
G4endl
115 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
119 return new tools::histo::h1d(title, nbins, fcn(xmin/unit), fcn(xmax/unit));
123 std::vector<G4double> edges;
124 ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
125 return new tools::histo::h1d(title, edges);
130 tools::histo::h1d* CreateToolsH1(
const G4String& title,
131 const std::vector<G4double>& edges,
139 std::vector<G4double> newEdges;
142 return new tools::histo::h1d(title, newEdges);
146 void ConfigureToolsH1(tools::histo::h1d* h1d,
162 <<
" User binning scheme setting was ignored." <<
G4endl
163 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
167 h1d->configure(nbins, fcn(xmin/unit), fcn(xmax/unit));
171 std::vector<G4double> edges;
172 ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
173 h1d->configure(edges);
178 void ConfigureToolsH1(tools::histo::h1d* h1d,
179 const std::vector<G4double>& edges,
186 std::vector<G4double> newEdges;
189 h1d->configure(newEdges);
201 G4bool onlyIfActive)
const
206 G4String inFunction =
"G4H1ToolsManager::";
207 inFunction += functionName;
209 description <<
" " <<
"histogram " <<
id <<
" does not exist.";
262 tools::histo::h1d* h1d
263 = CreateToolsH1(title, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
266 AddH1Annotation(h1d, unitName, fcnName);
284 const std::vector<G4double>& edges,
291 tools::histo::h1d* h1d
292 = CreateToolsH1(title, edges, unitName, fcnName);
295 AddH1Annotation(h1d, unitName, fcnName);
317 if ( ! h1d )
return false;
326 ConfigureToolsH1(h1d, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
329 AddH1Annotation(h1d, unitName, fcnName);
333 UpdateH1Information(info, unitName, fcnName, binScheme);
343 const std::vector<G4double>& edges,
348 if ( ! h1d )
return false;
357 ConfigureToolsH1(h1d, edges, unitName, fcnName);
360 AddH1Annotation(h1d, unitName, fcnName);
376 if ( ! h1d )
return false;
378 return h1d->scale(factor);
385 if ( ! h1d )
return false;
394 h1d->fill(info->
fFcn(value/info->
fUnit), weight);
398 description <<
" id " <<
id <<
" value " << value
399 <<
" fcn(value/unit) " << info->
fFcn(value/info->
fUnit)
400 <<
" weight " << weight;
410 std::map<G4String, G4int>::const_iterator it =
fH1NameIdMap.find(name);
413 G4String inFunction =
"G4H1ToolsManager::GetH1Id";
415 description <<
" " <<
"histogram " << name <<
" does not exist.";
427 if ( ! h1d )
return 0;
438 if ( ! h1d )
return 0;
447 if ( ! h1d )
return 0;
455 tools::histo::h1d* h1d =
GetH1InFunction(
id,
"GetH1XWidth",
true,
false);
456 if ( ! h1d )
return 0;
465 if ( ! h1d )
return false;
474 if ( ! h1d )
return false;
483 if ( ! h1d )
return false;
492 if ( ! h1d )
return "";
502 if ( ! h1d )
return "";
511 if ( ! h1d )
return "";
536 output <<
"\n 1D histogram " <<
id <<
": " << h1->title()
537 <<
"\n \n \t X \t\t Y" <<
G4endl;
539 for (
G4int j=0; j<
G4int(h1->axis().bins()); ++j) {
540 output <<
" " << j <<
"\t"
541 << h1->axis().bin_center(j) <<
"\t"
542 << h1->bin_height(j) <<
G4endl;
562 AddH1Annotation(h1d,
"none",
"none");
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 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)
static const G4double factor
G4Fcn GetFunction(const G4String &fcnName)
G4BinScheme GetBinScheme(const G4String &binSchemeName)
G4bool GetIsActivation() const
const G4AnalysisVerbose * GetVerboseL1() const
void SetActivation(G4bool activation)
const G4AnalysisManagerState & fState
G4HnDimensionInformation * GetHnDimensionInformation(G4int id, G4int dimension, G4String functionName="", G4bool warn=true) const