31#include "tools/histo/h2d"
44 const std::array<G4HnDimension, kDim2>& bins,
45 const std::array<G4HnDimensionInformation, kDim2>& 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, kDim2>& bins,
68 const std::array<G4HnDimensionInformation, kDim2>& 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, kDim2>& 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 ( (h2 ==
nullptr) || (! info->GetAscii()) ) {
129 Message(
kVL3,
"write on ascii",
"h2d", info->GetName());
131 output <<
"\n 2D histogram " <<
id++ <<
": " << h2->title()
132 <<
"\n \n \t \t X \t\t Y \t\t Bin Height" <<
G4endl;
134 for (
G4int j=0; j<
G4int(h2->axis_x().bins()); ++j) {
135 for (
G4int k=0; k<
G4int(h2->axis_y().bins()); ++k) {
136 output <<
" " << j <<
"\t" << k <<
"\t"
137 << h2->axis_x().bin_center(j) <<
"\t"
138 << h2->axis_y().bin_center(k) <<
"\t"
139 << h2->bin_height(j, k) <<
G4endl;
144 return output.good();
void Update(G4double &value, const G4HnDimensionInformation &hnInfo)