31#include "tools/histo/h3d"
44 const std::array<G4HnDimension, 3>& bins,
45 const std::array<G4HnDimensionInformation, 3>& hnInfo)
48 auto newXBins(bins[
kX]);
50 auto newYBins(bins[
kY]);
52 auto newZBins(bins[
kZ]);
58 return new tools::histo::h3d(title,
59 newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
60 newYBins.fNBins, newYBins.fMinValue, newYBins.fMaxValue,
61 newZBins.fNBins, newZBins.fMinValue, newZBins.fMaxValue);
64 return new tools::histo::h3d(title,
65 newXBins.fEdges, newYBins.fEdges, newZBins.fEdges);
71 tools::histo::h3d* ht,
72 const std::array<G4HnDimension, 3>& bins,
73 const std::array<G4HnDimensionInformation, 3>& hnInfo)
76 auto newXBins(bins[
kX]);
78 auto newYBins(bins[
kY]);
80 auto newZBins(bins[
kZ]);
87 newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
88 newYBins.fNBins, newYBins.fMinValue, newYBins.fMaxValue,
89 newZBins.fNBins, newZBins.fMinValue, newZBins.fMaxValue);
93 ht->configure(newXBins.fEdges, newYBins.fEdges, newZBins.fEdges);
100 std::array<G4double, 3>& value,
G4double weight)
112 ht->fill(value[
kX], value[
kY], value[
kZ], weight);
120 std::ofstream& output)
127 if ( ! GetHnManager()->IsAscii() )
return true;
130 auto id = GetHnManager()->GetFirstId();
131 for (
const auto& [h3, info] : *GetTHnVector()) {
133 if ( ! info->GetAscii() ) {
139 Message(
kVL3,
"write on ascii",
"h3d", info->GetName());
141 output <<
"\n 3D histogram " <<
id++ <<
": " << h3->title()
142 <<
"\n \n \t \t \t X \t\t Y \t\t Z \t\t Bin Height" <<
G4endl;
144 for (
G4int j=0; j<
G4int(h3->axis_x().bins()); ++j) {
145 for (
G4int k=0; k<
G4int(h3->axis_y().bins()); ++k) {
146 for (
G4int l=0; l<
G4int(h3->axis_y().bins()); ++l) {
147 output <<
" " << j <<
"\t" << k <<
"\t" << l <<
"\t"
148 << h3->axis_x().bin_center(j) <<
"\t"
149 << h3->axis_y().bin_center(k) <<
"\t"
150 << h3->axis_y().bin_center(l) <<
"\t"
151 << h3->bin_height(j, k, l) <<
G4endl;
157 return output.good();
void Update(G4double &value, const G4HnDimensionInformation &hnInfo)