34#include "tools/histo/h1d"
41const G4int G4H1ToolsManager::kDimension = 1;
74void AddH1Annotation(tools::histo::h1d* h1d,
80 h1d->add_annotation(tools::histo::key_axis_x_title(), axisTitle);
84tools::histo::h1d* CreateToolsH1(
const G4String& title,
100 <<
" User binning scheme setting was ignored." <<
G4endl
101 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
105 return new tools::histo::h1d(title, nbins, fcn(xmin/unit), fcn(xmax/unit));
109 std::vector<G4double> edges;
110 ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
111 return new tools::histo::h1d(title, edges);
116tools::histo::h1d* CreateToolsH1(
const G4String& title,
117 const std::vector<G4double>& edges,
125 std::vector<G4double> newEdges;
128 return new tools::histo::h1d(title, newEdges);
132void ConfigureToolsH1(tools::histo::h1d* h1d,
148 <<
" User binning scheme setting was ignored." <<
G4endl
149 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
153 h1d->configure(nbins, fcn(xmin/unit), fcn(xmax/unit));
157 std::vector<G4double> edges;
158 ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
159 h1d->configure(edges);
164void ConfigureToolsH1(tools::histo::h1d* h1d,
165 const std::vector<G4double>& edges,
172 std::vector<G4double> newEdges;
175 h1d->configure(newEdges);
185void G4H1ToolsManager::AddH1Information(
const G4String& name,
190 auto hnInformation =
fHnManager->AddHnInformation(name, kDimension);
191 hnInformation->
AddDimension(unitName, fcnName, binScheme);
211 = CreateToolsH1(title, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
214 AddH1Annotation(h1d, unitName, fcnName);
218 AddH1Information(name, unitName, fcnName, binScheme);
232 const std::vector<G4double>& edges,
240 = CreateToolsH1(title, edges, unitName, fcnName);
243 AddH1Annotation(h1d, unitName, fcnName);
246 AddH1Information(name, unitName, fcnName, G4BinScheme::kUser);
265 if ( ! h1d )
return false;
267 auto info =
fHnManager->GetHnInformation(
id,
"SetH1");
274 ConfigureToolsH1(h1d, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
277 AddH1Annotation(h1d, unitName, fcnName);
281 UpdateH1Information(info, unitName, fcnName, binScheme);
291 const std::vector<G4double>& edges,
296 if ( ! h1d )
return false;
298 auto info =
fHnManager->GetHnInformation(
id,
"SetH1");
305 ConfigureToolsH1(h1d, edges, unitName, fcnName);
308 AddH1Annotation(h1d, unitName, fcnName);
311 UpdateH1Information(info, unitName, fcnName, G4BinScheme::kUser);
324 if ( ! h1d )
return false;
326 return h1d->scale(factor);
333 if ( ! h1d )
return false;
341 =
fHnManager->GetHnDimensionInformation(
id,
kX,
"FillH1");
342 h1d->fill(info->fFcn(value/info->fUnit), weight);
346 description <<
" id " <<
id <<
" value " << value
347 <<
" fcn(value/unit) " << info->fFcn(value/info->fUnit)
348 <<
" weight " << weight;
358 return GetTId(name, warn);
365 if ( ! h1d )
return 0;
376 if ( ! h1d )
return 0.;
385 if ( ! h1d )
return 0.;
394 if ( ! h1d )
return 0.;
403 if ( ! h1d )
return false;
412 if ( ! h1d )
return false;
421 if ( ! h1d )
return false;
430 if ( ! h1d )
return "";
440 if ( ! h1d )
return "";
449 if ( ! h1d )
return "";
464 auto info =
fHnManager->GetHnInformation(
id,
"WriteOnAscii");
466 if ( ! info->GetAscii() )
continue;
474 output <<
"\n 1D histogram " <<
id <<
": " << h1->title()
475 <<
"\n \n \t X \t\t Y" <<
G4endl;
477 for (
G4int j=0; j<
G4int(h1->axis().bins()); ++j) {
478 output <<
" " << j <<
"\t"
479 << h1->axis().bin_center(j) <<
"\t"
480 << h1->bin_height(j) <<
G4endl;
500 AddH1Annotation(h1d,
"none",
"none");
502 AddH1Information(name,
"none",
"none", G4BinScheme::kLinear);
517 const std::vector<tools::histo::h1d*>& h1Vector)
524 G4bool onlyIfActive)
const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
const G4AnalysisVerbose * GetVerboseL3() const
const G4AnalysisVerbose * GetVerboseL2() const
G4bool GetIsActivation() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState
G4int GetTId(const G4String &name, G4bool warn=true) const
void AddTVector(const std::vector< tools::histo::h1d * > &tVector)
std::vector< tools::histo::h1d * > fTVector
G4int RegisterT(tools::histo::h1d *t, const G4String &name)
std::shared_ptr< G4HnManager > fHnManager
tools::histo::h1d * GetTInFunction(G4int id, G4String functionName, G4bool warn=true, G4bool onlyIfActive=true) const
G4int GetNbins(const G4ToolsBaseHisto &baseHisto, G4int dimension)
G4BinScheme GetBinScheme(const G4String &binSchemeName)
G4bool SetTitle(G4ToolsBaseHisto &baseHisto, const G4String &title)
G4double GetMin(const G4ToolsBaseHisto &baseHisto, G4int dimension)
G4double GetMax(const G4ToolsBaseHisto &baseHisto, G4int dimension)
G4double GetUnitValue(const G4String &unit)
void ComputeEdges(G4int nbins, G4double xmin, G4double xmax, G4double unit, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
G4bool SetAxisTitle(G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &title)
G4String GetAxisTitle(const G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &hnType)
G4double GetWidth(const G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &hnType)
void UpdateTitle(G4String &title, const G4String &unitName, const G4String &fcnName)
G4String GetTitle(const G4ToolsBaseHisto &baseHisto)
G4Fcn GetFunction(const G4String &fcnName)