31#include "tools/histo/h2d"
44 const std::array<G4HnDimension, 2>& bins,
45 const std::array<G4HnDimensionInformation, 2>& hnInfo)
48 auto newXBins(bins[
kX]);
50 auto newYBins(bins[
kY]);
55 return new tools::histo::h2d(title,
56 newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
57 newYBins.fNBins, newYBins.fMinValue, newYBins.fMaxValue);
60 return new tools::histo::h2d(title, newXBins.fEdges, newYBins.fEdges);
66 tools::histo::h2d* ht,
67 const std::array<G4HnDimension, 2>& bins,
68 const std::array<G4HnDimensionInformation, 2>& hnInfo)
71 auto newXBins(bins[
kX]);
73 auto newYBins(bins[
kY]);
79 newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
80 newYBins.fNBins, newYBins.fMinValue, newYBins.fMaxValue);
84 ht->configure(newXBins.fEdges, newYBins.fEdges);
91 std::array<G4double, 2>& value,
G4double weight)
101 ht->fill(value[
kX], value[
kY], weight);
109 std::ofstream& output)
116 if ( ! GetHnManager()->IsAscii() )
return true;
119 auto id = GetHnManager()->GetFirstId();
120 for (
const auto& [h2, info] : *GetTHnVector()) {
122 if ( ! info->GetAscii() ) {
128 Message(
kVL3,
"write on ascii",
"h2d", info->GetName());
130 output <<
"\n 2D histogram " <<
id++ <<
": " << h2->title()
131 <<
"\n \n \t \t X \t\t Y \t\t Bin Height" <<
G4endl;
133 for (
G4int j=0; j<
G4int(h2->axis_x().bins()); ++j) {
134 for (
G4int k=0; k<
G4int(h2->axis_y().bins()); ++k) {
135 output <<
" " << j <<
"\t" << k <<
"\t"
136 << h2->axis_x().bin_center(j) <<
"\t"
137 << h2->axis_y().bin_center(k) <<
"\t"
138 << h2->bin_height(j, k) <<
G4endl;
143 return output.good();
void Update(G4double &value, const G4HnDimensionInformation &hnInfo)