BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
HistogramAccumulator.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef HISTOGRAMACCUMULATOR_H
19#define HISTOGRAMACCUMULATOR_H
20
21#include <string>
22
23#include "Rtypes.h" // for classdef
24
25class TH1;
26
57{
58public:
61
65 HistogramAccumulator(TH1* baseHistogram,
66 const std::string& resultHistNameIn,
67 const std::string& resultHistTitleIn);
68
72 HistogramAccumulator(TH1* baseHistogram,
73 int nDimensionsIn,
74 const std::string& resultHistName,
75 const std::string& resultHistTitle);
76
79 virtual ~HistogramAccumulator();
80
84 virtual void Accumulate(TH1* newValue);
85
88 virtual TH1* Terminate();
89
91 inline TH1* Result() const {return result;}
92
95 inline void AddNEmptyEntries(unsigned long i){n += i;}
96
98 inline unsigned long N() const {return n;}
99
100protected:
106 virtual void AccumulateSingleValue(double oldMean,
107 double oldVari,
108 double x,
109 double xVari,
110 unsigned long nEntriesAccumulated,
111 unsigned long nEntriesToAccumulate,
112 double& newMean,
113 double& newVari) const;
114
116 unsigned long n;
118 const std::string resultHistName;
119 const std::string resultHistTitle;
120 TH1* mean;
121 TH1* variance;
122 TH1* result;
123
124 ClassDef(HistogramAccumulator,1);
125};
126
127#endif
Class to accumulate and merge histograms in different ways.
const std::string resultHistName
Name for resultant histogram.
unsigned long N() const
Access currently accumulated number of entries.
int nDimensions
Number of dimensions.
virtual void AccumulateSingleValue(double oldMean, double oldVari, double x, double xVari, unsigned long nEntriesAccumulated, unsigned long nEntriesToAccumulate, double &newMean, double &newVari) const
bool terminated
Whether this instance has been finished.
const std::string resultHistTitle
Title for resultant histogram.
unsigned long n
Counter.
void AddNEmptyEntries(unsigned long i)
HistogramAccumulator()
Default constructor only for ROOT reflexivity - not intended for use.
virtual void Accumulate(TH1 *newValue)
TH1 * Result() const
Accessor.