9 #include <utl/TimeDistributionAlgorithm.h>
10 #include <utl/TimeDistribution.h>
12 #include <utl/ErrorLogger.h>
24 const int rangeStart =
max(td.
GetStart(), min(bin1, bin2));
25 const int rangeStop = min(td.
GetStop(),
max(bin1, bin2));
27 if (td.
fData.find(rangeStart) == td.
fData.end() ||
33 const TDCIt mStop = ++(td.
fData.find(rangeStop));
34 for (TDCIt mIt = td.
fData.find(rangeStart); mIt != mStop; ++mIt)
45 return Sum(td, bin1, bin2) / (
abs(bin2 - bin1) + 1);
53 const int rangeStart =
max(td.
GetStart(), min(bin1, bin2));
54 const int rangeStop = min(td.
GetStop(),
max(bin1, bin2));
56 if (td.
fData.find(rangeStart) == td.
fData.end() ||
63 for (
int i = rangeStart; i <= rangeStop; ++i) {
64 const double slotContents = td.
At(i);
66 v2 += slotContents * slotContents;
68 const int n =
abs(bin2 - bin1) + 1;
72 return sqrt(v2 - v*v);
80 const int rangeStart =
max(td.
GetStart(), min(bin1, bin2));
81 const int rangeStop = min(td.
GetStop(),
max(bin1, bin2));
83 if (td.
fData.find(rangeStart) == td.
fData.end() ||
90 for (
int i = rangeStart; i <= rangeStop; ++i) {
91 const double slotContents = td.
At(i);
93 v2 += slotContents * slotContents;
95 const int n =
abs(bin2 - bin1) + 1;
107 const int rangeStart =
max(td.
GetStart(), min(bin1, bin2));
108 const int rangeStop = min(td.
GetStop(),
max(bin1, bin2));
109 if (td.
fData.find(rangeStart) == td.
fData.end() ||
115 for (
int i = rangeStart; i <= rangeStop; ++i) {
116 const double slotContent = td.
At(i);
118 val += slotContent * i;
127 template double TimeDistributionAlgorithm::Sum(const TimeDistribution<T>& td, const int bin1, const int bin2); \
128 template double TimeDistributionAlgorithm::Mean(const TimeDistribution<T>& td, const int bin1, const int bin2); \
129 template double TimeDistributionAlgorithm::RMS(const TimeDistribution<T>& td, const int bin1, const int bin2); \
130 template TimeDistributionAlgorithm::TupleD TimeDistributionAlgorithm::MeanRMS(const TimeDistribution<T>& td, const int bin1, const int bin2); \
131 template double TimeDistributionAlgorithm::Centroid(const TimeDistribution<T>& td, const int bin1, const int bin2)
T At(const double time) const
int GetStart() const
First slot with data.
static double RMS(const TimeDistribution< T > &td, const int bin1, const int bin2)
Evalueate RMS of TimeDistribution between bin1 and bin2.
boost::tuple< double, double > TupleD
Histogram class for time distributions with suppressed empty bins.
InternalMap::const_iterator InternalConstIterator
double abs(const SVector< n, T > &v)
int GetStop() const
Last slot with data (1 less than First slot if no data)
static TupleD MeanRMS(const TimeDistribution< T > &td, const int bin1, const int bin2)
Evalueate both mean and RMS of TimeDistribution between bin1 and bin2.
static double Centroid(const TimeDistribution< T > &td, const int bin1, const int bin2)
Evaluate the centroid in slot number between bin1 and bin2.
static double Sum(const TimeDistribution< T > &td, const int bin1, const int bin2)
Evaluate the sum of bin1 through bin2.
static double Mean(const TimeDistribution< T > &td, const int bin1, const int bin2)
Evaluate mean of TimeDistribution between bin1 and bin2.