34#include "tools/histo/h2d"
77 h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
78 h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
106 Warn(
"User binning scheme setting was ignored.\n"
107 "Linear binning will be applied with given (nbins, xmin, xmax) values.",
110 return new tools::histo::h2d(title,
111 nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
112 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
118 std::vector<G4double> xedges;
119 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
120 std::vector<G4double> yedges;
121 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
122 return new tools::histo::h2d(title, xedges, yedges);
129 const std::vector<G4double>& xedges,
130 const std::vector<G4double>& yedges,
142 std::vector<G4double> xnewEdges;
144 std::vector<G4double> ynewEdges;
147 return new tools::histo::h2d(title, xnewEdges, ynewEdges);
175 Warn(
"User binning scheme setting was ignored.\n"
176 "Linear binning will be applied with given (nbins, xmin, xmax) values.",
179 h2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
180 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
184 std::vector<G4double> xedges;
185 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
186 std::vector<G4double> yedges;
187 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
188 h2d->configure(xedges, yedges);
194 const std::vector<G4double>& xedges,
195 const std::vector<G4double>& yedges,
203 std::vector<G4double> xnewEdges;
208 std::vector<G4double> ynewEdges;
211 h2d->configure(xnewEdges, ynewEdges);
231 hnInformation->AddDimension(xunitName, xfcnName, xbinScheme);
232 hnInformation->AddDimension(yunitName, yfcnName, ybinScheme);
251 tools::histo::h2d* h2d
252 =
CreateToolsH2(title, nxbins, xmin, xmax, nybins, ymin, ymax,
253 xunitName, yunitName, xfcnName, yfcnName,
254 xbinSchemeName, ybinSchemeName,
fkClass);
263 name, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
275 const std::vector<G4double>& xedges,
276 const std::vector<G4double>& yedges,
283 tools::histo::h2d* h2d
285 xunitName, yunitName, xfcnName, yfcnName);
312 if ( ! h2d )
return false;
314 auto info =
fHnManager->GetHnInformation(
id,
"SetH2");
320 h2d, nxbins, xmin, xmax, nybins, ymin, ymax,
321 xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName, ybinSchemeName,
331 info, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
341 const std::vector<G4double>& xedges,
342 const std::vector<G4double>& yedges,
347 if ( ! h2d )
return false;
349 auto info =
fHnManager->GetHnInformation(
id,
"SetH2");
354 ConfigureToolsH2(h2d, xedges, yedges, xunitName, yunitName, xfcnName, yfcnName);
373 if ( ! h2d )
return false;
375 return h2d->scale(factor);
384 if ( ! h2d )
return false;
391 =
fHnManager->GetHnDimensionInformation(
id,
kX,
"FillH2");
393 =
fHnManager->GetHnDimensionInformation(
id,
kY,
"FillH2");
395 h2d->fill(xInfo->
fFcn(xvalue/xInfo->
fUnit),
396 yInfo->
fFcn(yvalue/yInfo->
fUnit), weight);
400 " id " + to_string(
id) +
401 " xvalue " + to_string(xvalue) +
402 " xfcn(xvalue/xunit) " + to_string(xInfo->
fFcn(xvalue/xInfo->
fUnit)) +
403 " yvalue " + to_string(yvalue) +
404 " yfcn(yvalue/yunit) " + to_string(yInfo->
fFcn(yvalue/yInfo->
fUnit)) +
405 " weight " + to_string(weight));
421 if ( ! h2d )
return 0;
432 if ( ! h2d )
return 0.;
441 if ( ! h2d )
return 0.;
450 if ( ! h2d )
return 0.;
459 if ( ! h2d )
return 0;
470 if ( ! h2d )
return 0.;
479 if ( ! h2d )
return 0.;
488 if ( ! h2d )
return 0.;
497 if ( ! h2d )
return false;
506 if ( ! h2d )
return false;
515 if ( ! h2d )
return false;
524 if ( ! h2d )
return false;
533 if ( ! h2d )
return "";
542 if ( ! h2d )
return "";
551 if ( ! h2d )
return "";
560 if ( ! h2d )
return "";
576 auto info =
fHnManager->GetHnInformation(
id,
"WriteOnAscii");
578 if ( ! info->GetAscii() )
continue;
581 Message(
kVL3,
"write on ascii",
"h2d", info->GetName());
583 output <<
"\n 2D histogram " <<
id <<
": " << h2->title()
584 <<
"\n \n \t \t X \t\t Y \t\t Bin Height" <<
G4endl;
586 for (
G4int j=0; j<
G4int(h2->axis_x().bins()); ++j) {
587 for (
G4int k=0; k<
G4int(h2->axis_y().bins()); ++k) {
588 output <<
" " << j <<
"\t" << k <<
"\t"
589 << h2->axis_x().bin_center(j) <<
"\t"
590 << h2->axis_y().bin_center(k) <<
"\t"
591 << h2->bin_height(j, k) <<
G4endl;
596 return output.good();
624 const std::vector<tools::histo::h2d*>& h2Vector)
630 G4bool onlyIfActive)
const
G4bool GetIsActivation() const
std::vector< tools::histo::h2d * > fTVector
tools::histo::h2d * GetTInFunction(G4int id, std::string_view functionName, G4bool warn=true, G4bool onlyIfActive=true) const
const G4AnalysisManagerState & fState
G4int GetTId(const G4String &name, G4bool warn=true) const
G4int RegisterT(tools::histo::h2d *t, const G4String &name)
void AddTVector(const std::vector< tools::histo::h2d * > &tVector)
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
std::shared_ptr< G4HnManager > fHnManager
G4bool IsVerbose(G4int verboseLevel) 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)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
G4Fcn GetFunction(const G4String &fcnName)
const char * name(G4int ptype)