31#include "tools/histo/p2d"
44 const std::array<G4HnDimension, kDim3>& bins,
45 const std::array<G4HnDimensionInformation, kDim3>& hnInfo)
48 auto newXBins(bins[
kX]);
50 auto newYBins(bins[
kY]);
52 auto newZBins(bins[
kZ]);
57 if ( newZBins.fMinValue == 0. && newZBins.fMaxValue == 0.) {
58 return new tools::histo::p2d(
59 title, newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
60 newYBins.fNBins, newYBins.fMinValue, newYBins.fMaxValue);
62 return new tools::histo::p2d(
63 title, newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
64 newYBins.fNBins, newYBins.fMinValue, newYBins.fMaxValue,
65 newZBins.fMinValue, newZBins.fMaxValue);
68 if ( newZBins.fMinValue == 0. && newZBins.fMaxValue == 0.) {
69 return new tools::histo::p2d(title, newXBins.fEdges, newYBins.fEdges);
71 return new tools::histo::p2d(title, newXBins.fEdges, newYBins.fEdges,
72 newZBins.fMinValue, newZBins.fMaxValue);
78 tools::histo::p2d* ht,
79 const std::array<G4HnDimension, kDim3>& bins,
80 const std::array<G4HnDimensionInformation, kDim3>& hnInfo)
83 auto newXBins(bins[
kX]);
85 auto newYBins(bins[
kY]);
87 auto newZBins(bins[
kZ]);
92 if ( newZBins.fMinValue == 0. && newZBins.fMaxValue == 0.) {
94 newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
95 newYBins.fNBins, newYBins.fMinValue, newYBins.fMaxValue);
99 newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
100 newYBins.fNBins, newYBins.fMinValue, newYBins.fMaxValue,
101 newZBins.fMinValue, newZBins.fMaxValue);
105 if ( newZBins.fMinValue == 0. && newZBins.fMaxValue == 0.) {
106 ht->configure(newXBins.fEdges, newYBins.fEdges);
110 ht->configure(newXBins.fEdges, newYBins.fEdges,
111 newZBins.fMinValue, newZBins.fMaxValue);
118 std::array<G4double, kDim3>& value,
G4double weight)
130 ht->fill(value[
kX], value[
kY], value[
kZ], weight);
138 std::ofstream& output)
143 if ( ! GetHnManager()->IsAscii() )
return true;
146 auto id = GetHnManager()->GetFirstId();
147 for (
const auto& [p2, info] : *GetTHnVector()) {
149 if ( (p2 ==
nullptr) || (! info->GetAscii()) ) {
156 Message(
kVL3,
"write on ascii",
"p2d", info->GetName());
158 output <<
"\n 2D profile " <<
id++ <<
": " << p2->title()
159 <<
"\n \n \t \t X \t\t Y \t\t MeanZ" <<
G4endl;
161 for (
G4int j=0; j<
G4int(p2->axis_x().bins()); ++j) {
162 for (
G4int k=0; k<
G4int(p2->axis_y().bins()); ++k) {
163 auto sw = p2->bin_Sw(j, k);
164 auto svw = p2->bin_Svw(j, k);
165 auto mean = ( sw != 0. ) ? (svw / sw) : 0.;
166 output <<
" " << j <<
"\t" << k <<
"\t"
167 << p2->axis_x().bin_center(j) <<
"\t"
168 << p2->axis_y().bin_center(k) <<
"\t"
174 return output.good();
void Update(G4double &value, const G4HnDimensionInformation &hnInfo)
void UpdateValues(G4HnDimension &bins, const G4HnDimensionInformation &hnInfo)