-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathThetaHistogram.cpp
More file actions
38 lines (34 loc) · 896 Bytes
/
Copy pathThetaHistogram.cpp
File metadata and controls
38 lines (34 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "ThetaHistogram.h"
#include "utilities.h"
ThetaHistogram::ThetaHistogram(const ThetaModel * const thetamodel, int bins, double min, double max)
: thetamodel_(thetamodel), bins_(bins), min_(min), max_(max)
{
histogram_.resize(bins,0);
measurements_=0;
}
ThetaHistogram::~ThetaHistogram(void)
{
}
void ThetaHistogram::Measure()
{
for(int i=0,end=thetamodel_->getSize();i<end;i++)
{
for(int j=0;j<3;j++)
{
int val = (int)(bins_*(thetamodel_->getRealTheta(i,j)-min_)/(max_-min_));
if( val >= 0 && val < bins_ )
{
histogram_[val]++;
}
}
}
measurements_++;
}
std::string ThetaHistogram::OutputData() const
{
std::ostringstream stream;
stream << "thetahistogram -> {measurements -> " << measurements_ << ", histogram -> ";
PrintToStream(stream,histogram_.begin(),histogram_.end());
stream << "}";
return stream.str();
}