31#include "tools/histo/p1d"
44 const std::array<G4HnDimension, kDim2>& bins,
45 const std::array<G4HnDimensionInformation, kDim2>& hnInfo)
48 auto newXBins(bins[
kX]);
50 auto newYBins(bins[
kY]);
54 if ( newYBins.fMinValue == 0. && newYBins.fMaxValue == 0.) {
55 return new tools::histo::p1d(
56 title, newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue);
58 return new tools::histo::p1d(
59 title, newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
60 newYBins.fMinValue, newYBins.fMaxValue);
63 if ( newYBins.fMinValue == 0. && newYBins.fMaxValue == 0.) {
64 return new tools::histo::p1d(title, newXBins.fEdges);
67 return new tools::histo::p1d(title, newXBins.fEdges,
68 newYBins.fMinValue, newYBins.fMaxValue);
74 tools::histo::p1d* ht,
75 const std::array<G4HnDimension, kDim2>& bins,
76 const std::array<G4HnDimensionInformation, kDim2>& hnInfo)
79 auto newXBins(bins[
kX]);
81 auto newYBins(bins[
kY]);
85 if ( newYBins.fMinValue == 0. && newYBins.fMaxValue == 0.) {
87 newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue);
91 newXBins.fNBins, newXBins.fMinValue, newXBins.fMaxValue,
92 newYBins.fMinValue, newYBins.fMaxValue);
96 if ( newYBins.fMinValue == 0. && newYBins.fMaxValue == 0.) {
97 ht->configure(newXBins.fEdges);
100 ht->configure(newXBins.fEdges, newYBins.fMinValue, newYBins.fMaxValue);
108 std::array<G4double, kDim2>& value,
G4double weight)
118 ht->fill(value[
kX], value[
kY], weight);
126 std::ofstream& output)
131 if ( ! GetHnManager()->IsAscii() )
return true;
134 auto id = GetHnManager()->GetFirstId();
135 for (
const auto& [p1, info] : *GetTHnVector()) {
137 if ( (p1 ==
nullptr) || (! info->GetAscii()) ) {
144 Message(
kVL3,
"write on ascii",
"p1d", info->GetName());
146 output <<
"\n 1D profile " <<
id++ <<
": " << p1->title()
147 <<
"\n \n \t \t X \t\t MeanY" <<
G4endl;
149 for (
G4int j=0; j<
G4int(p1->axis().bins()); ++j) {
150 auto sw = p1->bin_Sw(j);
151 auto svw = p1->bin_Svw(j);
152 auto mean = ( sw != 0. ) ? (svw / sw) : 0.;
153 output <<
" " << j <<
"\t"
154 << p1->axis().bin_center(j) <<
"\t"
159 return output.good();
void Update(G4double &value, const G4HnDimensionInformation &hnInfo)
void UpdateValues(G4HnDimension &bins, const G4HnDimensionInformation &hnInfo)