34#include "tools/histo/p2d"
84 p2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
85 p2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
86 p2d->add_annotation(tools::histo::key_axis_z_title(), zaxisTitle);
118 Warn(
"User binning scheme setting was ignored.\n"
119 "Linear binning will be applied with given (nbins, xmin, xmax) values.",
122 if ( zmin == 0. && zmax == 0.) {
123 return new tools::histo::p2d(title,
124 nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
125 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
129 return new tools::histo::p2d(title,
130 nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
131 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
132 zfcn(zmin/zunit), zfcn(zmax/zunit));
139 std::vector<G4double> xedges;
140 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
141 std::vector<G4double> yedges;
142 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
143 if ( zmin == 0. && zmax == 0.) {
144 return new tools::histo::p2d(title, xedges, yedges);
146 return new tools::histo::p2d(title, xedges, yedges,
147 zfcn(zmin/zunit), zfcn(zmax/zunit));
155 const std::vector<G4double>& xedges,
156 const std::vector<G4double>& yedges,
173 std::vector<G4double> xnewEdges;
175 std::vector<G4double> ynewEdges;
178 if ( zmin == 0. && zmax == 0.) {
179 return new tools::histo::p2d(title, xnewEdges, ynewEdges);
183 return new tools::histo::p2d(title, xnewEdges, ynewEdges,
184 zfcn(zmin/zunit), zfcn(zmax/zunit));
218 Warn(
"User binning scheme setting was ignored.\n"
219 "Linear binning will be applied with given (nbins, xmin, xmax) values.",
222 if ( zmin == 0. && zmax == 0. ) {
223 p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
224 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
226 p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
227 nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
228 zfcn(zmin/zunit), zfcn(zmax/zunit));
233 std::vector<G4double> xedges;
234 ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
235 std::vector<G4double> yedges;
236 ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
237 if ( zmin == 0. && zmax == 0. ) {
238 p2d->configure(xedges, yedges);
240 p2d->configure(xedges, yedges, zfcn(zmin/zunit), zfcn(zmax/zunit));
247 const std::vector<G4double>& xedges,
248 const std::vector<G4double>& yedges,
260 std::vector<G4double> xnewEdges;
265 std::vector<G4double> ynewEdges;
270 if ( zmin == 0. && zmax == 0. ) {
271 p2d->configure(xnewEdges, ynewEdges);
273 p2d->configure(xnewEdges, ynewEdges, zfcn(zmin/zunit), zfcn(zmax/zunit));
296 hnInformation->AddDimension(xunitName, xfcnName, xbinScheme);
297 hnInformation->AddDimension(yunitName, yfcnName, ybinScheme);
320 tools::histo::p2d* p2d
322 nxbins, xmin, xmax, nybins, ymin, ymax, zmin, zmax,
323 xunitName, yunitName, zunitName,
324 xfcnName, yfcnName, zfcnName,
325 xbinSchemeName, ybinSchemeName,
fkClass);
329 xfcnName, yfcnName, zfcnName);
335 name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
336 xbinScheme, ybinScheme);
348 const std::vector<G4double>& xedges,
349 const std::vector<G4double>& yedges,
359 tools::histo::p2d* p2d
361 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
365 p2d, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
369 name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
393 if ( ! p2d )
return false;
395 auto info =
fHnManager->GetHnInformation(
id,
"SetP2");
401 p2d, nxbins, xmin, xmax, nybins, ymin, ymax, zmin, zmax,
402 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
403 xbinSchemeName, ybinSchemeName,
fkClass);
407 xfcnName, yfcnName, zfcnName);
413 info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
414 xbinScheme, ybinScheme);
424 const std::vector<G4double>& xedges,
425 const std::vector<G4double>& yedges,
433 if ( ! p2d )
return false;
435 auto info =
fHnManager->GetHnInformation(
id,
"SetP2");
441 xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
445 xfcnName, yfcnName, zfcnName);
449 info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
462 if ( ! p2d )
return false;
464 return p2d->scale(factor);
473 if ( ! p2d )
return false;
480 =
fHnManager->GetHnDimensionInformation(
id,
kX,
"FillP2");
482 =
fHnManager->GetHnDimensionInformation(
id,
kY,
"FillP2");
484 =
fHnManager->GetHnDimensionInformation(
id,
kZ,
"FillP2");
486 p2d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
487 yInfo->fFcn(yvalue/yInfo->fUnit),
488 zInfo->fFcn(zvalue/zInfo->fUnit), weight);
492 " id " + to_string(
id) +
493 " xvalue " + to_string(xvalue) +
494 " xfcn(xvalue/xunit) " + to_string(xInfo->fFcn(xvalue/xInfo->fUnit)) +
495 " yvalue " + to_string(yvalue) +
496 " yfcn(yvalue/yunit) " + to_string(yInfo->fFcn(yvalue/yInfo->fUnit)) +
497 " zvalue " + to_string(zvalue) +
498 " zfcn(zvalue/zunit) " + to_string(zInfo->fFcn(zvalue/zInfo->fUnit)) +
499 " weight " + to_string(weight));
515 if ( ! p2d )
return 0;
526 if ( ! p2d )
return 0.;
535 if ( ! p2d )
return 0.;
544 if ( ! p2d )
return 0.;
553 if ( ! p2d )
return 0;
564 if ( ! p2d )
return 0.;
573 if ( ! p2d )
return 0.;
582 if ( ! p2d )
return 0.;
593 if ( ! p2d )
return 0.;
602 if ( ! p2d )
return 0.;
611 if ( ! p2d )
return false;
620 if ( ! p2d )
return false;
629 if ( ! p2d )
return false;
638 if ( ! p2d )
return false;
647 if ( ! p2d )
return "";
656 if ( ! p2d )
return "";
665 if ( ! p2d )
return "";
674 if ( ! p2d )
return "";
690 auto info =
fHnManager->GetHnInformation(
id,
"WriteOnAscii");
692 if ( ! info->GetAscii() )
continue;
695 Message(
kVL3,
"write on ascii",
"p2d", info->GetName());
697 output <<
"\n 2D profile " <<
id <<
": " << p2->title()
698 <<
"\n \n \t \t X \t\t Y \t\t MeanZ" <<
G4endl;
700 for (
G4int j=0; j<
G4int(p2->axis_x().bins()); ++j) {
701 for (
G4int k=0; k<
G4int(p2->axis_y().bins()); ++k) {
702 auto sw = p2->bin_Sw(j, k);
703 auto svw = p2->bin_Svw(j, k);
704 auto mean = ( sw != 0. ) ? (svw / sw) : 0.;
705 output <<
" " << j <<
"\t" << k <<
"\t"
706 << p2->axis_x().bin_center(j) <<
"\t"
707 << p2->axis_y().bin_center(k) <<
"\t"
713 return output.good();
741 const std::vector<tools::histo::p2d*>& p2Vector)
748 G4bool onlyIfActive)
const
G4bool GetIsActivation() const
std::vector< tools::histo::p2d * > fTVector
tools::histo::p2d * 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::p2d *t, const G4String &name)
void AddTVector(const std::vector< tools::histo::p2d * > &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)