34#include "tools/histo/p1d"
41const G4int G4P1ToolsManager::kDimension = 1;
76void AddP1Annotation(tools::histo::p1d* p1d,
86 p1d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
87 p1d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
91tools::histo::p1d* CreateToolsP1(
const G4String& title,
112 <<
" User binning scheme setting was ignored." <<
G4endl
113 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
117 if ( ymin == 0. && ymax == 0.) {
118 return new tools::histo::p1d(title,
119 nbins, xfcn(xmin/xunit), xfcn(xmax/xunit));
121 return new tools::histo::p1d(title,
122 nbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
123 yfcn(ymin/yunit), yfcn(ymax/yunit));
128 std::vector<G4double> edges;
129 ComputeEdges(nbins, xmin, xmax, xunit, xfcn, xbinScheme, edges);
130 if ( ymin == 0. && ymax == 0.) {
131 return new tools::histo::p1d(title, edges);
133 return new tools::histo::p1d(title, edges, yfcn(ymin/yunit), yfcn(ymax/yunit));
139tools::histo::p1d* CreateToolsP1(
const G4String& title,
140 const std::vector<G4double>& edges,
153 std::vector<G4double> newEdges;
156 return new tools::histo::p1d(title, newEdges, yfcn(ymin/yunit), yfcn(ymax/yunit));
160void ConfigureToolsP1(tools::histo::p1d* p1d,
181 <<
" User binning scheme setting was ignored." <<
G4endl
182 <<
" Linear binning will be applied with given (nbins, xmin, xmax) values";
186 if ( ymin == 0. && ymax == 0. ) {
187 p1d->configure(nbins, xfcn(xmin/xunit), xfcn(xmax/xunit));
189 p1d->configure(nbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
190 yfcn(ymin/yunit), yfcn(ymax/yunit));
195 std::vector<G4double> edges;
196 ComputeEdges(nbins, xmin, xmax, xunit, xfcn, xbinScheme, edges);
197 if ( ymin == 0. && ymax == 0. ) {
198 p1d->configure(edges);
200 p1d->configure(edges, yfcn(ymin/yunit), yfcn(ymax/yunit));
206void ConfigureToolsP1(tools::histo::p1d* p1d,
207 const std::vector<G4double>& edges,
219 std::vector<G4double> newEdges;
222 if ( ymin == 0. && ymax == 0. ) {
223 p1d->configure(newEdges);
225 p1d->configure(newEdges, yfcn(ymin/yunit), yfcn(ymax/yunit));
236void G4P1ToolsManager::AddP1Information(
const G4String& name,
243 auto hnInformation =
fHnManager->AddHnInformation(name, 2);
244 hnInformation->
AddDimension(xunitName, xfcnName, xbinScheme);
245 hnInformation->
AddDimension(yunitName, yfcnName, G4BinScheme::kLinear);
264 tools::histo::p1d* p1d
265 = CreateToolsP1(title, nbins, xmin, xmax, ymin, ymax,
266 xunitName, yunitName, xfcnName, yfcnName,
270 AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
275 name, xunitName, yunitName, xfcnName, yfcnName, xbinScheme);
289 const std::vector<G4double>& edges,
298 tools::histo::p1d* p1d
299 = CreateToolsP1(title, edges, ymin, ymax,
300 xunitName, yunitName, xfcnName, yfcnName);
303 AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
307 name, xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser);
328 if ( ! p1d )
return false;
330 auto info =
fHnManager->GetHnInformation(
id,
"SetP1");
338 p1d, nbins, xmin, xmax, ymin, ymax,
339 xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName);
342 AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
347 info, xunitName, yunitName, xfcnName, yfcnName, xbinScheme);
357 const std::vector<G4double>& edges,
363 if ( ! p1d )
return false;
365 auto info =
fHnManager->GetHnInformation(
id,
"SetP1");
372 ConfigureToolsP1(p1d, edges, ymin, ymax,
373 xunitName, yunitName, xfcnName, yfcnName);
376 AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
380 info, xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser);
393 if ( ! p1d )
return false;
395 return p1d->scale(factor);
403 if ( ! p1d )
return false;
411 =
fHnManager->GetHnDimensionInformation(
id,
kX,
"FillP1");
413 =
fHnManager->GetHnDimensionInformation(
id,
kY,
"FillP1");
415 p1d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
416 yInfo->fFcn(yvalue/yInfo->fUnit), weight);
421 description <<
" id " <<
id
422 <<
" xvalue " << xvalue
423 <<
" xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
424 <<
" yvalue " << yvalue
425 <<
" yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
426 <<
" weight " << weight;
436 return GetTId(name, warn);
443 if ( ! p1d )
return 0;
454 if ( ! p1d )
return 0.;
463 if ( ! p1d )
return 0.;
472 if ( ! p1d )
return 0.;
483 if ( ! p1d )
return 0.;
492 if ( ! p1d )
return 0.;
501 if ( ! p1d )
return false;
510 if ( ! p1d )
return false;
519 if ( ! p1d )
return false;
528 if ( ! p1d )
return "";
538 if ( ! p1d )
return "";
547 if ( ! p1d )
return "";
565 AddP1Annotation(p1d,
"none",
"none",
"none",
"none");
567 AddP1Information(name,
"none",
"none",
"none",
"none", G4BinScheme::kLinear);
581 const std::vector<tools::histo::p1d*>& p1Vector)
588 G4bool onlyIfActive)
const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
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::p1d * > &tVector)
G4int RegisterT(tools::histo::p1d *t, const G4String &name)
std::shared_ptr< G4HnManager > fHnManager
tools::histo::p1d * 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)